diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-12-29 00:16:54 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-12-29 00:16:54 +0300 |
commit | 0cd049b5b56b34b0b7ab3e3eac93dcb255c4e118 (patch) | |
tree | 5dedc441dcf535f8ac4b43f8b8ea0bb27c8ba6ac | |
parent | 7c51eee345d27e680a26a915ffccb2d0abf063ea (diff) | |
download | manaplus-0cd049b5b56b34b0b7ab3e3eac93dcb255c4e118.tar.gz manaplus-0cd049b5b56b34b0b7ab3e3eac93dcb255c4e118.tar.bz2 manaplus-0cd049b5b56b34b0b7ab3e3eac93dcb255c4e118.tar.xz manaplus-0cd049b5b56b34b0b7ab3e3eac93dcb255c4e118.zip |
Show flags icons in language selection list
Also add support for extended listboxes in popuplist control.
29 files changed, 117 insertions, 32 deletions
diff --git a/configure.ac b/configure.ac index 4281f4f2e..2433d27cc 100755 --- a/configure.ac +++ b/configure.ac @@ -310,6 +310,7 @@ data/Makefile data/evol/Makefile data/fonts/Makefile data/graphics/Makefile +data/graphics/flags/Makefile data/graphics/gui/Makefile data/graphics/images/Makefile data/graphics/sprites/Makefile diff --git a/data/graphics/CMakeLists.txt b/data/graphics/CMakeLists.txt index 5a9b0f65b..2713d7899 100644 --- a/data/graphics/CMakeLists.txt +++ b/data/graphics/CMakeLists.txt @@ -1,3 +1,4 @@ +ADD_SUBDIRECTORY(flags) ADD_SUBDIRECTORY(gui) ADD_SUBDIRECTORY(images) ADD_SUBDIRECTORY(sprites) diff --git a/data/graphics/Makefile.am b/data/graphics/Makefile.am index c0e91d050..c566673ec 100644 --- a/data/graphics/Makefile.am +++ b/data/graphics/Makefile.am @@ -4,4 +4,4 @@ graphicsdir = $(pkgdatadir)/data/graphics EXTRA_DIST = \ CMakeLists.txt -SUBDIRS = gui images sprites +SUBDIRS = flags gui images sprites diff --git a/data/graphics/flags/CMakeLists.txt b/data/graphics/flags/CMakeLists.txt new file mode 100644 index 000000000..02a07eaba --- /dev/null +++ b/data/graphics/flags/CMakeLists.txt @@ -0,0 +1,19 @@ +SET(FILES + cn.png + cz.png + de.png + en.png + es.png + fi.png + fr.png + id.png + it.png + jp.png + pl.png + pt_BR.png + pt.png + ru.png + vls.png + ) + +INSTALL(FILES ${FILES} DESTINATION ${DATA_DIR}/graphics/flags) diff --git a/data/graphics/flags/Makefile.am b/data/graphics/flags/Makefile.am new file mode 100644 index 000000000..4396903f6 --- /dev/null +++ b/data/graphics/flags/Makefile.am @@ -0,0 +1,22 @@ +flagsdir = $(pkgdatadir)/data/graphics/flags + +flags_DATA = \ + cn.png \ + cz.png \ + de.png \ + en.png \ + es.png \ + fi.png \ + fr.png \ + id.png \ + it.png \ + jp.png \ + pl.png \ + pt_BR.png \ + pt.png \ + ru.png \ + vls.png + +EXTRA_DIST = \ + $(flags_DATA) \ + CMakeLists.txt diff --git a/data/graphics/flags/cn.png b/data/graphics/flags/cn.png Binary files differnew file mode 100644 index 000000000..dfe68b743 --- /dev/null +++ b/data/graphics/flags/cn.png diff --git a/data/graphics/flags/cz.png b/data/graphics/flags/cz.png Binary files differnew file mode 100644 index 000000000..d6ceb5b2b --- /dev/null +++ b/data/graphics/flags/cz.png diff --git a/data/graphics/flags/de.png b/data/graphics/flags/de.png Binary files differnew file mode 100644 index 000000000..b162c174a --- /dev/null +++ b/data/graphics/flags/de.png diff --git a/data/graphics/flags/en.png b/data/graphics/flags/en.png Binary files differnew file mode 100644 index 000000000..bbc1d224d --- /dev/null +++ b/data/graphics/flags/en.png diff --git a/data/graphics/flags/es.png b/data/graphics/flags/es.png Binary files differnew file mode 100644 index 000000000..f9b3221ae --- /dev/null +++ b/data/graphics/flags/es.png diff --git a/data/graphics/flags/fi.png b/data/graphics/flags/fi.png Binary files differnew file mode 100644 index 000000000..0d8029469 --- /dev/null +++ b/data/graphics/flags/fi.png diff --git a/data/graphics/flags/fr.png b/data/graphics/flags/fr.png Binary files differnew file mode 100644 index 000000000..086ca9f2f --- /dev/null +++ b/data/graphics/flags/fr.png diff --git a/data/graphics/flags/id.png b/data/graphics/flags/id.png Binary files differnew file mode 100644 index 000000000..ca18a70a7 --- /dev/null +++ b/data/graphics/flags/id.png diff --git a/data/graphics/flags/it.png b/data/graphics/flags/it.png Binary files differnew file mode 100644 index 000000000..5b1bc0ef7 --- /dev/null +++ b/data/graphics/flags/it.png diff --git a/data/graphics/flags/jp.png b/data/graphics/flags/jp.png Binary files differnew file mode 100644 index 000000000..6f295e292 --- /dev/null +++ b/data/graphics/flags/jp.png diff --git a/data/graphics/flags/pl.png b/data/graphics/flags/pl.png Binary files differnew file mode 100644 index 000000000..007d5a0c6 --- /dev/null +++ b/data/graphics/flags/pl.png diff --git a/data/graphics/flags/pt.png b/data/graphics/flags/pt.png Binary files differnew file mode 100644 index 000000000..31411a17a --- /dev/null +++ b/data/graphics/flags/pt.png diff --git a/data/graphics/flags/pt_BR.png b/data/graphics/flags/pt_BR.png Binary files differnew file mode 100644 index 000000000..0c0d050fa --- /dev/null +++ b/data/graphics/flags/pt_BR.png diff --git a/data/graphics/flags/ru.png b/data/graphics/flags/ru.png Binary files differnew file mode 100644 index 000000000..92b8d13ce --- /dev/null +++ b/data/graphics/flags/ru.png diff --git a/data/graphics/flags/vls.png b/data/graphics/flags/vls.png Binary files differnew file mode 100644 index 000000000..0625b14d0 --- /dev/null +++ b/data/graphics/flags/vls.png diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index d875644f6..3bf526b40 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -108,7 +108,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory): mSlotsBar(new ProgressBar(this, 0.0f, 100, 0, Theme::PROG_INVY_SLOTS)), mFilter(nullptr), mSortModel(new SortListModel), - mSortDropDown(new DropDown(this, mSortModel, this, "sort")), + mSortDropDown(new DropDown(this, mSortModel, false, this, "sort")), mNameFilter(new TextField(this, "", true, this, "namefilter", true)), mSortDropDownCell(nullptr), mNameFilterCell(nullptr), diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp index 41016b05c..26093634e 100644 --- a/src/gui/logindialog.cpp +++ b/src/gui/logindialog.cpp @@ -163,7 +163,7 @@ LoginDialog::LoginDialog(LoginData *const data, std::string serverName, mLoginData->updateHost.c_str())); mUpdateListModel = new UpdateListModel(mLoginData); mUpdateHostDropDown = new DropDown(this, mUpdateListModel, - this, "updateselect"); + false, this, "updateselect"); const std::string str = serverConfig.getValue("updateHost2", ""); if (!str.empty()) mUpdateHostDropDown->setSelectedString(str); diff --git a/src/gui/setup_theme.cpp b/src/gui/setup_theme.cpp index 277ddadae..2a8836bcb 100644 --- a/src/gui/setup_theme.cpp +++ b/src/gui/setup_theme.cpp @@ -29,6 +29,7 @@ #include "gui/widgets/button.h" #include "gui/widgets/checkbox.h" #include "gui/widgets/dropdown.h" +#include "gui/widgets/extendedlistmodel.h" #include "gui/widgets/label.h" #include "gui/widgets/layouthelper.h" #include "gui/widgets/namesmodel.h" @@ -116,46 +117,73 @@ struct Language final { std::string name; std::string value; + std::string icon; }; const int langs_count = 16; 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_("Italian"), "it_IT"}, - {N_("Polish"), "pl_PL"}, - {N_("Japanese"), "ja_JP.utf8"}, - {N_("Dutch (Belgium/Flemish)"), "nl_BE"}, - {N_("Portuguese"), "pt_PT"}, - {N_("Portuguese (Brazilian)"), "pt_BR"}, - {N_("Russian"), "ru_RU"}, - {N_("Spanish (Castilian)"), "es_ES"} + {N_("(default)"), "", ""}, + {N_("Chinese (China)"), "zh_CN", "cn.png"}, + {N_("Czech"), "cs_CZ", "cz.png"}, + {N_("English"), "C", "en.png"}, + {N_("Finnish"), "fi_FI", "fi.png"}, + {N_("French"), "fr_FR", "fr.png"}, + {N_("German"), "de_DE", "de.png"}, + {N_("Indonesian"), "id_ID", "id.png"}, + {N_("Italian"), "it_IT", "it.png"}, + {N_("Polish"), "pl_PL", "pl.png"}, + {N_("Japanese"), "ja_JP", "jp.png"}, + {N_("Dutch (Belgium/Flemish)"), "nl_BE", ""}, + {N_("Portuguese"), "pt_PT", "pt.png"}, + {N_("Portuguese (Brazilian)"), "pt_BR", "pt_BR.png"}, + {N_("Russian"), "ru_RU", "ru.png"}, + {N_("Spanish (Castilian)"), "es_ES", "es.png"} }; -class LangListModel final : public gcn::ListModel +class LangListModel final : public ExtendedListModel { public: + LangListModel() + { + ResourceManager *const resman = ResourceManager::getInstance(); + for (int f = 0; f < langs_count; f ++) + { + mIcons[f] = resman->getImage("graphics/flags/" + + LANG_NAME[f].icon); + } + } + virtual ~LangListModel() - { } + { + for (int f = 0; f < langs_count; f ++) + { + Image *const img = mIcons[f]; + if (img) + img->decRef(); + } + } - virtual int getNumberOfElements() override + int getNumberOfElements() override A_WARN_UNUSED { return langs_count; } - virtual std::string getElementAt(int i) override + std::string getElementAt(int i) override A_WARN_UNUSED { if (i >= getNumberOfElements() || i < 0) return _("???"); return gettext(LANG_NAME[i].name.c_str()); } + + const Image *getImageAt(int i) override A_WARN_UNUSED + { + if (i >= getNumberOfElements() || i < 0) + return nullptr; + return mIcons[i]; + } + + Image *mIcons[langs_count]; }; Setup_Theme::Setup_Theme(const Widget2 *const widget) : @@ -170,7 +198,7 @@ Setup_Theme::Setup_Theme(const Widget2 *const widget) : mFont(config.getStringValue("font")), mLangListModel(new LangListModel), mLangLabel(new Label(this, _("Language"))), - mLangDropDown(new DropDown(this, mLangListModel)), + mLangDropDown(new DropDown(this, mLangListModel, true)), mLang(config.getStringValue("lang")), mBoldFontLabel(new Label(this, _("Bold font"))), mBoldFontDropDown(new DropDown(this, mFontsModel)), diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 384371107..dad85a0af 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -58,6 +58,7 @@ static std::string const dropdownFiles[2] = DropDown::DropDown(const Widget2 *const widget, gcn::ListModel *const listModel, + bool extended, gcn::ActionListener *const listener, const std::string &eventId): gcn::ActionListener(), @@ -67,7 +68,7 @@ DropDown::DropDown(const Widget2 *const widget, gcn::FocusListener(), gcn::SelectionListener(), Widget2(widget), - mPopup(new PopupList(this, listModel)), + mPopup(new PopupList(this, listModel, extended)), mShadowColor(getThemeColor(Theme::DROPDOWN_SHADOW)), mHighlightColor(getThemeColor(Theme::HIGHLIGHT)), mPadding(1), diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index 6b3b6503a..1707857cb 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -72,6 +72,7 @@ class DropDown final : public gcn::ActionListener, */ DropDown(const Widget2 *const widget, gcn::ListModel *const listModel = nullptr, + bool extended = false, gcn::ActionListener *const listener = nullptr, const std::string &eventId = ""); diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index b932f91b0..8c850775a 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -37,12 +37,21 @@ #include "debug.h" ExtendedListBox::ExtendedListBox(const Widget2 *const widget, - gcn::ListModel *const listModel) : + gcn::ListModel *const listModel, + int rowHeight) : ListBox(widget, listModel), - mRowHeight(13), + mRowHeight(rowHeight), mImagePadding(mSkin ? mSkin->getOption("imagePadding") : 0), mSpacing(mSkin ? mSkin->getOption("spacing") : 0) { + if (!mRowHeight) + { + const gcn::Font *font = getFont(); + if (font) + mRowHeight = font->getHeight() + 2 * mPadding; + else + mRowHeight = 13; + } } ExtendedListBox::~ExtendedListBox() diff --git a/src/gui/widgets/extendedlistbox.h b/src/gui/widgets/extendedlistbox.h index 32fd274aa..79ae868cf 100644 --- a/src/gui/widgets/extendedlistbox.h +++ b/src/gui/widgets/extendedlistbox.h @@ -30,7 +30,8 @@ class ExtendedListBox final : public ListBox * Constructor. */ ExtendedListBox(const Widget2 *const widget, - gcn::ListModel *const listModel); + gcn::ListModel *const listModel, + int rowHeight = 13); A_DELETE_COPY(ExtendedListBox) diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp index 260dcb6a9..80fd12e85 100644 --- a/src/gui/widgets/popuplist.cpp +++ b/src/gui/widgets/popuplist.cpp @@ -23,7 +23,7 @@ #include "gui/gui.h" #include "gui/widgets/dropdown.h" -#include "gui/widgets/listbox.h" +#include "gui/widgets/extendedlistbox.h" #include "gui/widgets/scrollarea.h" #include "utils/gettext.h" @@ -31,11 +31,13 @@ #include "debug.h" PopupList::PopupList(DropDown *const widget, - gcn::ListModel *const listModel): + gcn::ListModel *const listModel, + bool extended): Popup("PopupList", "popuplist.xml"), gcn::FocusListener(), mListModel(listModel), - mListBox(new ListBox(widget, listModel)), + mListBox(extended ? new ExtendedListBox(widget, listModel, 0) : + new ListBox(widget, listModel)), mScrollArea(new ScrollArea(mListBox, false)), mDropDown(widget) { diff --git a/src/gui/widgets/popuplist.h b/src/gui/widgets/popuplist.h index e609b52f6..3ba3773fe 100644 --- a/src/gui/widgets/popuplist.h +++ b/src/gui/widgets/popuplist.h @@ -39,7 +39,7 @@ class PopupList final : public Popup, { public: PopupList(DropDown *const widget, - gcn::ListModel *const listModel); + gcn::ListModel *const listModel, bool extended); ~PopupList(); |