From 03b24659e45ee25cfe9f33ea649b9c18ac480c1f Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Mon, 31 May 2010 10:20:18 +0000 Subject: [PATCH] - added ability to toggle the observer mode per game when players game is over (win or lose) --- source/glest_game/game/game.cpp | 16 +++++---- source/glest_game/game/game_settings.h | 6 +++- .../menu/menu_state_custom_game.cpp | 36 +++++++++++++------ .../glest_game/menu/menu_state_custom_game.h | 2 ++ 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 234b77305..08554bf98 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -1176,10 +1176,12 @@ void Game::checkWinnerStandard(){ } } gameOver= true; - // Let the poor user watch everything unfold - world.setFogOfWar(false); - // but don't let him cheat via teamchat - chatManager.setDisableTeamMode(true); + if(this->gameSettings.getEnableObserverModeAtEndGame() == true) { + // Let the poor user watch everything unfold + world.setFogOfWar(false); + // but don't let him cheat via teamchat + chatManager.setDisableTeamMode(true); + } showLoseMessageBox(); } @@ -1202,8 +1204,10 @@ void Game::checkWinnerStandard(){ } } gameOver= true; - // Let the happy winner view everything left in the world - world.setFogOfWar(false); + if(this->gameSettings.getEnableObserverModeAtEndGame() == true) { + // Let the happy winner view everything left in the world + world.setFogOfWar(false); + } showWinMessageBox(); } diff --git a/source/glest_game/game/game_settings.h b/source/glest_game/game/game_settings.h index 3b107466e..836804176 100644 --- a/source/glest_game/game/game_settings.h +++ b/source/glest_game/game/game_settings.h @@ -44,12 +44,14 @@ private: bool defaultVictoryConditions; bool fogOfWar; + bool enableObserverModeAtEndGame; public: GameSettings() { fogOfWar = true; + enableObserverModeAtEndGame = false; } // default copy constructor will do fine, and will maintain itself ;) @@ -75,6 +77,7 @@ public: bool getDefaultVictoryConditions() const {return defaultVictoryConditions;} bool getFogOfWar() const {return fogOfWar;} + bool getEnableObserverModeAtEndGame() const {return enableObserverModeAtEndGame;} //set void setDescription(const string& description) {this->description= description;} @@ -96,7 +99,8 @@ public: void setDefaultResources(bool defaultResources) {this->defaultResources= defaultResources;} void setDefaultVictoryConditions(bool defaultVictoryConditions) {this->defaultVictoryConditions= defaultVictoryConditions;} - void setFogOfWar(bool fogOfWar) {this->fogOfWar = fogOfWar;} + void setFogOfWar(bool fogOfWar) {this->fogOfWar = fogOfWar;} + void setEnableObserverModeAtEndGame(bool value) {this->enableObserverModeAtEndGame = value;} }; }}//end namespace diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index 2ac655bf4..ce1ef3f26 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -99,12 +99,20 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b // fog - o - war // @350 ? 300 ? - labelFogOfWar.init(350, 290, 100); - listBoxFogOfWar.init(350, 260, 100); + labelFogOfWar.init(320, 290, 65); + listBoxFogOfWar.init(320, 260, 65); listBoxFogOfWar.pushBackItem(lang.get("Yes")); listBoxFogOfWar.pushBackItem(lang.get("No")); listBoxFogOfWar.setSelectedItemIndex(0); + // Enable Observer Mode + // @350 ? 300 ? + labelEnableObserverMode.init(390, 290, 80); + listBoxEnableObserverMode.init(390, 260, 80); + listBoxEnableObserverMode.pushBackItem(lang.get("Yes")); + listBoxEnableObserverMode.pushBackItem(lang.get("No")); + listBoxEnableObserverMode.setSelectedItemIndex(0); + //tileset listBox findDirs(config.getPathListForType(ptTilesets), results); if (results.empty()) { @@ -201,6 +209,8 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b labelFaction.setText(lang.get("Faction")); labelTeam.setText(lang.get("Team")); + labelEnableObserverMode.setText(lang.get("EnableObserverMode")); + loadMapInfo(Map::getMapPath(mapFiles[listBoxMap.getSelectedItemIndex()]), &mapInfo); labelMapInfo.setText(mapInfo.desc); @@ -352,6 +362,15 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){ else if (listBoxFogOfWar.mouseClick(x, y)) { needToRepublishToMasterserver = true; + if(hasNetworkGameSettings() == true) + { + needToSetChangedGameSettings = true; + lastSetChangedGameSettings = time(NULL); + } + } + else if (listBoxEnableObserverMode.mouseClick(x, y)) { + needToRepublishToMasterserver = true; + if(hasNetworkGameSettings() == true) { needToSetChangedGameSettings = true; @@ -463,6 +482,7 @@ void MenuStateCustomGame::mouseMove(int x, int y, const MouseState *ms){ listBoxTileset.mouseMove(x, y); listBoxTechTree.mouseMove(x, y); listBoxPublishServer.mouseMove(x, y); + listBoxEnableObserverMode.mouseMove(x, y); } void MenuStateCustomGame::render(){ @@ -496,11 +516,13 @@ void MenuStateCustomGame::render(){ renderer.renderLabel(&labelFaction); renderer.renderLabel(&labelTeam); renderer.renderLabel(&labelMapInfo); + renderer.renderLabel(&labelEnableObserverMode); renderer.renderListBox(&listBoxMap); renderer.renderListBox(&listBoxFogOfWar); renderer.renderListBox(&listBoxTileset); renderer.renderListBox(&listBoxTechTree); + renderer.renderListBox(&listBoxEnableObserverMode); renderer.renderChatManager(&chatManager); renderer.renderConsole(&console); @@ -635,11 +657,6 @@ void MenuStateCustomGame::update() { label = label + " techtree"; } - //if(connectionSlot->getNetworkGameDataSynchCheckOkFogOfWar() == false) - //{ - // label = label + " FogOfWar == false"; - //} - } else { @@ -666,10 +683,6 @@ void MenuStateCustomGame::update() { label = label + " techtree"; } - //if(connectionSlot->getNetworkGameDataSynchCheckOkFogOfWar() == false) - //{ - // label = label + " FogOfWar == false"; - //} } } @@ -866,6 +879,7 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) gameSettings->setDefaultResources(true); gameSettings->setDefaultVictoryConditions(true); gameSettings->setFogOfWar(listBoxFogOfWar.getSelectedItemIndex() == 0); + gameSettings->setEnableObserverModeAtEndGame(listBoxEnableObserverMode.getSelectedItemIndex() == 0); for(int i=0; i mapFiles; vector techTreeFiles; vector tilesetFiles;