- bugfix for invalid language setting in userini

- added debug info to track down tomreyn's issue
This commit is contained in:
Mark Vejvoda
2011-12-05 00:02:32 +00:00
parent dee5b11518
commit 049b2952f2
7 changed files with 531 additions and 465 deletions

View File

@@ -400,9 +400,9 @@ void GraphicListBox::setSelectedItem(string item, bool errorOnMissing){
if(iter==items.end()) { if(iter==items.end()) {
if(errorOnMissing == true) { if(errorOnMissing == true) {
for(int idx = 0; idx < items.size(); idx++) { for(int idx = 0; idx < items.size(); idx++) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] idx = %d items[idx] = [%s]\n",__FILE__,__FUNCTION__,__LINE__,idx,items[idx].c_str()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] idx = %d items[idx] = [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,idx,items[idx].c_str());
} }
throw runtime_error("Value not found on list box: "+item); throw runtime_error("[" + instanceName +"] Value not found on list box: [" + item + "]");
} }
} }
else { else {

View File

@@ -33,6 +33,7 @@ using namespace Shared::Platform;
namespace Glest{ namespace Game{ namespace Glest{ namespace Game{
const char *DEFAULT_LANGUAGE = "english"; const char *DEFAULT_LANGUAGE = "english";
// ===================================================== // =====================================================
// class Lang // class Lang
// ===================================================== // =====================================================
@@ -47,6 +48,10 @@ Lang &Lang::getInstance() {
return lang; return lang;
} }
string Lang::getDefaultLanguage() const {
return DEFAULT_LANGUAGE;
}
void Lang::loadStrings(string uselanguage, bool loadFonts, void Lang::loadStrings(string uselanguage, bool loadFonts,
bool fallbackToDefault) { bool fallbackToDefault) {
if(uselanguage.length() == 2) { if(uselanguage.length() == 2) {

View File

@@ -57,6 +57,8 @@ public:
string getLanguage() const { return language; } string getLanguage() const { return language; }
bool isLanguageLocal(string compareLanguage) const; bool isLanguageLocal(string compareLanguage) const;
bool isUTF8Language() const; bool isUTF8Language() const;
string getDefaultLanguage() const;
map<string,string> getDiscoveredLanguageList(bool searchKeyIsLangName=false); map<string,string> getDiscoveredLanguageList(bool searchKeyIsLangName=false);
pair<string,string> getNavtiveNameFromLanguageName(string langName); pair<string,string> getNavtiveNameFromLanguageName(string langName);
}; };

View File

@@ -193,6 +193,12 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
for(int i= 0; i < mapFiles.size(); i++){// fetch info and put map in right list for(int i= 0; i < mapFiles.size(); i++){// fetch info and put map in right list
loadMapInfo(Map::getMapPath(mapFiles.at(i), "", false), &mapInfo, false); loadMapInfo(Map::getMapPath(mapFiles.at(i), "", false), &mapInfo, false);
if(GameConstants::maxPlayers+1 <= mapInfo.players) {
char szBuf[1024]="";
sprintf(szBuf,"Sorted map list [%d] does not match\ncurrent map playercount [%d] for map [%s]",GameConstants::maxPlayers+1,mapInfo.players,mapInfo.desc.c_str());
throw runtime_error(szBuf);
}
playerSortedMaps[mapInfo.players].push_back(mapFiles.at(i)); playerSortedMaps[mapInfo.players].push_back(mapFiles.at(i));
formattedPlayerSortedMaps[mapInfo.players].push_back(formatString(mapFiles.at(i))); formattedPlayerSortedMaps[mapInfo.players].push_back(formatString(mapFiles.at(i)));
if(config.getString("InitialMap", "Conflict") == formattedPlayerSortedMaps[mapInfo.players].back()){ if(config.getString("InitialMap", "Conflict") == formattedPlayerSortedMaps[mapInfo.players].back()){

View File

@@ -32,499 +32,508 @@ namespace Glest{ namespace Game{
MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu): MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
MenuState(program, mainMenu, "config") MenuState(program, mainMenu, "config")
{ {
containerName = "Options"; try {
Lang &lang= Lang::getInstance(); containerName = "Options";
Config &config= Config::getInstance(); Lang &lang= Lang::getInstance();
//modeinfos=list<ModeInfo> (); Config &config= Config::getInstance();
Shared::PlatformCommon::getFullscreenVideoModes(&modeInfos,!config.getBool("Windowed")); //modeinfos=list<ModeInfo> ();
activeInputLabel=NULL; Shared::PlatformCommon::getFullscreenVideoModes(&modeInfos,!config.getBool("Windowed"));
activeInputLabel=NULL;
int leftLabelStart=50; int leftLabelStart=50;
int leftColumnStart=leftLabelStart+180; int leftColumnStart=leftLabelStart+180;
int rightLabelStart=420; int rightLabelStart=420;
int rightColumnStart=rightLabelStart+310; int rightColumnStart=rightLabelStart+310;
int buttonRowPos=80; int buttonRowPos=80;
int buttonStartPos=170; int buttonStartPos=170;
int captionOffset=75; int captionOffset=75;
int currentLabelStart=leftLabelStart; int currentLabelStart=leftLabelStart;
int currentColumnStart=leftColumnStart; int currentColumnStart=leftColumnStart;
int currentLine=700; int currentLine=700;
int lineOffset=27; int lineOffset=27;
mainMessageBox.registerGraphicComponent(containerName,"mainMessageBox"); mainMessageBox.registerGraphicComponent(containerName,"mainMessageBox");
mainMessageBox.init(lang.get("Ok")); mainMessageBox.init(lang.get("Ok"));
mainMessageBox.setEnabled(false); mainMessageBox.setEnabled(false);
mainMessageBoxState=0; mainMessageBoxState=0;
labelAudioSection.registerGraphicComponent(containerName,"labelAudioSection"); labelAudioSection.registerGraphicComponent(containerName,"labelAudioSection");
labelAudioSection.init(currentLabelStart+captionOffset, currentLine); labelAudioSection.init(currentLabelStart+captionOffset, currentLine);
labelAudioSection.setFont(CoreData::getInstance().getMenuFontVeryBig()); labelAudioSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
labelAudioSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D()); labelAudioSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
labelAudioSection.setText(lang.get("Audio")); labelAudioSection.setText(lang.get("Audio"));
currentLine-=lineOffset; currentLine-=lineOffset;
//soundboxes //soundboxes
labelSoundFactory.registerGraphicComponent(containerName,"labelSoundFactory"); labelSoundFactory.registerGraphicComponent(containerName,"labelSoundFactory");
labelSoundFactory.init(currentLabelStart, currentLine); labelSoundFactory.init(currentLabelStart, currentLine);
labelSoundFactory.setText(lang.get("SoundAndMusic")); labelSoundFactory.setText(lang.get("SoundAndMusic"));
listBoxSoundFactory.registerGraphicComponent(containerName,"listBoxSoundFactory"); listBoxSoundFactory.registerGraphicComponent(containerName,"listBoxSoundFactory");
listBoxSoundFactory.init(currentColumnStart, currentLine, 100); listBoxSoundFactory.init(currentColumnStart, currentLine, 100);
listBoxSoundFactory.pushBackItem("None"); listBoxSoundFactory.pushBackItem("None");
listBoxSoundFactory.pushBackItem("OpenAL"); listBoxSoundFactory.pushBackItem("OpenAL");
#ifdef WIN32 #ifdef WIN32
listBoxSoundFactory.pushBackItem("DirectSound8"); listBoxSoundFactory.pushBackItem("DirectSound8");
#endif #endif
listBoxSoundFactory.setSelectedItem(config.getString("FactorySound")); listBoxSoundFactory.setSelectedItem(config.getString("FactorySound"));
currentLine-=lineOffset; currentLine-=lineOffset;
labelVolumeFx.registerGraphicComponent(containerName,"labelVolumeFx"); labelVolumeFx.registerGraphicComponent(containerName,"labelVolumeFx");
labelVolumeFx.init(currentLabelStart, currentLine); labelVolumeFx.init(currentLabelStart, currentLine);
labelVolumeFx.setText(lang.get("FxVolume")); labelVolumeFx.setText(lang.get("FxVolume"));
listBoxVolumeFx.registerGraphicComponent(containerName,"listBoxVolumeFx"); listBoxVolumeFx.registerGraphicComponent(containerName,"listBoxVolumeFx");
listBoxVolumeFx.init(currentColumnStart, currentLine, 80); listBoxVolumeFx.init(currentColumnStart, currentLine, 80);
currentLine-=lineOffset; currentLine-=lineOffset;
labelVolumeAmbient.registerGraphicComponent(containerName,"labelVolumeAmbient"); labelVolumeAmbient.registerGraphicComponent(containerName,"labelVolumeAmbient");
labelVolumeAmbient.init(currentLabelStart, currentLine); labelVolumeAmbient.init(currentLabelStart, currentLine);
listBoxVolumeAmbient.registerGraphicComponent(containerName,"listBoxVolumeAmbient"); listBoxVolumeAmbient.registerGraphicComponent(containerName,"listBoxVolumeAmbient");
listBoxVolumeAmbient.init(currentColumnStart, currentLine, 80); listBoxVolumeAmbient.init(currentColumnStart, currentLine, 80);
labelVolumeAmbient.setText(lang.get("AmbientVolume")); labelVolumeAmbient.setText(lang.get("AmbientVolume"));
currentLine-=lineOffset; currentLine-=lineOffset;
labelVolumeMusic.registerGraphicComponent(containerName,"labelVolumeMusic"); labelVolumeMusic.registerGraphicComponent(containerName,"labelVolumeMusic");
labelVolumeMusic.init(currentLabelStart, currentLine); labelVolumeMusic.init(currentLabelStart, currentLine);
listBoxVolumeMusic.registerGraphicComponent(containerName,"listBoxVolumeMusic"); listBoxVolumeMusic.registerGraphicComponent(containerName,"listBoxVolumeMusic");
listBoxVolumeMusic.init(currentColumnStart, currentLine, 80); listBoxVolumeMusic.init(currentColumnStart, currentLine, 80);
labelVolumeMusic.setText(lang.get("MusicVolume")); labelVolumeMusic.setText(lang.get("MusicVolume"));
currentLine-=lineOffset; currentLine-=lineOffset;
for(int i=0; i<=100; i+=5){ for(int i=0; i<=100; i+=5){
listBoxVolumeFx.pushBackItem(intToStr(i)); listBoxVolumeFx.pushBackItem(intToStr(i));
listBoxVolumeAmbient.pushBackItem(intToStr(i)); listBoxVolumeAmbient.pushBackItem(intToStr(i));
listBoxVolumeMusic.pushBackItem(intToStr(i)); listBoxVolumeMusic.pushBackItem(intToStr(i));
}
listBoxVolumeFx.setSelectedItem(intToStr(config.getInt("SoundVolumeFx")/5*5));
listBoxVolumeAmbient.setSelectedItem(intToStr(config.getInt("SoundVolumeAmbient")/5*5));
listBoxVolumeMusic.setSelectedItem(intToStr(config.getInt("SoundVolumeMusic")/5*5));
currentLine-=lineOffset;
// Video Section
labelVideoSection.registerGraphicComponent(containerName,"labelVideoSection");
labelVideoSection.init(currentLabelStart+captionOffset, currentLine);
labelVideoSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
labelVideoSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
labelVideoSection.setText(lang.get("Video"));
currentLine-=lineOffset;
//resolution
labelScreenModes.registerGraphicComponent(containerName,"labelScreenModes");
labelScreenModes.init(currentLabelStart, currentLine);
labelScreenModes.setText(lang.get("Resolution"));
listBoxScreenModes.registerGraphicComponent(containerName,"listBoxScreenModes");
listBoxScreenModes.init(currentColumnStart, currentLine, 170);
string currentResString = config.getString("ScreenWidth") + "x" +
config.getString("ScreenHeight") + "-" +
intToStr(config.getInt("ColorBits"));
bool currentResolutionFound = false;
for(vector<ModeInfo>::const_iterator it= modeInfos.begin(); it!=modeInfos.end(); ++it){
if((*it).getString() == currentResString) {
currentResolutionFound = true;
} }
listBoxScreenModes.pushBackItem((*it).getString()); listBoxVolumeFx.setSelectedItem(intToStr(config.getInt("SoundVolumeFx")/5*5));
} listBoxVolumeAmbient.setSelectedItem(intToStr(config.getInt("SoundVolumeAmbient")/5*5));
if(currentResolutionFound == false) { listBoxVolumeMusic.setSelectedItem(intToStr(config.getInt("SoundVolumeMusic")/5*5));
listBoxScreenModes.pushBackItem(currentResString);
} currentLine-=lineOffset;
listBoxScreenModes.setSelectedItem(currentResString); // Video Section
currentLine-=lineOffset; labelVideoSection.registerGraphicComponent(containerName,"labelVideoSection");
labelVideoSection.init(currentLabelStart+captionOffset, currentLine);
labelVideoSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
labelVideoSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
labelVideoSection.setText(lang.get("Video"));
currentLine-=lineOffset;
//resolution
labelScreenModes.registerGraphicComponent(containerName,"labelScreenModes");
labelScreenModes.init(currentLabelStart, currentLine);
labelScreenModes.setText(lang.get("Resolution"));
listBoxScreenModes.registerGraphicComponent(containerName,"listBoxScreenModes");
listBoxScreenModes.init(currentColumnStart, currentLine, 170);
string currentResString = config.getString("ScreenWidth") + "x" +
config.getString("ScreenHeight") + "-" +
intToStr(config.getInt("ColorBits"));
bool currentResolutionFound = false;
for(vector<ModeInfo>::const_iterator it= modeInfos.begin(); it!=modeInfos.end(); ++it){
if((*it).getString() == currentResString) {
currentResolutionFound = true;
}
listBoxScreenModes.pushBackItem((*it).getString());
}
if(currentResolutionFound == false) {
listBoxScreenModes.pushBackItem(currentResString);
}
listBoxScreenModes.setSelectedItem(currentResString);
currentLine-=lineOffset;
//FullscreenWindowed //FullscreenWindowed
labelFullscreenWindowed.registerGraphicComponent(containerName,"labelFullscreenWindowed"); labelFullscreenWindowed.registerGraphicComponent(containerName,"labelFullscreenWindowed");
labelFullscreenWindowed.init(currentLabelStart, currentLine); labelFullscreenWindowed.init(currentLabelStart, currentLine);
checkBoxFullscreenWindowed.registerGraphicComponent(containerName,"checkBoxFullscreenWindowed"); checkBoxFullscreenWindowed.registerGraphicComponent(containerName,"checkBoxFullscreenWindowed");
checkBoxFullscreenWindowed.init(currentColumnStart, currentLine); checkBoxFullscreenWindowed.init(currentColumnStart, currentLine);
labelFullscreenWindowed.setText(lang.get("Windowed")); labelFullscreenWindowed.setText(lang.get("Windowed"));
checkBoxFullscreenWindowed.setValue(config.getBool("Windowed")); checkBoxFullscreenWindowed.setValue(config.getBool("Windowed"));
currentLine-=lineOffset; currentLine-=lineOffset;
//filter //filter
labelFilter.registerGraphicComponent(containerName,"labelFilter"); labelFilter.registerGraphicComponent(containerName,"labelFilter");
labelFilter.init(currentLabelStart, currentLine); labelFilter.init(currentLabelStart, currentLine);
labelFilter.setText(lang.get("Filter")); labelFilter.setText(lang.get("Filter"));
listBoxFilter.registerGraphicComponent(containerName,"listBoxFilter"); listBoxFilter.registerGraphicComponent(containerName,"listBoxFilter");
listBoxFilter.init(currentColumnStart, currentLine, 170); listBoxFilter.init(currentColumnStart, currentLine, 170);
listBoxFilter.pushBackItem("Bilinear"); listBoxFilter.pushBackItem("Bilinear");
listBoxFilter.pushBackItem("Trilinear"); listBoxFilter.pushBackItem("Trilinear");
listBoxFilter.setSelectedItem(config.getString("Filter")); listBoxFilter.setSelectedItem(config.getString("Filter"));
currentLine-=lineOffset; currentLine-=lineOffset;
//shadows //shadows
labelShadows.registerGraphicComponent(containerName,"labelShadows"); labelShadows.registerGraphicComponent(containerName,"labelShadows");
labelShadows.init(currentLabelStart, currentLine); labelShadows.init(currentLabelStart, currentLine);
labelShadows.setText(lang.get("Shadows")); labelShadows.setText(lang.get("Shadows"));
listBoxShadows.registerGraphicComponent(containerName,"listBoxShadows"); listBoxShadows.registerGraphicComponent(containerName,"listBoxShadows");
listBoxShadows.init(currentColumnStart, currentLine, 170); listBoxShadows.init(currentColumnStart, currentLine, 170);
for(int i= 0; i<Renderer::sCount; ++i){ for(int i= 0; i<Renderer::sCount; ++i){
listBoxShadows.pushBackItem(lang.get(Renderer::shadowsToStr(static_cast<Renderer::Shadows>(i)))); listBoxShadows.pushBackItem(lang.get(Renderer::shadowsToStr(static_cast<Renderer::Shadows>(i))));
} }
string str= config.getString("Shadows"); string str= config.getString("Shadows");
listBoxShadows.setSelectedItemIndex(clamp(Renderer::strToShadows(str), 0, Renderer::sCount-1)); listBoxShadows.setSelectedItemIndex(clamp(Renderer::strToShadows(str), 0, Renderer::sCount-1));
currentLine-=lineOffset; currentLine-=lineOffset;
//textures 3d //textures 3d
labelTextures3D.registerGraphicComponent(containerName,"labelTextures3D"); labelTextures3D.registerGraphicComponent(containerName,"labelTextures3D");
labelTextures3D.init(currentLabelStart, currentLine); labelTextures3D.init(currentLabelStart, currentLine);
checkBoxTextures3D.registerGraphicComponent(containerName,"checkBoxTextures3D"); checkBoxTextures3D.registerGraphicComponent(containerName,"checkBoxTextures3D");
checkBoxTextures3D.init(currentColumnStart, currentLine); checkBoxTextures3D.init(currentColumnStart, currentLine);
labelTextures3D.setText(lang.get("Textures3D")); labelTextures3D.setText(lang.get("Textures3D"));
checkBoxTextures3D.setValue(config.getBool("Textures3D")); checkBoxTextures3D.setValue(config.getBool("Textures3D"));
currentLine-=lineOffset; currentLine-=lineOffset;
//lights //lights
labelLights.registerGraphicComponent(containerName,"labelLights"); labelLights.registerGraphicComponent(containerName,"labelLights");
labelLights.init(currentLabelStart, currentLine); labelLights.init(currentLabelStart, currentLine);
labelLights.setText(lang.get("MaxLights")); labelLights.setText(lang.get("MaxLights"));
listBoxLights.registerGraphicComponent(containerName,"listBoxLights"); listBoxLights.registerGraphicComponent(containerName,"listBoxLights");
listBoxLights.init(currentColumnStart, currentLine, 80); listBoxLights.init(currentColumnStart, currentLine, 80);
for(int i= 1; i<=8; ++i){ for(int i= 1; i<=8; ++i){
listBoxLights.pushBackItem(intToStr(i)); listBoxLights.pushBackItem(intToStr(i));
} }
listBoxLights.setSelectedItemIndex(clamp(config.getInt("MaxLights")-1, 0, 7)); listBoxLights.setSelectedItemIndex(clamp(config.getInt("MaxLights")-1, 0, 7));
currentLine-=lineOffset; currentLine-=lineOffset;
//unit particles //unit particles
labelUnitParticles.registerGraphicComponent(containerName,"labelUnitParticles"); labelUnitParticles.registerGraphicComponent(containerName,"labelUnitParticles");
labelUnitParticles.init(currentLabelStart,currentLine); labelUnitParticles.init(currentLabelStart,currentLine);
labelUnitParticles.setText(lang.get("ShowUnitParticles")); labelUnitParticles.setText(lang.get("ShowUnitParticles"));
checkBoxUnitParticles.registerGraphicComponent(containerName,"checkBoxUnitParticles"); checkBoxUnitParticles.registerGraphicComponent(containerName,"checkBoxUnitParticles");
checkBoxUnitParticles.init(currentColumnStart,currentLine); checkBoxUnitParticles.init(currentColumnStart,currentLine);
checkBoxUnitParticles.setValue(config.getBool("UnitParticles","true")); checkBoxUnitParticles.setValue(config.getBool("UnitParticles","true"));
currentLine-=lineOffset; currentLine-=lineOffset;
//tileset particles //tileset particles
labelTilesetParticles.registerGraphicComponent(containerName,"labelTilesetParticles"); labelTilesetParticles.registerGraphicComponent(containerName,"labelTilesetParticles");
labelTilesetParticles.init(currentLabelStart,currentLine); labelTilesetParticles.init(currentLabelStart,currentLine);
labelTilesetParticles.setText(lang.get("ShowTilesetParticles")); labelTilesetParticles.setText(lang.get("ShowTilesetParticles"));
checkBoxTilesetParticles.registerGraphicComponent(containerName,"checkBoxTilesetParticles"); checkBoxTilesetParticles.registerGraphicComponent(containerName,"checkBoxTilesetParticles");
checkBoxTilesetParticles.init(currentColumnStart,currentLine); checkBoxTilesetParticles.init(currentColumnStart,currentLine);
checkBoxTilesetParticles.setValue(config.getBool("TilesetParticles","true")); checkBoxTilesetParticles.setValue(config.getBool("TilesetParticles","true"));
currentLine-=lineOffset; currentLine-=lineOffset;
//unit particles //unit particles
labelMapPreview.registerGraphicComponent(containerName,"labelMapPreview"); labelMapPreview.registerGraphicComponent(containerName,"labelMapPreview");
labelMapPreview.init(currentLabelStart,currentLine); labelMapPreview.init(currentLabelStart,currentLine);
labelMapPreview.setText(lang.get("ShowMapPreview")); labelMapPreview.setText(lang.get("ShowMapPreview"));
checkBoxMapPreview.registerGraphicComponent(containerName,"checkBoxMapPreview"); checkBoxMapPreview.registerGraphicComponent(containerName,"checkBoxMapPreview");
checkBoxMapPreview.init(currentColumnStart,currentLine); checkBoxMapPreview.init(currentColumnStart,currentLine);
checkBoxMapPreview.setValue(config.getBool("MapPreview","true")); checkBoxMapPreview.setValue(config.getBool("MapPreview","true"));
currentLine-=lineOffset; currentLine-=lineOffset;
// Texture Compression flag // Texture Compression flag
labelEnableTextureCompression.registerGraphicComponent(containerName,"labelEnableTextureCompression"); labelEnableTextureCompression.registerGraphicComponent(containerName,"labelEnableTextureCompression");
labelEnableTextureCompression.init(currentLabelStart ,currentLine); labelEnableTextureCompression.init(currentLabelStart ,currentLine);
labelEnableTextureCompression.setText(lang.get("EnableTextureCompression")); labelEnableTextureCompression.setText(lang.get("EnableTextureCompression"));
checkBoxEnableTextureCompression.registerGraphicComponent(containerName,"checkBoxEnableTextureCompression"); checkBoxEnableTextureCompression.registerGraphicComponent(containerName,"checkBoxEnableTextureCompression");
checkBoxEnableTextureCompression.init(currentColumnStart ,currentLine ); checkBoxEnableTextureCompression.init(currentColumnStart ,currentLine );
checkBoxEnableTextureCompression.setValue(config.getBool("EnableTextureCompression","false")); checkBoxEnableTextureCompression.setValue(config.getBool("EnableTextureCompression","false"));
currentLine-=lineOffset; currentLine-=lineOffset;
labelVisibleHud.registerGraphicComponent(containerName,"lavelVisibleHud"); labelVisibleHud.registerGraphicComponent(containerName,"lavelVisibleHud");
labelVisibleHud.init(currentLabelStart ,currentLine); labelVisibleHud.init(currentLabelStart ,currentLine);
labelVisibleHud.setText(lang.get("VisibleHUD")); labelVisibleHud.setText(lang.get("VisibleHUD"));
checkBoxVisibleHud.registerGraphicComponent(containerName,"checkBoxVisibleHud"); checkBoxVisibleHud.registerGraphicComponent(containerName,"checkBoxVisibleHud");
checkBoxVisibleHud.init(currentColumnStart ,currentLine ); checkBoxVisibleHud.init(currentColumnStart ,currentLine );
checkBoxVisibleHud.setValue(config.getBool("VisibleHud","true")); checkBoxVisibleHud.setValue(config.getBool("VisibleHud","true"));
currentLine-=lineOffset; currentLine-=lineOffset;
labelRainEffect.registerGraphicComponent(containerName,"labelRainEffect"); labelRainEffect.registerGraphicComponent(containerName,"labelRainEffect");
labelRainEffect.init(currentLabelStart ,currentLine); labelRainEffect.init(currentLabelStart ,currentLine);
labelRainEffect.setText(lang.get("RainEffect")); labelRainEffect.setText(lang.get("RainEffect"));
checkBoxRainEffect.registerGraphicComponent(containerName,"checkBoxRainEffect"); checkBoxRainEffect.registerGraphicComponent(containerName,"checkBoxRainEffect");
checkBoxRainEffect.init(currentColumnStart ,currentLine ); checkBoxRainEffect.init(currentColumnStart ,currentLine );
checkBoxRainEffect.setValue(config.getBool("RainEffect","true")); checkBoxRainEffect.setValue(config.getBool("RainEffect","true"));
currentLine-=lineOffset; currentLine-=lineOffset;
// end // end
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
///////// RIGHT SIDE ///////// RIGHT SIDE
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
currentLine=700; // reset line pos currentLine=700; // reset line pos
currentLabelStart=rightLabelStart; // set to right side currentLabelStart=rightLabelStart; // set to right side
currentColumnStart=rightColumnStart; // set to right side currentColumnStart=rightColumnStart; // set to right side
//currentLine-=lineOffset; //currentLine-=lineOffset;
labelMiscSection.registerGraphicComponent(containerName,"labelMiscSection"); labelMiscSection.registerGraphicComponent(containerName,"labelMiscSection");
labelMiscSection.init(currentLabelStart+captionOffset, currentLine); labelMiscSection.init(currentLabelStart+captionOffset, currentLine);
labelMiscSection.setFont(CoreData::getInstance().getMenuFontVeryBig()); labelMiscSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
labelMiscSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D()); labelMiscSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
labelMiscSection.setText(lang.get("Misc")); labelMiscSection.setText(lang.get("Misc"));
currentLine-=lineOffset; currentLine-=lineOffset;
//lang //lang
labelLang.registerGraphicComponent(containerName,"labelLang"); labelLang.registerGraphicComponent(containerName,"labelLang");
labelLang.init(currentLabelStart, currentLine); labelLang.init(currentLabelStart, currentLine);
labelLang.setText(lang.get("Language")); labelLang.setText(lang.get("Language"));
listBoxLang.registerGraphicComponent(containerName,"listBoxLang"); listBoxLang.registerGraphicComponent(containerName,"listBoxLang");
listBoxLang.init(currentColumnStart, currentLine, 260); listBoxLang.init(currentColumnStart, currentLine, 260);
vector<string> langResults; vector<string> langResults;
// string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey); // string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
// //
// string userDataPath = getGameCustomCoreDataPath(data_path, ""); // string userDataPath = getGameCustomCoreDataPath(data_path, "");
// findAll(userDataPath + "data/lang/*.lng", langResults, true, false); // findAll(userDataPath + "data/lang/*.lng", langResults, true, false);
// //
// vector<string> langResults2; // vector<string> langResults2;
// findAll(data_path + "data/lang/*.lng", langResults2, true); // findAll(data_path + "data/lang/*.lng", langResults2, true);
// if(langResults2.empty() && langResults.empty()) { // if(langResults2.empty() && langResults.empty()) {
// throw runtime_error("There are no lang files"); // throw runtime_error("There are no lang files");
// } // }
// for(unsigned int i = 0; i < langResults2.size(); ++i) { // for(unsigned int i = 0; i < langResults2.size(); ++i) {
// string testLanguage = langResults2[i]; // string testLanguage = langResults2[i];
// if(std::find(langResults.begin(),langResults.end(),testLanguage) == langResults.end()) { // if(std::find(langResults.begin(),langResults.end(),testLanguage) == langResults.end()) {
// langResults.push_back(testLanguage); // langResults.push_back(testLanguage);
// } // }
// } // }
languageList = Lang::getInstance().getDiscoveredLanguageList(true); languageList = Lang::getInstance().getDiscoveredLanguageList(true);
for(map<string,string>::iterator iterMap = languageList.begin(); for(map<string,string>::iterator iterMap = languageList.begin();
iterMap != languageList.end(); ++iterMap) { iterMap != languageList.end(); ++iterMap) {
langResults.push_back(iterMap->first + "-" + iterMap->second); langResults.push_back(iterMap->first + "-" + iterMap->second);
} }
listBoxLang.setItems(langResults); listBoxLang.setItems(langResults);
pair<string,string> defaultLang = Lang::getInstance().getNavtiveNameFromLanguageName(config.getString("Lang")); pair<string,string> defaultLang = Lang::getInstance().getNavtiveNameFromLanguageName(config.getString("Lang"));
listBoxLang.setSelectedItem(defaultLang.second + "-" + defaultLang.first); if(defaultLang.first == "" && defaultLang.second == "") {
currentLine-=lineOffset; defaultLang = Lang::getInstance().getNavtiveNameFromLanguageName(Lang::getInstance().getDefaultLanguage());
}
listBoxLang.setSelectedItem(defaultLang.second + "-" + defaultLang.first);
currentLine-=lineOffset;
//playerName //playerName
labelPlayerNameLabel.registerGraphicComponent(containerName,"labelPlayerNameLabel"); labelPlayerNameLabel.registerGraphicComponent(containerName,"labelPlayerNameLabel");
labelPlayerNameLabel.init(currentLabelStart,currentLine); labelPlayerNameLabel.init(currentLabelStart,currentLine);
labelPlayerNameLabel.setText(lang.get("Playername")); labelPlayerNameLabel.setText(lang.get("Playername"));
labelPlayerName.registerGraphicComponent(containerName,"labelPlayerName"); labelPlayerName.registerGraphicComponent(containerName,"labelPlayerName");
labelPlayerName.init(currentColumnStart,currentLine); labelPlayerName.init(currentColumnStart,currentLine);
labelPlayerName.setText(config.getString("NetPlayerName",Socket::getHostName().c_str())); labelPlayerName.setText(config.getString("NetPlayerName",Socket::getHostName().c_str()));
labelPlayerName.setFont(CoreData::getInstance().getMenuFontBig()); labelPlayerName.setFont(CoreData::getInstance().getMenuFontBig());
labelPlayerName.setFont3D(CoreData::getInstance().getMenuFontBig3D()); labelPlayerName.setFont3D(CoreData::getInstance().getMenuFontBig3D());
currentLine-=lineOffset; currentLine-=lineOffset;
//FontSizeAdjustment //FontSizeAdjustment
labelFontSizeAdjustment.registerGraphicComponent(containerName,"labelFontSizeAdjustment"); labelFontSizeAdjustment.registerGraphicComponent(containerName,"labelFontSizeAdjustment");
labelFontSizeAdjustment.init(currentLabelStart,currentLine); labelFontSizeAdjustment.init(currentLabelStart,currentLine);
labelFontSizeAdjustment.setText(lang.get("FontSizeAdjustment")); labelFontSizeAdjustment.setText(lang.get("FontSizeAdjustment"));
listFontSizeAdjustment.registerGraphicComponent(containerName,"listFontSizeAdjustment"); listFontSizeAdjustment.registerGraphicComponent(containerName,"listFontSizeAdjustment");
listFontSizeAdjustment.init(currentColumnStart, currentLine, 80); listFontSizeAdjustment.init(currentColumnStart, currentLine, 80);
for(int i=-5; i<=5; i+=1){ for(int i=-5; i<=5; i+=1){
listFontSizeAdjustment.pushBackItem(intToStr(i)); listFontSizeAdjustment.pushBackItem(intToStr(i));
} }
listFontSizeAdjustment.setSelectedItem(intToStr(config.getInt("FontSizeAdjustment"))); listFontSizeAdjustment.setSelectedItem(intToStr(config.getInt("FontSizeAdjustment")));
currentLine-=lineOffset; currentLine-=lineOffset;
// Screenshot type flag // Screenshot type flag
labelScreenShotType.registerGraphicComponent(containerName,"labelScreenShotType"); labelScreenShotType.registerGraphicComponent(containerName,"labelScreenShotType");
labelScreenShotType.init(currentLabelStart ,currentLine); labelScreenShotType.init(currentLabelStart ,currentLine);
labelScreenShotType.setText(lang.get("ScreenShotFileType")); labelScreenShotType.setText(lang.get("ScreenShotFileType"));
listBoxScreenShotType.registerGraphicComponent(containerName,"listBoxScreenShotType"); listBoxScreenShotType.registerGraphicComponent(containerName,"listBoxScreenShotType");
listBoxScreenShotType.init(currentColumnStart ,currentLine, 80 ); listBoxScreenShotType.init(currentColumnStart ,currentLine, 80 );
listBoxScreenShotType.pushBackItem("bmp"); listBoxScreenShotType.pushBackItem("bmp");
listBoxScreenShotType.pushBackItem("jpg"); listBoxScreenShotType.pushBackItem("jpg");
listBoxScreenShotType.pushBackItem("png"); listBoxScreenShotType.pushBackItem("png");
listBoxScreenShotType.pushBackItem("tga"); listBoxScreenShotType.pushBackItem("tga");
listBoxScreenShotType.setSelectedItem(config.getString("ScreenShotFileType","jpg")); listBoxScreenShotType.setSelectedItem(config.getString("ScreenShotFileType","jpg"));
currentLine-=lineOffset; currentLine-=lineOffset;
labelDisableScreenshotConsoleText.registerGraphicComponent(containerName,"lavelDisableScreenshotConsoleText"); labelDisableScreenshotConsoleText.registerGraphicComponent(containerName,"lavelDisableScreenshotConsoleText");
labelDisableScreenshotConsoleText.init(currentLabelStart ,currentLine); labelDisableScreenshotConsoleText.init(currentLabelStart ,currentLine);
labelDisableScreenshotConsoleText.setText(lang.get("ScreenShotConsoleText")); labelDisableScreenshotConsoleText.setText(lang.get("ScreenShotConsoleText"));
checkBoxDisableScreenshotConsoleText.registerGraphicComponent(containerName,"checkBoxDisableScreenshotConsoleText"); checkBoxDisableScreenshotConsoleText.registerGraphicComponent(containerName,"checkBoxDisableScreenshotConsoleText");
checkBoxDisableScreenshotConsoleText.init(currentColumnStart ,currentLine ); checkBoxDisableScreenshotConsoleText.init(currentColumnStart ,currentLine );
checkBoxDisableScreenshotConsoleText.setValue(!config.getBool("DisableScreenshotConsoleText","false")); checkBoxDisableScreenshotConsoleText.setValue(!config.getBool("DisableScreenshotConsoleText","false"));
currentLine-=lineOffset; currentLine-=lineOffset;
labelMouseMoveScrollsWorld.registerGraphicComponent(containerName,"labelMouseMoveScrollsWorld"); labelMouseMoveScrollsWorld.registerGraphicComponent(containerName,"labelMouseMoveScrollsWorld");
labelMouseMoveScrollsWorld.init(currentLabelStart ,currentLine); labelMouseMoveScrollsWorld.init(currentLabelStart ,currentLine);
labelMouseMoveScrollsWorld.setText(lang.get("MouseScrollsWorld")); labelMouseMoveScrollsWorld.setText(lang.get("MouseScrollsWorld"));
checkBoxMouseMoveScrollsWorld.registerGraphicComponent(containerName,"checkBoxMouseMoveScrollsWorld"); checkBoxMouseMoveScrollsWorld.registerGraphicComponent(containerName,"checkBoxMouseMoveScrollsWorld");
checkBoxMouseMoveScrollsWorld.init(currentColumnStart ,currentLine ); checkBoxMouseMoveScrollsWorld.init(currentColumnStart ,currentLine );
checkBoxMouseMoveScrollsWorld.setValue(config.getBool("MouseMoveScrollsWorld","true")); checkBoxMouseMoveScrollsWorld.setValue(config.getBool("MouseMoveScrollsWorld","true"));
currentLine-=lineOffset; currentLine-=lineOffset;
currentLine-=lineOffset; currentLine-=lineOffset;
currentLine-=lineOffset; currentLine-=lineOffset;
labelNetworkSettings.registerGraphicComponent(containerName,"labelNetworkSettingsSection"); labelNetworkSettings.registerGraphicComponent(containerName,"labelNetworkSettingsSection");
labelNetworkSettings.init(currentLabelStart+captionOffset, currentLine); labelNetworkSettings.init(currentLabelStart+captionOffset, currentLine);
labelNetworkSettings.setFont(CoreData::getInstance().getMenuFontVeryBig()); labelNetworkSettings.setFont(CoreData::getInstance().getMenuFontVeryBig());
labelNetworkSettings.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D()); labelNetworkSettings.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
labelNetworkSettings.setText(lang.get("Network")); labelNetworkSettings.setText(lang.get("Network"));
currentLine-=lineOffset; currentLine-=lineOffset;
// server port // server port
labelServerPortLabel.registerGraphicComponent(containerName,"labelServerPortLabel"); labelServerPortLabel.registerGraphicComponent(containerName,"labelServerPortLabel");
labelServerPortLabel.init(currentLabelStart,currentLine); labelServerPortLabel.init(currentLabelStart,currentLine);
labelServerPortLabel.setText(lang.get("ServerPort")); labelServerPortLabel.setText(lang.get("ServerPort"));
labelServerPort.init(currentColumnStart,currentLine); labelServerPort.init(currentColumnStart,currentLine);
string port=intToStr(config.getInt("ServerPort")); string port=intToStr(config.getInt("ServerPort"));
if(port != intToStr(GameConstants::serverPort)){ if(port != intToStr(GameConstants::serverPort)){
port=port +" ("+lang.get("NonStandardPort")+"!!)"; port=port +" ("+lang.get("NonStandardPort")+"!!)";
} }
else{ else{
port=port +" ("+lang.get("StandardPort")+")"; port=port +" ("+lang.get("StandardPort")+")";
} }
labelServerPort.setText(port); labelServerPort.setText(port);
// external server port // external server port
currentLine-=lineOffset; currentLine-=lineOffset;
labelPublishServerExternalPort.registerGraphicComponent(containerName,"labelPublishServerExternalPort"); labelPublishServerExternalPort.registerGraphicComponent(containerName,"labelPublishServerExternalPort");
labelPublishServerExternalPort.init(currentLabelStart, currentLine, 150); labelPublishServerExternalPort.init(currentLabelStart, currentLine, 150);
labelPublishServerExternalPort.setText(lang.get("PublishServerExternalPort")); labelPublishServerExternalPort.setText(lang.get("PublishServerExternalPort"));
listBoxPublishServerExternalPort.registerGraphicComponent(containerName,"listBoxPublishServerExternalPort"); listBoxPublishServerExternalPort.registerGraphicComponent(containerName,"listBoxPublishServerExternalPort");
listBoxPublishServerExternalPort.init(currentColumnStart, currentLine, 170); listBoxPublishServerExternalPort.init(currentColumnStart, currentLine, 170);
string supportExternalPortList = config.getString("MasterServerExternalPortList",intToStr(GameConstants::serverPort).c_str()); string supportExternalPortList = config.getString("MasterServerExternalPortList",intToStr(GameConstants::serverPort).c_str());
std::vector<std::string> externalPortList; std::vector<std::string> externalPortList;
Tokenize(supportExternalPortList,externalPortList,","); Tokenize(supportExternalPortList,externalPortList,",");
string currentPort=config.getString("MasterServerExternalPort", intToStr(GameConstants::serverPort).c_str()); string currentPort=config.getString("MasterServerExternalPort", intToStr(GameConstants::serverPort).c_str());
int masterServerExternalPortSelectionIndex=0; int masterServerExternalPortSelectionIndex=0;
for(int idx = 0; idx < externalPortList.size(); idx++) { for(int idx = 0; idx < externalPortList.size(); idx++) {
if(externalPortList[idx] != "" && IsNumeric(externalPortList[idx].c_str(),false)) { if(externalPortList[idx] != "" && IsNumeric(externalPortList[idx].c_str(),false)) {
listBoxPublishServerExternalPort.pushBackItem(externalPortList[idx]); listBoxPublishServerExternalPort.pushBackItem(externalPortList[idx]);
if(currentPort==externalPortList[idx]) if(currentPort==externalPortList[idx])
{ {
masterServerExternalPortSelectionIndex=idx; masterServerExternalPortSelectionIndex=idx;
}
} }
} }
listBoxPublishServerExternalPort.setSelectedItemIndex(masterServerExternalPortSelectionIndex);
currentLine-=lineOffset;
// FTP Config - start
labelEnableFTP.registerGraphicComponent(containerName,"labelEnableFTP");
labelEnableFTP.init(currentLabelStart ,currentLine);
labelEnableFTP.setText(lang.get("EnableFTP"));
checkBoxEnableFTP.registerGraphicComponent(containerName,"checkBoxEnableFTP");
checkBoxEnableFTP.init(currentColumnStart ,currentLine );
checkBoxEnableFTP.setValue(config.getBool("EnableFTPXfer","true"));
currentLine-=lineOffset;
labelEnableFTPServer.registerGraphicComponent(containerName,"labelEnableFTPServer");
labelEnableFTPServer.init(currentLabelStart ,currentLine);
labelEnableFTPServer.setText(lang.get("EnableFTPServer"));
checkBoxEnableFTPServer.registerGraphicComponent(containerName,"checkBoxEnableFTPServer");
checkBoxEnableFTPServer.init(currentColumnStart ,currentLine );
checkBoxEnableFTPServer.setValue(config.getBool("EnableFTPServer","true"));
currentLine-=lineOffset;
labelFTPServerPortLabel.registerGraphicComponent(containerName,"labelFTPServerPortLabel");
labelFTPServerPortLabel.init(currentLabelStart ,currentLine );
labelFTPServerPortLabel.setText(lang.get("FTPServerPort"));
int FTPPort = config.getInt("FTPServerPort",intToStr(ServerSocket::getFTPServerPort()).c_str());
labelFTPServerPort.registerGraphicComponent(containerName,"labelFTPServerPort");
labelFTPServerPort.init(currentColumnStart ,currentLine );
labelFTPServerPort.setText(intToStr(FTPPort));
currentLine-=lineOffset;
labelFTPServerDataPortsLabel.registerGraphicComponent(containerName,"labelFTPServerDataPortsLabel");
labelFTPServerDataPortsLabel.init(currentLabelStart ,currentLine );
labelFTPServerDataPortsLabel.setText(lang.get("FTPServerDataPort"));
char szBuf[1024]="";
sprintf(szBuf,"%d - %d",FTPPort + 1, FTPPort + GameConstants::maxPlayers);
labelFTPServerDataPorts.registerGraphicComponent(containerName,"labelFTPServerDataPorts");
labelFTPServerDataPorts.init(currentColumnStart,currentLine );
labelFTPServerDataPorts.setText(szBuf);
currentLine-=lineOffset;
labelEnableFTPServerInternetTilesetXfer.registerGraphicComponent(containerName,"labelEnableFTPServerInternetTilesetXfer");
labelEnableFTPServerInternetTilesetXfer.init(currentLabelStart ,currentLine );
labelEnableFTPServerInternetTilesetXfer.setText(lang.get("EnableFTPServerInternetTilesetXfer"));
checkBoxEnableFTPServerInternetTilesetXfer.registerGraphicComponent(containerName,"checkBoxEnableFTPServerInternetTilesetXfer");
checkBoxEnableFTPServerInternetTilesetXfer.init(currentColumnStart ,currentLine );
checkBoxEnableFTPServerInternetTilesetXfer.setValue(config.getBool("EnableFTPServerInternetTilesetXfer","true"));
currentLine-=lineOffset;
labelEnableFTPServerInternetTechtreeXfer.registerGraphicComponent(containerName,"labelEnableFTPServerInternetTechtreeXfer");
labelEnableFTPServerInternetTechtreeXfer.init(currentLabelStart ,currentLine );
labelEnableFTPServerInternetTechtreeXfer.setText(lang.get("EnableFTPServerInternetTechtreeXfer"));
checkBoxEnableFTPServerInternetTechtreeXfer.registerGraphicComponent(containerName,"checkBoxEnableFTPServerInternetTechtreeXfer");
checkBoxEnableFTPServerInternetTechtreeXfer.init(currentColumnStart ,currentLine );
checkBoxEnableFTPServerInternetTechtreeXfer.setValue(config.getBool("EnableFTPServerInternetTechtreeXfer","true"));
currentLine-=lineOffset;
// FTP config end
// Privacy flag
labelEnablePrivacy.registerGraphicComponent(containerName,"labelEnablePrivacy");
labelEnablePrivacy.init(currentLabelStart ,currentLine);
labelEnablePrivacy.setText(lang.get("PrivacyPlease"));
checkBoxEnablePrivacy.registerGraphicComponent(containerName,"checkBoxEnablePrivacy");
checkBoxEnablePrivacy.init(currentColumnStart ,currentLine );
checkBoxEnablePrivacy.setValue(config.getBool("PrivacyPlease","false"));
currentLine-=lineOffset;
// end
// buttons
buttonOk.registerGraphicComponent(containerName,"buttonOk");
buttonOk.init(buttonStartPos, buttonRowPos, 100);
buttonOk.setText(lang.get("Ok"));
buttonAbort.setText(lang.get("Abort"));
buttonAbort.registerGraphicComponent(containerName,"buttonAbort");
buttonAbort.init(buttonStartPos+110, buttonRowPos, 100);
buttonAutoConfig.setText(lang.get("AutoConfig"));
buttonAutoConfig.registerGraphicComponent(containerName,"buttonAutoConfig");
buttonAutoConfig.init(buttonStartPos+250, buttonRowPos, 125);
buttonVideoInfo.setText(lang.get("VideoInfo"));
buttonVideoInfo.registerGraphicComponent(containerName,"buttonVideoInfo");
buttonVideoInfo.init(buttonStartPos+385, buttonRowPos, 125); // was 620
buttonKeyboardSetup.setText(lang.get("Keyboardsetup"));
buttonKeyboardSetup.registerGraphicComponent(containerName,"buttonKeyboardSetup");
buttonKeyboardSetup.init(buttonStartPos+520, buttonRowPos, 145);
GraphicComponent::applyAllCustomProperties(containerName);
}
catch(exception &e) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error loading options: %s\n",__FILE__,__FUNCTION__,__LINE__,e.what());
throw runtime_error(string("Error loading options msg: ") + e.what());
} }
listBoxPublishServerExternalPort.setSelectedItemIndex(masterServerExternalPortSelectionIndex);
currentLine-=lineOffset;
// FTP Config - start
labelEnableFTP.registerGraphicComponent(containerName,"labelEnableFTP");
labelEnableFTP.init(currentLabelStart ,currentLine);
labelEnableFTP.setText(lang.get("EnableFTP"));
checkBoxEnableFTP.registerGraphicComponent(containerName,"checkBoxEnableFTP");
checkBoxEnableFTP.init(currentColumnStart ,currentLine );
checkBoxEnableFTP.setValue(config.getBool("EnableFTPXfer","true"));
currentLine-=lineOffset;
labelEnableFTPServer.registerGraphicComponent(containerName,"labelEnableFTPServer");
labelEnableFTPServer.init(currentLabelStart ,currentLine);
labelEnableFTPServer.setText(lang.get("EnableFTPServer"));
checkBoxEnableFTPServer.registerGraphicComponent(containerName,"checkBoxEnableFTPServer");
checkBoxEnableFTPServer.init(currentColumnStart ,currentLine );
checkBoxEnableFTPServer.setValue(config.getBool("EnableFTPServer","true"));
currentLine-=lineOffset;
labelFTPServerPortLabel.registerGraphicComponent(containerName,"labelFTPServerPortLabel");
labelFTPServerPortLabel.init(currentLabelStart ,currentLine );
labelFTPServerPortLabel.setText(lang.get("FTPServerPort"));
int FTPPort = config.getInt("FTPServerPort",intToStr(ServerSocket::getFTPServerPort()).c_str());
labelFTPServerPort.registerGraphicComponent(containerName,"labelFTPServerPort");
labelFTPServerPort.init(currentColumnStart ,currentLine );
labelFTPServerPort.setText(intToStr(FTPPort));
currentLine-=lineOffset;
labelFTPServerDataPortsLabel.registerGraphicComponent(containerName,"labelFTPServerDataPortsLabel");
labelFTPServerDataPortsLabel.init(currentLabelStart ,currentLine );
labelFTPServerDataPortsLabel.setText(lang.get("FTPServerDataPort"));
char szBuf[1024]="";
sprintf(szBuf,"%d - %d",FTPPort + 1, FTPPort + GameConstants::maxPlayers);
labelFTPServerDataPorts.registerGraphicComponent(containerName,"labelFTPServerDataPorts");
labelFTPServerDataPorts.init(currentColumnStart,currentLine );
labelFTPServerDataPorts.setText(szBuf);
currentLine-=lineOffset;
labelEnableFTPServerInternetTilesetXfer.registerGraphicComponent(containerName,"labelEnableFTPServerInternetTilesetXfer");
labelEnableFTPServerInternetTilesetXfer.init(currentLabelStart ,currentLine );
labelEnableFTPServerInternetTilesetXfer.setText(lang.get("EnableFTPServerInternetTilesetXfer"));
checkBoxEnableFTPServerInternetTilesetXfer.registerGraphicComponent(containerName,"checkBoxEnableFTPServerInternetTilesetXfer");
checkBoxEnableFTPServerInternetTilesetXfer.init(currentColumnStart ,currentLine );
checkBoxEnableFTPServerInternetTilesetXfer.setValue(config.getBool("EnableFTPServerInternetTilesetXfer","true"));
currentLine-=lineOffset;
labelEnableFTPServerInternetTechtreeXfer.registerGraphicComponent(containerName,"labelEnableFTPServerInternetTechtreeXfer");
labelEnableFTPServerInternetTechtreeXfer.init(currentLabelStart ,currentLine );
labelEnableFTPServerInternetTechtreeXfer.setText(lang.get("EnableFTPServerInternetTechtreeXfer"));
checkBoxEnableFTPServerInternetTechtreeXfer.registerGraphicComponent(containerName,"checkBoxEnableFTPServerInternetTechtreeXfer");
checkBoxEnableFTPServerInternetTechtreeXfer.init(currentColumnStart ,currentLine );
checkBoxEnableFTPServerInternetTechtreeXfer.setValue(config.getBool("EnableFTPServerInternetTechtreeXfer","true"));
currentLine-=lineOffset;
// FTP config end
// Privacy flag
labelEnablePrivacy.registerGraphicComponent(containerName,"labelEnablePrivacy");
labelEnablePrivacy.init(currentLabelStart ,currentLine);
labelEnablePrivacy.setText(lang.get("PrivacyPlease"));
checkBoxEnablePrivacy.registerGraphicComponent(containerName,"checkBoxEnablePrivacy");
checkBoxEnablePrivacy.init(currentColumnStart ,currentLine );
checkBoxEnablePrivacy.setValue(config.getBool("PrivacyPlease","false"));
currentLine-=lineOffset;
// end
// buttons
buttonOk.registerGraphicComponent(containerName,"buttonOk");
buttonOk.init(buttonStartPos, buttonRowPos, 100);
buttonOk.setText(lang.get("Ok"));
buttonAbort.setText(lang.get("Abort"));
buttonAbort.registerGraphicComponent(containerName,"buttonAbort");
buttonAbort.init(buttonStartPos+110, buttonRowPos, 100);
buttonAutoConfig.setText(lang.get("AutoConfig"));
buttonAutoConfig.registerGraphicComponent(containerName,"buttonAutoConfig");
buttonAutoConfig.init(buttonStartPos+250, buttonRowPos, 125);
buttonVideoInfo.setText(lang.get("VideoInfo"));
buttonVideoInfo.registerGraphicComponent(containerName,"buttonVideoInfo");
buttonVideoInfo.init(buttonStartPos+385, buttonRowPos, 125); // was 620
buttonKeyboardSetup.setText(lang.get("Keyboardsetup"));
buttonKeyboardSetup.registerGraphicComponent(containerName,"buttonKeyboardSetup");
buttonKeyboardSetup.init(buttonStartPos+520, buttonRowPos, 145);
GraphicComponent::applyAllCustomProperties(containerName);
} }
void MenuStateOptions::reloadUI() { void MenuStateOptions::reloadUI() {

View File

@@ -78,6 +78,10 @@ MenuStateRoot::MenuStateRoot(Program *program, MainMenu *mainMenu):
mainMessageBox.init(lang.get("Yes"), lang.get("No")); mainMessageBox.init(lang.get("Yes"), lang.get("No"));
mainMessageBox.setEnabled(false); mainMessageBox.setEnabled(false);
errorMessageBox.registerGraphicComponent(containerName,"errorMessageBox");
errorMessageBox.init(lang.get("Ok"));
errorMessageBox.setEnabled(false);
//PopupMenu popupMenu; //PopupMenu popupMenu;
std::vector<string> menuItems; std::vector<string> menuItems;
menuItems.push_back("1"); menuItems.push_back("1");
@@ -111,56 +115,73 @@ void MenuStateRoot::reloadUI() {
buttonExit.setText(lang.get("Exit")); buttonExit.setText(lang.get("Exit"));
mainMessageBox.init(lang.get("Yes"), lang.get("No")); mainMessageBox.init(lang.get("Yes"), lang.get("No"));
errorMessageBox.init(lang.get("Ok"));
console.resetFonts(); console.resetFonts();
GraphicComponent::reloadFontsForRegisterGraphicComponents(containerName); GraphicComponent::reloadFontsForRegisterGraphicComponents(containerName);
} }
void MenuStateRoot::mouseClick(int x, int y, MouseButton mouseButton){ void MenuStateRoot::mouseClick(int x, int y, MouseButton mouseButton){
try {
CoreData &coreData= CoreData::getInstance();
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
CoreData &coreData= CoreData::getInstance(); if(popupMenu.mouseClick(x, y)) {
SoundRenderer &soundRenderer= SoundRenderer::getInstance(); std::pair<int,string> result = popupMenu.mouseClickedMenuItem(x, y);
if(popupMenu.mouseClick(x, y)) { //printf("In popup callback menuItemSelected [%s] menuIndexSelected = %d\n",result.second.c_str(),result.first);
std::pair<int,string> result = popupMenu.mouseClickedMenuItem(x, y); }
//exit message box, has to be the last thing to do in this function
//printf("In popup callback menuItemSelected [%s] menuIndexSelected = %d\n",result.second.c_str(),result.first); else if(mainMessageBox.getEnabled()){
} int button= 1;
else if(mainMessageBox.getEnabled() == false && buttonNewGame.mouseClick(x, y)){ if(mainMessageBox.mouseClick(x, y, button)) {
soundRenderer.playFx(coreData.getClickSoundB()); if(button==1) {
mainMenu->setState(new MenuStateNewGame(program, mainMenu)); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
} soundRenderer.playFx(coreData.getClickSoundA());
else if(mainMessageBox.getEnabled() == false && buttonMods.mouseClick(x, y)){ program->exit();
soundRenderer.playFx(coreData.getClickSoundB()); }
mainMenu->setState(new MenuStateMods(program, mainMenu)); else {
} if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
else if(mainMessageBox.getEnabled() == false && buttonOptions.mouseClick(x, y)){ //close message box
soundRenderer.playFx(coreData.getClickSoundB()); mainMessageBox.setEnabled(false);
mainMenu->setState(new MenuStateOptions(program, mainMenu)); }
}
else if(mainMessageBox.getEnabled() == false && buttonAbout.mouseClick(x, y)){
soundRenderer.playFx(coreData.getClickSoundB());
mainMenu->setState(new MenuStateAbout(program, mainMenu));
}
else if(buttonExit.mouseClick(x, y)){
soundRenderer.playFx(coreData.getClickSoundA());
program->exit();
}
//exit message box, has to be the last thing to do in this function
else if(mainMessageBox.getEnabled()){
int button= 1;
if(mainMessageBox.mouseClick(x, y, button)) {
if(button==1) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
soundRenderer.playFx(coreData.getClickSoundA());
program->exit();
}
else {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
//close message box
mainMessageBox.setEnabled(false);
} }
} }
//exit message box, has to be the last thing to do in this function
else if(errorMessageBox.getEnabled()){
int button= 1;
if(mainMessageBox.mouseClick(x, y, button)) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
//close message box
errorMessageBox.setEnabled(false);
}
}
else if(mainMessageBox.getEnabled() == false && buttonNewGame.mouseClick(x, y)){
soundRenderer.playFx(coreData.getClickSoundB());
mainMenu->setState(new MenuStateNewGame(program, mainMenu));
}
else if(mainMessageBox.getEnabled() == false && buttonMods.mouseClick(x, y)){
soundRenderer.playFx(coreData.getClickSoundB());
mainMenu->setState(new MenuStateMods(program, mainMenu));
}
else if(mainMessageBox.getEnabled() == false && buttonOptions.mouseClick(x, y)){
soundRenderer.playFx(coreData.getClickSoundB());
mainMenu->setState(new MenuStateOptions(program, mainMenu));
}
else if(mainMessageBox.getEnabled() == false && buttonAbout.mouseClick(x, y)){
soundRenderer.playFx(coreData.getClickSoundB());
mainMenu->setState(new MenuStateAbout(program, mainMenu));
}
else if(buttonExit.mouseClick(x, y)){
soundRenderer.playFx(coreData.getClickSoundA());
program->exit();
}
}
catch(exception &e) {
char szBuf[1024]="";
sprintf(szBuf,"In [%s::%s Line: %d]\nError in menu event:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what());
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
showErrorMessageBox(szBuf, "", true);
} }
} }
@@ -174,7 +195,9 @@ void MenuStateRoot::mouseMove(int x, int y, const MouseState *ms){
if (mainMessageBox.getEnabled()) { if (mainMessageBox.getEnabled()) {
mainMessageBox.mouseMove(x, y); mainMessageBox.mouseMove(x, y);
} }
if (errorMessageBox.getEnabled()) {
errorMessageBox.mouseMove(x, y);
}
} }
bool MenuStateRoot::isMasterserverMode() const { bool MenuStateRoot::isMasterserverMode() const {
@@ -251,6 +274,9 @@ void MenuStateRoot::render() {
if(mainMessageBox.getEnabled()) { if(mainMessageBox.getEnabled()) {
renderer.renderMessageBox(&mainMessageBox); renderer.renderMessageBox(&mainMessageBox);
} }
if(errorMessageBox.getEnabled()) {
renderer.renderMessageBox(&errorMessageBox);
}
if(program != NULL) program->renderProgramMsgBox(); if(program != NULL) program->renderProgramMsgBox();
} }
@@ -314,4 +340,19 @@ void MenuStateRoot::showMessageBox(const string &text, const string &header, boo
} }
} }
void MenuStateRoot::showErrorMessageBox(const string &text, const string &header, bool toggle){
if(!toggle){
errorMessageBox.setEnabled(false);
}
if(!errorMessageBox.getEnabled()){
errorMessageBox.setText(text);
errorMessageBox.setHeader(header);
errorMessageBox.setEnabled(true);
}
else{
errorMessageBox.setEnabled(false);
}
}
}}//end namespace }}//end namespace

View File

@@ -34,6 +34,7 @@ private:
GraphicLabel labelVersion; GraphicLabel labelVersion;
GraphicMessageBox mainMessageBox; GraphicMessageBox mainMessageBox;
GraphicMessageBox errorMessageBox;
PopupMenu popupMenu; PopupMenu popupMenu;
@@ -47,6 +48,8 @@ public:
virtual void keyDown(SDL_KeyboardEvent key); virtual void keyDown(SDL_KeyboardEvent key);
void showMessageBox(const string &text, const string &header, bool toggle); void showMessageBox(const string &text, const string &header, bool toggle);
void showErrorMessageBox(const string &text, const string &header, bool toggle);
virtual bool isMasterserverMode() const; virtual bool isMasterserverMode() const;
virtual void reloadUI(); virtual void reloadUI();
}; };