summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2007-06-04 16:07:22 +0000
committerglx <glx@openttd.org>2007-06-04 16:07:22 +0000
commitcb340626cafacd29c41580141fb00d137891b6a5 (patch)
treed201cb22a10fec046b45e4b47074038bb3b7b91a /src/network
parentf61029d47ee4f95282b09ab8c187f446ed819ffc (diff)
downloadopenttd-cb340626cafacd29c41580141fb00d137891b6a5.tar.xz
(svn r10032) -Add: sort the strings in server language dropdown
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network.h36
-rw-r--r--src/network/network_gui.cpp57
2 files changed, 52 insertions, 41 deletions
diff --git a/src/network/network.h b/src/network/network.h
index da8b52c01..df2dbbfca 100644
--- a/src/network/network.h
+++ b/src/network/network.h
@@ -76,12 +76,38 @@ enum NetworkJoinStatus {
NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO,
};
-// language ids for server_lang and client_lang
+/* Language ids for server_lang and client_lang. Do NOT modify the order. */
enum NetworkLanguage {
- NETLANG_ANY = 0,
- NETLANG_ENGLISH = 1,
- NETLANG_GERMAN = 2,
- NETLANG_FRENCH = 3,
+ NETLANG_ANY = 0,
+ NETLANG_ENGLISH,
+ NETLANG_GERMAN,
+ NETLANG_FRENCH,
+ NETLANG_BRAZILIAN,
+ NETLANG_BULGARIAN,
+ NETLANG_CHINESE,
+ NETLANG_CZECH,
+ NETLANG_DANISH,
+ NETLANG_DUTCH,
+ NETLANG_ESPERANTO,
+ NETLANG_FINNISH,
+ NETLANG_HUNGARIAN,
+ NETLANG_ICELANDIC,
+ NETLANG_ITALIAN,
+ NETLANG_JAPANESE,
+ NETLANG_KOREAN,
+ NETLANG_LITHUANIAN,
+ NETLANG_NORWEGIAN,
+ NETLANG_POLISH,
+ NETLANG_PORTUGUESE,
+ NETLANG_ROMANIAN,
+ NETLANG_RUSSIAN,
+ NETLANG_SLOVAK,
+ NETLANG_SLOVENIAN,
+ NETLANG_SPANISH,
+ NETLANG_SWEDISH,
+ NETLANG_TURKISH,
+ NETLANG_UKRAINIAN,
+ NETLANG_LAST
};
VARDEF NetworkGameInfo _network_game_info;
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 80ef20b86..2bc3cc27e 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -84,20 +84,20 @@ static const StringID _players_dropdown[] = {
STR_NETWORK_10_PLAYERS,
INVALID_STRING_ID
};
-/* The strings are in alphabetical order (in English). */
-static const StringID _language_dropdown[] = {
+
+static StringID _language_dropdown[] = {
STR_NETWORK_LANG_ANY,
+ STR_NETWORK_LANG_ENGLISH,
+ STR_NETWORK_LANG_GERMAN,
+ STR_NETWORK_LANG_FRENCH,
STR_NETWORK_LANG_BRAZILIAN,
STR_NETWORK_LANG_BULGARIAN,
STR_NETWORK_LANG_CHINESE,
STR_NETWORK_LANG_CZECH,
STR_NETWORK_LANG_DANISH,
STR_NETWORK_LANG_DUTCH,
- STR_NETWORK_LANG_ENGLISH,
STR_NETWORK_LANG_ESPERANTO,
STR_NETWORK_LANG_FINNISH,
- STR_NETWORK_LANG_FRENCH,
- STR_NETWORK_LANG_GERMAN,
STR_NETWORK_LANG_HUNGARIAN,
STR_NETWORK_LANG_ICELANDIC,
STR_NETWORK_LANG_ITALIAN,
@@ -119,37 +119,22 @@ static const StringID _language_dropdown[] = {
};
/* Used to map the _server_lang value to the sorted string. */
-static const int _server_lang_to_string[] = {
- 0, // Any
- 7, // English
- 11, // German
- 10, // French
- 1, // Brazilian
- 2, // Bulgarian
- 3, // Chinese
- 4, // Czech
- 5, // Danish
- 6, // Dutch
- 8, // Esperanto
- 9, // Finnish
- 12, // Hungarian
- 13, // Icelandic
- 14, // Italian
- 15, // Japanese
- 16, // Korean
- 17, // Lithuanian
- 18, // Norwegian
- 19, // Polish
- 20, // Portuguese
- 21, // Romanian
- 22, // Russian
- 23, // Slovak
- 24, // Slovenian
- 25, // Spanish
- 26, // Swedish
- 27, // Turkish
- 28, // Ukrainian
-};
+static int _server_lang_to_string[NETLANG_LAST] = {0};
+
+void SortNetworkLanguages() {
+ /* Sort the strings (we don't move 'any' and the 'invalid' one) */
+ qsort(&_language_dropdown[1], NETLANG_LAST - 1, sizeof(StringID), &StringIDSorter);
+
+ /* Update the lookup table */
+ for (int i = NETLANG_ANY; i < NETLANG_LAST; i++) {
+ for (int j = NETLANG_ANY; j < NETLANG_LAST; j++) {
+ if (_language_dropdown[j] - STR_NETWORK_LANG_ANY == i) {
+ _server_lang_to_string[i] = j;
+ break;
+ }
+ }
+ }
+}
enum {
NET_PRC__OFFSET_TOP_WIDGET = 54,