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 385 by gumby, Mon Jul 6 00:59:40 2009 UTC vs.
Revision 400 by gumby, Mon Jul 6 23:53:24 2009 UTC

# Line 1 | Line 1
1 + #ifndef NTDDI_VERSION          
2 + #define NTDDI_VERSION NTDDI_WIN7
3 + #endif
4 + #ifdef WIN32
5 + #include <windows.h>
6 + #include <shobjidl.h>
7 + HWND Handle;
8 +
9 + ITaskbarList *pTaskbarList;
10 + ITaskbarList3 *pTaskbarList3;
11 + #endif
12 +
13   /*
14   AE/Mod Installer
15   by Gumby and Iritscen
# Line 58 | Line 70 | using namespace std;
70   #include "boost/date_time/date_parsing.hpp"
71   #include "boost/date_time/posix_time/posix_time.hpp"
72  
73 + string escapePath(string input) {
74 +        
75 +        string output;
76 +        string escape_me = "& ;()|<>\"'\\#*?$";
77 +        for(int i = 0; i < input.size(); i++)  {
78 +                for(int j = 0; j < escape_me.size(); j++) if (input[i] == escape_me[j]) output += '\\';
79 +                output += input[i];
80 +        }
81 +        return output;
82 + }
83 +
84   int globalizeData(void)
85   {
86          busy = 1;
# Line 106 | Line 129 | int globalizeData(void)
129                  GDFPaths.push_back(TRAM);
130  
131  
132 <                path VanillaCharacters = "packages/VanillaDats/level0_Final/level0_Characters/level0_Characters.oni";
133 <                path VanillaParticles = "packages/VanillaDats/level0_Final/level0_Particles/level0_Particles.oni";
134 <                path VanillaTextures  = "packages/VanillaDats/level0_Final/level0_Textures/level0_Textures.oni";
135 <                path VanillaSounds = "packages/VanillaDats/level0_Final/level0_Sounds/level0_Sounds.oni";
136 <                path VanillaAnimations = "packages/VanillaDats/level0_Final/level0_Animations/level0_Animations.oni";
137 <                path VanillaTRAC = "packages/VanillaDats/level0_Final/level0_Animations/level0_TRAC.oni";
138 <                path VanillaTRAM = "packages/VanillaDats/level0_Final/level0_Animations/level0_TRAM.oni";
132 >                path VanillaCharacters = "VanillaDats/level0_Final/level0_Characters/level0_Characters.oni";
133 >                path VanillaParticles = "VanillaDats/level0_Final/level0_Particles/level0_Particles.oni";
134 >                path VanillaTextures  = "VanillaDats/level0_Final/level0_Textures/level0_Textures.oni";
135 >                path VanillaSounds = "VanillaDats/level0_Final/level0_Sounds/level0_Sounds.oni";
136 >                path VanillaAnimations = "VanillaDats/level0_Final/level0_Animations/level0_Animations.oni";
137 >                path VanillaTRAC = "VanillaDats/level0_Final/level0_Animations/level0_TRAC.oni";
138 >                path VanillaTRAM = "VanillaDats/level0_Final/level0_Animations/level0_TRAM.oni";
139  
140                  vector<path> VanillaPaths;
141  
# Line 146 | Line 169 | int globalizeData(void)
169  
170                  create_directory( "packages" );
171  
172 <                if (exists("packages/VanillaDats")) remove_all("packages/VanillaDats");
173 <                create_directory( "packages/VanillaDats" );
174 <
152 <                create_directory( "packages/VanillaDats/level0_Final/" );
172 >                if (exists("VanillaDats")) remove_all("VanillaDats");
173 >                create_directory( "VanillaDats" );
174 >                create_directory( "VanillaDats/level0_Final/" );
175                  //blah blah finish this.
176 <                //logfile <<  "packages/VanillaDats/level0_Final/ created";
176 >                //logfile <<  "VanillaDats/level0_Final/ created";
177                  create_directory( Characters );
178                  create_directory( Particles );
179                  create_directory( Archive );
# Line 183 | Line 205 | int globalizeData(void)
205                                  create_directory( "../GameDataFolder/level" + levels[i] + "_Final" );
206                                  //                              setStatusArea(strOniSplit + " -export ../GameDataFolder/level" + levels[i] + "_Final ../../GameDataFolder/level" + levels[i] + "_Final.dat");
207                                  system((strOniSplit + " -export ../GameDataFolder/level" + levels[i] + "_Final ../../GameDataFolder/level" + levels[i] + "_Final.dat").c_str());
208 <                                create_directory( "packages/VanillaDats/level" + levels[i] + "_Final" );
209 <                                create_directory( "packages/VanillaDats/level" + levels[i] + "_Final/level" + levels[i] + "_Final" );
208 >                                create_directory( "VanillaDats/level" + levels[i] + "_Final" );
209 >                                create_directory( "VanillaDats/level" + levels[i] + "_Final/level" + levels[i] + "_Final" );
210  
211                                  directory_iterator end_iter;
212                                  for ( directory_iterator dir_itr( "../GameDataFolder/level" + levels[i] + "_Final" ); dir_itr != end_iter; ++dir_itr )
# Line 261 | Line 283 | int globalizeData(void)
283                                                                  if(!exists( Archive / dir_itr->filename())) rename(dir_itr->path(), Archive / dir_itr->filename());
284                                                                  else remove(dir_itr->path());
285                                                  }
286 +                                                else if (dir_itr->path().filename().substr(0,4) == "ONWC") { //fix for buggy ONWC overriding
287 +                                                                cout <<dir_itr->path().filename() << "\n";
288 +
289 +                                                                if(!exists( "VanillaDats/level0_Final/level0_Final/" +  dir_itr->filename())) rename(dir_itr->path(), "VanillaDats/level0_Final/level0_Final/" +  dir_itr->filename());
290 +                                                                else remove(dir_itr->path());
291 +                                                }
292                                                  if (exists(dir_itr->path())) {
293  
294                                                  }
295                                                  else {
296 <                                                        //logfile << "\tMoved file: " << dir_itr->path().filename() << "\n";
296 >                                                        logfile << "\tMoved file: " << dir_itr->path().filename() << "\n";
297                                                  }
298                                          }
299  
# Line 287 | Line 315 | int globalizeData(void)
315                          //printf(levels[i],"%d",levels[i]);
316                          //printf(Step_x_x,"Step %d/%d: reimporting level", parts_done + 1, 7 + 2 * num_levels); setStatusArea((string)Step_x_x + levels[i] + (string)"_Final.dat");
317                          setStatusArea("Step " + lexical_cast<std::string>(parts_done + 1) + "/" + lexical_cast<std::string>(total_steps) + " reimporting level" + levels[i]+"_Final.oni");
318 <                        logfile << (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final packages/VanillaDats/level" + levels[i] + "_Final/level"
318 >                        logfile << (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final VanillaDats/level" + levels[i] + "_Final/level"
319                                  + levels[i] + "_Final/level" + levels[i] + "_Final.oni >> Globalize.log").c_str() << '\n';
320 <                        string sys_str = (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final packages/VanillaDats/level" + levels[i] + "_Final/level"
321 <                                + levels[i] + "_Final/level" + levels[i] + "_Final.oni >> Globalize2.log");
320 >                        string sys_str = (strOniSplit + " " + strImportOption + " ../GameDataFolder/level" + levels[i] + "_Final VanillaDats/level" + levels[i] + "_Final/level"
321 >                                + levels[i] + "_Final/level" + levels[i] + "_Final.oni >> Globalize.log");
322                                  system(sys_str.c_str() );
323                          setProgressBar( (int)(1000 * (float)(parts_done) / (float)(total_steps) ));
324                          parts_done++;
# Line 328 | Line 356 | int globalizeData(void)
356                  create_directory((path)"../GameDataFolder/IGMD");
357                  copy((path)"packages/VanillaBSL/IGMD", (path)"../GameDataFolder");
358                  setProgressBar( 1000 );
359 <                
360 <                // CIP:last of all, set up the edition folder as a playable Oni installation by placing the latest application (+ Daodan DLL on Windows) in edition/
361 <                
334 <                // CIP:then copy persist.dat and keyconfig.txt into edition/ as well
359 >
360 >                copy("../../persist.dat","..");
361 >                copy("../../key_config.txt","..");
362                  
363   #ifndef WIN32
364                  /* On Mac only, set the current GDF to the AE GDF by writing to Oni's global preferences file (thankfully a standard OS X ".plist" XML file).
365 <                   If there are no Oni prefs (only possible if Oni has not been run even once), then the above line will fail silently, no harm done,
366 <                   and when the user does run Oni for the first time, using the copy of the app in the AE GDF, Oni will set the prefs to use that GDF at that point */
367 <                path fullAEpath = system_complete("."); // get full path for Installer
368 <                char prefsCommand[300] = "defaults write com.godgames.oni RetailInstallationPath -string '";
369 <                strcat(prefsCommand, fullAEpath.parent_path().parent_path().string().c_str()); // get path of edition/ folder (Oni wants the folder that *contains* the GDF)
365 >                   Tests for presence of prefs with [ -f ] before doing anything so it doesn't create a partial prefs file -- just in case user has never
366 >                   run Oni before :-p */
367 >                string fullAEpath = escapePath(system_complete(".").parent_path().parent_path().string()); // get full path for edition/
368 >                char prefsCommand[300] = "[ -f ~/Library/Preferences/com.godgames.oni.plist ] && defaults write com.godgames.oni RetailInstallationPath -string '";
369 >                strcat(prefsCommand, fullAEpath.c_str()); // get path of edition/ folder (Oni wants the folder that *contains* the GDF)
370                  strcat(prefsCommand, "'"); // path string is enclosed in single quotes to avoid the need to escape UNIX-unfriendly characters
371                  system(prefsCommand);
372                  
373   #endif
374                  
375 +                
376                  setStatusArea((string)"Done! Now select your mod packages and click install.");
377                  //      while(1) Sleep(-1);
378  
379          }
380 <        catch (exception ex) {
380 >        catch (exception & ex) {
381                  setStatusArea("Warning, handled exception: " + (string)ex.what());
382          }
383  
# Line 519 | Line 547 | void recompileAll(vector<string> install
547          
548          setStatusArea("Importing levels...");
549          //setStatusArea("Recompiling Data...");
550 <        path vanilla_dir = "./packages/VanillaDats/";
550 >        path vanilla_dir = "./VanillaDats/";
551          string importCommand = "";
552          char statusString[128];
553          int numberOfDats = 0;
# Line 550 | Line 578 | void recompileAll(vector<string> install
578  
579                          }
580                  }
581 <
581 >                try {
582                  //recursive_directory_iterator end_iter;
583  
584  
585                  out << numberOfDats;
586                  datString = out.str();
559                try {
587                          for ( recursive_directory_iterator dir_itr( vanilla_dir );
588                                  dir_itr != end_iter;
589                                  ++dir_itr )
# Line 570 | Line 597 | void recompileAll(vector<string> install
597                                                          if (exists("packages/" + installedMods[i] + "/oni/" + dir_itr->path().parent_path().filename() + '/' + dir_itr->path().filename()  ))
598                                                                  importCommand += " packages/" + installedMods[i] + "/oni/" + dir_itr->path().parent_path().filename() + '/' + dir_itr->path().filename();
599  
600 <                                                        //else cout << " packages/VanillaDats/" + installedMods[i] + "/oni/";
600 >                                                        //else cout << " VanillaDats/" + installedMods[i] + "/oni/";
601                                                  }
602                                                  importCommand += " ../GameDataFolder/" + dir_itr->path().filename() + ".dat >> Install.log";
603  
# Line 974 | Line 1001 | void MainWindow::CreateControls()
1001      itemMenu42->Append(wxID_OPTIONS, _("Show Advanced Options..."), wxEmptyString, wxITEM_CHECK);
1002      menuBar->Append(itemMenu42, _("Options"));
1003      wxMenu* itemMenu44 = new wxMenu;
1004 <    itemMenu44->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL);
1005 <    menuBar->Append(itemMenu44, _("Help"));
1004 > #ifdef WIN32
1005 >        itemMenu44->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL);
1006 >        menuBar->Append(itemMenu44, _("Help"));
1007 > #else
1008 >        itemMenu37->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL);
1009 > #endif  
1010 >
1011      itemFrame1->SetMenuBar(menuBar);
1012  
1013      wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
# Line 1108 | Line 1140 | void MainWindow::CreateControls()
1140      Mods_CheckboxList->Connect(Mods_CheckboxList1, wxEVT_CREATE, wxWindowCreateEventHandler(MainWindow::ModList_OnCreate), NULL, this);
1141          ////@end MainWindow content construction
1142  
1143 +        Handle = (HWND)GetHWND();
1144 +        ::CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList, (void **)&pTaskbarList);
1145 +
1146 +
1147          if ( exists( "../../GameDataFolder/level0_Final.sep" ) ) {
1148                  strImportOption = "-import:sep";
1149                  splitInstances = NOT_SPLIT;
# Line 1116 | Line 1152 | void MainWindow::CreateControls()
1152                  strImportOption = "-import:nosep";
1153                  splitInstances = SPLIT;
1154          }
1155 <
1155 >        
1156          globalPackages = getPackages();
1157          globalInstalledMods = getInstallString();
1158          for (int i = 0; i < globalPackages.size(); i++) {
# Line 1128 | Line 1164 | void MainWindow::CreateControls()
1164          TheInstallButton = InstallButton;
1165          TheProgressBar = ProgressBar;
1166          OptionsPanel->Hide();
1167 +        
1168 + //#ifndef WIN32
1169 + //      itemMenu37->Append(wxID_ABOUT, _("About"), wxEmptyString, wxITEM_NORMAL);
1170 +        
1171 + //#endif
1172 +        
1173          if(splitInstances == SPLIT) SeperatedRadio->SetValue(true);
1174          else CompleteRadio->SetValue(true);
1133
1134
1135
1175          if(strImportOption == "-import:nosep") NoSepRadio->SetValue(true);
1176          else SepRadio->SetValue(true);
1177  
# Line 1373 | Line 1412 | void MainWindow::OnInstallButtonClick( w
1412  
1413   void setProgressBar( int i ) {
1414          //TheProgressBar->SetValue(
1415 + #ifdef WIN32
1416 +        
1417 +
1418 +
1419 + if (SUCCEEDED(pTaskbarList->QueryInterface(IID_ITaskbarList3, (void **)&pTaskbarList3)))
1420 + {
1421 +        
1422 +        pTaskbarList3->SetProgressValue(Handle,i, 1000);
1423 +        if ( i == 0 ) {
1424  
1425 +        pTaskbarList3->SetProgressState(Handle,TBPF_NOPROGRESS);
1426 +        }
1427 + }
1428 +
1429 +
1430 + #endif
1431          TheProgressBar->SetValue(i);
1432  
1433   }

Diff Legend

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