OpenTTD Source  14.0-beta3
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 <http://www.gnu.org/licenses/>.
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 "town.h"
18 #include "settings_internal.h"
19 #include "strings_func.h"
20 #include "window_func.h"
21 #include "string_func.h"
22 #include "widgets/dropdown_type.h"
23 #include "widgets/dropdown_func.h"
24 #include "widgets/slider_func.h"
25 #include "highscore.h"
26 #include "base_media_base.h"
27 #include "company_base.h"
28 #include "company_func.h"
29 #include "viewport_func.h"
30 #include "core/geometry_func.hpp"
31 #include "ai/ai.hpp"
32 #include "blitter/factory.hpp"
33 #include "language.h"
34 #include "textfile_gui.h"
35 #include "stringfilter_type.h"
36 #include "querystring_gui.h"
37 #include "fontcache.h"
38 #include "zoom_func.h"
39 #include "rev.h"
40 #include "video/video_driver.hpp"
41 #include "music/music_driver.hpp"
42 #include "gui.h"
43 #include "mixer.h"
44 #include "newgrf_config.h"
45 #include "network/core/config.h"
46 #include "network/network_gui.h"
47 #include "network/network_survey.h"
48 #include "video/video_driver.hpp"
49 #include "social_integration.h"
50 
51 #include "safeguards.h"
52 
53 
54 #if defined(WITH_FREETYPE) || defined(_WIN32) || defined(WITH_COCOA)
55 # define HAS_TRUETYPE_FONT
56 #endif
57 
58 static const StringID _autosave_dropdown[] = {
59  STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_OFF,
60  STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_10_MINUTES,
61  STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_30_MINUTES,
62  STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_60_MINUTES,
63  STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_120_MINUTES,
65 };
66 
68 static const uint32_t _autosave_dropdown_to_minutes[] = {
69  0,
70  10,
71  30,
72  60,
73  120,
74 };
75 
77 
78 static const void *ResolveObject(const GameSettings *settings_ptr, const IntSettingDesc *sd);
79 
85 {
86  auto it = std::find(_resolutions.begin(), _resolutions.end(), Dimension(_screen.width, _screen.height));
87  return std::distance(_resolutions.begin(), it);
88 }
89 
90 static void ShowCustCurrency();
91 
93 template <class TBaseSet>
95  const TBaseSet *baseset;
97 
99  {
100  this->ConstructWindow();
101 
102  auto textfile = this->baseset->GetTextfile(file_type);
103  this->LoadTextfile(textfile.value(), BASESET_DIR);
104  }
105 
106  void SetStringParameters(WidgetID widget) const override
107  {
108  if (widget == WID_TF_CAPTION) {
110  SetDParamStr(1, this->baseset->name);
111  }
112  }
113 };
114 
121 template <class TBaseSet>
122 void ShowBaseSetTextfileWindow(TextfileType file_type, const TBaseSet *baseset, StringID content_type)
123 {
124  CloseWindowById(WC_TEXTFILE, file_type);
125  new BaseSetTextfileWindow<TBaseSet>(file_type, baseset, content_type);
126 }
127 
128 std::set<int> _refresh_rates = { 30, 60, 75, 90, 100, 120, 144, 240 };
129 
135 {
136  /* Add the refresh rate as selected in the config. */
137  _refresh_rates.insert(_settings_client.gui.refresh_rate);
138 
139  /* Add all the refresh rates of all monitors connected to the machine. */
140  std::vector<int> monitorRates = VideoDriver::GetInstance()->GetListOfMonitorRefreshRates();
141  std::copy(monitorRates.begin(), monitorRates.end(), std::inserter(_refresh_rates, _refresh_rates.end()));
142 }
143 
144 static const std::map<int, StringID> _scale_labels = {
145  { 100, STR_GAME_OPTIONS_GUI_SCALE_1X },
146  { 125, STR_NULL },
147  { 150, STR_NULL },
148  { 175, STR_NULL },
149  { 200, STR_GAME_OPTIONS_GUI_SCALE_2X },
150  { 225, STR_NULL },
151  { 250, STR_NULL },
152  { 275, STR_NULL },
153  { 300, STR_GAME_OPTIONS_GUI_SCALE_3X },
154  { 325, STR_NULL },
155  { 350, STR_NULL },
156  { 375, STR_NULL },
157  { 400, STR_GAME_OPTIONS_GUI_SCALE_4X },
158  { 425, STR_NULL },
159  { 450, STR_NULL },
160  { 475, STR_NULL },
161  { 500, STR_GAME_OPTIONS_GUI_SCALE_5X },
162 };
163 
164 static const std::map<int, StringID> _volume_labels = {
165  { 0, STR_GAME_OPTIONS_VOLUME_0 },
166  { 15, STR_NULL },
167  { 31, STR_GAME_OPTIONS_VOLUME_25 },
168  { 47, STR_NULL },
169  { 63, STR_GAME_OPTIONS_VOLUME_50 },
170  { 79, STR_NULL },
171  { 95, STR_GAME_OPTIONS_VOLUME_75 },
172  { 111, STR_NULL },
173  { 127, STR_GAME_OPTIONS_VOLUME_100 },
174 };
175 
176 static const NWidgetPart _nested_social_plugins_widgets[] = {
178  NWidget(WWT_FRAME, COLOUR_GREY, WID_GO_SOCIAL_PLUGIN_TITLE), SetDataTip(STR_JUST_STRING2, STR_NULL),
180  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 0), SetDataTip(STR_GAME_OPTIONS_SOCIAL_PLUGIN_PLATFORM, STR_NULL),
181  NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_SOCIAL_PLUGIN_PLATFORM), SetMinimalSize(100, 12), SetDataTip(STR_JUST_RAW_STRING, STR_NULL), SetAlignment(SA_RIGHT),
182  EndContainer(),
184  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 0), SetDataTip(STR_GAME_OPTIONS_SOCIAL_PLUGIN_STATE, STR_NULL),
185  NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_SOCIAL_PLUGIN_STATE), SetMinimalSize(100, 12), SetDataTip(STR_JUST_STRING1, STR_NULL), SetAlignment(SA_RIGHT),
186  EndContainer(),
187  EndContainer(),
188  EndContainer(),
189 };
190 
191 static const NWidgetPart _nested_social_plugins_none_widgets[] = {
193  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 0), SetDataTip(STR_GAME_OPTIONS_SOCIAL_PLUGINS_NONE, STR_NULL),
194  EndContainer(),
195 };
196 
198 public:
200  {
201  this->plugins = SocialIntegration::GetPlugins();
202 
203  if (this->plugins.empty()) {
204  auto widget = MakeNWidgets(std::begin(_nested_social_plugins_none_widgets), std::end(_nested_social_plugins_none_widgets), nullptr);
205  this->Add(std::move(widget));
206  } else {
207  for (size_t i = 0; i < this->plugins.size(); i++) {
208  auto widget = MakeNWidgets(std::begin(_nested_social_plugins_widgets), std::end(_nested_social_plugins_widgets), nullptr);
209  this->Add(std::move(widget));
210  }
211  }
212 
213  this->SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0);
214  }
215 
216  void FillWidgetLookup(WidgetLookup &widget_lookup) override
217  {
218  widget_lookup[WID_GO_SOCIAL_PLUGINS] = this;
219  NWidgetVertical::FillWidgetLookup(widget_lookup);
220  }
221 
222  void SetupSmallestSize(Window *w) override
223  {
224  this->current_index = -1;
226  }
227 
234  template <typename T>
235  std::string &GetWidestPlugin(T SocialIntegrationPlugin::*member) const
236  {
237  std::string *longest = &(this->plugins[0]->*member);
238  int longest_length = 0;
239 
240  for (auto *plugin : this->plugins) {
241  int length = GetStringBoundingBox(plugin->*member).width;
242  if (length > longest_length) {
243  longest_length = length;
244  longest = &(plugin->*member);
245  }
246  }
247 
248  return *longest;
249  }
250 
251  void SetStringParameters(int widget) const
252  {
253  switch (widget) {
255  /* For SetupSmallestSize, use the longest string we have. */
256  if (this->current_index < 0) {
259  break;
260  }
261 
262  if (this->plugins[this->current_index]->name.empty()) {
263  SetDParam(0, STR_JUST_RAW_STRING);
264  SetDParamStr(1, this->plugins[this->current_index]->basepath);
265  } else {
266  SetDParam(0, STR_GAME_OPTIONS_SOCIAL_PLUGIN_TITLE);
267  SetDParamStr(1, this->plugins[this->current_index]->name);
268  SetDParamStr(2, this->plugins[this->current_index]->version);
269  }
270  break;
271 
273  /* For SetupSmallestSize, use the longest string we have. */
274  if (this->current_index < 0) {
276  break;
277  }
278 
279  SetDParamStr(0, this->plugins[this->current_index]->social_platform);
280  break;
281 
283  static const std::pair<SocialIntegrationPlugin::State, StringID> state_to_string[] = {
284  { SocialIntegrationPlugin::RUNNING, STR_GAME_OPTIONS_SOCIAL_PLUGIN_STATE_RUNNING },
285  { SocialIntegrationPlugin::FAILED, STR_GAME_OPTIONS_SOCIAL_PLUGIN_STATE_FAILED },
286  { SocialIntegrationPlugin::PLATFORM_NOT_RUNNING, STR_GAME_OPTIONS_SOCIAL_PLUGIN_STATE_PLATFORM_NOT_RUNNING },
287  { SocialIntegrationPlugin::UNLOADED, STR_GAME_OPTIONS_SOCIAL_PLUGIN_STATE_UNLOADED },
288  { SocialIntegrationPlugin::DUPLICATE, STR_GAME_OPTIONS_SOCIAL_PLUGIN_STATE_DUPLICATE },
289  { SocialIntegrationPlugin::UNSUPPORTED_API, STR_GAME_OPTIONS_SOCIAL_PLUGIN_STATE_UNSUPPORTED_API },
290  { SocialIntegrationPlugin::INVALID_SIGNATURE, STR_GAME_OPTIONS_SOCIAL_PLUGIN_STATE_INVALID_SIGNATURE },
291  };
292 
293  /* For SetupSmallestSize, use the longest string we have. */
294  if (this->current_index < 0) {
296 
297  /* Set the longest plugin when looking for the longest status. */
298  SetDParamStr(0, longest_plugin);
299 
300  StringID longest = STR_NULL;
301  int longest_length = 0;
302  for (auto state : state_to_string) {
303  int length = GetStringBoundingBox(state.second).width;
304  if (length > longest_length) {
305  longest_length = length;
306  longest = state.second;
307  }
308  }
309 
310  SetDParam(0, longest);
311  SetDParamStr(1, longest_plugin);
312  break;
313  }
314 
315  auto plugin = this->plugins[this->current_index];
316 
317  /* Default string, in case no state matches. */
318  SetDParam(0, STR_GAME_OPTIONS_SOCIAL_PLUGIN_STATE_FAILED);
319  SetDParamStr(1, plugin->social_platform);
320 
321  /* Find the string for the state. */
322  for (auto state : state_to_string) {
323  if (plugin->state == state.first) {
324  SetDParam(0, state.second);
325  break;
326  }
327  }
328  }
329  break;
330  }
331  }
332 
333  void Draw(const Window *w) override
334  {
335  this->current_index = 0;
336 
337  for (auto &wid : this->children) {
338  wid->Draw(w);
339  this->current_index++;
340  }
341  }
342 
343 private:
344  int current_index = -1;
345  std::vector<SocialIntegrationPlugin *> plugins;
346 };
347 
349 std::unique_ptr<NWidgetBase> MakeNWidgetSocialPlugins()
350 {
351  return std::make_unique<NWidgetSocialPlugins>();
352 }
353 
355  GameSettings *opt;
356  bool reload;
357  int gui_scale;
358  static inline WidgetID active_tab = WID_GO_TAB_GENERAL;
359 
360  GameOptionsWindow(WindowDesc *desc) : Window(desc)
361  {
362  this->opt = &GetGameSettings();
363  this->reload = false;
364  this->gui_scale = _gui_scale;
365 
367 
369  this->OnInvalidateData(0);
370 
371  this->SetTab(GameOptionsWindow::active_tab);
372 
373  if constexpr (!NetworkSurveyHandler::IsSurveyPossible()) this->GetWidget<NWidgetStacked>(WID_GO_SURVEY_SEL)->SetDisplayedPlane(SZSP_NONE);
374  }
375 
376  void Close([[maybe_unused]] int data = 0) override
377  {
380  if (this->reload) _switch_mode = SM_MENU;
381  this->Window::Close();
382  }
383 
390  DropDownList BuildDropDownList(WidgetID widget, int *selected_index) const
391  {
392  DropDownList list;
393  switch (widget) {
394  case WID_GO_CURRENCY_DROPDOWN: { // Setup currencies dropdown
395  *selected_index = this->opt->locale.currency;
396  uint64_t disabled = _game_mode == GM_MENU ? 0LL : ~GetMaskOfAllowedCurrencies();
397 
398  /* Add non-custom currencies; sorted naturally */
399  for (const CurrencySpec &currency : _currency_specs) {
400  int i = &currency - _currency_specs;
401  if (i == CURRENCY_CUSTOM) continue;
402  if (currency.code.empty()) {
403  list.push_back(std::make_unique<DropDownListStringItem>(currency.name, i, HasBit(disabled, i)));
404  } else {
405  SetDParam(0, currency.name);
406  SetDParamStr(1, currency.code);
407  list.push_back(std::make_unique<DropDownListStringItem>(STR_GAME_OPTIONS_CURRENCY_CODE, i, HasBit(disabled, i)));
408  }
409  }
410  std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
411 
412  /* Append custom currency at the end */
413  list.push_back(std::make_unique<DropDownListDividerItem>(-1, false)); // separator line
414  list.push_back(std::make_unique<DropDownListStringItem>(STR_GAME_OPTIONS_CURRENCY_CUSTOM, CURRENCY_CUSTOM, HasBit(disabled, CURRENCY_CUSTOM)));
415  break;
416  }
417 
418  case WID_GO_AUTOSAVE_DROPDOWN: { // Setup autosave dropdown
419  int index = 0;
420  for (auto &minutes : _autosave_dropdown_to_minutes) {
421  index++;
422  if (_settings_client.gui.autosave_interval <= minutes) break;
423  }
424  *selected_index = index - 1;
425 
426  const StringID *items = _autosave_dropdown;
427  for (uint i = 0; *items != INVALID_STRING_ID; items++, i++) {
428  list.push_back(std::make_unique<DropDownListStringItem>(*items, i, false));
429  }
430  break;
431  }
432 
433  case WID_GO_LANG_DROPDOWN: { // Setup interface language dropdown
434  for (uint i = 0; i < _languages.size(); i++) {
435  bool hide_language = IsReleasedVersion() && !_languages[i].IsReasonablyFinished();
436  if (hide_language) continue;
437  bool hide_percentage = IsReleasedVersion() || _languages[i].missing < _settings_client.gui.missing_strings_threshold;
438  if (&_languages[i] == _current_language) {
439  *selected_index = i;
440  SetDParamStr(0, _languages[i].own_name);
441  } else {
442  /* Especially with sprite-fonts, not all localized
443  * names can be rendered. So instead, we use the
444  * international names for anything but the current
445  * selected language. This avoids showing a few ????
446  * entries in the dropdown list. */
447  SetDParamStr(0, _languages[i].name);
448  }
449  SetDParam(1, (LANGUAGE_TOTAL_STRINGS - _languages[i].missing) * 100 / LANGUAGE_TOTAL_STRINGS);
450  list.push_back(std::make_unique<DropDownListStringItem>(hide_percentage ? STR_JUST_RAW_STRING : STR_GAME_OPTIONS_LANGUAGE_PERCENTAGE, i, false));
451  }
452  std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
453  break;
454  }
455 
456  case WID_GO_RESOLUTION_DROPDOWN: // Setup resolution dropdown
457  if (_resolutions.empty()) break;
458 
459  *selected_index = GetCurrentResolutionIndex();
460  for (uint i = 0; i < _resolutions.size(); i++) {
463  list.push_back(std::make_unique<DropDownListStringItem>(STR_GAME_OPTIONS_RESOLUTION_ITEM, i, false));
464  }
465  break;
466 
467  case WID_GO_REFRESH_RATE_DROPDOWN: // Setup refresh rate dropdown
468  for (auto it = _refresh_rates.begin(); it != _refresh_rates.end(); it++) {
469  auto i = std::distance(_refresh_rates.begin(), it);
470  if (*it == _settings_client.gui.refresh_rate) *selected_index = i;
471  SetDParam(0, *it);
472  list.push_back(std::make_unique<DropDownListStringItem>(STR_GAME_OPTIONS_REFRESH_RATE_ITEM, i, false));
473  }
474  break;
475 
477  list = BuildSetDropDownList<BaseGraphics>(selected_index);
478  break;
479 
481  list = BuildSetDropDownList<BaseSounds>(selected_index);
482  break;
483 
485  list = BuildSetDropDownList<BaseMusic>(selected_index);
486  break;
487  }
488 
489  return list;
490  }
491 
492  void SetStringParameters(WidgetID widget) const override
493  {
494  switch (widget) {
496  const CurrencySpec &currency = _currency_specs[this->opt->locale.currency];
497  if (currency.code.empty()) {
498  SetDParam(0, currency.name);
499  } else {
500  SetDParam(0, STR_GAME_OPTIONS_CURRENCY_CODE);
501  SetDParam(1, currency.name);
502  SetDParamStr(2, currency.code);
503  }
504  break;
505  }
507  int index = 0;
508  for (auto &minutes : _autosave_dropdown_to_minutes) {
509  index++;
510  if (_settings_client.gui.autosave_interval <= minutes) break;
511  }
512  SetDParam(0, _autosave_dropdown[index - 1]);
513  break;
514  }
516  case WID_GO_BASE_GRF_DROPDOWN: SetDParamStr(0, BaseGraphics::GetUsedSet()->GetListLabel()); break;
517  case WID_GO_BASE_SFX_DROPDOWN: SetDParamStr(0, BaseSounds::GetUsedSet()->GetListLabel()); break;
518  case WID_GO_BASE_MUSIC_DROPDOWN: SetDParamStr(0, BaseMusic::GetUsedSet()->GetListLabel()); break;
521  auto current_resolution = GetCurrentResolutionIndex();
522 
523  if (current_resolution == _resolutions.size()) {
524  SetDParam(0, STR_GAME_OPTIONS_RESOLUTION_OTHER);
525  } else {
526  SetDParam(0, STR_GAME_OPTIONS_RESOLUTION_ITEM);
527  SetDParam(1, _resolutions[current_resolution].width);
528  SetDParam(2, _resolutions[current_resolution].height);
529  }
530  break;
531  }
532 
536  const NWidgetSocialPlugins *plugin = this->GetWidget<NWidgetSocialPlugins>(WID_GO_SOCIAL_PLUGINS);
537  assert(plugin != nullptr);
538 
539  plugin->SetStringParameters(widget);
540  break;
541  }
542  }
543  }
544 
545  void DrawWidget(const Rect &r, WidgetID widget) const override
546  {
547  switch (widget) {
550  DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_JUST_RAW_STRING, TC_BLACK);
551  break;
552 
555  DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_JUST_RAW_STRING, TC_BLACK);
556  break;
557 
560  DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_JUST_RAW_STRING, TC_BLACK);
561  break;
562 
563  case WID_GO_GUI_SCALE:
564  DrawSliderWidget(r, MIN_INTERFACE_SCALE, MAX_INTERFACE_SCALE, this->gui_scale, _scale_labels);
565  break;
566 
568  SetDParamStr(0, VideoDriver::GetInstance()->GetInfoString());
569  DrawStringMultiLine(r, STR_GAME_OPTIONS_VIDEO_DRIVER_INFO);
570  break;
571 
573  DrawSliderWidget(r, 0, INT8_MAX, _settings_client.music.effect_vol, _volume_labels);
574  break;
575 
577  DrawSliderWidget(r, 0, INT8_MAX, _settings_client.music.music_vol, _volume_labels);
578  break;
579  }
580  }
581 
582  void SetTab(WidgetID widget)
583  {
585  this->LowerWidget(widget);
586  GameOptionsWindow::active_tab = widget;
587 
588  int pane;
589  switch (widget) {
590  case WID_GO_TAB_GENERAL: pane = 0; break;
591  case WID_GO_TAB_GRAPHICS: pane = 1; break;
592  case WID_GO_TAB_SOUND: pane = 2; break;
593  case WID_GO_TAB_SOCIAL: pane = 3; break;
594  default: NOT_REACHED();
595  }
596 
597  this->GetWidget<NWidgetStacked>(WID_GO_TAB_SELECTION)->SetDisplayedPlane(pane);
598  this->SetDirty();
599  }
600 
601  void OnResize() override
602  {
603  bool changed = false;
604 
605  NWidgetResizeBase *wid = this->GetWidget<NWidgetResizeBase>(WID_GO_BASE_GRF_DESCRIPTION);
606  int y = 0;
607  for (int i = 0; i < BaseGraphics::GetNumSets(); i++) {
609  y = std::max(y, GetStringHeight(STR_JUST_RAW_STRING, wid->current_x));
610  }
611  changed |= wid->UpdateVerticalSize(y);
612 
613  wid = this->GetWidget<NWidgetResizeBase>(WID_GO_BASE_SFX_DESCRIPTION);
614  y = 0;
615  for (int i = 0; i < BaseSounds::GetNumSets(); i++) {
617  y = std::max(y, GetStringHeight(STR_JUST_RAW_STRING, wid->current_x));
618  }
619  changed |= wid->UpdateVerticalSize(y);
620 
621  wid = this->GetWidget<NWidgetResizeBase>(WID_GO_BASE_MUSIC_DESCRIPTION);
622  y = 0;
623  for (int i = 0; i < BaseMusic::GetNumSets(); i++) {
624  SetDParamStr(0, BaseMusic::GetSet(i)->GetDescription(GetCurrentLanguageIsoCode()));
625  y = std::max(y, GetStringHeight(STR_JUST_RAW_STRING, wid->current_x));
626  }
627  changed |= wid->UpdateVerticalSize(y);
628 
629  wid = this->GetWidget<NWidgetResizeBase>(WID_GO_VIDEO_DRIVER_INFO);
630  SetDParamStr(0, VideoDriver::GetInstance()->GetInfoString());
631  y = GetStringHeight(STR_GAME_OPTIONS_VIDEO_DRIVER_INFO, wid->current_x);
632  changed |= wid->UpdateVerticalSize(y);
633 
634  if (changed) this->ReInit(0, 0, this->flags & WF_CENTERED);
635  }
636 
637  void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
638  {
639  switch (widget) {
642  Dimension d = maxdim(GetStringBoundingBox(STR_GAME_OPTIONS_SFX_VOLUME), GetStringBoundingBox(STR_GAME_OPTIONS_MUSIC_VOLUME));
643  d.width += padding.width;
644  d.height += padding.height;
645  *size = maxdim(*size, d);
646  break;
647  }
648 
657  int selected;
658  size->width = std::max(size->width, GetDropDownListDimension(this->BuildDropDownList(widget, &selected)).width + padding.width);
659  break;
660  }
661  }
662  }
663 
664  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
665  {
666  if (widget >= WID_GO_BASE_GRF_TEXTFILE && widget < WID_GO_BASE_GRF_TEXTFILE + TFT_CONTENT_END) {
667  if (BaseGraphics::GetUsedSet() == nullptr) return;
668 
669  ShowBaseSetTextfileWindow((TextfileType)(widget - WID_GO_BASE_GRF_TEXTFILE), BaseGraphics::GetUsedSet(), STR_CONTENT_TYPE_BASE_GRAPHICS);
670  return;
671  }
672  if (widget >= WID_GO_BASE_SFX_TEXTFILE && widget < WID_GO_BASE_SFX_TEXTFILE + TFT_CONTENT_END) {
673  if (BaseSounds::GetUsedSet() == nullptr) return;
674 
675  ShowBaseSetTextfileWindow((TextfileType)(widget - WID_GO_BASE_SFX_TEXTFILE), BaseSounds::GetUsedSet(), STR_CONTENT_TYPE_BASE_SOUNDS);
676  return;
677  }
678  if (widget >= WID_GO_BASE_MUSIC_TEXTFILE && widget < WID_GO_BASE_MUSIC_TEXTFILE + TFT_CONTENT_END) {
679  if (BaseMusic::GetUsedSet() == nullptr) return;
680 
681  ShowBaseSetTextfileWindow((TextfileType)(widget - WID_GO_BASE_MUSIC_TEXTFILE), BaseMusic::GetUsedSet(), STR_CONTENT_TYPE_BASE_MUSIC);
682  return;
683  }
684  switch (widget) {
685  case WID_GO_TAB_GENERAL:
686  case WID_GO_TAB_GRAPHICS:
687  case WID_GO_TAB_SOUND:
688  case WID_GO_TAB_SOCIAL:
689  this->SetTab(widget);
690  break;
691 
694  case PS_ASK:
695  case PS_NO:
697  break;
698 
699  case PS_YES:
701  break;
702  }
703 
706  break;
707 
709  OpenBrowser(NETWORK_SURVEY_DETAILS_LINK);
710  break;
711 
713  ShowSurveyResultTextfileWindow();
714  break;
715 
716  case WID_GO_FULLSCREEN_BUTTON: // Click fullscreen on/off
717  /* try to toggle full-screen on/off */
718  if (!ToggleFullScreen(!_fullscreen)) {
719  ShowErrorMessage(STR_ERROR_FULLSCREEN_FAILED, INVALID_STRING_ID, WL_ERROR);
720  }
723  break;
724 
727  ShowErrorMessage(STR_GAME_OPTIONS_VIDEO_ACCELERATION_RESTART, INVALID_STRING_ID, WL_INFO);
730 #ifndef __APPLE__
733 #endif
734  break;
735 
737  if (!_video_hw_accel) break;
738 
741 
746  break;
747 
750 
752  this->SetDirty();
753 
755  ReInitAllWindows(true);
756  break;
757  }
758 
759 #ifdef HAS_TRUETYPE_FONT
761  _fcsettings.prefer_sprite = !_fcsettings.prefer_sprite;
762 
765  this->SetDirty();
766 
767  InitFontCache(false);
768  InitFontCache(true);
769  ClearFontCache();
773  ReInitAllWindows(true);
774  break;
775 
776  case WID_GO_GUI_FONT_AA:
777  _fcsettings.global_aa = !_fcsettings.global_aa;
778 
781 
782  ClearFontCache();
783  break;
784 #endif /* HAS_TRUETYPE_FONT */
785 
786  case WID_GO_GUI_SCALE:
787  if (ClickSliderWidget(this->GetWidget<NWidgetBase>(widget)->GetCurrentRect(), pt, MIN_INTERFACE_SCALE, MAX_INTERFACE_SCALE, this->gui_scale)) {
788  if (!_ctrl_pressed) this->gui_scale = ((this->gui_scale + 12) / 25) * 25;
789  this->SetWidgetDirty(widget);
790  }
791 
792  if (click_count > 0) this->mouse_capture_widget = widget;
793  break;
794 
796  {
797  if (_gui_scale_cfg == -1) {
800  } else {
801  _gui_scale_cfg = -1;
803  if (AdjustGUIZoom(false)) ReInitAllWindows(true);
804  this->gui_scale = _gui_scale;
805  }
806  this->SetWidgetDirty(widget);
807  break;
808  }
809 
811  auto *used_set = BaseGraphics::GetUsedSet();
812  if (used_set == nullptr || !used_set->IsConfigurable()) break;
813  GRFConfig &extra_cfg = used_set->GetOrCreateExtraConfig();
814  if (extra_cfg.num_params == 0) extra_cfg.SetParameterDefaults();
815  OpenGRFParameterWindow(true, &extra_cfg, _game_mode == GM_MENU);
816  if (_game_mode == GM_MENU) this->reload = true;
817  break;
818  }
819 
823  if (ClickSliderWidget(this->GetWidget<NWidgetBase>(widget)->GetCurrentRect(), pt, 0, INT8_MAX, vol)) {
824  if (widget == WID_GO_BASE_MUSIC_VOLUME) {
826  } else {
827  SetEffectVolume(vol);
828  }
829  this->SetWidgetDirty(widget);
831  }
832 
833  if (click_count > 0) this->mouse_capture_widget = widget;
834  break;
835  }
836 
838  ShowMusicWindow();
839  break;
840  }
841 
843  if (BaseGraphics::GetUsedSet() == nullptr || BaseGraphics::GetUsedSet()->url.empty()) return;
844  OpenBrowser(BaseGraphics::GetUsedSet()->url);
845  break;
846 
848  if (BaseSounds::GetUsedSet() == nullptr || BaseSounds::GetUsedSet()->url.empty()) return;
849  OpenBrowser(BaseSounds::GetUsedSet()->url);
850  break;
851 
853  if (BaseMusic::GetUsedSet() == nullptr || BaseMusic::GetUsedSet()->url.empty()) return;
854  OpenBrowser(BaseMusic::GetUsedSet()->url);
855  break;
856 
865  int selected;
866  DropDownList list = this->BuildDropDownList(widget, &selected);
867  if (!list.empty()) {
868  ShowDropDownList(this, std::move(list), selected, widget);
869  } else {
870  if (widget == WID_GO_RESOLUTION_DROPDOWN) ShowErrorMessage(STR_ERROR_RESOLUTION_LIST_FAILED, INVALID_STRING_ID, WL_ERROR);
871  }
872  break;
873  }
874  }
875  }
876 
877  void OnMouseLoop() override
878  {
879  if (_left_button_down || this->gui_scale == _gui_scale) return;
880 
881  _gui_scale_cfg = this->gui_scale;
882 
883  if (AdjustGUIZoom(false)) {
884  ReInitAllWindows(true);
886  this->SetDirty();
887  }
888  }
889 
890  void OnDropdownSelect(WidgetID widget, int index) override
891  {
892  switch (widget) {
893  case WID_GO_CURRENCY_DROPDOWN: // Currency
894  if (index == CURRENCY_CUSTOM) ShowCustCurrency();
895  this->opt->locale.currency = index;
896  ReInitAllWindows(false);
897  break;
898 
899  case WID_GO_AUTOSAVE_DROPDOWN: // Autosave options
902  this->SetDirty();
903  break;
904 
905  case WID_GO_LANG_DROPDOWN: // Change interface language
906  ReadLanguagePack(&_languages[index]);
909  ClearAllCachedNames();
911  CheckBlitter();
912  ReInitAllWindows(false);
913  break;
914 
915  case WID_GO_RESOLUTION_DROPDOWN: // Change resolution
916  if ((uint)index < _resolutions.size() && ChangeResInGame(_resolutions[index].width, _resolutions[index].height)) {
917  this->SetDirty();
918  }
919  break;
920 
922  _settings_client.gui.refresh_rate = *std::next(_refresh_rates.begin(), index);
923  if (_settings_client.gui.refresh_rate > 60) {
924  /* Show warning to the user that this refresh rate might not be suitable on
925  * larger maps with many NewGRFs and vehicles. */
926  ShowErrorMessage(STR_GAME_OPTIONS_REFRESH_RATE_WARNING, INVALID_STRING_ID, WL_INFO);
927  }
928  break;
929  }
930 
932  if (_game_mode == GM_MENU) {
934  auto set = BaseGraphics::GetSet(index);
936  this->reload = true;
937  this->InvalidateData();
938  }
939  break;
940 
942  if (_game_mode == GM_MENU) {
943  auto set = BaseSounds::GetSet(index);
944  BaseSounds::ini_set = set->name;
945  BaseSounds::SetSet(set);
946  this->reload = true;
947  this->InvalidateData();
948  }
949  break;
950 
952  ChangeMusicSet(index);
953  break;
954  }
955  }
956 
962  void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
963  {
964  if (!gui_scope) return;
969 
970 #ifndef __APPLE__
973 #endif
974 
977 #ifdef HAS_TRUETYPE_FONT
981 #endif /* HAS_TRUETYPE_FONT */
982 
983  this->SetWidgetDisabledState(WID_GO_BASE_GRF_DROPDOWN, _game_mode != GM_MENU);
984  this->SetWidgetDisabledState(WID_GO_BASE_SFX_DROPDOWN, _game_mode != GM_MENU);
985 
987 
991 
992  for (TextfileType tft = TFT_CONTENT_BEGIN; tft < TFT_CONTENT_END; tft++) {
996  }
997  }
998 };
999 
1000 static constexpr NWidgetPart _nested_game_options_widgets[] = {
1002  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
1003  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1004  EndContainer(),
1005  NWidget(WWT_PANEL, COLOUR_GREY),
1007  NWidget(WWT_TEXTBTN, COLOUR_YELLOW, WID_GO_TAB_GENERAL), SetMinimalTextLines(2, 0), SetDataTip(STR_GAME_OPTIONS_TAB_GENERAL, STR_GAME_OPTIONS_TAB_GENERAL_TT), SetFill(1, 0),
1008  NWidget(WWT_TEXTBTN, COLOUR_YELLOW, WID_GO_TAB_GRAPHICS), SetMinimalTextLines(2, 0), SetDataTip(STR_GAME_OPTIONS_TAB_GRAPHICS, STR_GAME_OPTIONS_TAB_GRAPHICS_TT), SetFill(1, 0),
1009  NWidget(WWT_TEXTBTN, COLOUR_YELLOW, WID_GO_TAB_SOUND), SetMinimalTextLines(2, 0), SetDataTip(STR_GAME_OPTIONS_TAB_SOUND, STR_GAME_OPTIONS_TAB_SOUND_TT), SetFill(1, 0),
1010  NWidget(WWT_TEXTBTN, COLOUR_YELLOW, WID_GO_TAB_SOCIAL), SetMinimalTextLines(2, 0), SetDataTip(STR_GAME_OPTIONS_TAB_SOCIAL, STR_GAME_OPTIONS_TAB_SOCIAL_TT), SetFill(1, 0),
1011  EndContainer(),
1012  EndContainer(),
1013  NWidget(WWT_PANEL, COLOUR_GREY),
1014  NWidget(NWID_SELECTION, INVALID_COLOUR, WID_GO_TAB_SELECTION),
1015  /* General tab */
1017  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_LANGUAGE, STR_NULL),
1018  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_LANG_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_JUST_RAW_STRING, STR_GAME_OPTIONS_LANGUAGE_TOOLTIP), SetFill(1, 0),
1019  EndContainer(),
1020 
1021  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_AUTOSAVE_FRAME, STR_NULL),
1022  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_AUTOSAVE_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_JUST_STRING, STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_TOOLTIP), SetFill(1, 0),
1023  EndContainer(),
1024 
1025  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_CURRENCY_UNITS_FRAME, STR_NULL),
1026  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_CURRENCY_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_JUST_STRING2, STR_GAME_OPTIONS_CURRENCY_UNITS_DROPDOWN_TOOLTIP), SetFill(1, 0),
1027  EndContainer(),
1028 
1029  NWidget(NWID_SELECTION, INVALID_COLOUR, WID_GO_SURVEY_SEL),
1030  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_PARTICIPATE_SURVEY_FRAME, STR_NULL), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
1032  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 0), SetDataTip(STR_GAME_OPTIONS_PARTICIPATE_SURVEY, STR_NULL),
1033  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_SURVEY_PARTICIPATE_BUTTON), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_PARTICIPATE_SURVEY_TOOLTIP),
1034  EndContainer(),
1036  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_SURVEY_PREVIEW_BUTTON), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_GAME_OPTIONS_PARTICIPATE_SURVEY_PREVIEW, STR_GAME_OPTIONS_PARTICIPATE_SURVEY_PREVIEW_TOOLTIP),
1037  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_SURVEY_LINK_BUTTON), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_GAME_OPTIONS_PARTICIPATE_SURVEY_LINK, STR_GAME_OPTIONS_PARTICIPATE_SURVEY_LINK_TOOLTIP),
1038  EndContainer(),
1039  EndContainer(),
1040  EndContainer(),
1041  EndContainer(),
1042 
1043  /* Graphics tab */
1045  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_GUI_SCALE_FRAME, STR_NULL),
1047  NWidget(WWT_EMPTY, COLOUR_GREY, WID_GO_GUI_SCALE), SetMinimalSize(67, 0), SetMinimalTextLines(1, 12 + WidgetDimensions::unscaled.vsep_normal, FS_SMALL), SetFill(0, 0), SetDataTip(0x0, STR_GAME_OPTIONS_GUI_SCALE_TOOLTIP),
1049  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 0), SetDataTip(STR_GAME_OPTIONS_GUI_SCALE_AUTO, STR_NULL),
1050  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_GUI_SCALE_AUTO), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_GUI_SCALE_AUTO_TOOLTIP),
1051  EndContainer(),
1053  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 0), SetDataTip(STR_GAME_OPTIONS_GUI_SCALE_BEVELS, STR_NULL),
1054  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_GUI_SCALE_BEVEL_BUTTON), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_GUI_SCALE_BEVELS_TOOLTIP),
1055  EndContainer(),
1056 #ifdef HAS_TRUETYPE_FONT
1058  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 0), SetDataTip(STR_GAME_OPTIONS_GUI_FONT_SPRITE, STR_NULL),
1059  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_GUI_FONT_SPRITE), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_GUI_FONT_SPRITE_TOOLTIP),
1060  EndContainer(),
1062  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 0), SetDataTip(STR_GAME_OPTIONS_GUI_FONT_AA, STR_NULL),
1063  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_GUI_FONT_AA), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_GUI_FONT_AA_TOOLTIP),
1064  EndContainer(),
1065 #endif /* HAS_TRUETYPE_FONT */
1066  EndContainer(),
1067  EndContainer(),
1068 
1069  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_GRAPHICS, STR_NULL),
1072  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 0), SetDataTip(STR_GAME_OPTIONS_RESOLUTION, STR_NULL),
1073  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_RESOLUTION_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_JUST_STRING2, STR_GAME_OPTIONS_RESOLUTION_TOOLTIP),
1074  EndContainer(),
1076  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 0), SetDataTip(STR_GAME_OPTIONS_REFRESH_RATE, STR_NULL),
1077  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_REFRESH_RATE_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_GAME_OPTIONS_REFRESH_RATE_ITEM, STR_GAME_OPTIONS_REFRESH_RATE_TOOLTIP),
1078  EndContainer(),
1080  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 0), SetDataTip(STR_GAME_OPTIONS_FULLSCREEN, STR_NULL),
1081  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_FULLSCREEN_BUTTON), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_FULLSCREEN_TOOLTIP),
1082  EndContainer(),
1084  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 0), SetDataTip(STR_GAME_OPTIONS_VIDEO_ACCELERATION, STR_NULL),
1085  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_VIDEO_ACCEL_BUTTON), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_VIDEO_ACCELERATION_TOOLTIP),
1086  EndContainer(),
1087 #ifndef __APPLE__
1089  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 0), SetDataTip(STR_GAME_OPTIONS_VIDEO_VSYNC, STR_NULL),
1090  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_VIDEO_VSYNC_BUTTON), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_VIDEO_VSYNC_TOOLTIP),
1091  EndContainer(),
1092 #endif
1094  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GO_VIDEO_DRIVER_INFO), SetMinimalTextLines(1, 0), SetFill(1, 0),
1095  EndContainer(),
1096  EndContainer(),
1097  EndContainer(),
1098 
1099  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_BASE_GRF, STR_NULL), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0), SetFill(1, 0),
1101  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_GRF_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_JUST_RAW_STRING, STR_GAME_OPTIONS_BASE_GRF_TOOLTIP), SetFill(1, 0),
1102  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_GRF_PARAMETERS), SetDataTip(STR_NEWGRF_SETTINGS_SET_PARAMETERS, STR_NULL),
1103  EndContainer(),
1104  NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_BASE_GRF_DESCRIPTION), SetMinimalSize(200, 0), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_BASE_GRF_DESCRIPTION_TOOLTIP), SetFill(1, 0),
1107  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_GRF_OPEN_URL), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_CONTENT_OPEN_URL, STR_CONTENT_OPEN_URL_TOOLTIP),
1108  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_GRF_TEXTFILE + TFT_README), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_README, STR_TEXTFILE_VIEW_README_TOOLTIP),
1109  EndContainer(),
1111  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_GRF_TEXTFILE + TFT_CHANGELOG), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_CHANGELOG, STR_TEXTFILE_VIEW_CHANGELOG_TOOLTIP),
1112  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_GRF_TEXTFILE + TFT_LICENSE), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_LICENCE, STR_TEXTFILE_VIEW_LICENCE_TOOLTIP),
1113  EndContainer(),
1114  EndContainer(),
1115  EndContainer(),
1116  EndContainer(),
1117 
1118  /* Sound/Music tab */
1120  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_VOLUME, STR_NULL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0),
1122  NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_TEXT_SFX_VOLUME), SetMinimalSize(0, 12), SetDataTip(STR_GAME_OPTIONS_SFX_VOLUME, STR_NULL),
1123  NWidget(WWT_EMPTY, COLOUR_GREY, WID_GO_BASE_SFX_VOLUME), SetMinimalSize(67, 0), SetMinimalTextLines(1, 12 + WidgetDimensions::unscaled.vsep_normal, FS_SMALL), SetFill(1, 0), SetDataTip(0x0, STR_MUSIC_TOOLTIP_DRAG_SLIDERS_TO_SET_MUSIC),
1124  EndContainer(),
1126  NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_TEXT_MUSIC_VOLUME), SetMinimalSize(0, 12), SetDataTip(STR_GAME_OPTIONS_MUSIC_VOLUME, STR_NULL),
1127  NWidget(WWT_EMPTY, COLOUR_GREY, WID_GO_BASE_MUSIC_VOLUME), SetMinimalSize(67, 0), SetMinimalTextLines(1, 12 + WidgetDimensions::unscaled.vsep_normal, FS_SMALL), SetFill(1, 0), SetDataTip(0x0, STR_MUSIC_TOOLTIP_DRAG_SLIDERS_TO_SET_MUSIC),
1128  EndContainer(),
1129  EndContainer(),
1130 
1131  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_BASE_SFX, STR_NULL), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
1132  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_SFX_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_JUST_RAW_STRING, STR_GAME_OPTIONS_BASE_SFX_TOOLTIP), SetFill(1, 0),
1133  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GO_BASE_SFX_DESCRIPTION), SetMinimalSize(200, 0), SetMinimalTextLines(1, 0), SetDataTip(STR_NULL, STR_GAME_OPTIONS_BASE_SFX_DESCRIPTION_TOOLTIP), SetFill(1, 0),
1136  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_SFX_OPEN_URL), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_CONTENT_OPEN_URL, STR_CONTENT_OPEN_URL_TOOLTIP),
1137  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_SFX_TEXTFILE + TFT_README), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_README, STR_TEXTFILE_VIEW_README_TOOLTIP),
1138  EndContainer(),
1140  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_SFX_TEXTFILE + TFT_CHANGELOG), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_CHANGELOG, STR_TEXTFILE_VIEW_CHANGELOG_TOOLTIP),
1141  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_SFX_TEXTFILE + TFT_LICENSE), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_LICENCE, STR_TEXTFILE_VIEW_LICENCE_TOOLTIP),
1142  EndContainer(),
1143  EndContainer(),
1144  EndContainer(),
1145 
1146  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_BASE_MUSIC, STR_NULL), SetPIP(0, WidgetDimensions::unscaled.vsep_sparse, 0),
1147  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_MUSIC_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_JUST_RAW_STRING, STR_GAME_OPTIONS_BASE_MUSIC_TOOLTIP), SetFill(1, 0),
1149  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GO_BASE_MUSIC_DESCRIPTION), SetMinimalSize(200, 0), SetMinimalTextLines(1, 0), SetDataTip(STR_NULL, STR_GAME_OPTIONS_BASE_MUSIC_DESCRIPTION_TOOLTIP), SetFill(1, 0),
1150  NWidget(NWID_VERTICAL), SetPIPRatio(0, 0, 1),
1151  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_GO_BASE_MUSIC_JUKEBOX), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_MUSIC, STR_TOOLBAR_TOOLTIP_SHOW_SOUND_MUSIC_WINDOW),
1152  EndContainer(),
1153  EndContainer(),
1156  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_MUSIC_OPEN_URL), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_CONTENT_OPEN_URL, STR_CONTENT_OPEN_URL_TOOLTIP),
1157  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_MUSIC_TEXTFILE + TFT_README), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_README, STR_TEXTFILE_VIEW_README_TOOLTIP),
1158  EndContainer(),
1160  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_MUSIC_TEXTFILE + TFT_CHANGELOG), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_CHANGELOG, STR_TEXTFILE_VIEW_CHANGELOG_TOOLTIP),
1161  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_MUSIC_TEXTFILE + TFT_LICENSE), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_LICENCE, STR_TEXTFILE_VIEW_LICENCE_TOOLTIP),
1162  EndContainer(),
1163  EndContainer(),
1164  EndContainer(),
1165  EndContainer(),
1166 
1167  /* Social tab */
1170  EndContainer(),
1171  EndContainer(),
1172  EndContainer(),
1173 };
1174 
1175 static WindowDesc _game_options_desc(__FILE__, __LINE__,
1176  WDP_CENTER, nullptr, 0, 0,
1178  0,
1179  std::begin(_nested_game_options_widgets), std::end(_nested_game_options_widgets)
1180 );
1181 
1184 {
1186  new GameOptionsWindow(&_game_options_desc);
1187 }
1188 
1189 static int SETTING_HEIGHT = 11;
1190 
1199 
1201  SEF_FILTERED = 0x08,
1202 };
1203 
1212 };
1214 
1215 
1219  bool type_hides;
1222 };
1223 
1226  byte flags;
1227  byte level;
1228 
1229  BaseSettingEntry() : flags(0), level(0) {}
1230  virtual ~BaseSettingEntry() = default;
1231 
1232  virtual void Init(byte level = 0);
1233  virtual void FoldAll() {}
1234  virtual void UnFoldAll() {}
1235  virtual void ResetAll() = 0;
1236 
1241  void SetLastField(bool last_field) { if (last_field) SETBITS(this->flags, SEF_LAST_FIELD); else CLRBITS(this->flags, SEF_LAST_FIELD); }
1242 
1243  virtual uint Length() const = 0;
1244  virtual void GetFoldingState([[maybe_unused]] bool &all_folded, [[maybe_unused]] bool &all_unfolded) const {}
1245  virtual bool IsVisible(const BaseSettingEntry *item) const;
1246  virtual BaseSettingEntry *FindEntry(uint row, uint *cur_row);
1247  virtual uint GetMaxHelpHeight([[maybe_unused]] int maxw) { return 0; }
1248 
1253  bool IsFiltered() const { return (this->flags & SEF_FILTERED) != 0; }
1254 
1255  virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible) = 0;
1256 
1257  virtual 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;
1258 
1259 protected:
1260  virtual void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const = 0;
1261 };
1262 
1265  const char *name;
1267 
1268  SettingEntry(const char *name);
1269 
1270  void Init(byte level = 0) override;
1271  void ResetAll() override;
1272  uint Length() const override;
1273  uint GetMaxHelpHeight(int maxw) override;
1274  bool UpdateFilterState(SettingFilter &filter, bool force_visible) override;
1275 
1276  void SetButtons(byte new_val);
1277 
1278 protected:
1279  void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const override;
1280 
1281 private:
1283 };
1284 
1287  typedef std::vector<BaseSettingEntry*> EntryVector;
1288  EntryVector entries;
1289 
1290  template<typename T>
1291  T *Add(T *item)
1292  {
1293  this->entries.push_back(item);
1294  return item;
1295  }
1296 
1297  void Init(byte level = 0);
1298  void ResetAll();
1299  void FoldAll();
1300  void UnFoldAll();
1301 
1302  uint Length() const;
1303  void GetFoldingState(bool &all_folded, bool &all_unfolded) const;
1304  bool IsVisible(const BaseSettingEntry *item) const;
1305  BaseSettingEntry *FindEntry(uint row, uint *cur_row);
1306  uint GetMaxHelpHeight(int maxw);
1307 
1308  bool UpdateFilterState(SettingFilter &filter, bool force_visible);
1309 
1310  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;
1311 };
1312 
1316  bool folded;
1317 
1319 
1320  void Init(byte level = 0) override;
1321  void ResetAll() override;
1322  void FoldAll() override;
1323  void UnFoldAll() override;
1324 
1325  uint Length() const override;
1326  void GetFoldingState(bool &all_folded, bool &all_unfolded) const override;
1327  bool IsVisible(const BaseSettingEntry *item) const override;
1328  BaseSettingEntry *FindEntry(uint row, uint *cur_row) override;
1329  uint GetMaxHelpHeight(int maxw) override { return SettingsContainer::GetMaxHelpHeight(maxw); }
1330 
1331  bool UpdateFilterState(SettingFilter &filter, bool force_visible) override;
1332 
1333  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 override;
1334 
1335 protected:
1336  void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const override;
1337 };
1338 
1339 /* == BaseSettingEntry methods == */
1340 
1345 void BaseSettingEntry::Init(byte level)
1346 {
1347  this->level = level;
1348 }
1349 
1357 {
1358  if (this->IsFiltered()) return false;
1359  return this == item;
1360 }
1361 
1368 BaseSettingEntry *BaseSettingEntry::FindEntry(uint row_num, uint *cur_row)
1369 {
1370  if (this->IsFiltered()) return nullptr;
1371  if (row_num == *cur_row) return this;
1372  (*cur_row)++;
1373  return nullptr;
1374 }
1375 
1405 uint BaseSettingEntry::Draw(GameSettings *settings_ptr, int left, int right, int y, uint first_row, uint max_row, BaseSettingEntry *selected, uint cur_row, uint parent_last) const
1406 {
1407  if (this->IsFiltered()) return cur_row;
1408  if (cur_row >= max_row) return cur_row;
1409 
1410  bool rtl = _current_text_dir == TD_RTL;
1411  int offset = (rtl ? -(int)_circle_size.width : (int)_circle_size.width) / 2;
1413 
1414  int x = rtl ? right : left;
1415  if (cur_row >= first_row) {
1416  int colour = _colour_gradient[COLOUR_ORANGE][4];
1417  y += (cur_row - first_row) * SETTING_HEIGHT; // Compute correct y start position
1418 
1419  /* Draw vertical for parent nesting levels */
1420  for (uint lvl = 0; lvl < this->level; lvl++) {
1421  if (!HasBit(parent_last, lvl)) GfxDrawLine(x + offset, y, x + offset, y + SETTING_HEIGHT - 1, colour);
1422  x += level_width;
1423  }
1424  /* draw own |- prefix */
1425  int halfway_y = y + SETTING_HEIGHT / 2;
1426  int bottom_y = (flags & SEF_LAST_FIELD) ? halfway_y : y + SETTING_HEIGHT - 1;
1427  GfxDrawLine(x + offset, y, x + offset, bottom_y, colour);
1428  /* Small horizontal line from the last vertical line */
1429  GfxDrawLine(x + offset, halfway_y, x + level_width - (rtl ? -WidgetDimensions::scaled.hsep_normal : WidgetDimensions::scaled.hsep_normal), halfway_y, colour);
1430  x += level_width;
1431 
1432  this->DrawSetting(settings_ptr, rtl ? left : x, rtl ? x : right, y, this == selected);
1433  }
1434  cur_row++;
1435 
1436  return cur_row;
1437 }
1438 
1439 /* == SettingEntry methods == */
1440 
1446 {
1447  this->name = name;
1448  this->setting = nullptr;
1449 }
1450 
1455 void SettingEntry::Init(byte level)
1456 {
1458  this->setting = GetSettingFromName(this->name)->AsIntSetting();
1459 }
1460 
1461 /* Sets the given setting entry to its default value */
1462 void SettingEntry::ResetAll()
1463 {
1464  SetSettingValue(this->setting, this->setting->def);
1465 }
1466 
1472 void SettingEntry::SetButtons(byte new_val)
1473 {
1474  assert((new_val & ~SEF_BUTTONS_MASK) == 0); // Should not touch any flags outside the buttons
1475  this->flags = (this->flags & ~SEF_BUTTONS_MASK) | new_val;
1476 }
1477 
1480 {
1481  return this->IsFiltered() ? 0 : 1;
1482 }
1483 
1490 {
1491  return GetStringHeight(this->setting->GetHelp(), maxw);
1492 }
1493 
1500 {
1501  /* There shall not be any restriction, i.e. all settings shall be visible. */
1502  if (mode == RM_ALL) return true;
1503 
1504  const IntSettingDesc *sd = this->setting;
1505 
1506  if (mode == RM_BASIC) return (this->setting->cat & SC_BASIC_LIST) != 0;
1507  if (mode == RM_ADVANCED) return (this->setting->cat & SC_ADVANCED_LIST) != 0;
1508 
1509  /* Read the current value. */
1510  const void *object = ResolveObject(&GetGameSettings(), sd);
1511  int64_t current_value = sd->Read(object);
1512  int64_t filter_value;
1513 
1514  if (mode == RM_CHANGED_AGAINST_DEFAULT) {
1515  /* This entry shall only be visible, if the value deviates from its default value. */
1516 
1517  /* Read the default value. */
1518  filter_value = sd->def;
1519  } else {
1520  assert(mode == RM_CHANGED_AGAINST_NEW);
1521  /* This entry shall only be visible, if the value deviates from
1522  * its value is used when starting a new game. */
1523 
1524  /* Make sure we're not comparing the new game settings against itself. */
1525  assert(&GetGameSettings() != &_settings_newgame);
1526 
1527  /* Read the new game's value. */
1528  filter_value = sd->Read(ResolveObject(&_settings_newgame, sd));
1529  }
1530 
1531  return current_value != filter_value;
1532 }
1533 
1540 bool SettingEntry::UpdateFilterState(SettingFilter &filter, bool force_visible)
1541 {
1542  CLRBITS(this->flags, SEF_FILTERED);
1543 
1544  bool visible = true;
1545 
1546  const IntSettingDesc *sd = this->setting;
1547  if (!force_visible && !filter.string.IsEmpty()) {
1548  /* Process the search text filter for this item. */
1549  filter.string.ResetState();
1550 
1551  SetDParam(0, STR_EMPTY);
1552  filter.string.AddLine(sd->GetTitle());
1553  filter.string.AddLine(sd->GetHelp());
1554 
1555  visible = filter.string.GetState();
1556  }
1557 
1558  if (visible) {
1559  if (filter.type != ST_ALL && sd->GetType() != filter.type) {
1560  filter.type_hides = true;
1561  visible = false;
1562  }
1563  if (!this->IsVisibleByRestrictionMode(filter.mode)) {
1564  while (filter.min_cat < RM_ALL && (filter.min_cat == filter.mode || !this->IsVisibleByRestrictionMode(filter.min_cat))) filter.min_cat++;
1565  visible = false;
1566  }
1567  }
1568 
1569  if (!visible) SETBITS(this->flags, SEF_FILTERED);
1570  return visible;
1571 }
1572 
1573 static const void *ResolveObject(const GameSettings *settings_ptr, const IntSettingDesc *sd)
1574 {
1575  if ((sd->flags & SF_PER_COMPANY) != 0) {
1576  if (Company::IsValidID(_local_company) && _game_mode != GM_MENU) {
1577  return &Company::Get(_local_company)->settings;
1578  }
1579  return &_settings_client.company;
1580  }
1581  return settings_ptr;
1582 }
1583 
1592 void SettingEntry::DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const
1593 {
1594  const IntSettingDesc *sd = this->setting;
1595  int state = this->flags & SEF_BUTTONS_MASK;
1596 
1597  bool rtl = _current_text_dir == TD_RTL;
1598  uint buttons_left = rtl ? right + 1 - SETTING_BUTTON_WIDTH : left;
1599  uint text_left = left + (rtl ? 0 : SETTING_BUTTON_WIDTH + WidgetDimensions::scaled.hsep_wide);
1600  uint text_right = right - (rtl ? SETTING_BUTTON_WIDTH + WidgetDimensions::scaled.hsep_wide : 0);
1601  uint button_y = y + (SETTING_HEIGHT - SETTING_BUTTON_HEIGHT) / 2;
1602 
1603  /* We do not allow changes of some items when we are a client in a networkgame */
1604  bool editable = sd->IsEditable();
1605 
1606  SetDParam(0, STR_CONFIG_SETTING_VALUE);
1607  int32_t value = sd->Read(ResolveObject(settings_ptr, sd));
1608  if (sd->IsBoolSetting()) {
1609  /* Draw checkbox for boolean-value either on/off */
1610  DrawBoolButton(buttons_left, button_y, value != 0, editable);
1611  } else if ((sd->flags & SF_GUI_DROPDOWN) != 0) {
1612  /* Draw [v] button for settings of an enum-type */
1613  DrawDropDownButton(buttons_left, button_y, COLOUR_YELLOW, state != 0, editable);
1614  } else {
1615  /* Draw [<][>] boxes for settings of an integer-type */
1616  DrawArrowButtons(buttons_left, button_y, COLOUR_YELLOW, state,
1617  editable && value != (sd->flags & SF_GUI_0_IS_SPECIAL ? 0 : sd->min), editable && (uint32_t)value != sd->max);
1618  }
1619  sd->SetValueDParams(1, value);
1620  DrawString(text_left, text_right, y + (SETTING_HEIGHT - GetCharacterHeight(FS_NORMAL)) / 2, sd->GetTitle(), highlight ? TC_WHITE : TC_LIGHT_BLUE);
1621 }
1622 
1623 /* == SettingsContainer methods == */
1624 
1629 void SettingsContainer::Init(byte level)
1630 {
1631  for (auto &it : this->entries) {
1632  it->Init(level);
1633  }
1634 }
1635 
1638 {
1639  for (auto settings_entry : this->entries) {
1640  settings_entry->ResetAll();
1641  }
1642 }
1643 
1646 {
1647  for (auto &it : this->entries) {
1648  it->FoldAll();
1649  }
1650 }
1651 
1654 {
1655  for (auto &it : this->entries) {
1656  it->UnFoldAll();
1657  }
1658 }
1659 
1665 void SettingsContainer::GetFoldingState(bool &all_folded, bool &all_unfolded) const
1666 {
1667  for (auto &it : this->entries) {
1668  it->GetFoldingState(all_folded, all_unfolded);
1669  }
1670 }
1671 
1678 bool SettingsContainer::UpdateFilterState(SettingFilter &filter, bool force_visible)
1679 {
1680  bool visible = false;
1681  bool first_visible = true;
1682  for (EntryVector::reverse_iterator it = this->entries.rbegin(); it != this->entries.rend(); ++it) {
1683  visible |= (*it)->UpdateFilterState(filter, force_visible);
1684  (*it)->SetLastField(first_visible);
1685  if (visible && first_visible) first_visible = false;
1686  }
1687  return visible;
1688 }
1689 
1690 
1698 {
1699  for (const auto &it : this->entries) {
1700  if (it->IsVisible(item)) return true;
1701  }
1702  return false;
1703 }
1704 
1707 {
1708  uint length = 0;
1709  for (const auto &it : this->entries) {
1710  length += it->Length();
1711  }
1712  return length;
1713 }
1714 
1721 BaseSettingEntry *SettingsContainer::FindEntry(uint row_num, uint *cur_row)
1722 {
1723  BaseSettingEntry *pe = nullptr;
1724  for (const auto &it : this->entries) {
1725  pe = it->FindEntry(row_num, cur_row);
1726  if (pe != nullptr) {
1727  break;
1728  }
1729  }
1730  return pe;
1731 }
1732 
1739 {
1740  uint biggest = 0;
1741  for (const auto &it : this->entries) {
1742  biggest = std::max(biggest, it->GetMaxHelpHeight(maxw));
1743  }
1744  return biggest;
1745 }
1746 
1747 
1762 uint SettingsContainer::Draw(GameSettings *settings_ptr, int left, int right, int y, uint first_row, uint max_row, BaseSettingEntry *selected, uint cur_row, uint parent_last) const
1763 {
1764  for (const auto &it : this->entries) {
1765  cur_row = it->Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1766  if (cur_row >= max_row) break;
1767  }
1768  return cur_row;
1769 }
1770 
1771 /* == SettingsPage methods == */
1772 
1778 {
1779  this->title = title;
1780  this->folded = true;
1781 }
1782 
1787 void SettingsPage::Init(byte level)
1788 {
1791 }
1792 
1795 {
1796  for (auto settings_entry : this->entries) {
1797  settings_entry->ResetAll();
1798  }
1799 }
1800 
1803 {
1804  if (this->IsFiltered()) return;
1805  this->folded = true;
1806 
1808 }
1809 
1812 {
1813  if (this->IsFiltered()) return;
1814  this->folded = false;
1815 
1817 }
1818 
1824 void SettingsPage::GetFoldingState(bool &all_folded, bool &all_unfolded) const
1825 {
1826  if (this->IsFiltered()) return;
1827 
1828  if (this->folded) {
1829  all_unfolded = false;
1830  } else {
1831  all_folded = false;
1832  }
1833 
1834  SettingsContainer::GetFoldingState(all_folded, all_unfolded);
1835 }
1836 
1843 bool SettingsPage::UpdateFilterState(SettingFilter &filter, bool force_visible)
1844 {
1845  if (!force_visible && !filter.string.IsEmpty()) {
1846  filter.string.ResetState();
1847  filter.string.AddLine(this->title);
1848  force_visible = filter.string.GetState();
1849  }
1850 
1851  bool visible = SettingsContainer::UpdateFilterState(filter, force_visible);
1852  if (visible) {
1853  CLRBITS(this->flags, SEF_FILTERED);
1854  } else {
1855  SETBITS(this->flags, SEF_FILTERED);
1856  }
1857  return visible;
1858 }
1859 
1867 {
1868  if (this->IsFiltered()) return false;
1869  if (this == item) return true;
1870  if (this->folded) return false;
1871 
1872  return SettingsContainer::IsVisible(item);
1873 }
1874 
1877 {
1878  if (this->IsFiltered()) return 0;
1879  if (this->folded) return 1; // Only displaying the title
1880 
1881  return 1 + SettingsContainer::Length();
1882 }
1883 
1890 BaseSettingEntry *SettingsPage::FindEntry(uint row_num, uint *cur_row)
1891 {
1892  if (this->IsFiltered()) return nullptr;
1893  if (row_num == *cur_row) return this;
1894  (*cur_row)++;
1895  if (this->folded) return nullptr;
1896 
1897  return SettingsContainer::FindEntry(row_num, cur_row);
1898 }
1899 
1914 uint SettingsPage::Draw(GameSettings *settings_ptr, int left, int right, int y, uint first_row, uint max_row, BaseSettingEntry *selected, uint cur_row, uint parent_last) const
1915 {
1916  if (this->IsFiltered()) return cur_row;
1917  if (cur_row >= max_row) return cur_row;
1918 
1919  cur_row = BaseSettingEntry::Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1920 
1921  if (!this->folded) {
1922  if (this->flags & SEF_LAST_FIELD) {
1923  assert(this->level < 8 * sizeof(parent_last));
1924  SetBit(parent_last, this->level); // Add own last-field state
1925  }
1926 
1927  cur_row = SettingsContainer::Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1928  }
1929 
1930  return cur_row;
1931 }
1932 
1939 void SettingsPage::DrawSetting(GameSettings *, int left, int right, int y, bool) const
1940 {
1941  bool rtl = _current_text_dir == TD_RTL;
1942  DrawSprite((this->folded ? SPR_CIRCLE_FOLDED : SPR_CIRCLE_UNFOLDED), PAL_NONE, rtl ? right - _circle_size.width : left, y + (SETTING_HEIGHT - _circle_size.height) / 2);
1943  DrawString(rtl ? left : left + _circle_size.width + WidgetDimensions::scaled.hsep_normal, rtl ? right - _circle_size.width - WidgetDimensions::scaled.hsep_normal : right, y + (SETTING_HEIGHT - GetCharacterHeight(FS_NORMAL)) / 2, this->title, TC_ORANGE);
1944 }
1945 
1948 {
1949  static SettingsContainer *main = nullptr;
1950 
1951  if (main == nullptr)
1952  {
1953  /* Build up the dynamic settings-array only once per OpenTTD session */
1954  main = new SettingsContainer();
1955 
1956  SettingsPage *localisation = main->Add(new SettingsPage(STR_CONFIG_SETTING_LOCALISATION));
1957  {
1958  localisation->Add(new SettingEntry("locale.units_velocity"));
1959  localisation->Add(new SettingEntry("locale.units_velocity_nautical"));
1960  localisation->Add(new SettingEntry("locale.units_power"));
1961  localisation->Add(new SettingEntry("locale.units_weight"));
1962  localisation->Add(new SettingEntry("locale.units_volume"));
1963  localisation->Add(new SettingEntry("locale.units_force"));
1964  localisation->Add(new SettingEntry("locale.units_height"));
1965  localisation->Add(new SettingEntry("gui.date_format_in_default_names"));
1966  }
1967 
1968  SettingsPage *graphics = main->Add(new SettingsPage(STR_CONFIG_SETTING_GRAPHICS));
1969  {
1970  graphics->Add(new SettingEntry("gui.zoom_min"));
1971  graphics->Add(new SettingEntry("gui.zoom_max"));
1972  graphics->Add(new SettingEntry("gui.sprite_zoom_min"));
1973  graphics->Add(new SettingEntry("gui.smallmap_land_colour"));
1974  graphics->Add(new SettingEntry("gui.linkgraph_colours"));
1975  graphics->Add(new SettingEntry("gui.graph_line_thickness"));
1976  }
1977 
1978  SettingsPage *sound = main->Add(new SettingsPage(STR_CONFIG_SETTING_SOUND));
1979  {
1980  sound->Add(new SettingEntry("sound.click_beep"));
1981  sound->Add(new SettingEntry("sound.confirm"));
1982  sound->Add(new SettingEntry("sound.news_ticker"));
1983  sound->Add(new SettingEntry("sound.news_full"));
1984  sound->Add(new SettingEntry("sound.new_year"));
1985  sound->Add(new SettingEntry("sound.disaster"));
1986  sound->Add(new SettingEntry("sound.vehicle"));
1987  sound->Add(new SettingEntry("sound.ambient"));
1988  }
1989 
1990  SettingsPage *interface = main->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE));
1991  {
1992  SettingsPage *general = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_GENERAL));
1993  {
1994  general->Add(new SettingEntry("gui.osk_activation"));
1995  general->Add(new SettingEntry("gui.hover_delay_ms"));
1996  general->Add(new SettingEntry("gui.errmsg_duration"));
1997  general->Add(new SettingEntry("gui.window_snap_radius"));
1998  general->Add(new SettingEntry("gui.window_soft_limit"));
1999  general->Add(new SettingEntry("gui.right_click_wnd_close"));
2000  }
2001 
2002  SettingsPage *viewports = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_VIEWPORTS));
2003  {
2004  viewports->Add(new SettingEntry("gui.auto_scrolling"));
2005  viewports->Add(new SettingEntry("gui.scroll_mode"));
2006  viewports->Add(new SettingEntry("gui.smooth_scroll"));
2007  /* While the horizontal scrollwheel scrolling is written as general code, only
2008  * the cocoa (OSX) driver generates input for it.
2009  * Since it's also able to completely disable the scrollwheel will we display it on all platforms anyway */
2010  viewports->Add(new SettingEntry("gui.scrollwheel_scrolling"));
2011  viewports->Add(new SettingEntry("gui.scrollwheel_multiplier"));
2012 #ifdef __APPLE__
2013  /* We might need to emulate a right mouse button on mac */
2014  viewports->Add(new SettingEntry("gui.right_mouse_btn_emulation"));
2015 #endif
2016  viewports->Add(new SettingEntry("gui.population_in_label"));
2017  viewports->Add(new SettingEntry("gui.liveries"));
2018  viewports->Add(new SettingEntry("construction.train_signal_side"));
2019  viewports->Add(new SettingEntry("gui.measure_tooltip"));
2020  viewports->Add(new SettingEntry("gui.loading_indicators"));
2021  viewports->Add(new SettingEntry("gui.show_track_reservation"));
2022  }
2023 
2024  SettingsPage *construction = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_CONSTRUCTION));
2025  {
2026  construction->Add(new SettingEntry("gui.link_terraform_toolbar"));
2027  construction->Add(new SettingEntry("gui.persistent_buildingtools"));
2028  construction->Add(new SettingEntry("gui.default_rail_type"));
2029  construction->Add(new SettingEntry("gui.semaphore_build_before"));
2030  construction->Add(new SettingEntry("gui.signal_gui_mode"));
2031  construction->Add(new SettingEntry("gui.cycle_signal_types"));
2032  construction->Add(new SettingEntry("gui.drag_signals_fixed_distance"));
2033  construction->Add(new SettingEntry("gui.auto_remove_signals"));
2034  }
2035 
2036  interface->Add(new SettingEntry("gui.toolbar_pos"));
2037  interface->Add(new SettingEntry("gui.statusbar_pos"));
2038  interface->Add(new SettingEntry("gui.prefer_teamchat"));
2039  interface->Add(new SettingEntry("gui.advanced_vehicle_list"));
2040  interface->Add(new SettingEntry("gui.timetable_mode"));
2041  interface->Add(new SettingEntry("gui.timetable_arrival_departure"));
2042  interface->Add(new SettingEntry("gui.show_newgrf_name"));
2043  interface->Add(new SettingEntry("gui.show_cargo_in_vehicle_lists"));
2044  }
2045 
2046  SettingsPage *advisors = main->Add(new SettingsPage(STR_CONFIG_SETTING_ADVISORS));
2047  {
2048  advisors->Add(new SettingEntry("gui.coloured_news_year"));
2049  advisors->Add(new SettingEntry("news_display.general"));
2050  advisors->Add(new SettingEntry("news_display.new_vehicles"));
2051  advisors->Add(new SettingEntry("news_display.accident"));
2052  advisors->Add(new SettingEntry("news_display.accident_other"));
2053  advisors->Add(new SettingEntry("news_display.company_info"));
2054  advisors->Add(new SettingEntry("news_display.acceptance"));
2055  advisors->Add(new SettingEntry("news_display.arrival_player"));
2056  advisors->Add(new SettingEntry("news_display.arrival_other"));
2057  advisors->Add(new SettingEntry("news_display.advice"));
2058  advisors->Add(new SettingEntry("gui.order_review_system"));
2059  advisors->Add(new SettingEntry("gui.vehicle_income_warn"));
2060  advisors->Add(new SettingEntry("gui.lost_vehicle_warn"));
2061  advisors->Add(new SettingEntry("gui.show_finances"));
2062  advisors->Add(new SettingEntry("news_display.economy"));
2063  advisors->Add(new SettingEntry("news_display.subsidies"));
2064  advisors->Add(new SettingEntry("news_display.open"));
2065  advisors->Add(new SettingEntry("news_display.close"));
2066  advisors->Add(new SettingEntry("news_display.production_player"));
2067  advisors->Add(new SettingEntry("news_display.production_other"));
2068  advisors->Add(new SettingEntry("news_display.production_nobody"));
2069  }
2070 
2071  SettingsPage *company = main->Add(new SettingsPage(STR_CONFIG_SETTING_COMPANY));
2072  {
2073  company->Add(new SettingEntry("gui.starting_colour"));
2074  company->Add(new SettingEntry("gui.starting_colour_secondary"));
2075  company->Add(new SettingEntry("company.engine_renew"));
2076  company->Add(new SettingEntry("company.engine_renew_months"));
2077  company->Add(new SettingEntry("company.engine_renew_money"));
2078  company->Add(new SettingEntry("vehicle.servint_ispercent"));
2079  company->Add(new SettingEntry("vehicle.servint_trains"));
2080  company->Add(new SettingEntry("vehicle.servint_roadveh"));
2081  company->Add(new SettingEntry("vehicle.servint_ships"));
2082  company->Add(new SettingEntry("vehicle.servint_aircraft"));
2083  }
2084 
2085  SettingsPage *accounting = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCOUNTING));
2086  {
2087  accounting->Add(new SettingEntry("difficulty.infinite_money"));
2088  accounting->Add(new SettingEntry("economy.inflation"));
2089  accounting->Add(new SettingEntry("difficulty.initial_interest"));
2090  accounting->Add(new SettingEntry("difficulty.max_loan"));
2091  accounting->Add(new SettingEntry("difficulty.subsidy_multiplier"));
2092  accounting->Add(new SettingEntry("difficulty.subsidy_duration"));
2093  accounting->Add(new SettingEntry("economy.feeder_payment_share"));
2094  accounting->Add(new SettingEntry("economy.infrastructure_maintenance"));
2095  accounting->Add(new SettingEntry("difficulty.vehicle_costs"));
2096  accounting->Add(new SettingEntry("difficulty.construction_cost"));
2097  }
2098 
2099  SettingsPage *vehicles = main->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES));
2100  {
2101  SettingsPage *physics = vehicles->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES_PHYSICS));
2102  {
2103  physics->Add(new SettingEntry("vehicle.train_acceleration_model"));
2104  physics->Add(new SettingEntry("vehicle.train_slope_steepness"));
2105  physics->Add(new SettingEntry("vehicle.wagon_speed_limits"));
2106  physics->Add(new SettingEntry("vehicle.freight_trains"));
2107  physics->Add(new SettingEntry("vehicle.roadveh_acceleration_model"));
2108  physics->Add(new SettingEntry("vehicle.roadveh_slope_steepness"));
2109  physics->Add(new SettingEntry("vehicle.smoke_amount"));
2110  physics->Add(new SettingEntry("vehicle.plane_speed"));
2111  }
2112 
2113  SettingsPage *routing = vehicles->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES_ROUTING));
2114  {
2115  routing->Add(new SettingEntry("vehicle.road_side"));
2116  routing->Add(new SettingEntry("pf.pathfinder_for_trains"));
2117  routing->Add(new SettingEntry("difficulty.line_reverse_mode"));
2118  routing->Add(new SettingEntry("pf.reverse_at_signals"));
2119  routing->Add(new SettingEntry("pf.forbid_90_deg"));
2120  routing->Add(new SettingEntry("pf.pathfinder_for_roadvehs"));
2121  routing->Add(new SettingEntry("pf.pathfinder_for_ships"));
2122  }
2123 
2124  SettingsPage *orders = vehicles->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES_ORDERS));
2125  {
2126  orders->Add(new SettingEntry("gui.new_nonstop"));
2127  orders->Add(new SettingEntry("gui.quick_goto"));
2128  orders->Add(new SettingEntry("gui.stop_location"));
2129  }
2130  }
2131 
2132  SettingsPage *limitations = main->Add(new SettingsPage(STR_CONFIG_SETTING_LIMITATIONS));
2133  {
2134  limitations->Add(new SettingEntry("construction.command_pause_level"));
2135  limitations->Add(new SettingEntry("construction.autoslope"));
2136  limitations->Add(new SettingEntry("construction.extra_dynamite"));
2137  limitations->Add(new SettingEntry("construction.map_height_limit"));
2138  limitations->Add(new SettingEntry("construction.max_bridge_length"));
2139  limitations->Add(new SettingEntry("construction.max_bridge_height"));
2140  limitations->Add(new SettingEntry("construction.max_tunnel_length"));
2141  limitations->Add(new SettingEntry("station.never_expire_airports"));
2142  limitations->Add(new SettingEntry("vehicle.never_expire_vehicles"));
2143  limitations->Add(new SettingEntry("vehicle.max_trains"));
2144  limitations->Add(new SettingEntry("vehicle.max_roadveh"));
2145  limitations->Add(new SettingEntry("vehicle.max_aircraft"));
2146  limitations->Add(new SettingEntry("vehicle.max_ships"));
2147  limitations->Add(new SettingEntry("vehicle.max_train_length"));
2148  limitations->Add(new SettingEntry("station.station_spread"));
2149  limitations->Add(new SettingEntry("station.distant_join_stations"));
2150  limitations->Add(new SettingEntry("station.modified_catchment"));
2151  limitations->Add(new SettingEntry("construction.road_stop_on_town_road"));
2152  limitations->Add(new SettingEntry("construction.road_stop_on_competitor_road"));
2153  limitations->Add(new SettingEntry("construction.crossing_with_competitor"));
2154  limitations->Add(new SettingEntry("vehicle.disable_elrails"));
2155  limitations->Add(new SettingEntry("order.station_length_loading_penalty"));
2156  }
2157 
2158  SettingsPage *disasters = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCIDENTS));
2159  {
2160  disasters->Add(new SettingEntry("difficulty.disasters"));
2161  disasters->Add(new SettingEntry("difficulty.economy"));
2162  disasters->Add(new SettingEntry("vehicle.plane_crashes"));
2163  disasters->Add(new SettingEntry("difficulty.vehicle_breakdowns"));
2164  disasters->Add(new SettingEntry("order.no_servicing_if_no_breakdowns"));
2165  disasters->Add(new SettingEntry("order.serviceathelipad"));
2166  }
2167 
2168  SettingsPage *genworld = main->Add(new SettingsPage(STR_CONFIG_SETTING_GENWORLD));
2169  {
2170  genworld->Add(new SettingEntry("game_creation.landscape"));
2171  genworld->Add(new SettingEntry("game_creation.land_generator"));
2172  genworld->Add(new SettingEntry("difficulty.terrain_type"));
2173  genworld->Add(new SettingEntry("game_creation.tgen_smoothness"));
2174  genworld->Add(new SettingEntry("game_creation.variety"));
2175  genworld->Add(new SettingEntry("game_creation.snow_coverage"));
2176  genworld->Add(new SettingEntry("game_creation.snow_line_height"));
2177  genworld->Add(new SettingEntry("game_creation.desert_coverage"));
2178  genworld->Add(new SettingEntry("game_creation.amount_of_rivers"));
2179  }
2180 
2181  SettingsPage *environment = main->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT));
2182  {
2183  SettingsPage *time = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_TIME));
2184  {
2185  time->Add(new SettingEntry("economy.timekeeping_units"));
2186  time->Add(new SettingEntry("economy.minutes_per_calendar_year"));
2187  time->Add(new SettingEntry("game_creation.ending_year"));
2188  time->Add(new SettingEntry("gui.pause_on_newgame"));
2189  time->Add(new SettingEntry("gui.fast_forward_speed_limit"));
2190  }
2191 
2192  SettingsPage *authorities = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_AUTHORITIES));
2193  {
2194  authorities->Add(new SettingEntry("difficulty.town_council_tolerance"));
2195  authorities->Add(new SettingEntry("economy.bribe"));
2196  authorities->Add(new SettingEntry("economy.exclusive_rights"));
2197  authorities->Add(new SettingEntry("economy.fund_roads"));
2198  authorities->Add(new SettingEntry("economy.fund_buildings"));
2199  authorities->Add(new SettingEntry("economy.station_noise_level"));
2200  }
2201 
2202  SettingsPage *towns = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_TOWNS));
2203  {
2204  towns->Add(new SettingEntry("economy.town_cargo_scale"));
2205  towns->Add(new SettingEntry("economy.town_growth_rate"));
2206  towns->Add(new SettingEntry("economy.allow_town_roads"));
2207  towns->Add(new SettingEntry("economy.allow_town_level_crossings"));
2208  towns->Add(new SettingEntry("economy.found_town"));
2209  towns->Add(new SettingEntry("economy.town_layout"));
2210  towns->Add(new SettingEntry("economy.larger_towns"));
2211  towns->Add(new SettingEntry("economy.initial_city_size"));
2212  towns->Add(new SettingEntry("economy.town_cargogen_mode"));
2213  }
2214 
2215  SettingsPage *industries = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_INDUSTRIES));
2216  {
2217  industries->Add(new SettingEntry("economy.industry_cargo_scale"));
2218  industries->Add(new SettingEntry("difficulty.industry_density"));
2219  industries->Add(new SettingEntry("construction.raw_industry_construction"));
2220  industries->Add(new SettingEntry("construction.industry_platform"));
2221  industries->Add(new SettingEntry("economy.multiple_industry_per_town"));
2222  industries->Add(new SettingEntry("game_creation.oil_refinery_limit"));
2223  industries->Add(new SettingEntry("economy.type"));
2224  industries->Add(new SettingEntry("station.serve_neutral_industries"));
2225  }
2226 
2227  SettingsPage *cdist = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST));
2228  {
2229  cdist->Add(new SettingEntry("linkgraph.recalc_time"));
2230  cdist->Add(new SettingEntry("linkgraph.recalc_interval"));
2231  cdist->Add(new SettingEntry("linkgraph.distribution_pax"));
2232  cdist->Add(new SettingEntry("linkgraph.distribution_mail"));
2233  cdist->Add(new SettingEntry("linkgraph.distribution_armoured"));
2234  cdist->Add(new SettingEntry("linkgraph.distribution_default"));
2235  cdist->Add(new SettingEntry("linkgraph.accuracy"));
2236  cdist->Add(new SettingEntry("linkgraph.demand_distance"));
2237  cdist->Add(new SettingEntry("linkgraph.demand_size"));
2238  cdist->Add(new SettingEntry("linkgraph.short_path_saturation"));
2239  }
2240 
2241  SettingsPage *trees = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_TREES));
2242  {
2243  trees->Add(new SettingEntry("game_creation.tree_placer"));
2244  trees->Add(new SettingEntry("construction.extra_tree_placement"));
2245  }
2246  }
2247 
2248  SettingsPage *ai = main->Add(new SettingsPage(STR_CONFIG_SETTING_AI));
2249  {
2250  SettingsPage *npc = ai->Add(new SettingsPage(STR_CONFIG_SETTING_AI_NPC));
2251  {
2252  npc->Add(new SettingEntry("script.script_max_opcode_till_suspend"));
2253  npc->Add(new SettingEntry("script.script_max_memory_megabytes"));
2254  npc->Add(new SettingEntry("difficulty.competitor_speed"));
2255  npc->Add(new SettingEntry("ai.ai_in_multiplayer"));
2256  npc->Add(new SettingEntry("ai.ai_disable_veh_train"));
2257  npc->Add(new SettingEntry("ai.ai_disable_veh_roadveh"));
2258  npc->Add(new SettingEntry("ai.ai_disable_veh_aircraft"));
2259  npc->Add(new SettingEntry("ai.ai_disable_veh_ship"));
2260  }
2261 
2262  ai->Add(new SettingEntry("economy.give_money"));
2263  }
2264 
2265  SettingsPage *network = main->Add(new SettingsPage(STR_CONFIG_SETTING_NETWORK));
2266  {
2267  network->Add(new SettingEntry("network.use_relay_service"));
2268  }
2269 
2270  main->Init();
2271  }
2272  return *main;
2273 }
2274 
2275 static const StringID _game_settings_restrict_dropdown[] = {
2276  STR_CONFIG_SETTING_RESTRICT_BASIC, // RM_BASIC
2277  STR_CONFIG_SETTING_RESTRICT_ADVANCED, // RM_ADVANCED
2278  STR_CONFIG_SETTING_RESTRICT_ALL, // RM_ALL
2279  STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_DEFAULT, // RM_CHANGED_AGAINST_DEFAULT
2280  STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_NEW, // RM_CHANGED_AGAINST_NEW
2281 };
2282 static_assert(lengthof(_game_settings_restrict_dropdown) == RM_END);
2283 
2290 };
2291 
2297 static void ResetAllSettingsConfirmationCallback(Window *w, bool confirmed)
2298 {
2299  if (confirmed) {
2302  w->InvalidateData();
2303  }
2304 }
2305 
2309 
2315 
2321 
2322  Scrollbar *vscroll;
2323 
2325  {
2326  this->warn_missing = WHR_NONE;
2327  this->warn_lines = 0;
2329  this->filter.min_cat = RM_ALL;
2330  this->filter.type = ST_ALL;
2331  this->filter.type_hides = false;
2332  this->settings_ptr = &GetGameSettings();
2333 
2334  GetSettingsTree().FoldAll(); // Close all sub-pages
2335 
2336  this->valuewindow_entry = nullptr; // No setting entry for which a entry window is opened
2337  this->clicked_entry = nullptr; // No numeric setting buttons are depressed
2338  this->last_clicked = nullptr;
2339  this->valuedropdown_entry = nullptr;
2340  this->closing_dropdown = false;
2341  this->manually_changed_folding = false;
2342 
2343  this->CreateNestedTree();
2344  this->vscroll = this->GetScrollbar(WID_GS_SCROLLBAR);
2346 
2347  this->querystrings[WID_GS_FILTER] = &this->filter_editbox;
2348  this->filter_editbox.cancel_button = QueryString::ACTION_CLEAR;
2350 
2351  this->InvalidateData();
2352  }
2353 
2354  void OnInit() override
2355  {
2356  _circle_size = maxdim(GetSpriteSize(SPR_CIRCLE_FOLDED), GetSpriteSize(SPR_CIRCLE_UNFOLDED));
2357  }
2358 
2359  void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
2360  {
2361  switch (widget) {
2362  case WID_GS_OPTIONSPANEL:
2364  resize->width = 1;
2365 
2366  size->height = 5 * resize->height + WidgetDimensions::scaled.framerect.Vertical();
2367  break;
2368 
2369  case WID_GS_HELP_TEXT: {
2370  static const StringID setting_types[] = {
2371  STR_CONFIG_SETTING_TYPE_CLIENT,
2372  STR_CONFIG_SETTING_TYPE_COMPANY_MENU, STR_CONFIG_SETTING_TYPE_COMPANY_INGAME,
2373  STR_CONFIG_SETTING_TYPE_GAME_MENU, STR_CONFIG_SETTING_TYPE_GAME_INGAME,
2374  };
2375  for (uint i = 0; i < lengthof(setting_types); i++) {
2376  SetDParam(0, setting_types[i]);
2377  size->width = std::max(size->width, GetStringBoundingBox(STR_CONFIG_SETTING_TYPE).width + padding.width);
2378  }
2380  std::max(size->height, GetSettingsTree().GetMaxHelpHeight(size->width));
2381  break;
2382  }
2383 
2385  case WID_GS_RESTRICT_TYPE:
2386  size->width = std::max(GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_CATEGORY).width, GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_TYPE).width);
2387  break;
2388 
2389  default:
2390  break;
2391  }
2392  }
2393 
2394  void OnPaint() override
2395  {
2396  if (this->closing_dropdown) {
2397  this->closing_dropdown = false;
2398  assert(this->valuedropdown_entry != nullptr);
2399  this->valuedropdown_entry->SetButtons(0);
2400  this->valuedropdown_entry = nullptr;
2401  }
2402 
2403  /* Reserve the correct number of lines for the 'some search results are hidden' notice in the central settings display panel. */
2404  const Rect panel = this->GetWidget<NWidgetBase>(WID_GS_OPTIONSPANEL)->GetCurrentRect().Shrink(WidgetDimensions::scaled.frametext);
2405  StringID warn_str = STR_CONFIG_SETTING_CATEGORY_HIDES - 1 + this->warn_missing;
2406  int new_warn_lines;
2407  if (this->warn_missing == WHR_NONE) {
2408  new_warn_lines = 0;
2409  } else {
2410  SetDParam(0, _game_settings_restrict_dropdown[this->filter.min_cat]);
2411  new_warn_lines = GetStringLineCount(warn_str, panel.Width());
2412  }
2413  if (this->warn_lines != new_warn_lines) {
2414  this->vscroll->SetCount(this->vscroll->GetCount() - this->warn_lines + new_warn_lines);
2415  this->warn_lines = new_warn_lines;
2416  }
2417 
2418  this->DrawWidgets();
2419 
2420  /* Draw the 'some search results are hidden' notice. */
2421  if (this->warn_missing != WHR_NONE) {
2422  SetDParam(0, _game_settings_restrict_dropdown[this->filter.min_cat]);
2423  DrawStringMultiLine(panel.WithHeight(this->warn_lines * GetCharacterHeight(FS_NORMAL)), warn_str, TC_FROMSTRING, SA_CENTER);
2424  }
2425  }
2426 
2427  void SetStringParameters(WidgetID widget) const override
2428  {
2429  switch (widget) {
2431  SetDParam(0, _game_settings_restrict_dropdown[this->filter.mode]);
2432  break;
2433 
2434  case WID_GS_TYPE_DROPDOWN:
2435  switch (this->filter.type) {
2436  case ST_GAME: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME); break;
2437  case ST_COMPANY: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME); break;
2438  case ST_CLIENT: SetDParam(0, STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT); break;
2439  default: SetDParam(0, STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL); break;
2440  }
2441  break;
2442  }
2443  }
2444 
2445  DropDownList BuildDropDownList(WidgetID widget) const
2446  {
2447  DropDownList list;
2448  switch (widget) {
2450  for (int mode = 0; mode != RM_END; mode++) {
2451  /* If we are in adv. settings screen for the new game's settings,
2452  * we don't want to allow comparing with new game's settings. */
2453  bool disabled = mode == RM_CHANGED_AGAINST_NEW && settings_ptr == &_settings_newgame;
2454 
2455  list.push_back(std::make_unique<DropDownListStringItem>(_game_settings_restrict_dropdown[mode], mode, disabled));
2456  }
2457  break;
2458 
2459  case WID_GS_TYPE_DROPDOWN:
2460  list.push_back(std::make_unique<DropDownListStringItem>(STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL, ST_ALL, false));
2461  list.push_back(std::make_unique<DropDownListStringItem>(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME, ST_GAME, false));
2462  list.push_back(std::make_unique<DropDownListStringItem>(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME, ST_COMPANY, false));
2463  list.push_back(std::make_unique<DropDownListStringItem>(STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT, ST_CLIENT, false));
2464  break;
2465  }
2466  return list;
2467  }
2468 
2469  void DrawWidget(const Rect &r, WidgetID widget) const override
2470  {
2471  switch (widget) {
2472  case WID_GS_OPTIONSPANEL: {
2473  Rect tr = r.Shrink(WidgetDimensions::scaled.frametext, WidgetDimensions::scaled.framerect);
2474  tr.top += this->warn_lines * SETTING_HEIGHT;
2475  uint last_row = this->vscroll->GetPosition() + this->vscroll->GetCapacity() - this->warn_lines;
2476  int next_row = GetSettingsTree().Draw(settings_ptr, tr.left, tr.right, tr.top,
2477  this->vscroll->GetPosition(), last_row, this->last_clicked);
2478  if (next_row == 0) DrawString(tr, STR_CONFIG_SETTINGS_NONE);
2479  break;
2480  }
2481 
2482  case WID_GS_HELP_TEXT:
2483  if (this->last_clicked != nullptr) {
2484  const IntSettingDesc *sd = this->last_clicked->setting;
2485 
2486  Rect tr = r;
2487  switch (sd->GetType()) {
2488  case ST_COMPANY: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_COMPANY_INGAME); break;
2489  case ST_CLIENT: SetDParam(0, STR_CONFIG_SETTING_TYPE_CLIENT); break;
2490  case ST_GAME: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_GAME_MENU : STR_CONFIG_SETTING_TYPE_GAME_INGAME); break;
2491  default: NOT_REACHED();
2492  }
2493  DrawString(tr, STR_CONFIG_SETTING_TYPE);
2494  tr.top += GetCharacterHeight(FS_NORMAL);
2495 
2496  sd->SetValueDParams(0, sd->def);
2497  DrawString(tr, STR_CONFIG_SETTING_DEFAULT_VALUE);
2499 
2500  DrawStringMultiLine(tr, sd->GetHelp(), TC_WHITE);
2501  }
2502  break;
2503 
2504  default:
2505  break;
2506  }
2507  }
2508 
2514  {
2515  if (this->last_clicked != pe) this->SetDirty();
2516  this->last_clicked = pe;
2517  }
2518 
2519  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
2520  {
2521  switch (widget) {
2522  case WID_GS_EXPAND_ALL:
2523  this->manually_changed_folding = true;
2525  this->InvalidateData();
2526  break;
2527 
2528  case WID_GS_COLLAPSE_ALL:
2529  this->manually_changed_folding = true;
2531  this->InvalidateData();
2532  break;
2533 
2534  case WID_GS_RESET_ALL:
2535  ShowQuery(
2536  STR_CONFIG_SETTING_RESET_ALL_CONFIRMATION_DIALOG_CAPTION,
2537  STR_CONFIG_SETTING_RESET_ALL_CONFIRMATION_DIALOG_TEXT,
2538  this,
2540  );
2541  break;
2542 
2543  case WID_GS_RESTRICT_DROPDOWN: {
2544  DropDownList list = this->BuildDropDownList(widget);
2545  if (!list.empty()) {
2546  ShowDropDownList(this, std::move(list), this->filter.mode, widget);
2547  }
2548  break;
2549  }
2550 
2551  case WID_GS_TYPE_DROPDOWN: {
2552  DropDownList list = this->BuildDropDownList(widget);
2553  if (!list.empty()) {
2554  ShowDropDownList(this, std::move(list), this->filter.type, widget);
2555  }
2556  break;
2557  }
2558  }
2559 
2560  if (widget != WID_GS_OPTIONSPANEL) return;
2561 
2562  uint btn = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GS_OPTIONSPANEL, WidgetDimensions::scaled.framerect.top);
2563  if (btn == INT_MAX || (int)btn < this->warn_lines) return;
2564  btn -= this->warn_lines;
2565 
2566  uint cur_row = 0;
2568 
2569  if (clicked_entry == nullptr) return; // Clicked below the last setting of the page
2570 
2571  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; // Shift x coordinate
2572  if (x < 0) return; // Clicked left of the entry
2573 
2574  SettingsPage *clicked_page = dynamic_cast<SettingsPage*>(clicked_entry);
2575  if (clicked_page != nullptr) {
2576  this->SetDisplayedHelpText(nullptr);
2577  clicked_page->folded = !clicked_page->folded; // Flip 'folded'-ness of the sub-page
2578 
2579  this->manually_changed_folding = true;
2580 
2581  this->InvalidateData();
2582  return;
2583  }
2584 
2585  SettingEntry *pe = dynamic_cast<SettingEntry*>(clicked_entry);
2586  assert(pe != nullptr);
2587  const IntSettingDesc *sd = pe->setting;
2588 
2589  /* return if action is only active in network, or only settable by server */
2590  if (!sd->IsEditable()) {
2591  this->SetDisplayedHelpText(pe);
2592  return;
2593  }
2594 
2595  int32_t value = sd->Read(ResolveObject(settings_ptr, sd));
2596 
2597  /* clicked on the icon on the left side. Either scroller, bool on/off or dropdown */
2598  if (x < SETTING_BUTTON_WIDTH && (sd->flags & SF_GUI_DROPDOWN)) {
2599  this->SetDisplayedHelpText(pe);
2600 
2601  if (this->valuedropdown_entry == pe) {
2602  /* unclick the dropdown */
2604  this->closing_dropdown = false;
2605  this->valuedropdown_entry->SetButtons(0);
2606  this->valuedropdown_entry = nullptr;
2607  } else {
2608  if (this->valuedropdown_entry != nullptr) this->valuedropdown_entry->SetButtons(0);
2609  this->closing_dropdown = false;
2610 
2611  const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_GS_OPTIONSPANEL);
2612  int rel_y = (pt.y - wid->pos_y - WidgetDimensions::scaled.framerect.top) % wid->resize_y;
2613 
2614  Rect wi_rect;
2615  wi_rect.left = pt.x - (_current_text_dir == TD_RTL ? SETTING_BUTTON_WIDTH - 1 - x : x);
2616  wi_rect.right = wi_rect.left + SETTING_BUTTON_WIDTH - 1;
2617  wi_rect.top = pt.y - rel_y + (SETTING_HEIGHT - SETTING_BUTTON_HEIGHT) / 2;
2618  wi_rect.bottom = wi_rect.top + SETTING_BUTTON_HEIGHT - 1;
2619 
2620  /* For dropdowns we also have to check the y position thoroughly, the mouse may not above the just opening dropdown */
2621  if (pt.y >= wi_rect.top && pt.y <= wi_rect.bottom) {
2622  this->valuedropdown_entry = pe;
2623  this->valuedropdown_entry->SetButtons(SEF_LEFT_DEPRESSED);
2624 
2625  DropDownList list;
2626  for (int i = sd->min; i <= (int)sd->max; i++) {
2627  sd->SetValueDParams(0, i);
2628  list.push_back(std::make_unique<DropDownListStringItem>(STR_JUST_STRING2, i, false));
2629  }
2630 
2631  ShowDropDownListAt(this, std::move(list), value, WID_GS_SETTING_DROPDOWN, wi_rect, COLOUR_ORANGE);
2632  }
2633  }
2634  this->SetDirty();
2635  } else if (x < SETTING_BUTTON_WIDTH) {
2636  this->SetDisplayedHelpText(pe);
2637  int32_t oldvalue = value;
2638 
2639  if (sd->IsBoolSetting()) {
2640  value ^= 1;
2641  } else {
2642  /* Add a dynamic step-size to the scroller. In a maximum of
2643  * 50-steps you should be able to get from min to max,
2644  * unless specified otherwise in the 'interval' variable
2645  * of the current setting. */
2646  uint32_t step = (sd->interval == 0) ? ((sd->max - sd->min) / 50) : sd->interval;
2647  if (step == 0) step = 1;
2648 
2649  /* don't allow too fast scrolling */
2650  if ((this->flags & WF_TIMEOUT) && this->timeout_timer > 1) {
2651  _left_button_clicked = false;
2652  return;
2653  }
2654 
2655  /* Increase or decrease the value and clamp it to extremes */
2656  if (x >= SETTING_BUTTON_WIDTH / 2) {
2657  value += step;
2658  if (sd->min < 0) {
2659  assert((int32_t)sd->max >= 0);
2660  if (value > (int32_t)sd->max) value = (int32_t)sd->max;
2661  } else {
2662  if ((uint32_t)value > sd->max) value = (int32_t)sd->max;
2663  }
2664  if (value < sd->min) value = sd->min; // skip between "disabled" and minimum
2665  } else {
2666  value -= step;
2667  if (value < sd->min) value = (sd->flags & SF_GUI_0_IS_SPECIAL) ? 0 : sd->min;
2668  }
2669 
2670  /* Set up scroller timeout for numeric values */
2671  if (value != oldvalue) {
2672  if (this->clicked_entry != nullptr) { // Release previous buttons if any
2673  this->clicked_entry->SetButtons(0);
2674  }
2675  this->clicked_entry = pe;
2676  this->clicked_entry->SetButtons((x >= SETTING_BUTTON_WIDTH / 2) != (_current_text_dir == TD_RTL) ? SEF_RIGHT_DEPRESSED : SEF_LEFT_DEPRESSED);
2677  this->SetTimeout();
2678  _left_button_clicked = false;
2679  }
2680  }
2681 
2682  if (value != oldvalue) {
2683  SetSettingValue(sd, value);
2684  this->SetDirty();
2685  }
2686  } else {
2687  /* Only open editbox if clicked for the second time, and only for types where it is sensible for. */
2688  if (this->last_clicked == pe && !sd->IsBoolSetting() && !(sd->flags & SF_GUI_DROPDOWN)) {
2689  int64_t value64 = value;
2690  /* Show the correct currency-translated value */
2691  if (sd->flags & SF_GUI_CURRENCY) value64 *= _currency->rate;
2692 
2693  CharSetFilter charset_filter = CS_NUMERAL; //default, only numeric input allowed
2694  if (sd->min < 0) charset_filter = CS_NUMERAL_SIGNED; // special case, also allow '-' sign for negative input
2695 
2696  this->valuewindow_entry = pe;
2697  SetDParam(0, value64);
2698  /* Limit string length to 14 so that MAX_INT32 * max currency rate doesn't exceed MAX_INT64. */
2699  ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 15, this, charset_filter, QSF_ENABLE_DEFAULT);
2700  }
2701  this->SetDisplayedHelpText(pe);
2702  }
2703  }
2704 
2705  void OnTimeout() override
2706  {
2707  if (this->clicked_entry != nullptr) { // On timeout, release any depressed buttons
2708  this->clicked_entry->SetButtons(0);
2709  this->clicked_entry = nullptr;
2710  this->SetDirty();
2711  }
2712  }
2713 
2714  void OnQueryTextFinished(char *str) override
2715  {
2716  /* The user pressed cancel */
2717  if (str == nullptr) return;
2718 
2719  assert(this->valuewindow_entry != nullptr);
2720  const IntSettingDesc *sd = this->valuewindow_entry->setting;
2721 
2722  int32_t value;
2723  if (!StrEmpty(str)) {
2724  long long llvalue = atoll(str);
2725 
2726  /* Save the correct currency-translated value */
2727  if (sd->flags & SF_GUI_CURRENCY) llvalue /= _currency->rate;
2728 
2729  value = ClampTo<int32_t>(llvalue);
2730  } else {
2731  value = sd->def;
2732  }
2733 
2734  SetSettingValue(this->valuewindow_entry->setting, value);
2735  this->SetDirty();
2736  }
2737 
2738  void OnDropdownSelect(WidgetID widget, int index) override
2739  {
2740  switch (widget) {
2742  this->filter.mode = (RestrictionMode)index;
2743  if (this->filter.mode == RM_CHANGED_AGAINST_DEFAULT ||
2744  this->filter.mode == RM_CHANGED_AGAINST_NEW) {
2745 
2746  if (!this->manually_changed_folding) {
2747  /* Expand all when selecting 'changes'. Update the filter state first, in case it becomes less restrictive in some cases. */
2748  GetSettingsTree().UpdateFilterState(this->filter, false);
2750  }
2751  } else {
2752  /* Non-'changes' filter. Save as default. */
2754  }
2755  this->InvalidateData();
2756  break;
2757 
2758  case WID_GS_TYPE_DROPDOWN:
2759  this->filter.type = (SettingType)index;
2760  this->InvalidateData();
2761  break;
2762 
2764  /* Deal with drop down boxes on the panel. */
2765  assert(this->valuedropdown_entry != nullptr);
2766  const IntSettingDesc *sd = this->valuedropdown_entry->setting;
2767  assert(sd->flags & SF_GUI_DROPDOWN);
2768 
2769  SetSettingValue(sd, index);
2770  this->SetDirty();
2771  break;
2772  }
2773  }
2774 
2775  void OnDropdownClose(Point pt, WidgetID widget, int index, bool instant_close) override
2776  {
2777  if (widget != WID_GS_SETTING_DROPDOWN) {
2778  /* Normally the default implementation of OnDropdownClose() takes care of
2779  * a few things. We want that behaviour here too, but only for
2780  * "normal" dropdown boxes. The special dropdown boxes added for every
2781  * setting that needs one can't have this call. */
2782  Window::OnDropdownClose(pt, widget, index, instant_close);
2783  } else {
2784  /* We cannot raise the dropdown button just yet. OnClick needs some hint, whether
2785  * the same dropdown button was clicked again, and then not open the dropdown again.
2786  * So, we only remember that it was closed, and process it on the next OnPaint, which is
2787  * after OnClick. */
2788  assert(this->valuedropdown_entry != nullptr);
2789  this->closing_dropdown = true;
2790  this->SetDirty();
2791  }
2792  }
2793 
2794  void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
2795  {
2796  if (!gui_scope) return;
2797 
2798  /* Update which settings are to be visible. */
2799  RestrictionMode min_level = (this->filter.mode <= RM_ALL) ? this->filter.mode : RM_BASIC;
2800  this->filter.min_cat = min_level;
2801  this->filter.type_hides = false;
2802  GetSettingsTree().UpdateFilterState(this->filter, false);
2803 
2804  if (this->filter.string.IsEmpty()) {
2805  this->warn_missing = WHR_NONE;
2806  } else if (min_level < this->filter.min_cat) {
2807  this->warn_missing = this->filter.type_hides ? WHR_CATEGORY_TYPE : WHR_CATEGORY;
2808  } else {
2809  this->warn_missing = this->filter.type_hides ? WHR_TYPE : WHR_NONE;
2810  }
2811  this->vscroll->SetCount(GetSettingsTree().Length() + this->warn_lines);
2812 
2813  if (this->last_clicked != nullptr && !GetSettingsTree().IsVisible(this->last_clicked)) {
2814  this->SetDisplayedHelpText(nullptr);
2815  }
2816 
2817  bool all_folded = true;
2818  bool all_unfolded = true;
2819  GetSettingsTree().GetFoldingState(all_folded, all_unfolded);
2820  this->SetWidgetDisabledState(WID_GS_EXPAND_ALL, all_unfolded);
2821  this->SetWidgetDisabledState(WID_GS_COLLAPSE_ALL, all_folded);
2822  }
2823 
2824  void OnEditboxChanged(WidgetID wid) override
2825  {
2826  if (wid == WID_GS_FILTER) {
2827  this->filter.string.SetFilterTerm(this->filter_editbox.text.buf);
2828  if (!this->filter.string.IsEmpty() && !this->manually_changed_folding) {
2829  /* User never expanded/collapsed single pages and entered a filter term.
2830  * Expand everything, to save weird expand clicks, */
2832  }
2833  this->InvalidateData();
2834  }
2835  }
2836 
2837  void OnResize() override
2838  {
2839  this->vscroll->SetCapacityFromWidget(this, WID_GS_OPTIONSPANEL, WidgetDimensions::scaled.framerect.Vertical());
2840  }
2841 };
2842 
2844 
2845 static constexpr NWidgetPart _nested_settings_selection_widgets[] = {
2847  NWidget(WWT_CLOSEBOX, COLOUR_MAUVE),
2848  NWidget(WWT_CAPTION, COLOUR_MAUVE), SetDataTip(STR_CONFIG_SETTING_TREE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
2849  NWidget(WWT_DEFSIZEBOX, COLOUR_MAUVE),
2850  EndContainer(),
2851  NWidget(WWT_PANEL, COLOUR_MAUVE),
2854  NWidget(WWT_TEXT, COLOUR_MAUVE, WID_GS_RESTRICT_CATEGORY), SetDataTip(STR_CONFIG_SETTING_RESTRICT_CATEGORY, STR_NULL),
2855  NWidget(WWT_DROPDOWN, COLOUR_MAUVE, WID_GS_RESTRICT_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_JUST_STRING, STR_CONFIG_SETTING_RESTRICT_DROPDOWN_HELPTEXT), SetFill(1, 0), SetResize(1, 0),
2856  EndContainer(),
2858  NWidget(WWT_TEXT, COLOUR_MAUVE, WID_GS_RESTRICT_TYPE), SetDataTip(STR_CONFIG_SETTING_RESTRICT_TYPE, STR_NULL),
2859  NWidget(WWT_DROPDOWN, COLOUR_MAUVE, WID_GS_TYPE_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_JUST_STRING, STR_CONFIG_SETTING_TYPE_DROPDOWN_HELPTEXT), SetFill(1, 0), SetResize(1, 0),
2860  EndContainer(),
2862  NWidget(WWT_TEXT, COLOUR_MAUVE), SetFill(0, 1), SetDataTip(STR_CONFIG_SETTING_FILTER_TITLE, STR_NULL),
2863  NWidget(WWT_EDITBOX, COLOUR_MAUVE, WID_GS_FILTER), SetMinimalSize(50, 12), SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP), SetFill(1, 0), SetResize(1, 0),
2864  EndContainer(),
2865  EndContainer(),
2866  EndContainer(),
2869  NWidget(NWID_VSCROLLBAR, COLOUR_MAUVE, WID_GS_SCROLLBAR),
2870  EndContainer(),
2871  NWidget(WWT_PANEL, COLOUR_MAUVE),
2872  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GS_HELP_TEXT), SetMinimalSize(300, 25), SetFill(1, 1), SetResize(1, 0),
2874  EndContainer(),
2876  NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, WID_GS_EXPAND_ALL), SetDataTip(STR_CONFIG_SETTING_EXPAND_ALL, STR_NULL),
2877  NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, WID_GS_COLLAPSE_ALL), SetDataTip(STR_CONFIG_SETTING_COLLAPSE_ALL, STR_NULL),
2878  NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, WID_GS_RESET_ALL), SetDataTip(STR_CONFIG_SETTING_RESET_ALL, STR_NULL),
2879  NWidget(WWT_PANEL, COLOUR_MAUVE), SetFill(1, 0), SetResize(1, 0),
2880  EndContainer(),
2881  NWidget(WWT_RESIZEBOX, COLOUR_MAUVE),
2882  EndContainer(),
2883 };
2884 
2885 static WindowDesc _settings_selection_desc(__FILE__, __LINE__,
2886  WDP_CENTER, "settings", 510, 450,
2888  0,
2889  std::begin(_nested_settings_selection_widgets), std::end(_nested_settings_selection_widgets)
2890 );
2891 
2894 {
2896  new GameSettingsWindow(&_settings_selection_desc);
2897 }
2898 
2899 
2909 void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right)
2910 {
2911  int colour = _colour_gradient[button_colour][2];
2912  Dimension dim = NWidgetScrollbar::GetHorizontalDimension();
2913 
2914  Rect lr = {x, y, x + (int)dim.width - 1, y + (int)dim.height - 1};
2915  Rect rr = {x + (int)dim.width, y, x + (int)dim.width * 2 - 1, y + (int)dim.height - 1};
2916 
2917  DrawFrameRect(lr, button_colour, (state == 1) ? FR_LOWERED : FR_NONE);
2918  DrawFrameRect(rr, button_colour, (state == 2) ? FR_LOWERED : FR_NONE);
2919  DrawSpriteIgnorePadding(SPR_ARROW_LEFT, PAL_NONE, lr, SA_CENTER);
2920  DrawSpriteIgnorePadding(SPR_ARROW_RIGHT, PAL_NONE, rr, SA_CENTER);
2921 
2922  /* Grey out the buttons that aren't clickable */
2923  bool rtl = _current_text_dir == TD_RTL;
2924  if (rtl ? !clickable_right : !clickable_left) {
2926  }
2927  if (rtl ? !clickable_left : !clickable_right) {
2929  }
2930 }
2931 
2940 void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
2941 {
2942  int colour = _colour_gradient[button_colour][2];
2943 
2944  Rect r = {x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1};
2945 
2946  DrawFrameRect(r, button_colour, state ? FR_LOWERED : FR_NONE);
2947  DrawSpriteIgnorePadding(SPR_ARROW_DOWN, PAL_NONE, r, SA_CENTER);
2948 
2949  if (!clickable) {
2951  }
2952 }
2953 
2961 void DrawBoolButton(int x, int y, bool state, bool clickable)
2962 {
2963  static const Colours _bool_ctabs[2][2] = {{COLOUR_CREAM, COLOUR_RED}, {COLOUR_DARK_GREEN, COLOUR_GREEN}};
2964 
2965  Rect r = {x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1};
2966  DrawFrameRect(r, _bool_ctabs[state][clickable], state ? FR_LOWERED : FR_NONE);
2967 }
2968 
2970  int query_widget;
2971 
2972  CustomCurrencyWindow(WindowDesc *desc) : Window(desc)
2973  {
2974  this->InitNested();
2975 
2976  SetButtonState();
2977  }
2978 
2979  void SetButtonState()
2980  {
2981  this->SetWidgetDisabledState(WID_CC_RATE_DOWN, _custom_currency.rate == 1);
2982  this->SetWidgetDisabledState(WID_CC_RATE_UP, _custom_currency.rate == UINT16_MAX);
2983  this->SetWidgetDisabledState(WID_CC_YEAR_DOWN, _custom_currency.to_euro == CF_NOEURO);
2984  this->SetWidgetDisabledState(WID_CC_YEAR_UP, _custom_currency.to_euro == CalendarTime::MAX_YEAR);
2985  }
2986 
2987  void SetStringParameters(WidgetID widget) const override
2988  {
2989  switch (widget) {
2990  case WID_CC_RATE: SetDParam(0, 1); SetDParam(1, 1); break;
2991  case WID_CC_SEPARATOR: SetDParamStr(0, _custom_currency.separator); break;
2992  case WID_CC_PREFIX: SetDParamStr(0, _custom_currency.prefix); break;
2993  case WID_CC_SUFFIX: SetDParamStr(0, _custom_currency.suffix); break;
2994  case WID_CC_YEAR:
2995  SetDParam(0, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER);
2996  SetDParam(1, _custom_currency.to_euro);
2997  break;
2998 
2999  case WID_CC_PREVIEW:
3000  SetDParam(0, 10000);
3001  break;
3002  }
3003  }
3004 
3005  void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
3006  {
3007  switch (widget) {
3008  /* Set the appropriate width for the up/down buttons. */
3009  case WID_CC_RATE_DOWN:
3010  case WID_CC_RATE_UP:
3011  case WID_CC_YEAR_DOWN:
3012  case WID_CC_YEAR_UP:
3013  *size = maxdim(*size, {(uint)SETTING_BUTTON_WIDTH / 2, (uint)SETTING_BUTTON_HEIGHT});
3014  break;
3015 
3016  /* Set the appropriate width for the edit buttons. */
3017  case WID_CC_SEPARATOR_EDIT:
3018  case WID_CC_PREFIX_EDIT:
3019  case WID_CC_SUFFIX_EDIT:
3020  *size = maxdim(*size, {(uint)SETTING_BUTTON_WIDTH, (uint)SETTING_BUTTON_HEIGHT});
3021  break;
3022 
3023  /* Make sure the window is wide enough for the widest exchange rate */
3024  case WID_CC_RATE:
3025  SetDParam(0, 1);
3026  SetDParam(1, INT32_MAX);
3027  *size = GetStringBoundingBox(STR_CURRENCY_EXCHANGE_RATE);
3028  break;
3029  }
3030  }
3031 
3032  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
3033  {
3034  int line = 0;
3035  int len = 0;
3036  StringID str = 0;
3037  CharSetFilter afilter = CS_ALPHANUMERAL;
3038 
3039  switch (widget) {
3040  case WID_CC_RATE_DOWN:
3041  if (_custom_currency.rate > 1) _custom_currency.rate--;
3042  if (_custom_currency.rate == 1) this->DisableWidget(WID_CC_RATE_DOWN);
3044  break;
3045 
3046  case WID_CC_RATE_UP:
3047  if (_custom_currency.rate < UINT16_MAX) _custom_currency.rate++;
3048  if (_custom_currency.rate == UINT16_MAX) this->DisableWidget(WID_CC_RATE_UP);
3050  break;
3051 
3052  case WID_CC_RATE:
3053  SetDParam(0, _custom_currency.rate);
3054  str = STR_JUST_INT;
3055  len = 5;
3056  line = WID_CC_RATE;
3057  afilter = CS_NUMERAL;
3058  break;
3059 
3060  case WID_CC_SEPARATOR_EDIT:
3061  case WID_CC_SEPARATOR:
3062  SetDParamStr(0, _custom_currency.separator);
3063  str = STR_JUST_RAW_STRING;
3064  len = 7;
3065  line = WID_CC_SEPARATOR;
3066  break;
3067 
3068  case WID_CC_PREFIX_EDIT:
3069  case WID_CC_PREFIX:
3070  SetDParamStr(0, _custom_currency.prefix);
3071  str = STR_JUST_RAW_STRING;
3072  len = 15;
3073  line = WID_CC_PREFIX;
3074  break;
3075 
3076  case WID_CC_SUFFIX_EDIT:
3077  case WID_CC_SUFFIX:
3078  SetDParamStr(0, _custom_currency.suffix);
3079  str = STR_JUST_RAW_STRING;
3080  len = 15;
3081  line = WID_CC_SUFFIX;
3082  break;
3083 
3084  case WID_CC_YEAR_DOWN:
3085  _custom_currency.to_euro = (_custom_currency.to_euro <= MIN_EURO_YEAR) ? CF_NOEURO : _custom_currency.to_euro - 1;
3086  if (_custom_currency.to_euro == CF_NOEURO) this->DisableWidget(WID_CC_YEAR_DOWN);
3088  break;
3089 
3090  case WID_CC_YEAR_UP:
3091  _custom_currency.to_euro = Clamp(_custom_currency.to_euro + 1, MIN_EURO_YEAR, CalendarTime::MAX_YEAR);
3092  if (_custom_currency.to_euro == CalendarTime::MAX_YEAR) this->DisableWidget(WID_CC_YEAR_UP);
3094  break;
3095 
3096  case WID_CC_YEAR:
3097  SetDParam(0, _custom_currency.to_euro);
3098  str = STR_JUST_INT;
3099  len = 7;
3100  line = WID_CC_YEAR;
3101  afilter = CS_NUMERAL;
3102  break;
3103  }
3104 
3105  if (len != 0) {
3106  this->query_widget = line;
3107  ShowQueryString(str, STR_CURRENCY_CHANGE_PARAMETER, len + 1, this, afilter, QSF_NONE);
3108  }
3109 
3110  this->SetTimeout();
3111  this->SetDirty();
3112  }
3113 
3114  void OnQueryTextFinished(char *str) override
3115  {
3116  if (str == nullptr) return;
3117 
3118  switch (this->query_widget) {
3119  case WID_CC_RATE:
3120  _custom_currency.rate = Clamp(atoi(str), 1, UINT16_MAX);
3121  break;
3122 
3123  case WID_CC_SEPARATOR: // Thousands separator
3124  _custom_currency.separator = str;
3125  break;
3126 
3127  case WID_CC_PREFIX:
3128  _custom_currency.prefix = str;
3129  break;
3130 
3131  case WID_CC_SUFFIX:
3132  _custom_currency.suffix = str;
3133  break;
3134 
3135  case WID_CC_YEAR: { // Year to switch to euro
3136  TimerGameCalendar::Year val = atoi(str);
3137 
3138  _custom_currency.to_euro = (val < MIN_EURO_YEAR ? CF_NOEURO : std::min(val, CalendarTime::MAX_YEAR));
3139  break;
3140  }
3141  }
3143  SetButtonState();
3144  }
3145 
3146  void OnTimeout() override
3147  {
3148  this->SetDirty();
3149  }
3150 };
3151 
3152 static constexpr NWidgetPart _nested_cust_currency_widgets[] = {
3154  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
3155  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_CURRENCY_WINDOW, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
3156  EndContainer(),
3157  NWidget(WWT_PANEL, COLOUR_GREY),
3162  NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_RATE_DOWN), SetDataTip(AWV_DECREASE, STR_CURRENCY_DECREASE_EXCHANGE_RATE_TOOLTIP),
3163  NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_RATE_UP), SetDataTip(AWV_INCREASE, STR_CURRENCY_INCREASE_EXCHANGE_RATE_TOOLTIP),
3164  EndContainer(),
3165  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_RATE), SetDataTip(STR_CURRENCY_EXCHANGE_RATE, STR_CURRENCY_SET_EXCHANGE_RATE_TOOLTIP), SetFill(1, 0),
3166  EndContainer(),
3168  NWidget(WWT_PUSHBTN, COLOUR_DARK_BLUE, WID_CC_SEPARATOR_EDIT), SetDataTip(0x0, STR_CURRENCY_SET_CUSTOM_CURRENCY_SEPARATOR_TOOLTIP), SetFill(0, 1),
3169  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_SEPARATOR), SetDataTip(STR_CURRENCY_SEPARATOR, STR_CURRENCY_SET_CUSTOM_CURRENCY_SEPARATOR_TOOLTIP), SetFill(1, 0),
3170  EndContainer(),
3172  NWidget(WWT_PUSHBTN, COLOUR_DARK_BLUE, WID_CC_PREFIX_EDIT), SetDataTip(0x0, STR_CURRENCY_SET_CUSTOM_CURRENCY_PREFIX_TOOLTIP), SetFill(0, 1),
3173  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_PREFIX), SetDataTip(STR_CURRENCY_PREFIX, STR_CURRENCY_SET_CUSTOM_CURRENCY_PREFIX_TOOLTIP), SetFill(1, 0),
3174  EndContainer(),
3176  NWidget(WWT_PUSHBTN, COLOUR_DARK_BLUE, WID_CC_SUFFIX_EDIT), SetDataTip(0x0, STR_CURRENCY_SET_CUSTOM_CURRENCY_SUFFIX_TOOLTIP), SetFill(0, 1),
3177  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_SUFFIX), SetDataTip(STR_CURRENCY_SUFFIX, STR_CURRENCY_SET_CUSTOM_CURRENCY_SUFFIX_TOOLTIP), SetFill(1, 0),
3178  EndContainer(),
3181  NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_YEAR_DOWN), SetDataTip(AWV_DECREASE, STR_CURRENCY_DECREASE_CUSTOM_CURRENCY_TO_EURO_TOOLTIP),
3182  NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_YEAR_UP), SetDataTip(AWV_INCREASE, STR_CURRENCY_INCREASE_CUSTOM_CURRENCY_TO_EURO_TOOLTIP),
3183  EndContainer(),
3184  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_YEAR), SetDataTip(STR_JUST_STRING1, STR_CURRENCY_SET_CUSTOM_CURRENCY_TO_EURO_TOOLTIP), SetFill(1, 0),
3185  EndContainer(),
3186  EndContainer(),
3187  NWidget(WWT_LABEL, COLOUR_BLUE, WID_CC_PREVIEW),
3188  SetDataTip(STR_CURRENCY_PREVIEW, STR_CURRENCY_CUSTOM_CURRENCY_PREVIEW_TOOLTIP),
3189  EndContainer(),
3190  EndContainer(),
3191 };
3192 
3193 static WindowDesc _cust_currency_desc(__FILE__, __LINE__,
3194  WDP_CENTER, nullptr, 0, 0,
3196  0,
3197  std::begin(_nested_cust_currency_widgets), std::end(_nested_cust_currency_widgets)
3198 );
3199 
3201 static void ShowCustCurrency()
3202 {
3204  new CustomCurrencyWindow(&_cust_currency_desc);
3205 }
SZSP_NONE
@ SZSP_NONE
Display plane with zero size in both directions (none filling and resizing).
Definition: widget_type.h:469
WID_CC_YEAR_DOWN
@ WID_CC_YEAR_DOWN
Down button.
Definition: settings_widget.h:91
Window::timeout_timer
uint8_t timeout_timer
Timer value of the WF_TIMEOUT for flags.
Definition: window_gui.h:300
WC_CUSTOM_CURRENCY
@ WC_CUSTOM_CURRENCY
Custom currency; Window numbers:
Definition: window_type.h:625
NWidgetResizeBase
Base class for a resizable nested widget.
Definition: widget_type.h:291
SEF_RIGHT_DEPRESSED
@ SEF_RIGHT_DEPRESSED
Of a numeric setting entry, the right button is depressed.
Definition: settings_gui.cpp:1197
SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1141
_autosave_dropdown_to_minutes
static const uint32_t _autosave_dropdown_to_minutes[]
Available settings for autosave intervals.
Definition: settings_gui.cpp:68
WID_CC_PREVIEW
@ WID_CC_PREVIEW
Preview.
Definition: settings_widget.h:94
NWidgetContainer::children
std::vector< std::unique_ptr< NWidgetBase > > children
Child widgets in contaier.
Definition: widget_type.h:462
Window::SetTimeout
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
Definition: window_gui.h:355
CustomCurrencyWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: settings_gui.cpp:3146
CloseWindowByClass
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Definition: window.cpp:1153
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:1747
social_integration.h
WID_GO_FULLSCREEN_BUTTON
@ WID_GO_FULLSCREEN_BUTTON
Toggle fullscreen.
Definition: settings_widget.h:25
factory.hpp
SocialIntegrationPlugin::FAILED
@ FAILED
The plugin failed to initialize.
Definition: social_integration.h:18
WID_GS_TYPE_DROPDOWN
@ WID_GS_TYPE_DROPDOWN
The drop down box to choose client/game/company/all settings.
Definition: settings_widget.h:75
SetBit
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
Definition: bitmath_func.hpp:121
SocialIntegrationPlugin::name
std::string name
Name of the plugin.
Definition: social_integration.h:29
Pool::PoolItem<&_company_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:335
SEF_LEFT_DEPRESSED
@ SEF_LEFT_DEPRESSED
Of a numeric setting entry, the left button is depressed.
Definition: settings_gui.cpp:1196
querystring_gui.h
GetCurrentLanguageIsoCode
const char * GetCurrentLanguageIsoCode()
Get the ISO language code of the currently loaded language.
Definition: strings.cpp:2157
SEF_BUTTONS_MASK
@ SEF_BUTTONS_MASK
Bit-mask for button flags.
Definition: settings_gui.cpp:1198
ShowQuery
void ShowQuery(StringID caption, StringID 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:1230
WID_TF_CAPTION
@ WID_TF_CAPTION
The caption of the window.
Definition: misc_widget.h:51
WID_GO_BASE_SFX_OPEN_URL
@ WID_GO_BASE_SFX_OPEN_URL
Open base SFX URL.
Definition: settings_widget.h:39
WID_GS_COLLAPSE_ALL
@ WID_GS_COLLAPSE_ALL
Collapse all button.
Definition: settings_widget.h:70
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:30
command_func.h
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
BaseSetTextfileWindow::baseset
const TBaseSet * baseset
View the textfile of this BaseSet.
Definition: settings_gui.cpp:95
WID_GO_CURRENCY_DROPDOWN
@ WID_GO_CURRENCY_DROPDOWN
Currency dropdown.
Definition: settings_widget.h:20
ShowErrorMessage
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc)
Display an error message in a window.
Definition: error_gui.cpp:367
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_type.h:126
BaseSetTextfileWindow::content_type
StringID content_type
STR_CONTENT_TYPE_xxx for title.
Definition: settings_gui.cpp:96
dropdown_func.h
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition: geometry_type.hpp:98
GetSettingFromName
static const SettingDesc * GetSettingFromName(const std::string_view name, const SettingTable &settings)
Given a name of setting, return a setting description from the table.
Definition: settings.cpp:1619
GameSettingsWindow
Window to edit settings of the game.
Definition: settings_gui.cpp:2307
StringFilter::IsEmpty
bool IsEmpty() const
Check whether any filter words were entered.
Definition: stringfilter_type.h:60
BaseMedia< GraphicsSet >::SetSet
static bool SetSet(const GraphicsSet *set)
Set the set to be used.
Definition: base_media_func.h:241
_left_button_down
bool _left_button_down
Is left mouse button pressed?
Definition: gfx.cpp:40
SettingsPage::GetFoldingState
void GetFoldingState(bool &all_folded, bool &all_unfolded) const override
Recursively accumulate the folding state of the (filtered) tree.
Definition: settings_gui.cpp:1824
WID_CC_RATE_UP
@ WID_CC_RATE_UP
Up button.
Definition: settings_widget.h:83
company_base.h
SettingsPage::Length
uint Length() const override
Return number of rows needed to display the (filtered) entry.
Definition: settings_gui.cpp:1876
WID_GS_FILTER
@ WID_GS_FILTER
Text filter.
Definition: settings_widget.h:65
GameSettingsWindow::settings_ptr
static GameSettings * settings_ptr
Pointer to the game settings being displayed and modified.
Definition: settings_gui.cpp:2308
Window::OnDropdownClose
virtual void OnDropdownClose(Point pt, WidgetID widget, int index, bool instant_close)
A dropdown window associated to this window has been closed.
Definition: window.cpp:288
IntSettingDesc::cat
SettingCategory cat
assigned categories of the setting
Definition: settings_internal.h:213
StringFilter::SetFilterTerm
void SetFilterTerm(const char *str)
Set the term to filter on.
Definition: stringfilter.cpp:28
GameSettingsWindow::OnInit
void OnInit() override
Notification that the nested widget tree gets initialized.
Definition: settings_gui.cpp:2354
GameSettingsWindow::OnInvalidateData
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
Definition: settings_gui.cpp:2794
WID_GO_SOCIAL_PLUGIN_PLATFORM
@ WID_GO_SOCIAL_PLUGIN_PLATFORM
Platform of the social plugin.
Definition: settings_widget.h:59
WID_GO_GUI_SCALE
@ WID_GO_GUI_SCALE
GUI Scale slider.
Definition: settings_widget.h:26
NWidgetContainer::Add
void Add(std::unique_ptr< NWidgetBase > &&wid)
Append widget wid to container.
Definition: widget.cpp:1161
SettingFilter::type
SettingType type
Filter based on type.
Definition: settings_gui.cpp:1221
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:63
Window::SetWidgetDirty
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:552
BASESET_DIR
@ BASESET_DIR
Subdirectory for all base data (base sets, intro game)
Definition: fileio_type.h:116
currency.h
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:1328
MusicDriver::SetVolume
virtual void SetVolume(byte vol)=0
Set the volume, if possible.
SetAlignment
constexpr NWidgetPart SetAlignment(StringAlignment align)
Widget part function for setting the alignment of text/images.
Definition: widget_type.h:1130
WID_GO_LANG_DROPDOWN
@ WID_GO_LANG_DROPDOWN
Language dropdown.
Definition: settings_widget.h:23
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
ST_GAME
@ ST_GAME
Game setting.
Definition: settings_internal.h:61
SettingEntry::setting
const IntSettingDesc * setting
Setting description of the setting.
Definition: settings_gui.cpp:1266
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition: widget_type.h:59
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:1141
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:210
SettingDesc::GetType
SettingType GetType() const
Return the type of the setting.
Definition: settings.cpp:900
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition: widget_type.h:67
VideoDriver::ToggleVsync
virtual void ToggleVsync([[maybe_unused]] bool vsync)
Change the vsync setting.
Definition: video_driver.hpp:73
WID_GO_SURVEY_SEL
@ WID_GO_SURVEY_SEL
Selection to hide survey if no JSON library is compiled in.
Definition: settings_widget.h:53
SettingDesc::IsEditable
bool IsEditable(bool do_command=false) const
Check whether the setting is editable in the current gamemode.
Definition: settings.cpp:883
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:77
SettingsContainer::GetMaxHelpHeight
uint GetMaxHelpHeight(int maxw)
Get the biggest height of the help texts, if the width is at least maxw.
Definition: settings_gui.cpp:1738
WID_CC_RATE_DOWN
@ WID_CC_RATE_DOWN
Down button.
Definition: settings_widget.h:82
GameSettingsWindow::filter_editbox
QueryString filter_editbox
Filter editbox;.
Definition: settings_gui.cpp:2317
ST_CLIENT
@ ST_CLIENT
Client setting.
Definition: settings_internal.h:63
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition: geometry_func.cpp:22
WID_GS_EXPAND_ALL
@ WID_GS_EXPAND_ALL
Expand all button.
Definition: settings_widget.h:69
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:1048
BaseSettingEntry::SetLastField
void SetLastField(bool last_field)
Set whether this is the last visible entry of the parent node.
Definition: settings_gui.cpp:1241
Window::EnableWidget
void EnableWidget(WidgetID widget_index)
Sets a widget to Enabled.
Definition: window_gui.h:400
WID_GS_RESTRICT_DROPDOWN
@ WID_GS_RESTRICT_DROPDOWN
The drop down box to restrict the list of settings.
Definition: settings_widget.h:74
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1151
BaseSetTextfileWindow
Window for displaying the textfile of a BaseSet.
Definition: settings_gui.cpp:94
WID_GO_SOCIAL_PLUGIN_TITLE
@ WID_GO_SOCIAL_PLUGIN_TITLE
Title of the frame of the social plugin.
Definition: settings_widget.h:58
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:37
FILLRECT_CHECKER
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
Definition: gfx_type.h:294
WID_GO_SURVEY_PREVIEW_BUTTON
@ WID_GO_SURVEY_PREVIEW_BUTTON
Button to open a preview window with the survey results.
Definition: settings_widget.h:56
WID_GS_SCROLLBAR
@ WID_GS_SCROLLBAR
Scrollbar.
Definition: settings_widget.h:67
SettingFilter::string
StringFilter string
Filter string.
Definition: settings_gui.cpp:1217
GameOptionsWindow
Definition: settings_gui.cpp:354
zoom_func.h
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:2334
ST_COMPANY
@ ST_COMPANY
Company setting.
Definition: settings_internal.h:62
WID_GO_BASE_MUSIC_VOLUME
@ WID_GO_BASE_MUSIC_VOLUME
Change music volume.
Definition: settings_widget.h:44
base_media_base.h
NWidgetResizeBase::UpdateVerticalSize
bool UpdateVerticalSize(uint min_y)
Set absolute (post-scaling) minimal size of the widget.
Definition: widget.cpp:1056
SettingsContainer::entries
EntryVector entries
Settings on this page.
Definition: settings_gui.cpp:1288
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:54
GameSettingsWindow::last_clicked
SettingEntry * last_clicked
If non-nullptr, pointer to the last clicked setting.
Definition: settings_gui.cpp:2312
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition: widget_type.h:50
SettingsPage::FindEntry
BaseSettingEntry * FindEntry(uint row, uint *cur_row) override
Find setting entry at row row_num.
Definition: settings_gui.cpp:1890
WID_GO_BASE_GRF_TEXTFILE
@ WID_GO_BASE_GRF_TEXTFILE
Open base GRF readme, changelog (+1) or license (+2).
Definition: settings_widget.h:34
WidgetDimensions::hsep_wide
int hsep_wide
Wide horizontal spacing.
Definition: window_gui.h:64
town.h
RectPadding::Vertical
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Definition: geometry_type.hpp:69
WWT_PUSHARROWBTN
@ WWT_PUSHARROWBTN
Normal push-button (no toggle button) with arrow caption.
Definition: widget_type.h:112
StrongType::Typedef
Templated helper to make a type-safe 'typedef' representing a single POD value.
Definition: strong_typedef_type.hpp:150
StringFilter::AddLine
void AddLine(const char *str)
Pass another text line from the current item to the filter.
Definition: stringfilter.cpp:114
network_gui.h
FR_LOWERED
@ FR_LOWERED
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
Definition: window_gui.h:28
settings_internal.h
SettingDesc::flags
SettingFlag flags
Handles how a setting would show up in the GUI (text/currency, etc.).
Definition: settings_internal.h:76
SA_RIGHT
@ SA_RIGHT
Right align the text (must be a single bit).
Definition: gfx_type.h:340
SEF_FILTERED
@ SEF_FILTERED
Entry is hidden by the string filter.
Definition: settings_gui.cpp:1201
NWidgetFunction
constexpr NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
Obtain a nested widget (sub)tree from an external source.
Definition: widget_type.h:1279
WC_MUSIC_WINDOW
@ WC_MUSIC_WINDOW
Music window; Window numbers:
Definition: window_type.h:602
newgrf_config.h
SettingEntry::IsVisibleByRestrictionMode
bool IsVisibleByRestrictionMode(RestrictionMode mode) const
Checks whether an entry shall be made visible based on the restriction mode.
Definition: settings_gui.cpp:1499
SettingsPage::SettingsPage
SettingsPage(StringID title)
Constructor for a sub-page in the 'advanced settings' window.
Definition: settings_gui.cpp:1777
WID_GO_VIDEO_DRIVER_INFO
@ WID_GO_VIDEO_DRIVER_INFO
Label showing details about the current video driver.
Definition: settings_widget.h:52
BaseSettingEntry::Init
virtual void Init(byte level=0)
Initialization of a setting entry.
Definition: settings_gui.cpp:1345
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:678
Window::GetScrollbar
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:315
WID_GO_GUI_FONT_SPRITE
@ WID_GO_GUI_FONT_SPRITE
Toggle whether to prefer the sprite font over TTF fonts.
Definition: settings_widget.h:29
SettingsPage
Data structure describing one page of settings in the settings window.
Definition: settings_gui.cpp:1314
StrEmpty
bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition: string_func.h:56
TextfileWindow::file_type
TextfileType file_type
Type of textfile to view.
Definition: textfile_gui.h:22
TFT_CHANGELOG
@ TFT_CHANGELOG
Content changelog.
Definition: textfile_type.h:18
SettingsContainer::UpdateFilterState
bool UpdateFilterState(SettingFilter &filter, bool force_visible)
Update the filter state.
Definition: settings_gui.cpp:1678
Rect::WithHeight
Rect WithHeight(int height, bool end=false) const
Copy Rect and set its height.
Definition: geometry_type.hpp:211
Window::Window
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition: window.cpp:1757
CustomCurrencyWindow
Definition: settings_gui.cpp:2969
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:1038
textfile_gui.h
SettingEntry::Init
void Init(byte level=0) override
Initialization of a setting entry.
Definition: settings_gui.cpp:1455
Scrollbar::GetPosition
uint16_t GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:720
QueryString
Data stored about a string that can be modified in the GUI.
Definition: querystring_gui.h:20
WC_GRF_PARAMETERS
@ WC_GRF_PARAMETERS
NewGRF parameters; Window numbers:
Definition: window_type.h:181
NWidgetSocialPlugins::SetupSmallestSize
void SetupSmallestSize(Window *w) override
Definition: settings_gui.cpp:222
WID_GO_BASE_MUSIC_DESCRIPTION
@ WID_GO_BASE_MUSIC_DESCRIPTION
Description of selected base music set.
Definition: settings_widget.h:48
WID_GO_TAB_SELECTION
@ WID_GO_TAB_SELECTION
Background of the tab selection.
Definition: settings_widget.h:19
SETBITS
#define SETBITS(x, y)
Sets several bits in a variable.
Definition: bitmath_func.hpp:136
GameSettingsWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: settings_gui.cpp:2705
_colour_gradient
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
Definition: palette.cpp:26
_gui_scale
int _gui_scale
GUI scale, 100 is 100%.
Definition: gfx.cpp:62
GetStringLineCount
int GetStringLineCount(StringID str, int maxw)
Calculates number of lines of string.
Definition: gfx.cpp:729
textbuf_gui.h
Textbuf::buf
char *const buf
buffer in which text is saved
Definition: textbuf_type.h:32
Scrollbar::GetCount
uint16_t GetCount() const
Gets the number of elements in the list.
Definition: widget_type.h:702
MakeNWidgetSocialPlugins
std::unique_ptr< NWidgetBase > MakeNWidgetSocialPlugins()
Construct nested container widget for managing the list of social plugins.
Definition: settings_gui.cpp:349
ai.hpp
WN_GAME_OPTIONS_GAME_OPTIONS
@ WN_GAME_OPTIONS_GAME_OPTIONS
Game options.
Definition: window_type.h:26
SettingsPage::FoldAll
void FoldAll() override
Recursively close all (filtered) folds of sub-pages.
Definition: settings_gui.cpp:1802
WID_GO_BASE_GRF_OPEN_URL
@ WID_GO_BASE_GRF_OPEN_URL
Open base GRF URL.
Definition: settings_widget.h:33
WindowDesc
High level window description.
Definition: window_gui.h:153
GameSettingsWindow::warn_missing
WarnHiddenResult warn_missing
Whether and how to warn about missing search results.
Definition: settings_gui.cpp:2319
WidgetID
int WidgetID
Widget ID.
Definition: window_type.h:18
AdjustGUIZoom
bool AdjustGUIZoom(bool automatic)
Resolve GUI zoom level and adjust GUI to new zoom, if auto-suggestion is requested.
Definition: gfx.cpp:1814
BaseSettingEntry::level
byte level
Nesting level of this setting entry.
Definition: settings_gui.cpp:1227
WID_GO_BASE_SFX_DESCRIPTION
@ WID_GO_BASE_SFX_DESCRIPTION
Description of selected base SFX.
Definition: settings_widget.h:41
SocialIntegrationPlugin::INVALID_SIGNATURE
@ INVALID_SIGNATURE
The signature of the plugin is invalid.
Definition: social_integration.h:23
SettingType
SettingType
Type of settings for filtering.
Definition: settings_internal.h:60
DECLARE_POSTFIX_INCREMENT
#define DECLARE_POSTFIX_INCREMENT(enum_type)
Some enums need to have allowed incrementing (i.e.
Definition: enum_type.hpp:14
_gui_scale_cfg
int _gui_scale_cfg
GUI scale in config.
Definition: gfx.cpp:63
GUISettings::refresh_rate
uint16_t refresh_rate
How often we refresh the screen (time between draw-ticks).
Definition: settings_type.h:201
SettingEntry::DrawSetting
void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const override
Function to draw setting value (button + text + current value)
Definition: settings_gui.cpp:1592
SettingsPage::title
StringID title
Title of the sub-page.
Definition: settings_gui.cpp:1315
SettingFilter::min_cat
RestrictionMode min_cat
Minimum category needed to display all filtered strings (RM_BASIC, RM_ADVANCED, or RM_ALL).
Definition: settings_gui.cpp:1218
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:508
SF_GUI_CURRENCY
@ SF_GUI_CURRENCY
The number represents money, so when reading value multiply by exchange rate.
Definition: settings_internal.h:20
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:1188
WID_GO_AUTOSAVE_DROPDOWN
@ WID_GO_AUTOSAVE_DROPDOWN
Dropdown to say how often to autosave.
Definition: settings_widget.h:22
WID_GS_OPTIONSPANEL
@ WID_GS_OPTIONSPANEL
Panel widget containing the option lists.
Definition: settings_widget.h:66
SettingsPage::UpdateFilterState
bool UpdateFilterState(SettingFilter &filter, bool force_visible) override
Update the filter state.
Definition: settings_gui.cpp:1843
WC_QUERY_STRING
@ WC_QUERY_STRING
Query string window; Window numbers:
Definition: window_type.h:123
SocialIntegrationPlugin::UNLOADED
@ UNLOADED
The plugin is unloaded upon request.
Definition: social_integration.h:20
SF_GUI_0_IS_SPECIAL
@ SF_GUI_0_IS_SPECIAL
A value of zero is possible and has a custom string (the one after "strval").
Definition: settings_internal.h:18
SetResize
constexpr NWidgetPart SetResize(int16_t dx, int16_t dy)
Widget part function for setting the resize step.
Definition: widget_type.h:1086
DrawDropDownButton
void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
Draw a dropdown button.
Definition: settings_gui.cpp:2940
MIN_EURO_YEAR
static constexpr TimerGameCalendar::Year MIN_EURO_YEAR
The earliest year custom currencies may switch to the Euro.
Definition: currency.h:19
SocialIntegrationPlugin
Definition: social_integration.h:13
WWT_PUSHBTN
@ WWT_PUSHBTN
Normal push-button (no toggle button) with custom drawing.
Definition: widget_type.h:109
SettingsPage::ResetAll
void ResetAll() override
Resets all settings to their default values.
Definition: settings_gui.cpp:1794
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:308
GameSettingsWindow::warn_lines
int warn_lines
Number of lines used for warning about missing search results.
Definition: settings_gui.cpp:2320
ResetAllSettingsConfirmationCallback
static void ResetAllSettingsConfirmationCallback(Window *w, bool confirmed)
Callback function for the reset all settings button.
Definition: settings_gui.cpp:2297
VideoDriver::GetListOfMonitorRefreshRates
virtual std::vector< int > GetListOfMonitorRefreshRates()
Get a list of refresh rates of each available monitor.
Definition: video_driver.hpp:162
WID_GO_BASE_MUSIC_DROPDOWN
@ WID_GO_BASE_MUSIC_DROPDOWN
Use to select a base music set.
Definition: settings_widget.h:42
SETTING_HEIGHT
static int SETTING_HEIGHT
Height of a single setting in the tree view in pixels.
Definition: settings_gui.cpp:1189
GRFConfig
Information about GRF, used in the game and (part of it) in savegames.
Definition: newgrf_config.h:147
MusicDriver::GetInstance
static MusicDriver * GetInstance()
Get the currently active instance of the music driver.
Definition: music_driver.hpp:46
FS_NORMAL
@ FS_NORMAL
Index of the normal font in the font tables.
Definition: gfx_type.h:203
RestrictionMode
RestrictionMode
How the list of advanced settings is filtered.
Definition: settings_gui.cpp:1205
SettingEntry::UpdateFilterState
bool UpdateFilterState(SettingFilter &filter, bool force_visible) override
Update the filter state.
Definition: settings_gui.cpp:1540
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1747
SetScrollbar
constexpr NWidgetPart SetScrollbar(WidgetID index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1244
WWT_EDITBOX
@ WWT_EDITBOX
a textbox for typing
Definition: widget_type.h:73
GameSettingsWindow::valuewindow_entry
SettingEntry * valuewindow_entry
If non-nullptr, pointer to setting for which a value-entering window has been opened.
Definition: settings_gui.cpp:2310
ReInitAllWindows
void ReInitAllWindows(bool zoom_changed)
Re-initialize all windows.
Definition: window.cpp:3316
WHR_TYPE
@ WHR_TYPE
Type setting filtered matches away.
Definition: settings_gui.cpp:2288
Window::height
int height
Height of the window (number of pixels down in y direction)
Definition: window_gui.h:306
WF_CENTERED
@ WF_CENTERED
Window is centered and shall stay centered after ReInit.
Definition: window_gui.h:232
IntSettingDesc
Base integer type, including boolean, settings.
Definition: settings_internal.h:143
WID_GO_TAB_GRAPHICS
@ WID_GO_TAB_GRAPHICS
Graphics tab.
Definition: settings_widget.h:16
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:941
GRFConfig::SetParameterDefaults
void SetParameterDefaults()
Set the default value for all parameters as specified by action14.
Definition: newgrf_config.cpp:123
highscore.h
GetTextfile
std::optional< std::string > GetTextfile(TextfileType type, Subdirectory dir, const std::string &filename)
Search a textfile file next to the given content.
Definition: textfile_gui.cpp:865
FS_SMALL
@ FS_SMALL
Index of the small font in the font tables.
Definition: gfx_type.h:204
SettingsContainer::ResetAll
void ResetAll()
Resets all settings to their default values.
Definition: settings_gui.cpp:1637
SettingsPage::Init
void Init(byte level=0) override
Initialization of an entire setting page.
Definition: settings_gui.cpp:1787
WID_GS_RESTRICT_CATEGORY
@ WID_GS_RESTRICT_CATEGORY
Label upfront to the category drop-down box to restrict the list of settings to show.
Definition: settings_widget.h:72
GUISettings::missing_strings_threshold
byte missing_strings_threshold
the number of missing strings before showing the warning
Definition: settings_type.h:193
BaseSettingEntry
Data structure describing a single setting in a tab.
Definition: settings_gui.cpp:1225
NWidgetContainer::FillWidgetLookup
void FillWidgetLookup(WidgetLookup &widget_lookup) override
Definition: widget.cpp:1168
GameOptionsWindow::OnInvalidateData
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
Definition: settings_gui.cpp:962
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:110
InitFontCache
void InitFontCache(bool monospace)
(Re)initialize the font cache related things, i.e.
Definition: fontcache.cpp:197
WID_GO_SOCIAL_PLUGINS
@ WID_GO_SOCIAL_PLUGINS
Main widget handling the social plugins.
Definition: settings_widget.h:57
IntSettingDesc::def
int32_t def
default value given when none is present
Definition: settings_internal.h:206
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:135
NWidgetSocialPlugins::FillWidgetLookup
void FillWidgetLookup(WidgetLookup &widget_lookup) override
Definition: settings_gui.cpp:216
RM_END
@ RM_END
End for iteration.
Definition: settings_gui.cpp:1211
FontCacheSettings::prefer_sprite
bool prefer_sprite
Whether to prefer the built-in sprite font over resizable fonts.
Definition: fontcache.h:221
WID_GO_TEXT_MUSIC_VOLUME
@ WID_GO_TEXT_MUSIC_VOLUME
Music volume label.
Definition: settings_widget.h:43
SettingFilter::mode
RestrictionMode mode
Filter based on category.
Definition: settings_gui.cpp:1220
WID_GO_TAB_GENERAL
@ WID_GO_TAB_GENERAL
General tab.
Definition: settings_widget.h:15
Scrollbar::GetCapacity
uint16_t GetCapacity() const
Gets the number of visible elements of the scrollbar.
Definition: widget_type.h:711
SettingsPage::IsVisible
bool IsVisible(const BaseSettingEntry *item) const override
Check whether an entry is visible and not folded or filtered away.
Definition: settings_gui.cpp:1866
dropdown_type.h
SocialIntegrationPlugin::DUPLICATE
@ DUPLICATE
Another plugin of the same Social Platform is already loaded.
Definition: social_integration.h:21
WID_CC_YEAR
@ WID_CC_YEAR
Year of introduction.
Definition: settings_widget.h:93
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:953
WID_GO_BASE_SFX_VOLUME
@ WID_GO_BASE_SFX_VOLUME
Change sound effects volume.
Definition: settings_widget.h:38
GameSettingsWindow::OnDropdownClose
void OnDropdownClose(Point pt, WidgetID widget, int index, bool instant_close) override
A dropdown window associated to this window has been closed.
Definition: settings_gui.cpp:2775
IntSettingDesc::min
int32_t min
minimum values
Definition: settings_internal.h:207
SettingEntry::name
const char * name
Name of the setting.
Definition: settings_gui.cpp:1265
TextfileWindow::LoadTextfile
virtual void LoadTextfile(const std::string &textfile, Subdirectory dir)
Loads the textfile text from file and setup lines.
Definition: textfile_gui.cpp:765
WL_INFO
@ WL_INFO
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
Definition: error.h:24
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1258
WID_GO_SOCIAL_PLUGIN_STATE
@ WID_GO_SOCIAL_PLUGIN_STATE
State of the social plugin.
Definition: settings_widget.h:60
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:49
_current_language
const LanguageMetadata * _current_language
The currently loaded language.
Definition: strings.cpp:54
DrawSliderWidget
void DrawSliderWidget(Rect r, int min_value, int max_value, int value, const std::map< int, StringID > &labels)
Draw a slider widget with knob at given value.
Definition: slider.cpp:30
CurrencySpec::code
std::string code
3 letter untranslated code to identify the currency.
Definition: currency.h:80
SEF_LAST_FIELD
@ SEF_LAST_FIELD
This entry is the last one in a (sub-)page.
Definition: settings_gui.cpp:1200
WID_GO_TEXT_SFX_VOLUME
@ WID_GO_TEXT_SFX_VOLUME
Sound effects volume label.
Definition: settings_widget.h:37
GetMaskOfAllowedCurrencies
uint64_t GetMaskOfAllowedCurrencies()
get a mask of the allowed currencies depending on the year
Definition: currency.cpp:124
safeguards.h
ShowQueryString
void ShowQueryString(StringID 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:1086
RM_ALL
@ RM_ALL
List all settings regardless of the default/newgame/... values.
Definition: settings_gui.cpp:1208
Window::LowerWidget
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
Definition: window_gui.h:460
music_driver.hpp
Window::flags
WindowFlags flags
Window flags.
Definition: window_gui.h:294
_resolutions
std::vector< Dimension > _resolutions
List of resolutions.
Definition: driver.cpp:31
WF_TIMEOUT
@ WF_TIMEOUT
Window timeout counter.
Definition: window_gui.h:222
NWidgetVertical::SetupSmallestSize
void SetupSmallestSize(Window *w) override
Definition: widget.cpp:1549
GetStringHeight
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Definition: gfx.cpp:705
WID_GO_VIDEO_ACCEL_BUTTON
@ WID_GO_VIDEO_ACCEL_BUTTON
Toggle for video acceleration.
Definition: settings_widget.h:49
GameSettings
All settings together for the game.
Definition: settings_type.h:617
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
SettingsPage::folded
bool folded
Sub-page is folded (not visible except for its title)
Definition: settings_gui.cpp:1316
ChangeAutosaveFrequency
void ChangeAutosaveFrequency(bool reset)
Reset the interval of the autosave.
Definition: openttd.cpp:1533
DrawSprite
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Definition: gfx.cpp:1007
GameOptionsWindow::OnMouseLoop
void OnMouseLoop() override
Called for every mouse loop run, which is at least once per (game) tick.
Definition: settings_gui.cpp:877
GameSettingsWindow::valuedropdown_entry
SettingEntry * valuedropdown_entry
If non-nullptr, pointer to the value for which a dropdown window is currently opened.
Definition: settings_gui.cpp:2313
SettingsContainer::Init
void Init(byte level=0)
Initialization of an entire setting page.
Definition: settings_gui.cpp:1629
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
NWidgetSocialPlugins
Definition: settings_gui.cpp:197
error.h
WID_GO_BASE_GRF_DESCRIPTION
@ WID_GO_BASE_GRF_DESCRIPTION
Description of selected base GRF.
Definition: settings_widget.h:35
CheckBlitter
void CheckBlitter()
Check whether we still use the right blitter, or use another (better) one.
Definition: gfxinit.cpp:317
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
RM_BASIC
@ RM_BASIC
Display settings associated to the "basic" list.
Definition: settings_gui.cpp:1206
WWT_FRAME
@ WWT_FRAME
Frame.
Definition: widget_type.h:62
language.h
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:134
WHR_CATEGORY
@ WHR_CATEGORY
Category setting filtered matches away.
Definition: settings_gui.cpp:2287
WID_CC_SUFFIX
@ WID_CC_SUFFIX
Current suffix.
Definition: settings_widget.h:90
SETTING_BUTTON_WIDTH
#define SETTING_BUTTON_WIDTH
Width of setting buttons.
Definition: settings_gui.h:17
stdafx.h
DrawArrowButtons
void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right)
Draw [<][>] boxes.
Definition: settings_gui.cpp:2909
SettingFilter::type_hides
bool type_hides
Whether the type hides filtered strings.
Definition: settings_gui.cpp:1219
Window::SetFocusedWidget
bool SetFocusedWidget(WidgetID widget_index)
Set focus within this window to the given widget.
Definition: window.cpp:487
WID_GS_SETTING_DROPDOWN
@ WID_GS_SETTING_DROPDOWN
Dynamically created dropdown for changing setting value.
Definition: settings_widget.h:77
GfxFillRect
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
Definition: gfx.cpp:113
ShowCustCurrency
static void ShowCustCurrency()
Open custom currency window.
Definition: settings_gui.cpp:3201
WID_GO_BASE_GRF_PARAMETERS
@ WID_GO_BASE_GRF_PARAMETERS
Base GRF parameters.
Definition: settings_widget.h:32
IntSettingDesc::GetHelp
StringID GetHelp() const
Get the help text of the setting.
Definition: settings.cpp:466
TFT_README
@ TFT_README
Content readme.
Definition: textfile_type.h:17
LanguagePackHeader::own_name
char own_name[32]
the localized name of this language
Definition: language.h:30
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: settings_gui.cpp:1762
CurrencySpec
Specification of a currency.
Definition: currency.h:74
WarnHiddenResult
WarnHiddenResult
Warnings about hidden search results.
Definition: settings_gui.cpp:2285
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:3140
VideoDriver::GetInstance
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
Definition: video_driver.hpp:200
CS_ALPHANUMERAL
@ CS_ALPHANUMERAL
Both numeric and alphabetic and spaces and stuff.
Definition: string_type.h:25
viewport_func.h
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:45
WHR_CATEGORY_TYPE
@ WHR_CATEGORY_TYPE
Both category and type settings filtered matches away.
Definition: settings_gui.cpp:2289
Window::SetWidgetLoweredState
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:441
SocialIntegrationPlugin::RUNNING
@ RUNNING
The plugin is successfully loaded and running.
Definition: social_integration.h:16
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:79
ShowBaseSetTextfileWindow
void ShowBaseSetTextfileWindow(TextfileType file_type, const TBaseSet *baseset, StringID content_type)
Open the BaseSet version of the textfile window.
Definition: settings_gui.cpp:122
WID_CC_RATE
@ WID_CC_RATE
Rate of currency.
Definition: settings_widget.h:84
WID_GO_RESOLUTION_DROPDOWN
@ WID_GO_RESOLUTION_DROPDOWN
Dropdown for the resolution.
Definition: settings_widget.h:24
Scrollbar::GetScrolledRowFromWidget
int 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:2260
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition: window_gui.h:67
Window::SetWidgetDisabledState
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:381
MakeNWidgets
std::unique_ptr< NWidgetBase > MakeNWidgets(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, std::unique_ptr< NWidgetBase > &&container)
Construct a nested widget tree from an array of parts.
Definition: widget.cpp:3137
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:941
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:71
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:70
BaseMedia< GraphicsSet >::GetNumSets
static int GetNumSets()
Count the number of available graphics sets.
Definition: base_media_func.h:348
string_func.h
SettingEntry::SetButtons
void SetButtons(byte new_val)
Set the button-depressed flags (SEF_LEFT_DEPRESSED and SEF_RIGHT_DEPRESSED) to a specified value.
Definition: settings_gui.cpp:1472
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:235
TFT_LICENSE
@ TFT_LICENSE
Content license.
Definition: textfile_type.h:19
_switch_mode
SwitchMode _switch_mode
The next mainloop command.
Definition: gfx.cpp:48
GameSettingsWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: settings_gui.cpp:2837
WWT_PUSHIMGBTN
@ WWT_PUSHIMGBTN
Normal push-button (no toggle button) with image caption.
Definition: widget_type.h:111
WID_GO_VIDEO_VSYNC_BUTTON
@ WID_GO_VIDEO_VSYNC_BUTTON
Toggle for video vsync.
Definition: settings_widget.h:50
WID_GO_SURVEY_PARTICIPATE_BUTTON
@ WID_GO_SURVEY_PARTICIPATE_BUTTON
Toggle for participating in the automated survey.
Definition: settings_widget.h:54
Window::querystrings
std::map< WidgetID, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
Definition: window_gui.h:314
QueryString::cancel_button
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
Definition: querystring_gui.h:28
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:775
rev.h
WID_GO_GUI_FONT_AA
@ WID_GO_GUI_FONT_AA
Toggle whether to anti-alias fonts.
Definition: settings_widget.h:30
WC_GAME_OPTIONS
@ WC_GAME_OPTIONS
Game options window; Window numbers:
Definition: window_type.h:619
SocialIntegrationPlugin::version
std::string version
Version of the plugin.
Definition: social_integration.h:30
Window::CreateNestedTree
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1724
strings_func.h
WID_GO_BASE_SFX_DROPDOWN
@ WID_GO_BASE_SFX_DROPDOWN
Use to select a base SFX.
Definition: settings_widget.h:36
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:86
IntSettingDesc::GetTitle
StringID GetTitle() const
Get the title of the setting.
Definition: settings.cpp:457
ShowDropDownList
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, bool instant_close)
Show a drop down list.
Definition: dropdown.cpp:349
main
int CDECL main(int argc, char *argv[])
And the main program (what else?)
Definition: settingsgen.cpp:433
WID_GS_RESTRICT_TYPE
@ WID_GS_RESTRICT_TYPE
Label upfront to the type drop-down box to restrict the list of settings to show.
Definition: settings_widget.h:73
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
LocaleSettings::currency
byte currency
currency we currently use
Definition: settings_type.h:260
WidgetLookup
std::map< WidgetID, class NWidgetBase * > WidgetLookup
Lookup between widget IDs and NWidget objects.
Definition: widget_type.h:127
BaseSettingEntry::FindEntry
virtual BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find setting entry at row row_num.
Definition: settings_gui.cpp:1368
SettingsContainer::UnFoldAll
void UnFoldAll()
Recursively open all folds of sub-pages.
Definition: settings_gui.cpp:1653
Window::DisableWidget
void DisableWidget(WidgetID widget_index)
Sets a widget to disabled.
Definition: window_gui.h:391
Window::CloseChildWindows
void CloseChildWindows(WindowClass wc=WC_INVALID) const
Close all children a window might have in a head-recursive manner.
Definition: window.cpp:1036
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition: widget_type.h:60
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:1220
WidgetDimensions::hsep_indent
int hsep_indent
Width of identation for tree layouts.
Definition: window_gui.h:65
SettingsContainer::IsVisible
bool IsVisible(const BaseSettingEntry *item) const
Check whether an entry is visible and not folded or filtered away.
Definition: settings_gui.cpp:1697
SettingsContainer::Length
uint Length() const
Return number of rows needed to display the whole page.
Definition: settings_gui.cpp:1706
video_driver.hpp
SetDParam
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings.cpp:104
RM_CHANGED_AGAINST_DEFAULT
@ RM_CHANGED_AGAINST_DEFAULT
Show only settings which are different compared to default values.
Definition: settings_gui.cpp:1209
SC_BASIC_LIST
@ SC_BASIC_LIST
Settings displayed in the list of basic settings.
Definition: settings_internal.h:45
GUISettings::autosave_interval
uint32_t autosave_interval
how often should we do autosaves?
Definition: settings_type.h:160
geometry_func.hpp
WID_GO_BASE_MUSIC_JUKEBOX
@ WID_GO_BASE_MUSIC_JUKEBOX
Open the jukebox.
Definition: settings_widget.h:45
ClickSliderWidget
bool ClickSliderWidget(Rect r, Point pt, int min_value, int max_value, int &value)
Handle click on a slider widget to change the value.
Definition: slider.cpp:80
IntSettingDesc::max
uint32_t max
maximum values
Definition: settings_internal.h:208
GameSettingsWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: settings_gui.cpp:2394
UpdateAllVirtCoords
void UpdateAllVirtCoords()
Update the viewport coordinates of all signs.
Definition: afterload.cpp:222
StringFilter::ResetState
void ResetState()
Reset the matching state to process a new item.
Definition: stringfilter.cpp:98
IntSettingDesc::Read
int32_t Read(const void *object) const
Read the integer from the the actual setting.
Definition: settings.cpp:577
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:52
_video_hw_accel
bool _video_hw_accel
Whether to consider hardware accelerated video drivers.
Definition: video_driver.cpp:25
WidgetDimensions::vsep_normal
int vsep_normal
Normal vertical spacing.
Definition: window_gui.h:60
NWidgetBase::resize_y
uint resize_y
Vertical resize step (0 means not resizable).
Definition: widget_type.h:226
WID_GS_RESET_ALL
@ WID_GS_RESET_ALL
Reset all button.
Definition: settings_widget.h:71
Scrollbar::SetCount
void SetCount(size_t num)
Sets the number of elements in the list.
Definition: widget_type.h:760
IntSettingDesc::IsBoolSetting
virtual bool IsBoolSetting() const
Check whether this setting is a boolean type setting.
Definition: settings_internal.h:228
NWidgetVertical
Vertical container.
Definition: widget_type.h:565
SettingsContainer::FindEntry
BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find the setting entry at row number row_num.
Definition: settings_gui.cpp:1721
Window::mouse_capture_widget
WidgetID mouse_capture_widget
ID of current mouse capture widget (e.g. dragged scrollbar). -1 if no widget has mouse capture.
Definition: window_gui.h:320
StringFilter::GetState
bool GetState() const
Get the matching state of the current item.
Definition: stringfilter_type.h:71
WID_CC_SUFFIX_EDIT
@ WID_CC_SUFFIX_EDIT
Suffix edit button.
Definition: settings_widget.h:89
WID_GO_TAB_SOCIAL
@ WID_GO_TAB_SOCIAL
Social tab.
Definition: settings_widget.h:18
SetDParamStr
void SetDParamStr(size_t n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
Definition: strings.cpp:352
SettingsPage::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 override
Draw a row in the settings panel.
Definition: settings_gui.cpp:1914
WID_CC_SEPARATOR_EDIT
@ WID_CC_SEPARATOR_EDIT
Separator edit button.
Definition: settings_widget.h:85
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1734
IntSettingDesc::SetValueDParams
void SetValueDParams(uint first_param, int32_t value) const
Set the DParams for drawing the value of the setting.
Definition: settings.cpp:476
WID_GO_GUI_SCALE_BEVEL_BUTTON
@ WID_GO_GUI_SCALE_BEVEL_BUTTON
Toggle for chunky bevels.
Definition: settings_widget.h:28
company_func.h
WL_ERROR
@ WL_ERROR
Errors (eg. saving/loading failed)
Definition: error.h:26
SocialIntegrationPlugin::UNSUPPORTED_API
@ UNSUPPORTED_API
The plugin does not support the current API version.
Definition: social_integration.h:22
SM_MENU
@ SM_MENU
Switch to game intro menu.
Definition: openttd.h:33
WID_GO_GUI_SCALE_AUTO
@ WID_GO_GUI_SCALE_AUTO
Autodetect GUI scale button.
Definition: settings_widget.h:27
GetCurrentResolutionIndex
static uint GetCurrentResolutionIndex()
Get index of the current screen resolution.
Definition: settings_gui.cpp:84
QueryString::ACTION_CLEAR
static const int ACTION_CLEAR
Clear editbox.
Definition: querystring_gui.h:24
CS_NUMERAL_SIGNED
@ CS_NUMERAL_SIGNED
Only numbers and '-' for negative values.
Definition: string_type.h:28
Window::SetWidgetsLoweredState
void SetWidgetsLoweredState(bool lowered_stat, Args... widgets)
Sets the lowered/raised status of a list of widgets.
Definition: window_gui.h:526
WID_GO_BASE_MUSIC_TEXTFILE
@ WID_GO_BASE_MUSIC_TEXTFILE
Open base music readme, changelog (+1) or license (+2).
Definition: settings_widget.h:47
SettingsPage::UnFoldAll
void UnFoldAll() override
Recursively open all (filtered) folds of sub-pages.
Definition: settings_gui.cpp:1811
DrawFrameRect
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
Draw frame rectangle.
Definition: widget.cpp:281
NWidgetSocialPlugins::Draw
void Draw(const Window *w) override
Definition: settings_gui.cpp:333
CF_NOEURO
static constexpr TimerGameCalendar::Year CF_NOEURO
Currency never switches to the Euro (as far as known).
Definition: currency.h:17
network.h
SettingsContainer::FoldAll
void FoldAll()
Recursively close all folds of sub-pages.
Definition: settings_gui.cpp:1645
SettingsPage::DrawSetting
void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const override
Function to draw setting value (button + text + current value)
Definition: settings_gui.cpp:1939
_video_vsync
bool _video_vsync
Whether we should use vsync (only if _video_hw_accel is enabled).
Definition: video_driver.cpp:26
window_func.h
CheckForMissingGlyphs
void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher)
Check whether the currently loaded language pack uses characters that the currently loaded font does ...
Definition: strings.cpp:2268
SA_CENTER
@ SA_CENTER
Center both horizontally and vertically.
Definition: gfx_type.h:348
SocialIntegrationPlugin::PLATFORM_NOT_RUNNING
@ PLATFORM_NOT_RUNNING
The plugin failed to initialize because the Social Platform is not running.
Definition: social_integration.h:19
GetCharacterHeight
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition: fontcache.cpp:78
GameSettingsWindow::filter
SettingFilter filter
Filter for the list.
Definition: settings_gui.cpp:2316
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:379
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:300
Window::width
int width
width of the window (number of pixels to the right in x direction)
Definition: window_gui.h:305
MusicSettings::effect_vol
byte effect_vol
The requested effects volume.
Definition: settings_type.h:251
stringfilter_type.h
WID_CC_PREFIX
@ WID_CC_PREFIX
Current prefix.
Definition: settings_widget.h:88
SetMinimalSize
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1097
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition: gfx.cpp:1552
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:1232
ClientSettings::network
NetworkSettings network
settings related to the network
Definition: settings_type.h:637
GRFConfig::num_params
uint8_t num_params
Number of used parameters.
Definition: newgrf_config.h:168
GameSettings::locale
LocaleSettings locale
settings related to used currency/unit system in the current game
Definition: settings_type.h:631
SocialIntegrationPlugin::social_platform
std::string social_platform
Social platform this plugin is for.
Definition: social_integration.h:28
NWidgetBase::pos_y
int pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:237
config.h
BaseSettingEntry::IsVisible
virtual bool IsVisible(const BaseSettingEntry *item) const
Check whether an entry is visible and not folded or filtered away.
Definition: settings_gui.cpp:1356
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:658
SettingEntry::SettingEntry
SettingEntry(const char *name)
Constructor for a single setting in the 'advanced settings' window.
Definition: settings_gui.cpp:1445
SettingFilter
Filter for settings list.
Definition: settings_gui.cpp:1216
fontcache.h
RM_CHANGED_AGAINST_NEW
@ RM_CHANGED_AGAINST_NEW
Show only settings which are different compared to the user's new game setting values.
Definition: settings_gui.cpp:1210
TextfileWindow
Window for displaying a textfile.
Definition: textfile_gui.h:21
WidgetDimensions::bevel
RectPadding bevel
Bevel thickness, affected by "scaled bevels" game option.
Definition: window_gui.h:40
GetSettingsTree
static SettingsContainer & GetSettingsTree()
Construct settings tree.
Definition: settings_gui.cpp:1947
gui.h
ST_ALL
@ ST_ALL
Used in setting filter to match all types.
Definition: settings_internal.h:65
GetGameSettings
GameSettings & GetGameSettings()
Get the settings-object applicable for the current situation: the newgame settings when we're in the ...
Definition: settings_type.h:660
WID_GS_HELP_TEXT
@ WID_GS_HELP_TEXT
Information area to display help text of the selected option.
Definition: settings_widget.h:68
ClientSettings::company
CompanySettings company
default values for per-company settings
Definition: settings_type.h:638
WidgetDimensions::frametext
RectPadding frametext
Padding inside frame with text.
Definition: window_gui.h:43
SettingsContainer
Containers for BaseSettingEntry.
Definition: settings_gui.cpp:1286
GameSettingsWindow::closing_dropdown
bool closing_dropdown
True, if the dropdown list is currently closing.
Definition: settings_gui.cpp:2314
BaseSettingEntry::flags
byte flags
Flags of the setting entry.
Definition: settings_gui.cpp:1226
Window
Data structure for an opened window.
Definition: window_gui.h:267
TextfileType
TextfileType
Additional text files accompanying Tar archives.
Definition: textfile_type.h:14
BaseSounds::ini_set
static std::string ini_set
The set as saved in the config file.
Definition: base_media_base.h:301
SC_ADVANCED_LIST
@ SC_ADVANCED_LIST
Settings displayed in the list of advanced settings.
Definition: settings_internal.h:46
GameOptionsWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: settings_gui.cpp:601
SettingEntry
Standard setting.
Definition: settings_gui.cpp:1264
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:324
BaseMedia< GraphicsSet >::GetUsedSet
static const GraphicsSet * GetUsedSet()
Return the used set.
Definition: base_media_func.h:394
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:731
SF_GUI_DROPDOWN
@ SF_GUI_DROPDOWN
The value represents a limited number of string-options (internally integer) presented as dropdown.
Definition: settings_internal.h:19
Clamp
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:79
network_survey.h
ShowGameSettings
void ShowGameSettings()
Open advanced settings window.
Definition: settings_gui.cpp:2893
GetDropDownListDimension
Dimension GetDropDownListDimension(const DropDownList &list)
Determine width and height required to fully display a DropDownList.
Definition: dropdown.cpp:310
WID_CC_PREFIX_EDIT
@ WID_CC_PREFIX_EDIT
Prefix edit button.
Definition: settings_widget.h:87
DrawBoolButton
void DrawBoolButton(int x, int y, bool state, bool clickable)
Draw a toggle button.
Definition: settings_gui.cpp:2961
SetDataTip
constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1162
settings_gui.h
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:1109
Rect::Width
int Width() const
Get width of Rect.
Definition: geometry_type.hpp:85
NWID_SELECTION
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition: widget_type.h:82
GUISettings::scale_bevels
bool scale_bevels
bevels are scaled with GUI scale.
Definition: settings_type.h:223
SF_PER_COMPANY
@ SF_PER_COMPANY
This setting can be different for each company (saved in company struct).
Definition: settings_internal.h:26
_languages
LanguageList _languages
The actual list of language meta data.
Definition: strings.cpp:53
GameOptionsWindow::BuildDropDownList
DropDownList BuildDropDownList(WidgetID widget, int *selected_index) const
Build the dropdown list for a specific widget.
Definition: settings_gui.cpp:390
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:75
GameSettingsWindow::manually_changed_folding
bool manually_changed_folding
Whether the user expanded/collapsed something manually.
Definition: settings_gui.cpp:2318
FontCacheSettings::global_aa
bool global_aa
Whether to anti alias all font sizes.
Definition: fontcache.h:222
WID_CC_YEAR_UP
@ WID_CC_YEAR_UP
Up button.
Definition: settings_widget.h:92
WC_DROPDOWN_MENU
@ WC_DROPDOWN_MENU
Drop down menu; Window numbers:
Definition: window_type.h:156
BaseSettingEntry::Draw
virtual 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: settings_gui.cpp:1405
GameSettingsWindow::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:2513
WID_GO_BASE_GRF_DROPDOWN
@ WID_GO_BASE_GRF_DROPDOWN
Use to select a base GRF.
Definition: settings_widget.h:31
SettingEntry::Length
uint Length() const override
Return number of rows needed to display the (filtered) entry.
Definition: settings_gui.cpp:1479
AWV_INCREASE
@ AWV_INCREASE
Arrow to the right or in case of RTL to the left.
Definition: widget_type.h:34
SetWindowClassesDirty
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
Definition: window.cpp:3108
WID_GO_BASE_SFX_TEXTFILE
@ WID_GO_BASE_SFX_TEXTFILE
Open base SFX readme, changelog (+1) or license (+2).
Definition: settings_widget.h:40
QSF_ENABLE_DEFAULT
@ QSF_ENABLE_DEFAULT
enable the 'Default' button ("\0" is returned)
Definition: textbuf_gui.h:21
ClientSettings::music
MusicSettings music
settings related to music/sound
Definition: settings_type.h:640
CLRBITS
#define CLRBITS(x, y)
Clears several bits in a variable.
Definition: bitmath_func.hpp:166
NWidgetBase::current_x
uint current_x
Current horizontal size (after resizing).
Definition: widget_type.h:233
WC_TEXTFILE
@ WC_TEXTFILE
textfile; Window numbers:
Definition: window_type.h:187
WHR_NONE
@ WHR_NONE
Nothing was filtering matches away.
Definition: settings_gui.cpp:2286
WidgetDimensions::framerect
RectPadding framerect
Standard padding inside many panels.
Definition: window_gui.h:42
WidgetDimensions::hsep_normal
int hsep_normal
Normal horizontal spacing.
Definition: window_gui.h:63
SettingsContainer::GetFoldingState
void GetFoldingState(bool &all_folded, bool &all_unfolded) const
Recursively accumulate the folding state of the tree.
Definition: settings_gui.cpp:1665
WDP_CENTER
@ WDP_CENTER
Center the window.
Definition: window_gui.h:142
ChangeMusicSet
void ChangeMusicSet(int index)
Change the configured music set and reset playback.
Definition: music_gui.cpp:463
SETTING_BUTTON_HEIGHT
#define SETTING_BUTTON_HEIGHT
Height of setting buttons.
Definition: settings_gui.h:19
GameSettingsWindow::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:2311
ReadLanguagePack
bool ReadLanguagePack(const LanguageMetadata *lang)
Read a particular language.
Definition: strings.cpp:1907
MusicSettings::music_vol
byte music_vol
The requested music volume.
Definition: settings_type.h:250
_left_button_clicked
bool _left_button_clicked
Is left mouse button clicked?
Definition: gfx.cpp:41
WID_GO_TAB_SOUND
@ WID_GO_TAB_SOUND
Sound tab.
Definition: settings_widget.h:17
TD_RTL
@ TD_RTL
Text is written right-to-left by default.
Definition: strings_type.h:24
_current_text_dir
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition: strings.cpp:56
_circle_size
static Dimension _circle_size
Dimension of the circle +/- icon. This is here as not all users are within the class of the settings ...
Definition: settings_gui.cpp:76
CS_NUMERAL
@ CS_NUMERAL
Only numeric ones.
Definition: string_type.h:26
CharSetFilter
CharSetFilter
Valid filter types for IsValidChar.
Definition: string_type.h:24
SetupWidgetDimensions
void SetupWidgetDimensions()
Set up pre-scaled versions of Widget Dimensions.
Definition: widget.cpp:66
SocialIntegration::GetPlugins
static std::vector< SocialIntegrationPlugin * > GetPlugins()
Get the list of loaded social integration plugins.
Definition: social_integration.cpp:149
_currency_specs
CurrencySpec _currency_specs[CURRENCY_END]
Array of currencies used by the system.
Definition: currency.cpp:76
WID_GO_BASE_MUSIC_OPEN_URL
@ WID_GO_BASE_MUSIC_OPEN_URL
Open base music URL.
Definition: settings_widget.h:46
GetStringBoundingBox
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:852
StringFilter
String filter and state.
Definition: stringfilter_type.h:30
WID_CC_SEPARATOR
@ WID_CC_SEPARATOR
Current separator.
Definition: settings_widget.h:86
CURRENCY_CUSTOM
@ CURRENCY_CUSTOM
Custom currency.
Definition: currency.h:58
_settings_newgame
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
Definition: settings.cpp:56
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:57
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:17
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:636
mixer.h
AWV_DECREASE
@ AWV_DECREASE
Arrow to the left or in case of RTL to the right.
Definition: widget_type.h:33
ShowDropDownListAt
void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, WidgetID button, Rect wi_rect, Colours wi_colour, bool instant_close)
Show a drop down list.
Definition: dropdown.cpp:332
WWT_DROPDOWN
@ WWT_DROPDOWN
Drop down list.
Definition: widget_type.h:72
SettingDesc::AsIntSetting
const struct IntSettingDesc * AsIntSetting() const
Get the setting description of this setting as an integer setting.
Definition: settings.cpp:910
WID_GO_SURVEY_LINK_BUTTON
@ WID_GO_SURVEY_LINK_BUTTON
Button to open browser to go to the survey website.
Definition: settings_widget.h:55
SettingEntry::GetMaxHelpHeight
uint GetMaxHelpHeight(int maxw) override
Get the biggest height of the help text(s), if the width is at least maxw.
Definition: settings_gui.cpp:1489
BaseSettingEntry::IsFiltered
bool IsFiltered() const
Check whether an entry is hidden due to filters.
Definition: settings_gui.cpp:1253
NetworkSettings::participate_survey
ParticipateSurvey participate_survey
Participate in the automated survey.
Definition: settings_type.h:335
RM_ADVANCED
@ RM_ADVANCED
Display settings associated to the "advanced" list.
Definition: settings_gui.cpp:1207
WN_GAME_OPTIONS_GAME_SETTINGS
@ WN_GAME_OPTIONS_GAME_SETTINGS
Game settings.
Definition: window_type.h:27
ShowGameOptions
void ShowGameOptions()
Open the game options window.
Definition: settings_gui.cpp:1183
SettingEntryFlags
SettingEntryFlags
Flags for SettingEntry.
Definition: settings_gui.cpp:1195
WID_GO_REFRESH_RATE_DROPDOWN
@ WID_GO_REFRESH_RATE_DROPDOWN
Dropdown for all available refresh rates.
Definition: settings_widget.h:51
GUISettings::settings_restriction_mode
uint8_t settings_restriction_mode
selected restriction mode in adv. settings GUI.
Definition: settings_type.h:219
HasBit
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103