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 353 by iritscen, Sun Jun 14 23:28:58 2009 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 > AE/Mod Installer
3 > by Gumby and Iritscen
4 > */
5 >
6 > // To-do: - Disable Install button when nothing (new) is selected
7 > //                - Institute lots of checks into file-handling
8 > //                - Clear mod info fields when mod is de-selected
9 >
10 > #define DEBUG
11 > #include <stdio.h>
12 > //#include <conio.h>
13 > //#include <process.h>
14 > #include <string>
15 > #include <iostream>
16 > #include <cctype>
17 > #include <vector>
18 > #include <fstream>
19 > #include <errno.h>
20 > #include <sstream>
21 >
22 > #include "boost/filesystem.hpp" // includes all needed Boost.Filesystem declarations
23 >
24 > #include "installer.h"
25 >
26 > #ifdef WIN32
27 > #include <windows.h>
28 > #else // assume we're on Mac
29 > #include <stdlib.h>
30 > #include <dirent.h>
31 > #endif
32 >
33 > const string strInstallerVersion = "1.0";
34 > const bool SPLIT = 1;
35 > const bool NOT_SPLIT = 0;
36 > bool splitInstances = SPLIT;
37 >
38 > #ifdef WIN32
39 > const string strOniSplit = "Onisplit.exe";
40 > string strImportOption = "-import:nosep";
41 > const char* strClsCmd = "cls";
42 > const char* strPauseCmd = "PAUSE";
43 > #else // set up Mac equivalents since we're in Mac OS
44 > const string strOniSplit = "mono Onisplit.exe";
45 > string strImportOption = "-import:sep";
46 > const char* strClsCmd = "clear";
47 > const char* strPauseCmd = "read -n 1 -p \"Press any key to continue\"";
48 > void Sleep(int ms) { sleep( ms / 1000 ); }
49 > #endif
50 >
51 > using namespace boost::filesystem;
52 > using namespace std;
53 >
54 >
55 > /*
56 > int main(void)
57 > {
58 > if ( exists( "../../GameDataFolder/level0_Final.sep" ) ) splitInstances = NOT_SPLIT;
59 > else splitInstances = NOT_SPLIT;
60 > //     SetConsoleTitle("AE Installer"); windows junk, convert to SDL
61 > #ifdef WIN32  
62 > system("color 0A");
63 > #endif
64 > cout << "\nWelcome to the AE installer!\n";
65 > cout << "\nWhat would you like to do?\n";
66 >
67 > return mainMenu();
68 > }
69 > */
70 >
71 >
72 >
73 > int mainMenu(void)
74 > {
75 >        char choice = '0';
76 >        bool exit = false;
77 >        int err = 0;
78 >        do
79 >        {
80 >                if( exists( "../GameDataFolder" ) ) {
81 >                        cout << "\n1. Add new packages\n";
82 >                        cout << "2. Remove packages\n";
83 >                        cout << "3. See what is installed\n";
84 >                        cout << "4. Globalize data\n";
85 >                        cout << "5. About AE\n";
86 >                        cout << "6. Quit\n\n";
87 >                        
88 >                        choice = cin.get();
89 >                        cin.ignore(128, '\n');
90 >                        switch(choice)
91 >                        {
92 >                                case '1':
93 >                                        err = installPackages();
94 >                                        break;
95 >                                case '2':
96 >                                        err = uninstallPackages();
97 >                                        break;
98 >                                case '3':
99 >                                        err = listInstalledPackages();
100 >                                        break;
101 >                                case '4':
102 >                                        err = globalizeData();
103 >                                        break;
104 >                                case '5':
105 >                                        err = printInstallerInfo();
106 >                                        break;
107 >                                case '6':
108 >                                        exit = true;
109 >                                        break;
110 >                                default:
111 >                                        cout << "Please choose one of the above numbers, and press Enter.\n\n";
112 >                        }
113 >                        if (err) // if something fatal happened
114 >                                exit = true;
115 >                }
116 >                else {
117 >                        cout << "\n1. Globalize data\n";
118 >                        cout << "2. About AE\n";
119 >                        cout << "3. Quit\n\n";
120 >                        
121 >                        choice = cin.get();
122 >                        cin.ignore(128, '\n');
123 >                        switch(choice)
124 >                        {
125 >                                case '1':
126 >                                        err = globalizeData();
127 >                                        break;
128 >                                case '2':
129 >                                        err = printInstallerInfo();
130 >                                        break;
131 >                                case '3':
132 >                                        exit = true;
133 >                                        break;
134 >                                default:
135 >                                        cout << "Please choose one of the above numbers, and press Enter.\n\n";
136 >                        }
137 >                        if (err) // if something fatal happened
138 >                                exit = true;
139 >                }
140 >        } while(!exit);
141 >        
142 >        return err;
143 > }
144 >
145 > int globalizeData(void)
146 > {
147 >        int err = 0;
148 >        
149 >        try {
150 >                int levels[15] = {0, 1, 2, 3, 4, 6, 8, 9, 10, 11, 12, 13, 14, 18, 19}; // the levels Oni has
151 >                char choice = 0;
152 >                
153 >                //SetCurrentDirectory("C:/Program Files/Oni/edition/install");
154 >                char levelnum[3];
155 >                path Characters = "../GameDataFolder/level0_Characters";
156 >                path Particles = "../GameDataFolder/level0_Particles";
157 >                path Archive = "../GameDataFolder/Archive";
158 >                path Textures  = "../GameDataFolder/level0_Textures";
159 >                path Sounds = "../GameDataFolder/level0_Sounds";
160 >                path Animations = "../GameDataFolder/level0_Animations";
161 >                path TRAC = Animations / "level0_TRAC";
162 >                path TRAM = Animations / "level0_TRAM";
163 >                /*
164 >                 if (exists("../GameDataFolder/"))
165 >                 {
166 >                 //cout << "\nIt looks like you've already globalized Oni's data.\nDo you want to re-globalize?\n(This will erase existing mods installed to the AE's game data.)"
167 >                 //      << "\n1. Re-globalize"
168 >                 //      << "\n2. Return to main menu\n";
169 >                 //choice = cin.get();
170 >                 cin.ignore(128, '\n');
171 >                 if (choice == '1')
172 >                 remove_all("../GameDataFolder"); // remove AE GDF
173 >                 if (choice == '2')
174 >                 return 0;
175 >                 }
176 >                 */
177 >                create_directory( "../GameDataFolder/" );
178 >                create_directory( "packages" );
179 >                if (exists("packages/VanillaDats")) remove_all("packages/VanillaDats");
180 >                create_directory( "packages/VanillaDats" );
181 >                
182 >                create_directory( "packages/VanillaDats/level0_Final/" );
183 >                create_directory( Characters );
184 >                create_directory( Particles );
185 >                create_directory( Archive );
186 >                create_directory( Textures );
187 >                create_directory( Sounds );
188 >                create_directory( Animations );
189 >                create_directory( TRAC );
190 >                create_directory( TRAM );
191 >                
192 >                for(int i = 0; i < 15; i++)
193 >                {
194 >                        sprintf(levelnum,"%d",levels[i]); // int to char array
195 >                        exists("../../GameDataFolder/level" + (string)levelnum + "_Final");
196 >                        system((strOniSplit + " -export ../GameDataFolder/level" + (string)levelnum + "_Final ../../GameDataFolder/level" + (string)levelnum + "_Final.dat").c_str());
197 >                        
198 >                        create_directory( "packages/VanillaDats/level" + (string)levelnum + "_Final" ); //remember to cast your arrays as strings :)
199 >                        create_directory( "packages/VanillaDats/level" + (string)levelnum + "_Final/level" + (string)levelnum + "_Final" );
200 >                        
201 >                        directory_iterator end_iter;
202 >                        for ( directory_iterator dir_itr( "../GameDataFolder/level" + (string)levelnum + "_Final" ); dir_itr != end_iter; ++dir_itr )
203 >                        {
204 >                                //cout << dir_itr->path().filename();
205 >                                if ( is_regular_file( dir_itr->status() ) )
206 >                                {
207 >                                        
208 >                                        if ( dir_itr->path().filename().substr(0,8) == "TXMPfail" ||
209 >                                                dir_itr->path().filename().substr(0,9) == "TXMPlevel" ||
210 >                                                ( dir_itr->path().filename().substr(0,4) == "TXMP" && dir_itr->path().filename().find("intro")!=string::npos) ||
211 >                                                dir_itr->path().filename().substr(0,4) == "TXMB" ||
212 >                                                dir_itr->path().filename() == "M3GMpowerup_lsi.oni" ||
213 >                                                dir_itr->path().filename() == "TXMPlsi_icon.oni" ||
214 >                                                ( dir_itr->path().filename().substr(0,4) == "TXMB" && dir_itr->path().filename().find("splash_screen.oni")!=string::npos)       )
215 >                                        {
216 >                                                cout <<dir_itr->path().filename() << "\n";
217 >                                                create_directory( dir_itr->path().parent_path() / "NoGlobal");  
218 >                                                if(!exists( dir_itr->path().parent_path() / "NoGlobal" / dir_itr->filename())) rename(dir_itr->path(), dir_itr->path().parent_path() / "NoGlobal" /
219 >                                                                                                                                                                                                                          dir_itr->filename());
220 >                                                else remove(dir_itr->path());
221 >                                        }
222 >                                        else if (dir_itr->path().filename().substr(0,4) == "TRAC") {
223 >                                                cout <<dir_itr->path().filename() << "\n";
224 >                                                if(!exists( TRAC / dir_itr->filename())) rename(dir_itr->path(), TRAC / dir_itr->filename());
225 >                                                else remove(dir_itr->path());
226 >                                        }
227 >                                        else if (dir_itr->path().filename().substr(0,4) == "TRAM") {
228 >                                                cout <<dir_itr->path().filename() << "\n";
229 >                                                if(!exists( TRAM / dir_itr->filename())) rename(dir_itr->path(), TRAM / dir_itr->filename());
230 >                                                else remove(dir_itr->path());
231 >                                        }
232 >                                        else if (dir_itr->path().filename().substr(0,4) == "ONSK" ||
233 >                                                         dir_itr->path().filename().substr(0,4) == "TXMP") {
234 >                                                cout <<dir_itr->path().filename() << "\n";\
235 >                                                create_directory( dir_itr->path().parent_path() / "TexFix");    
236 >                                                if(!exists( Textures / dir_itr->filename())) rename(dir_itr->path(), Textures / dir_itr->filename());
237 >                                                //rename(dir_itr->path(), dir_itr->path().parent_path() / "TexFix" / dir_itr->filename());
238 >                                        }
239 >                                        else if (dir_itr->path().filename().substr(0,4) == "ONCC"
240 >                                                         || dir_itr->path().filename().substr(0,4) == "TRBS"
241 >                                                         || dir_itr->path().filename().substr(0,4) == "TRMA"
242 >                                                         || dir_itr->path().filename().substr(0,4) == "TRSC"
243 >                                                         || dir_itr->path().filename().substr(0,4) == "TRAS") {
244 >                                                cout <<dir_itr->path().filename() << "\n";
245 >                                                if(!exists( Characters / dir_itr->filename())) rename(dir_itr->path(), Characters / dir_itr->filename());
246 >                                                else remove(dir_itr->path());
247 >                                        }
248 >                                        else if (dir_itr->path().filename().substr(0,4) == "OSBD"
249 >                                                         || dir_itr->path().filename().substr(0,4) == "SNDD") {
250 >                                                cout << dir_itr->path().filename() << "\n";
251 >                                                if(!exists( Sounds / dir_itr->filename())) rename(dir_itr->path(), Sounds / dir_itr->filename());
252 >                                                else remove(dir_itr->path());
253 >                                        }
254 >                                        else if (dir_itr->path().filename().substr(0,5) == "BINA3"
255 >                                                         || dir_itr->path().filename().substr(0,10) == "M3GMdebris"
256 >                                                         || dir_itr->path().filename() == "M3GMtoxic_bubble.oni"
257 >                                                         || dir_itr->path().filename().substr(0,8) == "M3GMelec"
258 >                                                         || dir_itr->path().filename().substr(0,7) == "M3GMrat"
259 >                                                         || dir_itr->path().filename().substr(0,7) == "M3GMjet"
260 >                                                         || dir_itr->path().filename().substr(0,9) == "M3GMbomb_"
261 >                                                         || dir_itr->path().filename() == "M3GMbarab_swave.oni"
262 >                                                         || dir_itr->path().filename() == "M3GMbloodyfoot.oni"
263 >                                                         ){
264 >                                                cout <<dir_itr->path().filename() << "\n";
265 >                                                if(!exists( Particles / dir_itr->filename())) rename(dir_itr->path(), Particles / dir_itr->filename());
266 >                                                else remove(dir_itr->path());
267 >                                        }
268 >                                        else if (dir_itr->path().filename().substr(0,4) == "AGDB"
269 >                                                         || dir_itr->path().filename().substr(0,4) == "TRCM") {
270 >                                                cout <<dir_itr->path().filename() << "\n";
271 >                                                
272 >                                                if(!exists( Archive / dir_itr->filename())) rename(dir_itr->path(), Archive / dir_itr->filename());
273 >                                                else remove(dir_itr->path());
274 >                                        }
275 >                                }
276 >                                
277 >                                
278 >                        }
279 >                        system( (strOniSplit + " -move:delete " + Textures.string() + " ../GameDataFolder/level" + (string)levelnum + "_Final/TXMP*.oni").c_str());
280 >                        
281 >                }
282 >                
283 >                for (int i = 0; i < 15; i++)
284 >                {
285 >                        sprintf(levelnum,"%d",levels[i]);
286 >                        system( (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levelnum + "_Final packages/VanillaDats/level" + levelnum + "_Final/level"
287 >                                         + levelnum + "_Final/level" + levelnum + "_Final.oni").c_str());
288 >                }
289 >                path VanillaCharacters = "packages/VanillaDats/level0_Final/level0_Characters/level0_Characters.oni";
290 >                path VanillaParticles = "packages/VanillaDats/level0_Final/level0_Particles/level0_Particles.oni";
291 >                path VanillaTextures  = "packages/VanillaDats/level0_Final/level0_Textures/level0_Textures.oni";
292 >                path VanillaSounds = "packages/VanillaDats/level0_Final/level0_Sounds/level0_Sounds.oni";
293 >                path VanillaAnimations = "packages/VanillaDats/level0_Final/level0_Animations/level0_Animations.oni";
294 >                path VanillaTRAC = "packages/VanillaDats/level0_Final/level0_Animations/level0_TRAC.oni";
295 >                path VanillaTRAM = "packages/VanillaDats/level0_Final/level0_Animations/level0_TRAM.oni";
296 >                create_directory( VanillaCharacters.parent_path() );
297 >                create_directory( VanillaParticles.parent_path() );
298 >                create_directory( VanillaTextures.parent_path() );
299 >                create_directory( VanillaSounds.parent_path() );
300 >                create_directory( VanillaAnimations.remove_filename() );
301 >                system((strOniSplit + " " + strImportOption + " " + Characters.string() + " " + VanillaCharacters.string()).c_str());
302 >                system((strOniSplit + " " + strImportOption + " " + Particles.string() + " " + VanillaParticles.string()).c_str());
303 >                system((strOniSplit + " " + strImportOption + " " + Textures.string() + " " + VanillaTextures.string()).c_str());
304 >                //system((strOniSplit   + " " + strImportOption + (string)" " + Animations.string() + (string)" " + VanillaAnimations.string()).c_str());
305 >                system((strOniSplit + " " + strImportOption + " " + TRAC.string() + " " + VanillaTRAC.string()).c_str());
306 >                system((strOniSplit + " " + strImportOption + " " + Sounds.string() + " " + VanillaSounds.string()).c_str());
307 >                system((strOniSplit + " " + strImportOption + " " + TRAM.string() + " " + VanillaTRAM.string()).c_str());
308 >                
309 >                create_directory("../GameDataFolder/IGMD");
310 >                copy((path)"packages/VanillaBSL/IGMD", (path)"../GameDataFolder");
311 >        }
312 >        catch (exception ex) {
313 >                cout << ex.what();
314 >        }
315 >        return err;
316 > }
317 >
318 > int installPackages(void)
319 > {
320 >        bool installed_something = 0;
321 >        int err = 0;
322 >        ModPackage package;
323 >        vector<string> installed_packages;
324 >        vector<ModPackage> packages;
325 >        vector<ModPackage>::iterator iter;
326 >        vector<string> installString;
327 >        
328 >        iter = packages.begin();
329 >        packages = getPackages();
330 >        vector<string> installedMods = getInstallString();
331 >        
332 >        if (packages.empty())
333 >        {
334 >                cout << "Error: You have no packages!\n";
335 >                return 0;
336 >        }
337 >        
338 >        cout << "Detecting installed packages...\n";
339 >        
340 >        int index = 1;
341 >        char choice = '0';
342 >        
343 >        for (vector<ModPackage>::iterator package_iter = packages.begin(); package_iter != packages.end(); ++package_iter)
344 >        {
345 >                if (!binary_search(installedMods.begin(), installedMods.end(), package_iter->modStringName))
346 >                { //package_iter->isInstalled :< I forgot about this...
347 >                        //cout << index << " ";
348 >                        system(strClsCmd);
349 >                        cout << (*package_iter).name << "\n";
350 >                        for (int character = 1; character <= (*package_iter).name.length() - 1; character++) cout << '-';
351 >                        cout << "\n"
352 >                        << (*package_iter).readme << "\n\n"
353 >                        << "Please enter a number choice\n"
354 >                        << " 1. Add\n"
355 >                        << " 2. Don't Add\n"
356 >                        << "";
357 >                        index++;
358 >                        choice = 0;
359 >                        
360 >                        do
361 >                        {
362 >                                choice = cin.get();
363 >                                cin.ignore(1280, '\n');
364 >                        } while(choice == 0);
365 >                        
366 >                        if (choice == '1')
367 >                        {
368 >                                cout << "\nInstalling...\n\n";
369 >                                if (package_iter->hasOnis || (package_iter->hasDeltas /*(*package_iter).isUnpacked */ ))
370 >                                {
371 >                                        installed_something = 1;
372 >                                        installedMods.push_back(package_iter->modStringName);
373 >                                        system(strPauseCmd);
374 >                                }
375 >                        }
376 >                }
377 >        }
378 >        if (index == 1)
379 >        {
380 >                cout << "Warning: All packages are already installed\n";
381 >                //would you like to recombine your data?
382 >                return 0;
383 >        }
384 >        if (installed_something == 0)
385 >        {
386 >                cout << "Warning: You didn't add anything!\n";
387 >                //would you like to recombine your data?
388 >                return 0;
389 >        }
390 >        
391 >        sort(installedMods.begin(), installedMods.end());
392 >        //system(Onisplit.c_str());
393 >        recompileAll(installedMods);
394 >        system(strPauseCmd);
395 >        
396 >        return err;
397 > }
398 >
399 > int uninstallPackages(void)
400 > {
401 >        int err = 0;
402 >        ModPackage package;
403 >        vector<string> installed_packages;
404 >        vector<ModPackage> packages;
405 >        vector<ModPackage>::iterator iter;
406 >        vector<string> installString;
407 >        
408 >        iter = packages.begin();
409 >        packages = getPackages();
410 >        
411 >        
412 >        cout << "Detecting installed packages...\n";
413 >        
414 >        vector<string> installedMods = getInstallString();
415 >        
416 >        if (packages.empty())
417 >        {
418 >                cout << "Error: You have no packages!\n";
419 >                return 0;
420 >        }
421 >        
422 >        int index = 0;
423 >        int uninstalled_something = 0;
424 >        char choice = '0';
425 >        
426 >        for (vector<ModPackage>::iterator package_iter = packages.begin(); package_iter != packages.end(); ++package_iter)
427 >        {
428 >                if (binary_search(installedMods.begin(), installedMods.end(), package_iter->modStringName))
429 >                { //package_iter->isInstalled :< I forgot about this...
430 >                        //cout << index << " ";
431 >                        system(strClsCmd);
432 >                        cout << (*package_iter).name << "\n";
433 >                        for (int character = 1; character <= (*package_iter).name.length() - 1; character++) cout << '-';
434 >                        cout << "\n"
435 >                        << (*package_iter).readme << "\n\n"
436 >                        << "Please enter a number choice\n"
437 >                        << " 1. Remove\n"
438 >                        << " 2. Don't Remove\n"
439 >                        << "";
440 >                        
441 >                        choice = 0;
442 >                        
443 >                        do
444 >                        {
445 >                                choice = cin.get();
446 >                                cin.ignore(1280, '\n');
447 >                        } while(choice == 0);
448 >                        
449 >                        if (choice == '1')
450 >                        {
451 >                                cout << "\nUninstalling...\n\n";
452 >                                installedMods.erase( installedMods.begin() + (index) );
453 >                                system(strPauseCmd);
454 >                                uninstalled_something = 1;
455 >                                
456 >                        }
457 >                        else {
458 >                                index++;
459 >                        }
460 >                }
461 >        }
462 >        if ( uninstalled_something == 0 )
463 >        {
464 >                if (index == 0) //bad practice, I need to implement a second vector or something. Meh.
465 >                {
466 >                        cout << "\nWarning: You have no installed packages!";
467 >                }
468 >                else
469 >                {
470 >                        cout << "\nWarning: You didn't remove anything!";
471 >                }
472 >                //would you like to recombine your data?
473 >                return 0;
474 >                
475 >        }      
476 >        sort(installedMods.begin(), installedMods.end());
477 >        //system(Onisplit.c_str());
478 >        recompileAll(installedMods);
479 >        system(strPauseCmd);
480 >        
481 >        return err;
482 > }
483 >
484 > int listInstalledPackages(void)
485 > {
486 >        cout << "\nThis feature not yet implemented.\n\n";
487 >        
488 >        return 0;
489 > }
490 >
491 > int printInstallerInfo(void)
492 > {
493 >        cout << "\nAE/Mod Installer\n";
494 >        cout << "version " << strInstallerVersion << "\n";
495 >        cout << "by Gumby & Iritscen\n";
496 >        cout << "see http://oni.bungie.org/community/forums for more info\n\n";
497 >        
498 >        return 0;
499 > }
500 >
501 > vector<ModPackage> getPackages(void)
502 > {
503 >        vector<ModPackage> packages;
504 >        packages.reserve(65536); // come on, we shouldn't need this much space...right?!
505 >        fstream file;
506 >        string filename = "\0";
507 >        string MODINFO_CFG = "Mod_Info.cfg";
508 >        
509 >        try
510 >        {
511 >                directory_iterator end_iter;
512 >                for (directory_iterator dir_itr("./packages"); dir_itr != end_iter; ++dir_itr)
513 >                {
514 >                        file.open((dir_itr->path().string() + "/" + MODINFO_CFG).c_str());
515 >                        //cout << filename << "\n";
516 >                        
517 >                        if(!file.fail())
518 >                        {
519 >                                //cout << dir_itr->path().string() + MODINFO_CFG;
520 >                                //would prefer to push a pointer to a package, but this will do for now
521 >                                packages.push_back(fileToModPackage(file));
522 >                        }      
523 >                        file.close();
524 >                        file.clear();
525 >                }
526 >        }
527 >        catch (const std::exception & ex)
528 >        {
529 >                cout << "Warning, something odd happened!\n";
530 >        }
531 >        
532 >        return packages;
533 > }
534 >
535 > ModPackage fileToModPackage(fstream &file)
536 > {
537 >        /*
538 >         This converts a file to a ModPackage struct.
539 >        
540 >         A few notes...
541 >         "iter" is the current word we are on. I should have named it "token" or something, but I don't have multiple iterators, so its ok.
542 >         I refer to (*iter) at the beginning of each if statement block. I could probably store it as a variable, but I'm pretty sure that dereferencing a pointer\iterator isn't much
543 >         slower than reading a variable.
544 >         */
545 >        ModPackage package;
546 >        string line;
547 >        static string NameOfMod = "NameOfMod";  //used for comparing to the current token...
548 >        //I could have done it in reverse (*iter).compare("ModString") or  
549 >        static string ARROW = "->";                             //did something like "ModString".compare(*iter), and it would have been
550 >        static string ModString = "ModString";  //functionably the same.
551 >        static string HasOnis = "HasOnis";
552 >        static string HasDeltas = "HasDeltas";
553 >        static string HasBSL = "HasBSL";
554 >        static string HasDats = "HasDats";
555 >        static string IsEngine = "IsEngine";
556 >        static string Readme = "Readme";
557 >        static string GlobalNeeded = "GlobalNeeded";
558 >        static string Category = "Category";
559 >        static string Creator = "Creator";
560 >        while (! file.eof() )
561 >        {
562 >                getline (file,line);
563 >                vector<string> tokens;
564 >                vector<string>::iterator iter;
565 >                tokenize(line, tokens);                                 //string to vector of "words"
566 >                if (tokens.capacity() >= 2) {                   //make sure they are using enough stuff
567 >                        iter = tokens.begin();                          //what word we are on, starts at first word
568 >                        /*
569 >                         if (!AEInstallVersion.compare(*iter))
570 >                         If mod is too old, skip this mod.
571 >                         */
572 >                        /*else*/if (!NameOfMod.compare(*iter))  {       //if it contains the name
573 >                                for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) {     //interates through the words, ends if it reaches the end of the line or a "//" comment
574 >                                        if (ARROW.compare(*iter) && NameOfMod.compare(*iter)) {                 //ignores "->" and "NameOfMod"
575 >                                                //cout << *iter;
576 >                                                //cout << " ";
577 >                                                package.name += *iter + " ";
578 >                                        }
579 >                                }
580 >                                
581 >                        }
582 >                        else if (!ModString.compare(*iter)) {
583 >                                iter++; iter++;
584 >                                package.modStringName = *iter;
585 >                                iter++;
586 >                                package.modStringVersion = atoi((*iter).c_str());
587 >                        }
588 >                        else if (!HasOnis.compare(*iter)) {
589 >                                iter++; iter++;  
590 >                                if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasOnis = 1; //Gotta love c++'s lack of a standard case-insensitive
591 >                                else if (!HasBSL.compare(*iter)) { // string comparer...I know my implementation here sucks. I need to change it to check each character one by one. At the moment,
592 >                                iter++; iter++;}  // using "YFR" would probably set it off. :<
593 >                                
594 >                                if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasBSL = 1;
595 >                        }
596 >                        else if (!HasDeltas.compare(*iter)) {
597 >                                iter++; iter++;  
598 >                                if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasDeltas = 1;
599 >                        }
600 >                        else if (!HasDats.compare(*iter)) {
601 >                                iter++; iter++;  
602 >                                if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.hasDats = 1;
603 >                        }
604 >                        else if (!IsEngine.compare(*iter)) {
605 >                                iter++; iter++;  
606 >                                if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.isEngine = 1;
607 >                        }
608 >                        else if (!GlobalNeeded.compare(*iter)) {
609 >                                iter++; iter++;  
610 >                                if (toupper((*iter)[0]) + toupper((*iter)[1]) + toupper((*iter)[2]) == 'Y' + 'E' + 'S') package.globalNeeded = 1;
611 >                                else if (toupper((*iter)[0]) + toupper((*iter)[1]) == 'N' + 'O') package.globalNeeded = 1; //Really the only place where checking for "No" is important atm.
612 >                        }
613 >                        else if (!Category.compare(*iter))  {  
614 >                                for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) {     //interates through the words, ends if it reaches the end of the line or a "//" comment
615 >                                        if (ARROW.compare(*iter) && Category.compare(*iter)) {                  //ignores "->" and "Category"
616 >                                                //cout << *iter;
617 >                                                //cout << " ";
618 >                                                package.category += *iter + " ";
619 >                                        }
620 >                                }
621 >                        }
622 >                        else if (!Creator.compare(*iter))  {    //if it contains the name
623 >                                for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) {     //interates through the words, ends if it reaches the end of the line or a "//" comment
624 >                                        if (ARROW.compare(*iter) && Creator.compare(*iter)) {                   //ignores "->" and "Category"
625 >                                                //cout << *iter;
626 >                                                //cout << " ";
627 >                                                package.creator += *iter + " ";
628 >                                        }
629 >                                }
630 >                        }
631 >                        else if (!Readme.compare(*iter))  {     //if it contains the name
632 >                                for ( ; iter !=tokens.end() && SLASHSLASH.compare(*iter); iter++) {     //interates through the words, ends if it reaches the end of the line or a "//" comment
633 >                                        if (ARROW.compare(*iter) && Readme.compare(*iter)) {                    //ignores "->" and "Category"
634 >                                                if(!(*iter).compare("\\n")) package.readme += '\n';
635 >                                                else package.readme += *iter + " ";
636 >                                        }
637 >                                }
638 >                        }
639 >                }
640 >                
641 >        }
642 >        package.doOutput();
643 >        return package;
644 > }
645 >
646 > void recompileAll(vector<string> installedMods)
647 > {
648 > #ifdef WIN32
649 >        RedirectIOToConsole();
650 >        HWND hWnd = GetConsoleWindow();
651 >        ShowWindow( hWnd, SW_HIDE );
652 > #endif
653 >        setStatusArea("Importing levels...");
654 >        //setStatusArea("Recompiling Data...");
655 >        path vanilla_dir = "./packages/VanillaDats/";
656 >        string importCommand = "";
657 >        char statusString[128];
658 >        int numberOfDats = 0;
659 >        int j = 1;
660 >        string datString;
661 >        std::stringstream out;
662 >        
663 >        
664 >        clearOldDats();
665 >        remove("Onisplit.log");
666 >        if(splitInstances == SPLIT){
667 >                recursive_directory_iterator end_iter;
668 >                
669 >                for ( recursive_directory_iterator dir_itr( vanilla_dir );
670 >                         dir_itr != end_iter;
671 >                         ++dir_itr )
672 >                {
673 >                        try{
674 >                                if ( is_directory( dir_itr->status() ) &&  dir_itr.level() == 1)
675 >                                {
676 >                                        numberOfDats++;
677 >                                }
678 >                        }
679 >                        catch(exception ex) {
680 >                                
681 >                        }
682 >                }
683 >                
684 >                //recursive_directory_iterator end_iter;
685 >                
686 >                
687 >                out << numberOfDats;
688 >                datString = out.str();
689 >                try {
690 >                        for ( recursive_directory_iterator dir_itr( vanilla_dir );
691 >                                 dir_itr != end_iter;
692 >                                 ++dir_itr )
693 >                        {
694 >                                try
695 >                                {
696 >                                        if ( is_directory( dir_itr->status() ) &&  dir_itr.level() == 1)
697 >                                        {
698 >                                                importCommand = strOniSplit + " " + strImportOption + " " + dir_itr->path().parent_path().string() + '/' + dir_itr->path().filename();
699 >                                                for (int i = 0; i < installedMods.size(); ++i) {
700 >                                                        if (exists("packages/" + installedMods[i] + "/oni/" + dir_itr->path().parent_path().filename() + '/' + dir_itr->path().filename()  ))
701 >                                                                importCommand += " packages/" + installedMods[i] + "/oni/" + dir_itr->path().parent_path().filename() + '/' + dir_itr->path().filename();
702 >                                                        
703 >                                                        //else cout << " packages/VanillaDats/" + installedMods[i] + "/oni/";
704 >                                                }
705 >                                                importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Onisplit.log";
706 >                                                
707 >                                                sprintf(statusString,"%d/%i\0",j,numberOfDats);
708 >                                                setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats
709 >                                                setStatusArea("Importing " +  dir_itr->path().filename() + " " + statusString);
710 >                                                
711 >                                                system(importCommand.c_str());
712 >                                                //Sleep(1000);
713 >                                                //cout << importCommand << "\n";
714 >                                                j++;
715 >                                                
716 >                                        }
717 >                                }
718 >                                catch ( const std::exception & ex )
719 >                                {
720 >                                        cout << "Warning, exception " << ex.what() << "!";
721 >                                }
722 >                        }
723 >                        
724 >                }
725 >                catch( const std::exception & ex ) {
726 >                        cout << "Warning, exception " << ex.what() << "!\n"
727 >                        << "You probably need to re-globalize.";
728 >                        //create_directory( "./packages/VanillaDats" );
729 >                }
730 >                
731 >        }
732 >        else if(splitInstances == NOT_SPLIT){
733 >                directory_iterator end_iter;
734 >                
735 >                for ( directory_iterator dir_itr( vanilla_dir );
736 >                         dir_itr != end_iter;
737 >                         ++dir_itr )
738 >                {
739 >                        
740 >                        if ( is_directory( dir_itr->status() ) )
741 >                        {
742 >                                numberOfDats++;
743 >                        }
744 >                        
745 >                        
746 >                }
747 >                
748 >                out << numberOfDats;
749 >                datString = out.str();
750 >                
751 >                for ( directory_iterator dir_itr( vanilla_dir );
752 >                         dir_itr != end_iter;
753 >                         ++dir_itr )
754 >                {
755 >                        try
756 >                        {
757 >                                if ( is_directory( dir_itr->status() ) )
758 >                                {
759 >                                        importCommand = strOniSplit + " " + strImportOption + " " + vanilla_dir.string() + dir_itr->path().filename() + " " + "../GameDataFolder/" + dir_itr->path().filename()
760 >                                        + ".dat";
761 >                                        for (int i = 0; i < installedMods.size(); ++i) {
762 >                                                if (exists("packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename()  ))
763 >                                                        importCommand += " packages/" + installedMods[i] + "/oni/" + dir_itr->path().filename();
764 >                                        }
765 >                                        importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat";
766 >                                        
767 >                                        sprintf(statusString,"%d/%i\0",j,numberOfDats);
768 >                                        setProgressBar( (int)(1000 * (float)(j-1) / (float)numberOfDats) ); //100% * dat we're on / total dats
769 >                                        setStatusArea("Importing " +  dir_itr->path().filename() + " " + statusString);
770 >                                        
771 >                                        system(importCommand.c_str());
772 >                                        
773 >                                        j++;
774 >                                }
775 >                        }
776 >                        catch ( const std::exception & ex )
777 >                        {
778 >                                cout << "Warning, something odd happened!\n";
779 >                        }
780 >                }
781 >        }
782 >        writeInstalledMods(installedMods);
783 >        setProgressBar(1000);
784 >        setStatusArea("Done!");
785 >        Sleep(1000);
786 >        setProgressBar(0);
787 > }
788 >
789 > void writeInstalledMods(vector<string> installedMods)
790 > {
791 >        
792 >        if ( exists( strInstallCfg ) )
793 >        {
794 >                remove( strInstallCfg );
795 >        }
796 >        
797 >        ofstream file(strInstallCfg.c_str());
798 >        
799 >        vector<string>list = installedMods;
800 >        vector<string>::iterator begin_iter = list.begin();
801 >        vector<string>::iterator end_iter = list.end();
802 >        
803 >        sort( list.begin(), list.end() );
804 >        
805 >        for( ; begin_iter != end_iter; ++begin_iter) {
806 >                file << *begin_iter << " ";
807 >        }
808 >        
809 >        file.close();
810 >        file.clear();
811 >        
812 > }
813 >
814 > vector<string> getInstallString(string Cfg)
815 > {
816 >        //system(strPauseCmd);
817 >        vector<string> returnval;
818 >        
819 >        string line;
820 >        fstream file;
821 >        
822 >        if (exists( Cfg ))
823 >        {
824 >                file.open(Cfg.c_str());
825 >                getline(file, line);
826 >                tokenize(line, returnval);
827 >                file.close();
828 >                file.clear();
829 >                sort(returnval.begin(), returnval.end());
830 >        }
831 >        else cout << "fail";
832 >        
833 >        return returnval;
834 > }
835 >
836 > //stolen token function...
837 > void tokenize(const string& str, vector<string>& tokens, const string& delimiters)
838 > {
839 >        // Skip delimiters at beginning.
840 >        string::size_type lastPos = str.find_first_not_of(delimiters, 0);
841 >        // Find first "non-delimiter".
842 >        string::size_type pos     = str.find_first_of(delimiters, lastPos);
843 >        
844 >        while (string::npos != pos || string::npos != lastPos)
845 >        {
846 >                // Found a token, add it to the vector.
847 >                tokens.push_back(str.substr(lastPos, pos - lastPos));
848 >                // Skip delimiters.  Note the "not_of"
849 >                lastPos = str.find_first_not_of(delimiters, pos);
850 >                // Find next "non-delimiter"
851 >                pos = str.find_first_of(delimiters, lastPos);
852 >        }
853 > }
854 >
855 > void clearOldDats(void) {
856 >        directory_iterator end_iter_gdf;
857 >        for ( directory_iterator dir_itr_gdf( "../GameDataFolder" );
858 >                 dir_itr_gdf != end_iter_gdf;
859 >                 ++dir_itr_gdf )
860 >        {
861 >                //cout << dir_itr_gdf->path().extension() << "\n";
862 >                if ( dir_itr_gdf->path().extension() == ".dat" || dir_itr_gdf->path().extension() == ".raw" || dir_itr_gdf->path().extension() == ".sep" ) {
863 >                        remove( dir_itr_gdf->path() );
864 >                }
865 >                
866 >        }
867 >        
868 > }
869 >
870 > vector<string> globalInstalledMods;
871 > vector<ModPackage> globalPackages;
872 > #include "boost/thread.hpp"
873 > #include <boost/thread/mutex.hpp>
874 >
875 > /////////////////////////////////////////////////////////////////////////////
876 > // Name:        main_window.cpp
877 > // Purpose:    
878 > // Author:      
879 > // Modified by:
880 > // Created:     07/05/2009 20:38:25
881 > // RCS-ID:      
882 > // Copyright:  
883 > // Licence:    
884 > /////////////////////////////////////////////////////////////////////////////
885 >
886 > // For compilers that support precompilation, includes "wx/wx.h".
887 > #include "wx/wxprec.h"
888 >
889 > #ifdef __BORLANDC__
890 > #pragma hdrstop
891 > #endif
892 >
893 > #ifndef WX_PRECOMP
894 > #include "wx/wx.h"
895 > #endif
896 >
897 > ////@begin includes
898 > #include "about_window.h"
899 > ////@end includes
900 >
901 > #include "main_window.h"
902 >
903 > ////@begin XPM images
904 > #include "redo.xpm"
905 > #include "fileopen.xpm"
906 > #include "filesaveas.xpm"
907 > #include "quit.xpm"
908 > ////@end XPM images
909 >
910 > //#define wxDebug 1;
911 > //#define wxUSE_UNICODE 1;
912 >
913 > /*
914 > * MainWindow type definition
915 > */
916 >
917 > IMPLEMENT_CLASS( MainWindow, wxFrame )
918 >
919 >
920 > /*
921 > * MainWindow event table definition
922 > */
923 >
924 > BEGIN_EVENT_TABLE( MainWindow, wxFrame )
925 >
926 > ////@begin MainWindow event table entries
927 >    EVT_CHECKBOX( SelectAll_Checkbox, MainWindow::OnSelectAllCheckboxClick )
928 >
929 >    EVT_BUTTON( Refresh_Button, MainWindow::OnRefreshButtonClick )
930 >
931 >    EVT_LISTBOX( Mods_CheckboxList1, MainWindow::OnModsCheckboxList1Selected )
932 >    EVT_CHECKLISTBOX( Mods_CheckboxList1, MainWindow::OnModsCheckboxList1Toggled )
933 >
934 >    EVT_UPDATE_UI( ID_STATUSBAR, MainWindow::OnStatusbarUpdate )
935 >
936 >    EVT_BUTTON( Install_Button, MainWindow::OnInstallButtonClick )
937 >
938 >    EVT_RADIOBUTTON( Sep_RadioButton, MainWindow::OnSepRadioButtonSelected )
939 >
940 >    EVT_RADIOBUTTON( NoSep_RadioButton, MainWindow::OnNoSepRadioButtonSelected )
941 >
942 >    EVT_RADIOBUTTON( Separated_RadioButton, MainWindow::OnSeparatedRadioButtonSelected )
943 >
944 >    EVT_RADIOBUTTON( Complete_RadioButton, MainWindow::OnCompleteRadioButtonSelected )
945 >
946 >    EVT_BUTTON( ReGlobalize_Button, MainWindow::OnReGlobalizeButtonClick )
947 >
948 >    EVT_MENU( wxID_LOAD, MainWindow::OnLoadClick )
949 >
950 >    EVT_MENU( wxID_SAVE, MainWindow::OnSaveClick )
951 >
952 >    EVT_MENU( wxID_EXIT, MainWindow::OnExitClick )
953 >
954 >    EVT_MENU( wxID_OPTIONS, MainWindow::OnOptionsClick )
955 >
956 >    EVT_MENU( wxID_ABOUT, MainWindow::OnAboutClick )
957 >
958 > ////@end MainWindow event table entries
959 >
960 > END_EVENT_TABLE()
961 >
962 >
963 > /*
964 > * MainWindow constructors
965 > */
966 >
967 > MainWindow::MainWindow()
968 > {
969 >    Init();
970 > }
971 >
972 > MainWindow::MainWindow( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
973 > {
974 >    Init();
975 >    Create( parent, id, caption, pos, size, style );
976 > }
977 >
978 >
979 > /*
980 > * MainWindow creator
981 > */
982 >
983 > bool MainWindow::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
984 > {
985 > ////@begin MainWindow creation
986 >    wxFrame::Create( parent, id, caption, pos, size, style );
987 >
988 >    CreateControls();
989 >    SetIcon(GetIconResource(wxT("oni_special.ico")));
990 >    Centre();
991 > ////@end MainWindow creation
992 >    return true;
993 > }
994 >
995 >
996 > /*
997 > * MainWindow destructor
998 > */
999 >
1000 > MainWindow::~MainWindow()
1001 > {
1002 > ////@begin MainWindow destruction
1003 > ////@end MainWindow destruction
1004 > }
1005 >
1006 >
1007 > /*
1008 > * Member initialisation
1009 > */
1010 >
1011 > void MainWindow::Init()
1012 > {
1013 > ////@begin MainWindow member initialisation
1014 >    MainSplitter = NULL;
1015 >    SelectAll = NULL;
1016 >    RefreshButton = NULL;
1017 >    Mods_CheckboxList = NULL;
1018 >    titleText = NULL;
1019 >    creatorText = NULL;
1020 >    descriptionText = NULL;
1021 >    StatusArea = NULL;
1022 >    ProgressBar = NULL;
1023 >    InstallButton = NULL;
1024 >    OptionsPanel = NULL;
1025 >    SepRadio = NULL;
1026 >    NoSepRadio = NULL;
1027 >    SeparatedRadio = NULL;
1028 >    CompleteRadio = NULL;
1029 >    ReglobalizeButton = NULL;
1030 > ////@end MainWindow member initialisation
1031 >
1032 > }
1033 >
1034 >
1035 > /*
1036 > * Control creation for MainWindow
1037 > */
1038 > wxStatusBar **TheStatusBar;
1039 > wxButton* TheInstallButton;
1040 > wxGauge* TheProgressBar;
1041 > void MainWindow::CreateControls()
1042 > {    
1043 > ////@begin MainWindow content construction
1044 >    // Generated by DialogBlocks, 31/05/2009 19:03:55 (unregistered)
1045 >
1046 >    MainWindow* itemFrame1 = this;
1047 >
1048 >    wxMenuBar* menuBar = new wxMenuBar;
1049 >    wxMenu* itemMenu37 = new wxMenu;
1050 >    {
1051 >        wxMenuItem* menuItem = new wxMenuItem(itemMenu37, wxID_LOAD, _("&Load Configuration..."), wxEmptyString, wxITEM_NORMAL);
1052 >        wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("fileopen.xpm")));
1053 >        menuItem->SetBitmap(bitmap);
1054 >        itemMenu37->Append(menuItem);
1055 >    }
1056 >    {
1057 >        wxMenuItem* menuItem = new wxMenuItem(itemMenu37, wxID_SAVE, _("&Save Configuration..."), wxEmptyString, wxITEM_NORMAL);
1058 >        wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("filesaveas.xpm")));
1059 >        menuItem->SetBitmap(bitmap);
1060 >        itemMenu37->Append(menuItem);
1061 >    }
1062 >    itemMenu37->AppendSeparator();
1063 >    {
1064 >        wxMenuItem* menuItem = new wxMenuItem(itemMenu37, wxID_EXIT, _("Exit"), wxEmptyString, wxITEM_NORMAL);
1065 >        wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("quit.xpm")));
1066 >        menuItem->SetBitmap(bitmap);
1067 >        itemMenu37->Append(menuItem);
1068 >    }
1069 >    menuBar->Append(itemMenu37, _("&File"));
1070 >    wxMenu* itemMenu42 = new wxMenu;
1071 >    itemMenu42->Append(wxID_OPTIONS, _("Show Advanced Options..."), wxEmptyString, wxITEM_CHECK);
1072 >    menuBar->Append(itemMenu42, _("Options"));
1073 >    wxMenu* itemMenu44 = new wxMenu;
1074 >    itemMenu44->Append(wxID_HELP, _("Help"), wxEmptyString, wxITEM_NORMAL);
1075 >    itemMenu44->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL);
1076 >    menuBar->Append(itemMenu44, _("Help"));
1077 >    itemFrame1->SetMenuBar(menuBar);
1078 >
1079 >    wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
1080 >    itemFrame1->SetSizer(itemBoxSizer2);
1081 >
1082 >    MainSplitter = new wxSplitterWindow( itemFrame1, ID_SPLITTERWINDOW, wxDefaultPosition, wxSize(100, 100), wxSP_LIVE_UPDATE|wxNO_BORDER );
1083 >    MainSplitter->SetMinimumPaneSize(150);
1084 >    MainSplitter->SetName(_T("MainSplitter"));
1085 >
1086 >    wxPanel* itemPanel4 = new wxPanel( MainSplitter, ID_PANEL, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
1087 >    wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL);
1088 >    itemPanel4->SetSizer(itemBoxSizer5);
1089 >
1090 >    wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxHORIZONTAL);
1091 >    itemBoxSizer5->Add(itemBoxSizer6, 0, wxGROW|wxALL, 0);
1092 >    SelectAll = new wxCheckBox( itemPanel4, SelectAll_Checkbox, _("Select All/None"), wxDefaultPosition, wxDefaultSize, wxCHK_3STATE );
1093 >    SelectAll->SetValue(false);
1094 >    SelectAll->SetName(_T("SelectAll_Checkbox"));
1095 >    itemBoxSizer6->Add(SelectAll, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
1096 >
1097 >    RefreshButton = new wxBitmapButton( itemPanel4, Refresh_Button, itemFrame1->GetBitmapResource(wxT("redo.xpm")), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
1098 >    RefreshButton->SetName(_T("RefreshButton"));
1099 >    itemBoxSizer6->Add(RefreshButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM, 5);
1100 >
1101 >    wxArrayString Mods_CheckboxListStrings;
1102 >    Mods_CheckboxList = new wxCheckListBox( itemPanel4, Mods_CheckboxList1, wxDefaultPosition, wxDefaultSize, Mods_CheckboxListStrings, wxLB_HSCROLL );
1103 >    Mods_CheckboxList->SetName(_T("Mods_CheckboxList"));
1104 >    itemBoxSizer5->Add(Mods_CheckboxList, 1, wxGROW|wxALL, 0);
1105 >
1106 >    wxPanel* itemPanel10 = new wxPanel( MainSplitter, DescriptionHolder_Panel, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
1107 >    itemPanel10->SetName(_T("DescriptionHolder_Panel"));
1108 >    wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxVERTICAL);
1109 >    itemPanel10->SetSizer(itemBoxSizer11);
1110 >
1111 >    wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxHORIZONTAL);
1112 >    itemBoxSizer11->Add(itemBoxSizer12, 0, wxGROW|wxALL, 0);
1113 >    wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxVERTICAL);
1114 >    itemBoxSizer12->Add(itemBoxSizer13, 1, wxALIGN_CENTER_VERTICAL|wxALL, 0);
1115 >    titleText = new wxTextCtrl( itemPanel10, Title_Text, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
1116 >    titleText->SetName(_T("Title_Text"));
1117 >    titleText->SetBackgroundColour(wxColour(240, 240, 240));
1118 >    itemBoxSizer13->Add(titleText, 1, wxGROW|wxLEFT, 5);
1119 >
1120 >    wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxVERTICAL);
1121 >    itemBoxSizer12->Add(itemBoxSizer15, 1, wxGROW|wxALL, 0);
1122 >    creatorText = new wxTextCtrl( itemPanel10, Author_Text, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY|wxTE_RIGHT );
1123 >    creatorText->SetName(_T("Author_Text"));
1124 >    creatorText->SetBackgroundColour(wxColour(240, 240, 240));
1125 >    itemBoxSizer15->Add(creatorText, 1, wxGROW|wxRIGHT, 5);
1126 >
1127 >    wxStaticLine* itemStaticLine17 = new wxStaticLine( itemPanel10, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
1128 >    itemStaticLine17->Show(false);
1129 >    itemBoxSizer11->Add(itemStaticLine17, 0, wxGROW|wxALL, 5);
1130 >
1131 >    descriptionText = new wxTextCtrl( itemPanel10, Description_Text, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxTE_RICH|wxTE_AUTO_URL );
1132 >    descriptionText->SetName(_T("DescriptionName"));
1133 >    descriptionText->SetBackgroundColour(wxColour(240, 240, 240));
1134 >    itemBoxSizer11->Add(descriptionText, 1, wxGROW|wxLEFT|wxRIGHT, 5);
1135 >
1136 >    MainSplitter->SplitVertically(itemPanel4, itemPanel10, 150);
1137 >    itemBoxSizer2->Add(MainSplitter, 1, wxGROW|wxALL, 0);
1138 >
1139 >    StatusArea = new wxStatusBar( itemFrame1, ID_STATUSBAR, 0 );
1140 >    StatusArea->SetName(_T("StatusArea"));
1141 >    StatusArea->SetFieldsCount(1);
1142 >    StatusArea->SetStatusText(_("Status Area"), 0);
1143 >    itemBoxSizer2->Add(StatusArea, 0, wxGROW|wxALL, 0);
1144 >
1145 >    wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxHORIZONTAL);
1146 >    itemBoxSizer2->Add(itemBoxSizer20, 0, wxGROW|wxALL, 0);
1147 >
1148 >    ProgressBar = new wxGauge( itemFrame1, ProgressBar_Gauge, 1000, wxDefaultPosition, wxSize(-1, 30), wxGA_SMOOTH );
1149 >    ProgressBar->SetValue(0);
1150 >    itemBoxSizer20->Add(ProgressBar, 1, wxGROW|wxALL, 0);
1151 >
1152 >    InstallButton = new wxButton( itemFrame1, Install_Button, _("Install!"), wxDefaultPosition, wxSize(-1, 30), 0 );
1153 >    itemBoxSizer20->Add(InstallButton, 0, wxGROW|wxALL, 0);
1154 >
1155 >    wxBoxSizer* itemBoxSizer23 = new wxBoxSizer(wxVERTICAL);
1156 >    itemBoxSizer2->Add(itemBoxSizer23, 0, wxGROW|wxALL, 0);
1157 >
1158 >    OptionsPanel = new wxPanel( itemFrame1, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
1159 >    itemBoxSizer2->Add(OptionsPanel, 0, wxGROW, 0);
1160 >
1161 >    wxBoxSizer* itemBoxSizer25 = new wxBoxSizer(wxHORIZONTAL);
1162 >    OptionsPanel->SetSizer(itemBoxSizer25);
1163 >
1164 >    wxBoxSizer* itemBoxSizer26 = new wxBoxSizer(wxVERTICAL);
1165 >    itemBoxSizer25->Add(itemBoxSizer26, 0, wxGROW|wxALL, 5);
1166 >
1167 >    SepRadio = new wxRadioButton( OptionsPanel, Sep_RadioButton, _("Sep"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
1168 >    SepRadio->SetValue(false);
1169 >    if (MainWindow::ShowToolTips())
1170 >        SepRadio->SetToolTip(_("For PC Demo and Mac"));
1171 >    itemBoxSizer26->Add(SepRadio, 0, wxALIGN_LEFT|wxALL, 5);
1172 >
1173 >    NoSepRadio = new wxRadioButton( OptionsPanel, NoSep_RadioButton, _("NoSep"), wxDefaultPosition, wxDefaultSize, 0 );
1174 >    NoSepRadio->SetValue(false);
1175 >    if (MainWindow::ShowToolTips())
1176 >        NoSepRadio->SetToolTip(_("For PC Retail"));
1177 >    itemBoxSizer26->Add(NoSepRadio, 0, wxALIGN_LEFT|wxALL, 5);
1178 >
1179 >    wxStaticLine* itemStaticLine29 = new wxStaticLine( OptionsPanel, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
1180 >    itemBoxSizer25->Add(itemStaticLine29, 0, wxGROW|wxALL, 5);
1181 >
1182 >    wxBoxSizer* itemBoxSizer30 = new wxBoxSizer(wxVERTICAL);
1183 >    itemBoxSizer25->Add(itemBoxSizer30, 0, wxGROW|wxALL, 5);
1184 >
1185 >    SeparatedRadio = new wxRadioButton( OptionsPanel, Separated_RadioButton, _("Separated Level0"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
1186 >    SeparatedRadio->SetValue(false);
1187 >    SeparatedRadio->SetName(_T("Separated_RadioButton"));
1188 >    itemBoxSizer30->Add(SeparatedRadio, 0, wxALIGN_LEFT|wxALL, 5);
1189 >
1190 >    CompleteRadio = new wxRadioButton( OptionsPanel, Complete_RadioButton, _("Complete Level0"), wxDefaultPosition, wxDefaultSize, 0 );
1191 >    CompleteRadio->SetValue(false);
1192 >    CompleteRadio->SetName(_T("Complete_RadioButton"));
1193 >    itemBoxSizer30->Add(CompleteRadio, 0, wxALIGN_LEFT|wxALL, 5);
1194 >
1195 >    wxStaticLine* itemStaticLine33 = new wxStaticLine( OptionsPanel, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
1196 >    itemBoxSizer25->Add(itemStaticLine33, 0, wxGROW|wxALL, 5);
1197 >
1198 >    wxBoxSizer* itemBoxSizer34 = new wxBoxSizer(wxVERTICAL);
1199 >    itemBoxSizer25->Add(itemBoxSizer34, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
1200 >
1201 >    ReglobalizeButton = new wxButton( OptionsPanel, ReGlobalize_Button, _("Reglobalize"), wxDefaultPosition, wxDefaultSize, 0 );
1202 >    ReglobalizeButton->SetName(_T("Reglobalize_Button"));
1203 >    itemBoxSizer34->Add(ReglobalizeButton, 0, wxGROW|wxALL, 5);
1204 >
1205 >    // Connect events and objects
1206 >    Mods_CheckboxList->Connect(Mods_CheckboxList1, wxEVT_CREATE, wxWindowCreateEventHandler(MainWindow::ModList_OnCreate), NULL, this);
1207 > ////@end MainWindow content construction
1208 >        
1209 >        if ( exists( "../../GameDataFolder/level0_Final.sep" ) ) {
1210 >                static_cast<string>("-import:sep");
1211 >                splitInstances = NOT_SPLIT;
1212 >        }
1213 >        else {
1214 >                static_cast<string>("-import:nosep");
1215 >                splitInstances = SPLIT;
1216 >        }
1217 >
1218 >        globalPackages = getPackages();
1219 >        globalInstalledMods = getInstallString();
1220 >                for (int i = 0; i < globalPackages.size(); i++) {
1221 >                        Mods_CheckboxList->Append(globalPackages[i].name.c_str());
1222 >                        if( binary_search(globalInstalledMods.begin(), globalInstalledMods.end(), globalPackages[i].modStringName ) ) Mods_CheckboxList->Check(i);
1223 >        }
1224 >                TheStatusBar = &StatusArea;
1225 >                TheInstallButton = InstallButton;
1226 >                TheProgressBar = ProgressBar;
1227 >                OptionsPanel->Hide();
1228 >                if(splitInstances == SPLIT) SeparatedRadio->SetValue(true);
1229 >                else CompleteRadio->SetValue(true);
1230 >                
1231 >                
1232 >                
1233 >                if(strImportOption == "-import:nosep") NoSepRadio->SetValue(true);
1234 >                else SepRadio->SetValue(true);
1235 >
1236 >                        //MainWindow::SetSize(MainWindow::GetRect().GetWidth(), MainWindow::GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight() );
1237 > }
1238 >
1239 >                
1240 > /*
1241 > * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for SelectAll_Checkbox
1242 > */
1243 >
1244 > void MainWindow::OnSelectAllCheckboxClick( wxCommandEvent& event )
1245 > {
1246 >                switch(SelectAll->Get3StateValue()) {
1247 >        case wxCHK_UNCHECKED:
1248 >                for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false);
1249 >                //SelectAll->Set3StateValue(wxCHK_CHECKED);
1250 >                break;
1251 >        case wxCHK_CHECKED:
1252 >                for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, true);
1253 >                //SelectAll->Set3StateValue(wxCHK_UNCHECKED);
1254 >                break;
1255 >        case wxCHK_UNDETERMINED:
1256 >                for(int i = 0; i < globalPackages.size(); i++) Mods_CheckboxList->Check(i, false);
1257 >                //SelectAll->Set3StateValue(wxCHK_CHECKED);
1258 >                break;
1259 >
1260 >        }
1261 >        
1262 > }
1263 >
1264 >
1265 > /*
1266 > * wxEVT_CREATE event handler for Mods_CheckboxList
1267 > */
1268 >
1269 > void MainWindow::ModList_OnCreate( wxWindowCreateEvent& event )
1270 > {
1271 >
1272 >
1273 > }
1274 >
1275 >
1276 > /*
1277 > * Should we show tooltips?
1278 > */
1279 >
1280 > bool MainWindow::ShowToolTips()
1281 > {
1282 >    return true;
1283 > }
1284 >
1285 > /*
1286 > * Get bitmap resources
1287 > */
1288 >
1289 > wxBitmap MainWindow::GetBitmapResource( const wxString& name )
1290 > {
1291 >    // Bitmap retrieval
1292 > ////@begin MainWindow bitmap retrieval
1293 >    wxUnusedVar(name);
1294 >    if (name == _T("redo.xpm"))
1295 >    {
1296 >        wxBitmap bitmap(redo_xpm);
1297 >        return bitmap;
1298 >    }
1299 >    else if (name == _T("fileopen.xpm"))
1300 >    {
1301 >        wxBitmap bitmap( fileopen_xpm);
1302 >        return bitmap;
1303 >    }
1304 >    else if (name == _T("filesaveas.xpm"))
1305 >    {
1306 >        wxBitmap bitmap( filesaveas_xpm);
1307 >        return bitmap;
1308 >    }
1309 >    else if (name == _T("quit.xpm"))
1310 >    {
1311 >        wxBitmap bitmap( quit_xpm);
1312 >        return bitmap;
1313 >    }
1314 >    return wxNullBitmap;
1315 > ////@end MainWindow bitmap retrieval
1316 > }
1317 >
1318 > /*
1319 > * Get icon resources
1320 > */
1321 >
1322 > wxIcon MainWindow::GetIconResource( const wxString& name )
1323 > {
1324 >    // Icon retrieval
1325 > ////@begin MainWindow icon retrieval
1326 >    wxUnusedVar(name);
1327 >    if (name == _T("oni_special.ico"))
1328 >    {
1329 >        wxIcon icon(_T("oni_special.ico"), wxBITMAP_TYPE_ICO);
1330 >        return icon;
1331 >    }
1332 >    return wxNullIcon;
1333 > ////@end MainWindow icon retrieval
1334 > }
1335 >
1336 >
1337 > /*
1338 > * wxEVT_COMMAND_LISTBOX_SELECTED event handler for Mods_CheckboxList1
1339 > */
1340 >
1341 > void MainWindow::OnModsCheckboxList1Selected( wxCommandEvent& event )
1342 > {
1343 >        //event.GetSelection
1344 >        titleText->SetValue(globalPackages[event.GetSelection()].name.c_str());
1345 >        creatorText->SetValue(globalPackages[event.GetSelection()].creator.c_str());
1346 >        descriptionText->SetValue(globalPackages[event.GetSelection()].readme.c_str());
1347 >
1348 >        //creatorText->Refresh();
1349 > }
1350 >
1351 >
1352 > /*
1353 > * wxEVT_COMMAND_CHECKLISTBOX_TOGGLED event handler for Mods_CheckboxList1
1354 > */
1355 >
1356 > void MainWindow::OnModsCheckboxList1Toggled( wxCommandEvent& event )
1357 > {
1358 >        SelectAll->Set3StateValue(wxCHK_UNDETERMINED);
1359 >        if(event.GetInt()) {
1360 >        /*
1361 >                switch(SelectAll->Get3StateValue()) {
1362 >        case wxCHK_UNCHECKED:
1363 >                break;
1364 >        case wxCHK_CHECKED:
1365 >                break;
1366 >        case wxCHK_UNDETERMINED :
1367 >                break;
1368 >        }
1369 >        */
1370 >        }
1371 > }
1372 >
1373 >
1374 > /*
1375 > * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_OPTIONS
1376 > */
1377 >
1378 > void MainWindow::OnOptionsClick( wxCommandEvent& event )
1379 > {
1380 >        
1381 >        if (!event.GetInt() ) {
1382 >                OptionsPanel->Hide();
1383 >                MainWindow::SetSize(MainWindow::GetRect().GetWidth(), MainWindow::GetRect().GetHeight()-OptionsPanel->GetRect().GetHeight());}
1384 >        else {
1385 >                OptionsPanel->Show();
1386 >                MainWindow::SetSize(MainWindow::GetRect().GetWidth(), MainWindow::GetRect().GetHeight()+OptionsPanel->GetRect().GetHeight());
1387 >        }
1388 > }
1389 >
1390 >
1391 > /*
1392 > * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_EXIT
1393 > */
1394 >
1395 > void MainWindow::OnExitClick( wxCommandEvent& event )
1396 > {
1397 > exit(0);
1398 > }
1399 >
1400 >
1401 > /*
1402 > * wxEVT_COMMAND_BUTTON_CLICKED event handler for Install_Button
1403 > */
1404 >
1405 >
1406 > struct recompile
1407 > {
1408 >    recompile(vector<string> localPackages) : thePackages(localPackages) { }
1409 >    void operator()()
1410 >    {
1411 >                TheInstallButton->Disable();
1412 >       recompileAll(thePackages);
1413 >           TheInstallButton->Enable();
1414 >    }
1415 >
1416 >    vector<string> thePackages;
1417 > };
1418 >
1419 > void MainWindow::OnInstallButtonClick( wxCommandEvent& event )
1420 > {
1421 >        
1422 >        vector<string> localPackages;
1423 >        localPackages.push_back("Globalize");
1424 >        for(int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) localPackages.push_back( globalPackages[i].modStringName );
1425 >        if ( !localPackages.empty() )   {
1426 >                
1427 >                //MainWindow::MainWindow().Hide();      
1428 >        //      boost::thread thrd2(recompileAll(localPackages) );
1429 >                //MainWindow::MainWindow().Show();
1430 > #ifdef WIN32
1431 >                recompile packages(localPackages);
1432 >                boost::thread thrd(packages);
1433 > #else
1434 >                this->Disable();
1435 >                recompileAll(localPackages);
1436 >                this->Enable();
1437 > #endif
1438 >
1439 >        }
1440 >        
1441 >        
1442 > }
1443 >
1444 > /*void setStatusArea( string s ) {
1445 >        //TheStatusBar = MainWindow::StatusArea;
1446 >        (**TheStatusBar).SetStatusText(_(s.c_str()), 0);
1447 >        
1448 >                //MainWindow::MainWindow().SetSize(MainWindow::MainWindow().GetRect().GetWidth(), MainWindow::MainWindow().GetRect().GetHeight()+1);
1449 >                                                
1450 >        //MainWindow::StatusBar->SetLabel("Importing Files...");
1451 >        //StatusBar->SetLabel(s);
1452 > //->SetLabel(s);
1453 >        
1454 > }*/
1455 >
1456 > void setProgressBar( int i ) {
1457 > //TheProgressBar->SetValue(
1458 >
1459 >        TheProgressBar->SetValue(i);
1460 >
1461 > }
1462 >
1463 >
1464 > /*
1465 > * wxEVT_UPDATE_UI event handler for ID_STATUSBAR
1466 > */
1467 >
1468 > void MainWindow::OnStatusbarUpdate( wxUpdateUIEvent& event )
1469 > {
1470 > ////@begin wxEVT_UPDATE_UI event handler for ID_STATUSBAR in MainWindow.
1471 >    // Before editing this code, remove the block markers.
1472 >    event.Skip();
1473 > ////@end wxEVT_UPDATE_UI event handler for ID_STATUSBAR in MainWindow.
1474 > }
1475 >
1476 >
1477 > /*
1478 > * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT
1479 > */
1480 >
1481 > void MainWindow::OnAboutClick( wxCommandEvent& event )
1482 > {
1483 > ////@begin wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT in MainWindow.
1484 >    // Before editing this code, remove the block markers.
1485 >    About* window = new About(this);
1486 >    int returnValue = window->ShowModal();
1487 >    window->Destroy();
1488 > ////@end wxEVT_COMMAND_MENU_SELECTED event handler for wxID_ABOUT in MainWindow.
1489 > }
1490 >
1491 >
1492 > /*
1493 > * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for NoSep_RadioButton
1494 > */
1495 >
1496 > void MainWindow::OnNoSepRadioButtonSelected( wxCommandEvent& event )
1497 > {
1498 >        static_cast<string>("-import:nosep");
1499 > }
1500 >
1501 >
1502 > /*
1503 > * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Sep_RadioButton
1504 > */
1505 >
1506 > void MainWindow::OnSepRadioButtonSelected( wxCommandEvent& event )
1507 > {
1508 >        static_cast<string>("-import:sep");
1509 > }
1510 >
1511 >
1512 > /*
1513 > * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton
1514 > */
1515 >
1516 > void MainWindow::OnSeparatedRadioButtonSelected( wxCommandEvent& event )
1517 > {
1518 > splitInstances = SPLIT;
1519 >
1520 > }
1521 >
1522 >
1523 > /*
1524 > * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Complete_RadioButton
1525 > */
1526 >
1527 > void MainWindow::OnCompleteRadioButtonSelected( wxCommandEvent& event )
1528 > {
1529 > splitInstances = NOT_SPLIT;
1530 >
1531 > }
1532 >
1533 >
1534 > /*
1535 > * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BITMAPBUTTON
1536 > */
1537 >
1538 > void MainWindow::OnRefreshButtonClick( wxCommandEvent& event )
1539 > {
1540 >        refreshMods(globalInstalledMods);
1541 > }
1542 >
1543 >
1544 > /*
1545 > * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_LOAD
1546 > */
1547 >
1548 >
1549 >
1550 >
1551 > void MainWindow::refreshMods (vector<string> s) {
1552 >        
1553 >        Mods_CheckboxList->Clear();
1554 >                                           //globalInstalledMods = getPackages();
1555 >                for (int i = 0; i < globalPackages.size(); i++) {
1556 >                        Mods_CheckboxList->Append(globalPackages[i].name.c_str());
1557 >                        if( binary_search(s.begin(), s.end(), globalPackages[i].modStringName ) ) Mods_CheckboxList->Check(i);
1558 >                        //else Mods_CheckboxList->Check(i,0);
1559 >                
1560 >                }
1561 > }
1562 >
1563 > void MainWindow::OnLoadClick( wxCommandEvent& event )
1564 > {
1565 >        static const wxChar *FILETYPES = _T(
1566 >                "Mod Loadouts (*.cfg)|*.cfg|"
1567 >                "All files (*.*)|*.*"
1568 >        );
1569 >        
1570 >        wxFileDialog* openFileDialog =
1571 >                new wxFileDialog( this, _("Open Mod Loadout"), "", "", FILETYPES,
1572 >                                  wxOPEN, wxDefaultPosition);
1573 >
1574 >        if ( openFileDialog->ShowModal() == wxID_OK )
1575 >        {
1576 >                refreshMods(getInstallString( string(openFileDialog->GetPath()) ));
1577 >        }
1578 >
1579 >
1580 > }
1581 >
1582 >
1583 > /*
1584 > * wxEVT_COMMAND_MENU_SELECTED event handler for wxID_SAVE
1585 > */
1586 >
1587 > void MainWindow::OnSaveClick( wxCommandEvent& event )
1588 > {
1589 >        static const wxChar *FILETYPES = _T(
1590 >                "Mod Loadouts (*.cfg)|*.cfg|"
1591 >                "All files (*.*)|*.*"
1592 >        );
1593 >
1594 >                wxFileDialog* openFileDialog =
1595 >                new wxFileDialog( this, _("Open file"), "", "", FILETYPES,
1596 >                wxSAVE, wxDefaultPosition);
1597 >
1598 >        if ( openFileDialog->ShowModal() == wxID_OK )
1599 >        {
1600 >
1601 >                
1602 >                        //Mods_CheckboxList->
1603 >
1604 >
1605 >
1606 >                //
1607 >                
1608 >                if ( exists( openFileDialog->GetPath().c_str() ) )
1609 >        {
1610 >                remove( openFileDialog->GetPath().c_str() );
1611 >        }
1612 >
1613 >        ofstream file(openFileDialog->GetPath().c_str());
1614 >        
1615 >        vector<string>list;
1616 >        for(int i = 0; i < globalPackages.size(); i++) if(Mods_CheckboxList->IsChecked(i)) list.push_back( globalPackages[i].modStringName );
1617 >        vector<string>::iterator begin_iter = list.begin();
1618 >        vector<string>::iterator end_iter = list.end();
1619 >
1620 >        sort( list.begin(), list.end() );
1621 >
1622 >        for( ; begin_iter != end_iter; ++begin_iter) {
1623 >                file << *begin_iter << " ";
1624 >        }
1625 >        
1626 >        file.close();
1627 >        file.clear();
1628 >
1629 >                //SetCurrentFilename(openFileDialog->GetFilename());
1630 >                //theText->LoadFile(openFileDialog->GetFilename());
1631 >                //SetStatusText(GetCurrentFilename(), 0);
1632 >                //SetStatusText(openFileDialog->GetDirectory(),1);
1633 >        }
1634 > }
1635 >
1636 >
1637 > /*
1638 > * wxEVT_COMMAND_BUTTON_CLICKED event handler for ReGlobalize_Button
1639 > */
1640 >
1641 > void MainWindow::OnReGlobalizeButtonClick( wxCommandEvent& event )
1642 > {
1643 > globalizeData();
1644 >                setProgressBar(1000);
1645 >                setStatusArea("Done!");
1646 > }
1647 >
1648 >
1649 > /*
1650 > * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton
1651 > */
1652 >
1653 > /*void MainWindow::OnSeparatedRadioButtonSelected( wxCommandEvent& event )
1654 > {
1655 > ////@begin wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton in MainWindow.
1656 >    // Before editing this code, remove the block markers.
1657 >    event.Skip();
1658 > ////@end wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for Separated_RadioButton in MainWindow.
1659 > }*/
1660 >

Diff Legend

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