summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lang/english.txt1
-rw-r--r--src/settings_gui.cpp45
-rw-r--r--src/strings.cpp16
-rw-r--r--src/strings_type.h7
-rw-r--r--src/widgets/dropdown_type.h1
5 files changed, 35 insertions, 35 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 73fdefd2d..8f29dc526 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -1000,6 +1000,7 @@ STR_GAME_OPTIONS_FULLSCREEN_TOOLTIP :{BLACK}Check th
STR_GAME_OPTIONS_RESOLUTION :{BLACK}Screen resolution
STR_GAME_OPTIONS_RESOLUTION_TOOLTIP :{BLACK}Select the screen resolution to use
STR_GAME_OPTIONS_RESOLUTION_OTHER :other
+STR_GAME_OPTIONS_RESOLUTION_ITEM :{NUM}x{NUM}
STR_GAME_OPTIONS_VIDEO_ACCELERATION :{BLACK}Hardware acceleration
STR_GAME_OPTIONS_VIDEO_ACCELERATION_TOOLTIP :{BLACK}Check this box to allow OpenTTD to try to use hardware acceleration. A changed setting will only be applied upon game restart
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 1d38c4e43..ffa08e798 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -77,14 +77,10 @@ static const void *ResolveVariableAddress(const GameSettings *settings_ptr, cons
* Get index of the current screen resolution.
* @return Index of the current screen resolution if it is a known resolution, _resolutions.size() otherwise.
*/
-static uint GetCurRes()
+static uint GetCurrentResolutionIndex()
{
- uint i;
-
- for (i = 0; i != _resolutions.size(); i++) {
- if (_resolutions[i] == Dimension(_screen.width, _screen.height)) break;
- }
- return i;
+ auto it = std::find(_resolutions.begin(), _resolutions.end(), Dimension(_screen.width, _screen.height));
+ return std::distance(_resolutions.begin(), it);
}
static void ShowCustCurrency();
@@ -219,8 +215,19 @@ struct GameOptionsWindow : Window {
case WID_GO_LANG_DROPDOWN: { // Setup interface language dropdown
for (uint i = 0; i < _languages.size(); i++) {
- if (&_languages[i] == _current_language) *selected_index = i;
- list.emplace_back(new DropDownListStringItem(SPECSTR_LANGUAGE_START + i, i, false));
+ auto item = new DropDownListParamStringItem(STR_JUST_RAW_STRING, i, false);
+ if (&_languages[i] == _current_language) {
+ *selected_index = i;
+ item->SetParamStr(0, _languages[i].own_name);
+ } else {
+ /* Especially with sprite-fonts, not all localized
+ * names can be rendered. So instead, we use the
+ * international names for anything but the current
+ * selected language. This avoids showing a few ????
+ * entries in the dropdown list. */
+ item->SetParamStr(0, _languages[i].name);
+ }
+ list.emplace_back(item);
}
std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
break;
@@ -229,9 +236,12 @@ struct GameOptionsWindow : Window {
case WID_GO_RESOLUTION_DROPDOWN: // Setup resolution dropdown
if (_resolutions.empty()) break;
- *selected_index = GetCurRes();
+ *selected_index = GetCurrentResolutionIndex();
for (uint i = 0; i < _resolutions.size(); i++) {
- list.emplace_back(new DropDownListStringItem(SPECSTR_RESOLUTION_START + i, i, false));
+ auto item = new DropDownListParamStringItem(STR_GAME_OPTIONS_RESOLUTION_ITEM, i, false);
+ item->SetParam(0, _resolutions[i].width);
+ item->SetParam(1, _resolutions[i].height);
+ list.emplace_back(item);
}
break;
@@ -285,7 +295,6 @@ struct GameOptionsWindow : Window {
case WID_GO_CURRENCY_DROPDOWN: SetDParam(0, _currency_specs[this->opt->locale.currency].name); break;
case WID_GO_AUTOSAVE_DROPDOWN: SetDParam(0, _autosave_dropdown[_settings_client.gui.autosave]); break;
case WID_GO_LANG_DROPDOWN: SetDParamStr(0, _current_language->own_name); break;
- case WID_GO_RESOLUTION_DROPDOWN: SetDParam(0, GetCurRes() == _resolutions.size() ? STR_GAME_OPTIONS_RESOLUTION_OTHER : SPECSTR_RESOLUTION_START + GetCurRes()); break;
case WID_GO_GUI_ZOOM_DROPDOWN: SetDParam(0, _gui_zoom_dropdown[_gui_zoom_cfg != ZOOM_LVL_CFG_AUTO ? ZOOM_LVL_OUT_4X - _gui_zoom_cfg + 1 : 0]); break;
case WID_GO_FONT_ZOOM_DROPDOWN: SetDParam(0, _font_zoom_dropdown[_font_zoom_cfg != ZOOM_LVL_CFG_AUTO ? ZOOM_LVL_OUT_4X - _font_zoom_cfg + 1 : 0]); break;
case WID_GO_BASE_GRF_DROPDOWN: SetDParamStr(0, BaseGraphics::GetUsedSet()->name.c_str()); break;
@@ -294,6 +303,18 @@ struct GameOptionsWindow : Window {
case WID_GO_BASE_MUSIC_DROPDOWN: SetDParamStr(0, BaseMusic::GetUsedSet()->name.c_str()); break;
case WID_GO_BASE_MUSIC_STATUS: SetDParam(0, BaseMusic::GetUsedSet()->GetNumInvalid()); break;
case WID_GO_REFRESH_RATE_DROPDOWN: SetDParam(0, _settings_client.gui.refresh_rate); break;
+ case WID_GO_RESOLUTION_DROPDOWN: {
+ auto current_resolution = GetCurrentResolutionIndex();
+
+ if (current_resolution == _resolutions.size()) {
+ SetDParam(0, STR_GAME_OPTIONS_RESOLUTION_OTHER);
+ } else {
+ SetDParam(0, STR_GAME_OPTIONS_RESOLUTION_ITEM);
+ SetDParam(1, _resolutions[current_resolution].width);
+ SetDParam(2, _resolutions[current_resolution].height);
+ }
+ break;
+ }
}
}
diff --git a/src/strings.cpp b/src/strings.cpp
index acebf88ee..02ca30f23 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -1678,22 +1678,6 @@ static char *GetSpecialNameString(char *buff, int ind, StringParameters *args, c
return strecpy(buff, " Transport", last);
}
- /* language name? */
- if (IsInsideMM(ind, (SPECSTR_LANGUAGE_START - 0x70E4), (SPECSTR_LANGUAGE_END - 0x70E4) + 1)) {
- int i = ind - (SPECSTR_LANGUAGE_START - 0x70E4);
- return strecpy(buff,
- &_languages[i] == _current_language ? _current_language->own_name : _languages[i].name, last);
- }
-
- /* resolution size? */
- if (IsInsideBS(ind, (SPECSTR_RESOLUTION_START - 0x70E4), _resolutions.size())) {
- int i = ind - (SPECSTR_RESOLUTION_START - 0x70E4);
- buff += seprintf(
- buff, last, "%ux%u", _resolutions[i].width, _resolutions[i].height
- );
- return buff;
- }
-
NOT_REACHED();
}
diff --git a/src/strings_type.h b/src/strings_type.h
index 41ddfa957..7ad0c7126 100644
--- a/src/strings_type.h
+++ b/src/strings_type.h
@@ -86,13 +86,6 @@ enum SpecialStrings {
SPECSTR_SILLY_NAME = 0x70E5,
SPECSTR_ANDCO_NAME = 0x70E6,
SPECSTR_PRESIDENT_NAME = 0x70E7,
-
- /* reserve MAX_LANG strings for the *.lng files */
- SPECSTR_LANGUAGE_START = 0x7100,
- SPECSTR_LANGUAGE_END = SPECSTR_LANGUAGE_START + MAX_LANG - 1,
-
- /* reserve strings for various screen resolutions MUST BE THE LAST VALUE IN THIS ENUM */
- SPECSTR_RESOLUTION_START = SPECSTR_LANGUAGE_END + 1,
};
#endif /* STRINGS_TYPE_H */
diff --git a/src/widgets/dropdown_type.h b/src/widgets/dropdown_type.h
index 5617027e3..a1f240e96 100644
--- a/src/widgets/dropdown_type.h
+++ b/src/widgets/dropdown_type.h
@@ -61,6 +61,7 @@ public:
StringID String() const override;
void SetParam(uint index, uint64 value) { decode_params[index] = value; }
+ void SetParamStr(uint index, const char *str) { this->SetParam(index, (uint64)(size_t)str); }
};
/**