summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-01-05 21:51:03 +0300
committerAndrei Karas <akaras@inbox.ru>2014-01-05 21:51:03 +0300
commit5090180c23dd53de111c316286639d3ba8277468 (patch)
treeb936b58ce905a06cc83a5ec70ce08629722abd04
parent38489512096ca1f5a79a5fdaf9a73c9f5fda22e2 (diff)
downloadmanaverse-5090180c23dd53de111c316286639d3ba8277468.tar.gz
manaverse-5090180c23dd53de111c316286639d3ba8277468.tar.bz2
manaverse-5090180c23dd53de111c316286639d3ba8277468.tar.xz
manaverse-5090180c23dd53de111c316286639d3ba8277468.zip
Add chinese font auto usage if detected chinese locale.
-rw-r--r--src/client.cpp4
-rw-r--r--src/defaults.cpp2
-rw-r--r--src/gui/gui.cpp14
-rw-r--r--src/gui/theme.cpp2
-rw-r--r--src/gui/theme.h2
-rw-r--r--src/gui/widgets/tabs/setup_theme.cpp22
-rw-r--r--src/gui/widgets/tabs/setup_theme.h4
7 files changed, 49 insertions, 1 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 43c474dab..e5f06016e 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -2354,6 +2354,7 @@ void Client::storeSafeParameters() const
std::string helpFont;
std::string secureFont;
std::string japanFont;
+ std::string chinaFont;
bool showBackground;
bool enableMumble;
bool enableMapReduce;
@@ -2378,6 +2379,7 @@ void Client::storeSafeParameters() const
helpFont = config.getStringValue("helpFont");
secureFont = config.getStringValue("secureFont");
japanFont = config.getStringValue("japanFont");
+ chinaFont = config.getStringValue("chinaFont");
showBackground = config.getBoolValue("showBackground");
enableMumble = config.getBoolValue("enableMumble");
@@ -2398,6 +2400,7 @@ void Client::storeSafeParameters() const
config.setValue("helpFont", "fonts/dejavusansmono.ttf");
config.setValue("secureFont", "fonts/dejavusansmono.ttf");
config.setValue("japanFont", "fonts/mplus-1p-regular.ttf");
+ config.setValue("chinaFont", "fonts/wqy-microhei.ttf");
config.setValue("showBackground", false);
config.setValue("enableMumble", false);
config.setValue("enableMapReduce", false);
@@ -2438,6 +2441,7 @@ void Client::storeSafeParameters() const
config.setValue("helpFont", helpFont);
config.setValue("secureFont", secureFont);
config.setValue("japanFont", japanFont);
+ config.setValue("chinaFont", chinaFont);
config.setValue("showBackground", showBackground);
config.setValue("enableMumble", enableMumble);
config.setValue("enableMapReduce", enableMapReduce);
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 8aa64fcec..ab28532fe 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -188,6 +188,7 @@ DefaultsData* getConfigDefaults()
AddDEF("helpFont", "fonts/dejavusansmono.ttf");
AddDEF("secureFont", "fonts/dejavusansmono.ttf");
AddDEF("japanFont", "fonts/mplus-1p-regular.ttf");
+ AddDEF("chinaFont", "fonts/wqy-microhei.ttf");
AddDEF("npcFont", "fonts/dejavusans.ttf");
AddDEF("showBackground", true);
AddDEF("enableTradeTab", true);
@@ -430,6 +431,7 @@ DefaultsData* getBrandingDefaults()
AddDEF("secureFont", "fonts/dejavusansmono.ttf");
AddDEF("npcFont", "fonts/dejavusans.ttf");
AddDEF("japanFont", "fonts/mplus-1p-regular.ttf");
+ AddDEF("chinaFont", "fonts/wqy-microhei.ttf");
AddDEF("guiPath", "graphics/gui/");
AddDEF("guiThemePath", "themes/");
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;