diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui.cpp | 14 | ||||
-rw-r--r-- | src/gui/theme.cpp | 2 | ||||
-rw-r--r-- | src/gui/theme.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/tabs/setup_theme.cpp | 22 | ||||
-rw-r--r-- | src/gui/widgets/tabs/setup_theme.h | 4 |
5 files changed, 43 insertions, 1 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index db3faa314..3fe0443ca 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -137,6 +137,8 @@ void Gui::postInit(Graphics *const graphics) const StringVect langs = getLang(); const bool isJapan = (!langs.empty() && langs[0].size() > 3 && langs[0].substr(0, 3) == "ja_"); + const bool isChinese = (!langs.empty() && langs[0].size() > 3 + && langs[0].substr(0, 3) == "zh_"); // Set global font const int fontSize = config.getIntValue("fontSize"); @@ -147,6 +149,12 @@ void Gui::postInit(Graphics *const graphics) if (fontFile.empty()) fontFile = branding.getStringValue("japanFont"); } + else if(isChinese) + { + fontFile = config.getValue("chinaFont", ""); + if (fontFile.empty()) + fontFile = branding.getStringValue("chinaFont"); + } if (fontFile.empty()) fontFile = branding.getStringValue("font"); @@ -170,6 +178,12 @@ void Gui::postInit(Graphics *const graphics) if (fontFile.empty()) fontFile = branding.getStringValue("japanFont"); } + else if(isChinese) + { + fontFile = config.getValue("chinaFont", ""); + if (fontFile.empty()) + fontFile = branding.getStringValue("chinaFont"); + } if (fontFile.empty()) diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 45c6db5ba..6fdae088c 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -1310,6 +1310,8 @@ ThemeInfo *Theme::loadInfo(const std::string &themeName) readValue(secureFont); else if (xmlNameEqual(infoNode, "japanFont")) readValue(japanFont); + else if (xmlNameEqual(infoNode, "chinaFont")) + readValue(chinaFont); else if (xmlNameEqual(infoNode, "fontSize")) readIntValue(fontSize); else if (xmlNameEqual(infoNode, "npcfontSize")) diff --git a/src/gui/theme.h b/src/gui/theme.h index 95511dc59..2e4b70e13 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -54,6 +54,7 @@ struct ThemeInfo final helpFont(), secureFont(), japanFont(), + chinaFont(), fontSize(0), npcfontSize(0), guiAlpha(0.0F) @@ -67,6 +68,7 @@ struct ThemeInfo final std::string helpFont; std::string secureFont; std::string japanFont; + std::string chinaFont; int fontSize; int npcfontSize; float guiAlpha; diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp index c80ec3aac..b4f6c35ac 100644 --- a/src/gui/widgets/tabs/setup_theme.cpp +++ b/src/gui/widgets/tabs/setup_theme.cpp @@ -46,7 +46,8 @@ const char* ACTION_BOLD_FONT = "bold font"; const char* ACTION_PARTICLE_FONT = "particle font"; const char* ACTION_HELP_FONT = "help font"; const char* ACTION_SECURE_FONT = "secure font"; -const char* ACTION_JAPAN_FONT = "japan font"; +const char* ACTION_JAPAN_FONT = "japanese font"; +const char* ACTION_CHINA_FONT = "chinese font"; const char* ACTION_INFO = "info"; class ThemesModel final : public NamesModel @@ -261,6 +262,10 @@ Setup_Theme::Setup_Theme(const Widget2 *const widget) : mJapanFontLabel(new Label(this, _("Japanese font"))), mJapanFontDropDown(new DropDown(this, mFontsModel)), mJapanFont(config.getStringValue("japanFont")), + // TRANSLATORS: theme settings label + mChinaFontLabel(new Label(this, _("Chinese font"))), + mChinaFontDropDown(new DropDown(this, mFontsModel)), + mChinaFont(config.getStringValue("chinaFont")), mFontSizeListModel(new FontSizeChoiceListModel), // TRANSLATORS: theme settings label mFontSizeLabel(new Label(this, _("Font size"))), @@ -294,6 +299,8 @@ Setup_Theme::Setup_Theme(const Widget2 *const widget) : mSecureFontDropDown->addActionListener(this); mJapanFontDropDown->setActionEventId(ACTION_JAPAN_FONT); mJapanFontDropDown->addActionListener(this); + mChinaFontDropDown->setActionEventId(ACTION_CHINA_FONT); + mChinaFontDropDown->addActionListener(this); mFontSizeDropDown->setSelected(mFontSize - 9); mFontSizeDropDown->adjustHeight(); mNpcFontSizeDropDown->setSelected(mNpcFontSize - 9); @@ -327,6 +334,8 @@ Setup_Theme::Setup_Theme(const Widget2 *const widget) : config.getStringValue("secureFont"))); mJapanFontDropDown->setSelectedString(getFileName( config.getStringValue("japanFont"))); + mChinaFontDropDown->setSelectedString(getFileName( + config.getStringValue("chinaFont"))); updateInfo(); @@ -344,6 +353,7 @@ Setup_Theme::Setup_Theme(const Widget2 *const widget) : place(0, 7, mHelpFontLabel, 5); place(0, 8, mSecureFontLabel, 5); place(0, 9, mJapanFontLabel, 5); + place(0, 10, mChinaFontLabel, 5); place(6, 0, mThemeDropDown, 10); place(6, 1, mLangDropDown, 10); @@ -355,6 +365,7 @@ Setup_Theme::Setup_Theme(const Widget2 *const widget) : place(6, 7, mHelpFontDropDown, 10); place(6, 8, mSecureFontDropDown, 10); place(6, 9, mJapanFontDropDown, 10); + place(6, 10, mChinaFontDropDown, 10); place(17, 0, mInfoButton, 1); @@ -454,6 +465,10 @@ void Setup_Theme::action(const gcn::ActionEvent &event) { mJapanFont = mJapanFontDropDown->getSelectedString(); } + else if (eventId == ACTION_CHINA_FONT) + { + mChinaFont = mChinaFontDropDown->getSelectedString(); + } else if (eventId == ACTION_INFO) { // TRANSLATORS: theme info dialog header @@ -472,6 +487,7 @@ void Setup_Theme::cancel() mHelpFont = getFileName(config.getStringValue("helpFont")); mSecureFont = getFileName(config.getStringValue("secureFont")); mJapanFont = getFileName(config.getStringValue("japanFont")); + mChinaFont = getFileName(config.getStringValue("chinaFont")); } #define updateField(name1, name2) if (!mInfo->name1.empty()) \ @@ -495,6 +511,7 @@ void Setup_Theme::apply() updateField(helpFont, mHelpFont); updateField(secureFont, mSecureFont); updateField(japanFont, mJapanFont); + updateField(chinaFont, mChinaFont); if (mInfo->fontSize) { const int size = mInfo->fontSize - 9; @@ -518,6 +535,8 @@ void Setup_Theme::apply() || config.getValue("helpFont", "dejavusansmono.ttf") != mHelpFont || config.getValue("secureFont", "dejavusansmono.ttf") != mSecureFont || config.getValue("japanFont", "mplus-1p-regular.ttf") != mJapanFont + || config.getValue("chinaFont", "fonts/wqy-microhei.ttf") + != mChinaFont || config.getIntValue("fontSize") != static_cast<int>(mFontSizeDropDown->getSelected()) + 9 || config.getIntValue("npcfontSize") @@ -529,6 +548,7 @@ void Setup_Theme::apply() config.setValue("helpFont", "fonts/" + getFileName(mHelpFont)); config.setValue("secureFont", "fonts/" + getFileName(mSecureFont)); config.setValue("japanFont", "fonts/" + getFileName(mJapanFont)); + config.setValue("chinaFont", "fonts/" + getFileName(mChinaFont)); config.setValue("fontSize", mFontSizeDropDown->getSelected() + 9); config.setValue("npcfontSize", mNpcFontSizeDropDown->getSelected() + 9); diff --git a/src/gui/widgets/tabs/setup_theme.h b/src/gui/widgets/tabs/setup_theme.h index daf0a6f72..920ef62af 100644 --- a/src/gui/widgets/tabs/setup_theme.h +++ b/src/gui/widgets/tabs/setup_theme.h @@ -88,6 +88,10 @@ class Setup_Theme final : public SetupTab DropDown *mJapanFontDropDown; std::string mJapanFont; + Label *mChinaFontLabel; + DropDown *mChinaFontDropDown; + std::string mChinaFont; + FontSizeChoiceListModel *mFontSizeListModel; Label *mFontSizeLabel; int mFontSize; |