- added new menu option to toggle on / off observers
This commit is contained in:
parent
939bd9b5e3
commit
fba29d3002
|
@ -48,6 +48,7 @@ private:
|
|||
bool defaultVictoryConditions;
|
||||
|
||||
bool fogOfWar;
|
||||
bool allowObservers;
|
||||
bool enableObserverModeAtEndGame;
|
||||
bool enableServerControlledAI;
|
||||
int networkFramePeriod;
|
||||
|
@ -60,6 +61,7 @@ public:
|
|||
GameSettings() {
|
||||
thisFactionIndex = 0;
|
||||
fogOfWar = true;
|
||||
allowObservers = false;
|
||||
enableObserverModeAtEndGame = false;
|
||||
enableServerControlledAI = false;
|
||||
networkFramePeriod = GameConstants::networkFramePeriod;
|
||||
|
@ -109,6 +111,7 @@ public:
|
|||
bool getDefaultVictoryConditions() const {return defaultVictoryConditions;}
|
||||
|
||||
bool getFogOfWar() const {return fogOfWar;}
|
||||
bool getAllowObservers() const { return allowObservers;}
|
||||
bool getEnableObserverModeAtEndGame() const {return enableObserverModeAtEndGame;}
|
||||
bool getEnableServerControlledAI() const {return enableServerControlledAI;}
|
||||
int getNetworkFramePeriod() const {return networkFramePeriod; }
|
||||
|
@ -137,6 +140,7 @@ public:
|
|||
void setDefaultVictoryConditions(bool defaultVictoryConditions) {this->defaultVictoryConditions= defaultVictoryConditions;}
|
||||
|
||||
void setFogOfWar(bool fogOfWar) {this->fogOfWar = fogOfWar;}
|
||||
void setAllowObservers(bool value) {this->allowObservers = value;}
|
||||
void setEnableObserverModeAtEndGame(bool value) {this->enableObserverModeAtEndGame = value;}
|
||||
void setEnableServerControlledAI(bool value) {this->enableServerControlledAI = value;}
|
||||
void setNetworkFramePeriod(int value) {this->networkFramePeriod = value; }
|
||||
|
@ -170,6 +174,7 @@ public:
|
|||
result += "defaultResources = " + intToStr(defaultResources) + "\n";
|
||||
result += "defaultVictoryConditions = " + intToStr(defaultVictoryConditions) + "\n";
|
||||
result += "fogOfWar = " + intToStr(fogOfWar) + "\n";
|
||||
result += "allowObservers = " + intToStr(allowObservers) + "\n";
|
||||
result += "enableObserverModeAtEndGame = " + intToStr(enableObserverModeAtEndGame) + "\n";
|
||||
result += "enableServerControlledAI = " + intToStr(enableServerControlledAI) + "\n";
|
||||
result += "networkFramePeriod = " + intToStr(networkFramePeriod) + "\n";
|
||||
|
|
|
@ -101,14 +101,24 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||
xoffset=170;
|
||||
// fog - o - war
|
||||
// @350 ? 300 ?
|
||||
labelFogOfWar.init(xoffset+100, aHeadPos, 80);
|
||||
labelFogOfWar.init(xoffset+150, aHeadPos, 80);
|
||||
labelFogOfWar.setText(lang.get("FogOfWar"));
|
||||
listBoxFogOfWar.init(xoffset+100, aPos, 80);
|
||||
listBoxFogOfWar.init(xoffset+150, aPos, 80);
|
||||
listBoxFogOfWar.pushBackItem(lang.get("Yes"));
|
||||
listBoxFogOfWar.pushBackItem(lang.get("No"));
|
||||
listBoxFogOfWar.setSelectedItemIndex(0);
|
||||
listBoxFogOfWar.setEditable(false);
|
||||
|
||||
|
||||
labelAllowObservers.init(xoffset+50, aHeadPos, 80);
|
||||
labelAllowObservers.setText(lang.get("AllowObservers"));
|
||||
listBoxAllowObservers.init(xoffset+50, aPos, 80);
|
||||
listBoxAllowObservers.pushBackItem(lang.get("No"));
|
||||
listBoxAllowObservers.pushBackItem(lang.get("Yes"));
|
||||
listBoxAllowObservers.setSelectedItemIndex(0);
|
||||
listBoxAllowObservers.setEditable(false);
|
||||
|
||||
|
||||
// Enable Observer Mode
|
||||
labelEnableObserverMode.init(xoffset+250, aHeadPos, 80);
|
||||
listBoxEnableObserverMode.init(xoffset+250, aPos, 110);
|
||||
|
@ -399,10 +409,9 @@ void MenuStateConnectedGame::mouseMove(int x, int y, const MouseState *ms){
|
|||
|
||||
listBoxMap.mouseMove(x, y);
|
||||
listBoxFogOfWar.mouseMove(x, y);
|
||||
listBoxAllowObservers.mouseMove(x, y);
|
||||
listBoxTileset.mouseMove(x, y);
|
||||
listBoxTechTree.mouseMove(x, y);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void MenuStateConnectedGame::render() {
|
||||
|
@ -460,6 +469,7 @@ void MenuStateConnectedGame::render() {
|
|||
renderer.renderLabel(&labelInfo);
|
||||
renderer.renderLabel(&labelMap);
|
||||
renderer.renderLabel(&labelFogOfWar);
|
||||
renderer.renderLabel(&labelAllowObservers);
|
||||
renderer.renderLabel(&labelTileset);
|
||||
renderer.renderLabel(&labelTechTree);
|
||||
renderer.renderLabel(&labelControl);
|
||||
|
@ -469,6 +479,7 @@ void MenuStateConnectedGame::render() {
|
|||
|
||||
renderer.renderListBox(&listBoxMap);
|
||||
renderer.renderListBox(&listBoxFogOfWar);
|
||||
renderer.renderListBox(&listBoxAllowObservers);
|
||||
renderer.renderListBox(&listBoxTileset);
|
||||
renderer.renderListBox(&listBoxTechTree);
|
||||
|
||||
|
@ -712,6 +723,10 @@ void MenuStateConnectedGame::update() {
|
|||
currentFactionName = gameSettings->getTech();
|
||||
hasFactions = loadFactions(gameSettings,false);
|
||||
}
|
||||
else {
|
||||
// do this to process special faction types liek observers
|
||||
loadFactions(gameSettings,false);
|
||||
}
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] hasFactions = %d, currentFactionName [%s]\n",__FILE__,__FUNCTION__,__LINE__,hasFactions,currentFactionName.c_str());
|
||||
|
||||
|
@ -734,6 +749,15 @@ void MenuStateConnectedGame::update() {
|
|||
listBoxFogOfWar.setSelectedItemIndex(1);
|
||||
}
|
||||
|
||||
// Allow Observers
|
||||
if(gameSettings->getAllowObservers()) {
|
||||
listBoxAllowObservers.setSelectedItemIndex(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
listBoxAllowObservers.setSelectedItemIndex(0);
|
||||
}
|
||||
|
||||
if(gameSettings->getEnableObserverModeAtEndGame()) {
|
||||
listBoxEnableObserverMode.setSelectedItemIndex(0);
|
||||
}
|
||||
|
@ -947,8 +971,10 @@ bool MenuStateConnectedGame::loadFactions(const GameSettings *gameSettings, bool
|
|||
}
|
||||
else {
|
||||
// Add special Observer Faction
|
||||
Lang &lang= Lang::getInstance();
|
||||
results.push_back(formatString(GameConstants::OBSERVER_SLOTNAME));
|
||||
//Lang &lang= Lang::getInstance();
|
||||
if(gameSettings->getAllowObservers() == true) {
|
||||
results.push_back(formatString(GameConstants::OBSERVER_SLOTNAME));
|
||||
}
|
||||
|
||||
factionFiles= results;
|
||||
for(int i= 0; i<results.size(); ++i){
|
||||
|
@ -996,49 +1022,6 @@ bool MenuStateConnectedGame::hasNetworkGameSettings()
|
|||
return hasNetworkSlot;
|
||||
}
|
||||
|
||||
void MenuStateConnectedGame::reloadFactions() {
|
||||
|
||||
vector<string> results;
|
||||
|
||||
Config &config = Config::getInstance();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
vector<string> techPaths = config.getPathListForType(ptTechs);
|
||||
for(int idx = 0; idx < techPaths.size(); idx++) {
|
||||
string &techPath = techPaths[idx];
|
||||
|
||||
findAll(techPath + "/" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/*.", results, false, false);
|
||||
if(results.size() > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(results.size() == 0) {
|
||||
throw runtime_error("(2)There are no factions for the tech tree [" + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "]");
|
||||
}
|
||||
factionFiles= results;
|
||||
for(int i= 0; i<results.size(); ++i){
|
||||
results[i]= formatString(results[i]);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"Tech [%s] has faction [%s]\n",techTreeFiles[listBoxTechTree.getSelectedItemIndex()].c_str(),results[i].c_str());
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
for(int i=0; i<GameConstants::maxPlayers; ++i){
|
||||
listBoxFactions[i].setItems(results);
|
||||
listBoxFactions[i].setSelectedItemIndex(i % results.size());
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void MenuStateConnectedGame::keyDown(char key) {
|
||||
if(activeInputLabel!=NULL) {
|
||||
if(key==vkBack){
|
||||
|
|
|
@ -82,6 +82,9 @@ private:
|
|||
GraphicLabel labelNetStatus[GameConstants::maxPlayers];
|
||||
GraphicButton grabSlotButton[GameConstants::maxPlayers];
|
||||
|
||||
GraphicLabel labelAllowObservers;
|
||||
GraphicListBox listBoxAllowObservers;
|
||||
|
||||
GraphicLabel *activeInputLabel;
|
||||
|
||||
MapInfo mapInfo;
|
||||
|
@ -131,7 +134,6 @@ public:
|
|||
private:
|
||||
|
||||
bool hasNetworkGameSettings();
|
||||
void reloadFactions();
|
||||
bool loadFactions(const GameSettings *gameSettings,bool errorOnNoFactions);
|
||||
void returnToJoinMenu();
|
||||
string getHumanPlayerName();
|
||||
|
|
|
@ -205,7 +205,6 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||
listBoxTechTree.setItems(results);
|
||||
labelTechTree.init(xoffset+650, mapHeadPos);
|
||||
labelTechTree.setText(lang.get("TechTree"));
|
||||
|
||||
|
||||
// fog - o - war
|
||||
// @350 ? 300 ?
|
||||
|
@ -217,6 +216,13 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||
listBoxFogOfWar.pushBackItem(lang.get("No"));
|
||||
listBoxFogOfWar.setSelectedItemIndex(0);
|
||||
|
||||
labelAllowObservers.init(xoffset+180, aHeadPos, 80);
|
||||
labelAllowObservers.setText(lang.get("AllowObservers"));
|
||||
listBoxAllowObservers.init(xoffset+180, aPos, 80);
|
||||
listBoxAllowObservers.pushBackItem(lang.get("No"));
|
||||
listBoxAllowObservers.pushBackItem(lang.get("Yes"));
|
||||
listBoxAllowObservers.setSelectedItemIndex(0);
|
||||
|
||||
// Enable Observer Mode
|
||||
labelEnableObserverMode.init(xoffset+460, aHeadPos, 80);
|
||||
listBoxEnableObserverMode.init(xoffset+460, aPos, 150);
|
||||
|
@ -224,7 +230,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||
listBoxEnableObserverMode.pushBackItem(lang.get("No"));
|
||||
listBoxEnableObserverMode.setSelectedItemIndex(0);
|
||||
|
||||
// Witch Pathfinder
|
||||
// Which Pathfinder
|
||||
labelPathFinderType.init(xoffset+650, aHeadPos, 80);
|
||||
labelPathFinderType.setText(lang.get("PathFinderType"));
|
||||
listBoxPathFinderType.init(xoffset+650, aPos, 150);
|
||||
|
@ -638,6 +644,18 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||
needToRepublishToMasterserver = true;
|
||||
|
||||
if(hasNetworkGameSettings() == true)
|
||||
{
|
||||
needToSetChangedGameSettings = true;
|
||||
lastSetChangedGameSettings = time(NULL);
|
||||
}
|
||||
}
|
||||
else if (listBoxAllowObservers.mouseClick(x, y)) {
|
||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||
needToRepublishToMasterserver = true;
|
||||
|
||||
reloadFactions();
|
||||
|
||||
if(hasNetworkGameSettings() == true)
|
||||
{
|
||||
needToSetChangedGameSettings = true;
|
||||
|
@ -856,6 +874,7 @@ void MenuStateCustomGame::mouseMove(int x, int y, const MouseState *ms){
|
|||
}
|
||||
listBoxMap.mouseMove(x, y);
|
||||
listBoxFogOfWar.mouseMove(x, y);
|
||||
listBoxAllowObservers.mouseMove(x, y);
|
||||
listBoxTileset.mouseMove(x, y);
|
||||
listBoxMapFilter.mouseMove(x, y);
|
||||
listBoxTechTree.mouseMove(x, y);
|
||||
|
@ -907,6 +926,7 @@ void MenuStateCustomGame::render() {
|
|||
renderer.renderLabel(&labelLocalIP);
|
||||
renderer.renderLabel(&labelMap);
|
||||
renderer.renderLabel(&labelFogOfWar);
|
||||
renderer.renderLabel(&labelAllowObservers);
|
||||
renderer.renderLabel(&labelTileset);
|
||||
renderer.renderLabel(&labelMapFilter);
|
||||
renderer.renderLabel(&labelTechTree);
|
||||
|
@ -920,6 +940,7 @@ void MenuStateCustomGame::render() {
|
|||
|
||||
renderer.renderListBox(&listBoxMap);
|
||||
renderer.renderListBox(&listBoxFogOfWar);
|
||||
renderer.renderListBox(&listBoxAllowObservers);
|
||||
renderer.renderListBox(&listBoxTileset);
|
||||
renderer.renderListBox(&listBoxMapFilter);
|
||||
renderer.renderListBox(&listBoxTechTree);
|
||||
|
@ -1098,14 +1119,14 @@ void MenuStateCustomGame::update() {
|
|||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] mapInfo.players = %d\n",__FILE__,__FUNCTION__,__LINE__,mapInfo.players);
|
||||
|
||||
for(int i= 0; i<mapInfo.players; ++i) {
|
||||
for(int i= 0; i< mapInfo.players; ++i) {
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(listBoxControls[i].getSelectedItemIndex() == ctNetwork) {
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
ConnectionSlot* connectionSlot= serverInterface->getSlot(i);
|
||||
assert(connectionSlot!=NULL);
|
||||
//assert(connectionSlot!=NULL);
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
|
@ -1545,6 +1566,9 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) {
|
|||
gameSettings->setDefaultResources(true);
|
||||
gameSettings->setDefaultVictoryConditions(true);
|
||||
gameSettings->setFogOfWar(listBoxFogOfWar.getSelectedItemIndex() == 0);
|
||||
|
||||
gameSettings->setAllowObservers(listBoxAllowObservers.getSelectedItemIndex() == 1);
|
||||
|
||||
gameSettings->setEnableObserverModeAtEndGame(listBoxEnableObserverMode.getSelectedItemIndex() == 0);
|
||||
gameSettings->setPathFinderType(static_cast<PathFinderType>(listBoxPathFinderType.getSelectedItemIndex()));
|
||||
|
||||
|
@ -1663,6 +1687,9 @@ void MenuStateCustomGame::saveGameSettingsToFile(std::string fileName) {
|
|||
saveGameFile << "DefaultResources=" << gameSettings.getDefaultResources() << std::endl;
|
||||
saveGameFile << "DefaultVictoryConditions=" << gameSettings.getDefaultVictoryConditions() << std::endl;
|
||||
saveGameFile << "FogOfWar=" << gameSettings.getFogOfWar() << std::endl;
|
||||
|
||||
saveGameFile << "AllowObservers=" << gameSettings.getAllowObservers() << std::endl;
|
||||
|
||||
saveGameFile << "EnableObserverModeAtEndGame=" << gameSettings.getEnableObserverModeAtEndGame() << std::endl;
|
||||
saveGameFile << "PathFinderType=" << gameSettings.getPathFinderType() << std::endl;
|
||||
saveGameFile << "EnableServerControlledAI=" << gameSettings.getEnableServerControlledAI() << std::endl;
|
||||
|
@ -1717,6 +1744,9 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName)
|
|||
gameSettings.setDefaultResources(properties.getBool("DefaultResources"));
|
||||
gameSettings.setDefaultVictoryConditions(properties.getBool("DefaultVictoryConditions"));
|
||||
gameSettings.setFogOfWar(properties.getBool("FogOfWar"));
|
||||
|
||||
gameSettings.setAllowObservers(properties.getBool("AllowObservers","false"));
|
||||
|
||||
gameSettings.setEnableObserverModeAtEndGame(properties.getBool("EnableObserverModeAtEndGame"));
|
||||
gameSettings.setPathFinderType(static_cast<PathFinderType>(properties.getInt("PathFinderType",intToStr(pfBasic).c_str())));
|
||||
gameSettings.setEnableServerControlledAI(properties.getBool("EnableServerControlledAI","false"));
|
||||
|
@ -1765,6 +1795,8 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName)
|
|||
|
||||
Lang &lang= Lang::getInstance();
|
||||
listBoxFogOfWar.setSelectedItem(gameSettings.getFogOfWar() == true ? lang.get("Yes") : lang.get("No"));
|
||||
listBoxAllowObservers.setSelectedItem(gameSettings.getAllowObservers() == true ? lang.get("Yes") : lang.get("No"));
|
||||
|
||||
listBoxEnableObserverMode.setSelectedItem(gameSettings.getEnableObserverModeAtEndGame() == true ? lang.get("Yes") : lang.get("No"));
|
||||
listBoxPathFinderType.setSelectedItemIndex(gameSettings.getPathFinderType());
|
||||
|
||||
|
@ -1914,8 +1946,10 @@ void MenuStateCustomGame::reloadFactions() {
|
|||
}
|
||||
|
||||
// Add special Observer Faction
|
||||
Lang &lang= Lang::getInstance();
|
||||
results.push_back(formatString(GameConstants::OBSERVER_SLOTNAME));
|
||||
//Lang &lang= Lang::getInstance();
|
||||
if(listBoxAllowObservers.getSelectedItemIndex() == 1) {
|
||||
results.push_back(formatString(GameConstants::OBSERVER_SLOTNAME));
|
||||
}
|
||||
|
||||
factionFiles= results;
|
||||
for(int i= 0; i<results.size(); ++i){
|
||||
|
|
|
@ -84,6 +84,9 @@ private:
|
|||
GraphicLabel labelAdvanced;
|
||||
GraphicListBox listBoxAdvanced;
|
||||
|
||||
GraphicLabel labelAllowObservers;
|
||||
GraphicListBox listBoxAllowObservers;
|
||||
|
||||
GraphicLabel *activeInputLabel;
|
||||
|
||||
bool needToSetChangedGameSettings;
|
||||
|
|
|
@ -226,6 +226,7 @@ NetworkMessageLaunch::NetworkMessageLaunch(const GameSettings *gameSettings,int8
|
|||
data.defaultUnits= gameSettings->getDefaultUnits();
|
||||
data.defaultVictoryConditions= gameSettings->getDefaultVictoryConditions();
|
||||
data.fogOfWar = gameSettings->getFogOfWar();
|
||||
data.allowObservers = gameSettings->getAllowObservers();
|
||||
data.enableObserverModeAtEndGame = gameSettings->getEnableObserverModeAtEndGame();
|
||||
data.enableServerControlledAI = gameSettings->getEnableServerControlledAI();
|
||||
data.networkFramePeriod = gameSettings->getNetworkFramePeriod();
|
||||
|
@ -252,8 +253,8 @@ void NetworkMessageLaunch::buildGameSettings(GameSettings *gameSettings) const{
|
|||
gameSettings->setDefaultUnits(data.defaultUnits);
|
||||
gameSettings->setDefaultVictoryConditions(data.defaultVictoryConditions);
|
||||
gameSettings->setFogOfWar(data.fogOfWar);
|
||||
gameSettings->setAllowObservers(data.allowObservers);
|
||||
|
||||
gameSettings->setFogOfWar(data.fogOfWar);
|
||||
gameSettings->setEnableObserverModeAtEndGame(data.enableObserverModeAtEndGame);
|
||||
gameSettings->setEnableServerControlledAI(data.enableServerControlledAI);
|
||||
gameSettings->setNetworkFramePeriod(data.networkFramePeriod);
|
||||
|
|
|
@ -203,6 +203,7 @@ private:
|
|||
int8 defaultUnits;
|
||||
int8 defaultVictoryConditions;
|
||||
int8 fogOfWar;
|
||||
int8 allowObservers;
|
||||
int8 enableObserverModeAtEndGame;
|
||||
int8 enableServerControlledAI;
|
||||
uint8 networkFramePeriod; // allowed values 0 - 255
|
||||
|
|
Loading…
Reference in New Issue
Block a user