- added ability to toggle the observer mode per game when players game is over (win or lose)

This commit is contained in:
Mark Vejvoda 2010-05-31 10:20:18 +00:00
parent fc63460e07
commit 03b24659e4
4 changed files with 42 additions and 18 deletions

View File

@ -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();
}

View File

@ -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

View File

@ -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<mapInfo.players; ++i)
{

View File

@ -33,10 +33,12 @@ private:
GraphicLabel labelTechTree;
GraphicLabel labelTileset;
GraphicLabel labelMapInfo;
GraphicLabel labelEnableObserverMode;
GraphicListBox listBoxMap;
GraphicListBox listBoxFogOfWar;
GraphicListBox listBoxTechTree;
GraphicListBox listBoxTileset;
GraphicListBox listBoxEnableObserverMode;
vector<string> mapFiles;
vector<string> techTreeFiles;
vector<string> tilesetFiles;