summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/crashlog.cpp3
-rw-r--r--src/language.h3
-rw-r--r--src/settings_gui.cpp11
-rw-r--r--src/strings.cpp12
-rw-r--r--src/strings_type.h1
5 files changed, 20 insertions, 10 deletions
diff --git a/src/crashlog.cpp b/src/crashlog.cpp
index 5d0cc4427..e47a65ed7 100644
--- a/src/crashlog.cpp
+++ b/src/crashlog.cpp
@@ -25,6 +25,7 @@
#include "screenshot.h"
#include "gfx_func.h"
#include "network/network.h"
+#include "language.h"
#include "ai/ai_info.hpp"
#include "company_base.h"
@@ -120,7 +121,7 @@ char *CrashLog::LogConfiguration(char *buffer, const char *last) const
BlitterFactoryBase::GetCurrentBlitter() == NULL ? "none" : BlitterFactoryBase::GetCurrentBlitter()->GetName(),
BaseGraphics::GetUsedSet() == NULL ? "none" : BaseGraphics::GetUsedSet()->name,
BaseGraphics::GetUsedSet() == NULL ? UINT32_MAX : BaseGraphics::GetUsedSet()->version,
- StrEmpty(_dynlang.curr_file) ? "none" : _dynlang.curr_file,
+ _current_language == NULL ? "none" : _current_language->file,
_music_driver == NULL ? "none" : _music_driver->GetName(),
BaseMusic::GetUsedSet() == NULL ? "none" : BaseMusic::GetUsedSet()->name,
BaseMusic::GetUsedSet() == NULL ? UINT32_MAX : BaseMusic::GetUsedSet()->version,
diff --git a/src/language.h b/src/language.h
index 0456c3a43..884ac4540 100644
--- a/src/language.h
+++ b/src/language.h
@@ -56,4 +56,7 @@ struct LanguageMetadata : public LanguagePackHeader {
char file[MAX_PATH]; ///< Name of the file we read this data from.
};
+/** The currently loaded language. */
+extern const LanguageMetadata *_current_language;
+
#endif /* LANGUAGE_H */
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 14476b5dd..871a3b8ea 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -32,6 +32,7 @@
#include "viewport_func.h"
#include "core/geometry_func.hpp"
#include "ai/ai.hpp"
+#include "language.h"
#include <map>
#include "table/sprites.h"
@@ -190,7 +191,7 @@ struct GameOptionsWindow : Window {
case GOW_ROADSIDE_DROPDOWN: SetDParam(0, STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_LEFT + this->opt->vehicle.road_side); break;
case GOW_TOWNNAME_DROPDOWN: SetDParam(0, TownName(this->opt->game_creation.town_name)); break;
case GOW_AUTOSAVE_DROPDOWN: SetDParam(0, _autosave_dropdown[_settings_client.gui.autosave]); break;
- case GOW_LANG_DROPDOWN: SetDParam(0, SPECSTR_LANGUAGE_START + _dynlang.curr); break;
+ case GOW_LANG_DROPDOWN: SetDParamStr(0, _current_language->own_name); break;
case GOW_RESOLUTION_DROPDOWN: SetDParam(0, GetCurRes() == _num_resolutions ? STR_RES_OTHER : SPECSTR_RESOLUTION_START + GetCurRes()); break;
case GOW_SCREENSHOT_DROPDOWN: SetDParam(0, SPECSTR_SCREENSHOT_START + _cur_screenshot_format); break;
case GOW_BASE_GRF_DROPDOWN: SetDParamStr(0, BaseGraphics::GetUsedSet()->name); break;
@@ -315,14 +316,18 @@ struct GameOptionsWindow : Window {
/* Sort language names */
LangList langs;
- for (int i = 0; i < _dynlang.num; i++) langs[SPECSTR_LANGUAGE_START + i] = i;
+ int current_lang;
+ for (int i = 0; i < _dynlang.num; i++) {
+ if (&_dynlang.ent[i] == _current_language) current_lang = 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(this, list, _dynlang.curr, GOW_LANG_DROPDOWN);
+ ShowDropDownList(this, list, current_lang, GOW_LANG_DROPDOWN);
break;
}
diff --git a/src/strings.cpp b/src/strings.cpp
index e9564cfd1..2d9da5211 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -40,6 +40,8 @@
#include "table/strings.h"
#include "table/control_codes.h"
+const LanguageMetadata *_current_language = NULL; ///< The currently loaded language.
+
DynamicLanguages _dynlang; ///< Language information of the program.
TextDirection _current_text_dir; ///< Text direction of the currently selected language
uint64 _decode_parameters[20]; ///< Global array of string parameters. To access, use #SetDParam.
@@ -1277,7 +1279,7 @@ static char *GetSpecialNameString(char *buff, int ind, int64 *argv, const char *
if (IsInsideMM(ind, (SPECSTR_LANGUAGE_START - 0x70E4), (SPECSTR_LANGUAGE_END - 0x70E4) + 1)) {
int i = ind - (SPECSTR_LANGUAGE_START - 0x70E4);
return strecpy(buff,
- i == _dynlang.curr ? _langpack->own_name : _dynlang.ent[i].name, last);
+ &_dynlang.ent[i] == _current_language ? _current_language->own_name : _dynlang.ent[i].name, last);
}
/* resolution size? */
@@ -1382,12 +1384,12 @@ bool ReadLanguagePack(int lang_index)
free(_langpack_offs);
_langpack_offs = langpack_offs;
- const char *c_file = strrchr(_dynlang.ent[lang_index].file, PATHSEPCHAR) + 1;
+ _current_language = &_dynlang.ent[lang_index];
+ _current_text_dir = (TextDirection)_current_language->text_dir;
+ const char *c_file = strrchr(_current_language->file, PATHSEPCHAR) + 1;
strecpy(_dynlang.curr_file, c_file, lastof(_dynlang.curr_file));
+ SetCurrentGrfLangID(_current_language->newgrflangid);
- _dynlang.curr = lang_index;
- _current_text_dir = (TextDirection)lang_pack->text_dir;
- SetCurrentGrfLangID(_langpack->newgrflangid);
InitializeSortedCargoSpecs();
SortIndustryTypes();
BuildIndustriesLegend();
diff --git a/src/strings_type.h b/src/strings_type.h
index be415f162..326be62ec 100644
--- a/src/strings_type.h
+++ b/src/strings_type.h
@@ -31,7 +31,6 @@ enum TextDirection {
/** Used for dynamic language support */
struct DynamicLanguages {
int num; ///< Number of languages
- int curr; ///< Currently selected language index
char curr_file[MAX_PATH]; ///< Currently selected language file name without path (needed for saving the filename of the loaded language).
LanguageMetadata ent[MAX_LANG]; ///< Information about the languages
};