From f749576f6c2a1e356b5f72cf2a0bdeaee4d6ce2d Mon Sep 17 00:00:00 2001 From: filux Date: Fri, 6 Feb 2015 01:29:13 +0100 Subject: [PATCH] support for long transifex language codes (like xx_XX) and a bit more friendly options for other than english languages --- source/glest_game/menu/menu_state_options.cpp | 36 ++++++++++--------- .../menu/menu_state_options_graphics.cpp | 12 +++---- .../menu/menu_state_options_network.cpp | 8 ++--- .../menu/menu_state_options_sound.cpp | 14 ++++---- 4 files changed, 37 insertions(+), 33 deletions(-) diff --git a/source/glest_game/menu/menu_state_options.cpp b/source/glest_game/menu/menu_state_options.cpp index 506959b78..fd523141b 100644 --- a/source/glest_game/menu/menu_state_options.cpp +++ b/source/glest_game/menu/menu_state_options.cpp @@ -47,8 +47,8 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu, Program //modeinfos=list (); activeInputLabel=NULL; - int leftLabelStart=50; - int leftColumnStart=leftLabelStart+280; + int leftLabelStart=100; + int leftColumnStart=leftLabelStart+300; //int rightLabelStart=450; //int rightColumnStart=rightLabelStart+280; int buttonRowPos=50; @@ -108,7 +108,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu, Program labelLang.setText(lang.getString("Language")); listBoxLang.registerGraphicComponent(containerName,"listBoxLang"); - listBoxLang.init(currentColumnStart, currentLine, 320); + listBoxLang.init(currentColumnStart, currentLine, 375); vector langResults; // string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey); @@ -232,7 +232,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu, Program labelHealthBars.setText(lang.getString("Healthbar")); listBoxHealthBars.registerGraphicComponent(containerName,"lisBoxtHealthBars"); - listBoxHealthBars.init(currentColumnStart ,currentLine, 300 ); + listBoxHealthBars.init(currentColumnStart ,currentLine, 375); listBoxHealthBars.pushBackItem(lang.getString("HealthbarsFactionDefault")); listBoxHealthBars.pushBackItem(lang.getString("HealthbarsOff")); listBoxHealthBars.pushBackItem(lang.getString("HealthbarsAlways")); @@ -332,11 +332,11 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu, Program labelTransifexUserLabel.setText(lang.getString("TransifexUserName")); labelTransifexPwdLabel.registerGraphicComponent(containerName,"labelTransifexPwdLabel"); - labelTransifexPwdLabel.init(currentLabelStart + 250 ,currentLine); + labelTransifexPwdLabel.init(currentLabelStart + 260 ,currentLine); labelTransifexPwdLabel.setText(lang.getString("TransifexPwd")); labelTransifexI18NLabel.registerGraphicComponent(containerName,"labelTransifexI18NLabel"); - labelTransifexI18NLabel.init(currentLabelStart + 500 ,currentLine); + labelTransifexI18NLabel.init(currentLabelStart + 520 ,currentLine); labelTransifexI18NLabel.setText(lang.getString("TransifexI18N")); currentLine-=lineOffset; @@ -344,32 +344,32 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu, Program labelTransifexUser.registerGraphicComponent(containerName,"labelTransifexUser"); labelTransifexUser.init(currentLabelStart,currentLine); labelTransifexUser.setEditable(true); - labelTransifexUser.setMaxEditWidth(30); - labelTransifexUser.setMaxEditRenderWidth(220); + labelTransifexUser.setMaxEditWidth(28); + labelTransifexUser.setMaxEditRenderWidth(250); labelTransifexUser.setText(config.getString("TranslationGetURLUser","")); labelTransifexPwd.registerGraphicComponent(containerName,"labelTransifexPwd"); - labelTransifexPwd.init(currentLabelStart + 250 ,currentLine); + labelTransifexPwd.init(currentLabelStart + 260 ,currentLine); labelTransifexPwd.setIsPassword(true); labelTransifexPwd.setEditable(true); - labelTransifexPwd.setMaxEditWidth(35); - labelTransifexPwd.setMaxEditRenderWidth(220); + labelTransifexPwd.setMaxEditWidth(28); + labelTransifexPwd.setMaxEditRenderWidth(250); labelTransifexPwd.setText(config.getString("TranslationGetURLPassword","")); labelTransifexI18N.registerGraphicComponent(containerName,"labelTransifexI18N"); - labelTransifexI18N.init(currentLabelStart + 500 ,currentLine); + labelTransifexI18N.init(currentLabelStart + 520 ,currentLine); labelTransifexI18N.setEditable(true); - labelTransifexI18N.setMaxEditWidth(3); - labelTransifexI18N.setMaxEditRenderWidth(40); + labelTransifexI18N.setMaxEditWidth(6); + labelTransifexI18N.setMaxEditRenderWidth(70); labelTransifexI18N.setText(config.getString("TranslationGetURLLanguage","en")); currentLine-=lineOffset; buttonGetNewLanguageFiles.registerGraphicComponent(containerName,"buttonGetNewLanguageFiles"); - buttonGetNewLanguageFiles.init(currentLabelStart+20, currentLine, 200); + buttonGetNewLanguageFiles.init(currentLabelStart, currentLine, 250); buttonGetNewLanguageFiles.setText(lang.getString("TransifexGetLanguageFiles")); buttonDeleteNewLanguageFiles.registerGraphicComponent(containerName,"buttonDeleteNewLanguageFiles"); - buttonDeleteNewLanguageFiles.init(currentLabelStart + 250, currentLine, 200); + buttonDeleteNewLanguageFiles.init(currentLabelStart + 260, currentLine, 250); buttonDeleteNewLanguageFiles.setText(lang.getString("TransifexDeleteLanguageFiles")); setupTransifexUI(); @@ -609,6 +609,8 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){ if(labelTransifexI18N.getText() != "") { Lang &lang= Lang::getInstance(); string language = lang.getLanguageFile(labelTransifexI18N.getText()); + replaceAll(language,"(",""); + replaceAll(language,")",""); if(language != "") { bool foundFilesToDelete = false; @@ -853,6 +855,8 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){ replaceAll(langName,"@",""); replaceAll(langName,"!",""); replaceAll(langName,"*",""); + replaceAll(langName,"(",""); + replaceAll(langName,")",""); langName = trim(langName); replaceAll(langName," ","-"); } diff --git a/source/glest_game/menu/menu_state_options_graphics.cpp b/source/glest_game/menu/menu_state_options_graphics.cpp index d9aebef35..0d1e87d7b 100644 --- a/source/glest_game/menu/menu_state_options_graphics.cpp +++ b/source/glest_game/menu/menu_state_options_graphics.cpp @@ -49,8 +49,8 @@ MenuStateOptionsGraphics::MenuStateOptionsGraphics(Program *program, MainMenu *m //modeinfos=list (); ::Shared::PlatformCommon::getFullscreenVideoModes(&modeInfos,!config.getBool("Windowed")); - int leftLabelStart=50; - int leftColumnStart=leftLabelStart+280; + int leftLabelStart=100; + int leftColumnStart=leftLabelStart+300; //int rightLabelStart=450; //int rightColumnStart=rightLabelStart+280; int buttonRowPos=50; @@ -188,7 +188,7 @@ MenuStateOptionsGraphics::MenuStateOptionsGraphics(Program *program, MainMenu *m labelSelectionType.setText(lang.getString("SelectionType")); listBoxSelectionType.registerGraphicComponent(containerName,"listBoxSelectionType"); - listBoxSelectionType.init(currentColumnStart, currentLine, 200); + listBoxSelectionType.init(currentColumnStart, currentLine, 250); listBoxSelectionType.pushBackItem("SelectBuffer (nvidia)"); listBoxSelectionType.pushBackItem("ColorPicking (default)"); listBoxSelectionType.pushBackItem("FrustumPicking (bad)"); @@ -208,7 +208,7 @@ MenuStateOptionsGraphics::MenuStateOptionsGraphics(Program *program, MainMenu *m labelShadows.setText(lang.getString("Shadows")); listBoxShadows.registerGraphicComponent(containerName,"listBoxShadows"); - listBoxShadows.init(currentColumnStart, currentLine, 200); + listBoxShadows.init(currentColumnStart, currentLine, 250); for(int i= 0; i(i)))); } @@ -369,11 +369,11 @@ MenuStateOptionsGraphics::MenuStateOptionsGraphics(Program *program, MainMenu *m buttonAutoConfig.setText(lang.getString("AutoConfig")); buttonAutoConfig.registerGraphicComponent(containerName,"buttonAutoConfig"); - buttonAutoConfig.init(buttonStartPos+250, buttonRowPos, 125); + buttonAutoConfig.init(buttonStartPos+230, buttonRowPos, 175); buttonVideoInfo.setText(lang.getString("VideoInfo")); buttonVideoInfo.registerGraphicComponent(containerName,"buttonVideoInfo"); - buttonVideoInfo.init(buttonStartPos+385, buttonRowPos, 125); // was 620 + buttonVideoInfo.init(buttonStartPos+415, buttonRowPos, 175); // was 620 GraphicComponent::applyAllCustomProperties(containerName); } diff --git a/source/glest_game/menu/menu_state_options_network.cpp b/source/glest_game/menu/menu_state_options_network.cpp index 1e2bc53a1..d530cdab3 100644 --- a/source/glest_game/menu/menu_state_options_network.cpp +++ b/source/glest_game/menu/menu_state_options_network.cpp @@ -45,8 +45,8 @@ MenuStateOptionsNetwork::MenuStateOptionsNetwork(Program *program, MainMenu *mai this->parentUI=parentUI; this->console.setOnlyChatMessagesInStoredLines(false); //modeinfos=list (); - int leftLabelStart=50; - int leftColumnStart=leftLabelStart+280; + int leftLabelStart=100; + int leftColumnStart=leftLabelStart+300; //int rightLabelStart=450; //int rightColumnStart=rightLabelStart+280; int buttonRowPos=50; @@ -123,7 +123,7 @@ MenuStateOptionsNetwork::MenuStateOptionsNetwork(Program *program, MainMenu *mai labelServerPortLabel.setText(lang.getString("ServerPort")); listBoxServerPort.registerGraphicComponent(containerName,"listBoxPublishServerExternalPort"); - listBoxServerPort.init(currentColumnStart, currentLine, 170); + listBoxServerPort.init(currentColumnStart, currentLine, 160); string portListString = config.getString("PortList",intToStr(GameConstants::serverPort).c_str()); std::vector portList; @@ -219,8 +219,8 @@ MenuStateOptionsNetwork::MenuStateOptionsNetwork(Program *program, MainMenu *mai buttonOk.registerGraphicComponent(containerName,"buttonOk"); buttonOk.init(buttonStartPos, buttonRowPos, 100); buttonOk.setText(lang.getString("Save")); - buttonReturn.setText(lang.getString("Return")); + buttonReturn.setText(lang.getString("Return")); buttonReturn.registerGraphicComponent(containerName,"buttonAbort"); buttonReturn.init(buttonStartPos+110, buttonRowPos, 100); diff --git a/source/glest_game/menu/menu_state_options_sound.cpp b/source/glest_game/menu/menu_state_options_sound.cpp index e20ced4a7..0fbb7a52f 100644 --- a/source/glest_game/menu/menu_state_options_sound.cpp +++ b/source/glest_game/menu/menu_state_options_sound.cpp @@ -45,8 +45,8 @@ MenuStateOptionsSound::MenuStateOptionsSound(Program *program, MainMenu *mainMen Config &config= Config::getInstance(); this->console.setOnlyChatMessagesInStoredLines(false); - int leftLabelStart=50; - int leftColumnStart=leftLabelStart+280; + int leftLabelStart=100; + int leftColumnStart=leftLabelStart+300; //int rightLabelStart=450; //int rightColumnStart=rightLabelStart+280; int buttonRowPos=50; @@ -103,11 +103,11 @@ MenuStateOptionsSound::MenuStateOptionsSound(Program *program, MainMenu *mainMen //soundboxes labelSoundFactory.registerGraphicComponent(containerName,"labelSoundFactory"); labelSoundFactory.init(currentLabelStart, currentLine); - labelSoundFactory.setText(lang.getString("SoundAndMusic")); + labelSoundFactory.setText(lang.getString("SoundAndMusic2")); listBoxSoundFactory.registerGraphicComponent(containerName,"listBoxSoundFactory"); - listBoxSoundFactory.init(currentColumnStart, currentLine, 100); - listBoxSoundFactory.pushBackItem("None"); + listBoxSoundFactory.init(currentColumnStart, currentLine, 175); + listBoxSoundFactory.pushBackItem(lang.getString("None")); listBoxSoundFactory.pushBackItem("OpenAL"); listBoxSoundFactory.setSelectedItem(config.getString("FactorySound")); @@ -198,10 +198,10 @@ void MenuStateOptionsSound::reloadUI() { buttonNetworkSettings.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D()); buttonNetworkSettings.setText(lang.getString("Network")); - labelSoundFactory.setText(lang.getString("SoundAndMusic")); + labelSoundFactory.setText(lang.getString("SoundAndMusic2")); std::vector listboxData; - listboxData.push_back("None"); + listboxData.push_back(lang.getString("None")); listboxData.push_back("OpenAL"); listBoxSoundFactory.setItems(listboxData);