summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-08-16 19:04:43 +0300
committerAndrei Karas <akaras@inbox.ru>2011-08-16 19:04:43 +0300
commit92311f100efe888df9f8101d22ba9f2d7b483074 (patch)
treef59dcc185fd6e952b52607c164575a4c37052865 /src
parentb1f8a2eaab592b59b5946bdbe38f0d8f775cc434 (diff)
downloadmanaverse-92311f100efe888df9f8101d22ba9f2d7b483074.tar.gz
manaverse-92311f100efe888df9f8101d22ba9f2d7b483074.tar.bz2
manaverse-92311f100efe888df9f8101d22ba9f2d7b483074.tar.xz
manaverse-92311f100efe888df9f8101d22ba9f2d7b483074.zip
Enable japanese language in gettext.
Add ability to use japanese font if current locale is japan locale.
Diffstat (limited to 'src')
-rw-r--r--src/client.cpp4
-rw-r--r--src/defaults.cpp2
-rw-r--r--src/gui/gui.cpp13
-rw-r--r--src/gui/setup_theme.cpp47
-rw-r--r--src/gui/setup_theme.h4
5 files changed, 54 insertions, 16 deletions
diff --git a/src/client.cpp b/src/client.cpp
index cc3c384f7..0e871ed91 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -1802,6 +1802,7 @@ void Client::storeSafeParameters()
std::string particleFont;
std::string helpFont;
std::string secureFont;
+ std::string japanFont;
bool showBackground;
bool enableMumble;
bool enableMapReduce;
@@ -1829,6 +1830,7 @@ void Client::storeSafeParameters()
particleFont = config.getStringValue("particleFont");
helpFont = config.getStringValue("helpFont");
secureFont = config.getStringValue("secureFont");
+ japanFont = config.getStringValue("japanFont");
showBackground = config.getBoolValue("showBackground");
enableMumble = config.getBoolValue("enableMumble");
@@ -1847,6 +1849,7 @@ void Client::storeSafeParameters()
config.setValue("particleFont", "fonts/dejavusans.ttf");
config.setValue("helpFont", "fonts/dejavusansmono.ttf");
config.setValue("secureFont", "fonts/dejavusansmono.ttf");
+ config.setValue("japanFont", "fonts/mplus-1p-regular.ttf");
config.setValue("showBackground", false);
config.setValue("enableMumble", false);
config.setValue("enableMapReduce", false);
@@ -1872,6 +1875,7 @@ void Client::storeSafeParameters()
config.setValue("particleFont", particleFont);
config.setValue("helpFont", helpFont);
config.setValue("secureFont", secureFont);
+ config.setValue("japanFont", japanFont);
config.setValue("showBackground", showBackground);
config.setValue("enableMumble", enableMumble);
config.setValue("enableMapReduce", enableMapReduce);
diff --git a/src/defaults.cpp b/src/defaults.cpp
index e614a489b..e1cb08299 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -159,6 +159,7 @@ DefaultsData* getConfigDefaults()
AddDEF(configData, "particleFont", "fonts/dejavusans.ttf");
AddDEF(configData, "helpFont", "fonts/dejavusansmono.ttf");
AddDEF(configData, "secureFont", "fonts/dejavusansmono.ttf");
+ AddDEF(configData, "japanFont", "fonts/mplus-1p-regular.ttf");
AddDEF(configData, "showBackground", true);
AddDEF(configData, "enableTradeTab", true);
AddDEF(configData, "logToChat", false);
@@ -242,6 +243,7 @@ DefaultsData* getBrandingDefaults()
AddDEF(brandingData, "particleFont", "fonts/dejavusans.ttf");
AddDEF(brandingData, "helpFont", "fonts/dejavusansmono.ttf");
AddDEF(brandingData, "secureFont", "fonts/dejavusansmono.ttf");
+ AddDEF(brandingData, "japanFont", "fonts/mplus-1p-regular.ttf");
AddDEF(brandingData, "guiPath", "graphics/gui/");
AddDEF(brandingData, "guiThemePath", "themes/");
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 3e4ec764f..7d38b1025 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -107,9 +107,18 @@ Gui::Gui(Graphics *graphics):
// Set global font
const int fontSize = config.getIntValue("fontSize");
+
std::string fontFile = config.getValue("font", "");
-// may be here need get paths from paths.getValue?
-// std::string path = resman->getPath(fontFile);
+
+ std::vector<std::string> langs = getLang();
+ if (!langs.empty() && langs[0].size() > 3
+ && langs[0].substr(0, 3) == "ja_")
+ {
+ fontFile = config.getValue("japanFont", "");
+ if (fontFile.empty())
+ fontFile = branding.getStringValue("japanFont");
+ }
+
if (fontFile.empty())
fontFile = branding.getStringValue("font");
diff --git a/src/gui/setup_theme.cpp b/src/gui/setup_theme.cpp
index 7a2c66595..05f8c7315 100644
--- a/src/gui/setup_theme.cpp
+++ b/src/gui/setup_theme.cpp
@@ -51,6 +51,7 @@ 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";
class NamesModel : public gcn::ListModel
{
@@ -136,6 +137,7 @@ Setup_Theme::Setup_Theme():
mParticleFont(config.getStringValue("particleFont")),
mHelpFont(config.getStringValue("helpFont")),
mSecureFont(config.getStringValue("secureFont")),
+ mJapanFont(config.getStringValue("japanFont")),
mFontSize(config.getIntValue("fontSize"))
{
setName(_("Theme"));
@@ -146,6 +148,7 @@ Setup_Theme::Setup_Theme():
mParticleFontLabel = new Label(_("Particle font"));
mHelpFontLabel = new Label(_("Help font"));
mSecureFontLabel = new Label(_("Secure font"));
+ mJapanFontLabel = new Label(_("Japanese font"));
mThemesModel = new ThemesModel();
mFontsModel = new FontsModel();
@@ -173,6 +176,10 @@ Setup_Theme::Setup_Theme():
mSecureFontDropDown->setActionEventId(ACTION_SECURE_FONT);
mSecureFontDropDown->addActionListener(this);
+ mJapanFontDropDown = new DropDown(mFontsModel);
+ mJapanFontDropDown->setActionEventId(ACTION_JAPAN_FONT);
+ mJapanFontDropDown->addActionListener(this);
+
fontSizeLabel = new Label(_("Font size"));
mFontSizeListModel = new FontSizeChoiceListModel;
mFontSizeDropDown = new DropDown(mFontSizeListModel);
@@ -195,25 +202,30 @@ Setup_Theme::Setup_Theme():
config.getStringValue("helpFont")));
mSecureFontDropDown->setSelectedString(getFileName(
config.getStringValue("secureFont")));
+ mJapanFontDropDown->setSelectedString(getFileName(
+ config.getStringValue("japanFont")));
// Do the layout
LayoutHelper h(this);
ContainerPlacer place = h.getPlacer(0, 0);
- place(0, 0, mThemeLabel, 10);
- place(0, 1, mThemeDropDown, 6);
- place(0, 2, fontSizeLabel, 10);
- place(0, 3, mFontSizeDropDown, 6);
- place(0, 4, mFontLabel, 10);
- place(0, 5, mFontDropDown, 6);
- place(0, 6, mBoldFontLabel, 10);
- place(0, 7, mBoldFontDropDown, 6);
- place(0, 8, mParticleFontLabel, 10);
- place(0, 9, mParticleFontDropDown, 6);
- place(0, 10, mHelpFontLabel, 10);
- place(0, 11, mHelpFontDropDown, 6);
- place(0, 12, mSecureFontLabel, 10);
- place(0, 13, mSecureFontDropDown, 6);
+ place(0, 0, mThemeLabel, 5);
+ place(0, 1, fontSizeLabel, 5);
+ place(0, 2, mFontLabel, 5);
+ place(0, 3, mBoldFontLabel, 5);
+ place(0, 4, mParticleFontLabel, 5);
+ place(0, 5, mHelpFontLabel, 5);
+ place(0, 6, mSecureFontLabel, 5);
+ place(0, 7, mJapanFontLabel, 5);
+
+ place(6, 0, mThemeDropDown, 10);
+ place(6, 1, mFontSizeDropDown, 10);
+ place(6, 2, mFontDropDown, 10);
+ place(6, 3, mBoldFontDropDown, 10);
+ place(6, 4, mParticleFontDropDown, 10);
+ place(6, 5, mHelpFontDropDown, 10);
+ place(6, 6, mSecureFontDropDown, 10);
+ place(6, 7, mJapanFontDropDown, 10);
place.getCell().matchColWidth(0, 0);
place = h.getPlacer(0, 1);
@@ -262,6 +274,10 @@ void Setup_Theme::action(const gcn::ActionEvent &event)
{
mSecureFont = mSecureFontDropDown->getSelectedString();
}
+ else if (event.getId() == ACTION_JAPAN_FONT)
+ {
+ mJapanFont = mJapanFontDropDown->getSelectedString();
+ }
}
void Setup_Theme::cancel()
@@ -272,6 +288,7 @@ void Setup_Theme::cancel()
mParticleFont = getFileName(config.getStringValue("particleFont"));
mHelpFont = getFileName(config.getStringValue("helpFont"));
mSecureFont = getFileName(config.getStringValue("secureFont"));
+ mJapanFont = getFileName(config.getStringValue("japanFont"));
}
void Setup_Theme::apply()
@@ -290,6 +307,7 @@ void Setup_Theme::apply()
|| config.getValue("particleFont", "dejavusans.ttf") != mParticleFont
|| config.getValue("helpFont", "dejavusansmono.ttf") != mHelpFont
|| config.getValue("secureFont", "dejavusansmono.ttf") != mSecureFont
+ || config.getValue("japanFont", "mplus-1p-regular.ttf") != mJapanFont
|| config.getIntValue("fontSize")
!= static_cast<int>(mFontSizeDropDown->getSelected()) + 10)
{
@@ -298,6 +316,7 @@ void Setup_Theme::apply()
config.setValue("particleFont", "fonts/" + getFileName(mParticleFont));
config.setValue("helpFont", "fonts/" + getFileName(mHelpFont));
config.setValue("secureFont", "fonts/" + getFileName(mSecureFont));
+ config.setValue("japanFont", "fonts/" + getFileName(mJapanFont));
config.setValue("fontSize", mFontSizeDropDown->getSelected() + 10);
gui->updateFonts();
}
diff --git a/src/gui/setup_theme.h b/src/gui/setup_theme.h
index 1952a88c6..c803cc296 100644
--- a/src/gui/setup_theme.h
+++ b/src/gui/setup_theme.h
@@ -74,6 +74,10 @@ class Setup_Theme : public SetupTab
DropDown *mSecureFontDropDown;
std::string mSecureFont;
+ gcn::Label *mJapanFontLabel;
+ DropDown *mJapanFontDropDown;
+ std::string mJapanFont;
+
FontSizeChoiceListModel *mFontSizeListModel;
gcn::Label *fontSizeLabel;
int mFontSize;