From 4f3d5f0372b2716271f1819199d12dcc9bf35f56 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Thu, 14 Oct 2010 23:22:09 +0000 Subject: [PATCH] - when toggling observers, we now retain original faction selection --- .../menu/menu_state_custom_game.cpp | 33 ++++++++++++++----- .../glest_game/menu/menu_state_custom_game.h | 2 +- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index 4ad7c756..d1af46b7 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -410,7 +410,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b teamItems.push_back(intToStr(i)); } - reloadFactions(); + reloadFactions(false); vector techPaths = config.getPathListForType(ptTechs); for(int idx = 0; idx < techPaths.size(); idx++) { @@ -608,7 +608,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){ MutexSafeWrapper safeMutex(&masterServerThreadAccessor); needToRepublishToMasterserver = true; - reloadFactions(); + reloadFactions(true); if(hasNetworkGameSettings() == true) { @@ -677,7 +677,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){ } } else if(listBoxTechTree.mouseClick(x, y)){ - reloadFactions(); + reloadFactions(false); MutexSafeWrapper safeMutex(&masterServerThreadAccessor); needToRepublishToMasterserver = true; @@ -1973,7 +1973,7 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); - reloadFactions(); + reloadFactions(false); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d] gameSettings.getFactionCount() = %d\n",__FILE__,__FUNCTION__,__LINE__,gameSettings.getFactionCount()); @@ -2103,7 +2103,7 @@ void MenuStateCustomGame::loadMapInfo(string file, MapInfo *mapInfo, bool loadMa } -void MenuStateCustomGame::reloadFactions() { +void MenuStateCustomGame::reloadFactions(bool keepExistingSelectedItem) { vector results; @@ -2123,14 +2123,14 @@ void MenuStateCustomGame::reloadFactions() { throw runtime_error("(2)There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]"); } + results.push_back(formatString(GameConstants::RANDOMFACTION_SLOTNAME)); + // Add special Observer Faction //Lang &lang= Lang::getInstance(); if(listBoxAllowObservers.getSelectedItemIndex() == 1) { results.push_back(formatString(GameConstants::OBSERVER_SLOTNAME)); } - results.push_back(formatString(GameConstants::RANDOMFACTION_SLOTNAME)); - factionFiles= results; for(int i= 0; i