summaryrefslogtreecommitdiff
path: root/src/settings_gui.cpp
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2008-01-17 00:21:43 +0000
committerglx <glx@openttd.org>2008-01-17 00:21:43 +0000
commit2ad9edda9165eff2d9f5b46e6d801ff32eed73eb (patch)
treec3a0444854aceb9850f7aaf640a626b7df68b815 /src/settings_gui.cpp
parent20c2de3ace9f53ab96077a49953311fba5a0f1c4 (diff)
downloadopenttd-2ad9edda9165eff2d9f5b46e6d801ff32eed73eb.tar.xz
(svn r11886) -Add: sort the strings in languages dropdown
Diffstat (limited to 'src/settings_gui.cpp')
-rw-r--r--src/settings_gui.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 821fa7f48..c007a6d37 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -24,6 +24,7 @@
#include "core/alloc_func.hpp"
#include "string_func.h"
#include "gfx_func.h"
+#include "widgets/dropdown_type.h"
#include "widgets/dropdown_func.h"
#include "table/sprites.h"
@@ -157,6 +158,26 @@ enum GameOptionsWidgets {
GAMEOPT_SCREENSHOT_BTN,
};
+/**
+ * Update/redraw the languages dropdown
+ * @param w the window the dropdown belongs to
+ */
+static void ShowLangDropdown(Window *w)
+{
+ typedef std::map<StringID, int, StringIDCompare> LangList;
+
+ /* Sort language names */
+ LangList langs;
+ for (int i = 0; i < _dynlang.num; i++) langs[SPECSTR_LANGUAGE_START + i] = i;
+
+ DropDownList *list = new DropDownList();
+ for (LangList::iterator it = langs.begin(); it != langs.end(); it++) {
+ list->push_back(new DropDownListStringItem((*it).first, (*it).second, false));
+ }
+
+ ShowDropDownList(w, list, _dynlang.curr, GAMEOPT_LANG_BTN);
+}
+
static void ShowCustCurrency();
static void GameOptionsWndProc(Window *w, WindowEvent *e)
@@ -228,7 +249,7 @@ static void GameOptionsWndProc(Window *w, WindowEvent *e)
break; // not implemented
case GAMEOPT_LANG_TXT: case GAMEOPT_LANG_BTN: /* Setup interface language dropdown */
- ShowDropDownMenu(w, _dynlang.dropdown, _dynlang.curr, GAMEOPT_LANG_BTN, 0, 0);
+ ShowLangDropdown(w);
break;
case GAMEOPT_RESOLUTION_TXT: case GAMEOPT_RESOLUTION_BTN: /* Setup resolution dropdown */