mirror of
https://github.com/glest/glest-source.git
synced 2025-09-02 04:22:32 +02:00
- bugfix for invalid language setting in userini
- added debug info to track down tomreyn's issue
This commit is contained in:
@@ -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 {
|
||||||
|
@@ -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) {
|
||||||
|
@@ -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);
|
||||||
};
|
};
|
||||||
|
@@ -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()){
|
||||||
|
@@ -32,6 +32,7 @@ namespace Glest{ namespace Game{
|
|||||||
MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
||||||
MenuState(program, mainMenu, "config")
|
MenuState(program, mainMenu, "config")
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
containerName = "Options";
|
containerName = "Options";
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
Config &config= Config::getInstance();
|
Config &config= Config::getInstance();
|
||||||
@@ -72,9 +73,9 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
|||||||
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;
|
||||||
@@ -292,22 +293,22 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
|||||||
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) {
|
||||||
@@ -317,6 +318,9 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
|||||||
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"));
|
||||||
|
if(defaultLang.first == "" && defaultLang.second == "") {
|
||||||
|
defaultLang = Lang::getInstance().getNavtiveNameFromLanguageName(Lang::getInstance().getDefaultLanguage());
|
||||||
|
}
|
||||||
listBoxLang.setSelectedItem(defaultLang.second + "-" + defaultLang.first);
|
listBoxLang.setSelectedItem(defaultLang.second + "-" + defaultLang.first);
|
||||||
currentLine-=lineOffset;
|
currentLine-=lineOffset;
|
||||||
|
|
||||||
@@ -525,6 +529,11 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu):
|
|||||||
buttonKeyboardSetup.init(buttonStartPos+520, buttonRowPos, 145);
|
buttonKeyboardSetup.init(buttonStartPos+520, buttonRowPos, 145);
|
||||||
|
|
||||||
GraphicComponent::applyAllCustomProperties(containerName);
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateOptions::reloadUI() {
|
void MenuStateOptions::reloadUI() {
|
||||||
|
@@ -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,13 +115,14 @@ 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();
|
CoreData &coreData= CoreData::getInstance();
|
||||||
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||||
|
|
||||||
@@ -126,6 +131,31 @@ void MenuStateRoot::mouseClick(int x, int y, MouseButton mouseButton){
|
|||||||
|
|
||||||
//printf("In popup callback menuItemSelected [%s] menuIndexSelected = %d\n",result.second.c_str(),result.first);
|
//printf("In popup callback menuItemSelected [%s] menuIndexSelected = %d\n",result.second.c_str(),result.first);
|
||||||
}
|
}
|
||||||
|
//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)){
|
else if(mainMessageBox.getEnabled() == false && buttonNewGame.mouseClick(x, y)){
|
||||||
soundRenderer.playFx(coreData.getClickSoundB());
|
soundRenderer.playFx(coreData.getClickSoundB());
|
||||||
mainMenu->setState(new MenuStateNewGame(program, mainMenu));
|
mainMenu->setState(new MenuStateNewGame(program, mainMenu));
|
||||||
@@ -146,21 +176,12 @@ void MenuStateRoot::mouseClick(int x, int y, MouseButton mouseButton){
|
|||||||
soundRenderer.playFx(coreData.getClickSoundA());
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
program->exit();
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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
|
||||||
|
@@ -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();
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user