--- AE/Installer/trunk/source/installer.cpp 2010/04/24 17:41:46 507 +++ AE/Installer/trunk/source/installer.cpp 2010/04/28 10:40:52 516 @@ -27,6 +27,7 @@ using namespace boost::posix_time; // externs declared in installer.h string strInstallCfg = "../GameDataFolder/Add.cfg"; string strEUFN = "Edition"; // GetUpdateStatus() may set this to "Edition-patch" later, but this is the assumed name of the new Edition folder in Updates/ +extern MainWindow* TheWindow; int globalizeData(void) { @@ -978,18 +979,19 @@ int GetUpdateStatus(Install_info_cfg *cu fstream file; file.open((install_iter->path().string() + "/Mod_Info.cfg").c_str()); if (!file.fail()) - ModPackage updatePackage = fileToModPackage(file, install_iter->path().filename()); + updatePackage = fileToModPackage(file, install_iter->path().filename()); else { file.close(); continue; } - if (exists("packages" + install_iter->path().filename() + "/Mod_Info.cfg")) + if (exists("packages/" + install_iter->path().filename() + "/Mod_Info.cfg")) { file.close(); - file.open(("packages" + install_iter->path().filename() + "/Mod_Info.cfg").c_str()); + file.clear(); + file.open(("packages/" + install_iter->path().filename() + "/Mod_Info.cfg").c_str()); if (!file.fail()) - ModPackage installedPackage = fileToModPackage(file, install_iter->path().filename()); + installedPackage = fileToModPackage(file, install_iter->path().filename()); file.close(); if (updatePackage.modStringVersion > installedPackage.modStringVersion) { @@ -1004,27 +1006,6 @@ int GetUpdateStatus(Install_info_cfg *cu } } } - else - { - file.close(); - continue; - } - file.close(); - - file.open( ("packages" + install_iter->path().filename() + "/Mod_Info.cfg").c_str()); - if (!file.fail()) - { - ModPackage installedPackage = fileToModPackage(file, install_iter->path().filename()); - } - else - { - file.close(); - return UPDATE_THIRD_PARTY; - } - file.close(); - if(((string)INSTALLER_VERSION).compare(updatePackage.installerVersion) < 1 && updatePackage.modStringVersion > installedPackage.modStringVersion) { - return UPDATE_THIRD_PARTY; - } } } catch (exception & ex) { @@ -1044,7 +1025,7 @@ bool ReadInstallInfoCfg(fstream *fileHan string strDaodanVersion = "Daodan_Version"; string strOniSplitVersion = "OniSplit_Version"; string strGUIWinVersion = "GUI_Win_Version"; - string strGUIMacVersion = "GUI_Mac_Version"; + string strGUIMacVersion = "GUI_Mac_Version"; string strReglobalize = "Reglobalize"; string strDeleteList = "Delete_List"; string strArrow = "->"; @@ -1286,79 +1267,6 @@ bool ProcessInstallerUpdate(Install_info return true; // returning 'true' tells the Installer to quit itself ASAP so it can be replaced by the process that is now running } - -void CrawlPackages(string pathToUpdate, string strPathToPackages) { - try{ - directory_iterator end; - for ( directory_iterator update_iter( pathToUpdate ); - update_iter != end; - ++update_iter ) - { - - ModPackage installedPackage, updatePackage; - string updateStr = update_iter->path().string() + "/Mod_Info.cfg"; - if ( !boost::iequals(update_iter->path().filename(),"Edition") - && !boost::iequals(update_iter->path().filename(),"Edition-patch") - && is_directory( update_iter->path() ) - && exists( update_iter->path().string() + "/Mod_Info.cfg" ) ) - { - bool update = 0; - fstream file; - file.open( (update_iter->path().string() + "/Mod_Info.cfg").c_str()); - if (!file.fail()) - { - updatePackage = fileToModPackage(file, update_iter->path().filename()); - } - else - { - file.close(); - continue; - } - file.close(); - file.clear(); - if(exists(strPathToPackages + "/" + update_iter->path().filename() + "/Mod_Info.cfg")) - { - file.open((strPathToPackages + "/" + update_iter->path().filename() + "/Mod_Info.cfg").c_str()); - if (!file.fail()) - { - installedPackage = fileToModPackage(file, update_iter->path().filename()); - file.close(); - if(updatePackage.modStringVersion > installedPackage.modStringVersion) { - update = 1; - } - } - else - { - file.close(); - update = 1; - } - file.close(); - } - else update = 1; - if(update) { - if(exists((path)(strPathToPackages + "/" + updatePackage.modStringName))) - remove_all((path)(strPathToPackages + "/" + updatePackage.modStringName)); - rename((path)(pathToUpdate + "/" + updatePackage.modStringName), (path)(strPathToPackages + "/" + updatePackage.modStringName)); - - } - } - } - } - catch (exception & ex) { - // ex.what(); - setStatusArea("Warning, handled exception: " + (string)ex.what()); - } -} - - -bool ProcessThirdPartyUpdates() { -CrawlPackages( "../updates", "./packages"); -return true; - // globalPackages = getPackages(); -// refreshMods(globalInstalledMods); -} - - bool ProcessAEUpdate(Install_info_cfg *currentAE, Install_info_cfg *updateAE, bool *installerJustUpdated) { fstream file; @@ -1579,8 +1487,8 @@ bool ProcessAEUpdate(Install_info_cfg *c CheckForGlobalization(true); // the 'true' value forces re-globalization globalPackages = getPackages(); // refresh the list in memory - // TODO: Refresh the packages list in the window - + wxCommandEvent e; + TheWindow->OnRefreshButtonClick( e ); return true; } @@ -1634,32 +1542,31 @@ void ProcessPackageUpdates(string pathTo if (!file.fail()) { installedPackage = fileToModPackage(file, updtFolder); - file.close(); - if (updatePackage.modStringVersion > installedPackage.modStringVersion) - { - if (updatePackage.installerVersion <= INSTALLER_VERSION) - { + } + file.close(); + } + file.close(); + if (updatePackage.modStringVersion > installedPackage.modStringVersion) + { + if (updatePackage.installerVersion <= INSTALLER_VERSION) + { + if(exists(strPathToPackages + "/" + updatePackage.modStringName)) { #ifdef WIN32 - remove_all((path)(strPathToPackages + "/" + installedPackage.modStringName)); + remove_all((path)(strPathToPackages + "/" + updatePackage.modStringName)); #else - if (needNewTrashDir) - { - strTrashDir = strTrashDir + "Old_packages_" + boost::lexical_cast(tmStartTime.tm_hour) + "-" + - boost::lexical_cast(tmStartTime.tm_min) + "-" + boost::lexical_cast(tmStartTime.tm_sec) + "/"; - create_directory(strTrashDir); - needNewTrashDir = false; - } - rename((path)(strPathToPackages + "/" + installedPackage.modStringName), (path)(strTrashDir + installedPackage.modStringName)); -#endif - rename((path)(pathToUpdate + "/" + updatePackage.modStringName), (path)(strPathToPackages + "/" + updatePackage.modStringName)); + if (needNewTrashDir) + { + strTrashDir = strTrashDir + "Old_packages_" + boost::lexical_cast(tmStartTime.tm_hour) + "-" + + boost::lexical_cast(tmStartTime.tm_min) + "-" + boost::lexical_cast(tmStartTime.tm_sec) + "/"; + create_directory(strTrashDir); + needNewTrashDir = false; } + rename((path)(strPathToPackages + "/" + updatePackage.modStringName), (path)(strTrashDir + updatePackage.modStringName)); +#endif } + rename((path)(pathToUpdate + "/" + updatePackage.modStringName), (path)(strPathToPackages + "/" + updatePackage.modStringName)); } - else - file.close(); } - file.close(); - file.clear(); } } } @@ -1667,6 +1574,8 @@ void ProcessPackageUpdates(string pathTo { setStatusArea("Warning, handled exception: " + (string)ex.what()); } + wxCommandEvent e; + TheWindow->OnRefreshButtonClick( e ); } /* MakePathLocalToGlobalize is a function used once by ProcessAEUpdate() that takes a file in an \