ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/AE/Installer/trunk/source/main_window.cpp
(Generate patch)

Comparing AE/Installer/trunk/source/main_window.cpp (file contents):
Revision 324 by iritscen, Tue May 26 17:52:10 2009 UTC vs.
Revision 516 by iritscen, Wed Apr 28 10:40:52 2010 UTC

# Line 1 | Line 1
1 < #include "installer.cpp"
2 <
3 < vector<string> globalInstalledMods;
4 < vector<ModPackage> globalPackages;
5 < #include "boost/thread.hpp"
6 < #include <boost/thread/mutex.hpp>
7 <
8 < /////////////////////////////////////////////////////////////////////////////
9 < // Name:        main_window.cpp
10 < // Purpose:    
11 < // Author:      
12 < // Modified by:
13 < // Created:     07/05/2009 20:38:25
14 < // RCS-ID:      
15 < // Copyright:  
16 < // Licence:    
17 < /////////////////////////////////////////////////////////////////////////////
18 <
19 < // For compilers that support precompilation, includes "wx/wx.h".
20 < #include "wx/wxprec.h"
21 <
22 < #ifdef __BORLANDC__
23 < #pragma hdrstop
24 < #endif
25 <
26 < #ifndef WX_PRECOMP
27 < #include "wx/wx.h"
28 < #endif
29 <
30 < ////@begin includes
31 < #include "about_window.h"
32 < ////@end includes
33 <
34 < #include "main_window.h"
35 <
36 < ////@begin XPM images
37 < #include "redo.xpm"
38 < #include "fileopen.xpm"
39 < #include "filesaveas.xpm"
40 < #include "quit.xpm"
41 < ////@end XPM images
42 <
43 < //#define wxDebug 1;
44 < //#define wxUSE_UNICODE 1;
45 <
46 < /*
47 < * MainWindow type definition
48 < */
49 <
50 < IMPLEMENT_CLASS( MainWindow, wxFrame )
51 <
52 <
53 < /*
54 < * MainWindow event table definition
55 < */
56 <
57 < BEGIN_EVENT_TABLE( MainWindow, wxFrame )
58 <
59 < ////@begin MainWindow event table entries
60 <    EVT_CHECKBOX( SelectAll_Checkbox, MainWindow::OnSelectAllCheckboxClick )
61 <
62 <    EVT_BUTTON( Refresh_Button, MainWindow::OnRefreshButtonClick )
63 <
64 <    EVT_LISTBOX( Mods_CheckboxList1, MainWindow::OnModsCheckboxList1Selected )
65 <    EVT_CHECKLISTBOX( Mods_CheckboxList1, MainWindow::OnModsCheckboxList1Toggled )
66 <
67 <    EVT_UPDATE_UI( ID_STATUSBAR, MainWindow::OnStatusbarUpdate )
68 <
69 <    EVT_BUTTON( Install_Button, MainWindow::OnInstallButtonClick )
70 <
71 <    EVT_RADIOBUTTON( Sep_RadioButton, MainWindow::OnSepRadioButtonSelected )
72 <
73 <    EVT_RADIOBUTTON( NoSep_RadioButton, MainWindow::OnNoSepRadioButtonSelected )
74 <
75 <    EVT_RADIOBUTTON( Separated_RadioButton, MainWindow::OnSeparatedRadioButtonSelected )
76 <
77 <    EVT_RADIOBUTTON( Complete_RadioButton, MainWindow::OnCompleteRadioButtonSelected )
78 <
79 <    EVT_BUTTON( ReGlobalize_Button, MainWindow::OnReGlobalizeButtonClick )
80 <
81 <    EVT_MENU( wxID_LOAD, MainWindow::OnLoadClick )
82 <
83 <    EVT_MENU( wxID_SAVE, MainWindow::OnSaveClick )
84 <
85 <    EVT_MENU( wxID_EXIT, MainWindow::OnExitClick )
86 <
87 <    EVT_MENU( wxID_OPTIONS, MainWindow::OnOptionsClick )
88 <
89 <    EVT_MENU( wxID_ABOUT, MainWindow::OnAboutClick )
90 <
91 < ////@end MainWindow event table entries
92 <
93 < END_EVENT_TABLE()
94 <
95 <
96 < /*
97 < * MainWindow constructors
98 < */
99 <
100 < MainWindow::MainWindow()
101 < {
102 <    Init();
103 < }
104 <
105 < MainWindow::MainWindow( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
106 < {
107 <    Init();
108 <    Create( parent, id, caption, pos, size, style );
109 < }
110 <
111 <
112 < /*
113 < * MainWindow creator
114 < */
115 <
116 < bool MainWindow::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
117 < {
118 < ////@begin MainWindow creation
119 <    wxFrame::Create( parent, id, caption, pos, size, style );
120 <
121 <    CreateControls();
122 <    SetIcon(GetIconResource(wxT("oni_special.ico")));
123 <    Centre();
124 < ////@end MainWindow creation
125 <    return true;
126 < }
127 <
128 <
129 < /*
130 < * MainWindow destructor
131 < */
132 <
133 < MainWindow::~MainWindow()
134 < {
135 < ////@begin MainWindow destruction
136 < ////@end MainWindow destruction
137 < }
138 <
139 <
140 < /*
141 < * Member initialisation
142 < */
143 <
144 < void MainWindow::Init()
145 < {
146 < ////@begin MainWindow member initialisation
147 <    MainSplitter = NULL;
148 <    SelectAll = NULL;
149 <    RefreshButton = NULL;
150 <    Mods_CheckboxList = NULL;
151 <    titleText = NULL;
152 <    creatorText = NULL;
153 <    descriptionText = NULL;
154 <    StatusArea = NULL;
155 <    ProgressBar = NULL;
156 <    InstallButton = NULL;
157 <    OptionsPanel = NULL;
158 <    SepRadio = NULL;
159 <    NoSepRadio = NULL;
160 <    SeparatedRadio = NULL;
161 <    CompleteRadio = NULL;
162 <    ReglobalizeButton = NULL;
163 < ////@end MainWindow member initialisation
164 <
165 < }
166 <
167 <
168 < /*
169 < * Control creation for MainWindow
170 < */
171 < wxStatusBar* TheStatusBar;
172 < wxButton* TheInstallButton;
173 < wxGauge* TheProgressBar;
174 < void MainWindow::CreateControls()
175 < {    
176 < ////@begin MainWindow content construction
177 <    MainWindow* itemFrame1 = this;
178 <
179 <    wxMenuBar* menuBar = new wxMenuBar;
180 <    wxMenu* itemMenu37 = new wxMenu;
181 <    {
182 <        wxMenuItem* menuItem = new wxMenuItem(itemMenu37, wxID_LOAD, _("&Load Configuration..."), wxEmptyString, wxITEM_NORMAL);
183 <        wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("fileopen.xpm")));
184 <        menuItem->SetBitmap(bitmap);
185 <        itemMenu37->Append(menuItem);
186 <    }
187 <    {
188 <        wxMenuItem* menuItem = new wxMenuItem(itemMenu37, wxID_SAVE, _("&Save Configuration..."), wxEmptyString, wxITEM_NORMAL);
189 <        wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("filesaveas.xpm")));
190 <        menuItem->SetBitmap(bitmap);
191 <        itemMenu37->Append(menuItem);
192 <    }
193 <    itemMenu37->AppendSeparator();
194 <    {
195 <        wxMenuItem* menuItem = new wxMenuItem(itemMenu37, wxID_EXIT, _("Exit"), wxEmptyString, wxITEM_NORMAL);
196 <        wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("quit.xpm")));
197 <        menuItem->SetBitmap(bitmap);
198 <        itemMenu37->Append(menuItem);
199 <    }
200 <    menuBar->Append(itemMenu37, _("&File"));
201 <    wxMenu* itemMenu42 = new wxMenu;
202 <    itemMenu42->Append(wxID_OPTIONS, _("Show Advanced Options..."), wxEmptyString, wxITEM_CHECK);
203 <    menuBar->Append(itemMenu42, _("Options"));
204 <    wxMenu* itemMenu44 = new wxMenu;
205 <    itemMenu44->Append(wxID_HELP, _("Help"), wxEmptyString, wxITEM_NORMAL);
206 <    itemMenu44->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL);
207 <    menuBar->Append(itemMenu44, _("Help"));
208 <    itemFrame1->SetMenuBar(menuBar);
209 <
210 <    wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
211 <    itemFrame1->SetSizer(itemBoxSizer2);
212 <
213 <    MainSplitter = new wxSplitterWindow( itemFrame1, ID_SPLITTERWINDOW, wxDefaultPosition, wxSize(100, 100), wxSP_LIVE_UPDATE|wxNO_BORDER );
214 <    MainSplitter->SetMinimumPaneSize(150);
215 <    MainSplitter->SetName(_T("MainSplitter"));
216 <
217 <    wxPanel* itemPanel4 = new wxPanel( MainSplitter, ID_PANEL, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
218 <    wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL);
219 <    itemPanel4->SetSizer(itemBoxSizer5);
220 <
221 <    wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxHORIZONTAL);
222 <    itemBoxSizer5->Add(itemBoxSizer6, 0, wxGROW|wxALL, 0);
223 <    SelectAll = new wxCheckBox( itemPanel4, SelectAll_Checkbox, _("Select All/None"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE );
224 <    SelectAll->SetValue(false);
225 <    SelectAll->SetName(_T("SelectAll_Checkbox"));
226 <    itemBoxSizer6->Add(SelectAll, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
227 <
228 <    RefreshButton = new wxBitmapButton( itemPanel4, Refresh_Button, itemFrame1->GetBitmapResource(wxT("redo.xpm")), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
229 <    RefreshButton->SetName(_T("RefreshButton"));
230 <    itemBoxSizer6->Add(RefreshButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM, 5);
231 <
232 <    wxArrayString Mods_CheckboxListStrings;
233 <    Mods_CheckboxList = new wxCheckListBox( itemPanel4, Mods_CheckboxList1, wxDefaultPosition, wxDefaultSize, Mods_CheckboxListStrings, wxLB_HSCROLL );
234 <    Mods_CheckboxList->SetName(_T("Mods_CheckboxList"));
235 <    itemBoxSizer5->Add(Mods_CheckboxList, 1, wxGROW|wxALL, 0);
236 <
237 <    wxPanel* itemPanel10 = new wxPanel( MainSplitter, DescriptionHolder_Panel, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
238 <    itemPanel10->SetName(_T("DescriptionHolder_Panel"));
239 <    wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxVERTICAL);
240 <    itemPanel10->SetSizer(itemBoxSizer11);
241 <
242 <    wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxHORIZONTAL);
243 <    itemBoxSizer11->Add(itemBoxSizer12, 0, wxGROW|wxALL, 0);
244 <    wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxVERTICAL);
245 <    itemBoxSizer12->Add(itemBoxSizer13, 1, wxALIGN_CENTER_VERTICAL|wxALL, 0);
246 <    titleText = new wxTextCtrl( itemPanel10, Title_Text, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
247 <    titleText->SetName(_T("Title_Text"));
248 <    titleText->SetBackgroundColour(wxColour(240, 240, 240));
249 <    itemBoxSizer13->Add(titleText, 1, wxGROW|wxLEFT, 5);
250 <
251 <    wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxVERTICAL);
252 <    itemBoxSizer12->Add(itemBoxSizer15, 1, wxGROW|wxALL, 0);
253 <    creatorText = new wxTextCtrl( itemPanel10, Author_Text, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY|wxTE_RIGHT );
254 <    creatorText->SetName(_T("Author_Text"));
255 <    creatorText->SetBackgroundColour(wxColour(240, 240, 240));
256 <    itemBoxSizer15->Add(creatorText, 1, wxGROW|wxRIGHT, 5);
257 <
258 <    wxStaticLine* itemStaticLine17 = new wxStaticLine( itemPanel10, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
259 <    itemStaticLine17->Show(false);
260 <    itemBoxSizer11->Add(itemStaticLine17, 0, wxGROW|wxALL, 5);
261 <
262 <    descriptionText = new wxTextCtrl( itemPanel10, Description_Text, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxTE_RICH|wxTE_RICH2 );
263 <    descriptionText->SetName(_T("DescriptionName"));
264 <    descriptionText->SetBackgroundColour(wxColour(240, 240, 240));
265 <    itemBoxSizer11->Add(descriptionText, 1, wxGROW|wxLEFT|wxRIGHT, 5);
266 <
267 <    MainSplitter->SplitVertically(itemPanel4, itemPanel10, 150);
268 <    itemBoxSizer2->Add(MainSplitter, 1, wxGROW|wxALL, 0);
269 <
270 <    StatusArea = new wxStatusBar( itemFrame1, ID_STATUSBAR, 0 );
271 <    StatusArea->SetName(_T("StatusArea"));
272 <    StatusArea->SetFieldsCount(1);
273 <    StatusArea->SetStatusText(_("Status Area"), 0);
274 <    itemBoxSizer2->Add(StatusArea, 0, wxGROW|wxALL, 0);
275 <
276 <    wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxHORIZONTAL);
277 <    itemBoxSizer2->Add(itemBoxSizer20, 0, wxGROW|wxALL, 0);
278 <
279 <    ProgressBar = new wxGauge( itemFrame1, ProgressBar_Gauge, 1000, wxDefaultPosition, wxDefaultSize, wxGA_SMOOTH );
280 <    ProgressBar->SetValue(0);
281 <    itemBoxSizer20->Add(ProgressBar, 1, wxGROW|wxALL, 0);
282 <
283 <    InstallButton = new wxButton( itemFrame1, Install_Button, _("Install!"), wxDefaultPosition, wxDefaultSize, 0 );
284 <    itemBoxSizer20->Add(InstallButton, 0, wxGROW|wxALL, 0);
285 <
286 <    wxBoxSizer* itemBoxSizer23 = new wxBoxSizer(wxVERTICAL);
287 <    itemBoxSizer2->Add(itemBoxSizer23, 0, wxGROW|wxALL, 0);
288 <
289 <    OptionsPanel = new wxPanel( itemFrame1, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
290 <    itemBoxSizer2->Add(OptionsPanel, 0, wxGROW, 0);
291 <
292 <    wxBoxSizer* itemBoxSizer25 = new wxBoxSizer(wxHORIZONTAL);
293 <    OptionsPanel->SetSizer(itemBoxSizer25);
294 <
295 <    wxBoxSizer* itemBoxSizer26 = new wxBoxSizer(wxVERTICAL);
296 <    itemBoxSizer25->Add(itemBoxSizer26, 0, wxGROW|wxALL, 5);
297 <
298 <    SepRadio = new wxRadioButton( OptionsPanel, Sep_RadioButton, _("Sep"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
299 <    SepRadio->SetValue(false);
300 <    if (MainWindow::ShowToolTips())
301 <        SepRadio->SetToolTip(_("For PC Demo and Mac"));
302 <    itemBoxSizer26->Add(SepRadio, 0, wxALIGN_LEFT|wxALL, 5);
303 <
304 <    NoSepRadio = new wxRadioButton( OptionsPanel, NoSep_RadioButton, _("NoSep"), wxDefaultPosition, wxDefaultSize, 0 );
305 <    NoSepRadio->SetValue(false);
306 <    if (MainWindow::ShowToolTips())
307 <        NoSepRadio->SetToolTip(_("For PC Retail"));
308 <    itemBoxSizer26->Add(NoSepRadio, 0, wxALIGN_LEFT|wxALL, 5);
309 <
310 <    wxStaticLine* itemStaticLine29 = new wxStaticLine( OptionsPanel, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
311 <    itemBoxSizer25->Add(itemStaticLine29, 0, wxGROW|wxALL, 5);
312 <
313 <    wxBoxSizer* itemBoxSizer30 = new wxBoxSizer(wxVERTICAL);
314 <    itemBoxSizer25->Add(itemBoxSizer30, 0, wxGROW|wxALL, 5);
315 <
316 <    SeparatedRadio = new wxRadioButton( OptionsPanel, Separated_RadioButton, _("Separated Level0"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
317 <    SeparatedRadio->SetValue(false);
318 <    SeparatedRadio->SetName(_T("Separated_RadioButton"));
319 <    itemBoxSizer30->Add(SeparatedRadio, 0, wxALIGN_LEFT|wxALL, 5);
320 <
321 <    CompleteRadio = new wxRadioButton( OptionsPanel, Complete_RadioButton, _("Complete Level0"), wxDefaultPosition, wxDefaultSize, 0 );
322 <    CompleteRadio->SetValue(false);
323 <    CompleteRadio->SetName(_T("Complete_RadioButton"));
324 <    itemBoxSizer30->Add(CompleteRadio, 0, wxALIGN_LEFT|wxALL, 5);
325 <
326 <    wxStaticLine* itemStaticLine33 = new wxStaticLine( OptionsPanel, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
327 <    itemBoxSizer25->Add(itemStaticLine33, 0, wxGROW|wxALL, 5);
328 <
329 <    wxBoxSizer* itemBoxSizer34 = new wxBoxSizer(wxVERTICAL);
330 <    itemBoxSizer25->Add(itemBoxSizer34, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
331 <
332 <    ReglobalizeButton = new wxButton( OptionsPanel, ReGlobalize_Button, _("Reglobalize"), wxDefaultPosition, wxDefaultSize, 0 );
333 <    ReglobalizeButton->SetName(_T("Reglobalize_Button"));
334 <    itemBoxSizer34->Add(ReglobalizeButton, 0, wxGROW|wxALL, 5);
335 <
336 <    // Connect events and objects
337 <    Mods_CheckboxList->Connect(Mods_CheckboxList1, wxEVT_CREATE, wxWindowCreateEventHandler(MainWindow::ModList_OnCreate), NULL, this);
338 < ////@end MainWindow content construction
339 <        
340 <        if ( exists( "../../GameDataFolder/level0_Final.sep" ) ) {
341 <                static_cast<string>("-import:sep");
342 <                splitInstances = NOT_SPLIT;
343 <        }
344 <        else {
345 <                static_cast<string>("-import:nosep");
346 <                splitInstances = SPLIT;
347 <        }
348 <
349 <        globalPackages = getPackages();
350 <        globalInstalledMods = getInstallString();
351 <                for (int i = 0; i < globalPackages.size(); i++) {
352 <                        Mods_CheckboxList->Append(globalPackages[i].name.c_str());
353 <                        if( binary_search(globalInstalledMods.begin(), globalInstalledMods.end(), globalPackages[i].modStringName ) ) Mods_CheckboxList->Check(i);
354 <        }
355 <                TheStatusBar = StatusArea;
356 <                TheInstallButton = InstallButton;
357 <                TheProgressBar = ProgressBar;
358 <                OptionsPanel->Hide();
359 <                if(splitInstances == SPLIT) SeparatedRadio->SetValue(true);
360 <                else CompleteRadio->SetValue(true);
361 <                
362 <                
363 <                
364 <                if(strImportOption == "-import:nosep") NoSepRadio->SetValue(true);
365 <                else SepRadio->SetValue(true);
366 <
367 <                        //MainWindow::SetSize(MainWindow::GetRect().GetWidth(), MainWindow::GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight() );
368 < }
369 <
370 <                
371 < /*
372 < * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for SelectAll_Checkbox
373 < */
374 <
375 < void MainWindow::OnSelectAllCheckboxClick( wxCommandEvent& event )
376 < {
377 <                switch(SelectAll->Get3StateValue()) {
378 <        case wxCHK_UNCHECKED:
379 <                for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false);
380 <                //SelectAll->Set3StateValue(wxCHK_CHECKED);
381 <                break;
382 <        case wxCHK_CHECKED:
383 <                for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, true);
384 <                //SelectAll->Set3StateValue(wxCHK_UNCHECKED);
385 <                break;
386 <        case wxCHK_UNDETERMINED:
387 <                for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false);
388 <                //SelectAll->Set3StateValue(wxCHK_CHECKED);
389 <                break;
390 <
391 <        }
392 <        
393 < }
394 <
395 <
396 < /*
397 < * wxEVT_CREATE event handler for Mods_CheckboxList
398 < */
399 <
400 < void MainWindow::ModList_OnCreate( wxWindowCreateEvent& event )
401 < {
402 <
403 <
404 < }
405 <
406 <
407 < /*
408 < * Should we show tooltips?
409 < */
410 <
411 < bool MainWindow::ShowToolTips()
412 < {
413 <    return true;
414 < }
415 <
416 < /*
417 < * Get bitmap resources
418 < */
419 <
420 < wxBitmap MainWindow::GetBitmapResource( const wxString& name )
421 < {
422 <    // Bitmap retrieval
423 < ////@begin MainWindow bitmap retrieval
424 <    wxUnusedVar(name);
425 <    if (name == _T("redo.xpm"))
426 <    {
427 <        wxBitmap bitmap(redo_xpm);
428 <        return bitmap;
429 <    }
430 <    else if (name == _T("fileopen.xpm"))
431 <    {
432 <        wxBitmap bitmap( fileopen_xpm);
433 <        return bitmap;
434 <    }
435 <    else if (name == _T("filesaveas.xpm"))
436 <    {
437 <        wxBitmap bitmap( filesaveas_xpm);
438 <        return bitmap;
439 <    }
440 <    else if (name == _T("quit.xpm"))
441 <    {
442 <        wxBitmap bitmap( quit_xpm);
443 <        return bitmap;
444 <    }
445 <    return wxNullBitmap;
446 < ////@end MainWindow bitmap retrieval
447 < }
448 <
449 < /*
450 < * Get icon resources
451 < */
452 <
453 < wxIcon MainWindow::GetIconResource( const wxString& name )
454 < {
455 <    // Icon retrieval
456 < ////@begin MainWindow icon retrieval
457 <    wxUnusedVar(name);
458 <    if (name == _T("oni_special.ico"))
459 <    {
460 <        wxIcon icon(_T("oni_special.ico"), wxBITMAP_TYPE_ICO);
461 <        return icon;
462 <    }
463 <    return wxNullIcon;
464 < ////@end MainWindow icon retrieval
465 < }
466 <
467 <
468 < /*
469 < * wxEVT_COMMAND_LISTBOX_SELECTED event handler for Mods_CheckboxList1
470 < */
471 <
472 < void MainWindow::OnModsCheckboxList1Selected( wxCommandEvent& event )
473 < {
474 <        //event.GetSelection
475 <        titleText->SetLabel(wxT(globalPackages[event.GetSelection()].name.c_str()));
476 <        creatorText->SetLabel(globalPackages[event.GetSelection()].creator.c_str());
477 <        descriptionText->SetLabel(globalPackages[event.GetSelection()].readme.c_str());
478 <
479 <        creatorText->Refresh();
480 < }
481 <
482 <
483 < /*
484 < * wxEVT_COMMAND_CHECKLISTBOX_TOGGLED event handler for Mods_CheckboxList1
485 < */
486 <
487 < void MainWindow::OnModsCheckboxList1Toggled( wxCommandEvent& event )
488 < {
489 <        SelectAll->Set3StateValue(wxCHK_UNDETERMINED);
490 <        if(event.GetInt()) {
491 <        /*
492 <                switch(SelectAll->Get3StateValue()) {
493 <        case wxCHK_UNCHECKED:
494 <                break;
495 <        case wxCHK_CHECKED:
496 <                break;
497 <        case wxCHK_UNDETERMINED :
498 <                break;
499 <        }
500 <        */
501 <        }
502 < }
503 <
504 <
505 < /*
506 < * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_OPTIONS
507 < */
508 <
509 < void MainWindow::OnOptionsClick( wxCommandEvent& event )
510 < {
511 <        
512 <        if (!event.GetInt() ) {
513 <                OptionsPanel->Hide();
514 <                MainWindow::SetSize(MainWindow::GetRect().GetWidth(), MainWindow::GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight());}
515 <        else {
516 <                OptionsPanel->Show();
517 <                MainWindow::SetSize(MainWindow::GetRect().GetWidth(), MainWindow::GetRect().GetHeight()+OptionsPanel->GetRect().GetHeight());
518 <        }
519 < }
520 <
521 <
522 < /*
523 < * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_EXIT
524 < */
525 <
526 < void MainWindow::OnExitClick( wxCommandEvent& event )
527 < {
528 < exit(0);
529 < }
530 <
531 <
532 < /*
533 < * wxEVT_COMMAND_BUTTON_CLICKED event handler for Install_Button
534 < */
535 <
536 <
537 < struct recompile
538 < {
539 <    recompile(vector<string> localPackages) : thePackages(localPackages) { }
540 <    void operator()()
541 <    {
542 <                TheInstallButton->Disable();
543 <       recompileAll(thePackages);
544 <           TheInstallButton->Enable();
545 <    }
546 <
547 <    vector<string> thePackages;
548 < };
549 <
550 < void MainWindow::OnInstallButtonClick( wxCommandEvent& event )
551 < {
552 <        
553 <        vector<string> localPackages;
554 <        localPackages.push_back("Globalize");
555 <        for(int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) localPackages.push_back( globalPackages[i].modStringName );
556 <        if ( !localPackages.empty() )   {
557 <                
558 <                //MainWindow::MainWindow().Hide();      
559 <        //      boost::thread thrd2(recompileAll(localPackages) );
560 <                //MainWindow::MainWindow().Show();
561 <    recompile packages(localPackages);
562 <    boost::thread thrd(packages);
563 <
564 <        }
565 <        
566 <        
567 < }
568 <
569 < void setStatusArea( string s ) {
570 <        TheStatusBar->SetStatusText(_(s.c_str()));
571 <        
572 <                //MainWindow::MainWindow().SetSize(MainWindow::MainWindow().GetRect().GetWidth(), MainWindow::MainWindow().GetRect().GetHeight()+1);
573 <                                                
574 <        //MainWindow::StatusBar->SetLabel("Importing Files...");
575 <        //StatusBar->SetLabel(s);
576 < //->SetLabel(s);
577 <        
578 < }
579 <
580 < void setProgressBar( int i ) {
581 < //TheProgressBar->SetValue(
582 <
583 <        TheProgressBar->SetValue(i);
584 <
585 < }
586 <
587 <
588 < /*
589 < * wxEVT_UPDATE_UI event handler for ID_STATUSBAR
590 < */
591 <
592 < void MainWindow::OnStatusbarUpdate( wxUpdateUIEvent& event )
593 < {
594 < ////@begin wxEVT_UPDATE_UI event handler for ID_STATUSBAR in MainWindow.
595 <    // Before editing this code, remove the block markers.
596 <    event.Skip();
597 < ////@end wxEVT_UPDATE_UI event handler for ID_STATUSBAR in MainWindow.
598 < }
599 <
600 <
601 < /*
602 < * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT
603 < */
604 <
605 < void MainWindow::OnAboutClick( wxCommandEvent& event )
606 < {
607 < ////@begin wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT in MainWindow.
608 <    // Before editing this code, remove the block markers.
609 <    About* window = new About(this);
610 <    int returnValue = window->ShowModal();
611 <    window->Destroy();
612 < ////@end wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT in MainWindow.
613 < }
614 <
615 <
616 < /*
617 < * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for NoSep_RadioButton
618 < */
619 <
620 < void MainWindow::OnNoSepRadioButtonSelected( wxCommandEvent& event )
621 < {
622 <        static_cast<string>("-import:nosep");
623 < }
624 <
625 <
626 < /*
627 < * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Sep_RadioButton
628 < */
629 <
630 < void MainWindow::OnSepRadioButtonSelected( wxCommandEvent& event )
631 < {
632 <        static_cast<string>("-import:sep");
633 < }
634 <
635 <
636 < /*
637 < * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton
638 < */
639 <
640 < void MainWindow::OnSeparatedRadioButtonSelected( wxCommandEvent& event )
641 < {
642 < splitInstances = SPLIT;
643 <
644 < }
645 <
646 <
647 < /*
648 < * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Complete_RadioButton
649 < */
650 <
651 < void MainWindow::OnCompleteRadioButtonSelected( wxCommandEvent& event )
652 < {
653 < splitInstances = NOT_SPLIT;
654 <
655 < }
656 <
657 <
658 < /*
659 < * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BITMAPBUTTON
660 < */
661 <
662 < void MainWindow::OnRefreshButtonClick( wxCommandEvent& event )
663 < {
664 <        refreshMods(globalInstalledMods);
665 < }
666 <
667 <
668 < /*
669 < * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_LOAD
670 < */
671 <
672 <
673 <
674 <
675 < void MainWindow::refreshMods (vector<string> s) {
676 <        
677 <        Mods_CheckboxList->Clear();
678 <                                           //globalInstalledMods = getPackages();
679 <                for (int i = 0; i < globalPackages.size(); i++) {
680 <                        Mods_CheckboxList->Append(globalPackages[i].name.c_str());
681 <                        if( binary_search(s.begin(), s.end(), globalPackages[i].modStringName ) ) Mods_CheckboxList->Check(i);
682 <                        //else Mods_CheckboxList->Check(i,0);
683 <                
684 <                }
685 < }
686 <
687 < void MainWindow::OnLoadClick( wxCommandEvent& event )
688 < {
689 <        static const wxChar *FILETYPES = _T(
690 <                "Mod Loadouts (*.cfg)|*.cfg|"
691 <                "All files (*.*)|*.*"
692 <        );
693 <        
694 <        wxFileDialog* openFileDialog =
695 <                new wxFileDialog( this, _("Open Mod Loadout"), "", "", FILETYPES,
696 <                                  wxOPEN, wxDefaultPosition);
697 <
698 <        if ( openFileDialog->ShowModal() == wxID_OK )
699 <        {
700 <                refreshMods(getInstallString( string(openFileDialog->GetPath()) ));
701 <        }
702 <
703 <
704 < }
705 <
706 <
707 < /*
708 < * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_SAVE
709 < */
710 <
711 < void MainWindow::OnSaveClick( wxCommandEvent& event )
712 < {
713 <        static const wxChar *FILETYPES = _T(
714 <                "Mod Loadouts (*.cfg)|*.cfg|"
715 <                "All files (*.*)|*.*"
716 <        );
717 <
718 <                wxFileDialog* openFileDialog =
719 <                new wxFileDialog( this, _("Open file"), "", "", FILETYPES,
720 <                wxSAVE, wxDefaultPosition);
721 <
722 <        if ( openFileDialog->ShowModal() == wxID_OK )
723 <        {
724 <
725 <                
726 <                        //Mods_CheckboxList->
727 <
728 <
729 <
730 <                //
731 <                
732 <                if ( exists( openFileDialog->GetPath().c_str() ) )
733 <        {
734 <                remove( openFileDialog->GetPath().c_str() );
735 <        }
736 <
737 <        ofstream file(openFileDialog->GetPath().c_str());
738 <        
739 <        vector<string>list;
740 <        for(int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) list.push_back( globalPackages[i].modStringName );
741 <        vector<string>::iterator begin_iter = list.begin();
742 <        vector<string>::iterator end_iter = list.end();
743 <
744 <        sort( list.begin(), list.end() );
745 <
746 <        for( ; begin_iter != end_iter; ++begin_iter) {
747 <                file << *begin_iter << " ";
748 <        }
749 <        
750 <        file.close();
751 <        file.clear();
752 <
753 <                //SetCurrentFilename(openFileDialog->GetFilename());
754 <                //theText->LoadFile(openFileDialog->GetFilename());
755 <                //SetStatusText(GetCurrentFilename(), 0);
756 <                //SetStatusText(openFileDialog->GetDirectory(),1);
757 <        }
758 < }
759 <
760 <
761 < /*
762 < * wxEVT_COMMAND_BUTTON_CLICKED event handler for ReGlobalize_Button
763 < */
764 <
765 < void MainWindow::OnReGlobalizeButtonClick( wxCommandEvent& event )
766 < {
767 < globalizeData();
768 <                setProgressBar(1000);
769 <                setStatusArea("Done!");
770 < }
771 <
1 > /***************************************************************************\
2 > | Project: AE Installer                                                                                                         |
3 > | By: Gumby & Iritscen                                                                                                          |
4 > | File: Main_Window.cpp                                                                                                         |
5 > | Function: Handles the GUI.                                                                                            |
6 > | Created: 07/05/2009 20:38:25                                                                                          |
7 > \***************************************************************************/
8 >
9 > #ifndef NTDDI_VERSION          
10 > #define NTDDI_VERSION NTDDI_WIN7
11 > #endif
12 > #ifdef WIN32
13 > #include <windows.h>
14 > #include <shobjidl.h>
15 > HWND Handle;
16 > ITaskbarList *pTaskbarList;
17 > ITaskbarList3 *pTaskbarList3;
18 > #endif
19 >
20 > #include <boost/thread/mutex.hpp>
21 > // For compilers that support precompilation, includes "wx/wx.h".
22 > #include "wx/wxprec.h"
23 >
24 > #ifdef __BORLANDC__
25 > #pragma hdrstop
26 > #endif
27 >
28 > #ifndef WX_PRECOMP
29 > #include "wx/wx.h"
30 > #endif
31 >
32 > ////@begin includes
33 > #include "about.h"
34 > #include "main_window.h"
35 > #include "installer.h"
36 > ////@end includes
37 >
38 > ////@begin XPM images
39 > #include "aelogosmall.xpm"
40 > #include "undo.xpm"
41 > #include "fileopen.xpm"
42 > #include "filesaveas.xpm"
43 > #include "quit.xpm"
44 > ////@end XPM images
45 >
46 > bool busy = false;
47 > int updateStatus;
48 > bool installerJustUpdated = false;
49 > vector<string> globalInstalledMods;
50 > vector<ModPackage> globalPackages;
51 > // Variable declarations
52 > #ifdef WIN32
53 > bool splitInstances = true;
54 > string strImportOption = "-import:nosep";
55 > string strOniSplit = "Onisplit.exe";
56 > #else
57 > bool splitInstances = false;
58 > string strImportOption = "-import:sep";
59 > string strOniSplit = "mono Onisplit.exe";
60 > #endif
61 >
62 > /*
63 > * MainWindow type definition
64 > */
65 >
66 > IMPLEMENT_CLASS( MainWindow, wxFrame )
67 >
68 >
69 > /*
70 > * MainWindow event table definition
71 > */
72 >
73 > BEGIN_EVENT_TABLE( MainWindow, wxFrame )
74 >
75 > ////@begin MainWindow event table entries
76 >    EVT_CHECKBOX( SelectAll_Checkbox, MainWindow::OnSelectAllCheckboxClick )
77 >
78 >    EVT_BUTTON( Refresh_Button, MainWindow::OnRefreshButtonClick )
79 >
80 >    EVT_LISTBOX( Mods_CheckboxList1, MainWindow::OnModsCheckboxList1Selected )
81 >    EVT_CHECKLISTBOX( Mods_CheckboxList1, MainWindow::OnModsCheckboxList1Toggled )
82 >
83 >    EVT_UPDATE_UI( ID_STATUSBAR, MainWindow::OnStatusbarUpdate )
84 >
85 >    EVT_BUTTON( Install_Button, MainWindow::OnInstallButtonClick )
86 >
87 >    EVT_RADIOBUTTON( Sep_RadioButton, MainWindow::OnSepRadioButtonSelected )
88 >
89 >    EVT_RADIOBUTTON( NoSep_RadioButton, MainWindow::OnNoSepRadioButtonSelected )
90 >
91 >    EVT_RADIOBUTTON( Seperated_RadioButton, MainWindow::OnSeperatedRadioButtonSelected )
92 >
93 >    EVT_RADIOBUTTON( Complete_RadioButton, MainWindow::OnCompleteRadioButtonSelected )
94 >
95 >    EVT_BUTTON( ReGlobalize_Button, MainWindow::OnReGlobalizeButtonClick )
96 >
97 >    EVT_MENU( wxID_LOAD, MainWindow::OnLoadClick )
98 >
99 >    EVT_MENU( wxID_SAVE, MainWindow::OnSaveClick )
100 >
101 >    EVT_MENU( wxID_EXIT, MainWindow::OnExitClick )
102 >
103 >    EVT_MENU( wxID_OPTIONS, MainWindow::OnOptionsClick )
104 >
105 >    EVT_MENU( wxID_ABOUT, MainWindow::OnAboutClick )
106 >
107 >        EVT_BUTTON( Dir_Button, MainWindow::OnDirButtonClick )
108 > ////@end MainWindow event table entries
109 >
110 > END_EVENT_TABLE()
111 >
112 >
113 > /*
114 > * MainWindow constructors
115 > */
116 >
117 > MainWindow::MainWindow()
118 > {  
119 >        Init();
120 > }
121 >
122 > MainWindow::MainWindow( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
123 > {
124 >        Init();
125 >        Create( parent, id, caption, pos, size, style );
126 > }
127 >
128 >
129 > /*
130 > * MainWindow creator
131 > */
132 >
133 > bool MainWindow::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
134 > {
135 >        ////@begin MainWindow creation
136 >    wxFrame::Create( parent, id, caption, pos, size, style );
137 >
138 >    CreateControls();
139 >    SetIcon(GetIconResource(wxT("aelogosmall.png")));
140 >    Centre();
141 >        ////@end MainWindow creation
142 >        return true;
143 > }
144 >
145 > /*
146 > * MainWindow destructor
147 > */
148 >
149 > MainWindow::~MainWindow()
150 > {
151 >        ////@begin MainWindow destruction
152 >        ////@end MainWindow destruction
153 > }
154 >
155 > /*
156 > * Member initialisation
157 > */
158 >
159 > void MainWindow::Init()
160 > {
161 >        ////@begin MainWindow member initialisation
162 >    MainSplitter = NULL;
163 >    SelectAll = NULL;
164 >    RefreshButton = NULL;
165 >    Mods_CheckboxList = NULL;
166 >    titleText = NULL;
167 >    creatorText = NULL;
168 >    descriptionText = NULL;
169 >    StatusArea = NULL;
170 >    ProgressBar = NULL;
171 >    InstallButton = NULL;
172 >    OptionsPanel = NULL;
173 >    SepRadio = NULL;
174 >    NoSepRadio = NULL;
175 >    SeperatedRadio = NULL;
176 >    CompleteRadio = NULL;
177 >    ReglobalizeButton = NULL;
178 >
179 >        ChangeDirectoryButton = NULL;
180 >        ////@end MainWindow member initialisation
181 > }
182 >
183 > /*
184 > * Control creation for MainWindow
185 > */
186 > wxStatusBar **TheStatusBar;
187 > wxButton* TheInstallButton;
188 > wxGauge* TheProgressBar;
189 > void MainWindow::CreateControls()
190 > {    
191 >        ////@begin MainWindow content construction
192 >    MainWindow* itemFrame1 = this;
193 >
194 >    wxMenuBar* menuBar = new wxMenuBar;
195 >    wxMenu* itemMenu37 = new wxMenu;
196 >    {
197 >        wxMenuItem* menuItem = new wxMenuItem(itemMenu37, wxID_LOAD, _("&Load Configuration..."), wxEmptyString, wxITEM_NORMAL);
198 >        wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("fileopen.xpm")));
199 >        menuItem->SetBitmap(bitmap);
200 >        itemMenu37->Append(menuItem);
201 >    }
202 >    {
203 >        wxMenuItem* menuItem = new wxMenuItem(itemMenu37, wxID_SAVE, _("&Save Configuration..."), wxEmptyString, wxITEM_NORMAL);
204 >        wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("filesaveas.xpm")));
205 >        menuItem->SetBitmap(bitmap);
206 >        itemMenu37->Append(menuItem);
207 >    }
208 >    itemMenu37->AppendSeparator();
209 >    {
210 >        wxMenuItem* menuItem = new wxMenuItem(itemMenu37, wxID_EXIT, _("Exit"), wxEmptyString, wxITEM_NORMAL);
211 >        wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("quit.xpm")));
212 >        menuItem->SetBitmap(bitmap);
213 >        itemMenu37->Append(menuItem);
214 >    }
215 >    menuBar->Append(itemMenu37, _("&File"));
216 >    wxMenu* itemMenu42 = new wxMenu;
217 >    itemMenu42->Append(wxID_OPTIONS, _("Show Advanced Options..."), wxEmptyString, wxITEM_CHECK);
218 >    menuBar->Append(itemMenu42, _("Options"));
219 > //#ifdef WIN32
220 > //      itemMenu44->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL);
221 > //      menuBar->Append(itemMenu44, _("Help"));
222 > //#else
223 >        itemMenu37->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL);
224 > //#endif        
225 >
226 >    itemFrame1->SetMenuBar(menuBar);
227 >
228 >    wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
229 >    itemFrame1->SetSizer(itemBoxSizer2);
230 >
231 >    MainSplitter = new wxSplitterWindow( itemFrame1, ID_SPLITTERWINDOW, wxDefaultPosition, wxSize(100, 100), wxSP_LIVE_UPDATE|wxNO_BORDER );
232 >    MainSplitter->SetMinimumPaneSize(1);
233 >    MainSplitter->SetName(_T("MainSplitter"));
234 >
235 >    wxPanel* itemPanel4 = new wxPanel( MainSplitter, ID_PANEL, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
236 >    wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL);
237 >    itemPanel4->SetSizer(itemBoxSizer5);
238 >
239 >    wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxHORIZONTAL);
240 >    itemBoxSizer5->Add(itemBoxSizer6, 0, wxGROW|wxALL, 0);
241 >    SelectAll = new wxCheckBox( itemPanel4, SelectAll_Checkbox, _("Select All/None"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE );
242 >    SelectAll->SetValue(false);
243 >    SelectAll->SetName(_T("SelectAll_Checkbox"));
244 >    itemBoxSizer6->Add(SelectAll, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
245 >
246 >    RefreshButton = new wxBitmapButton( itemPanel4, Refresh_Button, itemFrame1->GetBitmapResource(wxT("undo.xpm")), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
247 >    RefreshButton->SetName(_T("RefreshButton"));
248 >    itemBoxSizer6->Add(RefreshButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM, 5);
249 >
250 >    wxArrayString Mods_CheckboxListStrings;
251 >    Mods_CheckboxList = new wxCheckListBox( itemPanel4, Mods_CheckboxList1, wxDefaultPosition, wxDefaultSize, Mods_CheckboxListStrings, wxLB_HSCROLL );
252 >    Mods_CheckboxList->SetName(_T("Mods_CheckboxList"));
253 >    itemBoxSizer5->Add(Mods_CheckboxList, 1, wxGROW|wxALL, 0);
254 >
255 >    wxPanel* itemPanel10 = new wxPanel( MainSplitter, DescriptionHolder_Panel, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
256 >    itemPanel10->SetName(_T("DescriptionHolder_Panel"));
257 >    wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxVERTICAL);
258 >    itemPanel10->SetSizer(itemBoxSizer11);
259 >
260 >    wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxHORIZONTAL);
261 >    itemBoxSizer11->Add(itemBoxSizer12, 0, wxGROW|wxALL, 0);
262 >    wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxVERTICAL);
263 >    itemBoxSizer12->Add(itemBoxSizer13, 1, wxALIGN_CENTER_VERTICAL|wxALL, 0);
264 >    titleText = new wxTextCtrl( itemPanel10, Title_Text, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
265 >    titleText->SetName(_T("Title_Text"));
266 >    titleText->SetBackgroundColour(wxColour(240, 240, 240));
267 >    itemBoxSizer13->Add(titleText, 1, wxGROW|wxLEFT, 5);
268 >
269 >    wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxVERTICAL);
270 >    itemBoxSizer12->Add(itemBoxSizer15, 1, wxGROW|wxALL, 0);
271 >    creatorText = new wxTextCtrl( itemPanel10, Author_Text, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY|wxTE_RIGHT );
272 >    creatorText->SetName(_T("Author_Text"));
273 >    creatorText->SetBackgroundColour(wxColour(240, 240, 240));
274 >    itemBoxSizer15->Add(creatorText, 1, wxGROW|wxRIGHT, 5);
275 >
276 >    wxStaticLine* itemStaticLine17 = new wxStaticLine( itemPanel10, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
277 >    itemStaticLine17->Show(false);
278 >    itemBoxSizer11->Add(itemStaticLine17, 0, wxGROW|wxALL, 5);
279 >
280 >    descriptionText = new wxTextCtrl( itemPanel10, Description_Text, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxTE_RICH|wxTE_RICH2 );
281 >    descriptionText->SetName(_T("DescriptionName"));
282 >    descriptionText->SetBackgroundColour(wxColour(240, 240, 240));
283 >    itemBoxSizer11->Add(descriptionText, 1, wxGROW|wxLEFT|wxRIGHT, 5);
284 >
285 >    MainSplitter->SplitVertically(itemPanel4, itemPanel10, 200);
286 >    itemBoxSizer2->Add(MainSplitter, 1, wxGROW|wxALL, 0);
287 >
288 >    StatusArea = new wxStatusBar( itemFrame1, ID_STATUSBAR, 0 );
289 >    StatusArea->SetName(_T("StatusArea"));
290 >    StatusArea->SetFieldsCount(1);
291 >        string versionText = "AE Installer v" + (string)INSTALLER_VERSION;
292 >    StatusArea->SetStatusText(versionText.c_str(), 0);
293 >    itemBoxSizer2->Add(StatusArea, 0, wxGROW|wxALL, 0);
294 >
295 >    wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxHORIZONTAL);
296 >    itemBoxSizer2->Add(itemBoxSizer20, 0, wxGROW|wxALL, 0);
297 >
298 >    ProgressBar = new wxGauge( itemFrame1, ProgressBar_Gauge, 1000, wxDefaultPosition, wxDefaultSize, wxGA_SMOOTH );
299 >    ProgressBar->SetValue(0);
300 >    itemBoxSizer20->Add(ProgressBar, 1, wxGROW|wxALL, 0);
301 >
302 >    InstallButton = new wxButton( itemFrame1, Install_Button, _("Install!"), wxDefaultPosition, wxDefaultSize, 0 );
303 >    itemBoxSizer20->Add(InstallButton, 0, wxGROW|wxALL, 0);
304 >
305 >    wxBoxSizer* itemBoxSizer23 = new wxBoxSizer(wxVERTICAL);
306 >    itemBoxSizer2->Add(itemBoxSizer23, 0, wxGROW|wxALL, 0);
307 >
308 >    OptionsPanel = new wxPanel( itemFrame1, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
309 >    itemBoxSizer2->Add(OptionsPanel, 0, wxGROW, 0);
310 >
311 >    wxBoxSizer* itemBoxSizer25 = new wxBoxSizer(wxHORIZONTAL);
312 >    OptionsPanel->SetSizer(itemBoxSizer25);
313 >
314 >    wxBoxSizer* itemBoxSizer26 = new wxBoxSizer(wxVERTICAL);
315 >    itemBoxSizer25->Add(itemBoxSizer26, 0, wxGROW|wxALL, 5);
316 >
317 >    SepRadio = new wxRadioButton( OptionsPanel, Sep_RadioButton, _("Sep"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
318 >    SepRadio->SetValue(false);
319 >    if (MainWindow::ShowToolTips())
320 >        SepRadio->SetToolTip(_("For PC Demo and Mac"));
321 >    itemBoxSizer26->Add(SepRadio, 0, wxALIGN_LEFT|wxALL, 5);
322 >
323 >    NoSepRadio = new wxRadioButton( OptionsPanel, NoSep_RadioButton, _("NoSep"), wxDefaultPosition, wxDefaultSize, 0 );
324 >    NoSepRadio->SetValue(false);
325 >    if (MainWindow::ShowToolTips())
326 >        NoSepRadio->SetToolTip(_("For PC Retail"));
327 >    itemBoxSizer26->Add(NoSepRadio, 0, wxALIGN_LEFT|wxALL, 5);
328 >
329 >    wxStaticLine* itemStaticLine29 = new wxStaticLine( OptionsPanel, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
330 >    itemBoxSizer25->Add(itemStaticLine29, 0, wxGROW|wxALL, 5);
331 >
332 >    wxBoxSizer* itemBoxSizer30 = new wxBoxSizer(wxVERTICAL);
333 >    itemBoxSizer25->Add(itemBoxSizer30, 0, wxGROW|wxALL, 5);
334 >
335 >    SeperatedRadio = new wxRadioButton( OptionsPanel, Seperated_RadioButton, _("Separated Level0"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
336 >    SeperatedRadio->SetValue(false);
337 >    SeperatedRadio->SetName(_T("Seperated_RadioButton"));
338 >    itemBoxSizer30->Add(SeperatedRadio, 0, wxALIGN_LEFT|wxALL, 5);
339 >
340 >    CompleteRadio = new wxRadioButton( OptionsPanel, Complete_RadioButton, _("Complete Level0"), wxDefaultPosition, wxDefaultSize, 0 );
341 >    CompleteRadio->SetValue(false);
342 >    CompleteRadio->SetName(_T("Complete_RadioButton"));
343 >    itemBoxSizer30->Add(CompleteRadio, 0, wxALIGN_LEFT|wxALL, 5);
344 >
345 >    wxStaticLine* itemStaticLine33 = new wxStaticLine( OptionsPanel, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
346 >    itemBoxSizer25->Add(itemStaticLine33, 0, wxGROW|wxALL, 5);
347 >
348 >    wxBoxSizer* itemBoxSizer34 = new wxBoxSizer(wxVERTICAL);
349 >    itemBoxSizer25->Add(itemBoxSizer34, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
350 >
351 >    ReglobalizeButton = new wxButton( OptionsPanel, ReGlobalize_Button, _("Reglobalize"), wxDefaultPosition, wxDefaultSize, 0 );
352 >    ReglobalizeButton->SetName(_T("Reglobalize_Button"));
353 >    itemBoxSizer34->Add(ReglobalizeButton, 0, wxGROW|wxALL, 5);
354 >
355 >    wxStaticLine* itemStaticLine100 = new wxStaticLine( OptionsPanel, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
356 >    itemBoxSizer25->Add(itemStaticLine100, 0, wxGROW|wxALL, 5);
357 >
358 >        ChangeDirectoryButton =  new wxButton( OptionsPanel, Dir_Button, _("Change Dir"), wxDefaultPosition, wxDefaultSize, 0 );
359 >        ChangeDirectoryButton->SetName(_T("Dir_Button"));
360 >        itemBoxSizer34->Add(ChangeDirectoryButton, 0, wxGROW|wxALL, 5);
361 >
362 >        // Connect events and objects
363 >    Mods_CheckboxList->Connect(Mods_CheckboxList1, wxEVT_CREATE, wxWindowCreateEventHandler(MainWindow::ModList_OnCreate), NULL, this);
364 >        ////@end MainWindow content construction
365 > #ifdef WIN32
366 >        Handle = (HWND)GetHWND();
367 >        ::CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList, (void **)&pTaskbarList);
368 > #endif
369 >
370 >        updateStatus = GetUpdateStatus(&currentAE, &updateAE, &installerJustUpdated);
371 >        
372 >        globalPackages = getPackages();
373 >        globalInstalledMods = getInstallString();
374 >        for (unsigned int i = 0; i < globalPackages.size(); i++)
375 >        {
376 >                Mods_CheckboxList->Append(globalPackages[i].name.c_str());
377 >                if (binary_search(globalInstalledMods.begin(), globalInstalledMods.end(), globalPackages[i].modStringName)) Mods_CheckboxList->Check(i);
378 >        }
379 >
380 >        TheStatusBar = &StatusArea;
381 >        TheInstallButton = InstallButton;
382 >        TheProgressBar = ProgressBar;
383 >        OptionsPanel->Hide();
384 >        
385 >        if(splitInstances) SeperatedRadio->SetValue(true);
386 >        else CompleteRadio->SetValue(true);
387 >        if(strImportOption == "-import:nosep") NoSepRadio->SetValue(true);
388 >        else SepRadio->SetValue(true);
389 >
390 > #ifdef WIN32
391 >        RedirectIOToConsole();
392 >        HWND hWnd = GetConsoleWindow();
393 >        ShowWindow( hWnd, SW_HIDE );
394 > #endif
395 > }
396 >
397 > /*
398 > * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for SelectAll_Checkbox
399 > */
400 >
401 > void MainWindow::OnSelectAllCheckboxClick( wxCommandEvent& event )
402 > {
403 >        switch(SelectAll->Get3StateValue()) {
404 >        case wxCHK_UNCHECKED:
405 >                for(unsigned int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false);
406 >                break;
407 >        case wxCHK_CHECKED:
408 >                for(unsigned int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, true);
409 >                break;
410 >        case wxCHK_UNDETERMINED:
411 >                for(unsigned int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false);
412 >                break;
413 >        }
414 > }
415 >
416 > /*
417 > * wxEVT_CREATE event handler for Mods_CheckboxList
418 > */
419 >
420 > void MainWindow::ModList_OnCreate( wxWindowCreateEvent& event )
421 > {
422 >
423 > }
424 >
425 >
426 > /*
427 > * Should we show tooltips?
428 > */
429 >
430 > bool MainWindow::ShowToolTips()
431 > {
432 >        return true;
433 > }
434 >
435 > /*
436 > * Get bitmap resources
437 > */
438 >
439 > wxBitmap MainWindow::GetBitmapResource( const wxString& name )
440 > {
441 >        // Bitmap retrieval
442 >        ////@begin MainWindow bitmap retrieval
443 >    wxUnusedVar(name);
444 >    if (name == _T("undo.xpm"))
445 >    {
446 >        wxBitmap bitmap( undo_xpm);
447 >        return bitmap;
448 >    }
449 >    else if (name == _T("fileopen.xpm"))
450 >    {
451 >        wxBitmap bitmap( fileopen_xpm);
452 >        return bitmap;
453 >    }
454 >    else if (name == _T("filesaveas.xpm"))
455 >    {
456 >        wxBitmap bitmap( filesaveas_xpm);
457 >        return bitmap;
458 >    }
459 >    else if (name == _T("quit.xpm"))
460 >    {
461 >        wxBitmap bitmap( quit_xpm);
462 >        return bitmap;
463 >    }
464 >    return wxNullBitmap;
465 >        ////@end MainWindow bitmap retrieval
466 > }
467 >
468 > /*
469 > * Get icon resources
470 > */
471 >
472 > wxIcon MainWindow::GetIconResource( const wxString& name )
473 > {
474 >        // Icon retrieval
475 >        ////@begin MainWindow icon retrieval
476 >    wxUnusedVar(name);
477 >    if (name == _T("aelogosmall.png"))
478 >    {
479 >        wxIcon icon(aelogosmall_xpm);
480 >        return icon;
481 >    }
482 >    return wxNullIcon;
483 >        ////@end MainWindow icon retrieval
484 > }
485 >
486 > /*
487 > * wxEVT_COMMAND_LISTBOX_SELECTED event handler for Mods_CheckboxList1
488 > */
489 >
490 > void MainWindow::OnModsCheckboxList1Selected( wxCommandEvent& event )
491 > {
492 >        titleText->SetValue(globalPackages[event.GetSelection()].name.c_str());
493 >        creatorText->SetValue(globalPackages[event.GetSelection()].creator.c_str());
494 >        descriptionText->SetValue(globalPackages[event.GetSelection()].readme.c_str());
495 > }
496 >
497 > /*
498 > * wxEVT_COMMAND_CHECKLISTBOX_TOGGLED event handler for Mods_CheckboxList1
499 > */
500 >
501 > void MainWindow::OnModsCheckboxList1Toggled( wxCommandEvent& event )
502 > {
503 >        SelectAll->Set3StateValue(wxCHK_UNDETERMINED);
504 >        if(event.GetInt()) {
505 >                /*
506 >                switch(SelectAll->Get3StateValue()) {
507 >                case wxCHK_UNCHECKED:
508 >                break;
509 >                case wxCHK_CHECKED:
510 >                break;
511 >                case wxCHK_UNDETERMINED :
512 >                break;
513 >                }
514 >                */
515 >        }
516 > }
517 >
518 >
519 > /*
520 > * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_OPTIONS
521 > */
522 >
523 > void MainWindow::OnOptionsClick( wxCommandEvent& event )
524 > {
525 >        if (!event.GetInt() ) {
526 >                OptionsPanel->Hide();
527 >                
528 >                this->SetSize(this->GetRect().GetWidth(), this->GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight());}
529 >        else {
530 >                wxMessageDialog* YesNoDialog = new wxMessageDialog(this, "WARNING: These options are for advanced users only, use with caution.",
531 >                                                                                                                   "AE Installer Alert",  wxOK | wxICON_EXCLAMATION     , wxDefaultPosition);
532 >                YesNoDialog->ShowModal();
533 >                OptionsPanel->Show();
534 >                this->SetSize(this->GetRect().GetWidth(), this->GetRect().GetHeight()+OptionsPanel->GetRect().GetHeight()+1);
535 >                this->SetSize(this->GetRect().GetWidth(), this->GetRect().GetHeight()-1);
536 >        }
537 > }
538 >
539 > /*
540 > * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_EXIT
541 > */
542 >
543 > void MainWindow::OnExitClick( wxCommandEvent& event )
544 > {
545 >        exit(0);
546 > }
547 >
548 > /*
549 > * wxEVT_COMMAND_BUTTON_CLICKED event handler for Install_Button
550 > */
551 >
552 > struct recompile
553 > {
554 >        recompile(vector<string> localPackages) : thePackages(localPackages) { }
555 >        void operator()()
556 >        {
557 >                TheInstallButton->Disable();
558 >                recompileAll(thePackages);
559 >                TheInstallButton->Enable();
560 >                
561 >        }
562 >        vector<string> thePackages;
563 > };
564 >
565 > void globalize2(void) {
566 >                TheInstallButton->Disable();
567 >                globalizeData();
568 >                TheInstallButton->Enable();
569 > }
570 >
571 > void MainWindow::OnInstallButtonClick( wxCommandEvent& event )
572 > {
573 >        vector<string> localPackages;
574 >        localPackages.push_back("00000Globalize");
575 >        for(unsigned int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) localPackages.push_back( globalPackages[i].modStringName );
576 >        if ( !localPackages.empty() )   {
577 >                sort(localPackages.begin(), localPackages.end());
578 >                localPackages[0] = "Globalize";
579 >                this->InstallButton->Disable();
580 >                this->ReglobalizeButton->Disable();
581 > #ifdef WIN32
582 >                recompile packages(localPackages);
583 >                boost::thread thrd(packages);
584 > #else
585 >                recompileAll(localPackages);
586 > #endif
587 >                this->InstallButton->Enable();
588 >                this->ReglobalizeButton->Enable();
589 >        }
590 > }
591 >
592 > void setProgressBar( int i )
593 > {
594 > #ifdef WIN32
595 > if (SUCCEEDED(pTaskbarList->QueryInterface(IID_ITaskbarList3, (void **)&pTaskbarList3)))
596 > {
597 >        pTaskbarList3->SetProgressValue(Handle,i, 1000);
598 >        if ( i == 0 )
599 >        {
600 >                pTaskbarList3->SetProgressState(Handle,TBPF_NOPROGRESS);
601 >        }
602 > }
603 > #endif
604 >        TheProgressBar->SetValue(i);
605 > }
606 >
607 > /*
608 > * wxEVT_UPDATE_UI event handler for ID_STATUSBAR
609 > */
610 >
611 > void MainWindow::OnStatusbarUpdate( wxUpdateUIEvent& event )
612 > {
613 >        ////@begin wxEVT_UPDATE_UI event handler for ID_STATUSBAR in MainWindow.
614 >    // Before editing this code, remove the block markers.
615 >    event.Skip();
616 >        ////@end wxEVT_UPDATE_UI event handler for ID_STATUSBAR in MainWindow.
617 > }
618 >
619 > /*
620 > * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT
621 > */
622 >
623 > void MainWindow::OnAboutClick( wxCommandEvent& event )
624 > {
625 >        ////@begin wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT in MainWindow.
626 >    // Before editing this code, remove the block markers.
627 >    About* window = new About(this);
628 >        window->ShowModal();
629 >    window->Destroy();
630 >        ////@end wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT in MainWindow.
631 > }
632 >
633 > /*
634 > * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for NoSep_RadioButton
635 > */
636 >
637 > void MainWindow::OnNoSepRadioButtonSelected( wxCommandEvent& event )
638 > {
639 >        static_cast<string>("-import:nosep");
640 > }
641 >
642 > /*
643 > * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Sep_RadioButton
644 > */
645 >
646 > void MainWindow::OnSepRadioButtonSelected( wxCommandEvent& event )
647 > {
648 >        static_cast<string>("-import:sep");
649 > }
650 >
651 > /*
652 > * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton
653 > */
654 >
655 > /*
656 > * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Complete_RadioButton
657 > */
658 >
659 > void MainWindow::OnCompleteRadioButtonSelected( wxCommandEvent& event )
660 > {
661 >        splitInstances = false;
662 > }
663 >
664 > /*
665 > * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BITMAPBUTTON
666 > */
667 >
668 > void MainWindow::OnRefreshButtonClick( wxCommandEvent& event )
669 > {
670 >        globalPackages = getPackages();
671 >        refreshMods(globalInstalledMods);
672 > }
673 >
674 > /*
675 > * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_LOAD
676 > */
677 >
678 > void MainWindow::refreshMods (vector<string> s)
679 > {
680 >        Mods_CheckboxList->Clear();
681 >        for (unsigned int i = 0; i < globalPackages.size(); i++) {
682 >                Mods_CheckboxList->Append(globalPackages[i].name.c_str());
683 >                if( binary_search(s.begin(), s.end(), globalPackages[i].modStringName ) )
684 >                        Mods_CheckboxList->Check(i);
685 >        }
686 > }
687 >
688 > void MainWindow::OnLoadClick( wxCommandEvent& event )
689 > {
690 >        if (busy == 1) return;
691 >        static const wxChar *FILETYPES = _T(
692 >                "Mod Loadouts (*.cfg)|*.cfg|"
693 >                "All files (*.*)|*.*"
694 >                );
695 >
696 >        wxFileDialog* openFileDialog =
697 >                new wxFileDialog( this, _("Open Mod Loadout"), "", "", FILETYPES,
698 >                wxOPEN, wxDefaultPosition);
699 >
700 >        if ( openFileDialog->ShowModal() == wxID_OK )
701 >        {
702 >                refreshMods(getInstallString( string(openFileDialog->GetPath()) ));
703 >        }
704 > }
705 >
706 > /*
707 > * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_SAVE
708 > */
709 >
710 > void MainWindow::OnSaveClick( wxCommandEvent& event )
711 > {
712 >        if (busy == 1) return;
713 >        static const wxChar *FILETYPES = _T(
714 >                "Mod Loadouts (*.cfg)|*.cfg|"
715 >                "All files (*.*)|*.*"
716 >                );
717 >
718 >        wxFileDialog* openFileDialog =
719 >                new wxFileDialog( this, _("Open file"), "", "", FILETYPES,
720 >                wxSAVE, wxDefaultPosition);
721 >
722 >        if ( openFileDialog->ShowModal() == wxID_OK )
723 >        {
724 >                if ( exists( openFileDialog->GetPath().c_str() ) )
725 >                {
726 >                        remove( openFileDialog->GetPath().c_str() );
727 >                }
728 >
729 >                ofstream file(openFileDialog->GetPath().c_str());
730 >
731 >                vector<string>list;
732 >                for(unsigned int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) list.push_back( globalPackages[i].modStringName );
733 >                vector<string>::iterator begin_iter = list.begin();
734 >                vector<string>::iterator end_iter = list.end();
735 >
736 >                sort( list.begin(), list.end() );
737 >
738 >                for( ; begin_iter != end_iter; ++begin_iter) {
739 >                        file << *begin_iter << " ";
740 >                }
741 >
742 >                file.close();
743 >                file.clear();
744 >        }
745 > }
746 >
747 > /*
748 > * wxEVT_COMMAND_BUTTON_CLICKED event handler for ReGlobalize_Button
749 > */
750 >
751 > void MainWindow::OnReGlobalizeButtonClick( wxCommandEvent& event )
752 > {
753 >        string YesNoMsg = "WARNING: This will DELETE the Edition's GameDataFolder and recreate it from the vanilla Oni game data.\n";
754 >        YesNoMsg = YesNoMsg + "Are you SURE you want to do this?";
755 >        wxMessageDialog* YesNoDialog = new wxMessageDialog(this, YesNoMsg.c_str(), "AE Installer Alert",  wxYES_NO | wxICON_EXCLAMATION , wxDefaultPosition);
756 >
757 >        if (YesNoDialog->ShowModal() == wxID_NO)
758 >        {
759 >                //if the user said no...
760 >        }
761 >        else
762 >        {
763 >                this->InstallButton->Disable();
764 >                this->ReglobalizeButton->Disable();
765 > #ifdef WIN32
766 >                boost::thread thrd2(globalizeData);
767 >                //globalizeData();
768 >                //boost::thread::create_thread(&globalizeData);
769 >                //       boost::thread_group Tg;
770 >                // Tg.create_thread( &globalizeData(), this );
771 > #else
772 >                globalizeData();
773 > #endif
774 >                this->InstallButton->Enable();
775 >                this->ReglobalizeButton->Enable();
776 >        }
777 > }
778 > /*
779 > * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton
780 > */
781 >
782 > /*
783 > * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Seperated_RadioButton
784 > */
785 >
786 > void MainWindow::OnSeperatedRadioButtonSelected( wxCommandEvent& event )
787 > {
788 >        splitInstances = true;
789 > }
790 >
791 > void MainWindow::OnDirButtonClick( wxCommandEvent& event )
792 > {
793 >        wxDirDialog* newDir = new wxDirDialog(this, "Set current directory", "", wxDD_DEFAULT_STYLE,
794 >                wxDefaultPosition, wxDefaultSize, "wxDirCtrl");
795 >        newDir->ShowModal();
796 >        if(newDir->GetPath()[0]) current_path( (path)newDir->GetPath() );
797 >        OnRefreshButtonClick(event);
798 > }

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)