summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-11-04 00:53:30 +0300
committerAndrei Karas <akaras@inbox.ru>2011-11-04 02:28:31 +0300
commit8f251ac16f72e2d56c66748cafce77823ea5a7dd (patch)
treee4196d6a71b284a0a6c0c871cbeb709c89bb3963 /src/gui
parentf21e729bf1ce78449a23ce257f7287e1ead3e4c4 (diff)
downloadmv-8f251ac16f72e2d56c66748cafce77823ea5a7dd.tar.gz
mv-8f251ac16f72e2d56c66748cafce77823ea5a7dd.tar.bz2
mv-8f251ac16f72e2d56c66748cafce77823ea5a7dd.tar.xz
mv-8f251ac16f72e2d56c66748cafce77823ea5a7dd.zip
Add option to settings for select any supported language. (tab Theme)
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/setup_theme.cpp107
-rw-r--r--src/gui/setup_theme.h11
2 files changed, 102 insertions, 16 deletions
diff --git a/src/gui/setup_theme.cpp b/src/gui/setup_theme.cpp
index 05f8c7315..56ce0188a 100644
--- a/src/gui/setup_theme.cpp
+++ b/src/gui/setup_theme.cpp
@@ -47,6 +47,7 @@
const char* ACTION_THEME = "theme";
const char* ACTION_FONT = "font";
+const char* ACTION_LANG = "lang";
const char* ACTION_BOLD_FONT = "bold font";
const char* ACTION_PARTICLE_FONT = "particle font";
const char* ACTION_HELP_FONT = "help font";
@@ -130,9 +131,55 @@ public:
}
};
+struct Language
+{
+ std::string name;
+
+ std::string value;
+};
+
+const int langs_count = 14;
+
+const Language LANG_NAME[langs_count] =
+{
+ {N_("(default)"), ""},
+ {N_("Chinese (China)"), "zh_CN"},
+ {N_("Czech"), "cs_CZ"},
+ {N_("English"), "C"},
+ {N_("Finnish"), "fi_FI"},
+ {N_("French"), "fr_FR"},
+ {N_("German"), "de_DE"},
+ {N_("Indonesian"), "id_ID"},
+ {N_("Japanese"), "ja_JP"},
+ {N_("Dutch (Belgium/Flemish)"), "nl_BE"},
+ {N_("Portuguese"), "pt_PT"},
+ {N_("Portuguese (Brazilian)"), "pt_BR"},
+ {N_("Russian"), "ru_RU"},
+ {N_("Spanish (Castilian)"), "es_ES"},
+};
+
+class LangListModel : public gcn::ListModel
+{
+public:
+ virtual ~LangListModel()
+ { }
+
+ virtual int getNumberOfElements()
+ { return langs_count; }
+
+ virtual std::string getElementAt(int i)
+ {
+ if (i >= getNumberOfElements() || i < 0)
+ return _("???");
+
+ return LANG_NAME[i].name;
+ }
+};
+
Setup_Theme::Setup_Theme():
mTheme(config.getValue("theme", config.getValue("selectedSkin", ""))),
mFont(config.getStringValue("font")),
+ mLang(config.getStringValue("lang")),
mBoldFont(config.getStringValue("boldFont")),
mParticleFont(config.getStringValue("particleFont")),
mHelpFont(config.getStringValue("helpFont")),
@@ -143,6 +190,7 @@ Setup_Theme::Setup_Theme():
setName(_("Theme"));
mThemeLabel = new Label(_("Gui theme"));
+ mLangLabel = new Label(_("Language"));
mFontLabel = new Label(_("Main Font"));
mBoldFontLabel = new Label(_("Bold font"));
mParticleFontLabel = new Label(_("Particle font"));
@@ -151,6 +199,7 @@ Setup_Theme::Setup_Theme():
mJapanFontLabel = new Label(_("Japanese font"));
mThemesModel = new ThemesModel();
mFontsModel = new FontsModel();
+ mLangListModel = new LangListModel();
mThemeDropDown = new DropDown(mThemesModel);
mThemeDropDown->setActionEventId(ACTION_THEME);
@@ -160,6 +209,10 @@ Setup_Theme::Setup_Theme():
mFontDropDown->setActionEventId(ACTION_FONT);
mFontDropDown->addActionListener(this);
+ mLangDropDown = new DropDown(mLangListModel);
+ mLangDropDown->setActionEventId(ACTION_LANG);
+ mLangDropDown->addActionListener(this);
+
mBoldFontDropDown = new DropDown(mFontsModel);
mBoldFontDropDown->setActionEventId(ACTION_BOLD_FONT);
mBoldFontDropDown->addActionListener(this);
@@ -192,6 +245,17 @@ Setup_Theme::Setup_Theme():
else
mThemeDropDown->setSelected(0);
+ const std::string str = config.getStringValue("lang");
+
+ for (int f = 0; f < langs_count; f ++)
+ {
+ if (LANG_NAME[f].value == str)
+ {
+ mLangDropDown->setSelected(f);
+ break;
+ }
+ }
+
mFontDropDown->setSelectedString(getFileName(
config.getStringValue("font")));
mBoldFontDropDown->setSelectedString(getFileName(
@@ -210,22 +274,24 @@ Setup_Theme::Setup_Theme():
ContainerPlacer place = h.getPlacer(0, 0);
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(0, 1, mLangLabel, 5);
+ place(0, 2, fontSizeLabel, 5);
+ place(0, 3, mFontLabel, 5);
+ place(0, 4, mBoldFontLabel, 5);
+ place(0, 5, mParticleFontLabel, 5);
+ place(0, 6, mHelpFontLabel, 5);
+ place(0, 7, mSecureFontLabel, 5);
+ place(0, 8, 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(6, 1, mLangDropDown, 10);
+ place(6, 2, mFontSizeDropDown, 10);
+ place(6, 3, mFontDropDown, 10);
+ place(6, 4, mBoldFontDropDown, 10);
+ place(6, 5, mParticleFontDropDown, 10);
+ place(6, 6, mHelpFontDropDown, 10);
+ place(6, 7, mSecureFontDropDown, 10);
+ place(6, 8, mJapanFontDropDown, 10);
place.getCell().matchColWidth(0, 0);
place = h.getPlacer(0, 1);
@@ -243,6 +309,9 @@ Setup_Theme::~Setup_Theme()
delete mFontSizeListModel;
mFontSizeListModel = 0;
+
+ delete mLangListModel;
+ mLangListModel = 0;
}
void Setup_Theme::action(const gcn::ActionEvent &event)
@@ -258,6 +327,14 @@ void Setup_Theme::action(const gcn::ActionEvent &event)
{
mFont = mFontDropDown->getSelectedString();
}
+ else if (event.getId() == ACTION_LANG)
+ {
+ int id = mLangDropDown->getSelected();
+ if (id < 0 || id >= langs_count)
+ mLang = "";
+ else
+ mLang = LANG_NAME[id].value;
+ }
else if (event.getId() == ACTION_BOLD_FONT)
{
mBoldFont = mBoldFontDropDown->getSelectedString();
@@ -283,6 +360,7 @@ void Setup_Theme::action(const gcn::ActionEvent &event)
void Setup_Theme::cancel()
{
mTheme = config.getValue("theme", config.getValue("selectedSkin", ""));
+ mLang = config.getStringValue("lang");
mFont = getFileName(config.getStringValue("font"));
mBoldFont = getFileName(config.getStringValue("boldFont"));
mParticleFont = getFileName(config.getStringValue("particleFont"));
@@ -302,6 +380,7 @@ void Setup_Theme::apply()
config.setValue("selectedSkin", "");
config.setValue("theme", mTheme);
+ config.setValue("lang", mLang);
if (config.getValue("font", "dejavusans.ttf") != mFont
|| config.getValue("boldFont", "dejavusans-bold.ttf") != mBoldFont
|| config.getValue("particleFont", "dejavusans.ttf") != mParticleFont
diff --git a/src/gui/setup_theme.h b/src/gui/setup_theme.h
index c803cc296..1ff159195 100644
--- a/src/gui/setup_theme.h
+++ b/src/gui/setup_theme.h
@@ -30,10 +30,11 @@
#include <guichan/actionlistener.hpp>
+class DropDown;
+class EditDialog;
class FontsModel;
class FontSizeChoiceListModel;
-class EditDialog;
-class DropDown;
+class LangListModel;
class ThemesModel;
class Setup_Theme : public SetupTab
@@ -58,6 +59,12 @@ class Setup_Theme : public SetupTab
DropDown *mFontDropDown;
std::string mFont;
+ LangListModel *mLangListModel;
+
+ gcn::Label *mLangLabel;
+ DropDown *mLangDropDown;
+ std::string mLang;
+
gcn::Label *mBoldFontLabel;
DropDown *mBoldFontDropDown;
std::string mBoldFont;