OpenTTD Source: src/settings_gui.cpp Source File

OpenTTD Source 15.3

settings_gui.cpp
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#include "stdafx.h"
11#include "currency.h"
12#include "error.h"
13#include "settings_gui.h"
14#include "textbuf_gui.h"
15#include "command_func.h"
16#include "network/network.h"
17#include "network/network_content.h"
18#include "town.h"
19#include "settings_internal.h"
20#include "strings_func.h"
21#include "window_func.h"
22#include "string_func.h"
23#include "dropdown_type.h"
24#include "dropdown_func.h"
25#include "slider_func.h"
26#include "highscore.h"
27#include "base_media_base.h"
28#include "base_media_graphics.h"
29#include "base_media_music.h"
30#include "base_media_sounds.h"
31#include "company_base.h"
32#include "company_func.h"
33#include "viewport_func.h"
34#include "core/geometry_func.hpp"
35#include "ai/ai.hpp"
36#include "blitter/factory.hpp"
37#include "language.h"
38#include "textfile_gui.h"
39#include "stringfilter_type.h"
40#include "querystring_gui.h"
41#include "fontcache.h"
42#include "zoom_func.h"
43#include "rev.h"
44#include "video/video_driver.hpp"
45#include "music/music_driver.hpp"
46#include "gui.h"
47#include "mixer.h"
48#include "newgrf_config.h"
49#include "network/core/config.h"
50#include "network/network_gui.h"
51#include "network/network_survey.h"
52#include "video/video_driver.hpp"
53#include "social_integration.h"
54#include "sound_func.h"
55#include "settingentry_gui.h"
56#include "core/string_consumer.hpp"
57
58#include "table/strings.h"
59
60#include "dropdown_common_type.h"
61
62#include "safeguards.h"
63
64
65#if defined(WITH_FREETYPE) || defined(_WIN32) || defined(WITH_COCOA)
66# define HAS_TRUETYPE_FONT
67#endif
68
69static const StringID _autosave_dropdown[] = {
70 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_OFF,
71 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_10_MINUTES,
72 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_30_MINUTES,
73 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_60_MINUTES,
74 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_120_MINUTES,
75 INVALID_STRING_ID,
76};
77
79 static const uint32_t _autosave_dropdown_to_minutes[] = {
80 0,
81 10,
82 30,
83 60,
84 120,
85};
86
91 static uint GetCurrentResolutionIndex()
92{
93 auto it = std::ranges::find(_resolutions, Dimension(_screen.width, _screen.height));
94 return std::distance(_resolutions.begin(), it);
95}
96
97static void ShowCustCurrency();
98
100 struct BaseSetTextfileWindow : public TextfileWindow {
101 const std::string name;
102 const StringID content_type;
103
104 BaseSetTextfileWindow(Window *parent, TextfileType file_type, const std::string &name, const std::string &textfile, StringID content_type) : TextfileWindow(parent, file_type), name(name), content_type(content_type)
105 {
106 this->ConstructWindow();
107 this->LoadTextfile(textfile, BASESET_DIR);
108 }
109
110 std::string GetWidgetString(WidgetID widget, StringID stringid) const override
111 {
112 if (widget == WID_TF_CAPTION) {
113 return GetString(stringid, this->content_type, this->name);
114 }
115
116 return this->Window::GetWidgetString(widget, stringid);
117 }
118};
119
126template <class TBaseSet>
127 void ShowBaseSetTextfileWindow(Window *parent, TextfileType file_type, const TBaseSet *baseset, StringID content_type)
128{
129 parent->CloseChildWindowById(WC_TEXTFILE, file_type);
130 new BaseSetTextfileWindow(parent, file_type, baseset->name, *baseset->GetTextfile(file_type), content_type);
131}
132
139template <typename TBaseSet>
140 static std::string GetListLabel(const TBaseSet *baseset)
141{
142 if (baseset->GetNumInvalid() == 0) return GetString(STR_JUST_RAW_STRING, baseset->name);
143 return GetString(STR_BASESET_STATUS, baseset->name, baseset->GetNumInvalid());
144}
145
146template <class T>
147 DropDownList BuildSetDropDownList(int *selected_index)
148{
149 int n = T::GetNumSets();
150 *selected_index = T::GetIndexOfUsedSet();
151 DropDownList list;
152 for (int i = 0; i < n; i++) {
153 list.push_back(MakeDropDownListStringItem(GetListLabel(T::GetSet(i)), i));
154 }
155 return list;
156}
157
158std::set<int> _refresh_rates = { 30, 60, 75, 90, 100, 120, 144, 240 };
159
164 static void AddCustomRefreshRates()
165{
166 /* Add the refresh rate as selected in the config. */
167 _refresh_rates.insert(_settings_client.gui.refresh_rate);
168
169 /* Add all the refresh rates of all monitors connected to the machine. */
170 std::vector<int> monitor_rates = VideoDriver::GetInstance()->GetListOfMonitorRefreshRates();
171 std::copy(monitor_rates.begin(), monitor_rates.end(), std::inserter(_refresh_rates, _refresh_rates.end()));
172}
173
174static const int SCALE_NMARKS = (MAX_INTERFACE_SCALE - MIN_INTERFACE_SCALE) / 25 + 1; // Show marks at 25% increments
175static const int VOLUME_NMARKS = 9; // Show 5 values and 4 empty marks.
176
177static std::optional<std::string> ScaleMarkFunc(int, int, int value)
178{
179 /* Label only every 100% mark. */
180 if (value % 100 != 0) return std::string{};
181
182 return GetString(STR_GAME_OPTIONS_GUI_SCALE_MARK, value / 100, 0);
183}
184
185static std::optional<std::string> VolumeMarkFunc(int, int mark, int value)
186{
187 /* Label only every other mark. */
188 if (mark % 2 != 0) return std::string{};
189
190 /* 0-127 does not map nicely to 0-100. Dividing first gives us nice round numbers. */
191 return GetString(STR_GAME_OPTIONS_VOLUME_MARK, value / 31 * 25);
192}
193
195 static constexpr Colours GAME_OPTIONS_BACKGROUND = COLOUR_MAUVE;
197 static constexpr Colours GAME_OPTIONS_BUTTON = COLOUR_YELLOW;
199 static constexpr TextColour GAME_OPTIONS_FRAME = TC_ORANGE;
201 static constexpr TextColour GAME_OPTIONS_LABEL = TC_LIGHT_BLUE;
203 static constexpr TextColour GAME_OPTIONS_SELECTED = TC_WHITE;
204
205static constexpr std::initializer_list<NWidgetPart> _nested_social_plugins_widgets = {
206 NWidget(NWID_HORIZONTAL),
207 NWidget(WWT_FRAME, GAME_OPTIONS_BACKGROUND, WID_GO_SOCIAL_PLUGIN_TITLE), SetTextStyle(GAME_OPTIONS_FRAME),
208 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
209 NWidget(WWT_TEXT, INVALID_COLOUR), SetResize(1, 0), SetFill(1, 0), SetStringTip(STR_GAME_OPTIONS_SOCIAL_PLUGIN_PLATFORM), SetTextStyle(GAME_OPTIONS_LABEL),
210 NWidget(WWT_TEXT, INVALID_COLOUR, WID_GO_SOCIAL_PLUGIN_PLATFORM), SetAlignment(SA_RIGHT),
211 EndContainer(),
212 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
213 NWidget(WWT_TEXT, INVALID_COLOUR), SetResize(1, 0), SetFill(1, 0), SetStringTip(STR_GAME_OPTIONS_SOCIAL_PLUGIN_STATE), SetTextStyle(GAME_OPTIONS_LABEL),
214 NWidget(WWT_TEXT, INVALID_COLOUR, WID_GO_SOCIAL_PLUGIN_STATE), SetAlignment(SA_RIGHT),
215 EndContainer(),
216 EndContainer(),
217 EndContainer(),
218};
219
220static constexpr std::initializer_list<NWidgetPart> _nested_social_plugins_none_widgets = {
221 NWidget(NWID_HORIZONTAL),
222 NWidget(WWT_TEXT, INVALID_COLOUR), SetResize(1, 0), SetFill(1, 0), SetStringTip(STR_GAME_OPTIONS_SOCIAL_PLUGINS_NONE), SetTextStyle(GAME_OPTIONS_LABEL),
223 EndContainer(),
224};
225
226 class NWidgetSocialPlugins : public NWidgetVertical {
227public:
228 NWidgetSocialPlugins() : NWidgetVertical({}, WID_GO_SOCIAL_PLUGINS)
229 {
230 this->plugins = SocialIntegration::GetPlugins();
231
232 if (this->plugins.empty()) {
233 auto widget = MakeNWidgets(_nested_social_plugins_none_widgets, nullptr);
234 this->Add(std::move(widget));
235 } else {
236 for (size_t i = 0; i < this->plugins.size(); i++) {
237 auto widget = MakeNWidgets(_nested_social_plugins_widgets, nullptr);
238 this->Add(std::move(widget));
239 }
240 }
241
242 this->SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0);
243 }
244
245 void SetupSmallestSize(Window *w) override
246 {
247 this->current_index = -1;
248 NWidgetVertical::SetupSmallestSize(w);
249 }
250
257 template <typename T>
258 std::string &GetWidestPlugin(T SocialIntegrationPlugin::*member) const
259 {
260 std::string *longest = &(this->plugins[0]->*member);
261 int longest_length = 0;
262
263 for (auto *plugin : this->plugins) {
264 int length = GetStringBoundingBox(plugin->*member).width;
265 if (length > longest_length) {
266 longest_length = length;
267 longest = &(plugin->*member);
268 }
269 }
270
271 return *longest;
272 }
273
274 std::string GetWidgetString(WidgetID widget, StringID) const
275 {
276 switch (widget) {
277 case WID_GO_SOCIAL_PLUGIN_TITLE:
278 /* For SetupSmallestSize, use the longest string we have. */
279 if (this->current_index < 0) {
280 return GetString(STR_GAME_OPTIONS_SOCIAL_PLUGIN_TITLE, GetWidestPlugin(&SocialIntegrationPlugin::name), GetWidestPlugin(&SocialIntegrationPlugin::version));
281 }
282
283 if (this->plugins[this->current_index]->name.empty()) {
284 return this->plugins[this->current_index]->basepath;
285 }
286
287 return GetString(STR_GAME_OPTIONS_SOCIAL_PLUGIN_TITLE, this->plugins[this->current_index]->name, this->plugins[this->current_index]->version);
288
289 case WID_GO_SOCIAL_PLUGIN_PLATFORM:
290 /* For SetupSmallestSize, use the longest string we have. */
291 if (this->current_index < 0) {
292 return GetWidestPlugin(&SocialIntegrationPlugin::social_platform);
293 }
294
295 return this->plugins[this->current_index]->social_platform;
296
297 case WID_GO_SOCIAL_PLUGIN_STATE: {
298 static const std::pair<SocialIntegrationPlugin::State, StringID> state_to_string[] = {
299 { SocialIntegrationPlugin::RUNNING, STR_GAME_OPTIONS_SOCIAL_PLUGIN_STATE_RUNNING },
300 { SocialIntegrationPlugin::FAILED, STR_GAME_OPTIONS_SOCIAL_PLUGIN_STATE_FAILED },
301 { SocialIntegrationPlugin::PLATFORM_NOT_RUNNING, STR_GAME_OPTIONS_SOCIAL_PLUGIN_STATE_PLATFORM_NOT_RUNNING },
302 { SocialIntegrationPlugin::UNLOADED, STR_GAME_OPTIONS_SOCIAL_PLUGIN_STATE_UNLOADED },
303 { SocialIntegrationPlugin::DUPLICATE, STR_GAME_OPTIONS_SOCIAL_PLUGIN_STATE_DUPLICATE },
304 { SocialIntegrationPlugin::UNSUPPORTED_API, STR_GAME_OPTIONS_SOCIAL_PLUGIN_STATE_UNSUPPORTED_API },
305 { SocialIntegrationPlugin::INVALID_SIGNATURE, STR_GAME_OPTIONS_SOCIAL_PLUGIN_STATE_INVALID_SIGNATURE },
306 };
307
308 /* For SetupSmallestSize, use the longest string we have. */
309 if (this->current_index < 0) {
310 auto longest_plugin = GetWidestPlugin(&SocialIntegrationPlugin::social_platform);
311
312 /* Set the longest plugin when looking for the longest status. */
313 StringID longest = STR_NULL;
314 int longest_length = 0;
315 for (const auto &[state, string] : state_to_string) {
316 int length = GetStringBoundingBox(GetString(string, longest_plugin)).width;
317 if (length > longest_length) {
318 longest_length = length;
319 longest = string;
320 }
321 }
322
323 return GetString(longest, longest_plugin);
324 }
325
326 const auto plugin = this->plugins[this->current_index];
327
328 /* Find the string for the state. */
329 for (const auto &[state, string] : state_to_string) {
330 if (plugin->state == state) {
331 return GetString(string, plugin->social_platform);
332 }
333 }
334
335 /* Default string, in case no state matches. */
336 return GetString(STR_GAME_OPTIONS_SOCIAL_PLUGIN_STATE_FAILED, plugin->social_platform);
337 }
338
339 default: NOT_REACHED();
340 }
341 }
342
343 void Draw(const Window *w) override
344 {
345 this->current_index = 0;
346
347 for (auto &wid : this->children) {
348 wid->Draw(w);
349 this->current_index++;
350 }
351 }
352
353private:
354 int current_index = -1;
355 std::vector<SocialIntegrationPlugin *> plugins{};
356};
357
359std::unique_ptr<NWidgetBase> MakeNWidgetSocialPlugins()
360{
361 return std::make_unique<NWidgetSocialPlugins>();
362}
363
364static const StringID _game_settings_restrict_dropdown[] = {
365 STR_CONFIG_SETTING_RESTRICT_BASIC, // RM_BASIC
366 STR_CONFIG_SETTING_RESTRICT_ADVANCED, // RM_ADVANCED
367 STR_CONFIG_SETTING_RESTRICT_ALL, // RM_ALL
368 STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_DEFAULT, // RM_CHANGED_AGAINST_DEFAULT
369 STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_NEW, // RM_CHANGED_AGAINST_NEW
370};
371static_assert(lengthof(_game_settings_restrict_dropdown) == RM_END);
372
374 enum WarnHiddenResult {
375 WHR_NONE,
376 WHR_CATEGORY,
377 WHR_TYPE,
378 WHR_CATEGORY_TYPE,
379};
380
386 static void ResetAllSettingsConfirmationCallback(Window *w, bool confirmed)
387{
388 if (confirmed) {
389 GetSettingsTree().ResetAll();
390 GetSettingsTree().FoldAll();
391 w->InvalidateData();
392 }
393}
394
395 struct GameOptionsWindow : Window {
396 static inline GameSettings *settings_ptr;
397
398 SettingEntry *valuewindow_entry = nullptr;
399 SettingEntry *clicked_entry = nullptr;
400 SettingEntry *last_clicked = nullptr;
401 SettingEntry *valuedropdown_entry = nullptr;
402 bool closing_dropdown = false;
403
404 SettingFilter filter{};
405 QueryString filter_editbox;
406 bool manually_changed_folding = false;
407 WarnHiddenResult warn_missing = WHR_NONE;
408 int warn_lines = 0;
409
410 Scrollbar *vscroll;
411 Scrollbar *vscroll_description;
412 static constexpr uint NUM_DESCRIPTION_LINES = 5;
413
414 GameSettings *opt = nullptr;
415 bool reload = false;
416 bool gui_scale_changed = false;
417 int gui_scale = 0;
418 static inline int previous_gui_scale = 0;
419 static inline WidgetID active_tab = WID_GO_TAB_GENERAL;
420
421 GameOptionsWindow(WindowDesc &desc) : Window(desc), filter_editbox(50)
422 {
423 this->opt = &GetGameSettings();
424
425 AddCustomRefreshRates();
426
427 this->filter.mode = (RestrictionMode)_settings_client.gui.settings_restriction_mode;
428 this->filter.min_cat = RM_ALL;
429 this->filter.type = ST_ALL;
430 this->filter.type_hides = false;
431 this->settings_ptr = &GetGameSettings();
432
433 GetSettingsTree().FoldAll(); // Close all sub-pages
434
435 this->CreateNestedTree();
436 this->vscroll = this->GetScrollbar(WID_GO_SCROLLBAR);
437 this->vscroll_description = this->GetScrollbar(WID_GO_HELP_TEXT_SCROLL);
438 this->vscroll_description->SetCapacity(NUM_DESCRIPTION_LINES);
439 this->FinishInitNested(WN_GAME_OPTIONS_GAME_OPTIONS);
440
441 this->querystrings[WID_GO_FILTER] = &this->filter_editbox;
442 this->filter_editbox.cancel_button = QueryString::ACTION_CLEAR;
443
444 this->OnInvalidateData(0);
445
446 this->SetTab(GameOptionsWindow::active_tab);
447
448 if constexpr (!NetworkSurveyHandler::IsSurveyPossible()) this->GetWidget<NWidgetStacked>(WID_GO_SURVEY_SEL)->SetDisplayedPlane(SZSP_NONE);
449 }
450
451 void OnInit() override
452 {
453 BaseSettingEntry::circle_size = maxdim(GetSpriteSize(SPR_CIRCLE_FOLDED), GetSpriteSize(SPR_CIRCLE_UNFOLDED));
454 BaseSettingEntry::line_height = std::max({static_cast<int>(BaseSettingEntry::circle_size.height), SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)}) + WidgetDimensions::scaled.vsep_normal;
455
456 this->gui_scale = _gui_scale;
457 }
458
459 void Close([[maybe_unused]] int data = 0) override
460 {
461 CloseWindowById(WC_CUSTOM_CURRENCY, 0);
462 if (this->reload) _switch_mode = SM_MENU;
463 this->Window::Close();
464 }
465
472 DropDownList BuildDropDownList(WidgetID widget, int *selected_index) const
473 {
474 DropDownList list;
475 switch (widget) {
476 case WID_GO_CURRENCY_DROPDOWN: { // Setup currencies dropdown
477 *selected_index = this->opt->locale.currency;
478 uint64_t disabled = _game_mode == GM_MENU ? 0LL : ~GetMaskOfAllowedCurrencies();
479
480 /* Add non-custom currencies; sorted naturally */
481 for (const CurrencySpec &currency : _currency_specs) {
482 int i = &currency - _currency_specs.data();
483 if (i == CURRENCY_CUSTOM) continue;
484 if (currency.code.empty()) {
485 list.push_back(MakeDropDownListStringItem(currency.name, i, HasBit(disabled, i)));
486 } else {
487 list.push_back(MakeDropDownListStringItem(GetString(STR_GAME_OPTIONS_CURRENCY_CODE, currency.name, currency.code), i, HasBit(disabled, i)));
488 }
489 }
490 std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
491
492 /* Append custom currency at the end */
493 list.push_back(MakeDropDownListDividerItem()); // separator line
494 list.push_back(MakeDropDownListStringItem(STR_GAME_OPTIONS_CURRENCY_CUSTOM, CURRENCY_CUSTOM, HasBit(disabled, CURRENCY_CUSTOM)));
495 break;
496 }
497
498 case WID_GO_AUTOSAVE_DROPDOWN: { // Setup autosave dropdown
499 int index = 0;
500 for (auto &minutes : _autosave_dropdown_to_minutes) {
501 index++;
502 if (_settings_client.gui.autosave_interval <= minutes) break;
503 }
504 *selected_index = index - 1;
505
506 const StringID *items = _autosave_dropdown;
507 for (uint i = 0; *items != INVALID_STRING_ID; items++, i++) {
508 list.push_back(MakeDropDownListStringItem(*items, i));
509 }
510 break;
511 }
512
513 case WID_GO_LANG_DROPDOWN: { // Setup interface language dropdown
514 for (uint i = 0; i < _languages.size(); i++) {
515 bool hide_language = IsReleasedVersion() && !_languages[i].IsReasonablyFinished();
516 if (hide_language) continue;
517 bool hide_percentage = IsReleasedVersion() || _languages[i].missing < _settings_client.gui.missing_strings_threshold;
518 std::string name;
519 if (&_languages[i] == _current_language) {
520 *selected_index = i;
521 name = _languages[i].own_name;
522 } else {
523 /* Especially with sprite-fonts, not all localized
524 * names can be rendered. So instead, we use the
525 * international names for anything but the current
526 * selected language. This avoids showing a few ????
527 * entries in the dropdown list. */
528 name = _languages[i].name;
529 }
530 if (hide_percentage) {
531 list.push_back(MakeDropDownListStringItem(std::move(name), i));
532 } else {
533 int percentage = (LANGUAGE_TOTAL_STRINGS - _languages[i].missing) * 100 / LANGUAGE_TOTAL_STRINGS;
534 list.push_back(MakeDropDownListStringItem(GetString(STR_GAME_OPTIONS_LANGUAGE_PERCENTAGE, std::move(name), percentage), i));
535 }
536 }
537 std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
538 break;
539 }
540
541 case WID_GO_RESOLUTION_DROPDOWN: // Setup resolution dropdown
542 if (_resolutions.empty()) break;
543
544 *selected_index = GetCurrentResolutionIndex();
545 for (uint i = 0; i < _resolutions.size(); i++) {
546 list.push_back(MakeDropDownListStringItem(GetString(STR_GAME_OPTIONS_RESOLUTION_ITEM, _resolutions[i].width, _resolutions[i].height), i));
547 }
548 break;
549
550 case WID_GO_REFRESH_RATE_DROPDOWN: // Setup refresh rate dropdown
551 for (auto it = _refresh_rates.begin(); it != _refresh_rates.end(); it++) {
552 auto i = std::distance(_refresh_rates.begin(), it);
553 if (*it == _settings_client.gui.refresh_rate) *selected_index = i;
554 list.push_back(MakeDropDownListStringItem(GetString(STR_GAME_OPTIONS_REFRESH_RATE_ITEM, *it), i));
555 }
556 break;
557
558 case WID_GO_BASE_GRF_DROPDOWN:
559 list = BuildSetDropDownList<BaseGraphics>(selected_index);
560 break;
561
562 case WID_GO_BASE_SFX_DROPDOWN:
563 list = BuildSetDropDownList<BaseSounds>(selected_index);
564 break;
565
566 case WID_GO_BASE_MUSIC_DROPDOWN:
567 list = BuildSetDropDownList<BaseMusic>(selected_index);
568 break;
569
570 case WID_GO_RESTRICT_DROPDOWN:
571 for (int mode = 0; mode != RM_END; mode++) {
572 /* If we are in adv. settings screen for the new game's settings,
573 * we don't want to allow comparing with new game's settings. */
574 bool disabled = mode == RM_CHANGED_AGAINST_NEW && settings_ptr == &_settings_newgame;
575
576 list.push_back(MakeDropDownListStringItem(_game_settings_restrict_dropdown[mode], mode, disabled));
577 }
578 break;
579
580 case WID_GO_TYPE_DROPDOWN:
581 list.push_back(MakeDropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL, ST_ALL));
582 list.push_back(MakeDropDownListStringItem(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME, ST_GAME));
583 list.push_back(MakeDropDownListStringItem(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME, ST_COMPANY));
584 list.push_back(MakeDropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT, ST_CLIENT));
585 break;
586 }
587
588 return list;
589 }
590
591 std::string GetToggleString(StringID stringid, WidgetID state_widget) const
592 {
593 return GetString(STR_GAME_OPTIONS_SETTING, stringid, this->IsWidgetLowered(state_widget) ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
594 }
595
596 std::string GetWidgetString(WidgetID widget, StringID stringid) const override
597 {
598 switch (widget) {
599 case WID_GO_CURRENCY_DROPDOWN: {
600 const CurrencySpec &currency = _currency_specs[this->opt->locale.currency];
601 if (currency.code.empty()) return GetString(currency.name);
602 return GetString(STR_GAME_OPTIONS_CURRENCY_CODE, currency.name, currency.code);
603 }
604
605 case WID_GO_AUTOSAVE_DROPDOWN: {
606 int index = 0;
607 for (auto &minutes : _autosave_dropdown_to_minutes) {
608 index++;
609 if (_settings_client.gui.autosave_interval <= minutes) break;
610 }
611 return GetString(_autosave_dropdown[index - 1]);
612 }
613
614 case WID_GO_LANG_DROPDOWN: return _current_language->own_name;
615 case WID_GO_BASE_GRF_DROPDOWN: return GetListLabel(BaseGraphics::GetUsedSet());
616 case WID_GO_BASE_SFX_DROPDOWN: return GetListLabel(BaseSounds::GetUsedSet());
617 case WID_GO_BASE_MUSIC_DROPDOWN: return GetListLabel(BaseMusic::GetUsedSet());
618 case WID_GO_REFRESH_RATE_DROPDOWN: return GetString(STR_GAME_OPTIONS_REFRESH_RATE_ITEM, _settings_client.gui.refresh_rate);
619 case WID_GO_RESOLUTION_DROPDOWN: {
620 auto current_resolution = GetCurrentResolutionIndex();
621
622 if (current_resolution == _resolutions.size()) {
623 return GetString(STR_GAME_OPTIONS_RESOLUTION_OTHER);
624 }
625 return GetString(STR_GAME_OPTIONS_RESOLUTION_ITEM, _resolutions[current_resolution].width, _resolutions[current_resolution].height);
626 }
627
628 case WID_GO_SOCIAL_PLUGIN_TITLE:
629 case WID_GO_SOCIAL_PLUGIN_PLATFORM:
630 case WID_GO_SOCIAL_PLUGIN_STATE: {
631 const NWidgetSocialPlugins *plugin = this->GetWidget<NWidgetSocialPlugins>(WID_GO_SOCIAL_PLUGINS);
632 assert(plugin != nullptr);
633
634 return plugin->GetWidgetString(widget, stringid);
635 }
636
637 case WID_GO_RESTRICT_DROPDOWN:
638 return GetString(_game_settings_restrict_dropdown[this->filter.mode]);
639
640 case WID_GO_TYPE_DROPDOWN:
641 switch (this->filter.type) {
642 case ST_GAME: return GetString(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME);
643 case ST_COMPANY: return GetString(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME);
644 case ST_CLIENT: return GetString(STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT);
645 default: return GetString(STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL);
646 }
647 break;
648
649 case WID_GO_SURVEY_PARTICIPATE_TEXT:
650 return GetToggleString(STR_GAME_OPTIONS_PARTICIPATE_SURVEY, WID_GO_SURVEY_PARTICIPATE_BUTTON);
651
652 case WID_GO_GUI_SCALE_AUTO_TEXT:
653 return GetToggleString(STR_GAME_OPTIONS_GUI_SCALE_AUTO, WID_GO_GUI_SCALE_AUTO);
654
655 case WID_GO_GUI_SCALE_BEVEL_TEXT:
656 return GetToggleString(STR_GAME_OPTIONS_GUI_SCALE_BEVELS, WID_GO_GUI_SCALE_BEVEL_BUTTON);
657
658 case WID_GO_GUI_FONT_SPRITE_TEXT:
659 return GetToggleString(STR_GAME_OPTIONS_GUI_FONT_SPRITE, WID_GO_GUI_FONT_SPRITE);
660
661 case WID_GO_GUI_FONT_AA_TEXT:
662 return GetToggleString(STR_GAME_OPTIONS_GUI_FONT_AA, WID_GO_GUI_FONT_AA);
663
664 case WID_GO_FULLSCREEN_TEXT:
665 return GetToggleString(STR_GAME_OPTIONS_FULLSCREEN, WID_GO_FULLSCREEN_BUTTON);
666
667 case WID_GO_VIDEO_ACCEL_TEXT:
668 return GetToggleString(STR_GAME_OPTIONS_VIDEO_ACCELERATION, WID_GO_VIDEO_ACCEL_BUTTON);
669
670 case WID_GO_VIDEO_VSYNC_TEXT:
671 return GetToggleString(STR_GAME_OPTIONS_VIDEO_VSYNC, WID_GO_VIDEO_VSYNC_BUTTON);
672
673 default:
674 return this->Window::GetWidgetString(widget, stringid);
675 }
676 }
677
678 void DrawWidget(const Rect &r, WidgetID widget) const override
679 {
680 switch (widget) {
681 case WID_GO_BASE_GRF_DESCRIPTION:
682 DrawStringMultiLine(r, GetString(STR_JUST_RAW_STRING, BaseGraphics::GetUsedSet()->GetDescription(GetCurrentLanguageIsoCode())), GAME_OPTIONS_SELECTED);
683 break;
684
685 case WID_GO_BASE_SFX_DESCRIPTION:
686 DrawStringMultiLine(r, GetString(STR_JUST_RAW_STRING, BaseSounds::GetUsedSet()->GetDescription(GetCurrentLanguageIsoCode())), GAME_OPTIONS_SELECTED);
687 break;
688
689 case WID_GO_BASE_MUSIC_DESCRIPTION:
690 DrawStringMultiLine(r, GetString(STR_JUST_RAW_STRING, BaseMusic::GetUsedSet()->GetDescription(GetCurrentLanguageIsoCode())), GAME_OPTIONS_SELECTED);
691 break;
692
693 case WID_GO_GUI_SCALE:
694 DrawSliderWidget(r, GAME_OPTIONS_BACKGROUND, GAME_OPTIONS_BUTTON, TC_BLACK, MIN_INTERFACE_SCALE, MAX_INTERFACE_SCALE, SCALE_NMARKS, this->gui_scale, ScaleMarkFunc);
695 break;
696
697 case WID_GO_VIDEO_DRIVER_INFO:
698 DrawStringMultiLine(r, GetString(STR_GAME_OPTIONS_VIDEO_DRIVER_INFO, std::string{VideoDriver::GetInstance()->GetInfoString()}), GAME_OPTIONS_SELECTED);
699 break;
700
701 case WID_GO_BASE_SFX_VOLUME:
702 DrawSliderWidget(r, GAME_OPTIONS_BACKGROUND, GAME_OPTIONS_BUTTON, TC_BLACK, 0, INT8_MAX, VOLUME_NMARKS, _settings_client.music.effect_vol, VolumeMarkFunc);
703 break;
704
705 case WID_GO_BASE_MUSIC_VOLUME:
706 DrawSliderWidget(r, GAME_OPTIONS_BACKGROUND, GAME_OPTIONS_BUTTON, TC_BLACK, 0, INT8_MAX, VOLUME_NMARKS, _settings_client.music.music_vol, VolumeMarkFunc);
707 break;
708
709 case WID_GO_OPTIONSPANEL: {
710 Rect tr = r.Shrink(WidgetDimensions::scaled.frametext, WidgetDimensions::scaled.framerect);
711 tr.top += this->warn_lines * BaseSettingEntry::line_height;
712 uint last_row = this->vscroll->GetPosition() + this->vscroll->GetCapacity() - this->warn_lines;
713 int next_row = GetSettingsTree().Draw(settings_ptr, tr.left, tr.right, tr.top,
714 this->vscroll->GetPosition(), last_row, this->last_clicked);
715 if (next_row == 0) DrawString(tr, STR_CONFIG_SETTINGS_NONE);
716 break;
717 }
718
719 case WID_GO_SETTING_PROPERTIES:
720 if (this->last_clicked != nullptr) {
721 const IntSettingDesc *sd = this->last_clicked->setting;
722
723 Rect tr = r;
724 std::string str;
725 switch (sd->GetType()) {
726 case ST_COMPANY: str = GetString(STR_CONFIG_SETTING_TYPE, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_COMPANY_INGAME); break;
727 case ST_CLIENT: str = GetString(STR_CONFIG_SETTING_TYPE, STR_CONFIG_SETTING_TYPE_CLIENT); break;
728 case ST_GAME: str = GetString(STR_CONFIG_SETTING_TYPE, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_GAME_MENU : STR_CONFIG_SETTING_TYPE_GAME_INGAME); break;
729 default: NOT_REACHED();
730 }
731 DrawString(tr, str);
732 tr.top += GetCharacterHeight(FS_NORMAL);
733
734 auto [param1, param2] = sd->GetValueParams(sd->GetDefaultValue());
735 DrawString(tr, GetString(STR_CONFIG_SETTING_DEFAULT_VALUE, param1, param2));
736 }
737 break;
738
739 case WID_GO_HELP_TEXT:
740 if (this->last_clicked != nullptr) {
741 const IntSettingDesc *sd = this->last_clicked->setting;
742
743 DrawPixelInfo tmp_dpi;
744 if (FillDrawPixelInfo(&tmp_dpi, r)) {
745 AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
746 int scrolls_pos = this->vscroll_description->GetPosition() * GetCharacterHeight(FS_NORMAL);
747 DrawStringMultiLine(0, r.Width() - 1, -scrolls_pos, r.Height() - 1, sd->GetHelp(), TC_WHITE);
748 }
749 }
750 break;
751
752 default:
753 break;
754 }
755 }
756
761 void SetDisplayedHelpText(SettingEntry *pe)
762 {
763 if (this->last_clicked != pe) this->SetDirty();
764 this->last_clicked = pe;
765 UpdateHelpTextSize();
766 }
767
768 void UpdateHelpTextSize()
769 {
770 NWidgetResizeBase *wid = this->GetWidget<NWidgetResizeBase>(WID_GO_HELP_TEXT);
771 this->vscroll_description->SetCount(this->last_clicked ? CeilDiv(this->last_clicked->GetMaxHelpHeight(wid->current_x), GetCharacterHeight(FS_NORMAL)) : 0);
772 }
773
774 void SetTab(WidgetID widget)
775 {
776 this->SetWidgetsLoweredState(false, WID_GO_TAB_GENERAL, WID_GO_TAB_GRAPHICS, WID_GO_TAB_SOUND, WID_GO_TAB_ADVANCED, WID_GO_TAB_SOCIAL);
777 this->LowerWidget(widget);
778 GameOptionsWindow::active_tab = widget;
779
780 int plane;
781 switch (widget) {
782 case WID_GO_TAB_GENERAL: plane = 0; break;
783 case WID_GO_TAB_GRAPHICS: plane = 1; break;
784 case WID_GO_TAB_SOUND: plane = 2; break;
785 case WID_GO_TAB_SOCIAL: plane = 3; break;
786 case WID_GO_TAB_ADVANCED: plane = 4; break;
787 default: NOT_REACHED();
788 }
789
790 this->GetWidget<NWidgetStacked>(WID_GO_TAB_SELECTION)->SetDisplayedPlane(plane);
791 if (widget == WID_GO_TAB_ADVANCED) this->SetFocusedWidget(WID_GO_FILTER);
792 this->SetDirty();
793 }
794
795 void OnResize() override
796 {
797 this->vscroll->SetCapacityFromWidget(this, WID_GO_OPTIONSPANEL, WidgetDimensions::scaled.framerect.Vertical());
798 UpdateHelpTextSize();
799
800 bool changed = false;
801
802 NWidgetResizeBase *wid = this->GetWidget<NWidgetResizeBase>(WID_GO_BASE_GRF_DESCRIPTION);
803 int y = 0;
804 for (int i = 0; i < BaseGraphics::GetNumSets(); i++) {
805 std::string str = GetString(STR_JUST_RAW_STRING, BaseGraphics::GetSet(i)->GetDescription(GetCurrentLanguageIsoCode()));
806 y = std::max(y, GetStringHeight(str, wid->current_x));
807 }
808 changed |= wid->UpdateVerticalSize(y);
809
810 wid = this->GetWidget<NWidgetResizeBase>(WID_GO_BASE_SFX_DESCRIPTION);
811 y = 0;
812 for (int i = 0; i < BaseSounds::GetNumSets(); i++) {
813 std::string str = GetString(STR_JUST_RAW_STRING, BaseSounds::GetSet(i)->GetDescription(GetCurrentLanguageIsoCode()));
814 y = std::max(y, GetStringHeight(str, wid->current_x));
815 }
816 changed |= wid->UpdateVerticalSize(y);
817
818 wid = this->GetWidget<NWidgetResizeBase>(WID_GO_BASE_MUSIC_DESCRIPTION);
819 y = 0;
820 for (int i = 0; i < BaseMusic::GetNumSets(); i++) {
821 std::string str = GetString(STR_JUST_RAW_STRING, BaseMusic::GetSet(i)->GetDescription(GetCurrentLanguageIsoCode()));
822 y = std::max(y, GetStringHeight(str, wid->current_x));
823 }
824 changed |= wid->UpdateVerticalSize(y);
825
826 wid = this->GetWidget<NWidgetResizeBase>(WID_GO_VIDEO_DRIVER_INFO);
827 std::string str = GetString(STR_GAME_OPTIONS_VIDEO_DRIVER_INFO, std::string{VideoDriver::GetInstance()->GetInfoString()});
828 y = GetStringHeight(str, wid->current_x);
829 changed |= wid->UpdateVerticalSize(y);
830
831 if (changed) this->ReInit(0, 0, this->flags.Test(WindowFlag::Centred));
832 }
833
834 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
835 {
836 switch (widget) {
837 case WID_GO_TEXT_SFX_VOLUME:
838 case WID_GO_TEXT_MUSIC_VOLUME: {
839 Dimension d = maxdim(GetStringBoundingBox(STR_GAME_OPTIONS_SFX_VOLUME), GetStringBoundingBox(STR_GAME_OPTIONS_MUSIC_VOLUME));
840 d.width += padding.width;
841 d.height += padding.height;
842 size = maxdim(size, d);
843 break;
844 }
845
846 case WID_GO_CURRENCY_DROPDOWN:
847 case WID_GO_AUTOSAVE_DROPDOWN:
848 case WID_GO_LANG_DROPDOWN:
849 case WID_GO_RESOLUTION_DROPDOWN:
850 case WID_GO_REFRESH_RATE_DROPDOWN:
851 case WID_GO_BASE_GRF_DROPDOWN:
852 case WID_GO_BASE_SFX_DROPDOWN:
853 case WID_GO_BASE_MUSIC_DROPDOWN: {
854 int selected;
855 size.width = std::max(size.width, GetDropDownListDimension(this->BuildDropDownList(widget, &selected)).width + padding.width);
856 break;
857 }
858
859 case WID_GO_OPTIONSPANEL:
860 fill.height = resize.height = BaseSettingEntry::line_height;
861 resize.width = 1;
862
863 size.height = 8 * resize.height + WidgetDimensions::scaled.framerect.Vertical();
864 break;
865
866 case WID_GO_SETTING_PROPERTIES: {
867 static const StringID setting_types[] = {
868 STR_CONFIG_SETTING_TYPE_CLIENT,
869 STR_CONFIG_SETTING_TYPE_COMPANY_MENU, STR_CONFIG_SETTING_TYPE_COMPANY_INGAME,
870 STR_CONFIG_SETTING_TYPE_GAME_MENU, STR_CONFIG_SETTING_TYPE_GAME_INGAME,
871 };
872 for (const auto &setting_type : setting_types) {
873 size.width = std::max(size.width, GetStringBoundingBox(GetString(STR_CONFIG_SETTING_TYPE, setting_type)).width + padding.width);
874 }
875 size.height = 2 * GetCharacterHeight(FS_NORMAL);
876 break;
877 }
878
879 case WID_GO_HELP_TEXT:
880 size.height = NUM_DESCRIPTION_LINES * GetCharacterHeight(FS_NORMAL);
881 break;
882
883 case WID_GO_RESTRICT_CATEGORY:
884 case WID_GO_RESTRICT_TYPE:
885 size.width = std::max(GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_CATEGORY).width, GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_TYPE).width);
886 break;
887
888 default:
889 break;
890 }
891 }
892
893 void OnPaint() override
894 {
895 if (this->GetWidget<NWidgetStacked>(WID_GO_TAB_SELECTION)->shown_plane != 4) {
896 this->DrawWidgets();
897 return;
898 }
899
900 if (this->closing_dropdown) {
901 this->closing_dropdown = false;
902 assert(this->valuedropdown_entry != nullptr);
903 this->valuedropdown_entry->SetButtons({});
904 this->valuedropdown_entry = nullptr;
905 }
906
907 /* Reserve the correct number of lines for the 'some search results are hidden' notice in the central settings display panel. */
908 const Rect panel = this->GetWidget<NWidgetBase>(WID_GO_OPTIONSPANEL)->GetCurrentRect().Shrink(WidgetDimensions::scaled.frametext);
909 StringID warn_str = STR_CONFIG_SETTING_CATEGORY_HIDES - 1 + this->warn_missing;
910 int new_warn_lines;
911 if (this->warn_missing == WHR_NONE) {
912 new_warn_lines = 0;
913 } else {
914 new_warn_lines = GetStringLineCount(GetString(warn_str, _game_settings_restrict_dropdown[this->filter.min_cat]), panel.Width());
915 }
916 if (this->warn_lines != new_warn_lines) {
917 this->vscroll->SetCount(this->vscroll->GetCount() - this->warn_lines + new_warn_lines);
918 this->warn_lines = new_warn_lines;
919 }
920
921 this->DrawWidgets();
922
923 /* Draw the 'some search results are hidden' notice. */
924 if (this->warn_missing != WHR_NONE) {
925 DrawStringMultiLineWithClipping(panel.WithHeight(this->warn_lines * GetCharacterHeight(FS_NORMAL)),
926 GetString(warn_str, _game_settings_restrict_dropdown[this->filter.min_cat]),
927 TC_BLACK, SA_CENTER);
928 }
929 }
930
931 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
932 {
933 if (widget >= WID_GO_BASE_GRF_TEXTFILE && widget < WID_GO_BASE_GRF_TEXTFILE + TFT_CONTENT_END) {
934 if (BaseGraphics::GetUsedSet() == nullptr) return;
935
936 ShowBaseSetTextfileWindow(this, (TextfileType)(widget - WID_GO_BASE_GRF_TEXTFILE), BaseGraphics::GetUsedSet(), STR_CONTENT_TYPE_BASE_GRAPHICS);
937 return;
938 }
939 if (widget >= WID_GO_BASE_SFX_TEXTFILE && widget < WID_GO_BASE_SFX_TEXTFILE + TFT_CONTENT_END) {
940 if (BaseSounds::GetUsedSet() == nullptr) return;
941
942 ShowBaseSetTextfileWindow(this, (TextfileType)(widget - WID_GO_BASE_SFX_TEXTFILE), BaseSounds::GetUsedSet(), STR_CONTENT_TYPE_BASE_SOUNDS);
943 return;
944 }
945 if (widget >= WID_GO_BASE_MUSIC_TEXTFILE && widget < WID_GO_BASE_MUSIC_TEXTFILE + TFT_CONTENT_END) {
946 if (BaseMusic::GetUsedSet() == nullptr) return;
947
948 ShowBaseSetTextfileWindow(this, (TextfileType)(widget - WID_GO_BASE_MUSIC_TEXTFILE), BaseMusic::GetUsedSet(), STR_CONTENT_TYPE_BASE_MUSIC);
949 return;
950 }
951 switch (widget) {
952 case WID_GO_TAB_GENERAL:
953 case WID_GO_TAB_GRAPHICS:
954 case WID_GO_TAB_SOUND:
955 case WID_GO_TAB_ADVANCED:
956 case WID_GO_TAB_SOCIAL:
957 SndClickBeep();
958 this->SetTab(widget);
959 break;
960
961 case WID_GO_SURVEY_PARTICIPATE_BUTTON:
962 switch (_settings_client.network.participate_survey) {
963 case PS_ASK:
964 case PS_NO:
965 _settings_client.network.participate_survey = PS_YES;
966 break;
967
968 case PS_YES:
969 _settings_client.network.participate_survey = PS_NO;
970 break;
971 }
972
973 this->SetWidgetLoweredState(WID_GO_SURVEY_PARTICIPATE_BUTTON, _settings_client.network.participate_survey == PS_YES);
974 this->SetWidgetDirty(WID_GO_SURVEY_PARTICIPATE_BUTTON);
975 this->SetWidgetDirty(WID_GO_SURVEY_PARTICIPATE_TEXT);
976 break;
977
978 case WID_GO_SURVEY_LINK_BUTTON:
979 OpenBrowser(NETWORK_SURVEY_DETAILS_LINK);
980 break;
981
982 case WID_GO_SURVEY_PREVIEW_BUTTON:
983 ShowSurveyResultTextfileWindow(this);
984 break;
985
986 case WID_GO_FULLSCREEN_BUTTON: // Click fullscreen on/off
987 /* try to toggle full-screen on/off */
988 if (!ToggleFullScreen(!_fullscreen)) {
989 ShowErrorMessage(GetEncodedString(STR_ERROR_FULLSCREEN_FAILED), {}, WL_ERROR);
990 }
991 this->SetWidgetLoweredState(WID_GO_FULLSCREEN_BUTTON, _fullscreen);
992 this->SetWidgetDirty(WID_GO_FULLSCREEN_BUTTON);
993 this->SetWidgetDirty(WID_GO_FULLSCREEN_TEXT);
994 break;
995
996 case WID_GO_VIDEO_ACCEL_BUTTON:
997 _video_hw_accel = !_video_hw_accel;
998 ShowErrorMessage(GetEncodedString(STR_GAME_OPTIONS_VIDEO_ACCELERATION_RESTART), {}, WL_INFO);
999 this->SetWidgetLoweredState(WID_GO_VIDEO_ACCEL_BUTTON, _video_hw_accel);
1000 this->SetWidgetDirty(WID_GO_VIDEO_ACCEL_BUTTON);
1001 this->SetWidgetDirty(WID_GO_VIDEO_ACCEL_TEXT);
1002#ifndef __APPLE__
1003 this->SetWidgetLoweredState(WID_GO_VIDEO_VSYNC_BUTTON, _video_hw_accel && _video_vsync);
1004 this->SetWidgetDisabledState(WID_GO_VIDEO_VSYNC_BUTTON, !_video_hw_accel);
1005 this->SetWidgetDirty(WID_GO_VIDEO_VSYNC_BUTTON);
1006 this->SetWidgetDirty(WID_GO_VIDEO_VSYNC_TEXT);
1007#endif
1008 break;
1009
1010 case WID_GO_VIDEO_VSYNC_BUTTON:
1011 if (!_video_hw_accel) break;
1012
1013 _video_vsync = !_video_vsync;
1014 VideoDriver::GetInstance()->ToggleVsync(_video_vsync);
1015
1016 this->SetWidgetLoweredState(WID_GO_VIDEO_VSYNC_BUTTON, _video_vsync);
1017 this->SetWidgetDirty(WID_GO_VIDEO_VSYNC_BUTTON);
1018 this->SetWidgetDirty(WID_GO_VIDEO_VSYNC_TEXT);
1019 this->SetWidgetDisabledState(WID_GO_REFRESH_RATE_DROPDOWN, _video_vsync);
1020 this->SetWidgetDirty(WID_GO_REFRESH_RATE_DROPDOWN);
1021 break;
1022
1023 case WID_GO_GUI_SCALE_BEVEL_BUTTON: {
1024 _settings_client.gui.scale_bevels = !_settings_client.gui.scale_bevels;
1025
1026 this->SetWidgetLoweredState(WID_GO_GUI_SCALE_BEVEL_BUTTON, _settings_client.gui.scale_bevels);
1027 this->SetDirty();
1028
1029 SetupWidgetDimensions();
1030 ReInitAllWindows(true);
1031 break;
1032 }
1033
1034#ifdef HAS_TRUETYPE_FONT
1035 case WID_GO_GUI_FONT_SPRITE:
1036 _fcsettings.prefer_sprite = !_fcsettings.prefer_sprite;
1037
1038 this->SetWidgetLoweredState(WID_GO_GUI_FONT_SPRITE, _fcsettings.prefer_sprite);
1039 this->SetWidgetDisabledState(WID_GO_GUI_FONT_AA, _fcsettings.prefer_sprite);
1040 this->SetDirty();
1041
1042 FontCache::LoadFontCaches(FONTSIZES_ALL);
1043 FontCache::ClearFontCaches(FONTSIZES_ALL);
1044 CheckForMissingGlyphs();
1045 SetupWidgetDimensions();
1046 UpdateAllVirtCoords();
1047 ReInitAllWindows(true);
1048 break;
1049
1050 case WID_GO_GUI_FONT_AA:
1051 _fcsettings.global_aa = !_fcsettings.global_aa;
1052
1053 this->SetWidgetLoweredState(WID_GO_GUI_FONT_AA, _fcsettings.global_aa);
1054 MarkWholeScreenDirty();
1055
1056 FontCache::ClearFontCaches(FONTSIZES_ALL);
1057 break;
1058#endif /* HAS_TRUETYPE_FONT */
1059
1060 case WID_GO_GUI_SCALE:
1061 /* Any click on the slider deactivates automatic interface scaling, setting it to the current value before being adjusted. */
1062 if (_gui_scale_cfg == -1) {
1063 _gui_scale_cfg = this->gui_scale;
1064 this->SetWidgetLoweredState(WID_GO_GUI_SCALE_AUTO, false);
1065 this->SetWidgetDirty(WID_GO_GUI_SCALE_AUTO);
1066 this->SetWidgetDirty(WID_GO_GUI_SCALE_AUTO_TEXT);
1067 }
1068
1069 if (ClickSliderWidget(this->GetWidget<NWidgetBase>(widget)->GetCurrentRect(), pt, MIN_INTERFACE_SCALE, MAX_INTERFACE_SCALE, _ctrl_pressed ? 0 : SCALE_NMARKS, this->gui_scale)) {
1070 this->gui_scale_changed = true;
1071 this->SetWidgetDirty(widget);
1072 }
1073
1074 if (click_count > 0) this->mouse_capture_widget = widget;
1075 break;
1076
1077 case WID_GO_GUI_SCALE_AUTO:
1078 {
1079 if (_gui_scale_cfg == -1) {
1080 _gui_scale_cfg = this->previous_gui_scale; // Load the previous GUI scale
1081 this->SetWidgetLoweredState(WID_GO_GUI_SCALE_AUTO, false);
1082 if (AdjustGUIZoom(false)) ReInitAllWindows(true);
1083 this->gui_scale = _gui_scale;
1084 } else {
1085 this->previous_gui_scale = _gui_scale; // Set the previous GUI scale value as the current one
1086 _gui_scale_cfg = -1;
1087 this->SetWidgetLoweredState(WID_GO_GUI_SCALE_AUTO, true);
1088 if (AdjustGUIZoom(false)) ReInitAllWindows(true);
1089 this->gui_scale = _gui_scale;
1090 }
1091 this->SetWidgetDirty(widget);
1092 this->SetWidgetDirty(WID_GO_GUI_SCALE_AUTO_TEXT);
1093 break;
1094 }
1095
1096 case WID_GO_BASE_GRF_PARAMETERS: {
1097 auto *used_set = BaseGraphics::GetUsedSet();
1098 if (used_set == nullptr || !used_set->IsConfigurable()) break;
1099 GRFConfig &extra_cfg = used_set->GetOrCreateExtraConfig();
1100 if (extra_cfg.param.empty()) extra_cfg.SetParameterDefaults();
1101 OpenGRFParameterWindow(true, extra_cfg, _game_mode == GM_MENU);
1102 if (_game_mode == GM_MENU) this->reload = true;
1103 break;
1104 }
1105
1106 case WID_GO_BASE_SFX_VOLUME:
1107 case WID_GO_BASE_MUSIC_VOLUME: {
1108 uint8_t &vol = (widget == WID_GO_BASE_MUSIC_VOLUME) ? _settings_client.music.music_vol : _settings_client.music.effect_vol;
1109 if (ClickSliderWidget(this->GetWidget<NWidgetBase>(widget)->GetCurrentRect(), pt, 0, INT8_MAX, 0, vol)) {
1110 if (widget == WID_GO_BASE_MUSIC_VOLUME) {
1111 MusicDriver::GetInstance()->SetVolume(vol);
1112 } else {
1113 SetEffectVolume(vol);
1114 }
1115 this->SetWidgetDirty(widget);
1116 SetWindowClassesDirty(WC_MUSIC_WINDOW);
1117 }
1118
1119 if (click_count > 0) this->mouse_capture_widget = widget;
1120 break;
1121 }
1122
1123 case WID_GO_BASE_MUSIC_JUKEBOX: {
1124 ShowMusicWindow();
1125 break;
1126 }
1127
1128 case WID_GO_BASE_GRF_OPEN_URL:
1129 if (BaseGraphics::GetUsedSet() == nullptr || BaseGraphics::GetUsedSet()->url.empty()) return;
1130 OpenBrowser(BaseGraphics::GetUsedSet()->url);
1131 break;
1132
1133 case WID_GO_BASE_SFX_OPEN_URL:
1134 if (BaseSounds::GetUsedSet() == nullptr || BaseSounds::GetUsedSet()->url.empty()) return;
1135 OpenBrowser(BaseSounds::GetUsedSet()->url);
1136 break;
1137
1138 case WID_GO_BASE_MUSIC_OPEN_URL:
1139 if (BaseMusic::GetUsedSet() == nullptr || BaseMusic::GetUsedSet()->url.empty()) return;
1140 OpenBrowser(BaseMusic::GetUsedSet()->url);
1141 break;
1142
1143 case WID_GO_BASE_GRF_CONTENT_DOWNLOAD:
1144 ShowNetworkContentListWindow(nullptr, CONTENT_TYPE_BASE_GRAPHICS);
1145 break;
1146
1147 case WID_GO_BASE_SFX_CONTENT_DOWNLOAD:
1148 ShowNetworkContentListWindow(nullptr, CONTENT_TYPE_BASE_SOUNDS);
1149 break;
1150
1151 case WID_GO_BASE_MUSIC_CONTENT_DOWNLOAD:
1152 ShowNetworkContentListWindow(nullptr, CONTENT_TYPE_BASE_MUSIC);
1153 break;
1154
1155 case WID_GO_CURRENCY_DROPDOWN:
1156 case WID_GO_AUTOSAVE_DROPDOWN:
1157 case WID_GO_LANG_DROPDOWN:
1158 case WID_GO_RESOLUTION_DROPDOWN:
1159 case WID_GO_REFRESH_RATE_DROPDOWN:
1160 case WID_GO_BASE_GRF_DROPDOWN:
1161 case WID_GO_BASE_SFX_DROPDOWN:
1162 case WID_GO_BASE_MUSIC_DROPDOWN: {
1163 int selected;
1164 DropDownList list = this->BuildDropDownList(widget, &selected);
1165 if (!list.empty()) {
1166 ShowDropDownList(this, std::move(list), selected, widget);
1167 } else {
1168 if (widget == WID_GO_RESOLUTION_DROPDOWN) ShowErrorMessage(GetEncodedString(STR_ERROR_RESOLUTION_LIST_FAILED), {}, WL_ERROR);
1169 }
1170 break;
1171 }
1172
1173 case WID_GO_EXPAND_ALL:
1174 this->manually_changed_folding = true;
1175 GetSettingsTree().UnFoldAll();
1176 this->InvalidateData();
1177 break;
1178
1179 case WID_GO_COLLAPSE_ALL:
1180 this->manually_changed_folding = true;
1181 GetSettingsTree().FoldAll();
1182 this->InvalidateData();
1183 break;
1184
1185 case WID_GO_RESET_ALL:
1186 ShowQuery(
1187 GetEncodedString(STR_CONFIG_SETTING_RESET_ALL_CONFIRMATION_DIALOG_CAPTION),
1188 GetEncodedString(STR_CONFIG_SETTING_RESET_ALL_CONFIRMATION_DIALOG_TEXT),
1189 this,
1190 ResetAllSettingsConfirmationCallback
1191 );
1192 break;
1193
1194 case WID_GO_RESTRICT_DROPDOWN: {
1195 int selected;
1196 DropDownList list = this->BuildDropDownList(widget, &selected);
1197 if (!list.empty()) {
1198 ShowDropDownList(this, std::move(list), this->filter.mode, widget);
1199 }
1200 break;
1201 }
1202
1203 case WID_GO_TYPE_DROPDOWN: {
1204 int selected;
1205 DropDownList list = this->BuildDropDownList(widget, &selected);
1206 if (!list.empty()) {
1207 ShowDropDownList(this, std::move(list), this->filter.type, widget);
1208 }
1209 break;
1210 }
1211
1212 case WID_GO_OPTIONSPANEL:
1213 OptionsPanelClick(pt);
1214 break;
1215 }
1216 }
1217
1218 void OptionsPanelClick(Point pt)
1219 {
1220 int32_t btn = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GO_OPTIONSPANEL, WidgetDimensions::scaled.framerect.top);
1221 if (btn == INT32_MAX || btn < this->warn_lines) return;
1222 btn -= this->warn_lines;
1223
1224 uint cur_row = 0;
1225 BaseSettingEntry *clicked_entry = GetSettingsTree().FindEntry(btn, &cur_row);
1226
1227 if (clicked_entry == nullptr) return; // Clicked below the last setting of the page
1228
1229 const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_GO_OPTIONSPANEL);
1230 int x = (_current_text_dir == TD_RTL ? this->width - 1 - pt.x : pt.x) - WidgetDimensions::scaled.frametext.left - (clicked_entry->level + 1) * WidgetDimensions::scaled.hsep_indent - wid->pos_x; // Shift x coordinate
1231 if (x < 0) return; // Clicked left of the entry
1232
1233 SettingsPage *clicked_page = dynamic_cast<SettingsPage*>(clicked_entry);
1234 if (clicked_page != nullptr) {
1235 this->SetDisplayedHelpText(nullptr);
1236 clicked_page->folded = !clicked_page->folded; // Flip 'folded'-ness of the sub-page
1237
1238 this->manually_changed_folding = true;
1239
1240 this->InvalidateData();
1241 return;
1242 }
1243
1244 SettingEntry *pe = dynamic_cast<SettingEntry*>(clicked_entry);
1245 assert(pe != nullptr);
1246 const IntSettingDesc *sd = pe->setting;
1247
1248 /* return if action is only active in network, or only settable by server */
1249 if (!sd->IsEditable()) {
1250 this->SetDisplayedHelpText(pe);
1251 return;
1252 }
1253
1254 auto [min_val, max_val] = sd->GetRange();
1255 int32_t value = sd->Read(ResolveObject(settings_ptr, sd));
1256
1257 /* clicked on the icon on the left side. Either scroller, bool on/off or dropdown */
1258 if (x < SETTING_BUTTON_WIDTH && sd->flags.Test(SettingFlag::GuiDropdown)) {
1259 this->SetDisplayedHelpText(pe);
1260
1261 if (this->valuedropdown_entry == pe) {
1262 /* unclick the dropdown */
1263 this->CloseChildWindows(WC_DROPDOWN_MENU);
1264 this->closing_dropdown = false;
1265 this->valuedropdown_entry->SetButtons({});
1266 this->valuedropdown_entry = nullptr;
1267 } else {
1268 if (this->valuedropdown_entry != nullptr) this->valuedropdown_entry->SetButtons({});
1269 this->closing_dropdown = false;
1270
1271 int rel_y = (pt.y - wid->pos_y - WidgetDimensions::scaled.framerect.top) % wid->resize_y;
1272
1273 Rect wi_rect;
1274 wi_rect.left = pt.x - (_current_text_dir == TD_RTL ? SETTING_BUTTON_WIDTH - 1 - x : x);
1275 wi_rect.right = wi_rect.left + SETTING_BUTTON_WIDTH - 1;
1276 wi_rect.top = pt.y - rel_y + (BaseSettingEntry::line_height - SETTING_BUTTON_HEIGHT) / 2;
1277 wi_rect.bottom = wi_rect.top + SETTING_BUTTON_HEIGHT - 1;
1278
1279 /* For dropdowns we also have to check the y position thoroughly, the mouse may not above the just opening dropdown */
1280 if (pt.y >= wi_rect.top && pt.y <= wi_rect.bottom) {
1281 this->valuedropdown_entry = pe;
1282 this->valuedropdown_entry->SetButtons(SettingEntryFlag::LeftDepressed);
1283
1284 DropDownList list;
1285 for (int32_t i = min_val; i <= static_cast<int32_t>(max_val); i++) {
1286 auto [param1, param2] = sd->GetValueParams(i);
1287 list.push_back(MakeDropDownListStringItem(GetString(STR_JUST_STRING1, param1, param2), i));
1288 }
1289
1290 ShowDropDownListAt(this, std::move(list), value, WID_GO_SETTING_DROPDOWN, wi_rect, COLOUR_ORANGE);
1291 }
1292 }
1293 this->SetDirty();
1294 } else if (x < SETTING_BUTTON_WIDTH) {
1295 this->SetDisplayedHelpText(pe);
1296 int32_t oldvalue = value;
1297
1298 if (sd->IsBoolSetting()) {
1299 value ^= 1;
1300 } else {
1301 /* Add a dynamic step-size to the scroller. In a maximum of
1302 * 50-steps you should be able to get from min to max,
1303 * unless specified otherwise in the 'interval' variable
1304 * of the current setting. */
1305 uint32_t step = (sd->interval == 0) ? ((max_val - min_val) / 50) : sd->interval;
1306 if (step == 0) step = 1;
1307
1308 /* don't allow too fast scrolling */
1309 if (this->flags.Test(WindowFlag::Timeout) && this->timeout_timer > 1) {
1310 _left_button_clicked = false;
1311 return;
1312 }
1313
1314 /* Increase or decrease the value and clamp it to extremes */
1315 if (x >= SETTING_BUTTON_WIDTH / 2) {
1316 value += step;
1317 if (min_val < 0) {
1318 assert(static_cast<int32_t>(max_val) >= 0);
1319 if (value > static_cast<int32_t>(max_val)) value = static_cast<int32_t>(max_val);
1320 } else {
1321 if (static_cast<uint32_t>(value) > max_val) value = static_cast<int32_t>(max_val);
1322 }
1323 if (value < min_val) value = min_val; // skip between "disabled" and minimum
1324 } else {
1325 value -= step;
1326 if (value < min_val) value = sd->flags.Test(SettingFlag::GuiZeroIsSpecial) ? 0 : min_val;
1327 }
1328
1329 /* Set up scroller timeout for numeric values */
1330 if (value != oldvalue) {
1331 if (this->clicked_entry != nullptr) { // Release previous buttons if any
1332 this->clicked_entry->SetButtons({});
1333 }
1334 this->clicked_entry = pe;
1335 this->clicked_entry->SetButtons((x >= SETTING_BUTTON_WIDTH / 2) != (_current_text_dir == TD_RTL) ? SettingEntryFlag::RightDepressed : SettingEntryFlag::LeftDepressed);
1336 this->SetTimeout();
1337 _left_button_clicked = false;
1338 }
1339 }
1340
1341 if (value != oldvalue) {
1342 SetSettingValue(sd, value);
1343 this->SetDirty();
1344 }
1345 } else {
1346 /* Only open editbox if clicked for the second time, and only for types where it is sensible for. */
1347 if (this->last_clicked == pe && !sd->IsBoolSetting() && !sd->flags.Test(SettingFlag::GuiDropdown)) {
1348 int64_t value64 = value;
1349 /* Show the correct currency-translated value */
1350 if (sd->flags.Test(SettingFlag::GuiCurrency)) value64 *= GetCurrency().rate;
1351
1352 CharSetFilter charset_filter = CS_NUMERAL; //default, only numeric input allowed
1353 if (min_val < 0) charset_filter = CS_NUMERAL_SIGNED; // special case, also allow '-' sign for negative input
1354
1355 this->valuewindow_entry = pe;
1356 /* Limit string length to 14 so that MAX_INT32 * max currency rate doesn't exceed MAX_INT64. */
1357 ShowQueryString(GetString(STR_JUST_INT, value64), STR_CONFIG_SETTING_QUERY_CAPTION, 15, this, charset_filter, QueryStringFlag::EnableDefault);
1358 }
1359 this->SetDisplayedHelpText(pe);
1360 }
1361 }
1362
1363 void OnTimeout() override
1364 {
1365 if (this->clicked_entry != nullptr) { // On timeout, release any depressed buttons
1366 this->clicked_entry->SetButtons({});
1367 this->clicked_entry = nullptr;
1368 this->SetDirty();
1369 }
1370 }
1371
1372 void OnQueryTextFinished(std::optional<std::string> str) override
1373 {
1374 /* The user pressed cancel */
1375 if (!str.has_value()) return;
1376
1377 assert(this->valuewindow_entry != nullptr);
1378 const IntSettingDesc *sd = this->valuewindow_entry->setting;
1379
1380 int32_t value;
1381 if (!str->empty()) {
1382 auto llvalue = ParseInteger<int64_t>(*str, 10, true);
1383 if (!llvalue.has_value()) return;
1384
1385 /* Save the correct currency-translated value */
1386 if (sd->flags.Test(SettingFlag::GuiCurrency)) llvalue = *llvalue / GetCurrency().rate;
1387
1388 value = ClampTo<int32_t>(*llvalue);
1389 } else {
1390 value = sd->GetDefaultValue();
1391 }
1392
1393 SetSettingValue(this->valuewindow_entry->setting, value);
1394 this->SetDirty();
1395 }
1396
1397 void OnMouseLoop() override
1398 {
1399 if (_left_button_down || !this->gui_scale_changed) return;
1400
1401 this->gui_scale_changed = false;
1402 _gui_scale_cfg = this->gui_scale;
1403
1404 if (AdjustGUIZoom(false)) {
1405 ReInitAllWindows(true);
1406 this->SetWidgetLoweredState(WID_GO_GUI_SCALE_AUTO, false);
1407 this->SetDirty();
1408 }
1409 }
1410
1411 void OnDropdownSelect(WidgetID widget, int index, int) override
1412 {
1413 switch (widget) {
1414 case WID_GO_CURRENCY_DROPDOWN: // Currency
1415 if (index == CURRENCY_CUSTOM) ShowCustCurrency();
1416 this->opt->locale.currency = index;
1417 ReInitAllWindows(false);
1418 break;
1419
1420 case WID_GO_AUTOSAVE_DROPDOWN: // Autosave options
1421 _settings_client.gui.autosave_interval = _autosave_dropdown_to_minutes[index];
1422 ChangeAutosaveFrequency(false);
1423 this->SetDirty();
1424 break;
1425
1426 case WID_GO_LANG_DROPDOWN: // Change interface language
1427 ReadLanguagePack(&_languages[index]);
1428 CloseWindowByClass(WC_QUERY_STRING);
1429 CheckForMissingGlyphs();
1430 ClearAllCachedNames();
1431 UpdateAllVirtCoords();
1432 CheckBlitter();
1433 ReInitAllWindows(false);
1434 break;
1435
1436 case WID_GO_RESOLUTION_DROPDOWN: // Change resolution
1437 if ((uint)index < _resolutions.size() && ChangeResInGame(_resolutions[index].width, _resolutions[index].height)) {
1438 this->SetDirty();
1439 }
1440 break;
1441
1442 case WID_GO_REFRESH_RATE_DROPDOWN: {
1443 _settings_client.gui.refresh_rate = *std::next(_refresh_rates.begin(), index);
1444 if (_settings_client.gui.refresh_rate > 60) {
1445 /* Show warning to the user that this refresh rate might not be suitable on
1446 * larger maps with many NewGRFs and vehicles. */
1447 ShowErrorMessage(GetEncodedString(STR_GAME_OPTIONS_REFRESH_RATE_WARNING), {}, WL_INFO);
1448 }
1449 break;
1450 }
1451
1452 case WID_GO_BASE_GRF_DROPDOWN:
1453 if (_game_mode == GM_MENU) {
1454 CloseWindowByClass(WC_GRF_PARAMETERS);
1455 auto set = BaseGraphics::GetSet(index);
1456 BaseGraphics::SetSet(set);
1457 this->reload = true;
1458 this->InvalidateData();
1459 }
1460 break;
1461
1462 case WID_GO_BASE_SFX_DROPDOWN:
1463 ChangeSoundSet(index);
1464 break;
1465
1466 case WID_GO_BASE_MUSIC_DROPDOWN:
1467 ChangeMusicSet(index);
1468 break;
1469
1470 case WID_GO_RESTRICT_DROPDOWN:
1471 this->filter.mode = (RestrictionMode)index;
1472 if (this->filter.mode == RM_CHANGED_AGAINST_DEFAULT ||
1473 this->filter.mode == RM_CHANGED_AGAINST_NEW) {
1474
1475 if (!this->manually_changed_folding) {
1476 /* Expand all when selecting 'changes'. Update the filter state first, in case it becomes less restrictive in some cases. */
1477 GetSettingsTree().UpdateFilterState(this->filter, false);
1478 GetSettingsTree().UnFoldAll();
1479 }
1480 } else {
1481 /* Non-'changes' filter. Save as default. */
1482 _settings_client.gui.settings_restriction_mode = this->filter.mode;
1483 }
1484 this->InvalidateData();
1485 break;
1486
1487 case WID_GO_TYPE_DROPDOWN:
1488 this->filter.type = (SettingType)index;
1489 this->InvalidateData();
1490 break;
1491
1492 case WID_GO_SETTING_DROPDOWN:
1493 /* Deal with drop down boxes on the panel. */
1494 assert(this->valuedropdown_entry != nullptr);
1495 const IntSettingDesc *sd = this->valuedropdown_entry->setting;
1496 assert(sd->flags.Test(SettingFlag::GuiDropdown));
1497
1498 SetSettingValue(sd, index);
1499 this->SetDirty();
1500 break;
1501 }
1502 }
1503
1504 void OnDropdownClose(Point pt, WidgetID widget, int index, int click_result, bool instant_close) override
1505 {
1506 if (widget != WID_GO_SETTING_DROPDOWN) {
1507 /* Normally the default implementation of OnDropdownClose() takes care of
1508 * a few things. We want that behaviour here too, but only for
1509 * "normal" dropdown boxes. The special dropdown boxes added for every
1510 * setting that needs one can't have this call. */
1511 Window::OnDropdownClose(pt, widget, index, click_result, instant_close);
1512 } else {
1513 /* We cannot raise the dropdown button just yet. OnClick needs some hint, whether
1514 * the same dropdown button was clicked again, and then not open the dropdown again.
1515 * So, we only remember that it was closed, and process it on the next OnPaint, which is
1516 * after OnClick. */
1517 assert(this->valuedropdown_entry != nullptr);
1518 this->closing_dropdown = true;
1519 this->SetDirty();
1520 }
1521 }
1522
1528 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
1529 {
1530 if (!gui_scope) return;
1531 this->SetWidgetLoweredState(WID_GO_SURVEY_PARTICIPATE_BUTTON, _settings_client.network.participate_survey == PS_YES);
1532 this->SetWidgetLoweredState(WID_GO_FULLSCREEN_BUTTON, _fullscreen);
1533 this->SetWidgetLoweredState(WID_GO_VIDEO_ACCEL_BUTTON, _video_hw_accel);
1534 this->SetWidgetDisabledState(WID_GO_REFRESH_RATE_DROPDOWN, _video_vsync);
1535
1536#ifndef __APPLE__
1537 this->SetWidgetLoweredState(WID_GO_VIDEO_VSYNC_BUTTON, _video_hw_accel && _video_vsync);
1538 this->SetWidgetDisabledState(WID_GO_VIDEO_VSYNC_BUTTON, !_video_hw_accel);
1539#endif
1540
1541 this->SetWidgetLoweredState(WID_GO_GUI_SCALE_AUTO, _gui_scale_cfg == -1);
1542 this->SetWidgetLoweredState(WID_GO_GUI_SCALE_BEVEL_BUTTON, _settings_client.gui.scale_bevels);
1543#ifdef HAS_TRUETYPE_FONT
1544 this->SetWidgetLoweredState(WID_GO_GUI_FONT_SPRITE, _fcsettings.prefer_sprite);
1545 this->SetWidgetLoweredState(WID_GO_GUI_FONT_AA, _fcsettings.global_aa);
1546 this->SetWidgetDisabledState(WID_GO_GUI_FONT_AA, _fcsettings.prefer_sprite);
1547#endif /* HAS_TRUETYPE_FONT */
1548
1549 this->SetWidgetDisabledState(WID_GO_BASE_GRF_DROPDOWN, _game_mode != GM_MENU);
1550
1551 this->SetWidgetDisabledState(WID_GO_BASE_GRF_PARAMETERS, BaseGraphics::GetUsedSet() == nullptr || !BaseGraphics::GetUsedSet()->IsConfigurable());
1552
1553 this->SetWidgetDisabledState(WID_GO_BASE_GRF_OPEN_URL, BaseGraphics::GetUsedSet() == nullptr || BaseGraphics::GetUsedSet()->url.empty());
1554 this->SetWidgetDisabledState(WID_GO_BASE_SFX_OPEN_URL, BaseSounds::GetUsedSet() == nullptr || BaseSounds::GetUsedSet()->url.empty());
1555 this->SetWidgetDisabledState(WID_GO_BASE_MUSIC_OPEN_URL, BaseMusic::GetUsedSet() == nullptr || BaseMusic::GetUsedSet()->url.empty());
1556
1557 for (TextfileType tft = TFT_CONTENT_BEGIN; tft < TFT_CONTENT_END; tft++) {
1558 this->SetWidgetDisabledState(WID_GO_BASE_GRF_TEXTFILE + tft, BaseGraphics::GetUsedSet() == nullptr || !BaseGraphics::GetUsedSet()->GetTextfile(tft).has_value());
1559 this->SetWidgetDisabledState(WID_GO_BASE_SFX_TEXTFILE + tft, BaseSounds::GetUsedSet() == nullptr || !BaseSounds::GetUsedSet()->GetTextfile(tft).has_value());
1560 this->SetWidgetDisabledState(WID_GO_BASE_MUSIC_TEXTFILE + tft, BaseMusic::GetUsedSet() == nullptr || !BaseMusic::GetUsedSet()->GetTextfile(tft).has_value());
1561 }
1562
1563 this->SetWidgetsDisabledState(!_network_available, WID_GO_BASE_GRF_CONTENT_DOWNLOAD, WID_GO_BASE_SFX_CONTENT_DOWNLOAD, WID_GO_BASE_MUSIC_CONTENT_DOWNLOAD);
1564
1565 /* Update which settings are to be visible. */
1566 RestrictionMode min_level = (this->filter.mode <= RM_ALL) ? this->filter.mode : RM_BASIC;
1567 this->filter.min_cat = min_level;
1568 this->filter.type_hides = false;
1569 GetSettingsTree().UpdateFilterState(this->filter, false);
1570
1571 if (this->filter.string.IsEmpty()) {
1572 this->warn_missing = WHR_NONE;
1573 } else if (min_level < this->filter.min_cat) {
1574 this->warn_missing = this->filter.type_hides ? WHR_CATEGORY_TYPE : WHR_CATEGORY;
1575 } else {
1576 this->warn_missing = this->filter.type_hides ? WHR_TYPE : WHR_NONE;
1577 }
1578 this->vscroll->SetCount(GetSettingsTree().Length() + this->warn_lines);
1579
1580 if (this->last_clicked != nullptr && !GetSettingsTree().IsVisible(this->last_clicked)) {
1581 this->SetDisplayedHelpText(nullptr);
1582 }
1583
1584 bool all_folded = true;
1585 bool all_unfolded = true;
1586 GetSettingsTree().GetFoldingState(all_folded, all_unfolded);
1587 this->SetWidgetDisabledState(WID_GO_EXPAND_ALL, all_unfolded);
1588 this->SetWidgetDisabledState(WID_GO_COLLAPSE_ALL, all_folded);
1589 }
1590
1591 void OnEditboxChanged(WidgetID wid) override
1592 {
1593 if (wid == WID_GO_FILTER) {
1594 this->filter.string.SetFilterTerm(this->filter_editbox.text.GetText());
1595 if (!this->filter.string.IsEmpty() && !this->manually_changed_folding) {
1596 /* User never expanded/collapsed single pages and entered a filter term.
1597 * Expand everything, to save weird expand clicks, */
1598 GetSettingsTree().UnFoldAll();
1599 }
1600 this->InvalidateData();
1601 }
1602 }
1603};
1604
1605static constexpr std::initializer_list<NWidgetPart> _nested_game_options_widgets = {
1606 NWidget(NWID_HORIZONTAL),
1607 NWidget(WWT_CLOSEBOX, GAME_OPTIONS_BACKGROUND),
1608 NWidget(WWT_CAPTION, GAME_OPTIONS_BACKGROUND), SetStringTip(STR_GAME_OPTIONS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1609 NWidget(WWT_DEFSIZEBOX, GAME_OPTIONS_BACKGROUND),
1610 EndContainer(),
1611 NWidget(WWT_PANEL, GAME_OPTIONS_BACKGROUND),
1612 NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize), SetPadding(WidgetDimensions::unscaled.sparse),
1613 NWidget(WWT_TEXTBTN, GAME_OPTIONS_BUTTON, WID_GO_TAB_GENERAL), SetMinimalTextLines(2, 0), SetStringTip(STR_GAME_OPTIONS_TAB_GENERAL, STR_GAME_OPTIONS_TAB_GENERAL_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
1614 NWidget(WWT_TEXTBTN, GAME_OPTIONS_BUTTON, WID_GO_TAB_GRAPHICS), SetMinimalTextLines(2, 0), SetStringTip(STR_GAME_OPTIONS_TAB_GRAPHICS, STR_GAME_OPTIONS_TAB_GRAPHICS_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
1615 NWidget(WWT_TEXTBTN, GAME_OPTIONS_BUTTON, WID_GO_TAB_SOUND), SetMinimalTextLines(2, 0), SetStringTip(STR_GAME_OPTIONS_TAB_SOUND, STR_GAME_OPTIONS_TAB_SOUND_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
1616 NWidget(WWT_TEXTBTN, GAME_OPTIONS_BUTTON, WID_GO_TAB_SOCIAL), SetMinimalTextLines(2, 0), SetStringTip(STR_GAME_OPTIONS_TAB_SOCIAL, STR_GAME_OPTIONS_TAB_SOCIAL_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
1617 NWidget(WWT_TEXTBTN, GAME_OPTIONS_BUTTON, WID_GO_TAB_ADVANCED), SetMinimalTextLines(2, 0), SetStringTip(STR_GAME_OPTIONS_TAB_ADVANCED, STR_GAME_OPTIONS_TAB_ADVANCED_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
1618 EndContainer(),
1619 EndContainer(),
1620 NWidget(WWT_PANEL, GAME_OPTIONS_BACKGROUND),
1621 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_GO_TAB_SELECTION),
1622 /* General tab */
1623 NWidget(NWID_VERTICAL), SetPadding(WidgetDimensions::unscaled.sparse_resize),
1624 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0),
1625 NWidget(WWT_FRAME, GAME_OPTIONS_BACKGROUND), SetStringTip(STR_GAME_OPTIONS_LANGUAGE), SetTextStyle(GAME_OPTIONS_FRAME),
1626 NWidget(WWT_DROPDOWN, GAME_OPTIONS_BUTTON, WID_GO_LANG_DROPDOWN), SetToolTip(STR_GAME_OPTIONS_LANGUAGE_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
1627 EndContainer(),
1628
1629 NWidget(WWT_FRAME, GAME_OPTIONS_BACKGROUND), SetStringTip(STR_GAME_OPTIONS_AUTOSAVE_FRAME), SetTextStyle(GAME_OPTIONS_FRAME),
1630 NWidget(WWT_DROPDOWN, GAME_OPTIONS_BUTTON, WID_GO_AUTOSAVE_DROPDOWN), SetToolTip(STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
1631 EndContainer(),
1632
1633 NWidget(WWT_FRAME, GAME_OPTIONS_BACKGROUND), SetStringTip(STR_GAME_OPTIONS_CURRENCY_UNITS_FRAME), SetTextStyle(GAME_OPTIONS_FRAME),
1634 NWidget(WWT_DROPDOWN, GAME_OPTIONS_BUTTON, WID_GO_CURRENCY_DROPDOWN), SetToolTip(STR_GAME_OPTIONS_CURRENCY_UNITS_DROPDOWN_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
1635 EndContainer(),
1636
1637 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_GO_SURVEY_SEL),
1638 NWidget(WWT_FRAME, GAME_OPTIONS_BACKGROUND), SetStringTip(STR_GAME_OPTIONS_PARTICIPATE_SURVEY_FRAME), SetTextStyle(GAME_OPTIONS_FRAME), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
1639 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
1640 NWidget(WWT_BOOLBTN, GAME_OPTIONS_BACKGROUND, WID_GO_SURVEY_PARTICIPATE_BUTTON), SetAlternateColourTip(GAME_OPTIONS_BUTTON, STR_GAME_OPTIONS_PARTICIPATE_SURVEY_TOOLTIP),
1641 NWidget(WWT_TEXT, INVALID_COLOUR, WID_GO_SURVEY_PARTICIPATE_TEXT), SetFill(1, 0), SetResize(1, 0), SetTextStyle(GAME_OPTIONS_LABEL),
1642 EndContainer(),
1643 NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize),
1644 NWidget(WWT_TEXTBTN, GAME_OPTIONS_BUTTON, WID_GO_SURVEY_PREVIEW_BUTTON), SetFill(1, 0), SetResize(1, 0), SetStringTip(STR_GAME_OPTIONS_PARTICIPATE_SURVEY_PREVIEW, STR_GAME_OPTIONS_PARTICIPATE_SURVEY_PREVIEW_TOOLTIP),
1645 NWidget(WWT_TEXTBTN, GAME_OPTIONS_BUTTON, WID_GO_SURVEY_LINK_BUTTON), SetFill(1, 0), SetResize(1, 0), SetStringTip(STR_GAME_OPTIONS_PARTICIPATE_SURVEY_LINK, STR_GAME_OPTIONS_PARTICIPATE_SURVEY_LINK_TOOLTIP),
1646 EndContainer(),
1647 EndContainer(),
1648 EndContainer(),
1649 EndContainer(),
1650 NWidget(NWID_SPACER), SetFill(1, 1), SetResize(1, 1), // Allows this pane to resize
1651 EndContainer(),
1652
1653 /* Graphics tab */
1654 NWidget(NWID_VERTICAL), SetPadding(WidgetDimensions::unscaled.sparse_resize),
1655 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0),
1656 NWidget(WWT_FRAME, GAME_OPTIONS_BACKGROUND), SetStringTip(STR_GAME_OPTIONS_INTERFACE), SetTextStyle(GAME_OPTIONS_FRAME),
1657 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0),
1658 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
1659 NWidget(WWT_TEXT, INVALID_COLOUR), SetStringTip(STR_GAME_OPTIONS_GUI_SCALE_FRAME), SetTextStyle(GAME_OPTIONS_LABEL),
1660 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GO_GUI_SCALE), SetMinimalTextLines(1, 12 + WidgetDimensions::unscaled.vsep_normal, FS_SMALL), SetFill(1, 0), SetResize(1, 0), SetToolTip(STR_GAME_OPTIONS_GUI_SCALE_TOOLTIP),
1661 EndContainer(),
1662 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
1663 NWidget(WWT_BOOLBTN, GAME_OPTIONS_BACKGROUND, WID_GO_GUI_SCALE_AUTO), SetAlternateColourTip(GAME_OPTIONS_BUTTON, STR_GAME_OPTIONS_GUI_SCALE_AUTO_TOOLTIP),
1664 NWidget(WWT_TEXT, INVALID_COLOUR, WID_GO_GUI_SCALE_AUTO_TEXT), SetFill(1, 0), SetResize(1, 0), SetTextStyle(GAME_OPTIONS_LABEL),
1665 EndContainer(),
1666 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
1667 NWidget(WWT_BOOLBTN, GAME_OPTIONS_BACKGROUND, WID_GO_GUI_SCALE_BEVEL_BUTTON), SetAlternateColourTip(GAME_OPTIONS_BUTTON, STR_GAME_OPTIONS_GUI_SCALE_BEVELS_TOOLTIP),
1668 NWidget(WWT_TEXT, INVALID_COLOUR, WID_GO_GUI_SCALE_BEVEL_TEXT), SetFill(1, 0), SetResize(1, 0), SetTextStyle(GAME_OPTIONS_LABEL),
1669 EndContainer(),
1670#ifdef HAS_TRUETYPE_FONT
1671 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
1672 NWidget(WWT_BOOLBTN, GAME_OPTIONS_BACKGROUND, WID_GO_GUI_FONT_SPRITE), SetAlternateColourTip(GAME_OPTIONS_BUTTON, STR_GAME_OPTIONS_GUI_FONT_SPRITE_TOOLTIP),
1673 NWidget(WWT_TEXT, INVALID_COLOUR, WID_GO_GUI_FONT_SPRITE_TEXT), SetFill(1, 0), SetResize(1, 0), SetTextStyle(GAME_OPTIONS_LABEL),
1674 EndContainer(),
1675 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
1676 NWidget(WWT_BOOLBTN, GAME_OPTIONS_BACKGROUND, WID_GO_GUI_FONT_AA), SetAlternateColourTip(GAME_OPTIONS_BUTTON, STR_GAME_OPTIONS_GUI_FONT_AA_TOOLTIP),
1677 NWidget(WWT_TEXT, INVALID_COLOUR, WID_GO_GUI_FONT_AA_TEXT), SetFill(1, 0), SetResize(1, 0), SetTextStyle(GAME_OPTIONS_LABEL),
1678 EndContainer(),
1679#endif /* HAS_TRUETYPE_FONT */
1680 EndContainer(),
1681 EndContainer(),
1682
1683 NWidget(WWT_FRAME, GAME_OPTIONS_BACKGROUND), SetStringTip(STR_GAME_OPTIONS_DISPLAY), SetTextStyle(GAME_OPTIONS_FRAME),
1684 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0),
1685 NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
1686 NWidget(WWT_TEXT, INVALID_COLOUR), SetFill(1, 0), SetResize(1, 0), SetStringTip(STR_GAME_OPTIONS_RESOLUTION), SetTextStyle(GAME_OPTIONS_LABEL),
1687 NWidget(WWT_DROPDOWN, GAME_OPTIONS_BUTTON, WID_GO_RESOLUTION_DROPDOWN), SetFill(1, 0), SetToolTip(STR_GAME_OPTIONS_RESOLUTION_TOOLTIP),
1688 EndContainer(),
1689 NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
1690 NWidget(WWT_TEXT, INVALID_COLOUR), SetFill(1, 0), SetResize(1, 0), SetStringTip(STR_GAME_OPTIONS_REFRESH_RATE), SetTextStyle(GAME_OPTIONS_LABEL),
1691 NWidget(WWT_DROPDOWN, GAME_OPTIONS_BUTTON, WID_GO_REFRESH_RATE_DROPDOWN), SetFill(1, 0), SetToolTip(STR_GAME_OPTIONS_REFRESH_RATE_TOOLTIP),
1692 EndContainer(),
1693 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
1694 NWidget(WWT_BOOLBTN, GAME_OPTIONS_BACKGROUND, WID_GO_FULLSCREEN_BUTTON), SetAlternateColourTip(GAME_OPTIONS_BUTTON, STR_GAME_OPTIONS_FULLSCREEN_TOOLTIP),
1695 NWidget(WWT_TEXT, INVALID_COLOUR, WID_GO_FULLSCREEN_TEXT), SetFill(1, 0), SetResize(1, 0), SetTextStyle(GAME_OPTIONS_LABEL),
1696 EndContainer(),
1697 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
1698 NWidget(WWT_BOOLBTN, GAME_OPTIONS_BACKGROUND, WID_GO_VIDEO_ACCEL_BUTTON), SetAlternateColourTip(GAME_OPTIONS_BUTTON, STR_GAME_OPTIONS_VIDEO_ACCELERATION_TOOLTIP),
1699 NWidget(WWT_TEXT, INVALID_COLOUR,WID_GO_VIDEO_ACCEL_TEXT), SetFill(1, 0), SetResize(1, 0), SetTextStyle(GAME_OPTIONS_LABEL),
1700 EndContainer(),
1701#ifndef __APPLE__
1702 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
1703 NWidget(WWT_BOOLBTN, GAME_OPTIONS_BACKGROUND, WID_GO_VIDEO_VSYNC_BUTTON), SetAlternateColourTip(GAME_OPTIONS_BUTTON, STR_GAME_OPTIONS_VIDEO_VSYNC_TOOLTIP),
1704 NWidget(WWT_TEXT, INVALID_COLOUR, WID_GO_VIDEO_VSYNC_TEXT), SetFill(1, 0), SetResize(1, 0), SetTextStyle(GAME_OPTIONS_LABEL),
1705 EndContainer(),
1706#endif
1707 NWidget(NWID_HORIZONTAL),
1708 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GO_VIDEO_DRIVER_INFO), SetMinimalTextLines(1, 0), SetFill(1, 0), SetResize(1, 0),
1709 EndContainer(),
1710 EndContainer(),
1711 EndContainer(),
1712
1713 NWidget(WWT_FRAME, GAME_OPTIONS_BACKGROUND), SetStringTip(STR_GAME_OPTIONS_BASE_GRF), SetTextStyle(GAME_OPTIONS_FRAME), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0), SetFill(1, 0),
1714 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
1715 NWidget(WWT_DROPDOWN, GAME_OPTIONS_BUTTON, WID_GO_BASE_GRF_DROPDOWN), SetToolTip(STR_GAME_OPTIONS_BASE_GRF_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
1716 NWidget(WWT_PUSHTXTBTN, GAME_OPTIONS_BUTTON, WID_GO_BASE_GRF_PARAMETERS), SetStringTip(STR_NEWGRF_SETTINGS_SET_PARAMETERS),
1717 NWidget(WWT_PUSHTXTBTN, GAME_OPTIONS_BUTTON, WID_GO_BASE_GRF_CONTENT_DOWNLOAD), SetStringTip(STR_GAME_OPTIONS_ONLINE_CONTENT, STR_GAME_OPTIONS_ONLINE_CONTENT_TOOLTIP),
1718 EndContainer(),
1719 NWidget(WWT_TEXT, INVALID_COLOUR, WID_GO_BASE_GRF_DESCRIPTION), SetStringTip(STR_EMPTY, STR_GAME_OPTIONS_BASE_GRF_DESCRIPTION_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
1720 NWidget(NWID_VERTICAL),
1721 NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize),
1722 NWidget(WWT_PUSHTXTBTN, GAME_OPTIONS_BUTTON, WID_GO_BASE_GRF_OPEN_URL), SetResize(1, 0), SetFill(1, 0), SetStringTip(STR_CONTENT_OPEN_URL, STR_CONTENT_OPEN_URL_TOOLTIP),
1723 NWidget(WWT_PUSHTXTBTN, GAME_OPTIONS_BUTTON, WID_GO_BASE_GRF_TEXTFILE + TFT_README), SetFill(1, 0), SetResize(1, 0), SetStringTip(STR_TEXTFILE_VIEW_README, STR_TEXTFILE_VIEW_README_TOOLTIP),
1724 EndContainer(),
1725 NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize),
1726 NWidget(WWT_PUSHTXTBTN, GAME_OPTIONS_BUTTON, WID_GO_BASE_GRF_TEXTFILE + TFT_CHANGELOG), SetFill(1, 0), SetResize(1, 0), SetStringTip(STR_TEXTFILE_VIEW_CHANGELOG, STR_TEXTFILE_VIEW_CHANGELOG_TOOLTIP),
1727 NWidget(WWT_PUSHTXTBTN, GAME_OPTIONS_BUTTON, WID_GO_BASE_GRF_TEXTFILE + TFT_LICENSE), SetFill(1, 0), SetResize(1, 0), SetStringTip(STR_TEXTFILE_VIEW_LICENCE, STR_TEXTFILE_VIEW_LICENCE_TOOLTIP),
1728 EndContainer(),
1729 EndContainer(),
1730 EndContainer(),
1731 EndContainer(),
1732 NWidget(NWID_SPACER), SetFill(1, 1), SetResize(1, 1), // Allows this pane to resize
1733 EndContainer(),
1734
1735 /* Sound/Music tab */
1736 NWidget(NWID_VERTICAL), SetPadding(WidgetDimensions::unscaled.sparse_resize),
1737 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0),
1738 NWidget(WWT_FRAME, GAME_OPTIONS_BACKGROUND), SetStringTip(STR_GAME_OPTIONS_VOLUME), SetTextStyle(GAME_OPTIONS_FRAME), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0),
1739 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
1740 NWidget(WWT_TEXT, INVALID_COLOUR, WID_GO_TEXT_SFX_VOLUME), SetStringTip(STR_GAME_OPTIONS_SFX_VOLUME), SetTextStyle(GAME_OPTIONS_LABEL),
1741 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GO_BASE_SFX_VOLUME), SetMinimalTextLines(1, 12 + WidgetDimensions::unscaled.vsep_normal, FS_SMALL), SetFill(1, 0), SetResize(1, 0), SetToolTip(STR_MUSIC_TOOLTIP_DRAG_SLIDERS_TO_SET_MUSIC),
1742 EndContainer(),
1743 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
1744 NWidget(WWT_TEXT, INVALID_COLOUR, WID_GO_TEXT_MUSIC_VOLUME), SetStringTip(STR_GAME_OPTIONS_MUSIC_VOLUME), SetTextStyle(GAME_OPTIONS_LABEL),
1745 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GO_BASE_MUSIC_VOLUME), SetMinimalTextLines(1, 12 + WidgetDimensions::unscaled.vsep_normal, FS_SMALL), SetFill(1, 0), SetResize(1, 0), SetToolTip(STR_MUSIC_TOOLTIP_DRAG_SLIDERS_TO_SET_MUSIC),
1746 EndContainer(),
1747 EndContainer(),
1748
1749 NWidget(WWT_FRAME, GAME_OPTIONS_BACKGROUND), SetStringTip(STR_GAME_OPTIONS_BASE_SFX), SetTextStyle(GAME_OPTIONS_FRAME), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
1750 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
1751 NWidget(WWT_DROPDOWN, GAME_OPTIONS_BUTTON, WID_GO_BASE_SFX_DROPDOWN), SetToolTip(STR_GAME_OPTIONS_BASE_SFX_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
1752 NWidget(WWT_PUSHTXTBTN, GAME_OPTIONS_BUTTON, WID_GO_BASE_SFX_CONTENT_DOWNLOAD), SetStringTip(STR_GAME_OPTIONS_ONLINE_CONTENT, STR_GAME_OPTIONS_ONLINE_CONTENT_TOOLTIP),
1753 EndContainer(),
1754 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GO_BASE_SFX_DESCRIPTION), SetMinimalTextLines(1, 0), SetToolTip(STR_GAME_OPTIONS_BASE_SFX_DESCRIPTION_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
1755 NWidget(NWID_VERTICAL),
1756 NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize),
1757 NWidget(WWT_PUSHTXTBTN, GAME_OPTIONS_BUTTON, WID_GO_BASE_SFX_OPEN_URL), SetResize(1, 0), SetFill(1, 0), SetStringTip(STR_CONTENT_OPEN_URL, STR_CONTENT_OPEN_URL_TOOLTIP),
1758 NWidget(WWT_PUSHTXTBTN, GAME_OPTIONS_BUTTON, WID_GO_BASE_SFX_TEXTFILE + TFT_README), SetFill(1, 0), SetResize(1, 0), SetStringTip(STR_TEXTFILE_VIEW_README, STR_TEXTFILE_VIEW_README_TOOLTIP),
1759 EndContainer(),
1760 NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize),
1761 NWidget(WWT_PUSHTXTBTN, GAME_OPTIONS_BUTTON, WID_GO_BASE_SFX_TEXTFILE + TFT_CHANGELOG), SetFill(1, 0), SetResize(1, 0), SetStringTip(STR_TEXTFILE_VIEW_CHANGELOG, STR_TEXTFILE_VIEW_CHANGELOG_TOOLTIP),
1762 NWidget(WWT_PUSHTXTBTN, GAME_OPTIONS_BUTTON, WID_GO_BASE_SFX_TEXTFILE + TFT_LICENSE), SetFill(1, 0), SetResize(1, 0), SetStringTip(STR_TEXTFILE_VIEW_LICENCE, STR_TEXTFILE_VIEW_LICENCE_TOOLTIP),
1763 EndContainer(),
1764 EndContainer(),
1765 EndContainer(),
1766
1767 NWidget(WWT_FRAME, GAME_OPTIONS_BACKGROUND), SetStringTip(STR_GAME_OPTIONS_BASE_MUSIC), SetTextStyle(GAME_OPTIONS_FRAME), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
1768 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
1769 NWidget(WWT_DROPDOWN, GAME_OPTIONS_BUTTON, WID_GO_BASE_MUSIC_DROPDOWN), SetToolTip(STR_GAME_OPTIONS_BASE_MUSIC_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
1770 NWidget(WWT_PUSHTXTBTN, GAME_OPTIONS_BUTTON, WID_GO_BASE_MUSIC_CONTENT_DOWNLOAD), SetStringTip(STR_GAME_OPTIONS_ONLINE_CONTENT, STR_GAME_OPTIONS_ONLINE_CONTENT_TOOLTIP),
1771 EndContainer(),
1772 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
1773 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GO_BASE_MUSIC_DESCRIPTION), SetMinimalTextLines(1, 0), SetToolTip(STR_GAME_OPTIONS_BASE_MUSIC_DESCRIPTION_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
1774 NWidget(NWID_VERTICAL), SetPIPRatio(0, 0, 1),
1775 NWidget(WWT_PUSHIMGBTN, GAME_OPTIONS_BUTTON, WID_GO_BASE_MUSIC_JUKEBOX), SetToolbarMinimalSize(1), SetSpriteTip(SPR_IMG_MUSIC, STR_TOOLBAR_TOOLTIP_SHOW_SOUND_MUSIC_WINDOW),
1776 EndContainer(),
1777 EndContainer(),
1778 NWidget(NWID_VERTICAL),
1779 NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize),
1780 NWidget(WWT_PUSHTXTBTN, GAME_OPTIONS_BUTTON, WID_GO_BASE_MUSIC_OPEN_URL), SetResize(1, 0), SetFill(1, 0), SetStringTip(STR_CONTENT_OPEN_URL, STR_CONTENT_OPEN_URL_TOOLTIP),
1781 NWidget(WWT_PUSHTXTBTN, GAME_OPTIONS_BUTTON, WID_GO_BASE_MUSIC_TEXTFILE + TFT_README), SetFill(1, 0), SetResize(1, 0), SetStringTip(STR_TEXTFILE_VIEW_README, STR_TEXTFILE_VIEW_README_TOOLTIP),
1782 EndContainer(),
1783 NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize),
1784 NWidget(WWT_PUSHTXTBTN, GAME_OPTIONS_BUTTON, WID_GO_BASE_MUSIC_TEXTFILE + TFT_CHANGELOG), SetFill(1, 0), SetResize(1, 0), SetStringTip(STR_TEXTFILE_VIEW_CHANGELOG, STR_TEXTFILE_VIEW_CHANGELOG_TOOLTIP),
1785 NWidget(WWT_PUSHTXTBTN, GAME_OPTIONS_BUTTON, WID_GO_BASE_MUSIC_TEXTFILE + TFT_LICENSE), SetFill(1, 0), SetResize(1, 0), SetStringTip(STR_TEXTFILE_VIEW_LICENCE, STR_TEXTFILE_VIEW_LICENCE_TOOLTIP),
1786 EndContainer(),
1787 EndContainer(),
1788 EndContainer(),
1789 EndContainer(),
1790 NWidget(NWID_SPACER), SetFill(1, 1), SetResize(1, 1), // Allows this pane to resize
1791 EndContainer(),
1792
1793 /* Social tab */
1794 NWidget(NWID_VERTICAL), SetPadding(WidgetDimensions::unscaled.sparse_resize),
1795 NWidgetFunction(MakeNWidgetSocialPlugins),
1796 NWidget(NWID_SPACER), SetFill(1, 1), SetResize(1, 1), // Allows this pane to resize
1797 EndContainer(),
1798
1799 /* Advanced settings tab */
1800 NWidget(NWID_VERTICAL), SetPadding(WidgetDimensions::unscaled.sparse_resize), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
1801 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0),
1802 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
1803 NWidget(WWT_TEXT, INVALID_COLOUR, WID_GO_RESTRICT_CATEGORY), SetStringTip(STR_CONFIG_SETTING_RESTRICT_CATEGORY), SetTextStyle(GAME_OPTIONS_LABEL),
1804 NWidget(WWT_DROPDOWN, GAME_OPTIONS_BUTTON, WID_GO_RESTRICT_DROPDOWN), SetToolTip(STR_CONFIG_SETTING_RESTRICT_DROPDOWN_HELPTEXT), SetFill(1, 0), SetResize(1, 0),
1805 EndContainer(),
1806 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
1807 NWidget(WWT_TEXT, INVALID_COLOUR, WID_GO_RESTRICT_TYPE), SetStringTip(STR_CONFIG_SETTING_RESTRICT_TYPE), SetTextStyle(GAME_OPTIONS_LABEL),
1808 NWidget(WWT_DROPDOWN, GAME_OPTIONS_BUTTON, WID_GO_TYPE_DROPDOWN), SetToolTip(STR_CONFIG_SETTING_TYPE_DROPDOWN_HELPTEXT), SetFill(1, 0), SetResize(1, 0),
1809 EndContainer(),
1810 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
1811 NWidget(WWT_TEXT, INVALID_COLOUR), SetFill(0, 1), SetStringTip(STR_CONFIG_SETTING_FILTER_TITLE), SetTextStyle(GAME_OPTIONS_LABEL),
1812 NWidget(WWT_EDITBOX, GAME_OPTIONS_BACKGROUND, WID_GO_FILTER), SetStringTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
1813 EndContainer(),
1814 EndContainer(),
1815
1816 NWidget(NWID_HORIZONTAL),
1817 NWidget(WWT_PANEL, GAME_OPTIONS_BACKGROUND, WID_GO_OPTIONSPANEL), SetFill(1, 1), SetResize(1, 1), SetScrollbar(WID_GO_SCROLLBAR),
1818 EndContainer(),
1819 NWidget(NWID_VSCROLLBAR, GAME_OPTIONS_BACKGROUND, WID_GO_SCROLLBAR),
1820 EndContainer(),
1821
1822 NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize),
1823 NWidget(WWT_PUSHTXTBTN, GAME_OPTIONS_BUTTON, WID_GO_EXPAND_ALL), SetStringTip(STR_CONFIG_SETTING_EXPAND_ALL), SetFill(1, 0), SetResize(1, 0),
1824 NWidget(WWT_PUSHTXTBTN, GAME_OPTIONS_BUTTON, WID_GO_COLLAPSE_ALL), SetStringTip(STR_CONFIG_SETTING_COLLAPSE_ALL), SetFill(1, 0), SetResize(1, 0),
1825 NWidget(WWT_PUSHTXTBTN, GAME_OPTIONS_BUTTON, WID_GO_RESET_ALL), SetStringTip(STR_CONFIG_SETTING_RESET_ALL), SetFill(1, 0), SetResize(1, 0),
1826 EndContainer(),
1827
1828 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GO_SETTING_PROPERTIES), SetFill(1, 0), SetResize(1, 0),
1829 NWidget(NWID_HORIZONTAL),
1830 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GO_HELP_TEXT), SetFill(1, 0), SetResize(1, 0), SetScrollbar(WID_GO_HELP_TEXT_SCROLL),
1831 NWidget(NWID_VSCROLLBAR, GAME_OPTIONS_BACKGROUND, WID_GO_HELP_TEXT_SCROLL),
1832 EndContainer(),
1833 EndContainer(),
1834 EndContainer(),
1835
1836 NWidget(NWID_HORIZONTAL),
1837 NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0),
1838 NWidget(WWT_RESIZEBOX, GAME_OPTIONS_BACKGROUND), SetResizeWidgetTypeTip(RWV_HIDE_BEVEL, STR_TOOLTIP_RESIZE),
1839 EndContainer(),
1840 EndContainer(),
1841};
1842
1843static WindowDesc _game_options_desc(
1844 WDP_CENTER, "game_options", 0, 0,
1845 WC_GAME_OPTIONS, WC_NONE,
1846 {},
1847 _nested_game_options_widgets
1848);
1849
1851 void ShowGameOptions()
1852{
1853 CloseWindowByClass(WC_GAME_OPTIONS);
1854 new GameOptionsWindow(_game_options_desc);
1855}
1856
1866 void DrawArrowButtons(int x, int y, Colours button_colour, uint8_t state, bool clickable_left, bool clickable_right)
1867{
1868 PixelColour colour = GetColourGradient(button_colour, SHADE_DARKER);
1869 Dimension dim = NWidgetScrollbar::GetHorizontalDimension();
1870
1871 Rect lr = {x, y, x + (int)dim.width - 1, y + (int)dim.height - 1};
1872 Rect rr = {x + (int)dim.width, y, x + (int)dim.width * 2 - 1, y + (int)dim.height - 1};
1873
1874 DrawFrameRect(lr, button_colour, (state == 1) ? FrameFlag::Lowered : FrameFlags{});
1875 DrawFrameRect(rr, button_colour, (state == 2) ? FrameFlag::Lowered : FrameFlags{});
1876 DrawSpriteIgnorePadding(SPR_ARROW_LEFT, PAL_NONE, lr, SA_CENTER);
1877 DrawSpriteIgnorePadding(SPR_ARROW_RIGHT, PAL_NONE, rr, SA_CENTER);
1878
1879 /* Grey out the buttons that aren't clickable */
1880 bool rtl = _current_text_dir == TD_RTL;
1881 if (rtl ? !clickable_right : !clickable_left) {
1882 GfxFillRect(lr.Shrink(WidgetDimensions::scaled.bevel), colour, FILLRECT_CHECKER);
1883 }
1884 if (rtl ? !clickable_left : !clickable_right) {
1885 GfxFillRect(rr.Shrink(WidgetDimensions::scaled.bevel), colour, FILLRECT_CHECKER);
1886 }
1887}
1888
1898 void DrawUpDownButtons(int x, int y, Colours button_colour, uint8_t state, bool clickable_up, bool clickable_down)
1899{
1900 PixelColour colour = GetColourGradient(button_colour, SHADE_DARKER);
1901
1902 Rect r = {x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1};
1903 Rect ur = r.WithWidth(SETTING_BUTTON_WIDTH / 2, (_current_text_dir == TD_RTL));
1904 Rect dr = r.WithWidth(SETTING_BUTTON_WIDTH / 2, (_current_text_dir != TD_RTL));
1905
1906 DrawFrameRect(ur, button_colour, (state == 1) ? FrameFlag::Lowered : FrameFlags{});
1907 DrawFrameRect(dr, button_colour, (state == 2) ? FrameFlag::Lowered : FrameFlags{});
1908 DrawSpriteIgnorePadding(SPR_ARROW_UP, PAL_NONE, ur, SA_CENTER);
1909 DrawSpriteIgnorePadding(SPR_ARROW_DOWN, PAL_NONE, dr, SA_CENTER);
1910
1911 /* Grey out the buttons that aren't clickable */
1912 if (!clickable_up) GfxFillRect(ur.Shrink(WidgetDimensions::scaled.bevel), colour, FILLRECT_CHECKER);
1913 if (!clickable_down) GfxFillRect(dr.Shrink(WidgetDimensions::scaled.bevel), colour, FILLRECT_CHECKER);
1914}
1915
1924 void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
1925{
1926 PixelColour colour = GetColourGradient(button_colour, SHADE_DARKER);
1927
1928 Rect r = {x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1};
1929
1930 DrawFrameRect(r, button_colour, state ? FrameFlag::Lowered : FrameFlags{});
1931 DrawSpriteIgnorePadding(SPR_ARROW_DOWN, PAL_NONE, r, SA_CENTER);
1932
1933 if (!clickable) {
1934 GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), colour, FILLRECT_CHECKER);
1935 }
1936}
1937
1947 void DrawBoolButton(int x, int y, Colours button_colour, Colours background, bool state, bool clickable)
1948{
1949 Rect r = {x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1};
1950 DrawFrameRect(r, state ? COLOUR_GREEN : background, state ? FrameFlags{FrameFlag::Lowered} : FrameFlags{FrameFlag::Lowered, FrameFlag::BorderOnly});
1951 if (!clickable) {
1952 GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(state ? COLOUR_GREEN : background, SHADE_DARKER), FILLRECT_CHECKER);
1953 }
1954
1955 Rect button_rect = r.WithWidth(SETTING_BUTTON_WIDTH / 3, state ^ (_current_text_dir == TD_RTL));
1956 DrawFrameRect(button_rect, button_colour, {});
1957 if (!clickable) {
1958 GfxFillRect(button_rect.Shrink(WidgetDimensions::scaled.bevel), GetColourGradient(button_colour, SHADE_DARKER), FILLRECT_CHECKER);
1959 }
1960}
1961
1962 struct CustomCurrencyWindow : Window {
1963 WidgetID query_widget{};
1964
1965 CustomCurrencyWindow(WindowDesc &desc) : Window(desc)
1966 {
1967 this->InitNested();
1968
1969 SetButtonState();
1970 }
1971
1972 void SetButtonState()
1973 {
1974 this->SetWidgetDisabledState(WID_CC_RATE_DOWN, GetCustomCurrency().rate == 1);
1975 this->SetWidgetDisabledState(WID_CC_RATE_UP, GetCustomCurrency().rate == UINT16_MAX);
1976 this->SetWidgetDisabledState(WID_CC_YEAR_DOWN, GetCustomCurrency().to_euro == CF_NOEURO);
1977 this->SetWidgetDisabledState(WID_CC_YEAR_UP, GetCustomCurrency().to_euro == CalendarTime::MAX_YEAR);
1978 }
1979
1980 std::string GetWidgetString(WidgetID widget, StringID stringid) const override
1981 {
1982 switch (widget) {
1983 case WID_CC_RATE: return GetString(STR_CURRENCY_EXCHANGE_RATE, 1, 1);
1984 case WID_CC_SEPARATOR: return GetString(STR_CURRENCY_SEPARATOR, GetCustomCurrency().separator);
1985 case WID_CC_PREFIX: return GetString(STR_CURRENCY_PREFIX, GetCustomCurrency().prefix);
1986 case WID_CC_SUFFIX: return GetString(STR_CURRENCY_SUFFIX, GetCustomCurrency().suffix);
1987 case WID_CC_YEAR:
1988 return GetString((GetCustomCurrency().to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER, GetCustomCurrency().to_euro);
1989
1990 case WID_CC_PREVIEW:
1991 return GetString(STR_CURRENCY_PREVIEW, 10000);
1992
1993 default:
1994 return this->Window::GetWidgetString(widget, stringid);
1995 }
1996 }
1997
1998 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
1999 {
2000 switch (widget) {
2001 /* Set the appropriate width for the up/down buttons. */
2002 case WID_CC_RATE_DOWN:
2003 case WID_CC_RATE_UP:
2004 case WID_CC_YEAR_DOWN:
2005 case WID_CC_YEAR_UP:
2006 size = maxdim(size, {(uint)SETTING_BUTTON_WIDTH / 2, (uint)SETTING_BUTTON_HEIGHT});
2007 break;
2008
2009 /* Set the appropriate width for the edit buttons. */
2010 case WID_CC_SEPARATOR_EDIT:
2011 case WID_CC_PREFIX_EDIT:
2012 case WID_CC_SUFFIX_EDIT:
2013 size = maxdim(size, {(uint)SETTING_BUTTON_WIDTH, (uint)SETTING_BUTTON_HEIGHT});
2014 break;
2015
2016 /* Make sure the window is wide enough for the widest exchange rate */
2017 case WID_CC_RATE:
2018 size = GetStringBoundingBox(GetString(STR_CURRENCY_EXCHANGE_RATE, 1, INT32_MAX));
2019 break;
2020 }
2021 }
2022
2023 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
2024 {
2025 int line = 0;
2026 int len = 0;
2027 std::string str;
2028 CharSetFilter afilter = CS_ALPHANUMERAL;
2029
2030 switch (widget) {
2031 case WID_CC_RATE_DOWN:
2032 if (GetCustomCurrency().rate > 1) GetCustomCurrency().rate--;
2033 if (GetCustomCurrency().rate == 1) this->DisableWidget(WID_CC_RATE_DOWN);
2034 this->EnableWidget(WID_CC_RATE_UP);
2035 break;
2036
2037 case WID_CC_RATE_UP:
2038 if (GetCustomCurrency().rate < UINT16_MAX) GetCustomCurrency().rate++;
2039 if (GetCustomCurrency().rate == UINT16_MAX) this->DisableWidget(WID_CC_RATE_UP);
2040 this->EnableWidget(WID_CC_RATE_DOWN);
2041 break;
2042
2043 case WID_CC_RATE:
2044 str = GetString(STR_JUST_INT, GetCustomCurrency().rate);
2045 len = 5;
2046 line = WID_CC_RATE;
2047 afilter = CS_NUMERAL;
2048 break;
2049
2050 case WID_CC_SEPARATOR_EDIT:
2051 case WID_CC_SEPARATOR:
2052 str = GetCustomCurrency().separator;
2053 len = 7;
2054 line = WID_CC_SEPARATOR;
2055 break;
2056
2057 case WID_CC_PREFIX_EDIT:
2058 case WID_CC_PREFIX:
2059 str = GetCustomCurrency().prefix;
2060 len = 15;
2061 line = WID_CC_PREFIX;
2062 break;
2063
2064 case WID_CC_SUFFIX_EDIT:
2065 case WID_CC_SUFFIX:
2066 str = GetCustomCurrency().suffix;
2067 len = 15;
2068 line = WID_CC_SUFFIX;
2069 break;
2070
2071 case WID_CC_YEAR_DOWN:
2072 GetCustomCurrency().to_euro = (GetCustomCurrency().to_euro <= MIN_EURO_YEAR) ? CF_NOEURO : GetCustomCurrency().to_euro - 1;
2073 if (GetCustomCurrency().to_euro == CF_NOEURO) this->DisableWidget(WID_CC_YEAR_DOWN);
2074 this->EnableWidget(WID_CC_YEAR_UP);
2075 break;
2076
2077 case WID_CC_YEAR_UP:
2078 GetCustomCurrency().to_euro = Clamp(GetCustomCurrency().to_euro + 1, MIN_EURO_YEAR, CalendarTime::MAX_YEAR);
2079 if (GetCustomCurrency().to_euro == CalendarTime::MAX_YEAR) this->DisableWidget(WID_CC_YEAR_UP);
2080 this->EnableWidget(WID_CC_YEAR_DOWN);
2081 break;
2082
2083 case WID_CC_YEAR:
2084 str = GetString(STR_JUST_INT, GetCustomCurrency().to_euro);
2085 len = 7;
2086 line = WID_CC_YEAR;
2087 afilter = CS_NUMERAL;
2088 break;
2089 }
2090
2091 if (len != 0) {
2092 this->query_widget = line;
2093 ShowQueryString(str, STR_CURRENCY_CHANGE_PARAMETER, len + 1, this, afilter, {});
2094 }
2095
2096 this->SetTimeout();
2097 this->SetDirty();
2098 }
2099
2100 void OnQueryTextFinished(std::optional<std::string> str) override
2101 {
2102 if (!str.has_value()) return;
2103
2104 switch (this->query_widget) {
2105 case WID_CC_RATE: {
2106 auto val = ParseInteger(*str, 10, true);
2107 if (!val.has_value()) return;
2108 GetCustomCurrency().rate = Clamp(*val, 1, UINT16_MAX);
2109 break;
2110 }
2111
2112 case WID_CC_SEPARATOR: // Thousands separator
2113 GetCustomCurrency().separator = std::move(*str);
2114 break;
2115
2116 case WID_CC_PREFIX:
2117 GetCustomCurrency().prefix = std::move(*str);
2118 break;
2119
2120 case WID_CC_SUFFIX:
2121 GetCustomCurrency().suffix = std::move(*str);
2122 break;
2123
2124 case WID_CC_YEAR: { // Year to switch to euro
2125 TimerGameCalendar::Year year = CF_NOEURO;
2126 if (!str->empty()) {
2127 auto val = ParseInteger(*str, 10, true);
2128 if (!val.has_value()) return;
2129 year = Clamp(static_cast<TimerGameCalendar::Year>(*val), MIN_EURO_YEAR, CalendarTime::MAX_YEAR);
2130 }
2131 GetCustomCurrency().to_euro = year;
2132 break;
2133 }
2134 }
2135 MarkWholeScreenDirty();
2136 SetButtonState();
2137 }
2138
2139 void OnTimeout() override
2140 {
2141 this->SetDirty();
2142 }
2143};
2144
2145static constexpr std::initializer_list<NWidgetPart> _nested_cust_currency_widgets = {
2146 NWidget(NWID_HORIZONTAL),
2147 NWidget(WWT_CLOSEBOX, COLOUR_GREY),
2148 NWidget(WWT_CAPTION, COLOUR_GREY), SetStringTip(STR_CURRENCY_WINDOW, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
2149 EndContainer(),
2150 NWidget(WWT_PANEL, COLOUR_GREY),
2151 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0), SetPadding(WidgetDimensions::unscaled.sparse),
2152 NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0),
2153 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
2154 NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize),
2155 NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_RATE_DOWN), SetArrowWidgetTypeTip(AWV_DECREASE, STR_CURRENCY_DECREASE_EXCHANGE_RATE_TOOLTIP),
2156 NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_RATE_UP), SetArrowWidgetTypeTip(AWV_INCREASE, STR_CURRENCY_INCREASE_EXCHANGE_RATE_TOOLTIP),
2157 EndContainer(),
2158 NWidget(WWT_TEXT, INVALID_COLOUR, WID_CC_RATE), SetToolTip(STR_CURRENCY_SET_EXCHANGE_RATE_TOOLTIP), SetFill(1, 0),
2159 EndContainer(),
2160 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
2161 NWidget(WWT_PUSHBTN, COLOUR_DARK_BLUE, WID_CC_SEPARATOR_EDIT), SetToolTip(STR_CURRENCY_SET_CUSTOM_CURRENCY_SEPARATOR_TOOLTIP), SetFill(0, 1),
2162 NWidget(WWT_TEXT, INVALID_COLOUR, WID_CC_SEPARATOR), SetToolTip(STR_CURRENCY_SET_CUSTOM_CURRENCY_SEPARATOR_TOOLTIP), SetFill(1, 0),
2163 EndContainer(),
2164 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
2165 NWidget(WWT_PUSHBTN, COLOUR_DARK_BLUE, WID_CC_PREFIX_EDIT), SetToolTip(STR_CURRENCY_SET_CUSTOM_CURRENCY_PREFIX_TOOLTIP), SetFill(0, 1),
2166 NWidget(WWT_TEXT, INVALID_COLOUR, WID_CC_PREFIX), SetToolTip(STR_CURRENCY_SET_CUSTOM_CURRENCY_PREFIX_TOOLTIP), SetFill(1, 0),
2167 EndContainer(),
2168 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
2169 NWidget(WWT_PUSHBTN, COLOUR_DARK_BLUE, WID_CC_SUFFIX_EDIT), SetToolTip(STR_CURRENCY_SET_CUSTOM_CURRENCY_SUFFIX_TOOLTIP), SetFill(0, 1),
2170 NWidget(WWT_TEXT, INVALID_COLOUR, WID_CC_SUFFIX), SetToolTip(STR_CURRENCY_SET_CUSTOM_CURRENCY_SUFFIX_TOOLTIP), SetFill(1, 0),
2171 EndContainer(),
2172 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
2173 NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize),
2174 NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_YEAR_DOWN), SetArrowWidgetTypeTip(AWV_DECREASE, STR_CURRENCY_DECREASE_CUSTOM_CURRENCY_TO_EURO_TOOLTIP),
2175 NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_YEAR_UP), SetArrowWidgetTypeTip(AWV_INCREASE, STR_CURRENCY_INCREASE_CUSTOM_CURRENCY_TO_EURO_TOOLTIP),
2176 EndContainer(),
2177 NWidget(WWT_TEXT, INVALID_COLOUR, WID_CC_YEAR), SetToolTip(STR_CURRENCY_SET_CUSTOM_CURRENCY_TO_EURO_TOOLTIP), SetFill(1, 0),
2178 EndContainer(),
2179 EndContainer(),
2180 NWidget(WWT_LABEL, INVALID_COLOUR, WID_CC_PREVIEW),
2181 SetToolTip(STR_CURRENCY_CUSTOM_CURRENCY_PREVIEW_TOOLTIP),
2182 EndContainer(),
2183 EndContainer(),
2184};
2185
2186static WindowDesc _cust_currency_desc(
2187 WDP_CENTER, {}, 0, 0,
2188 WC_CUSTOM_CURRENCY, WC_NONE,
2189 {},
2190 _nested_cust_currency_widgets
2191);
2192
2194 static void ShowCustCurrency()
2195{
2196 CloseWindowById(WC_CUSTOM_CURRENCY, 0);
2197 new CustomCurrencyWindow(_cust_currency_desc);
2198}
UpdateAllVirtCoords
void UpdateAllVirtCoords()
Update the viewport coordinates of all signs.
Definition afterload.cpp:220
ai.hpp
Base functions for all AIs.
base_media_base.h
Generic functions for replacing base data (graphics, sounds).
base_media_graphics.h
Generic functions for replacing base graphics data.
base_media_music.h
Generic functions for replacing base music data.
base_media_sounds.h
Generic functions for replacing base sounds data.
HasBit
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Definition bitmath_func.hpp:103
BaseBitSet::Test
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
Definition base_bitset_type.hpp:141
BaseMedia< GraphicsSet >::GetUsedSet
static const GraphicsSet * GetUsedSet()
Return the used set.
Definition base_media_func.h:400
BaseMedia< GraphicsSet >::GetNumSets
static int GetNumSets()
Count the number of available graphics sets.
Definition base_media_func.h:357
BaseMedia< GraphicsSet >::GetSet
static const GraphicsSet * GetSet(int index)
Get the name of the graphics set at the specified index.
Definition base_media_func.h:385
BaseMedia< GraphicsSet >::SetSet
static bool SetSet(const GraphicsSet *set)
Set the set to be used.
Definition base_media_func.h:250
DropDownString< DropDownListItem >::NatSortFunc
static bool NatSortFunc(std::unique_ptr< const DropDownListItem > const &first, std::unique_ptr< const DropDownListItem > const &second)
Natural sorting comparator function for DropDownList::sort().
Definition dropdown_common_type.h:99
EnumBitSet
Enum-as-bit-set wrapper.
Definition enum_type.hpp:177
FontCache::ClearFontCaches
static void ClearFontCaches(FontSizes fontsizes)
Clear cached information for the specified font caches.
Definition fontcache.cpp:257
FontCache::LoadFontCaches
static void LoadFontCaches(FontSizes fontsizes)
(Re)initialize the font cache related things, i.e.
Definition fontcache.cpp:237
MusicDriver::GetInstance
static MusicDriver * GetInstance()
Get the currently active instance of the music driver.
Definition music_driver.hpp:46
MusicDriver::SetVolume
virtual void SetVolume(uint8_t vol)=0
Set the volume, if possible.
NWidgetBase
Baseclass for nested widgets.
Definition widget_type.h:137
NWidgetBase::current_x
uint current_x
Current horizontal size (after resizing).
Definition widget_type.h:238
NWidgetBase::pos_y
int pos_y
Vertical position of top-left corner of the widget in the window.
Definition widget_type.h:244
NWidgetBase::pos_x
int pos_x
Horizontal position of top-left corner of the widget in the window.
Definition widget_type.h:243
NWidgetBase::resize_y
uint resize_y
Vertical resize step (0 means not resizable).
Definition widget_type.h:231
NWidgetContainer::Add
void Add(std::unique_ptr< NWidgetBase > &&wid)
Append widget wid to container.
Definition widget.cpp:1320
NWidgetContainer::children
std::vector< std::unique_ptr< NWidgetBase > > children
Child widgets in container.
Definition widget_type.h:502
NWidgetPIPContainer::SetPIP
void SetPIP(uint8_t pip_pre, uint8_t pip_inter, uint8_t pip_post)
Set additional pre/inter/post space for the container.
Definition widget.cpp:1536
NWidgetResizeBase
Base class for a resizable nested widget.
Definition widget_type.h:300
NWidgetResizeBase::UpdateVerticalSize
bool UpdateVerticalSize(uint min_y)
Set absolute (post-scaling) minimal size of the widget.
Definition widget.cpp:1148
NWidgetSocialPlugins
Definition settings_gui.cpp:226
NWidgetSocialPlugins::Draw
void Draw(const Window *w) override
Draw the widgets of the tree.
Definition settings_gui.cpp:343
NWidgetSocialPlugins::SetupSmallestSize
void SetupSmallestSize(Window *w) override
Compute smallest size needed by the widget.
Definition settings_gui.cpp:245
NWidgetSocialPlugins::GetWidestPlugin
std::string & GetWidestPlugin(T SocialIntegrationPlugin::*member) const
Find of all the plugins the one where the member is the widest (in pixels).
Definition settings_gui.cpp:258
NWidgetVertical
Vertical container.
Definition widget_type.h:601
NWidgetVertical::SetupSmallestSize
void SetupSmallestSize(Window *w) override
Compute smallest size needed by the widget.
Definition widget.cpp:1746
Scrollbar
Scrollbar data structure.
Definition widget_type.h:711
Scrollbar::GetCapacity
size_type GetCapacity() const
Gets the number of visible elements of the scrollbar.
Definition widget_type.h:746
Scrollbar::SetCount
void SetCount(size_t num)
Sets the number of elements in the list.
Definition widget_type.h:795
Scrollbar::SetCapacity
void SetCapacity(size_t capacity)
Set the capacity of visible elements.
Definition widget_type.h:809
Scrollbar::GetScrolledRowFromWidget
size_type GetScrolledRowFromWidget(int clickpos, const Window *const w, WidgetID widget, int padding=0, int line_height=-1) const
Compute the row of a scrolled widget that a user clicked in.
Definition widget.cpp:2453
Scrollbar::SetCapacityFromWidget
void SetCapacityFromWidget(Window *w, WidgetID widget, int padding=0)
Set capacity of visible elements from the size and resize properties of a widget.
Definition widget.cpp:2527
Scrollbar::GetCount
size_type GetCount() const
Gets the number of elements in the list.
Definition widget_type.h:737
Scrollbar::GetPosition
size_type GetPosition() const
Gets the position of the first visible element in the list.
Definition widget_type.h:755
SocialIntegrationPlugin
Definition social_integration.h:13
SocialIntegrationPlugin::social_platform
std::string social_platform
Social platform this plugin is for.
Definition social_integration.h:28
SocialIntegrationPlugin::name
std::string name
Name of the plugin.
Definition social_integration.h:29
SocialIntegrationPlugin::version
std::string version
Version of the plugin.
Definition social_integration.h:30
SocialIntegrationPlugin::PLATFORM_NOT_RUNNING
@ PLATFORM_NOT_RUNNING
The plugin failed to initialize because the Social Platform is not running.
Definition social_integration.h:19
SocialIntegrationPlugin::UNSUPPORTED_API
@ UNSUPPORTED_API
The plugin does not support the current API version.
Definition social_integration.h:22
SocialIntegrationPlugin::RUNNING
@ RUNNING
The plugin is successfully loaded and running.
Definition social_integration.h:16
SocialIntegrationPlugin::FAILED
@ FAILED
The plugin failed to initialize.
Definition social_integration.h:18
SocialIntegrationPlugin::DUPLICATE
@ DUPLICATE
Another plugin of the same Social Platform is already loaded.
Definition social_integration.h:21
SocialIntegrationPlugin::INVALID_SIGNATURE
@ INVALID_SIGNATURE
The signature of the plugin is invalid.
Definition social_integration.h:23
SocialIntegrationPlugin::UNLOADED
@ UNLOADED
The plugin is unloaded upon request.
Definition social_integration.h:20
SocialIntegration::GetPlugins
static std::vector< SocialIntegrationPlugin * > GetPlugins()
Get the list of loaded social integration plugins.
Definition social_integration.cpp:149
TimerGameConst< struct Calendar >::MAX_YEAR
static constexpr TimerGame< struct Calendar >::Year MAX_YEAR
MAX_YEAR, nicely rounded value of the number of years that can be encoded in a single 32 bits date,...
Definition timer_game_common.h:173
VideoDriver::ToggleVsync
virtual void ToggleVsync(bool vsync)
Change the vsync setting.
Definition video_driver.hpp:75
VideoDriver::GetInstance
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
Definition video_driver.hpp:192
VideoDriver::GetListOfMonitorRefreshRates
virtual std::vector< int > GetListOfMonitorRefreshRates()
Get a list of refresh rates of each available monitor.
Definition video_driver.hpp:164
WidgetDimensions::framerect
RectPadding framerect
Standard padding inside many panels.
Definition window_gui.h:40
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition window_gui.h:30
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition window_gui.h:93
WidgetDimensions::bevel
RectPadding bevel
Bevel thickness, affected by "scaled bevels" game option.
Definition window_gui.h:38
WidgetDimensions::hsep_indent
int hsep_indent
Width of indentation for tree layouts.
Definition window_gui.h:63
command_func.h
Functions related to commands.
company_base.h
Definition of stuff that is very close to a company, like the company struct itself.
company_func.h
Functions related to companies.
config.h
Configuration options of the network stuff.
NETWORK_SURVEY_DETAILS_LINK
static const std::string NETWORK_SURVEY_DETAILS_LINK
Link with more details & privacy statement of the survey.
Definition config.h:30
_currency_specs
std::array< CurrencySpec, CURRENCY_END > _currency_specs
Array of currencies used by the system.
Definition currency.cpp:80
currency.h
Functions to handle different currencies.
MIN_EURO_YEAR
static constexpr TimerGameCalendar::Year MIN_EURO_YEAR
The earliest year custom currencies may switch to the Euro.
Definition currency.h:19
CURRENCY_CUSTOM
@ CURRENCY_CUSTOM
Custom currency.
Definition currency.h:58
GetCustomCurrency
CurrencySpec & GetCustomCurrency()
Get the custom currency.
Definition currency.h:110
CF_NOEURO
static constexpr TimerGameCalendar::Year CF_NOEURO
Currency never switches to the Euro (as far as known).
Definition currency.h:17
GetCurrency
const CurrencySpec & GetCurrency()
Get the currently selected currency.
Definition currency.h:119
_resolutions
std::vector< Dimension > _resolutions
List of resolutions.
Definition driver.cpp:28
ShowDropDownListAt
void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, WidgetID button, Rect wi_rect, Colours wi_colour, DropDownOptions options)
Show a drop down list.
Definition dropdown.cpp:402
GetDropDownListDimension
Dimension GetDropDownListDimension(const DropDownList &list)
Determine width and height required to fully display a DropDownList.
Definition dropdown.cpp:381
ShowDropDownList
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, DropDownOptions options)
Show a drop down list.
Definition dropdown.cpp:418
dropdown_common_type.h
Common drop down list components.
dropdown_func.h
Functions related to the drop down widget.
dropdown_type.h
Types related to the drop down widget.
DropDownList
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
Definition dropdown_type.h:56
error.h
Functions related to errors.
WL_ERROR
@ WL_ERROR
Errors (eg. saving/loading failed)
Definition error.h:26
WL_INFO
@ WL_INFO
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
Definition error.h:24
ShowErrorMessage
void ShowErrorMessage(EncodedString &&summary_msg, int x, int y, CommandCost &cc)
Display an error message in a window.
Definition error_gui.cpp:296
factory.hpp
Factory to 'query' all available blitters.
BASESET_DIR
@ BASESET_DIR
Subdirectory for all base data (base sets, intro game)
Definition fileio_type.h:96
GetCharacterHeight
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition fontcache.cpp:87
fontcache.h
Functions to read fonts from files and cache them.
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition geometry_func.cpp:22
geometry_func.hpp
Geometry functions.
GetStringHeight
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Definition gfx.cpp:715
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition gfx.cpp:968
GetStringLineCount
int GetStringLineCount(std::string_view str, int maxw)
Calculates number of lines of string.
Definition gfx.cpp:739
_left_button_down
bool _left_button_down
Is left mouse button pressed?
Definition gfx.cpp:41
GetStringBoundingBox
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition gfx.cpp:897
DrawString
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition gfx.cpp:668
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition gfx.cpp:38
_left_button_clicked
bool _left_button_clicked
Is left mouse button clicked?
Definition gfx.cpp:42
_gui_scale_cfg
int _gui_scale_cfg
GUI scale in config.
Definition gfx.cpp:64
DrawStringMultiLineWithClipping
bool DrawStringMultiLineWithClipping(int left, int right, int top, int bottom, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw a multiline string, possibly over multiple lines, if the region is within the current display cl...
Definition gfx.cpp:870
DrawStringMultiLine
int DrawStringMultiLine(int left, int right, int top, int bottom, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
Definition gfx.cpp:785
GfxFillRect
void GfxFillRect(int left, int top, int right, int bottom, const std::variant< PixelColour, PaletteID > &colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
Definition gfx.cpp:115
_switch_mode
SwitchMode _switch_mode
The next mainloop command.
Definition gfx.cpp:49
FillDrawPixelInfo
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
Definition gfx.cpp:1568
AdjustGUIZoom
bool AdjustGUIZoom(bool automatic)
Resolve GUI zoom level and adjust GUI to new zoom, if auto-suggestion is requested.
Definition gfx.cpp:1818
_gui_scale
int _gui_scale
GUI scale, 100 is 100%.
Definition gfx.cpp:63
CheckBlitter
void CheckBlitter()
Check whether we still use the right blitter, or use another (better) one.
Definition gfxinit.cpp:325
FS_SMALL
@ FS_SMALL
Index of the small font in the font tables.
Definition gfx_type.h:250
FS_NORMAL
@ FS_NORMAL
Index of the normal font in the font tables.
Definition gfx_type.h:249
SA_RIGHT
@ SA_RIGHT
Right align the text (must be a single bit).
Definition gfx_type.h:390
SA_CENTER
@ SA_CENTER
Center both horizontally and vertically.
Definition gfx_type.h:398
FONTSIZES_ALL
constexpr FontSizes FONTSIZES_ALL
Mask of all possible font sizes.
Definition gfx_type.h:262
TextColour
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition gfx_type.h:307
FILLRECT_CHECKER
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
Definition gfx_type.h:346
NWidgetFunction
constexpr NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
Obtain a nested widget (sub)tree from an external source.
Definition widget_type.h:1448
SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition widget_type.h:1222
SetSpriteTip
constexpr NWidgetPart SetSpriteTip(SpriteID sprite, StringID tip={})
Widget part function for setting the sprite and tooltip.
Definition widget_type.h:1254
SetToolbarMinimalSize
constexpr NWidgetPart SetToolbarMinimalSize(int width)
Widget part function to setting the minimal size for a toolbar button.
Definition widget_type.h:1178
SetPIP
constexpr NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post)
Widget part function for setting a pre/inter/post spaces.
Definition widget_type.h:1378
SetScrollbar
constexpr NWidgetPart SetScrollbar(WidgetID index)
Attach a scrollbar to a widget.
Definition widget_type.h:1402
SetPadding
constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
Widget part function for setting additional space around a widget.
Definition widget_type.h:1335
SetAlternateColourTip
constexpr NWidgetPart SetAlternateColourTip(Colours colour, StringID tip)
Widget part function for setting the alternate colour and tooltip.
Definition widget_type.h:1299
SetStringTip
constexpr NWidgetPart SetStringTip(StringID string, StringID tip={})
Widget part function for setting the string and tooltip.
Definition widget_type.h:1243
SetTextStyle
constexpr NWidgetPart SetTextStyle(TextColour colour, FontSize size=FS_NORMAL)
Widget part function for setting the text style.
Definition widget_type.h:1201
SetResizeWidgetTypeTip
constexpr NWidgetPart SetResizeWidgetTypeTip(ResizeWidgetValues widget_type, StringID tip)
Widget part function for setting the resize widget type and tooltip.
Definition widget_type.h:1288
MakeNWidgets
std::unique_ptr< NWidgetBase > MakeNWidgets(std::span< const NWidgetPart > nwid_parts, std::unique_ptr< NWidgetBase > &&container)
Construct a nested widget tree from an array of parts.
Definition widget.cpp:3410
SetToolTip
constexpr NWidgetPart SetToolTip(StringID tip)
Widget part function for setting tooltip and clearing the widget data.
Definition widget_type.h:1321
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition widget_type.h:1232
SetArrowWidgetTypeTip
constexpr NWidgetPart SetArrowWidgetTypeTip(ArrowWidgetValues widget_type, StringID tip={})
Widget part function for setting the arrow widget type and tooltip.
Definition widget_type.h:1277
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=INVALID_WIDGET)
Widget part function for starting a new 'real' widget.
Definition widget_type.h:1427
SetMinimalTextLines
constexpr NWidgetPart SetMinimalTextLines(uint8_t lines, uint8_t spacing, FontSize size=FS_NORMAL)
Widget part function for setting the minimal text lines.
Definition widget_type.h:1190
SetAlignment
constexpr NWidgetPart SetAlignment(StringAlignment align)
Widget part function for setting the alignment of text/images.
Definition widget_type.h:1211
SetResize
constexpr NWidgetPart SetResize(int16_t dx, int16_t dy)
Widget part function for setting the resize step.
Definition widget_type.h:1148
SetPIPRatio
constexpr NWidgetPart SetPIPRatio(uint8_t ratio_pre, uint8_t ratio_inter, uint8_t ratio_post)
Widget part function for setting a pre/inter/post ratio.
Definition widget_type.h:1390
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition window.cpp:968
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition gfx.cpp:1549
gui.h
GUI functions that shouldn't be here.
highscore.h
Declaration of functions and types defined in highscore.h and highscore_gui.h.
language.h
Information about languages and their files.
_languages
LanguageList _languages
The actual list of language meta data.
Definition strings.cpp:53
_current_language
const LanguageMetadata * _current_language
The currently loaded language.
Definition strings.cpp:54
ReadLanguagePack
bool ReadLanguagePack(const LanguageMetadata *lang)
Read a particular language.
Definition strings.cpp:2048
CeilDiv
constexpr uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
Definition math_func.hpp:310
Clamp
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition math_func.hpp:79
ShowQuery
void ShowQuery(EncodedString &&caption, EncodedString &&message, Window *parent, QueryCallbackProc *callback, bool focus)
Show a confirmation window with standard 'yes' and 'no' buttons The window is aligned to the centre o...
Definition misc_gui.cpp:1204
ShowQueryString
void ShowQueryString(std::string_view str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
Definition misc_gui.cpp:1064
WID_TF_CAPTION
@ WID_TF_CAPTION
The caption of the window.
Definition misc_widget.h:53
mixer.h
Functions to mix sound samples.
music_driver.hpp
Base for all music playback.
ChangeMusicSet
void ChangeMusicSet(int index)
Change the configured music set and reset playback.
Definition music_gui.cpp:462
_network_available
bool _network_available
is network mode available?
Definition network.cpp:69
network.h
Basic functions/variables used all over the place.
network_content.h
Part of the network protocol handling content distribution.
ShowNetworkContentListWindow
void ShowNetworkContentListWindow(ContentVector *cv=nullptr, ContentType type1=CONTENT_TYPE_END, ContentType type2=CONTENT_TYPE_END)
Show the content list window with a given set of content.
Definition network_content_gui.cpp:1117
network_gui.h
GUIs related to networking.
network_survey.h
Part of the network protocol handling opt-in survey.
VehicleCallbackMask::Length
@ Length
Vehicle length (trains and road vehicles)
newgrf_config.h
Functions to find and configure NewGRFs.
ChangeAutosaveFrequency
void ChangeAutosaveFrequency(bool reset)
Reset the interval of the autosave.
Definition openttd.cpp:1314
SM_MENU
@ SM_MENU
Switch to game intro menu.
Definition openttd.h:33
GetColourGradient
PixelColour GetColourGradient(Colours colour, ColourShade shade)
Get colour gradient palette index.
Definition palette.cpp:388
querystring_gui.h
Base for the GUIs that have an edit box in them.
rev.h
declaration of OTTD revision dependent variables
safeguards.h
A number of safeguards to prevent using unsafe methods.
GetSettingsTree
SettingsContainer & GetSettingsTree()
Construct settings tree.
Definition settingentry_gui.cpp:619
settingentry_gui.h
Declarations of classes for handling display of individual configuration settings.
RestrictionMode
RestrictionMode
How the list of advanced settings is filtered.
Definition settingentry_gui.h:32
RM_CHANGED_AGAINST_DEFAULT
@ RM_CHANGED_AGAINST_DEFAULT
Show only settings which are different compared to default values.
Definition settingentry_gui.h:36
RM_ALL
@ RM_ALL
List all settings regardless of the default/newgame/... values.
Definition settingentry_gui.h:35
RM_CHANGED_AGAINST_NEW
@ RM_CHANGED_AGAINST_NEW
Show only settings which are different compared to the user's new game setting values.
Definition settingentry_gui.h:37
RM_END
@ RM_END
End for iteration.
Definition settingentry_gui.h:38
RM_BASIC
@ RM_BASIC
Display settings associated to the "basic" list.
Definition settingentry_gui.h:33
SettingEntryFlag
SettingEntryFlag
Flags for SettingEntry.
Definition settingentry_gui.h:21
SettingEntryFlag::LeftDepressed
@ LeftDepressed
Of a numeric setting entry, the left button is depressed.
SettingEntryFlag::RightDepressed
@ RightDepressed
Of a numeric setting entry, the right button is depressed.
SetSettingValue
bool SetSettingValue(const IntSettingDesc *sd, int32_t value, bool force_newgame)
Top function to save the new value of an element of the Settings struct.
Definition settings.cpp:1818
_settings_newgame
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
Definition settings.cpp:62
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition settings.cpp:60
GAME_OPTIONS_LABEL
static constexpr TextColour GAME_OPTIONS_LABEL
Colour for label text of game options.
Definition settings_gui.cpp:201
GAME_OPTIONS_BACKGROUND
static constexpr Colours GAME_OPTIONS_BACKGROUND
Colour for background of game options.
Definition settings_gui.cpp:195
WarnHiddenResult
WarnHiddenResult
Warnings about hidden search results.
Definition settings_gui.cpp:374
WHR_CATEGORY_TYPE
@ WHR_CATEGORY_TYPE
Both category and type settings filtered matches away.
Definition settings_gui.cpp:378
WHR_CATEGORY
@ WHR_CATEGORY
Category setting filtered matches away.
Definition settings_gui.cpp:376
WHR_NONE
@ WHR_NONE
Nothing was filtering matches away.
Definition settings_gui.cpp:375
WHR_TYPE
@ WHR_TYPE
Type setting filtered matches away.
Definition settings_gui.cpp:377
DrawArrowButtons
void DrawArrowButtons(int x, int y, Colours button_colour, uint8_t state, bool clickable_left, bool clickable_right)
Draw [<][>] boxes.
Definition settings_gui.cpp:1866
ResetAllSettingsConfirmationCallback
static void ResetAllSettingsConfirmationCallback(Window *w, bool confirmed)
Callback function for the reset all settings button.
Definition settings_gui.cpp:386
DrawBoolButton
void DrawBoolButton(int x, int y, Colours button_colour, Colours background, bool state, bool clickable)
Draw a toggle button.
Definition settings_gui.cpp:1947
DrawUpDownButtons
void DrawUpDownButtons(int x, int y, Colours button_colour, uint8_t state, bool clickable_up, bool clickable_down)
Draw [^][v] buttons.
Definition settings_gui.cpp:1898
ShowBaseSetTextfileWindow
void ShowBaseSetTextfileWindow(Window *parent, TextfileType file_type, const TBaseSet *baseset, StringID content_type)
Open the BaseSet version of the textfile window.
Definition settings_gui.cpp:127
_autosave_dropdown_to_minutes
static const uint32_t _autosave_dropdown_to_minutes[]
Available settings for autosave intervals.
Definition settings_gui.cpp:79
GetListLabel
static std::string GetListLabel(const TBaseSet *baseset)
Get string to use when listing this set in the settings window.
Definition settings_gui.cpp:140
AddCustomRefreshRates
static void AddCustomRefreshRates()
Add the refresh rate from the config and the refresh rates from all the monitors to our list of refre...
Definition settings_gui.cpp:164
MakeNWidgetSocialPlugins
std::unique_ptr< NWidgetBase > MakeNWidgetSocialPlugins()
Construct nested container widget for managing the list of social plugins.
Definition settings_gui.cpp:359
DrawDropDownButton
void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
Draw a dropdown button.
Definition settings_gui.cpp:1924
GAME_OPTIONS_FRAME
static constexpr TextColour GAME_OPTIONS_FRAME
Colour for frame text of game options.
Definition settings_gui.cpp:199
GetCurrentResolutionIndex
static uint GetCurrentResolutionIndex()
Get index of the current screen resolution.
Definition settings_gui.cpp:91
GAME_OPTIONS_BUTTON
static constexpr Colours GAME_OPTIONS_BUTTON
Colour for buttons of game options.
Definition settings_gui.cpp:197
ShowCustCurrency
static void ShowCustCurrency()
Open custom currency window.
Definition settings_gui.cpp:2194
GAME_OPTIONS_SELECTED
static constexpr TextColour GAME_OPTIONS_SELECTED
Colour for selected text of game options.
Definition settings_gui.cpp:203
ShowGameOptions
void ShowGameOptions()
Open the game options window.
Definition settings_gui.cpp:1851
settings_gui.h
Functions for setting GUIs.
SETTING_BUTTON_WIDTH
#define SETTING_BUTTON_WIDTH
Width of setting buttons.
Definition settings_gui.h:17
SETTING_BUTTON_HEIGHT
#define SETTING_BUTTON_HEIGHT
Height of setting buttons.
Definition settings_gui.h:19
settings_internal.h
Functions and types used internally for the settings configurations.
SettingFlag::GuiCurrency
@ GuiCurrency
The number represents money, so when reading value multiply by exchange rate.
SettingFlag::GuiZeroIsSpecial
@ GuiZeroIsSpecial
A value of zero is possible and has a custom string (the one after "strval").
SettingFlag::GuiDropdown
@ GuiDropdown
The value represents a limited number of string-options (internally integer) presented as dropdown.
SettingType
SettingType
Type of settings for filtering.
Definition settings_internal.h:60
ST_CLIENT
@ ST_CLIENT
Client setting.
Definition settings_internal.h:63
ST_ALL
@ ST_ALL
Used in setting filter to match all types.
Definition settings_internal.h:65
ST_GAME
@ ST_GAME
Game setting.
Definition settings_internal.h:61
ST_COMPANY
@ ST_COMPANY
Company setting.
Definition settings_internal.h:62
GetGameSettings
GameSettings & GetGameSettings()
Get the settings-object applicable for the current situation: the newgame settings when we're in the ...
Definition settings_type.h:674
WID_GO_BASE_SFX_OPEN_URL
@ WID_GO_BASE_SFX_OPEN_URL
Open base SFX URL.
Definition settings_widget.h:47
WID_GO_SETTING_DROPDOWN
@ WID_GO_SETTING_DROPDOWN
Dynamically created dropdown for changing setting value.
Definition settings_widget.h:88
WID_GO_BASE_MUSIC_DESCRIPTION
@ WID_GO_BASE_MUSIC_DESCRIPTION
Description of selected base music set.
Definition settings_widget.h:57
WID_GO_BASE_MUSIC_CONTENT_DOWNLOAD
@ WID_GO_BASE_MUSIC_CONTENT_DOWNLOAD
'Get Content' button for base music.
Definition settings_widget.h:51
WID_GO_RESTRICT_DROPDOWN
@ WID_GO_RESTRICT_DROPDOWN
The drop down box to restrict the list of settings.
Definition settings_widget.h:85
WID_GO_RESOLUTION_DROPDOWN
@ WID_GO_RESOLUTION_DROPDOWN
Dropdown for the resolution.
Definition settings_widget.h:25
WID_GO_COLLAPSE_ALL
@ WID_GO_COLLAPSE_ALL
Collapse all button.
Definition settings_widget.h:81
WID_GO_CURRENCY_DROPDOWN
@ WID_GO_CURRENCY_DROPDOWN
Currency dropdown.
Definition settings_widget.h:21
WID_GO_BASE_GRF_DESCRIPTION
@ WID_GO_BASE_GRF_DESCRIPTION
Description of selected base GRF.
Definition settings_widget.h:42
WID_GO_BASE_SFX_DESCRIPTION
@ WID_GO_BASE_SFX_DESCRIPTION
Description of selected base SFX.
Definition settings_widget.h:49
WID_GO_GUI_FONT_AA_TEXT
@ WID_GO_GUI_FONT_AA_TEXT
Text for anti-alias toggle.
Definition settings_widget.h:36
WID_GO_RESET_ALL
@ WID_GO_RESET_ALL
Reset all button.
Definition settings_widget.h:82
WID_GO_GUI_SCALE_BEVEL_BUTTON
@ WID_GO_GUI_SCALE_BEVEL_BUTTON
Toggle for chunky bevels.
Definition settings_widget.h:31
WID_GO_GUI_SCALE
@ WID_GO_GUI_SCALE
GUI Scale slider.
Definition settings_widget.h:28
WID_GO_BASE_SFX_TEXTFILE
@ WID_GO_BASE_SFX_TEXTFILE
Open base SFX readme, changelog (+1) or license (+2).
Definition settings_widget.h:48
WID_GO_TAB_ADVANCED
@ WID_GO_TAB_ADVANCED
Advanced tab.
Definition settings_widget.h:19
WID_GO_GUI_FONT_SPRITE
@ WID_GO_GUI_FONT_SPRITE
Toggle whether to prefer the sprite font over TTF fonts.
Definition settings_widget.h:33
WID_GO_GUI_SCALE_AUTO
@ WID_GO_GUI_SCALE_AUTO
Autodetect GUI scale button.
Definition settings_widget.h:29
WID_GO_SOCIAL_PLUGINS
@ WID_GO_SOCIAL_PLUGINS
Main widget handling the social plugins.
Definition settings_widget.h:69
WID_GO_BASE_GRF_CONTENT_DOWNLOAD
@ WID_GO_BASE_GRF_CONTENT_DOWNLOAD
'Get Content' button for base GRF.
Definition settings_widget.h:39
WID_GO_FILTER
@ WID_GO_FILTER
Text filter.
Definition settings_widget.h:74
WID_GO_BASE_GRF_TEXTFILE
@ WID_GO_BASE_GRF_TEXTFILE
Open base GRF readme, changelog (+1) or license (+2).
Definition settings_widget.h:41
WID_GO_TAB_GENERAL
@ WID_GO_TAB_GENERAL
General tab.
Definition settings_widget.h:15
WID_GO_VIDEO_VSYNC_TEXT
@ WID_GO_VIDEO_VSYNC_TEXT
Text for video vsync toggle.
Definition settings_widget.h:61
WID_GO_BASE_GRF_DROPDOWN
@ WID_GO_BASE_GRF_DROPDOWN
Use to select a base GRF.
Definition settings_widget.h:37
WID_GO_BASE_MUSIC_VOLUME
@ WID_GO_BASE_MUSIC_VOLUME
Change music volume.
Definition settings_widget.h:53
WID_GO_GUI_FONT_SPRITE_TEXT
@ WID_GO_GUI_FONT_SPRITE_TEXT
Text for sprite font toggle.
Definition settings_widget.h:34
WID_GO_BASE_SFX_VOLUME
@ WID_GO_BASE_SFX_VOLUME
Change sound effects volume.
Definition settings_widget.h:46
WID_GO_BASE_GRF_PARAMETERS
@ WID_GO_BASE_GRF_PARAMETERS
Base GRF parameters.
Definition settings_widget.h:38
WID_GO_LANG_DROPDOWN
@ WID_GO_LANG_DROPDOWN
Language dropdown.
Definition settings_widget.h:24
WID_GO_VIDEO_ACCEL_TEXT
@ WID_GO_VIDEO_ACCEL_TEXT
Text for video acceleration toggle.
Definition settings_widget.h:59
WID_GO_GUI_FONT_AA
@ WID_GO_GUI_FONT_AA
Toggle whether to anti-alias fonts.
Definition settings_widget.h:35
WID_GO_VIDEO_VSYNC_BUTTON
@ WID_GO_VIDEO_VSYNC_BUTTON
Toggle for video vsync.
Definition settings_widget.h:60
WID_GO_SURVEY_LINK_BUTTON
@ WID_GO_SURVEY_LINK_BUTTON
Button to open browser to go to the survey website.
Definition settings_widget.h:67
WID_GO_SURVEY_PARTICIPATE_TEXT
@ WID_GO_SURVEY_PARTICIPATE_TEXT
Text for automated survey toggle.
Definition settings_widget.h:66
WID_GO_OPTIONSPANEL
@ WID_GO_OPTIONSPANEL
Panel widget containing the option lists.
Definition settings_widget.h:75
WID_GO_TAB_SELECTION
@ WID_GO_TAB_SELECTION
Background of the tab selection.
Definition settings_widget.h:20
WID_GO_SURVEY_PARTICIPATE_BUTTON
@ WID_GO_SURVEY_PARTICIPATE_BUTTON
Toggle for participating in the automated survey.
Definition settings_widget.h:65
WID_GO_AUTOSAVE_DROPDOWN
@ WID_GO_AUTOSAVE_DROPDOWN
Dropdown to say how often to autosave.
Definition settings_widget.h:23
WID_GO_TAB_GRAPHICS
@ WID_GO_TAB_GRAPHICS
Graphics tab.
Definition settings_widget.h:16
WID_GO_HELP_TEXT_SCROLL
@ WID_GO_HELP_TEXT_SCROLL
Scrollbar for setting description.
Definition settings_widget.h:79
WID_GO_SCROLLBAR
@ WID_GO_SCROLLBAR
Scrollbar.
Definition settings_widget.h:76
WID_GO_GUI_SCALE_AUTO_TEXT
@ WID_GO_GUI_SCALE_AUTO_TEXT
Text for Autodetect GUI scale.
Definition settings_widget.h:30
WID_GO_TEXT_MUSIC_VOLUME
@ WID_GO_TEXT_MUSIC_VOLUME
Music volume label.
Definition settings_widget.h:52
WID_GO_GUI_SCALE_BEVEL_TEXT
@ WID_GO_GUI_SCALE_BEVEL_TEXT
Text for chunky bevels.
Definition settings_widget.h:32
WID_GO_BASE_MUSIC_JUKEBOX
@ WID_GO_BASE_MUSIC_JUKEBOX
Open the jukebox.
Definition settings_widget.h:54
WID_GO_SOCIAL_PLUGIN_STATE
@ WID_GO_SOCIAL_PLUGIN_STATE
State of the social plugin.
Definition settings_widget.h:72
WID_GO_SETTING_PROPERTIES
@ WID_GO_SETTING_PROPERTIES
Information area to display setting type and default value.
Definition settings_widget.h:77
WID_GO_SURVEY_SEL
@ WID_GO_SURVEY_SEL
Selection to hide survey if no JSON library is compiled in.
Definition settings_widget.h:64
WID_GO_REFRESH_RATE_DROPDOWN
@ WID_GO_REFRESH_RATE_DROPDOWN
Dropdown for all available refresh rates.
Definition settings_widget.h:62
WID_GO_EXPAND_ALL
@ WID_GO_EXPAND_ALL
Expand all button.
Definition settings_widget.h:80
WID_GO_SOCIAL_PLUGIN_TITLE
@ WID_GO_SOCIAL_PLUGIN_TITLE
Title of the frame of the social plugin.
Definition settings_widget.h:70
WID_GO_BASE_GRF_OPEN_URL
@ WID_GO_BASE_GRF_OPEN_URL
Open base GRF URL.
Definition settings_widget.h:40
WID_GO_BASE_MUSIC_TEXTFILE
@ WID_GO_BASE_MUSIC_TEXTFILE
Open base music readme, changelog (+1) or license (+2).
Definition settings_widget.h:56
WID_GO_RESTRICT_CATEGORY
@ WID_GO_RESTRICT_CATEGORY
Label upfront to the category drop-down box to restrict the list of settings to show.
Definition settings_widget.h:83
WID_GO_VIDEO_ACCEL_BUTTON
@ WID_GO_VIDEO_ACCEL_BUTTON
Toggle for video acceleration.
Definition settings_widget.h:58
WID_GO_TAB_SOCIAL
@ WID_GO_TAB_SOCIAL
Social tab.
Definition settings_widget.h:18
WID_GO_FULLSCREEN_TEXT
@ WID_GO_FULLSCREEN_TEXT
Text for toggle fullscreen.
Definition settings_widget.h:27
WID_GO_HELP_TEXT
@ WID_GO_HELP_TEXT
Information area to display help text of the selected option.
Definition settings_widget.h:78
WID_GO_SURVEY_PREVIEW_BUTTON
@ WID_GO_SURVEY_PREVIEW_BUTTON
Button to open a preview window with the survey results.
Definition settings_widget.h:68
WID_GO_BASE_SFX_CONTENT_DOWNLOAD
@ WID_GO_BASE_SFX_CONTENT_DOWNLOAD
'Get Content' button for base SFX.
Definition settings_widget.h:44
WID_GO_SOCIAL_PLUGIN_PLATFORM
@ WID_GO_SOCIAL_PLUGIN_PLATFORM
Platform of the social plugin.
Definition settings_widget.h:71
WID_GO_BASE_MUSIC_DROPDOWN
@ WID_GO_BASE_MUSIC_DROPDOWN
Use to select a base music set.
Definition settings_widget.h:50
WID_GO_BASE_MUSIC_OPEN_URL
@ WID_GO_BASE_MUSIC_OPEN_URL
Open base music URL.
Definition settings_widget.h:55
WID_GO_TYPE_DROPDOWN
@ WID_GO_TYPE_DROPDOWN
The drop down box to choose client/game/company/all settings.
Definition settings_widget.h:86
WID_GO_FULLSCREEN_BUTTON
@ WID_GO_FULLSCREEN_BUTTON
Toggle fullscreen.
Definition settings_widget.h:26
WID_GO_TAB_SOUND
@ WID_GO_TAB_SOUND
Sound tab.
Definition settings_widget.h:17
WID_GO_BASE_SFX_DROPDOWN
@ WID_GO_BASE_SFX_DROPDOWN
Use to select a base SFX.
Definition settings_widget.h:43
WID_GO_TEXT_SFX_VOLUME
@ WID_GO_TEXT_SFX_VOLUME
Sound effects volume label.
Definition settings_widget.h:45
WID_GO_VIDEO_DRIVER_INFO
@ WID_GO_VIDEO_DRIVER_INFO
Label showing details about the current video driver.
Definition settings_widget.h:63
WID_GO_RESTRICT_TYPE
@ WID_GO_RESTRICT_TYPE
Label upfront to the type drop-down box to restrict the list of settings to show.
Definition settings_widget.h:84
WID_CC_YEAR_DOWN
@ WID_CC_YEAR_DOWN
Down button.
Definition settings_widget.h:102
WID_CC_YEAR
@ WID_CC_YEAR
Year of introduction.
Definition settings_widget.h:104
WID_CC_SUFFIX_EDIT
@ WID_CC_SUFFIX_EDIT
Suffix edit button.
Definition settings_widget.h:100
WID_CC_SEPARATOR_EDIT
@ WID_CC_SEPARATOR_EDIT
Separator edit button.
Definition settings_widget.h:96
WID_CC_RATE_DOWN
@ WID_CC_RATE_DOWN
Down button.
Definition settings_widget.h:93
WID_CC_RATE_UP
@ WID_CC_RATE_UP
Up button.
Definition settings_widget.h:94
WID_CC_PREVIEW
@ WID_CC_PREVIEW
Preview.
Definition settings_widget.h:105
WID_CC_PREFIX
@ WID_CC_PREFIX
Current prefix.
Definition settings_widget.h:99
WID_CC_PREFIX_EDIT
@ WID_CC_PREFIX_EDIT
Prefix edit button.
Definition settings_widget.h:98
WID_CC_SUFFIX
@ WID_CC_SUFFIX
Current suffix.
Definition settings_widget.h:101
WID_CC_YEAR_UP
@ WID_CC_YEAR_UP
Up button.
Definition settings_widget.h:103
WID_CC_SEPARATOR
@ WID_CC_SEPARATOR
Current separator.
Definition settings_widget.h:97
WID_CC_RATE
@ WID_CC_RATE
Rate of currency.
Definition settings_widget.h:95
DrawSliderWidget
void DrawSliderWidget(Rect r, Colours wedge_colour, Colours handle_colour, TextColour text_colour, int min_value, int max_value, int nmarks, int value, SliderMarkFunc *mark_func)
Draw a slider widget with knob at given value.
Definition slider.cpp:34
ClickSliderWidget
bool ClickSliderWidget(Rect r, Point pt, int min_value, int max_value, int nmarks, int &value)
Handle click on a slider widget to change the value.
Definition slider.cpp:94
social_integration.h
Interface definitions for game to report/respond to social integration.
SndClickBeep
void SndClickBeep()
Play a beep sound for a click event if enabled in settings.
Definition sound.cpp:253
ChangeSoundSet
void ChangeSoundSet(int index)
Change the configured sound set and reset sounds.
Definition sound.cpp:167
sound_func.h
Functions related to sound.
stdafx.h
Definition of base types and functions in a cross-platform compatible way.
lengthof
#define lengthof(array)
Return the length of an fixed size array.
Definition stdafx.h:271
string_consumer.hpp
Parse strings.
ParseInteger
static std::optional< T > ParseInteger(std::string_view arg, int base=10, bool clamp=false)
Change a string into its number representation.
Definition string_consumer.hpp:917
string_func.h
Functions related to low-level strings.
CharSetFilter
CharSetFilter
Valid filter types for IsValidChar.
Definition string_type.h:24
CS_NUMERAL
@ CS_NUMERAL
Only numeric ones.
Definition string_type.h:26
CS_NUMERAL_SIGNED
@ CS_NUMERAL_SIGNED
Only numbers and '-' for negative values.
Definition string_type.h:28
CS_ALPHANUMERAL
@ CS_ALPHANUMERAL
Both numeric and alphabetic and spaces and stuff.
Definition string_type.h:25
stringfilter_type.h
Searching and filtering using a stringterm.
GetEncodedString
EncodedString GetEncodedString(StringID str)
Encode a string with no parameters into an encoded string.
Definition strings.cpp:90
CheckForMissingGlyphs
void CheckForMissingGlyphs(MissingGlyphSearcher *searcher)
Check whether the currently loaded language pack uses characters that the currently loaded font does ...
Definition strings.cpp:2390
GetString
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
Definition strings.cpp:424
GetCurrentLanguageIsoCode
std::string_view GetCurrentLanguageIsoCode()
Get the ISO language code of the currently loaded language.
Definition strings.cpp:2297
_current_text_dir
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition strings.cpp:56
strings_func.h
Functions related to OTTD's strings.
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition strings_type.h:19
INVALID_STRING_ID
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition strings_type.h:20
TD_RTL
@ TD_RTL
Text is written right-to-left by default.
Definition strings_type.h:27
AutoRestoreBackup
Class to backup a specific variable and restore it upon destruction of this object to prevent stack v...
Definition backup_type.hpp:150
BaseSetTextfileWindow
Window for displaying the textfile of a BaseSet.
Definition settings_gui.cpp:100
BaseSetTextfileWindow::name
const std::string name
Name of the content.
Definition settings_gui.cpp:101
BaseSetTextfileWindow::GetWidgetString
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
Definition settings_gui.cpp:110
BaseSetTextfileWindow::content_type
const StringID content_type
STR_CONTENT_TYPE_xxx for title.
Definition settings_gui.cpp:102
BaseSettingEntry
Data structure describing a single setting in a tab.
Definition settingentry_gui.h:52
BaseSettingEntry::circle_size
static Dimension circle_size
Dimension of the circle +/- icon.
Definition settingentry_gui.h:86
BaseSettingEntry::line_height
static int line_height
Height of a single setting.
Definition settingentry_gui.h:87
BaseSettingEntry::level
uint8_t level
Nesting level of this setting entry.
Definition settingentry_gui.h:54
ClientSettings::music
MusicSettings music
settings related to music/sound
Definition settings_type.h:654
ClientSettings::network
NetworkSettings network
settings related to the network
Definition settings_type.h:651
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition settings_type.h:650
Coord2D< int >
Coord2D::y
T y
Y coordinate.
Definition geometry_type.hpp:35
Coord2D::x
T x
X coordinate.
Definition geometry_type.hpp:34
CurrencySpec
Specification of a currency.
Definition currency.h:77
CurrencySpec::separator
std::string separator
The thousands separator for this currency.
Definition currency.h:79
CurrencySpec::prefix
std::string prefix
Prefix to apply when formatting money in this currency.
Definition currency.h:81
CurrencySpec::to_euro
TimerGameCalendar::Year to_euro
Year of switching to the Euro. May also be CF_NOEURO or CF_ISEURO.
Definition currency.h:80
CurrencySpec::suffix
std::string suffix
Suffix to apply when formatting money in this currency.
Definition currency.h:82
CurrencySpec::code
std::string code
3 letter untranslated code to identify the currency.
Definition currency.h:83
CurrencySpec::rate
uint16_t rate
The conversion rate compared to the base currency.
Definition currency.h:78
CustomCurrencyWindow
Definition settings_gui.cpp:1962
CustomCurrencyWindow::GetWidgetString
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
Definition settings_gui.cpp:1980
CustomCurrencyWindow::UpdateWidgetSize
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
Definition settings_gui.cpp:1998
CustomCurrencyWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition settings_gui.cpp:2139
CustomCurrencyWindow::OnClick
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition settings_gui.cpp:2023
CustomCurrencyWindow::OnQueryTextFinished
void OnQueryTextFinished(std::optional< std::string > str) override
The query window opened from this window has closed.
Definition settings_gui.cpp:2100
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition geometry_type.hpp:56
DrawPixelInfo
Data about how and where to blit pixels.
Definition gfx_type.h:157
FontCacheSettings::prefer_sprite
bool prefer_sprite
Whether to prefer the built-in sprite font over resizable fonts.
Definition fontcache.h:185
FontCacheSettings::global_aa
bool global_aa
Whether to anti alias all font sizes.
Definition fontcache.h:186
GRFConfig
Information about GRF, used in the game and (part of it) in savegames.
Definition newgrf_config.h:158
GRFConfig::SetParameterDefaults
void SetParameterDefaults()
Set the default value for all parameters as specified by action14.
Definition newgrf_config.cpp:114
GRFConfig::param
std::vector< uint32_t > param
GRF parameters.
Definition newgrf_config.h:185
GUISettings::settings_restriction_mode
uint8_t settings_restriction_mode
selected restriction mode in adv. settings GUI.
Definition settings_type.h:254
GUISettings::refresh_rate
uint16_t refresh_rate
How often we refresh the screen (time between draw-ticks).
Definition settings_type.h:236
GUISettings::autosave_interval
uint32_t autosave_interval
how often should we do autosaves?
Definition settings_type.h:194
GUISettings::missing_strings_threshold
uint8_t missing_strings_threshold
the number of missing strings before showing the warning
Definition settings_type.h:228
GUISettings::scale_bevels
bool scale_bevels
bevels are scaled with GUI scale.
Definition settings_type.h:258
GameOptionsWindow
Definition settings_gui.cpp:395
GameOptionsWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition settings_gui.cpp:795
GameOptionsWindow::filter
SettingFilter filter
Filter for the list.
Definition settings_gui.cpp:404
GameOptionsWindow::closing_dropdown
bool closing_dropdown
True, if the dropdown list is currently closing.
Definition settings_gui.cpp:402
GameOptionsWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition settings_gui.cpp:1363
GameOptionsWindow::OnDropdownClose
void OnDropdownClose(Point pt, WidgetID widget, int index, int click_result, bool instant_close) override
A dropdown window associated to this window has been closed.
Definition settings_gui.cpp:1504
GameOptionsWindow::valuewindow_entry
SettingEntry * valuewindow_entry
If non-nullptr, pointer to setting for which a value-entering window has been opened.
Definition settings_gui.cpp:398
GameOptionsWindow::OnQueryTextFinished
void OnQueryTextFinished(std::optional< std::string > str) override
The query window opened from this window has closed.
Definition settings_gui.cpp:1372
GameOptionsWindow::UpdateWidgetSize
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
Definition settings_gui.cpp:834
GameOptionsWindow::previous_gui_scale
static int previous_gui_scale
Previous GUI scale.
Definition settings_gui.cpp:418
GameOptionsWindow::OnDropdownSelect
void OnDropdownSelect(WidgetID widget, int index, int) override
A dropdown option associated to this window has been selected.
Definition settings_gui.cpp:1411
GameOptionsWindow::valuedropdown_entry
SettingEntry * valuedropdown_entry
If non-nullptr, pointer to the value for which a dropdown window is currently opened.
Definition settings_gui.cpp:401
GameOptionsWindow::OnClick
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition settings_gui.cpp:931
GameOptionsWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition settings_gui.cpp:893
GameOptionsWindow::clicked_entry
SettingEntry * clicked_entry
If non-nullptr, pointer to a clicked numeric setting (with a depressed left or right button).
Definition settings_gui.cpp:399
GameOptionsWindow::OnEditboxChanged
void OnEditboxChanged(WidgetID wid) override
The text in an editbox has been edited.
Definition settings_gui.cpp:1591
GameOptionsWindow::filter_editbox
QueryString filter_editbox
Filter editbox;.
Definition settings_gui.cpp:405
GameOptionsWindow::warn_missing
WarnHiddenResult warn_missing
Whether and how to warn about missing search results.
Definition settings_gui.cpp:407
GameOptionsWindow::OnMouseLoop
void OnMouseLoop() override
Called for every mouse loop run, which is at least once per (game) tick.
Definition settings_gui.cpp:1397
GameOptionsWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition settings_gui.cpp:1528
GameOptionsWindow::Close
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
Definition settings_gui.cpp:459
GameOptionsWindow::SetDisplayedHelpText
void SetDisplayedHelpText(SettingEntry *pe)
Set the entry that should have its help text displayed, and mark the window dirty so it gets repainte...
Definition settings_gui.cpp:761
GameOptionsWindow::GetWidgetString
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
Definition settings_gui.cpp:596
GameOptionsWindow::warn_lines
int warn_lines
Number of lines used for warning about missing search results.
Definition settings_gui.cpp:408
GameOptionsWindow::DrawWidget
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
Definition settings_gui.cpp:678
GameOptionsWindow::manually_changed_folding
bool manually_changed_folding
Whether the user expanded/collapsed something manually.
Definition settings_gui.cpp:406
GameOptionsWindow::last_clicked
SettingEntry * last_clicked
If non-nullptr, pointer to the last clicked setting.
Definition settings_gui.cpp:400
GameOptionsWindow::BuildDropDownList
DropDownList BuildDropDownList(WidgetID widget, int *selected_index) const
Build the dropdown list for a specific widget.
Definition settings_gui.cpp:472
GameOptionsWindow::OnInit
void OnInit() override
Notification that the nested widget tree gets initialized.
Definition settings_gui.cpp:451
GameOptionsWindow::settings_ptr
static GameSettings * settings_ptr
Pointer to the game settings being displayed and modified.
Definition settings_gui.cpp:396
GameSettings
All settings together for the game.
Definition settings_type.h:632
GameSettings::locale
LocaleSettings locale
settings related to used currency/unit system in the current game
Definition settings_type.h:645
IntSettingDesc
Base integer type, including boolean, settings.
Definition settings_internal.h:148
IntSettingDesc::GetRange
std::tuple< int32_t, uint32_t > GetRange() const
Get the min/max range for the setting.
Definition settings.cpp:476
IntSettingDesc::GetDefaultValue
int32_t GetDefaultValue() const
Get the default value of the setting.
Definition settings.cpp:467
IntSettingDesc::GetHelp
StringID GetHelp() const
Get the help text of the setting.
Definition settings.cpp:436
IntSettingDesc::IsBoolSetting
virtual bool IsBoolSetting() const
Check whether this setting is a boolean type setting.
Definition settings_internal.h:232
IntSettingDesc::GetValueParams
std::pair< StringParameter, StringParameter > GetValueParams(int32_t value) const
Get parameters for drawing the value of the setting.
Definition settings.cpp:445
IntSettingDesc::Read
int32_t Read(const void *object) const
Read the integer from the the actual setting.
Definition settings.cpp:567
IntSettingDesc::interval
int32_t interval
the interval to use between settings in the 'settings' window. If interval is '0' the interval is dyn...
Definition settings_internal.h:209
LanguagePackHeader::own_name
char own_name[32]
the localized name of this language
Definition language.h:30
LocaleSettings::currency
uint8_t currency
currency we currently use
Definition settings_type.h:295
MusicSettings::effect_vol
uint8_t effect_vol
The requested effects volume.
Definition settings_type.h:286
MusicSettings::music_vol
uint8_t music_vol
The requested music volume.
Definition settings_type.h:285
NetworkSettings::participate_survey
ParticipateSurvey participate_survey
Participate in the automated survey.
Definition settings_type.h:372
PixelColour
Colour for pixel/line drawing.
Definition gfx_type.h:405
QueryString
Data stored about a string that can be modified in the GUI.
Definition querystring_gui.h:20
QueryString::cancel_button
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
Definition querystring_gui.h:28
QueryString::ACTION_CLEAR
static const int ACTION_CLEAR
Clear editbox.
Definition querystring_gui.h:24
RectPadding::Vertical
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Definition geometry_type.hpp:95
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition geometry_type.hpp:101
Rect::WithWidth
Rect WithWidth(int width, bool end) const
Copy Rect and set its width.
Definition geometry_type.hpp:211
Rect::Width
int Width() const
Get width of Rect.
Definition geometry_type.hpp:111
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition geometry_type.hpp:124
Rect::WithHeight
Rect WithHeight(int height, bool end=false) const
Copy Rect and set its height.
Definition geometry_type.hpp:237
Rect::Height
int Height() const
Get height of Rect.
Definition geometry_type.hpp:117
SettingDesc::IsEditable
bool IsEditable(bool do_command=false) const
Check whether the setting is editable in the current gamemode.
Definition settings.cpp:894
SettingDesc::flags
SettingFlags flags
Handles how a setting would show up in the GUI (text/currency, etc.).
Definition settings_internal.h:76
SettingDesc::GetType
SettingType GetType() const
Return the type of the setting.
Definition settings.cpp:911
SettingEntry
Standard setting.
Definition settingentry_gui.h:94
SettingEntry::SetButtons
void SetButtons(SettingEntryFlags new_val)
Set the button-depressed flags (#SettingsEntryFlag::LeftDepressed and #SettingsEntryFlag::RightDepres...
Definition settingentry_gui.cpp:148
SettingEntry::GetMaxHelpHeight
uint GetMaxHelpHeight(int maxw) override
Get the biggest height of the help text(s), if the width is at least maxw.
Definition settingentry_gui.cpp:166
SettingEntry::setting
const IntSettingDesc * setting
Setting description of the setting.
Definition settingentry_gui.h:96
SettingFilter
Filter for settings list.
Definition settingentry_gui.h:43
SettingFilter::type
SettingType type
Filter based on type.
Definition settingentry_gui.h:48
SettingFilter::type_hides
bool type_hides
Whether the type hides filtered strings.
Definition settingentry_gui.h:46
SettingFilter::mode
RestrictionMode mode
Filter based on category.
Definition settingentry_gui.h:47
SettingFilter::min_cat
RestrictionMode min_cat
Minimum category needed to display all filtered strings (RM_BASIC, RM_ADVANCED, or RM_ALL).
Definition settingentry_gui.h:45
SettingFilter::string
StringFilter string
Filter string.
Definition settingentry_gui.h:44
SettingsContainer::UpdateFilterState
bool UpdateFilterState(SettingFilter &filter, bool force_visible)
Update the filter state.
Definition settingentry_gui.cpp:354
SettingsContainer::GetFoldingState
void GetFoldingState(bool &all_folded, bool &all_unfolded) const
Recursively accumulate the folding state of the tree.
Definition settingentry_gui.cpp:341
SettingsContainer::ResetAll
void ResetAll()
Resets all settings to their default values.
Definition settingentry_gui.cpp:313
SettingsContainer::FoldAll
void FoldAll()
Recursively close all folds of sub-pages.
Definition settingentry_gui.cpp:321
SettingsContainer::UnFoldAll
void UnFoldAll()
Recursively open all folds of sub-pages.
Definition settingentry_gui.cpp:329
SettingsContainer::FindEntry
BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find the setting entry at row number row_num.
Definition settingentry_gui.cpp:397
SettingsContainer::Draw
uint Draw(GameSettings *settings_ptr, int left, int right, int y, uint first_row, uint max_row, BaseSettingEntry *selected, uint cur_row=0, uint parent_last=0) const
Draw a row in the settings panel.
Definition settingentry_gui.cpp:438
SettingsPage
Data structure describing one page of settings in the settings window.
Definition settingentry_gui.h:144
SettingsPage::folded
bool folded
Sub-page is folded (not visible except for its title)
Definition settingentry_gui.h:146
StringFilter::IsEmpty
bool IsEmpty() const
Check whether any filter words were entered.
Definition stringfilter_type.h:57
StringFilter::SetFilterTerm
void SetFilterTerm(std::string_view str)
Set the term to filter on.
Definition stringfilter.cpp:29
StrongType::Typedef
Templated helper to make a type-safe 'typedef' representing a single POD value.
Definition strong_typedef_type.hpp:130
Textbuf::GetText
std::string_view GetText() const
Get the current text.
Definition textbuf.cpp:284
TextfileWindow
Window for displaying a textfile.
Definition textfile_gui.h:22
TextfileWindow::file_type
TextfileType file_type
Type of textfile to view.
Definition textfile_gui.h:23
TextfileWindow::LoadTextfile
virtual void LoadTextfile(const std::string &textfile, Subdirectory dir)
Loads the textfile text from file and setup lines.
Definition textfile_gui.cpp:851
WindowDesc
High level window description.
Definition window_gui.h:168
Window
Data structure for an opened window.
Definition window_gui.h:274
Window::ReInit
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
Definition window.cpp:980
Window::Close
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
Definition window.cpp:1104
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition window.cpp:1809
Window::querystrings
std::map< WidgetID, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
Definition window_gui.h:321
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition widget.cpp:784
Window::InvalidateData
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
Definition window.cpp:3237
Window::parent
Window * parent
Parent window.
Definition window_gui.h:329
Window::SetWidgetDirty
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
Definition window.cpp:558
Window::GetWidgetString
virtual std::string GetWidgetString(WidgetID widget, StringID stringid) const
Get the raw string for a widget.
Definition window.cpp:506
Window::mouse_capture_widget
WidgetID mouse_capture_widget
ID of current mouse capture widget (e.g. dragged scrollbar). INVALID_WIDGET if no widget has mouse ca...
Definition window_gui.h:327
Window::CloseChildWindows
void CloseChildWindows(WindowClass wc=WC_INVALID) const
Close all children a window might have in a head-recursive manner.
Definition window.cpp:1077
Window::resize
ResizeInfo resize
Resize information.
Definition window_gui.h:315
Window::DisableWidget
void DisableWidget(WidgetID widget_index)
Sets a widget to disabled.
Definition window_gui.h:392
Window::SetWidgetsDisabledState
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
Definition window_gui.h:516
Window::CreateNestedTree
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
Definition window.cpp:1799
Window::CloseChildWindowById
void CloseChildWindowById(WindowClass wc, WindowNumber number) const
Close all children a window might have in a head-recursive manner.
Definition window.cpp:1092
Window::SetFocusedWidget
bool SetFocusedWidget(WidgetID widget_index)
Set focus within this window to the given widget.
Definition window.cpp:487
Window::IsWidgetLowered
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
Definition window_gui.h:492
Window::SetWidgetsLoweredState
void SetWidgetsLoweredState(bool lowered_stat, Args... widgets)
Sets the lowered/raised status of a list of widgets.
Definition window_gui.h:527
Window::SetWidgetLoweredState
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition window_gui.h:442
Window::EnableWidget
void EnableWidget(WidgetID widget_index)
Sets a widget to Enabled.
Definition window_gui.h:401
Window::OnDropdownClose
virtual void OnDropdownClose(Point pt, WidgetID widget, int index, int click_result, bool instant_close)
A dropdown window associated to this window has been closed.
Definition window.cpp:286
Window::SetTimeout
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
Definition window_gui.h:356
Window::LowerWidget
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
Definition window_gui.h:461
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition window.cpp:1823
Window::flags
WindowFlags flags
Window flags.
Definition window_gui.h:301
Window::GetScrollbar
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
Definition window.cpp:315
Window::SetWidgetDisabledState
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition window_gui.h:382
Window::height
int height
Height of the window (number of pixels down in y direction)
Definition window_gui.h:313
Window::width
int width
width of the window (number of pixels to the right in x direction)
Definition window_gui.h:312
CONTENT_TYPE_BASE_SOUNDS
@ CONTENT_TYPE_BASE_SOUNDS
The content consists of base sounds.
Definition tcp_content_type.h:29
CONTENT_TYPE_BASE_GRAPHICS
@ CONTENT_TYPE_BASE_GRAPHICS
The content consists of base graphics.
Definition tcp_content_type.h:23
CONTENT_TYPE_BASE_MUSIC
@ CONTENT_TYPE_BASE_MUSIC
The content consists of base music.
Definition tcp_content_type.h:30
textbuf_gui.h
Stuff related to the text buffer GUI.
QueryStringFlag::EnableDefault
@ EnableDefault
enable the 'Default' button ("\0" is returned)
GetTextfile
std::optional< std::string > GetTextfile(TextfileType type, Subdirectory dir, std::string_view filename)
Search a textfile file next to the given content.
Definition textfile_gui.cpp:939
textfile_gui.h
GUI functions related to textfiles.
TextfileType
TextfileType
Additional text files accompanying Tar archives.
Definition textfile_type.h:14
TFT_LICENSE
@ TFT_LICENSE
Content license.
Definition textfile_type.h:19
TFT_README
@ TFT_README
Content readme.
Definition textfile_type.h:17
TFT_CHANGELOG
@ TFT_CHANGELOG
Content changelog.
Definition textfile_type.h:18
town.h
Base of the town class.
_video_vsync
bool _video_vsync
Whether we should use vsync (only if active video driver supports HW acceleration).
Definition video_driver.cpp:28
_video_hw_accel
bool _video_hw_accel
Whether to consider hardware accelerated video drivers on startup.
Definition video_driver.cpp:27
video_driver.hpp
Base of all video drivers.
viewport_func.h
Functions related to (drawing on) viewports.
DrawFrameRect
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
Draw frame rectangle.
Definition widget.cpp:307
SetupWidgetDimensions
void SetupWidgetDimensions()
Set up pre-scaled versions of Widget Dimensions.
Definition widget.cpp:96
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition widget_type.h:105
WWT_PUSHBTN
@ WWT_PUSHBTN
Normal push-button (no toggle button) with custom drawing.
Definition widget_type.h:104
WWT_PUSHIMGBTN
@ WWT_PUSHIMGBTN
Normal push-button (no toggle button) with image caption.
Definition widget_type.h:106
WWT_PUSHARROWBTN
@ WWT_PUSHARROWBTN
Normal push-button (no toggle button) with arrow caption.
Definition widget_type.h:107
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition widget_type.h:48
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition widget_type.h:70
WWT_EDITBOX
@ WWT_EDITBOX
a textbox for typing
Definition widget_type.h:62
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition widget_type.h:66
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition widget_type.h:44
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition widget_type.h:39
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition widget_type.h:52
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition widget_type.h:76
WWT_BOOLBTN
@ WWT_BOOLBTN
Standard boolean toggle button.
Definition widget_type.h:46
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition widget_type.h:68
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition widget_type.h:60
WWT_FRAME
@ WWT_FRAME
Frame.
Definition widget_type.h:51
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition widget_type.h:37
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition widget_type.h:59
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition widget_type.h:56
WWT_DROPDOWN
@ WWT_DROPDOWN
Drop down list.
Definition widget_type.h:61
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition widget_type.h:49
NWID_SELECTION
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition widget_type.h:71
SZSP_NONE
@ SZSP_NONE
Display plane with zero size in both directions (none filling and resizing).
Definition widget_type.h:509
EqualSize
@ EqualSize
Containers should keep all their (resizing) children equally large.
Definition widget_type.h:544
AWV_DECREASE
@ AWV_DECREASE
Arrow to the left or in case of RTL to the right.
Definition widget_type.h:20
AWV_INCREASE
@ AWV_INCREASE
Arrow to the right or in case of RTL to the left.
Definition widget_type.h:21
RWV_HIDE_BEVEL
@ RWV_HIDE_BEVEL
Bevel of resize box is hidden.
Definition widget_type.h:29
CloseWindowById
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
Definition window.cpp:1195
ReInitAllWindows
void ReInitAllWindows(bool zoom_changed)
Re-initialize all windows.
Definition window.cpp:3413
CloseWindowByClass
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Definition window.cpp:1207
SetWindowClassesDirty
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
Definition window.cpp:3205
window_func.h
Window functions not directly related to making/drawing windows.
FrameFlag::BorderOnly
@ BorderOnly
Draw border only, no background.
FrameFlag::Lowered
@ Lowered
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
WindowFlag::Centred
@ Centred
Window is centered and shall stay centered after ReInit.
WindowFlag::Timeout
@ Timeout
Window timeout counter.
WDP_CENTER
@ WDP_CENTER
Center the window.
Definition window_gui.h:145
WidgetID
int WidgetID
Widget ID.
Definition window_type.h:20
WN_GAME_OPTIONS_GAME_OPTIONS
@ WN_GAME_OPTIONS_GAME_OPTIONS
Game options.
Definition window_type.h:31
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition window_type.h:50
WC_MUSIC_WINDOW
@ WC_MUSIC_WINDOW
Music window; Window numbers:
Definition window_type.h:618
WC_CUSTOM_CURRENCY
@ WC_CUSTOM_CURRENCY
Custom currency; Window numbers:
Definition window_type.h:641
WC_GAME_OPTIONS
@ WC_GAME_OPTIONS
Game options window; Window numbers:
Definition window_type.h:635
WC_TEXTFILE
@ WC_TEXTFILE
textfile; Window numbers:
Definition window_type.h:192
WC_DROPDOWN_MENU
@ WC_DROPDOWN_MENU
Drop down menu; Window numbers:
Definition window_type.h:161
WC_QUERY_STRING
@ WC_QUERY_STRING
Query string window; Window numbers:
Definition window_type.h:128
WC_GRF_PARAMETERS
@ WC_GRF_PARAMETERS
NewGRF parameters; Window numbers:
Definition window_type.h:186
zoom_func.h
Functions related to zooming.