OpenTTD Source  13.2.1
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 
45 #include <vector>
46 #include <iterator>
47 
48 #include "safeguards.h"
49 #include "video/video_driver.hpp"
50 
51 
52 static const StringID _autosave_dropdown[] = {
53  STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_OFF,
54  STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_1_MONTH,
55  STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_3_MONTHS,
56  STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_6_MONTHS,
57  STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_12_MONTHS,
59 };
60 
62 
63 static const void *ResolveObject(const GameSettings *settings_ptr, const IntSettingDesc *sd);
64 
70 {
71  auto it = std::find(_resolutions.begin(), _resolutions.end(), Dimension(_screen.width, _screen.height));
72  return std::distance(_resolutions.begin(), it);
73 }
74 
75 static void ShowCustCurrency();
76 
77 template <class T>
78 static DropDownList BuildSetDropDownList(int *selected_index, bool allow_selection)
79 {
80  int n = T::GetNumSets();
81  *selected_index = T::GetIndexOfUsedSet();
82 
83  DropDownList list;
84  for (int i = 0; i < n; i++) {
85  list.emplace_back(new DropDownListCharStringItem(T::GetSet(i)->name, i, !allow_selection && (*selected_index != i)));
86  }
87 
88  return list;
89 }
90 
91 DropDownList BuildMusicSetDropDownList(int *selected_index)
92 {
93  return BuildSetDropDownList<BaseMusic>(selected_index, true);
94 }
95 
97 template <class TBaseSet>
99  const TBaseSet* baseset;
101 
103  {
104  const char *textfile = this->baseset->GetTextfile(file_type);
105  this->LoadTextfile(textfile, BASESET_DIR);
106  }
107 
108  void SetStringParameters(int widget) const override
109  {
110  if (widget == WID_TF_CAPTION) {
112  SetDParamStr(1, this->baseset->name);
113  }
114  }
115 };
116 
123 template <class TBaseSet>
124 void ShowBaseSetTextfileWindow(TextfileType file_type, const TBaseSet* baseset, StringID content_type)
125 {
126  CloseWindowById(WC_TEXTFILE, file_type);
127  new BaseSetTextfileWindow<TBaseSet>(file_type, baseset, content_type);
128 }
129 
130 std::set<int> _refresh_rates = { 30, 60, 75, 90, 100, 120, 144, 240 };
131 
137 {
138  /* Add the refresh rate as selected in the config. */
139  _refresh_rates.insert(_settings_client.gui.refresh_rate);
140 
141  /* Add all the refresh rates of all monitors connected to the machine. */
142  std::vector<int> monitorRates = VideoDriver::GetInstance()->GetListOfMonitorRefreshRates();
143  std::copy(monitorRates.begin(), monitorRates.end(), std::inserter(_refresh_rates, _refresh_rates.end()));
144 }
145 
146 static const std::map<int, StringID> _scale_labels = {
147  { 100, STR_GAME_OPTIONS_GUI_SCALE_1X },
148  { 125, STR_NULL },
149  { 150, STR_NULL },
150  { 175, STR_NULL },
151  { 200, STR_GAME_OPTIONS_GUI_SCALE_2X },
152  { 225, STR_NULL },
153  { 250, STR_NULL },
154  { 275, STR_NULL },
155  { 300, STR_GAME_OPTIONS_GUI_SCALE_3X },
156  { 325, STR_NULL },
157  { 350, STR_NULL },
158  { 375, STR_NULL },
159  { 400, STR_GAME_OPTIONS_GUI_SCALE_4X },
160  { 425, STR_NULL },
161  { 450, STR_NULL },
162  { 475, STR_NULL },
163  { 500, STR_GAME_OPTIONS_GUI_SCALE_5X },
164 };
165 
167  GameSettings *opt;
168  bool reload;
169  int gui_scale;
170 
171  GameOptionsWindow(WindowDesc *desc) : Window(desc)
172  {
173  this->opt = &GetGameSettings();
174  this->reload = false;
175  this->gui_scale = _gui_scale;
176 
178 
180  this->OnInvalidateData(0);
181  }
182 
183  void Close() override
184  {
187  if (this->reload) _switch_mode = SM_MENU;
188  this->Window::Close();
189  }
190 
197  DropDownList BuildDropDownList(int widget, int *selected_index) const
198  {
199  DropDownList list;
200  switch (widget) {
201  case WID_GO_CURRENCY_DROPDOWN: { // Setup currencies dropdown
202  *selected_index = this->opt->locale.currency;
203  StringID *items = BuildCurrencyDropdown();
204  uint64 disabled = _game_mode == GM_MENU ? 0LL : ~GetMaskOfAllowedCurrencies();
205 
206  /* Add non-custom currencies; sorted naturally */
207  for (uint i = 0; i < CURRENCY_END; items++, i++) {
208  if (i == CURRENCY_CUSTOM) continue;
209  list.emplace_back(new DropDownListStringItem(*items, i, HasBit(disabled, i)));
210  }
211  std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
212 
213  /* Append custom currency at the end */
214  list.emplace_back(new DropDownListItem(-1, false)); // separator line
215  list.emplace_back(new DropDownListStringItem(STR_GAME_OPTIONS_CURRENCY_CUSTOM, CURRENCY_CUSTOM, HasBit(disabled, CURRENCY_CUSTOM)));
216  break;
217  }
218 
219  case WID_GO_AUTOSAVE_DROPDOWN: { // Setup autosave dropdown
220  *selected_index = _settings_client.gui.autosave;
221  const StringID *items = _autosave_dropdown;
222  for (uint i = 0; *items != INVALID_STRING_ID; items++, i++) {
223  list.emplace_back(new DropDownListStringItem(*items, i, false));
224  }
225  break;
226  }
227 
228  case WID_GO_LANG_DROPDOWN: { // Setup interface language dropdown
229  for (uint i = 0; i < _languages.size(); i++) {
230  bool hide_language = IsReleasedVersion() && !_languages[i].IsReasonablyFinished();
231  if (hide_language) continue;
232  bool hide_percentage = IsReleasedVersion() || _languages[i].missing < _settings_client.gui.missing_strings_threshold;
233  auto item = new DropDownListParamStringItem(hide_percentage ? STR_JUST_RAW_STRING : STR_GAME_OPTIONS_LANGUAGE_PERCENTAGE, i, false);
234  if (&_languages[i] == _current_language) {
235  *selected_index = i;
236  item->SetParamStr(0, _languages[i].own_name);
237  } else {
238  /* Especially with sprite-fonts, not all localized
239  * names can be rendered. So instead, we use the
240  * international names for anything but the current
241  * selected language. This avoids showing a few ????
242  * entries in the dropdown list. */
243  item->SetParamStr(0, _languages[i].name);
244  }
245  item->SetParam(1, (LANGUAGE_TOTAL_STRINGS - _languages[i].missing) * 100 / LANGUAGE_TOTAL_STRINGS);
246  list.emplace_back(item);
247  }
248  std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
249  break;
250  }
251 
252  case WID_GO_RESOLUTION_DROPDOWN: // Setup resolution dropdown
253  if (_resolutions.empty()) break;
254 
255  *selected_index = GetCurrentResolutionIndex();
256  for (uint i = 0; i < _resolutions.size(); i++) {
257  auto item = new DropDownListParamStringItem(STR_GAME_OPTIONS_RESOLUTION_ITEM, i, false);
258  item->SetParam(0, _resolutions[i].width);
259  item->SetParam(1, _resolutions[i].height);
260  list.emplace_back(item);
261  }
262  break;
263 
264  case WID_GO_REFRESH_RATE_DROPDOWN: // Setup refresh rate dropdown
265  for (auto it = _refresh_rates.begin(); it != _refresh_rates.end(); it++) {
266  auto i = std::distance(_refresh_rates.begin(), it);
267  if (*it == _settings_client.gui.refresh_rate) *selected_index = i;
268  auto item = new DropDownListParamStringItem(STR_GAME_OPTIONS_REFRESH_RATE_ITEM, i, false);
269  item->SetParam(0, *it);
270  list.emplace_back(item);
271  }
272  break;
273 
275  list = BuildSetDropDownList<BaseGraphics>(selected_index, (_game_mode == GM_MENU));
276  break;
277 
279  list = BuildSetDropDownList<BaseSounds>(selected_index, (_game_mode == GM_MENU));
280  break;
281 
283  list = BuildMusicSetDropDownList(selected_index);
284  break;
285  }
286 
287  return list;
288  }
289 
290  void SetStringParameters(int widget) const override
291  {
292  switch (widget) {
293  case WID_GO_CURRENCY_DROPDOWN: SetDParam(0, _currency_specs[this->opt->locale.currency].name); break;
294  case WID_GO_AUTOSAVE_DROPDOWN: SetDParam(0, _autosave_dropdown[_settings_client.gui.autosave]); break;
297  case WID_GO_BASE_GRF_STATUS: SetDParam(0, BaseGraphics::GetUsedSet()->GetNumInvalid()); break;
300  case WID_GO_BASE_MUSIC_STATUS: SetDParam(0, BaseMusic::GetUsedSet()->GetNumInvalid()); break;
301  case WID_GO_VIDEO_DRIVER_INFO: SetDParamStr(0, VideoDriver::GetInstance()->GetInfoString()); break;
304  auto current_resolution = GetCurrentResolutionIndex();
305 
306  if (current_resolution == _resolutions.size()) {
307  SetDParam(0, STR_GAME_OPTIONS_RESOLUTION_OTHER);
308  } else {
309  SetDParam(0, STR_GAME_OPTIONS_RESOLUTION_ITEM);
310  SetDParam(1, _resolutions[current_resolution].width);
311  SetDParam(2, _resolutions[current_resolution].height);
312  }
313  break;
314  }
315  }
316  }
317 
318  void DrawWidget(const Rect &r, int widget) const override
319  {
320  switch (widget) {
323  DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_BLACK_RAW_STRING);
324  break;
325 
328  DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_BLACK_RAW_STRING);
329  break;
330 
333  DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_BLACK_RAW_STRING);
334  break;
335 
336  case WID_GO_GUI_SCALE:
337  DrawSliderWidget(r, MIN_INTERFACE_SCALE, MAX_INTERFACE_SCALE, this->gui_scale, _scale_labels);
338  break;
339 
341  DrawSliderWidget(r, 0, INT8_MAX, _settings_client.music.effect_vol, {});
342  break;
343 
345  DrawSliderWidget(r, 0, INT8_MAX, _settings_client.music.music_vol, {});
346  break;
347  }
348  }
349 
350  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
351  {
352  switch (widget) {
354  /* Find the biggest description for the default size. */
355  for (int i = 0; i < BaseGraphics::GetNumSets(); i++) {
357  size->height = std::max(size->height, (uint)GetStringHeight(STR_BLACK_RAW_STRING, size->width));
358  }
359  break;
360 
362  /* Find the biggest description for the default size. */
363  for (int i = 0; i < BaseGraphics::GetNumSets(); i++) {
364  uint invalid_files = BaseGraphics::GetSet(i)->GetNumInvalid();
365  if (invalid_files == 0) continue;
366 
367  SetDParam(0, invalid_files);
368  *size = maxdim(*size, GetStringBoundingBox(STR_GAME_OPTIONS_BASE_GRF_STATUS));
369  }
370  break;
371 
373  /* Find the biggest description for the default size. */
374  for (int i = 0; i < BaseSounds::GetNumSets(); i++) {
376  size->height = std::max(size->height, (uint)GetStringHeight(STR_BLACK_RAW_STRING, size->width));
377  }
378  break;
379 
381  /* Find the biggest description for the default size. */
382  for (int i = 0; i < BaseMusic::GetNumSets(); i++) {
383  SetDParamStr(0, BaseMusic::GetSet(i)->GetDescription(GetCurrentLanguageIsoCode()));
384  size->height = std::max(size->height, (uint)GetStringHeight(STR_BLACK_RAW_STRING, size->width));
385  }
386  break;
387 
389  /* Find the biggest description for the default size. */
390  for (int i = 0; i < BaseMusic::GetNumSets(); i++) {
391  uint invalid_files = BaseMusic::GetSet(i)->GetNumInvalid();
392  if (invalid_files == 0) continue;
393 
394  SetDParam(0, invalid_files);
395  *size = maxdim(*size, GetStringBoundingBox(STR_GAME_OPTIONS_BASE_MUSIC_STATUS));
396  }
397  break;
398 
399  default: {
400  int selected;
401  DropDownList list = this->BuildDropDownList(widget, &selected);
402  if (!list.empty()) {
403  /* Find the biggest item for the default size. */
404  for (const auto &ddli : list) {
405  Dimension string_dim;
406  int width = ddli->Width();
407  string_dim.width = width + padding.width;
408  string_dim.height = ddli->Height(width) + padding.height;
409  *size = maxdim(*size, string_dim);
410  }
411  }
412  }
413  }
414  }
415 
416  void OnClick(Point pt, int widget, int click_count) override
417  {
418  if (widget >= WID_GO_BASE_GRF_TEXTFILE && widget < WID_GO_BASE_GRF_TEXTFILE + TFT_END) {
419  if (BaseGraphics::GetUsedSet() == nullptr) return;
420 
421  ShowBaseSetTextfileWindow((TextfileType)(widget - WID_GO_BASE_GRF_TEXTFILE), BaseGraphics::GetUsedSet(), STR_CONTENT_TYPE_BASE_GRAPHICS);
422  return;
423  }
424  if (widget >= WID_GO_BASE_SFX_TEXTFILE && widget < WID_GO_BASE_SFX_TEXTFILE + TFT_END) {
425  if (BaseSounds::GetUsedSet() == nullptr) return;
426 
427  ShowBaseSetTextfileWindow((TextfileType)(widget - WID_GO_BASE_SFX_TEXTFILE), BaseSounds::GetUsedSet(), STR_CONTENT_TYPE_BASE_SOUNDS);
428  return;
429  }
430  if (widget >= WID_GO_BASE_MUSIC_TEXTFILE && widget < WID_GO_BASE_MUSIC_TEXTFILE + TFT_END) {
431  if (BaseMusic::GetUsedSet() == nullptr) return;
432 
433  ShowBaseSetTextfileWindow((TextfileType)(widget - WID_GO_BASE_MUSIC_TEXTFILE), BaseMusic::GetUsedSet(), STR_CONTENT_TYPE_BASE_MUSIC);
434  return;
435  }
436  switch (widget) {
437  case WID_GO_FULLSCREEN_BUTTON: // Click fullscreen on/off
438  /* try to toggle full-screen on/off */
439  if (!ToggleFullScreen(!_fullscreen)) {
440  ShowErrorMessage(STR_ERROR_FULLSCREEN_FAILED, INVALID_STRING_ID, WL_ERROR);
441  }
444  break;
445 
448  ShowErrorMessage(STR_GAME_OPTIONS_VIDEO_ACCELERATION_RESTART, INVALID_STRING_ID, WL_INFO);
451 #ifndef __APPLE__
454 #endif
455  break;
456 
458  if (!_video_hw_accel) break;
459 
462 
467  break;
468 
471 
473  this->SetDirty();
474 
476  ReInitAllWindows(true);
477  break;
478  }
479 
480  case WID_GO_GUI_SCALE:
481  if (ClickSliderWidget(this->GetWidget<NWidgetBase>(widget)->GetCurrentRect(), pt, MIN_INTERFACE_SCALE, MAX_INTERFACE_SCALE, this->gui_scale)) {
482  if (!_ctrl_pressed) this->gui_scale = ((this->gui_scale + 12) / 25) * 25;
483  this->SetWidgetDirty(widget);
484  }
485 
486  if (click_count > 0) this->mouse_capture_widget = widget;
487  break;
488 
490  {
491  if (_gui_scale_cfg == -1) {
494  } else {
495  _gui_scale_cfg = -1;
497  if (AdjustGUIZoom(false)) ReInitAllWindows(true);
498  this->gui_scale = _gui_scale;
499  }
500  this->SetWidgetDirty(widget);
501  break;
502  }
503 
507  if (ClickSliderWidget(this->GetWidget<NWidgetBase>(widget)->GetCurrentRect(), pt, 0, INT8_MAX, vol)) {
508  if (widget == WID_GO_BASE_MUSIC_VOLUME) {
510  } else {
511  SetEffectVolume(vol);
512  }
513  this->SetWidgetDirty(widget);
515  }
516 
517  if (click_count > 0) this->mouse_capture_widget = widget;
518  break;
519  }
520 
522  ShowMusicWindow();
523  break;
524  }
525 
526  default: {
527  int selected;
528  DropDownList list = this->BuildDropDownList(widget, &selected);
529  if (!list.empty()) {
530  ShowDropDownList(this, std::move(list), selected, widget);
531  } else {
532  if (widget == WID_GO_RESOLUTION_DROPDOWN) ShowErrorMessage(STR_ERROR_RESOLUTION_LIST_FAILED, INVALID_STRING_ID, WL_ERROR);
533  }
534  break;
535  }
536  }
537  }
538 
539  void OnMouseLoop() override
540  {
541  if (_left_button_down || this->gui_scale == _gui_scale) return;
542 
543  _gui_scale_cfg = this->gui_scale;
544 
545  if (AdjustGUIZoom(false)) {
546  ReInitAllWindows(true);
548  this->SetDirty();
549  }
550  }
551 
557  template <class T>
558  void SetMediaSet(int index)
559  {
560  if (_game_mode == GM_MENU) {
561  auto name = T::GetSet(index)->name;
562 
563  T::ini_set = name;
564 
565  T::SetSet(name);
566  this->reload = true;
567  this->InvalidateData();
568  }
569  }
570 
571  void OnDropdownSelect(int widget, int index) override
572  {
573  switch (widget) {
574  case WID_GO_CURRENCY_DROPDOWN: // Currency
575  if (index == CURRENCY_CUSTOM) ShowCustCurrency();
576  this->opt->locale.currency = index;
577  ReInitAllWindows(false);
578  break;
579 
580  case WID_GO_AUTOSAVE_DROPDOWN: // Autosave options
581  _settings_client.gui.autosave = index;
582  this->SetDirty();
583  break;
584 
585  case WID_GO_LANG_DROPDOWN: // Change interface language
586  ReadLanguagePack(&_languages[index]);
589  ClearAllCachedNames();
591  CheckBlitter();
592  ReInitAllWindows(false);
593  break;
594 
595  case WID_GO_RESOLUTION_DROPDOWN: // Change resolution
596  if ((uint)index < _resolutions.size() && ChangeResInGame(_resolutions[index].width, _resolutions[index].height)) {
597  this->SetDirty();
598  }
599  break;
600 
602  _settings_client.gui.refresh_rate = *std::next(_refresh_rates.begin(), index);
603  if (_settings_client.gui.refresh_rate > 60) {
604  /* Show warning to the user that this refresh rate might not be suitable on
605  * larger maps with many NewGRFs and vehicles. */
606  ShowErrorMessage(STR_GAME_OPTIONS_REFRESH_RATE_WARNING, INVALID_STRING_ID, WL_INFO);
607  }
608  break;
609  }
610 
612  this->SetMediaSet<BaseGraphics>(index);
613  break;
614 
616  this->SetMediaSet<BaseSounds>(index);
617  break;
618 
620  ChangeMusicSet(index);
621  break;
622  }
623  }
624 
630  void OnInvalidateData(int data = 0, bool gui_scope = true) override
631  {
632  if (!gui_scope) return;
636 
637 #ifndef __APPLE__
640 #endif
641 
644 
645  bool missing_files = BaseGraphics::GetUsedSet()->GetNumMissing() == 0;
646  this->GetWidget<NWidgetCore>(WID_GO_BASE_GRF_STATUS)->SetDataTip(missing_files ? STR_EMPTY : STR_GAME_OPTIONS_BASE_GRF_STATUS, STR_NULL);
647 
648  for (TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) {
652  }
653 
654  missing_files = BaseMusic::GetUsedSet()->GetNumInvalid() == 0;
655  this->GetWidget<NWidgetCore>(WID_GO_BASE_MUSIC_STATUS)->SetDataTip(missing_files ? STR_EMPTY : STR_GAME_OPTIONS_BASE_MUSIC_STATUS, STR_NULL);
656  }
657 };
658 
659 static const NWidgetPart _nested_game_options_widgets[] = {
661  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
662  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
663  EndContainer(),
664  NWidget(WWT_PANEL, COLOUR_GREY, WID_GO_BACKGROUND), SetPIP(6, 6, 10),
665  NWidget(NWID_HORIZONTAL), SetPIP(10, 10, 10),
666  NWidget(NWID_VERTICAL), SetPIP(0, 6, 0),
667  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_AUTOSAVE_FRAME, STR_NULL),
668  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_AUTOSAVE_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_TOOLTIP), SetFill(1, 0),
669  EndContainer(),
670  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_CURRENCY_UNITS_FRAME, STR_NULL),
671  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_CURRENCY_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_CURRENCY_UNITS_DROPDOWN_TOOLTIP), SetFill(1, 0),
672  EndContainer(),
673  EndContainer(),
674 
675  NWidget(NWID_VERTICAL), SetPIP(0, 6, 0),
676  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_LANGUAGE, STR_NULL),
677  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_LANG_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_RAW_STRING, STR_GAME_OPTIONS_LANGUAGE_TOOLTIP), SetFill(1, 0),
678  EndContainer(),
679  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_GUI_SCALE_FRAME, STR_NULL),
681  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),
683  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetDataTip(STR_GAME_OPTIONS_GUI_SCALE_AUTO, STR_NULL),
684  NWidget(NWID_SPACER), SetMinimalSize(1, 0), SetFill(1, 0),
685  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_GUI_SCALE_AUTO), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_GUI_SCALE_AUTO_TOOLTIP),
686  EndContainer(),
688  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetDataTip(STR_GAME_OPTIONS_GUI_SCALE_BEVELS, STR_NULL),
689  NWidget(NWID_SPACER), SetMinimalSize(1, 0), SetFill(1, 0),
690  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_GUI_SCALE_BEVEL_BUTTON), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_GUI_SCALE_BEVELS_TOOLTIP),
691  EndContainer(),
692  EndContainer(),
693  EndContainer(),
694  EndContainer(),
695  EndContainer(),
696 
697  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_GRAPHICS, STR_NULL), SetPadding(0, 10, 0, 10),
699  NWidget(NWID_VERTICAL), SetPIP(0, 2, 0),
701  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12),SetDataTip(STR_GAME_OPTIONS_RESOLUTION, STR_NULL),
702  NWidget(NWID_SPACER), SetMinimalSize(1, 0), SetFill(1, 0),
703  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_RESOLUTION_DROPDOWN), SetMinimalSize(200, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_RESOLUTION_TOOLTIP),
704  EndContainer(),
706  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetDataTip(STR_GAME_OPTIONS_REFRESH_RATE, STR_NULL),
707  NWidget(NWID_SPACER), SetMinimalSize(1, 0), SetFill(1, 0),
708  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_REFRESH_RATE_DROPDOWN), SetMinimalSize(200, 12), SetDataTip(STR_GAME_OPTIONS_REFRESH_RATE_ITEM, STR_GAME_OPTIONS_REFRESH_RATE_TOOLTIP),
709  EndContainer(),
711  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetDataTip(STR_GAME_OPTIONS_FULLSCREEN, STR_NULL),
712  NWidget(NWID_SPACER), SetMinimalSize(1, 0), SetFill(1, 0),
713  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_FULLSCREEN_BUTTON), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_FULLSCREEN_TOOLTIP),
714  EndContainer(),
716  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetDataTip(STR_GAME_OPTIONS_VIDEO_ACCELERATION, STR_NULL),
717  NWidget(NWID_SPACER), SetMinimalSize(1, 0), SetFill(1, 0),
718  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_VIDEO_ACCEL_BUTTON), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_VIDEO_ACCELERATION_TOOLTIP),
719  EndContainer(),
720 #ifndef __APPLE__
722  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetDataTip(STR_GAME_OPTIONS_VIDEO_VSYNC, STR_NULL),
723  NWidget(NWID_SPACER), SetMinimalSize(1, 0), SetFill(1, 0),
724  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_VIDEO_VSYNC_BUTTON), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_VIDEO_VSYNC_TOOLTIP),
725  EndContainer(),
726 #endif
728  NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_VIDEO_DRIVER_INFO), SetMinimalSize(0, 12), SetFill(1, 0), SetDataTip(STR_GAME_OPTIONS_VIDEO_DRIVER_INFO, STR_NULL),
729  EndContainer(),
730  EndContainer(),
731  EndContainer(),
732  EndContainer(),
733 
734  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_BASE_GRF, STR_NULL), SetPadding(0, 10, 0, 10),
735  NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 0),
736  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_GRF_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_RAW_STRING, STR_GAME_OPTIONS_BASE_GRF_TOOLTIP),
737  NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_BASE_GRF_STATUS), SetMinimalSize(150, 12), SetDataTip(STR_EMPTY, STR_NULL), SetFill(1, 0),
738  EndContainer(),
739  NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_BASE_GRF_DESCRIPTION), SetMinimalSize(330, 0), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_BASE_GRF_DESCRIPTION_TOOLTIP), SetFill(1, 0), SetPadding(6, 0, 6, 0),
741  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_GRF_TEXTFILE + TFT_README), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_README, STR_NULL),
742  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_GRF_TEXTFILE + TFT_CHANGELOG), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_CHANGELOG, STR_NULL),
743  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_GRF_TEXTFILE + TFT_LICENSE), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_LICENCE, STR_NULL),
744  EndContainer(),
745  EndContainer(),
746 
747  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_BASE_SFX, STR_NULL), SetPadding(0, 10, 0, 10),
748  NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 7),
749  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_SFX_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_RAW_STRING, STR_GAME_OPTIONS_BASE_SFX_TOOLTIP),
750  NWidget(NWID_SPACER), SetMinimalSize(150, 12), SetFill(1, 0),
751  NWidget(WWT_EMPTY, COLOUR_GREY, WID_GO_BASE_SFX_VOLUME), SetMinimalSize(67, 12), SetFill(0, 0), SetDataTip(0x0, STR_MUSIC_TOOLTIP_DRAG_SLIDERS_TO_SET_MUSIC),
752  EndContainer(),
753  NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_BASE_SFX_DESCRIPTION), SetMinimalSize(330, 0), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_BASE_SFX_DESCRIPTION_TOOLTIP), SetFill(1, 0), SetPadding(6, 0, 6, 0),
755  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_SFX_TEXTFILE + TFT_README), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_README, STR_NULL),
756  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_SFX_TEXTFILE + TFT_CHANGELOG), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_CHANGELOG, STR_NULL),
757  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_SFX_TEXTFILE + TFT_LICENSE), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_LICENCE, STR_NULL),
758  EndContainer(),
759  EndContainer(),
760 
761  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_BASE_MUSIC, STR_NULL), SetPadding(0, 10, 0, 10),
762  NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 7),
763  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_MUSIC_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_RAW_STRING, STR_GAME_OPTIONS_BASE_MUSIC_TOOLTIP),
764  NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_BASE_MUSIC_STATUS), SetMinimalSize(150, 12), SetDataTip(STR_EMPTY, STR_NULL), SetFill(1, 0),
765  NWidget(WWT_EMPTY, COLOUR_GREY, WID_GO_BASE_MUSIC_VOLUME), SetMinimalSize(67, 12), SetFill(0, 0), SetDataTip(0x0, STR_MUSIC_TOOLTIP_DRAG_SLIDERS_TO_SET_MUSIC),
766  EndContainer(),
767  NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 7),
768  NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_BASE_MUSIC_DESCRIPTION), SetMinimalSize(330, 0), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_BASE_MUSIC_DESCRIPTION_TOOLTIP), SetFill(1, 0), SetPadding(6, 0, 6, 0),
769  NWidget(NWID_VERTICAL), SetPIP(0, 0, 0),
770  NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_GO_BASE_MUSIC_JUKEBOX), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_MUSIC, STR_TOOLBAR_TOOLTIP_SHOW_SOUND_MUSIC_WINDOW), SetPadding(6, 0, 6, 0),
771  EndContainer(),
772  EndContainer(),
774  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_MUSIC_TEXTFILE + TFT_README), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_README, STR_NULL),
775  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_MUSIC_TEXTFILE + TFT_CHANGELOG), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_CHANGELOG, STR_NULL),
776  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GO_BASE_MUSIC_TEXTFILE + TFT_LICENSE), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_TEXTFILE_VIEW_LICENCE, STR_NULL),
777  EndContainer(),
778  EndContainer(),
779  EndContainer(),
780 };
781 
782 static WindowDesc _game_options_desc(
783  WDP_CENTER, "settings_game", 0, 0,
785  0,
786  _nested_game_options_widgets, lengthof(_nested_game_options_widgets)
787 );
788 
791 {
793  new GameOptionsWindow(&_game_options_desc);
794 }
795 
796 static int SETTING_HEIGHT = 11;
797 
806 
807  SEF_LAST_FIELD = 0x04,
808  SEF_FILTERED = 0x08,
809 };
810 
819 };
821 
822 
826  bool type_hides;
829 };
830 
833  byte flags;
834  byte level;
835 
836  BaseSettingEntry() : flags(0), level(0) {}
837  virtual ~BaseSettingEntry() {}
838 
839  virtual void Init(byte level = 0);
840  virtual void FoldAll() {}
841  virtual void UnFoldAll() {}
842  virtual void ResetAll() = 0;
843 
848  void SetLastField(bool last_field) { if (last_field) SETBITS(this->flags, SEF_LAST_FIELD); else CLRBITS(this->flags, SEF_LAST_FIELD); }
849 
850  virtual uint Length() const = 0;
851  virtual void GetFoldingState(bool &all_folded, bool &all_unfolded) const {}
852  virtual bool IsVisible(const BaseSettingEntry *item) const;
853  virtual BaseSettingEntry *FindEntry(uint row, uint *cur_row);
854  virtual uint GetMaxHelpHeight(int maxw) { return 0; }
855 
860  bool IsFiltered() const { return (this->flags & SEF_FILTERED) != 0; }
861 
862  virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible) = 0;
863 
864  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;
865 
866 protected:
867  virtual void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const = 0;
868 };
869 
872  const char *name;
874 
875  SettingEntry(const char *name);
876 
877  virtual void Init(byte level = 0);
878  virtual void ResetAll();
879  virtual uint Length() const;
880  virtual uint GetMaxHelpHeight(int maxw);
881  virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible);
882 
883  void SetButtons(byte new_val);
884 
889  inline StringID GetHelpText() const
890  {
891  return this->setting->str_help;
892  }
893 
894  void SetValueDParams(uint first_param, int32 value) const;
895 
896 protected:
897  virtual void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const;
898 
899 private:
901 };
902 
905  typedef std::vector<BaseSettingEntry*> EntryVector;
906  EntryVector entries;
907 
908  template<typename T>
909  T *Add(T *item)
910  {
911  this->entries.push_back(item);
912  return item;
913  }
914 
915  void Init(byte level = 0);
916  void ResetAll();
917  void FoldAll();
918  void UnFoldAll();
919 
920  uint Length() const;
921  void GetFoldingState(bool &all_folded, bool &all_unfolded) const;
922  bool IsVisible(const BaseSettingEntry *item) const;
923  BaseSettingEntry *FindEntry(uint row, uint *cur_row);
924  uint GetMaxHelpHeight(int maxw);
925 
926  bool UpdateFilterState(SettingFilter &filter, bool force_visible);
927 
928  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;
929 };
930 
934  bool folded;
935 
937 
938  virtual void Init(byte level = 0);
939  virtual void ResetAll();
940  virtual void FoldAll();
941  virtual void UnFoldAll();
942 
943  virtual uint Length() const;
944  virtual void GetFoldingState(bool &all_folded, bool &all_unfolded) const;
945  virtual bool IsVisible(const BaseSettingEntry *item) const;
946  virtual BaseSettingEntry *FindEntry(uint row, uint *cur_row);
947  virtual uint GetMaxHelpHeight(int maxw) { return SettingsContainer::GetMaxHelpHeight(maxw); }
948 
949  virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible);
950 
951  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;
952 
953 protected:
954  virtual void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const;
955 };
956 
957 /* == BaseSettingEntry methods == */
958 
963 void BaseSettingEntry::Init(byte level)
964 {
965  this->level = level;
966 }
967 
975 {
976  if (this->IsFiltered()) return false;
977  return this == item;
978 }
979 
986 BaseSettingEntry *BaseSettingEntry::FindEntry(uint row_num, uint *cur_row)
987 {
988  if (this->IsFiltered()) return nullptr;
989  if (row_num == *cur_row) return this;
990  (*cur_row)++;
991  return nullptr;
992 }
993 
1023 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
1024 {
1025  if (this->IsFiltered()) return cur_row;
1026  if (cur_row >= max_row) return cur_row;
1027 
1028  bool rtl = _current_text_dir == TD_RTL;
1029  int offset = (rtl ? -(int)_circle_size.width : _circle_size.width) / 2;
1031 
1032  int x = rtl ? right : left;
1033  if (cur_row >= first_row) {
1034  int colour = _colour_gradient[COLOUR_ORANGE][4];
1035  y += (cur_row - first_row) * SETTING_HEIGHT; // Compute correct y start position
1036 
1037  /* Draw vertical for parent nesting levels */
1038  for (uint lvl = 0; lvl < this->level; lvl++) {
1039  if (!HasBit(parent_last, lvl)) GfxDrawLine(x + offset, y, x + offset, y + SETTING_HEIGHT - 1, colour);
1040  x += level_width;
1041  }
1042  /* draw own |- prefix */
1043  int halfway_y = y + SETTING_HEIGHT / 2;
1044  int bottom_y = (flags & SEF_LAST_FIELD) ? halfway_y : y + SETTING_HEIGHT - 1;
1045  GfxDrawLine(x + offset, y, x + offset, bottom_y, colour);
1046  /* Small horizontal line from the last vertical line */
1047  GfxDrawLine(x + offset, halfway_y, x + level_width - WidgetDimensions::scaled.hsep_normal, halfway_y, colour);
1048  x += level_width;
1049 
1050  this->DrawSetting(settings_ptr, rtl ? left : x, rtl ? x : right, y, this == selected);
1051  }
1052  cur_row++;
1053 
1054  return cur_row;
1055 }
1056 
1057 /* == SettingEntry methods == */
1058 
1064 {
1065  this->name = name;
1066  this->setting = nullptr;
1067 }
1068 
1073 void SettingEntry::Init(byte level)
1074 {
1076  this->setting = GetSettingFromName(this->name)->AsIntSetting();
1077 }
1078 
1079 /* Sets the given setting entry to its default value */
1080 void SettingEntry::ResetAll()
1081 {
1082  SetSettingValue(this->setting, this->setting->def);
1083 }
1084 
1090 void SettingEntry::SetButtons(byte new_val)
1091 {
1092  assert((new_val & ~SEF_BUTTONS_MASK) == 0); // Should not touch any flags outside the buttons
1093  this->flags = (this->flags & ~SEF_BUTTONS_MASK) | new_val;
1094 }
1095 
1098 {
1099  return this->IsFiltered() ? 0 : 1;
1100 }
1101 
1108 {
1109  return GetStringHeight(this->GetHelpText(), maxw);
1110 }
1111 
1118 {
1119  /* There shall not be any restriction, i.e. all settings shall be visible. */
1120  if (mode == RM_ALL) return true;
1121 
1122  const IntSettingDesc *sd = this->setting;
1123 
1124  if (mode == RM_BASIC) return (this->setting->cat & SC_BASIC_LIST) != 0;
1125  if (mode == RM_ADVANCED) return (this->setting->cat & SC_ADVANCED_LIST) != 0;
1126 
1127  /* Read the current value. */
1128  const void *object = ResolveObject(&GetGameSettings(), sd);
1129  int64 current_value = sd->Read(object);
1130  int64 filter_value;
1131 
1132  if (mode == RM_CHANGED_AGAINST_DEFAULT) {
1133  /* This entry shall only be visible, if the value deviates from its default value. */
1134 
1135  /* Read the default value. */
1136  filter_value = sd->def;
1137  } else {
1138  assert(mode == RM_CHANGED_AGAINST_NEW);
1139  /* This entry shall only be visible, if the value deviates from
1140  * its value is used when starting a new game. */
1141 
1142  /* Make sure we're not comparing the new game settings against itself. */
1143  assert(&GetGameSettings() != &_settings_newgame);
1144 
1145  /* Read the new game's value. */
1146  filter_value = sd->Read(ResolveObject(&_settings_newgame, sd));
1147  }
1148 
1149  return current_value != filter_value;
1150 }
1151 
1158 bool SettingEntry::UpdateFilterState(SettingFilter &filter, bool force_visible)
1159 {
1160  CLRBITS(this->flags, SEF_FILTERED);
1161 
1162  bool visible = true;
1163 
1164  const IntSettingDesc *sd = this->setting;
1165  if (!force_visible && !filter.string.IsEmpty()) {
1166  /* Process the search text filter for this item. */
1167  filter.string.ResetState();
1168 
1169  SetDParam(0, STR_EMPTY);
1170  filter.string.AddLine(sd->str);
1171  filter.string.AddLine(this->GetHelpText());
1172 
1173  visible = filter.string.GetState();
1174  }
1175 
1176  if (visible) {
1177  if (filter.type != ST_ALL && sd->GetType() != filter.type) {
1178  filter.type_hides = true;
1179  visible = false;
1180  }
1181  if (!this->IsVisibleByRestrictionMode(filter.mode)) {
1182  while (filter.min_cat < RM_ALL && (filter.min_cat == filter.mode || !this->IsVisibleByRestrictionMode(filter.min_cat))) filter.min_cat++;
1183  visible = false;
1184  }
1185  }
1186 
1187  if (!visible) SETBITS(this->flags, SEF_FILTERED);
1188  return visible;
1189 }
1190 
1191 static const void *ResolveObject(const GameSettings *settings_ptr, const IntSettingDesc *sd)
1192 {
1193  if ((sd->flags & SF_PER_COMPANY) != 0) {
1194  if (Company::IsValidID(_local_company) && _game_mode != GM_MENU) {
1195  return &Company::Get(_local_company)->settings;
1196  }
1197  return &_settings_client.company;
1198  }
1199  return settings_ptr;
1200 }
1201 
1207 void SettingEntry::SetValueDParams(uint first_param, int32 value) const
1208 {
1209  if (this->setting->IsBoolSetting()) {
1210  SetDParam(first_param++, value != 0 ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
1211  } else {
1212  if ((this->setting->flags & SF_GUI_DROPDOWN) != 0) {
1213  SetDParam(first_param++, this->setting->str_val - this->setting->min + value);
1214  } else if ((this->setting->flags & SF_GUI_NEGATIVE_IS_SPECIAL) != 0) {
1215  SetDParam(first_param++, this->setting->str_val + ((value >= 0) ? 1 : 0));
1216  value = abs(value);
1217  } else {
1218  SetDParam(first_param++, this->setting->str_val + ((value == 0 && (this->setting->flags & SF_GUI_0_IS_SPECIAL) != 0) ? 1 : 0));
1219  }
1220  SetDParam(first_param++, value);
1221  }
1222 }
1223 
1232 void SettingEntry::DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const
1233 {
1234  const IntSettingDesc *sd = this->setting;
1235  int state = this->flags & SEF_BUTTONS_MASK;
1236 
1237  bool rtl = _current_text_dir == TD_RTL;
1238  uint buttons_left = rtl ? right + 1 - SETTING_BUTTON_WIDTH : left;
1239  uint text_left = left + (rtl ? 0 : SETTING_BUTTON_WIDTH + WidgetDimensions::scaled.hsep_wide);
1240  uint text_right = right - (rtl ? SETTING_BUTTON_WIDTH + WidgetDimensions::scaled.hsep_wide : 0);
1241  uint button_y = y + (SETTING_HEIGHT - SETTING_BUTTON_HEIGHT) / 2;
1242 
1243  /* We do not allow changes of some items when we are a client in a networkgame */
1244  bool editable = sd->IsEditable();
1245 
1246  SetDParam(0, highlight ? STR_ORANGE_STRING1_WHITE : STR_ORANGE_STRING1_LTBLUE);
1247  int32 value = sd->Read(ResolveObject(settings_ptr, sd));
1248  if (sd->IsBoolSetting()) {
1249  /* Draw checkbox for boolean-value either on/off */
1250  DrawBoolButton(buttons_left, button_y, value != 0, editable);
1251  } else if ((sd->flags & SF_GUI_DROPDOWN) != 0) {
1252  /* Draw [v] button for settings of an enum-type */
1253  DrawDropDownButton(buttons_left, button_y, COLOUR_YELLOW, state != 0, editable);
1254  } else {
1255  /* Draw [<][>] boxes for settings of an integer-type */
1256  DrawArrowButtons(buttons_left, button_y, COLOUR_YELLOW, state,
1257  editable && value != (sd->flags & SF_GUI_0_IS_SPECIAL ? 0 : sd->min), editable && (uint32)value != sd->max);
1258  }
1259  this->SetValueDParams(1, value);
1260  DrawString(text_left, text_right, y + (SETTING_HEIGHT - FONT_HEIGHT_NORMAL) / 2, sd->str, highlight ? TC_WHITE : TC_LIGHT_BLUE);
1261 }
1262 
1263 /* == SettingsContainer methods == */
1264 
1269 void SettingsContainer::Init(byte level)
1270 {
1271  for (EntryVector::iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1272  (*it)->Init(level);
1273  }
1274 }
1275 
1278 {
1279  for (auto settings_entry : this->entries) {
1280  settings_entry->ResetAll();
1281  }
1282 }
1283 
1286 {
1287  for (EntryVector::iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1288  (*it)->FoldAll();
1289  }
1290 }
1291 
1294 {
1295  for (EntryVector::iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1296  (*it)->UnFoldAll();
1297  }
1298 }
1299 
1305 void SettingsContainer::GetFoldingState(bool &all_folded, bool &all_unfolded) const
1306 {
1307  for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1308  (*it)->GetFoldingState(all_folded, all_unfolded);
1309  }
1310 }
1311 
1318 bool SettingsContainer::UpdateFilterState(SettingFilter &filter, bool force_visible)
1319 {
1320  bool visible = false;
1321  bool first_visible = true;
1322  for (EntryVector::reverse_iterator it = this->entries.rbegin(); it != this->entries.rend(); ++it) {
1323  visible |= (*it)->UpdateFilterState(filter, force_visible);
1324  (*it)->SetLastField(first_visible);
1325  if (visible && first_visible) first_visible = false;
1326  }
1327  return visible;
1328 }
1329 
1330 
1338 {
1339  for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1340  if ((*it)->IsVisible(item)) return true;
1341  }
1342  return false;
1343 }
1344 
1347 {
1348  uint length = 0;
1349  for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1350  length += (*it)->Length();
1351  }
1352  return length;
1353 }
1354 
1361 BaseSettingEntry *SettingsContainer::FindEntry(uint row_num, uint *cur_row)
1362 {
1363  BaseSettingEntry *pe = nullptr;
1364  for (EntryVector::iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1365  pe = (*it)->FindEntry(row_num, cur_row);
1366  if (pe != nullptr) {
1367  break;
1368  }
1369  }
1370  return pe;
1371 }
1372 
1379 {
1380  uint biggest = 0;
1381  for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1382  biggest = std::max(biggest, (*it)->GetMaxHelpHeight(maxw));
1383  }
1384  return biggest;
1385 }
1386 
1387 
1402 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
1403 {
1404  for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1405  cur_row = (*it)->Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1406  if (cur_row >= max_row) {
1407  break;
1408  }
1409  }
1410  return cur_row;
1411 }
1412 
1413 /* == SettingsPage methods == */
1414 
1420 {
1421  this->title = title;
1422  this->folded = true;
1423 }
1424 
1429 void SettingsPage::Init(byte level)
1430 {
1433 }
1434 
1437 {
1438  for (auto settings_entry : this->entries) {
1439  settings_entry->ResetAll();
1440  }
1441 }
1442 
1445 {
1446  if (this->IsFiltered()) return;
1447  this->folded = true;
1448 
1450 }
1451 
1454 {
1455  if (this->IsFiltered()) return;
1456  this->folded = false;
1457 
1459 }
1460 
1466 void SettingsPage::GetFoldingState(bool &all_folded, bool &all_unfolded) const
1467 {
1468  if (this->IsFiltered()) return;
1469 
1470  if (this->folded) {
1471  all_unfolded = false;
1472  } else {
1473  all_folded = false;
1474  }
1475 
1476  SettingsContainer::GetFoldingState(all_folded, all_unfolded);
1477 }
1478 
1485 bool SettingsPage::UpdateFilterState(SettingFilter &filter, bool force_visible)
1486 {
1487  if (!force_visible && !filter.string.IsEmpty()) {
1488  filter.string.ResetState();
1489  filter.string.AddLine(this->title);
1490  force_visible = filter.string.GetState();
1491  }
1492 
1493  bool visible = SettingsContainer::UpdateFilterState(filter, force_visible);
1494  if (visible) {
1495  CLRBITS(this->flags, SEF_FILTERED);
1496  } else {
1497  SETBITS(this->flags, SEF_FILTERED);
1498  }
1499  return visible;
1500 }
1501 
1509 {
1510  if (this->IsFiltered()) return false;
1511  if (this == item) return true;
1512  if (this->folded) return false;
1513 
1514  return SettingsContainer::IsVisible(item);
1515 }
1516 
1519 {
1520  if (this->IsFiltered()) return 0;
1521  if (this->folded) return 1; // Only displaying the title
1522 
1523  return 1 + SettingsContainer::Length();
1524 }
1525 
1532 BaseSettingEntry *SettingsPage::FindEntry(uint row_num, uint *cur_row)
1533 {
1534  if (this->IsFiltered()) return nullptr;
1535  if (row_num == *cur_row) return this;
1536  (*cur_row)++;
1537  if (this->folded) return nullptr;
1538 
1539  return SettingsContainer::FindEntry(row_num, cur_row);
1540 }
1541 
1556 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
1557 {
1558  if (this->IsFiltered()) return cur_row;
1559  if (cur_row >= max_row) return cur_row;
1560 
1561  cur_row = BaseSettingEntry::Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1562 
1563  if (!this->folded) {
1564  if (this->flags & SEF_LAST_FIELD) {
1565  assert(this->level < 8 * sizeof(parent_last));
1566  SetBit(parent_last, this->level); // Add own last-field state
1567  }
1568 
1569  cur_row = SettingsContainer::Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1570  }
1571 
1572  return cur_row;
1573 }
1574 
1583 void SettingsPage::DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const
1584 {
1585  bool rtl = _current_text_dir == TD_RTL;
1586  DrawSprite((this->folded ? SPR_CIRCLE_FOLDED : SPR_CIRCLE_UNFOLDED), PAL_NONE, rtl ? right - _circle_size.width : left, y + (SETTING_HEIGHT - _circle_size.height) / 2);
1587  DrawString(rtl ? left : left + _circle_size.width + WidgetDimensions::scaled.hsep_normal, rtl ? right - _circle_size.width - WidgetDimensions::scaled.hsep_normal : right, y + (SETTING_HEIGHT - FONT_HEIGHT_NORMAL) / 2, this->title);
1588 }
1589 
1592 {
1593  static SettingsContainer *main = nullptr;
1594 
1595  if (main == nullptr)
1596  {
1597  /* Build up the dynamic settings-array only once per OpenTTD session */
1598  main = new SettingsContainer();
1599 
1600  SettingsPage *localisation = main->Add(new SettingsPage(STR_CONFIG_SETTING_LOCALISATION));
1601  {
1602  localisation->Add(new SettingEntry("locale.units_velocity"));
1603  localisation->Add(new SettingEntry("locale.units_power"));
1604  localisation->Add(new SettingEntry("locale.units_weight"));
1605  localisation->Add(new SettingEntry("locale.units_volume"));
1606  localisation->Add(new SettingEntry("locale.units_force"));
1607  localisation->Add(new SettingEntry("locale.units_height"));
1608  localisation->Add(new SettingEntry("gui.date_format_in_default_names"));
1609  }
1610 
1611  SettingsPage *graphics = main->Add(new SettingsPage(STR_CONFIG_SETTING_GRAPHICS));
1612  {
1613  graphics->Add(new SettingEntry("gui.zoom_min"));
1614  graphics->Add(new SettingEntry("gui.zoom_max"));
1615  graphics->Add(new SettingEntry("gui.sprite_zoom_min"));
1616  graphics->Add(new SettingEntry("gui.smallmap_land_colour"));
1617  graphics->Add(new SettingEntry("gui.linkgraph_colours"));
1618  graphics->Add(new SettingEntry("gui.graph_line_thickness"));
1619  }
1620 
1621  SettingsPage *sound = main->Add(new SettingsPage(STR_CONFIG_SETTING_SOUND));
1622  {
1623  sound->Add(new SettingEntry("sound.click_beep"));
1624  sound->Add(new SettingEntry("sound.confirm"));
1625  sound->Add(new SettingEntry("sound.news_ticker"));
1626  sound->Add(new SettingEntry("sound.news_full"));
1627  sound->Add(new SettingEntry("sound.new_year"));
1628  sound->Add(new SettingEntry("sound.disaster"));
1629  sound->Add(new SettingEntry("sound.vehicle"));
1630  sound->Add(new SettingEntry("sound.ambient"));
1631  }
1632 
1633  SettingsPage *interface = main->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE));
1634  {
1635  SettingsPage *general = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_GENERAL));
1636  {
1637  general->Add(new SettingEntry("gui.osk_activation"));
1638  general->Add(new SettingEntry("gui.hover_delay_ms"));
1639  general->Add(new SettingEntry("gui.errmsg_duration"));
1640  general->Add(new SettingEntry("gui.window_snap_radius"));
1641  general->Add(new SettingEntry("gui.window_soft_limit"));
1642  general->Add(new SettingEntry("gui.right_mouse_wnd_close"));
1643  }
1644 
1645  SettingsPage *viewports = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_VIEWPORTS));
1646  {
1647  viewports->Add(new SettingEntry("gui.auto_scrolling"));
1648  viewports->Add(new SettingEntry("gui.scroll_mode"));
1649  viewports->Add(new SettingEntry("gui.smooth_scroll"));
1650  /* While the horizontal scrollwheel scrolling is written as general code, only
1651  * the cocoa (OSX) driver generates input for it.
1652  * Since it's also able to completely disable the scrollwheel will we display it on all platforms anyway */
1653  viewports->Add(new SettingEntry("gui.scrollwheel_scrolling"));
1654  viewports->Add(new SettingEntry("gui.scrollwheel_multiplier"));
1655 #ifdef __APPLE__
1656  /* We might need to emulate a right mouse button on mac */
1657  viewports->Add(new SettingEntry("gui.right_mouse_btn_emulation"));
1658 #endif
1659  viewports->Add(new SettingEntry("gui.population_in_label"));
1660  viewports->Add(new SettingEntry("gui.liveries"));
1661  viewports->Add(new SettingEntry("construction.train_signal_side"));
1662  viewports->Add(new SettingEntry("gui.measure_tooltip"));
1663  viewports->Add(new SettingEntry("gui.loading_indicators"));
1664  viewports->Add(new SettingEntry("gui.show_track_reservation"));
1665  }
1666 
1667  SettingsPage *construction = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_CONSTRUCTION));
1668  {
1669  construction->Add(new SettingEntry("gui.link_terraform_toolbar"));
1670  construction->Add(new SettingEntry("gui.persistent_buildingtools"));
1671  construction->Add(new SettingEntry("gui.quick_goto"));
1672  construction->Add(new SettingEntry("gui.default_rail_type"));
1673  }
1674 
1675  interface->Add(new SettingEntry("gui.fast_forward_speed_limit"));
1676  interface->Add(new SettingEntry("gui.autosave"));
1677  interface->Add(new SettingEntry("gui.toolbar_pos"));
1678  interface->Add(new SettingEntry("gui.statusbar_pos"));
1679  interface->Add(new SettingEntry("gui.prefer_teamchat"));
1680  interface->Add(new SettingEntry("gui.advanced_vehicle_list"));
1681  interface->Add(new SettingEntry("gui.timetable_in_ticks"));
1682  interface->Add(new SettingEntry("gui.timetable_arrival_departure"));
1683  interface->Add(new SettingEntry("gui.show_newgrf_name"));
1684  interface->Add(new SettingEntry("gui.show_cargo_in_vehicle_lists"));
1685  }
1686 
1687  SettingsPage *advisors = main->Add(new SettingsPage(STR_CONFIG_SETTING_ADVISORS));
1688  {
1689  advisors->Add(new SettingEntry("gui.coloured_news_year"));
1690  advisors->Add(new SettingEntry("news_display.general"));
1691  advisors->Add(new SettingEntry("news_display.new_vehicles"));
1692  advisors->Add(new SettingEntry("news_display.accident"));
1693  advisors->Add(new SettingEntry("news_display.accident_other"));
1694  advisors->Add(new SettingEntry("news_display.company_info"));
1695  advisors->Add(new SettingEntry("news_display.acceptance"));
1696  advisors->Add(new SettingEntry("news_display.arrival_player"));
1697  advisors->Add(new SettingEntry("news_display.arrival_other"));
1698  advisors->Add(new SettingEntry("news_display.advice"));
1699  advisors->Add(new SettingEntry("gui.order_review_system"));
1700  advisors->Add(new SettingEntry("gui.vehicle_income_warn"));
1701  advisors->Add(new SettingEntry("gui.lost_vehicle_warn"));
1702  advisors->Add(new SettingEntry("gui.show_finances"));
1703  advisors->Add(new SettingEntry("news_display.economy"));
1704  advisors->Add(new SettingEntry("news_display.subsidies"));
1705  advisors->Add(new SettingEntry("news_display.open"));
1706  advisors->Add(new SettingEntry("news_display.close"));
1707  advisors->Add(new SettingEntry("news_display.production_player"));
1708  advisors->Add(new SettingEntry("news_display.production_other"));
1709  advisors->Add(new SettingEntry("news_display.production_nobody"));
1710  }
1711 
1712  SettingsPage *company = main->Add(new SettingsPage(STR_CONFIG_SETTING_COMPANY));
1713  {
1714  company->Add(new SettingEntry("gui.semaphore_build_before"));
1715  company->Add(new SettingEntry("gui.cycle_signal_types"));
1716  company->Add(new SettingEntry("gui.signal_gui_mode"));
1717  company->Add(new SettingEntry("gui.drag_signals_fixed_distance"));
1718  company->Add(new SettingEntry("gui.auto_remove_signals"));
1719  company->Add(new SettingEntry("gui.new_nonstop"));
1720  company->Add(new SettingEntry("gui.stop_location"));
1721  company->Add(new SettingEntry("gui.starting_colour"));
1722  company->Add(new SettingEntry("company.engine_renew"));
1723  company->Add(new SettingEntry("company.engine_renew_months"));
1724  company->Add(new SettingEntry("company.engine_renew_money"));
1725  company->Add(new SettingEntry("vehicle.servint_ispercent"));
1726  company->Add(new SettingEntry("vehicle.servint_trains"));
1727  company->Add(new SettingEntry("vehicle.servint_roadveh"));
1728  company->Add(new SettingEntry("vehicle.servint_ships"));
1729  company->Add(new SettingEntry("vehicle.servint_aircraft"));
1730  }
1731 
1732  SettingsPage *accounting = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCOUNTING));
1733  {
1734  accounting->Add(new SettingEntry("economy.inflation"));
1735  accounting->Add(new SettingEntry("difficulty.initial_interest"));
1736  accounting->Add(new SettingEntry("difficulty.max_loan"));
1737  accounting->Add(new SettingEntry("difficulty.subsidy_multiplier"));
1738  accounting->Add(new SettingEntry("difficulty.subsidy_duration"));
1739  accounting->Add(new SettingEntry("economy.feeder_payment_share"));
1740  accounting->Add(new SettingEntry("economy.infrastructure_maintenance"));
1741  accounting->Add(new SettingEntry("difficulty.vehicle_costs"));
1742  accounting->Add(new SettingEntry("difficulty.construction_cost"));
1743  }
1744 
1745  SettingsPage *vehicles = main->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES));
1746  {
1747  SettingsPage *physics = vehicles->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES_PHYSICS));
1748  {
1749  physics->Add(new SettingEntry("vehicle.train_acceleration_model"));
1750  physics->Add(new SettingEntry("vehicle.train_slope_steepness"));
1751  physics->Add(new SettingEntry("vehicle.wagon_speed_limits"));
1752  physics->Add(new SettingEntry("vehicle.freight_trains"));
1753  physics->Add(new SettingEntry("vehicle.roadveh_acceleration_model"));
1754  physics->Add(new SettingEntry("vehicle.roadveh_slope_steepness"));
1755  physics->Add(new SettingEntry("vehicle.smoke_amount"));
1756  physics->Add(new SettingEntry("vehicle.plane_speed"));
1757  }
1758 
1759  SettingsPage *routing = vehicles->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES_ROUTING));
1760  {
1761  routing->Add(new SettingEntry("pf.pathfinder_for_trains"));
1762  routing->Add(new SettingEntry("difficulty.line_reverse_mode"));
1763  routing->Add(new SettingEntry("pf.reverse_at_signals"));
1764  routing->Add(new SettingEntry("pf.forbid_90_deg"));
1765  routing->Add(new SettingEntry("pf.pathfinder_for_roadvehs"));
1766  routing->Add(new SettingEntry("pf.pathfinder_for_ships"));
1767  }
1768 
1769  vehicles->Add(new SettingEntry("order.no_servicing_if_no_breakdowns"));
1770  vehicles->Add(new SettingEntry("order.serviceathelipad"));
1771  }
1772 
1773  SettingsPage *limitations = main->Add(new SettingsPage(STR_CONFIG_SETTING_LIMITATIONS));
1774  {
1775  limitations->Add(new SettingEntry("construction.command_pause_level"));
1776  limitations->Add(new SettingEntry("construction.autoslope"));
1777  limitations->Add(new SettingEntry("construction.extra_dynamite"));
1778  limitations->Add(new SettingEntry("construction.map_height_limit"));
1779  limitations->Add(new SettingEntry("construction.max_bridge_length"));
1780  limitations->Add(new SettingEntry("construction.max_bridge_height"));
1781  limitations->Add(new SettingEntry("construction.max_tunnel_length"));
1782  limitations->Add(new SettingEntry("station.never_expire_airports"));
1783  limitations->Add(new SettingEntry("vehicle.never_expire_vehicles"));
1784  limitations->Add(new SettingEntry("vehicle.max_trains"));
1785  limitations->Add(new SettingEntry("vehicle.max_roadveh"));
1786  limitations->Add(new SettingEntry("vehicle.max_aircraft"));
1787  limitations->Add(new SettingEntry("vehicle.max_ships"));
1788  limitations->Add(new SettingEntry("vehicle.max_train_length"));
1789  limitations->Add(new SettingEntry("station.station_spread"));
1790  limitations->Add(new SettingEntry("station.distant_join_stations"));
1791  limitations->Add(new SettingEntry("construction.road_stop_on_town_road"));
1792  limitations->Add(new SettingEntry("construction.road_stop_on_competitor_road"));
1793  limitations->Add(new SettingEntry("vehicle.disable_elrails"));
1794  }
1795 
1796  SettingsPage *disasters = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCIDENTS));
1797  {
1798  disasters->Add(new SettingEntry("difficulty.disasters"));
1799  disasters->Add(new SettingEntry("difficulty.economy"));
1800  disasters->Add(new SettingEntry("difficulty.vehicle_breakdowns"));
1801  disasters->Add(new SettingEntry("vehicle.plane_crashes"));
1802  }
1803 
1804  SettingsPage *genworld = main->Add(new SettingsPage(STR_CONFIG_SETTING_GENWORLD));
1805  {
1806  genworld->Add(new SettingEntry("game_creation.landscape"));
1807  genworld->Add(new SettingEntry("game_creation.land_generator"));
1808  genworld->Add(new SettingEntry("difficulty.terrain_type"));
1809  genworld->Add(new SettingEntry("game_creation.tgen_smoothness"));
1810  genworld->Add(new SettingEntry("game_creation.variety"));
1811  genworld->Add(new SettingEntry("game_creation.snow_coverage"));
1812  genworld->Add(new SettingEntry("game_creation.snow_line_height"));
1813  genworld->Add(new SettingEntry("game_creation.desert_coverage"));
1814  genworld->Add(new SettingEntry("game_creation.amount_of_rivers"));
1815  genworld->Add(new SettingEntry("game_creation.tree_placer"));
1816  genworld->Add(new SettingEntry("vehicle.road_side"));
1817  genworld->Add(new SettingEntry("economy.larger_towns"));
1818  genworld->Add(new SettingEntry("economy.initial_city_size"));
1819  genworld->Add(new SettingEntry("economy.town_layout"));
1820  genworld->Add(new SettingEntry("difficulty.industry_density"));
1821  genworld->Add(new SettingEntry("gui.pause_on_newgame"));
1822  genworld->Add(new SettingEntry("game_creation.ending_year"));
1823  }
1824 
1825  SettingsPage *environment = main->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT));
1826  {
1827  SettingsPage *authorities = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_AUTHORITIES));
1828  {
1829  authorities->Add(new SettingEntry("difficulty.town_council_tolerance"));
1830  authorities->Add(new SettingEntry("economy.bribe"));
1831  authorities->Add(new SettingEntry("economy.exclusive_rights"));
1832  authorities->Add(new SettingEntry("economy.fund_roads"));
1833  authorities->Add(new SettingEntry("economy.fund_buildings"));
1834  authorities->Add(new SettingEntry("economy.station_noise_level"));
1835  }
1836 
1837  SettingsPage *towns = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_TOWNS));
1838  {
1839  towns->Add(new SettingEntry("economy.town_growth_rate"));
1840  towns->Add(new SettingEntry("economy.allow_town_roads"));
1841  towns->Add(new SettingEntry("economy.allow_town_level_crossings"));
1842  towns->Add(new SettingEntry("economy.found_town"));
1843  towns->Add(new SettingEntry("economy.town_cargogen_mode"));
1844  }
1845 
1846  SettingsPage *industries = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_INDUSTRIES));
1847  {
1848  industries->Add(new SettingEntry("construction.raw_industry_construction"));
1849  industries->Add(new SettingEntry("construction.industry_platform"));
1850  industries->Add(new SettingEntry("economy.multiple_industry_per_town"));
1851  industries->Add(new SettingEntry("game_creation.oil_refinery_limit"));
1852  industries->Add(new SettingEntry("economy.type"));
1853  industries->Add(new SettingEntry("station.serve_neutral_industries"));
1854  }
1855 
1856  SettingsPage *cdist = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST));
1857  {
1858  cdist->Add(new SettingEntry("linkgraph.recalc_time"));
1859  cdist->Add(new SettingEntry("linkgraph.recalc_interval"));
1860  cdist->Add(new SettingEntry("linkgraph.distribution_pax"));
1861  cdist->Add(new SettingEntry("linkgraph.distribution_mail"));
1862  cdist->Add(new SettingEntry("linkgraph.distribution_armoured"));
1863  cdist->Add(new SettingEntry("linkgraph.distribution_default"));
1864  cdist->Add(new SettingEntry("linkgraph.accuracy"));
1865  cdist->Add(new SettingEntry("linkgraph.demand_distance"));
1866  cdist->Add(new SettingEntry("linkgraph.demand_size"));
1867  cdist->Add(new SettingEntry("linkgraph.short_path_saturation"));
1868  }
1869 
1870  environment->Add(new SettingEntry("station.modified_catchment"));
1871  environment->Add(new SettingEntry("construction.extra_tree_placement"));
1872  }
1873 
1874  SettingsPage *ai = main->Add(new SettingsPage(STR_CONFIG_SETTING_AI));
1875  {
1876  SettingsPage *npc = ai->Add(new SettingsPage(STR_CONFIG_SETTING_AI_NPC));
1877  {
1878  npc->Add(new SettingEntry("script.settings_profile"));
1879  npc->Add(new SettingEntry("script.script_max_opcode_till_suspend"));
1880  npc->Add(new SettingEntry("script.script_max_memory_megabytes"));
1881  npc->Add(new SettingEntry("difficulty.competitor_speed"));
1882  npc->Add(new SettingEntry("ai.ai_in_multiplayer"));
1883  npc->Add(new SettingEntry("ai.ai_disable_veh_train"));
1884  npc->Add(new SettingEntry("ai.ai_disable_veh_roadveh"));
1885  npc->Add(new SettingEntry("ai.ai_disable_veh_aircraft"));
1886  npc->Add(new SettingEntry("ai.ai_disable_veh_ship"));
1887  }
1888 
1889  ai->Add(new SettingEntry("economy.give_money"));
1890  ai->Add(new SettingEntry("economy.allow_shares"));
1891  ai->Add(new SettingEntry("economy.min_years_for_shares"));
1892  }
1893 
1894  SettingsPage *network = main->Add(new SettingsPage(STR_CONFIG_SETTING_NETWORK));
1895  {
1896  network->Add(new SettingEntry("network.use_relay_service"));
1897  }
1898 
1899  main->Init();
1900  }
1901  return *main;
1902 }
1903 
1904 static const StringID _game_settings_restrict_dropdown[] = {
1905  STR_CONFIG_SETTING_RESTRICT_BASIC, // RM_BASIC
1906  STR_CONFIG_SETTING_RESTRICT_ADVANCED, // RM_ADVANCED
1907  STR_CONFIG_SETTING_RESTRICT_ALL, // RM_ALL
1908  STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_DEFAULT, // RM_CHANGED_AGAINST_DEFAULT
1909  STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_NEW, // RM_CHANGED_AGAINST_NEW
1910 };
1911 static_assert(lengthof(_game_settings_restrict_dropdown) == RM_END);
1912 
1919 };
1920 
1926 static void ResetAllSettingsConfirmationCallback(Window *w, bool confirmed)
1927 {
1928  if (confirmed) {
1931  w->InvalidateData();
1932  }
1933 }
1934 
1938 
1944 
1950 
1951  Scrollbar *vscroll;
1952 
1954  {
1955  this->warn_missing = WHR_NONE;
1956  this->warn_lines = 0;
1958  this->filter.min_cat = RM_ALL;
1959  this->filter.type = ST_ALL;
1960  this->filter.type_hides = false;
1961  this->settings_ptr = &GetGameSettings();
1962 
1963  GetSettingsTree().FoldAll(); // Close all sub-pages
1964 
1965  this->valuewindow_entry = nullptr; // No setting entry for which a entry window is opened
1966  this->clicked_entry = nullptr; // No numeric setting buttons are depressed
1967  this->last_clicked = nullptr;
1968  this->valuedropdown_entry = nullptr;
1969  this->closing_dropdown = false;
1970  this->manually_changed_folding = false;
1971 
1972  this->CreateNestedTree();
1973  this->vscroll = this->GetScrollbar(WID_GS_SCROLLBAR);
1975 
1976  this->querystrings[WID_GS_FILTER] = &this->filter_editbox;
1977  this->filter_editbox.cancel_button = QueryString::ACTION_CLEAR;
1979 
1980  this->InvalidateData();
1981  }
1982 
1983  void OnInit() override
1984  {
1985  _circle_size = maxdim(GetSpriteSize(SPR_CIRCLE_FOLDED), GetSpriteSize(SPR_CIRCLE_UNFOLDED));
1986  }
1987 
1988  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1989  {
1990  switch (widget) {
1991  case WID_GS_OPTIONSPANEL:
1992  resize->height = SETTING_HEIGHT = std::max({(int)_circle_size.height, SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL}) + WidgetDimensions::scaled.vsep_normal;
1993  resize->width = 1;
1994 
1995  size->height = 5 * resize->height + WidgetDimensions::scaled.framerect.Vertical();
1996  break;
1997 
1998  case WID_GS_HELP_TEXT: {
1999  static const StringID setting_types[] = {
2000  STR_CONFIG_SETTING_TYPE_CLIENT,
2001  STR_CONFIG_SETTING_TYPE_COMPANY_MENU, STR_CONFIG_SETTING_TYPE_COMPANY_INGAME,
2002  STR_CONFIG_SETTING_TYPE_GAME_MENU, STR_CONFIG_SETTING_TYPE_GAME_INGAME,
2003  };
2004  for (uint i = 0; i < lengthof(setting_types); i++) {
2005  SetDParam(0, setting_types[i]);
2006  size->width = std::max(size->width, GetStringBoundingBox(STR_CONFIG_SETTING_TYPE).width + padding.width);
2007  }
2009  std::max(size->height, GetSettingsTree().GetMaxHelpHeight(size->width));
2010  break;
2011  }
2012 
2014  case WID_GS_RESTRICT_TYPE:
2015  size->width = std::max(GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_CATEGORY).width, GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_TYPE).width);
2016  break;
2017 
2018  default:
2019  break;
2020  }
2021  }
2022 
2023  void OnPaint() override
2024  {
2025  if (this->closing_dropdown) {
2026  this->closing_dropdown = false;
2027  assert(this->valuedropdown_entry != nullptr);
2028  this->valuedropdown_entry->SetButtons(0);
2029  this->valuedropdown_entry = nullptr;
2030  }
2031 
2032  /* Reserve the correct number of lines for the 'some search results are hidden' notice in the central settings display panel. */
2033  const Rect panel = this->GetWidget<NWidgetBase>(WID_GS_OPTIONSPANEL)->GetCurrentRect().Shrink(WidgetDimensions::scaled.frametext);
2034  StringID warn_str = STR_CONFIG_SETTING_CATEGORY_HIDES - 1 + this->warn_missing;
2035  int new_warn_lines;
2036  if (this->warn_missing == WHR_NONE) {
2037  new_warn_lines = 0;
2038  } else {
2039  SetDParam(0, _game_settings_restrict_dropdown[this->filter.min_cat]);
2040  new_warn_lines = GetStringLineCount(warn_str, panel.Width());
2041  }
2042  if (this->warn_lines != new_warn_lines) {
2043  this->vscroll->SetCount(this->vscroll->GetCount() - this->warn_lines + new_warn_lines);
2044  this->warn_lines = new_warn_lines;
2045  }
2046 
2047  this->DrawWidgets();
2048 
2049  /* Draw the 'some search results are hidden' notice. */
2050  if (this->warn_missing != WHR_NONE) {
2051  SetDParam(0, _game_settings_restrict_dropdown[this->filter.min_cat]);
2052  DrawStringMultiLine(panel.WithHeight(this->warn_lines * FONT_HEIGHT_NORMAL), warn_str, TC_FROMSTRING, SA_CENTER);
2053  }
2054  }
2055 
2056  void SetStringParameters(int widget) const override
2057  {
2058  switch (widget) {
2060  SetDParam(0, _game_settings_restrict_dropdown[this->filter.mode]);
2061  break;
2062 
2063  case WID_GS_TYPE_DROPDOWN:
2064  switch (this->filter.type) {
2065  case ST_GAME: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME); break;
2066  case ST_COMPANY: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME); break;
2067  case ST_CLIENT: SetDParam(0, STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT); break;
2068  default: SetDParam(0, STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL); break;
2069  }
2070  break;
2071  }
2072  }
2073 
2074  DropDownList BuildDropDownList(int widget) const
2075  {
2076  DropDownList list;
2077  switch (widget) {
2079  for (int mode = 0; mode != RM_END; mode++) {
2080  /* If we are in adv. settings screen for the new game's settings,
2081  * we don't want to allow comparing with new game's settings. */
2082  bool disabled = mode == RM_CHANGED_AGAINST_NEW && settings_ptr == &_settings_newgame;
2083 
2084  list.emplace_back(new DropDownListStringItem(_game_settings_restrict_dropdown[mode], mode, disabled));
2085  }
2086  break;
2087 
2088  case WID_GS_TYPE_DROPDOWN:
2089  list.emplace_back(new DropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL, ST_ALL, false));
2090  list.emplace_back(new DropDownListStringItem(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME, ST_GAME, false));
2091  list.emplace_back(new DropDownListStringItem(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME, ST_COMPANY, false));
2092  list.emplace_back(new DropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT, ST_CLIENT, false));
2093  break;
2094  }
2095  return list;
2096  }
2097 
2098  void DrawWidget(const Rect &r, int widget) const override
2099  {
2100  switch (widget) {
2101  case WID_GS_OPTIONSPANEL: {
2102  Rect tr = r.Shrink(WidgetDimensions::scaled.frametext, WidgetDimensions::scaled.framerect);
2103  tr.top += this->warn_lines * SETTING_HEIGHT;
2104  uint last_row = this->vscroll->GetPosition() + this->vscroll->GetCapacity() - this->warn_lines;
2105  int next_row = GetSettingsTree().Draw(settings_ptr, tr.left, tr.right, tr.top,
2106  this->vscroll->GetPosition(), last_row, this->last_clicked);
2107  if (next_row == 0) DrawString(tr, STR_CONFIG_SETTINGS_NONE);
2108  break;
2109  }
2110 
2111  case WID_GS_HELP_TEXT:
2112  if (this->last_clicked != nullptr) {
2113  const IntSettingDesc *sd = this->last_clicked->setting;
2114 
2115  Rect tr = r;
2116  switch (sd->GetType()) {
2117  case ST_COMPANY: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_COMPANY_INGAME); break;
2118  case ST_CLIENT: SetDParam(0, STR_CONFIG_SETTING_TYPE_CLIENT); break;
2119  case ST_GAME: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_GAME_MENU : STR_CONFIG_SETTING_TYPE_GAME_INGAME); break;
2120  default: NOT_REACHED();
2121  }
2122  DrawString(tr, STR_CONFIG_SETTING_TYPE);
2123  tr.top += FONT_HEIGHT_NORMAL;
2124 
2125  this->last_clicked->SetValueDParams(0, sd->def);
2126  DrawString(tr, STR_CONFIG_SETTING_DEFAULT_VALUE);
2128 
2129  DrawStringMultiLine(tr, this->last_clicked->GetHelpText(), TC_WHITE);
2130  }
2131  break;
2132 
2133  default:
2134  break;
2135  }
2136  }
2137 
2143  {
2144  if (this->last_clicked != pe) this->SetDirty();
2145  this->last_clicked = pe;
2146  }
2147 
2148  void OnClick(Point pt, int widget, int click_count) override
2149  {
2150  switch (widget) {
2151  case WID_GS_EXPAND_ALL:
2152  this->manually_changed_folding = true;
2154  this->InvalidateData();
2155  break;
2156 
2157  case WID_GS_COLLAPSE_ALL:
2158  this->manually_changed_folding = true;
2160  this->InvalidateData();
2161  break;
2162 
2163  case WID_GS_RESET_ALL:
2164  ShowQuery(
2165  STR_CONFIG_SETTING_RESET_ALL_CONFIRMATION_DIALOG_CAPTION,
2166  STR_CONFIG_SETTING_RESET_ALL_CONFIRMATION_DIALOG_TEXT,
2167  this,
2169  );
2170  break;
2171 
2172  case WID_GS_RESTRICT_DROPDOWN: {
2173  DropDownList list = this->BuildDropDownList(widget);
2174  if (!list.empty()) {
2175  ShowDropDownList(this, std::move(list), this->filter.mode, widget);
2176  }
2177  break;
2178  }
2179 
2180  case WID_GS_TYPE_DROPDOWN: {
2181  DropDownList list = this->BuildDropDownList(widget);
2182  if (!list.empty()) {
2183  ShowDropDownList(this, std::move(list), this->filter.type, widget);
2184  }
2185  break;
2186  }
2187  }
2188 
2189  if (widget != WID_GS_OPTIONSPANEL) return;
2190 
2191  uint btn = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GS_OPTIONSPANEL, WidgetDimensions::scaled.framerect.top);
2192  if (btn == INT_MAX || (int)btn < this->warn_lines) return;
2193  btn -= this->warn_lines;
2194 
2195  uint cur_row = 0;
2197 
2198  if (clicked_entry == nullptr) return; // Clicked below the last setting of the page
2199 
2200  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
2201  if (x < 0) return; // Clicked left of the entry
2202 
2203  SettingsPage *clicked_page = dynamic_cast<SettingsPage*>(clicked_entry);
2204  if (clicked_page != nullptr) {
2205  this->SetDisplayedHelpText(nullptr);
2206  clicked_page->folded = !clicked_page->folded; // Flip 'folded'-ness of the sub-page
2207 
2208  this->manually_changed_folding = true;
2209 
2210  this->InvalidateData();
2211  return;
2212  }
2213 
2214  SettingEntry *pe = dynamic_cast<SettingEntry*>(clicked_entry);
2215  assert(pe != nullptr);
2216  const IntSettingDesc *sd = pe->setting;
2217 
2218  /* return if action is only active in network, or only settable by server */
2219  if (!sd->IsEditable()) {
2220  this->SetDisplayedHelpText(pe);
2221  return;
2222  }
2223 
2224  int32 value = sd->Read(ResolveObject(settings_ptr, sd));
2225 
2226  /* clicked on the icon on the left side. Either scroller, bool on/off or dropdown */
2227  if (x < SETTING_BUTTON_WIDTH && (sd->flags & SF_GUI_DROPDOWN)) {
2228  this->SetDisplayedHelpText(pe);
2229 
2230  if (this->valuedropdown_entry == pe) {
2231  /* unclick the dropdown */
2233  this->closing_dropdown = false;
2234  this->valuedropdown_entry->SetButtons(0);
2235  this->valuedropdown_entry = nullptr;
2236  } else {
2237  if (this->valuedropdown_entry != nullptr) this->valuedropdown_entry->SetButtons(0);
2238  this->closing_dropdown = false;
2239 
2240  const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_GS_OPTIONSPANEL);
2241  int rel_y = (pt.y - (int)wid->pos_y - WidgetDimensions::scaled.framerect.top) % wid->resize_y;
2242 
2243  Rect wi_rect;
2244  wi_rect.left = pt.x - (_current_text_dir == TD_RTL ? SETTING_BUTTON_WIDTH - 1 - x : x);
2245  wi_rect.right = wi_rect.left + SETTING_BUTTON_WIDTH - 1;
2246  wi_rect.top = pt.y - rel_y + (SETTING_HEIGHT - SETTING_BUTTON_HEIGHT) / 2;
2247  wi_rect.bottom = wi_rect.top + SETTING_BUTTON_HEIGHT - 1;
2248 
2249  /* For dropdowns we also have to check the y position thoroughly, the mouse may not above the just opening dropdown */
2250  if (pt.y >= wi_rect.top && pt.y <= wi_rect.bottom) {
2251  this->valuedropdown_entry = pe;
2252  this->valuedropdown_entry->SetButtons(SEF_LEFT_DEPRESSED);
2253 
2254  DropDownList list;
2255  for (int i = sd->min; i <= (int)sd->max; i++) {
2256  list.emplace_back(new DropDownListStringItem(sd->str_val + i - sd->min, i, false));
2257  }
2258 
2259  ShowDropDownListAt(this, std::move(list), value, -1, wi_rect, COLOUR_ORANGE, true);
2260  }
2261  }
2262  this->SetDirty();
2263  } else if (x < SETTING_BUTTON_WIDTH) {
2264  this->SetDisplayedHelpText(pe);
2265  int32 oldvalue = value;
2266 
2267  if (sd->IsBoolSetting()) {
2268  value ^= 1;
2269  } else {
2270  /* Add a dynamic step-size to the scroller. In a maximum of
2271  * 50-steps you should be able to get from min to max,
2272  * unless specified otherwise in the 'interval' variable
2273  * of the current setting. */
2274  uint32 step = (sd->interval == 0) ? ((sd->max - sd->min) / 50) : sd->interval;
2275  if (step == 0) step = 1;
2276 
2277  /* don't allow too fast scrolling */
2278  if ((this->flags & WF_TIMEOUT) && this->timeout_timer > 1) {
2279  _left_button_clicked = false;
2280  return;
2281  }
2282 
2283  /* Increase or decrease the value and clamp it to extremes */
2284  if (x >= SETTING_BUTTON_WIDTH / 2) {
2285  value += step;
2286  if (sd->min < 0) {
2287  assert((int32)sd->max >= 0);
2288  if (value > (int32)sd->max) value = (int32)sd->max;
2289  } else {
2290  if ((uint32)value > sd->max) value = (int32)sd->max;
2291  }
2292  if (value < sd->min) value = sd->min; // skip between "disabled" and minimum
2293  } else {
2294  value -= step;
2295  if (value < sd->min) value = (sd->flags & SF_GUI_0_IS_SPECIAL) ? 0 : sd->min;
2296  }
2297 
2298  /* Set up scroller timeout for numeric values */
2299  if (value != oldvalue) {
2300  if (this->clicked_entry != nullptr) { // Release previous buttons if any
2301  this->clicked_entry->SetButtons(0);
2302  }
2303  this->clicked_entry = pe;
2304  this->clicked_entry->SetButtons((x >= SETTING_BUTTON_WIDTH / 2) != (_current_text_dir == TD_RTL) ? SEF_RIGHT_DEPRESSED : SEF_LEFT_DEPRESSED);
2305  this->SetTimeout();
2306  _left_button_clicked = false;
2307  }
2308  }
2309 
2310  if (value != oldvalue) {
2311  SetSettingValue(sd, value);
2312  this->SetDirty();
2313  }
2314  } else {
2315  /* Only open editbox if clicked for the second time, and only for types where it is sensible for. */
2316  if (this->last_clicked == pe && !sd->IsBoolSetting() && !(sd->flags & SF_GUI_DROPDOWN)) {
2317  int64 value64 = value;
2318  /* Show the correct currency-translated value */
2319  if (sd->flags & SF_GUI_CURRENCY) value64 *= _currency->rate;
2320 
2321  CharSetFilter charset_filter = CS_NUMERAL; //default, only numeric input allowed
2322  if (sd->min < 0) charset_filter = CS_NUMERAL_SIGNED; // special case, also allow '-' sign for negative input
2323 
2324  this->valuewindow_entry = pe;
2325  SetDParam(0, value64);
2326  /* Limit string length to 14 so that MAX_INT32 * max currency rate doesn't exceed MAX_INT64. */
2327  ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 15, this, charset_filter, QSF_ENABLE_DEFAULT);
2328  }
2329  this->SetDisplayedHelpText(pe);
2330  }
2331  }
2332 
2333  void OnTimeout() override
2334  {
2335  if (this->clicked_entry != nullptr) { // On timeout, release any depressed buttons
2336  this->clicked_entry->SetButtons(0);
2337  this->clicked_entry = nullptr;
2338  this->SetDirty();
2339  }
2340  }
2341 
2342  void OnQueryTextFinished(char *str) override
2343  {
2344  /* The user pressed cancel */
2345  if (str == nullptr) return;
2346 
2347  assert(this->valuewindow_entry != nullptr);
2348  const IntSettingDesc *sd = this->valuewindow_entry->setting;
2349 
2350  int32 value;
2351  if (!StrEmpty(str)) {
2352  long long llvalue = atoll(str);
2353 
2354  /* Save the correct currency-translated value */
2355  if (sd->flags & SF_GUI_CURRENCY) llvalue /= _currency->rate;
2356 
2357  value = (int32)ClampToI32(llvalue);
2358  } else {
2359  value = sd->def;
2360  }
2361 
2362  SetSettingValue(this->valuewindow_entry->setting, value);
2363  this->SetDirty();
2364  }
2365 
2366  void OnDropdownSelect(int widget, int index) override
2367  {
2368  switch (widget) {
2370  this->filter.mode = (RestrictionMode)index;
2371  if (this->filter.mode == RM_CHANGED_AGAINST_DEFAULT ||
2372  this->filter.mode == RM_CHANGED_AGAINST_NEW) {
2373 
2374  if (!this->manually_changed_folding) {
2375  /* Expand all when selecting 'changes'. Update the filter state first, in case it becomes less restrictive in some cases. */
2376  GetSettingsTree().UpdateFilterState(this->filter, false);
2378  }
2379  } else {
2380  /* Non-'changes' filter. Save as default. */
2382  }
2383  this->InvalidateData();
2384  break;
2385 
2386  case WID_GS_TYPE_DROPDOWN:
2387  this->filter.type = (SettingType)index;
2388  this->InvalidateData();
2389  break;
2390 
2391  default:
2392  if (widget < 0) {
2393  /* Deal with drop down boxes on the panel. */
2394  assert(this->valuedropdown_entry != nullptr);
2395  const IntSettingDesc *sd = this->valuedropdown_entry->setting;
2396  assert(sd->flags & SF_GUI_DROPDOWN);
2397 
2398  SetSettingValue(sd, index);
2399  this->SetDirty();
2400  }
2401  break;
2402  }
2403  }
2404 
2405  void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override
2406  {
2407  if (widget >= 0) {
2408  /* Normally the default implementation of OnDropdownClose() takes care of
2409  * a few things. We want that behaviour here too, but only for
2410  * "normal" dropdown boxes. The special dropdown boxes added for every
2411  * setting that needs one can't have this call. */
2412  Window::OnDropdownClose(pt, widget, index, instant_close);
2413  } else {
2414  /* We cannot raise the dropdown button just yet. OnClick needs some hint, whether
2415  * the same dropdown button was clicked again, and then not open the dropdown again.
2416  * So, we only remember that it was closed, and process it on the next OnPaint, which is
2417  * after OnClick. */
2418  assert(this->valuedropdown_entry != nullptr);
2419  this->closing_dropdown = true;
2420  this->SetDirty();
2421  }
2422  }
2423 
2424  void OnInvalidateData(int data = 0, bool gui_scope = true) override
2425  {
2426  if (!gui_scope) return;
2427 
2428  /* Update which settings are to be visible. */
2429  RestrictionMode min_level = (this->filter.mode <= RM_ALL) ? this->filter.mode : RM_BASIC;
2430  this->filter.min_cat = min_level;
2431  this->filter.type_hides = false;
2432  GetSettingsTree().UpdateFilterState(this->filter, false);
2433 
2434  if (this->filter.string.IsEmpty()) {
2435  this->warn_missing = WHR_NONE;
2436  } else if (min_level < this->filter.min_cat) {
2437  this->warn_missing = this->filter.type_hides ? WHR_CATEGORY_TYPE : WHR_CATEGORY;
2438  } else {
2439  this->warn_missing = this->filter.type_hides ? WHR_TYPE : WHR_NONE;
2440  }
2441  this->vscroll->SetCount(GetSettingsTree().Length() + this->warn_lines);
2442 
2443  if (this->last_clicked != nullptr && !GetSettingsTree().IsVisible(this->last_clicked)) {
2444  this->SetDisplayedHelpText(nullptr);
2445  }
2446 
2447  bool all_folded = true;
2448  bool all_unfolded = true;
2449  GetSettingsTree().GetFoldingState(all_folded, all_unfolded);
2450  this->SetWidgetDisabledState(WID_GS_EXPAND_ALL, all_unfolded);
2451  this->SetWidgetDisabledState(WID_GS_COLLAPSE_ALL, all_folded);
2452  }
2453 
2454  void OnEditboxChanged(int wid) override
2455  {
2456  if (wid == WID_GS_FILTER) {
2457  this->filter.string.SetFilterTerm(this->filter_editbox.text.buf);
2458  if (!this->filter.string.IsEmpty() && !this->manually_changed_folding) {
2459  /* User never expanded/collapsed single pages and entered a filter term.
2460  * Expand everything, to save weird expand clicks, */
2462  }
2463  this->InvalidateData();
2464  }
2465  }
2466 
2467  void OnResize() override
2468  {
2469  this->vscroll->SetCapacityFromWidget(this, WID_GS_OPTIONSPANEL, WidgetDimensions::scaled.framerect.Vertical());
2470  }
2471 };
2472 
2474 
2475 static const NWidgetPart _nested_settings_selection_widgets[] = {
2477  NWidget(WWT_CLOSEBOX, COLOUR_MAUVE),
2478  NWidget(WWT_CAPTION, COLOUR_MAUVE), SetDataTip(STR_CONFIG_SETTING_TREE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
2479  NWidget(WWT_DEFSIZEBOX, COLOUR_MAUVE),
2480  EndContainer(),
2481  NWidget(WWT_PANEL, COLOUR_MAUVE),
2484  NWidget(WWT_TEXT, COLOUR_MAUVE, WID_GS_RESTRICT_CATEGORY), SetDataTip(STR_CONFIG_SETTING_RESTRICT_CATEGORY, STR_NULL),
2485  NWidget(WWT_DROPDOWN, COLOUR_MAUVE, WID_GS_RESTRICT_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_BLACK_STRING, STR_CONFIG_SETTING_RESTRICT_DROPDOWN_HELPTEXT), SetFill(1, 0), SetResize(1, 0),
2486  EndContainer(),
2488  NWidget(WWT_TEXT, COLOUR_MAUVE, WID_GS_RESTRICT_TYPE), SetDataTip(STR_CONFIG_SETTING_RESTRICT_TYPE, STR_NULL),
2489  NWidget(WWT_DROPDOWN, COLOUR_MAUVE, WID_GS_TYPE_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_BLACK_STRING, STR_CONFIG_SETTING_TYPE_DROPDOWN_HELPTEXT), SetFill(1, 0), SetResize(1, 0),
2490  EndContainer(),
2492  NWidget(WWT_TEXT, COLOUR_MAUVE), SetFill(0, 1), SetDataTip(STR_CONFIG_SETTING_FILTER_TITLE, STR_NULL),
2493  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),
2494  EndContainer(),
2495  EndContainer(),
2496  EndContainer(),
2499  NWidget(NWID_VSCROLLBAR, COLOUR_MAUVE, WID_GS_SCROLLBAR),
2500  EndContainer(),
2501  NWidget(WWT_PANEL, COLOUR_MAUVE),
2502  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GS_HELP_TEXT), SetMinimalSize(300, 25), SetFill(1, 1), SetResize(1, 0),
2504  EndContainer(),
2506  NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, WID_GS_EXPAND_ALL), SetDataTip(STR_CONFIG_SETTING_EXPAND_ALL, STR_NULL),
2507  NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, WID_GS_COLLAPSE_ALL), SetDataTip(STR_CONFIG_SETTING_COLLAPSE_ALL, STR_NULL),
2508  NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, WID_GS_RESET_ALL), SetDataTip(STR_CONFIG_SETTING_RESET_ALL, STR_NULL),
2509  NWidget(WWT_PANEL, COLOUR_MAUVE), SetFill(1, 0), SetResize(1, 0),
2510  EndContainer(),
2511  NWidget(WWT_RESIZEBOX, COLOUR_MAUVE),
2512  EndContainer(),
2513 };
2514 
2515 static WindowDesc _settings_selection_desc(
2516  WDP_CENTER, "settings", 510, 450,
2518  0,
2519  _nested_settings_selection_widgets, lengthof(_nested_settings_selection_widgets)
2520 );
2521 
2524 {
2526  new GameSettingsWindow(&_settings_selection_desc);
2527 }
2528 
2529 
2539 void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right)
2540 {
2541  int colour = _colour_gradient[button_colour][2];
2542  Dimension dim = NWidgetScrollbar::GetHorizontalDimension();
2543 
2544  Rect lr = {x, y, x + (int)dim.width - 1, y + (int)dim.height - 1};
2545  Rect rr = {x + (int)dim.width, y, x + (int)dim.width * 2 - 1, y + (int)dim.height - 1};
2546 
2547  DrawFrameRect(lr, button_colour, (state == 1) ? FR_LOWERED : FR_NONE);
2548  DrawFrameRect(rr, button_colour, (state == 2) ? FR_LOWERED : FR_NONE);
2549  DrawSpriteIgnorePadding(SPR_ARROW_LEFT, PAL_NONE, lr, (state == 1), SA_CENTER);
2550  DrawSpriteIgnorePadding(SPR_ARROW_RIGHT, PAL_NONE, rr, (state == 2), SA_CENTER);
2551 
2552  /* Grey out the buttons that aren't clickable */
2553  bool rtl = _current_text_dir == TD_RTL;
2554  if (rtl ? !clickable_right : !clickable_left) {
2556  }
2557  if (rtl ? !clickable_left : !clickable_right) {
2559  }
2560 }
2561 
2570 void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
2571 {
2572  int colour = _colour_gradient[button_colour][2];
2573 
2574  Rect r = {x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1};
2575 
2576  DrawFrameRect(r, button_colour, state ? FR_LOWERED : FR_NONE);
2577  DrawSpriteIgnorePadding(SPR_ARROW_DOWN, PAL_NONE, r, state, SA_CENTER);
2578 
2579  if (!clickable) {
2581  }
2582 }
2583 
2591 void DrawBoolButton(int x, int y, bool state, bool clickable)
2592 {
2593  static const Colours _bool_ctabs[2][2] = {{COLOUR_CREAM, COLOUR_RED}, {COLOUR_DARK_GREEN, COLOUR_GREEN}};
2594 
2595  Rect r = {x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1};
2596  DrawFrameRect(r, _bool_ctabs[state][clickable], state ? FR_LOWERED : FR_NONE);
2597 }
2598 
2600  int query_widget;
2601 
2602  CustomCurrencyWindow(WindowDesc *desc) : Window(desc)
2603  {
2604  this->InitNested();
2605 
2606  SetButtonState();
2607  }
2608 
2609  void SetButtonState()
2610  {
2611  this->SetWidgetDisabledState(WID_CC_RATE_DOWN, _custom_currency.rate == 1);
2612  this->SetWidgetDisabledState(WID_CC_RATE_UP, _custom_currency.rate == UINT16_MAX);
2613  this->SetWidgetDisabledState(WID_CC_YEAR_DOWN, _custom_currency.to_euro == CF_NOEURO);
2614  this->SetWidgetDisabledState(WID_CC_YEAR_UP, _custom_currency.to_euro == MAX_YEAR);
2615  }
2616 
2617  void SetStringParameters(int widget) const override
2618  {
2619  switch (widget) {
2620  case WID_CC_RATE: SetDParam(0, 1); SetDParam(1, 1); break;
2621  case WID_CC_SEPARATOR: SetDParamStr(0, _custom_currency.separator); break;
2622  case WID_CC_PREFIX: SetDParamStr(0, _custom_currency.prefix); break;
2623  case WID_CC_SUFFIX: SetDParamStr(0, _custom_currency.suffix); break;
2624  case WID_CC_YEAR:
2625  SetDParam(0, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER);
2626  SetDParam(1, _custom_currency.to_euro);
2627  break;
2628 
2629  case WID_CC_PREVIEW:
2630  SetDParam(0, 10000);
2631  break;
2632  }
2633  }
2634 
2635  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
2636  {
2637  switch (widget) {
2638  /* Set the appropriate width for the edit 'buttons' */
2639  case WID_CC_SEPARATOR_EDIT:
2640  case WID_CC_PREFIX_EDIT:
2641  case WID_CC_SUFFIX_EDIT:
2642  size->width = this->GetWidget<NWidgetBase>(WID_CC_RATE_DOWN)->smallest_x + this->GetWidget<NWidgetBase>(WID_CC_RATE_UP)->smallest_x;
2643  break;
2644 
2645  /* Make sure the window is wide enough for the widest exchange rate */
2646  case WID_CC_RATE:
2647  SetDParam(0, 1);
2648  SetDParam(1, INT32_MAX);
2649  *size = GetStringBoundingBox(STR_CURRENCY_EXCHANGE_RATE);
2650  break;
2651  }
2652  }
2653 
2654  void OnClick(Point pt, int widget, int click_count) override
2655  {
2656  int line = 0;
2657  int len = 0;
2658  StringID str = 0;
2659  CharSetFilter afilter = CS_ALPHANUMERAL;
2660 
2661  switch (widget) {
2662  case WID_CC_RATE_DOWN:
2663  if (_custom_currency.rate > 1) _custom_currency.rate--;
2664  if (_custom_currency.rate == 1) this->DisableWidget(WID_CC_RATE_DOWN);
2666  break;
2667 
2668  case WID_CC_RATE_UP:
2669  if (_custom_currency.rate < UINT16_MAX) _custom_currency.rate++;
2670  if (_custom_currency.rate == UINT16_MAX) this->DisableWidget(WID_CC_RATE_UP);
2672  break;
2673 
2674  case WID_CC_RATE:
2675  SetDParam(0, _custom_currency.rate);
2676  str = STR_JUST_INT;
2677  len = 5;
2678  line = WID_CC_RATE;
2679  afilter = CS_NUMERAL;
2680  break;
2681 
2682  case WID_CC_SEPARATOR_EDIT:
2683  case WID_CC_SEPARATOR:
2684  SetDParamStr(0, _custom_currency.separator);
2685  str = STR_JUST_RAW_STRING;
2686  len = 7;
2687  line = WID_CC_SEPARATOR;
2688  break;
2689 
2690  case WID_CC_PREFIX_EDIT:
2691  case WID_CC_PREFIX:
2692  SetDParamStr(0, _custom_currency.prefix);
2693  str = STR_JUST_RAW_STRING;
2694  len = 15;
2695  line = WID_CC_PREFIX;
2696  break;
2697 
2698  case WID_CC_SUFFIX_EDIT:
2699  case WID_CC_SUFFIX:
2700  SetDParamStr(0, _custom_currency.suffix);
2701  str = STR_JUST_RAW_STRING;
2702  len = 15;
2703  line = WID_CC_SUFFIX;
2704  break;
2705 
2706  case WID_CC_YEAR_DOWN:
2707  _custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ? CF_NOEURO : _custom_currency.to_euro - 1;
2708  if (_custom_currency.to_euro == CF_NOEURO) this->DisableWidget(WID_CC_YEAR_DOWN);
2710  break;
2711 
2712  case WID_CC_YEAR_UP:
2713  _custom_currency.to_euro = Clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR);
2714  if (_custom_currency.to_euro == MAX_YEAR) this->DisableWidget(WID_CC_YEAR_UP);
2716  break;
2717 
2718  case WID_CC_YEAR:
2719  SetDParam(0, _custom_currency.to_euro);
2720  str = STR_JUST_INT;
2721  len = 7;
2722  line = WID_CC_YEAR;
2723  afilter = CS_NUMERAL;
2724  break;
2725  }
2726 
2727  if (len != 0) {
2728  this->query_widget = line;
2729  ShowQueryString(str, STR_CURRENCY_CHANGE_PARAMETER, len + 1, this, afilter, QSF_NONE);
2730  }
2731 
2732  this->SetTimeout();
2733  this->SetDirty();
2734  }
2735 
2736  void OnQueryTextFinished(char *str) override
2737  {
2738  if (str == nullptr) return;
2739 
2740  switch (this->query_widget) {
2741  case WID_CC_RATE:
2742  _custom_currency.rate = Clamp(atoi(str), 1, UINT16_MAX);
2743  break;
2744 
2745  case WID_CC_SEPARATOR: // Thousands separator
2746  _custom_currency.separator = str;
2747  break;
2748 
2749  case WID_CC_PREFIX:
2750  _custom_currency.prefix = str;
2751  break;
2752 
2753  case WID_CC_SUFFIX:
2754  _custom_currency.suffix = str;
2755  break;
2756 
2757  case WID_CC_YEAR: { // Year to switch to euro
2758  int val = atoi(str);
2759 
2760  _custom_currency.to_euro = (val < 2000 ? CF_NOEURO : std::min(val, MAX_YEAR));
2761  break;
2762  }
2763  }
2765  SetButtonState();
2766  }
2767 
2768  void OnTimeout() override
2769  {
2770  this->SetDirty();
2771  }
2772 };
2773 
2774 static const NWidgetPart _nested_cust_currency_widgets[] = {
2776  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
2777  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_CURRENCY_WINDOW, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
2778  EndContainer(),
2779  NWidget(WWT_PANEL, COLOUR_GREY),
2781  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
2782  NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_RATE_DOWN), SetDataTip(AWV_DECREASE, STR_CURRENCY_DECREASE_EXCHANGE_RATE_TOOLTIP),
2783  NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_RATE_UP), SetDataTip(AWV_INCREASE, STR_CURRENCY_INCREASE_EXCHANGE_RATE_TOOLTIP),
2785  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_RATE), SetDataTip(STR_CURRENCY_EXCHANGE_RATE, STR_CURRENCY_SET_EXCHANGE_RATE_TOOLTIP), SetFill(1, 0),
2786  EndContainer(),
2787  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
2788  NWidget(WWT_PUSHBTN, COLOUR_DARK_BLUE, WID_CC_SEPARATOR_EDIT), SetDataTip(0x0, STR_CURRENCY_SET_CUSTOM_CURRENCY_SEPARATOR_TOOLTIP), SetFill(0, 1),
2790  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_SEPARATOR), SetDataTip(STR_CURRENCY_SEPARATOR, STR_CURRENCY_SET_CUSTOM_CURRENCY_SEPARATOR_TOOLTIP), SetFill(1, 0),
2791  EndContainer(),
2792  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
2793  NWidget(WWT_PUSHBTN, COLOUR_DARK_BLUE, WID_CC_PREFIX_EDIT), SetDataTip(0x0, STR_CURRENCY_SET_CUSTOM_CURRENCY_PREFIX_TOOLTIP), SetFill(0, 1),
2795  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_PREFIX), SetDataTip(STR_CURRENCY_PREFIX, STR_CURRENCY_SET_CUSTOM_CURRENCY_PREFIX_TOOLTIP), SetFill(1, 0),
2796  EndContainer(),
2797  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
2798  NWidget(WWT_PUSHBTN, COLOUR_DARK_BLUE, WID_CC_SUFFIX_EDIT), SetDataTip(0x0, STR_CURRENCY_SET_CUSTOM_CURRENCY_SUFFIX_TOOLTIP), SetFill(0, 1),
2800  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_SUFFIX), SetDataTip(STR_CURRENCY_SUFFIX, STR_CURRENCY_SET_CUSTOM_CURRENCY_SUFFIX_TOOLTIP), SetFill(1, 0),
2801  EndContainer(),
2802  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
2803  NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_YEAR_DOWN), SetDataTip(AWV_DECREASE, STR_CURRENCY_DECREASE_CUSTOM_CURRENCY_TO_EURO_TOOLTIP),
2804  NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_YEAR_UP), SetDataTip(AWV_INCREASE, STR_CURRENCY_INCREASE_CUSTOM_CURRENCY_TO_EURO_TOOLTIP),
2806  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_YEAR), SetDataTip(STR_JUST_STRING, STR_CURRENCY_SET_CUSTOM_CURRENCY_TO_EURO_TOOLTIP), SetFill(1, 0),
2807  EndContainer(),
2808  EndContainer(),
2809  NWidget(WWT_LABEL, COLOUR_BLUE, WID_CC_PREVIEW),
2810  SetDataTip(STR_CURRENCY_PREVIEW, STR_CURRENCY_CUSTOM_CURRENCY_PREVIEW_TOOLTIP), SetPadding(15, 1, 18, 2),
2811  EndContainer(),
2812 };
2813 
2814 static WindowDesc _cust_currency_desc(
2815  WDP_CENTER, nullptr, 0, 0,
2817  0,
2818  _nested_cust_currency_widgets, lengthof(_nested_cust_currency_widgets)
2819 );
2820 
2822 static void ShowCustCurrency()
2823 {
2825  new CustomCurrencyWindow(&_cust_currency_desc);
2826 }
WID_GO_REFRESH_RATE_DROPDOWN
@ WID_GO_REFRESH_RATE_DROPDOWN
Dropdown for all available refresh rates.
Definition: settings_widget.h:41
SettingEntry::Length
virtual uint Length() const
Return number of rows needed to display the (filtered) entry.
Definition: settings_gui.cpp:1097
WC_CUSTOM_CURRENCY
@ WC_CUSTOM_CURRENCY
Custom currency; Window numbers:
Definition: window_type.h:612
SEF_RIGHT_DEPRESSED
@ SEF_RIGHT_DEPRESSED
Of a numeric setting entry, the right button is depressed.
Definition: settings_gui.cpp:804
WID_GO_FULLSCREEN_BUTTON
@ WID_GO_FULLSCREEN_BUTTON
Toggle fullscreen.
Definition: settings_widget.h:21
Window::SetTimeout
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
Definition: window_gui.h:295
SettingEntry::UpdateFilterState
virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible)
Update the filter state.
Definition: settings_gui.cpp:1158
CustomCurrencyWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: settings_gui.cpp:2768
CF_NOEURO
static const int CF_NOEURO
Currency never switches to the Euro (as far as known).
Definition: currency.h:17
SF_PER_COMPANY
@ SF_PER_COMPANY
This setting can be different for each company (saved in company struct).
Definition: settings_internal.h:27
ClampToI32
static int32 ClampToI32(const int64 a)
Reduce a signed 64-bit int to a signed 32-bit one.
Definition: math_func.hpp:167
factory.hpp
GUISettings::refresh_rate
uint16 refresh_rate
How often we refresh the screen (time between draw-ticks).
Definition: settings_type.h:177
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
TextfileWindow::LoadTextfile
virtual void LoadTextfile(const char *textfile, Subdirectory dir)
Loads the textfile text from file and setup lines.
Definition: textfile_gui.cpp:338
Pool::PoolItem<&_company_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:337
WID_GO_AUTOSAVE_DROPDOWN
@ WID_GO_AUTOSAVE_DROPDOWN
Dropdown to say how often to autosave.
Definition: settings_widget.h:18
SEF_LEFT_DEPRESSED
@ SEF_LEFT_DEPRESSED
Of a numeric setting entry, the left button is depressed.
Definition: settings_gui.cpp:803
Window::timeout_timer
uint8 timeout_timer
Timer value of the WF_TIMEOUT for flags.
Definition: window_gui.h:243
querystring_gui.h
DropDownListParamStringItem
String list item with parameters.
Definition: dropdown_type.h:56
SetScrollbar
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1210
GetCurrentLanguageIsoCode
const char * GetCurrentLanguageIsoCode()
Get the ISO language code of the currently loaded language.
Definition: strings.cpp:2051
SEF_BUTTONS_MASK
@ SEF_BUTTONS_MASK
Bit-mask for button flags.
Definition: settings_gui.cpp:805
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
Scrollbar::GetCapacity
uint16 GetCapacity() const
Gets the number of visible elements of the scrollbar.
Definition: widget_type.h:669
WID_GS_OPTIONSPANEL
@ WID_GS_OPTIONSPANEL
Panel widget containing the option lists.
Definition: settings_widget.h:48
command_func.h
BaseSetTextfileWindow::baseset
const TBaseSet * baseset
View the textfile of this BaseSet.
Definition: settings_gui.cpp:99
WID_GS_COLLAPSE_ALL
@ WID_GS_COLLAPSE_ALL
Collapse all button.
Definition: settings_widget.h:52
WID_GS_HELP_TEXT
@ WID_GS_HELP_TEXT
Information area to display help text of the selected option.
Definition: settings_widget.h:50
SetPadding
static NWidgetPart SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1143
Window::GetScrollbar
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:319
BaseSetTextfileWindow::content_type
StringID content_type
STR_CONTENT_TYPE_xxx for title.
Definition: settings_gui.cpp:100
dropdown_func.h
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition: geometry_type.hpp:92
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:1420
WID_GO_BASE_GRF_STATUS
@ WID_GO_BASE_GRF_STATUS
Info about missing files etc.
Definition: settings_widget.h:26
GameSettingsWindow
Window to edit settings of the game.
Definition: settings_gui.cpp:1936
StringFilter::IsEmpty
bool IsEmpty() const
Check whether any filter words were entered.
Definition: stringfilter_type.h:59
_left_button_down
bool _left_button_down
Is left mouse button pressed?
Definition: gfx.cpp:41
CustomCurrencyWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: settings_gui.cpp:2654
SettingsPage::DrawSetting
virtual void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const
Function to draw setting value (button + text + current value)
Definition: settings_gui.cpp:1583
company_base.h
WID_CC_SEPARATOR_EDIT
@ WID_CC_SEPARATOR_EDIT
Separator edit button.
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:1937
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition: window_gui.h:67
IntSettingDesc::cat
SettingCategory cat
assigned categories of the setting
Definition: settings_internal.h:167
StringFilter::SetFilterTerm
void SetFilterTerm(const char *str)
Set the term to filter on.
Definition: stringfilter.cpp:27
GameSettingsWindow::OnInit
void OnInit() override
Notification that the nested widget tree gets initialized.
Definition: settings_gui.cpp:1983
WID_GO_BASE_SFX_TEXTFILE
@ WID_GO_BASE_SFX_TEXTFILE
Open base SFX readme, changelog (+1) or license (+2).
Definition: settings_widget.h:31
IntSettingDesc::min
int32 min
minimum values
Definition: settings_internal.h:161
WID_GS_RESET_ALL
@ WID_GS_RESET_ALL
Reset all button.
Definition: settings_widget.h:53
SettingFilter::type
SettingType type
Filter based on type.
Definition: settings_gui.cpp:828
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
BASESET_DIR
@ BASESET_DIR
Subdirectory for all base data (base sets, intro game)
Definition: fileio_type.h:116
currency.h
MusicDriver::SetVolume
virtual void SetVolume(byte vol)=0
Set the volume, if possible.
ST_GAME
@ ST_GAME
Game setting.
Definition: settings_internal.h:62
SettingEntry::setting
const IntSettingDesc * setting
Setting description of the setting.
Definition: settings_gui.cpp:873
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition: widget_type.h:55
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:99
WID_CC_YEAR
@ WID_CC_YEAR
Year of introduction.
Definition: settings_widget.h:73
SettingDesc::GetType
SettingType GetType() const
Return the type of the setting.
Definition: settings.cpp:823
SettingsPage::Init
virtual void Init(byte level=0)
Initialization of an entire setting page.
Definition: settings_gui.cpp:1429
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition: widget_type.h:63
Window::CreateNestedTree
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1775
SettingsPage::Length
virtual uint Length() const
Return number of rows needed to display the (filtered) entry.
Definition: settings_gui.cpp:1518
SettingDesc::IsEditable
bool IsEditable(bool do_command=false) const
Check whether the setting is editable in the current gamemode.
Definition: settings.cpp:807
WID_GO_BASE_GRF_DESCRIPTION
@ WID_GO_BASE_GRF_DESCRIPTION
Description of selected base GRF.
Definition: settings_widget.h:28
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
WID_GO_GUI_SCALE_AUTO
@ WID_GO_GUI_SCALE_AUTO
Autodetect GUI scale button.
Definition: settings_widget.h:23
GameSettingsWindow::OnDropdownClose
void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override
A dropdown window associated to this window has been closed.
Definition: settings_gui.cpp:2405
DropDownListCharStringItem
List item containing a C char string.
Definition: dropdown_type.h:70
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:1378
GameSettingsWindow::filter_editbox
QueryString filter_editbox
Filter editbox;.
Definition: settings_gui.cpp:1946
ST_CLIENT
@ ST_CLIENT
Client setting.
Definition: settings_internal.h:64
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition: geometry_func.cpp:22
BaseSettingEntry::SetLastField
void SetLastField(bool last_field)
Set whether this is the last visible entry of the parent node.
Definition: settings_gui.cpp:848
WID_CC_RATE
@ WID_CC_RATE
Rate of currency.
Definition: settings_widget.h:64
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
BaseSetTextfileWindow
Window for displaying the textfile of a BaseSet.
Definition: settings_gui.cpp:98
Scrollbar::SetCount
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:717
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:38
FILLRECT_CHECKER
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
Definition: gfx_type.h:294
SettingFilter::string
StringFilter string
Filter string.
Definition: settings_gui.cpp:824
SettingEntry::Init
virtual void Init(byte level=0)
Initialization of a setting entry.
Definition: settings_gui.cpp:1073
GameOptionsWindow
Definition: settings_gui.cpp:166
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:997
zoom_func.h
ST_COMPANY
@ ST_COMPANY
Company setting.
Definition: settings_internal.h:63
WID_GS_EXPAND_ALL
@ WID_GS_EXPAND_ALL
Expand all button.
Definition: settings_widget.h:51
base_media_base.h
DropDownListItem
Base list item class from which others are derived.
Definition: dropdown_type.h:22
SettingsContainer::entries
EntryVector entries
Settings on this page.
Definition: settings_gui.cpp:906
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:53
GameSettingsWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: settings_gui.cpp:1988
DrawString
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:644
GameSettingsWindow::last_clicked
SettingEntry * last_clicked
If non-nullptr, pointer to the last clicked setting.
Definition: settings_gui.cpp:1941
GUISettings::autosave
byte autosave
how often should we do autosaves?
Definition: settings_type.h:137
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:46
town.h
WWT_PUSHARROWBTN
@ WWT_PUSHARROWBTN
Normal push-button (no toggle button) with arrow caption.
Definition: widget_type.h:106
WID_GO_BASE_MUSIC_VOLUME
@ WID_GO_BASE_MUSIC_VOLUME
Change music volume.
Definition: settings_widget.h:34
WID_GS_FILTER
@ WID_GS_FILTER
Text filter.
Definition: settings_widget.h:47
StringFilter::AddLine
void AddLine(const char *str)
Pass another text line from the current item to the filter.
Definition: stringfilter.cpp:104
Window::OnDropdownClose
virtual void OnDropdownClose(Point pt, int widget, int index, bool instant_close)
A dropdown window associated to this window has been closed.
Definition: window.cpp:292
FR_LOWERED
@ FR_LOWERED
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
Definition: window_gui.h:34
settings_internal.h
WID_CC_PREFIX
@ WID_CC_PREFIX
Current prefix.
Definition: settings_widget.h:68
SettingDesc::flags
SettingFlag flags
Handles how a setting would show up in the GUI (text/currency, etc.).
Definition: settings_internal.h:77
SEF_FILTERED
@ SEF_FILTERED
Entry is hidden by the string filter.
Definition: settings_gui.cpp:808
WID_GO_BASE_MUSIC_DROPDOWN
@ WID_GO_BASE_MUSIC_DROPDOWN
Use to select a base music set.
Definition: settings_widget.h:33
WC_MUSIC_WINDOW
@ WC_MUSIC_WINDOW
Music window; Window numbers:
Definition: window_type.h:589
Scrollbar::GetScrolledRowFromWidget
int GetScrolledRowFromWidget(int clickpos, const Window *const w, int widget, int padding=0) const
Compute the row of a scrolled widget that a user clicked in.
Definition: widget.cpp:2353
SettingEntry::IsVisibleByRestrictionMode
bool IsVisibleByRestrictionMode(RestrictionMode mode) const
Checks whether an entry shall be made visible based on the restriction mode.
Definition: settings_gui.cpp:1117
SettingsPage::SettingsPage
SettingsPage(StringID title)
Constructor for a sub-page in the 'advanced settings' window.
Definition: settings_gui.cpp:1419
BaseSettingEntry::Init
virtual void Init(byte level=0)
Initialization of a setting entry.
Definition: settings_gui.cpp:963
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:636
SettingsPage
Data structure describing one page of settings in the settings window.
Definition: settings_gui.cpp:932
TextfileWindow::file_type
TextfileType file_type
Type of textfile to view.
Definition: textfile_gui.h:30
TFT_CHANGELOG
@ TFT_CHANGELOG
NewGRF changelog.
Definition: textfile_type.h:18
SettingsContainer::UpdateFilterState
bool UpdateFilterState(SettingFilter &filter, bool force_visible)
Update the filter state.
Definition: settings_gui.cpp:1318
_colour_gradient
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
Definition: gfx.cpp:55
Rect::WithHeight
Rect WithHeight(int height, bool end=false) const
Copy Rect and set its height.
Definition: geometry_type.hpp:205
Window::Window
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition: window.cpp:1814
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:196
CustomCurrencyWindow
Definition: settings_gui.cpp:2599
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:975
textfile_gui.h
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1111
QueryString
Data stored about a string that can be modified in the GUI.
Definition: querystring_gui.h:20
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:2333
GetStringBoundingBox
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:890
GameOptionsWindow::Close
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
Definition: settings_gui.cpp:183
_gui_scale
int _gui_scale
GUI scale, 100 is 100%.
Definition: gfx.cpp:65
GetStringLineCount
int GetStringLineCount(StringID str, int maxw)
Calculates number of lines of string.
Definition: gfx.cpp:740
textbuf_gui.h
Textbuf::buf
char *const buf
buffer in which text is saved
Definition: textbuf_type.h:32
Window::querystrings
SmallMap< int, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
Definition: window_gui.h:257
ShowErrorMessage
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=nullptr, uint textref_stack_size=0, const uint32 *textref_stack=nullptr)
Display an error message in a window.
Definition: error_gui.cpp:377
DrawStringMultiLine
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
Definition: gfx.cpp:789
GameOptionsWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: settings_gui.cpp:290
SettingEntry::GetMaxHelpHeight
virtual uint GetMaxHelpHeight(int maxw)
Get the biggest height of the help text(s), if the width is at least maxw.
Definition: settings_gui.cpp:1107
BuildCurrencyDropdown
StringID * BuildCurrencyDropdown()
Build a list of currency names StringIDs to use in a dropdown list.
Definition: currency.cpp:169
ai.hpp
WID_CC_SEPARATOR
@ WID_CC_SEPARATOR
Current separator.
Definition: settings_widget.h:66
GetGameSettings
static GameSettings & GetGameSettings()
Get the settings-object applicable for the current situation: the newgame settings when we're in the ...
Definition: settings_type.h:628
WN_GAME_OPTIONS_GAME_OPTIONS
@ WN_GAME_OPTIONS_GAME_OPTIONS
Game options.
Definition: window_type.h:19
WindowDesc
High level window description.
Definition: window_gui.h:102
GameSettingsWindow::warn_missing
WarnHiddenResult warn_missing
Whether and how to warn about missing search results.
Definition: settings_gui.cpp:1948
AdjustGUIZoom
bool AdjustGUIZoom(bool automatic)
Resolve GUI zoom level and adjust GUI to new zoom, if auto-suggestion is requested.
Definition: gfx.cpp:2023
BaseSettingEntry::level
byte level
Nesting level of this setting entry.
Definition: settings_gui.cpp:834
SettingType
SettingType
Type of settings for filtering.
Definition: settings_internal.h:61
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:66
SettingsPage::title
StringID title
Title of the sub-page.
Definition: settings_gui.cpp:933
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:825
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:469
WC_QUERY_STRING
@ WC_QUERY_STRING
Query string window; Window numbers:
Definition: window_type.h:116
GameOptionsWindow::BuildDropDownList
DropDownList BuildDropDownList(int widget, int *selected_index) const
Build the dropdown list for a specific widget.
Definition: settings_gui.cpp:197
DrawDropDownButton
void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
Draw a dropdown button.
Definition: settings_gui.cpp:2570
IntSettingDesc::str_val
StringID str_val
(Translated) first string describing the value.
Definition: settings_internal.h:166
WWT_PUSHBTN
@ WWT_PUSHBTN
Normal push-button (no toggle button) with custom drawing.
Definition: widget_type.h:103
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:251
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:54
GameSettingsWindow::warn_lines
int warn_lines
Number of lines used for warning about missing search results.
Definition: settings_gui.cpp:1949
ResetAllSettingsConfirmationCallback
static void ResetAllSettingsConfirmationCallback(Window *w, bool confirmed)
Callback function for the reset all settings button.
Definition: settings_gui.cpp:1926
VideoDriver::GetListOfMonitorRefreshRates
virtual std::vector< int > GetListOfMonitorRefreshRates()
Get a list of refresh rates of each available monitor.
Definition: video_driver.hpp:164
Scrollbar::GetCount
uint16 GetCount() const
Gets the number of elements in the list.
Definition: widget_type.h:660
SETTING_HEIGHT
static int SETTING_HEIGHT
Height of a single setting in the tree view in pixels.
Definition: settings_gui.cpp:796
Window::EnableWidget
void EnableWidget(byte widget_index)
Sets a widget to Enabled.
Definition: window_gui.h:340
MusicDriver::GetInstance
static MusicDriver * GetInstance()
Get the currently active instance of the music driver.
Definition: music_driver.hpp:46
WidgetDimensions::hsep_normal
int hsep_normal
Normal horizontal spacing.
Definition: window_gui.h:63
RestrictionMode
RestrictionMode
How the list of advanced settings is filtered.
Definition: settings_gui.cpp:812
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1804
WWT_EDITBOX
@ WWT_EDITBOX
a textbox for typing
Definition: widget_type.h:69
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:1939
ReInitAllWindows
void ReInitAllWindows(bool zoom_changed)
Re-initialize all windows.
Definition: window.cpp:3377
SettingEntry::DrawSetting
virtual void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const
Function to draw setting value (button + text + current value)
Definition: settings_gui.cpp:1232
WHR_TYPE
@ WHR_TYPE
Type setting filtered matches away.
Definition: settings_gui.cpp:1917
Window::height
int height
Height of the window (number of pixels down in y direction)
Definition: window_gui.h:249
WID_CC_SUFFIX_EDIT
@ WID_CC_SUFFIX_EDIT
Suffix edit button.
Definition: settings_widget.h:69
WID_GO_GUI_SCALE_BEVEL_BUTTON
@ WID_GO_GUI_SCALE_BEVEL_BUTTON
Toggle for chunky bevels.
Definition: settings_widget.h:24
IntSettingDesc
Base integer type, including boolean, settings.
Definition: settings_internal.h:136
WID_GO_BASE_MUSIC_DESCRIPTION
@ WID_GO_BASE_MUSIC_DESCRIPTION
Description of selected base music set.
Definition: settings_widget.h:38
CustomCurrencyWindow::OnQueryTextFinished
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: settings_gui.cpp:2736
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:1008
highscore.h
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:1277
GameSettingsWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: settings_gui.cpp:2366
GUISettings::missing_strings_threshold
byte missing_strings_threshold
the number of missing strings before showing the warning
Definition: settings_type.h:170
VideoDriver::ToggleVsync
virtual void ToggleVsync(bool vsync)
Change the vsync setting.
Definition: video_driver.hpp:75
BaseSettingEntry
Data structure describing a single setting in a tab.
Definition: settings_gui.cpp:832
GameSettingsWindow::OnQueryTextFinished
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: settings_gui.cpp:2342
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:104
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:126
WidgetDimensions::hsep_wide
int hsep_wide
Wide horizontal spacing.
Definition: window_gui.h:64
ShowDropDownList
void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
Definition: dropdown.cpp:444
GameOptionsWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: settings_gui.cpp:318
RM_END
@ RM_END
End for iteration.
Definition: settings_gui.cpp:818
SettingFilter::mode
RestrictionMode mode
Filter based on category.
Definition: settings_gui.cpp:827
dropdown_type.h
WID_GO_VIDEO_DRIVER_INFO
@ WID_GO_VIDEO_DRIVER_INFO
Label showing details about the current video driver.
Definition: settings_widget.h:42
SettingEntry::name
const char * name
Name of the setting.
Definition: settings_gui.cpp:872
Window::SetWidgetDisabledState
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:321
WL_INFO
@ WL_INFO
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
Definition: error.h:22
SettingsPage::FoldAll
virtual void FoldAll()
Recursively close all (filtered) folds of sub-pages.
Definition: settings_gui.cpp:1444
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:46
_current_language
const LanguageMetadata * _current_language
The currently loaded language.
Definition: strings.cpp:47
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:29
SEF_LAST_FIELD
@ SEF_LAST_FIELD
This entry is the last one in a (sub-)page.
Definition: settings_gui.cpp:807
DropDownListStringItem
Common string list item.
Definition: dropdown_type.h:39
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:1115
RM_ALL
@ RM_ALL
List all settings regardless of the default/newgame/... values.
Definition: settings_gui.cpp:815
music_driver.hpp
Window::flags
WindowFlags flags
Window flags.
Definition: window_gui.h:239
_resolutions
std::vector< Dimension > _resolutions
List of resolutions.
Definition: driver.cpp:31
WF_TIMEOUT
@ WF_TIMEOUT
Window timeout counter.
Definition: window_gui.h:168
StrEmpty
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition: string_func.h:67
GameSettings
All settings together for the game.
Definition: settings_type.h:585
SettingsPage::folded
bool folded
Sub-page is folded (not visible except for its title)
Definition: settings_gui.cpp:934
SF_GUI_NEGATIVE_IS_SPECIAL
@ SF_GUI_NEGATIVE_IS_SPECIAL
A negative value has another string (the one after "strval").
Definition: settings_internal.h:19
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:1058
WID_GO_BASE_GRF_DROPDOWN
@ WID_GO_BASE_GRF_DROPDOWN
Use to select a base GRF.
Definition: settings_widget.h:25
GameOptionsWindow::OnMouseLoop
void OnMouseLoop() override
Called for every mouse loop run, which is at least once per (game) tick.
Definition: settings_gui.cpp:539
WID_CC_YEAR_UP
@ WID_CC_YEAR_UP
Up button.
Definition: settings_widget.h:72
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:1942
SettingsContainer::Init
void Init(byte level=0)
Initialization of an entire setting page.
Definition: settings_gui.cpp:1269
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
SF_GUI_CURRENCY
@ SF_GUI_CURRENCY
The number represents money, so when reading value multiply by exchange rate.
Definition: settings_internal.h:21
error.h
CheckBlitter
void CheckBlitter()
Check whether we still use the right blitter, or use another (better) one.
Definition: gfxinit.cpp:334
RM_BASIC
@ RM_BASIC
Display settings associated to the "basic" list.
Definition: settings_gui.cpp:813
WWT_FRAME
@ WWT_FRAME
Frame.
Definition: widget_type.h:58
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:136
WID_CC_YEAR_DOWN
@ WID_CC_YEAR_DOWN
Down button.
Definition: settings_widget.h:71
WHR_CATEGORY
@ WHR_CATEGORY
Category setting filtered matches away.
Definition: settings_gui.cpp:1916
SettingsPage::FindEntry
virtual BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find setting entry at row row_num.
Definition: settings_gui.cpp:1532
BaseSetTextfileWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: settings_gui.cpp:108
SETTING_BUTTON_WIDTH
#define SETTING_BUTTON_WIDTH
Width of setting buttons.
Definition: settings_gui.h:17
CustomCurrencyWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: settings_gui.cpp:2617
Window::SetFocusedWidget
bool SetFocusedWidget(int widget_index)
Set focus within this window to the given widget.
Definition: window.cpp:519
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:2539
WID_GO_LANG_DROPDOWN
@ WID_GO_LANG_DROPDOWN
Language dropdown.
Definition: settings_widget.h:19
SettingFilter::type_hides
bool type_hides
Whether the type hides filtered strings.
Definition: settings_gui.cpp:826
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:116
ShowCustCurrency
static void ShowCustCurrency()
Open custom currency window.
Definition: settings_gui.cpp:2822
RectPadding::Vertical
uint Vertical() const
Get total vertical padding of RectPadding.
Definition: geometry_type.hpp:65
WID_CC_RATE_DOWN
@ WID_CC_RATE_DOWN
Down button.
Definition: settings_widget.h:62
TFT_README
@ TFT_README
NewGRF 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:1402
WarnHiddenResult
WarnHiddenResult
Warnings about hidden search results.
Definition: settings_gui.cpp:1914
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:3194
VideoDriver::GetInstance
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
Definition: video_driver.hpp:202
CS_ALPHANUMERAL
@ CS_ALPHANUMERAL
Both numeric and alphabetic and spaces and stuff.
Definition: string_type.h:27
viewport_func.h
Window::mouse_capture_widget
int mouse_capture_widget
Widgetindex of current mouse capture widget (e.g. dragged scrollbar). -1 if no widget has mouse captu...
Definition: window_gui.h:264
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:38
WHR_CATEGORY_TYPE
@ WHR_CATEGORY_TYPE
Both category and type settings filtered matches away.
Definition: settings_gui.cpp:1918
WID_GO_GUI_SCALE
@ WID_GO_GUI_SCALE
GUI Scale slider.
Definition: settings_widget.h:22
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:75
ShowBaseSetTextfileWindow
void ShowBaseSetTextfileWindow(TextfileType file_type, const TBaseSet *baseset, StringID content_type)
Open the BaseSet version of the textfile window.
Definition: settings_gui.cpp:124
BaseSet::GetNumMissing
int GetNumMissing() const
Get the number of missing files.
Definition: base_media_base.h:88
WID_CC_RATE_UP
@ WID_CC_RATE_UP
Up button.
Definition: settings_widget.h:63
GetStringHeight
int GetStringHeight(const char *str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Definition: gfx.cpp:715
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:993
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:67
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:66
GameSettingsWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: settings_gui.cpp:2056
WID_GO_BACKGROUND
@ WID_GO_BACKGROUND
Background of the window.
Definition: settings_widget.h:15
BaseMedia< GraphicsSet >::GetNumSets
static int GetNumSets()
Count the number of available graphics sets.
Definition: base_media_func.h:311
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:1090
TFT_LICENSE
@ TFT_LICENSE
NewGRF license.
Definition: textfile_type.h:19
_switch_mode
SwitchMode _switch_mode
The next mainloop command.
Definition: gfx.cpp:49
GameSettingsWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: settings_gui.cpp:2467
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
WWT_PUSHIMGBTN
@ WWT_PUSHIMGBTN
Normal push-button (no toggle button) with image caption.
Definition: widget_type.h:105
ShowQuery
void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback)
Show a modal confirmation window with standard 'yes' and 'no' buttons The window is aligned to the ce...
Definition: misc_gui.cpp:1266
WID_GS_SCROLLBAR
@ WID_GS_SCROLLBAR
Scrollbar.
Definition: settings_widget.h:49
WID_CC_PREFIX_EDIT
@ WID_CC_PREFIX_EDIT
Prefix edit button.
Definition: settings_widget.h:67
IntSettingDesc::str_help
StringID str_help
(Translated) string with help text; gui only.
Definition: settings_internal.h:165
QueryString::cancel_button
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
Definition: querystring_gui.h:28
rev.h
WC_GAME_OPTIONS
@ WC_GAME_OPTIONS
Game options window; Window numbers:
Definition: window_type.h:606
CURRENCY_END
@ CURRENCY_END
always the last item
Definition: currency.h:68
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1096
Clamp
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:77
WID_GO_RESOLUTION_DROPDOWN
@ WID_GO_RESOLUTION_DROPDOWN
Dropdown for the resolution.
Definition: settings_widget.h:20
strings_func.h
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:82
main
int CDECL main(int argc, char *argv[])
And the main program (what else?)
Definition: settingsgen.cpp:455
GetTextfile
const char * GetTextfile(TextfileType type, Subdirectory dir, const char *filename)
Search a textfile file next to the given content.
Definition: textfile_gui.cpp:414
LocaleSettings::currency
byte currency
currency we currently use
Definition: settings_type.h:236
WID_GO_BASE_SFX_DROPDOWN
@ WID_GO_BASE_SFX_DROPDOWN
Use to select a base SFX.
Definition: settings_widget.h:29
GRFConfig::name
GRFTextWrapper name
NOSAVE: GRF name (Action 0x08)
Definition: newgrf_config.h:166
WID_GO_BASE_MUSIC_TEXTFILE
@ WID_GO_BASE_MUSIC_TEXTFILE
Open base music readme, changelog (+1) or license (+2).
Definition: settings_widget.h:37
BaseSettingEntry::FindEntry
virtual BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find setting entry at row row_num.
Definition: settings_gui.cpp:986
IntSettingDesc::interval
int32 interval
the interval to use between settings in the 'settings' window. If interval is '0' the interval is dyn...
Definition: settings_internal.h:163
SettingsContainer::UnFoldAll
void UnFoldAll()
Recursively open all folds of sub-pages.
Definition: settings_gui.cpp:1293
Window::CloseChildWindows
void CloseChildWindows(WindowClass wc=WC_INVALID) const
Close all children a window might have in a head-recursive manner.
Definition: window.cpp:1095
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition: widget_type.h:56
SettingsContainer::IsVisible
bool IsVisible(const BaseSettingEntry *item) const
Check whether an entry is visible and not folded or filtered away.
Definition: settings_gui.cpp:1337
WidgetDimensions::hsep_indent
int hsep_indent
Width of identation for tree layouts.
Definition: window_gui.h:65
SettingsPage::GetFoldingState
virtual void GetFoldingState(bool &all_folded, bool &all_unfolded) const
Recursively accumulate the folding state of the (filtered) tree.
Definition: settings_gui.cpp:1466
SettingsContainer::Length
uint Length() const
Return number of rows needed to display the whole page.
Definition: settings_gui.cpp:1346
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:55
SetSettingValue
bool SetSettingValue(const IntSettingDesc *sd, int32 value, bool force_newgame)
Top function to save the new value of an element of the Settings struct.
Definition: settings.cpp:1548
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:206
video_driver.hpp
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1229
GameSettingsWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: settings_gui.cpp:2098
RM_CHANGED_AGAINST_DEFAULT
@ RM_CHANGED_AGAINST_DEFAULT
Show only settings which are different compared to default values.
Definition: settings_gui.cpp:816
SC_BASIC_LIST
@ SC_BASIC_LIST
Settings displayed in the list of basic settings.
Definition: settings_internal.h:46
WID_GO_BASE_SFX_VOLUME
@ WID_GO_BASE_SFX_VOLUME
Change sound effects volume.
Definition: settings_widget.h:30
geometry_func.hpp
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:79
CloseWindowByClass
void CloseWindowByClass(WindowClass cls)
Close all windows of a given class.
Definition: window.cpp:1203
IntSettingDesc::str
StringID str
(translated) string with descriptive text; gui and console
Definition: settings_internal.h:164
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1014
GameSettingsWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: settings_gui.cpp:2023
UpdateAllVirtCoords
void UpdateAllVirtCoords()
Update the viewport coordinates of all signs.
Definition: afterload.cpp:218
StringFilter::ResetState
void ResetState()
Reset the matching state to process a new item.
Definition: stringfilter.cpp:88
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
SettingsPage::UpdateFilterState
virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible)
Update the filter state.
Definition: settings_gui.cpp:1485
_video_hw_accel
bool _video_hw_accel
Whether to consider hardware accelerated video drivers.
Definition: video_driver.cpp:24
NWidgetBase::resize_y
uint resize_y
Vertical resize step (0 means not resizable).
Definition: widget_type.h:189
IntSettingDesc::IsBoolSetting
virtual bool IsBoolSetting() const
Check whether this setting is a boolean type setting.
Definition: settings_internal.h:175
SettingsContainer::FindEntry
BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find the setting entry at row number row_num.
Definition: settings_gui.cpp:1361
Scrollbar::GetPosition
uint16 GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:678
CustomCurrencyWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: settings_gui.cpp:2635
StringFilter::GetState
bool GetState() const
Get the matching state of the current item.
Definition: stringfilter_type.h:69
WidgetDimensions::bevel
RectPadding bevel
Widths of bevel border.
Definition: window_gui.h:45
WID_GO_BASE_MUSIC_STATUS
@ WID_GO_BASE_MUSIC_STATUS
Info about corrupted files etc.
Definition: settings_widget.h:36
SF_GUI_DROPDOWN
@ SF_GUI_DROPDOWN
The value represents a limited number of string-options (internally integer) presented as dropdown.
Definition: settings_internal.h:20
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1791
WID_GS_RESTRICT_DROPDOWN
@ WID_GS_RESTRICT_DROPDOWN
The drop down box to restrict the list of settings.
Definition: settings_widget.h:56
WID_GO_BASE_MUSIC_JUKEBOX
@ WID_GO_BASE_MUSIC_JUKEBOX
Open the jukebox.
Definition: settings_widget.h:35
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:77
WID_GO_VIDEO_VSYNC_BUTTON
@ WID_GO_VIDEO_VSYNC_BUTTON
Toggle for video vsync.
Definition: settings_widget.h:40
GameSettingsWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: settings_gui.cpp:2424
IntSettingDesc::Read
int32 Read(const void *object) const
Read the integer from the the actual setting.
Definition: settings.cpp:519
company_func.h
WL_ERROR
@ WL_ERROR
Errors (eg. saving/loading failed)
Definition: error.h:24
SM_MENU
@ SM_MENU
Switch to game intro menu.
Definition: openttd.h:32
GetCurrentResolutionIndex
static uint GetCurrentResolutionIndex()
Get index of the current screen resolution.
Definition: settings_gui.cpp:69
QueryString::ACTION_CLEAR
static const int ACTION_CLEAR
Clear editbox.
Definition: querystring_gui.h:24
SettingsPage::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:1556
CS_NUMERAL_SIGNED
@ CS_NUMERAL_SIGNED
Only numbers and '-' for negative values.
Definition: string_type.h:30
abs
static T abs(const T a)
Returns the absolute value of (scalar) variable.
Definition: math_func.hpp:21
WidgetDimensions::framerect
RectPadding framerect
Offsets within frame area.
Definition: window_gui.h:47
WID_GO_BASE_GRF_TEXTFILE
@ WID_GO_BASE_GRF_TEXTFILE
Open base GRF readme, changelog (+1) or license (+2).
Definition: settings_widget.h:27
GameOptionsWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: settings_gui.cpp:416
SettingEntry::SetValueDParams
void SetValueDParams(uint first_param, int32 value) const
Set the DParams for drawing the value of a setting.
Definition: settings_gui.cpp:1207
DrawFrameRect
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
Draw frame rectangle.
Definition: widget.cpp:414
network.h
SettingsPage::IsVisible
virtual bool IsVisible(const BaseSettingEntry *item) const
Check whether an entry is visible and not folded or filtered away.
Definition: settings_gui.cpp:1508
SettingsContainer::FoldAll
void FoldAll()
Recursively close all folds of sub-pages.
Definition: settings_gui.cpp:1285
IntSettingDesc::max
uint32 max
maximum values
Definition: settings_internal.h:162
ShowDropDownListAt
void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button, Rect wi_rect, Colours wi_colour, bool auto_width, bool instant_close)
Show a drop down list.
Definition: dropdown.cpp:358
_video_vsync
bool _video_vsync
Whether we should use vsync (only if _video_hw_accel is enabled).
Definition: video_driver.cpp:25
GUISettings::settings_restriction_mode
uint8 settings_restriction_mode
selected restriction mode in adv. settings GUI.
Definition: settings_type.h:195
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:2158
SA_CENTER
@ SA_CENTER
Center both horizontally and vertically.
Definition: gfx_type.h:344
GameSettingsWindow::filter
SettingFilter filter
Filter for the list.
Definition: settings_gui.cpp:1945
SetBit
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
Definition: bitmath_func.hpp:121
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:342
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:386
Window::width
int width
width of the window (number of pixels to the right in x direction)
Definition: window_gui.h:248
MusicSettings::effect_vol
byte effect_vol
The requested effects volume.
Definition: settings_type.h:227
stringfilter_type.h
Scrollbar::SetCapacityFromWidget
void SetCapacityFromWidget(Window *w, int widget, int padding=0)
Set capacity of visible elements from the size and resize properties of a widget.
Definition: widget.cpp:2427
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition: gfx.cpp:1767
GameSettings::locale
LocaleSettings locale
settings related to used currency/unit system in the current game
Definition: settings_type.h:599
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1191
CloseWindowById
void CloseWindowById(WindowClass cls, WindowNumber number, bool force)
Close a window by its class and window number (if it is open).
Definition: window.cpp:1191
NWidgetBase::pos_y
int pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:200
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:974
SettingEntry::SettingEntry
SettingEntry(const char *name)
Constructor for a single setting in the 'advanced settings' window.
Definition: settings_gui.cpp:1063
WID_GO_VIDEO_ACCEL_BUTTON
@ WID_GO_VIDEO_ACCEL_BUTTON
Toggle for video acceleration.
Definition: settings_widget.h:39
SettingFilter
Filter for settings list.
Definition: settings_gui.cpp:823
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:817
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1080
TextfileWindow
Window for displaying a textfile.
Definition: textfile_gui.h:21
WID_CC_PREVIEW
@ WID_CC_PREVIEW
Preview.
Definition: settings_widget.h:74
GameOptionsWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: settings_gui.cpp:630
GetSettingsTree
static SettingsContainer & GetSettingsTree()
Construct settings tree.
Definition: settings_gui.cpp:1591
gui.h
ST_ALL
@ ST_ALL
Used in setting filter to match all types.
Definition: settings_internal.h:66
ClientSettings::company
CompanySettings company
default values for per-company settings
Definition: settings_type.h:606
SettingsContainer
Containers for BaseSettingEntry.
Definition: settings_gui.cpp:904
GameSettingsWindow::closing_dropdown
bool closing_dropdown
True, if the dropdown list is currently closing.
Definition: settings_gui.cpp:1943
BaseSettingEntry::flags
byte flags
Flags of the setting entry.
Definition: settings_gui.cpp:833
Window
Data structure for an opened window.
Definition: window_gui.h:213
TextfileType
TextfileType
Additional text files accompanying Tar archives.
Definition: textfile_type.h:14
WID_GO_BASE_SFX_DESCRIPTION
@ WID_GO_BASE_SFX_DESCRIPTION
Description of selected base SFX.
Definition: settings_widget.h:32
SC_ADVANCED_LIST
@ SC_ADVANCED_LIST
Settings displayed in the list of advanced settings.
Definition: settings_internal.h:47
SettingEntry
Standard setting.
Definition: settings_gui.cpp:871
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:326
SettingsPage::ResetAll
virtual void ResetAll()
Resets all settings to their default values.
Definition: settings_gui.cpp:1436
BaseMedia< GraphicsSet >::GetUsedSet
static const GraphicsSet * GetUsedSet()
Return the used set.
Definition: base_media_func.h:357
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:858
ShowGameSettings
void ShowGameSettings()
Open advanced settings window.
Definition: settings_gui.cpp:2523
WidgetDimensions::frametext
RectPadding frametext
Offsets within a text frame area.
Definition: window_gui.h:48
DrawBoolButton
void DrawBoolButton(int x, int y, bool state, bool clickable)
Draw a toggle button.
Definition: settings_gui.cpp:2591
settings_gui.h
Rect::Width
int Width() const
Get width of Rect.
Definition: geometry_type.hpp:79
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
WID_TF_CAPTION
@ WID_TF_CAPTION
The caption of the window.
Definition: misc_widget.h:51
GUISettings::scale_bevels
bool scale_bevels
bevels are scaled with GUI scale.
Definition: settings_type.h:199
SettingEntry::GetHelpText
StringID GetHelpText() const
Get the help text of a single setting.
Definition: settings_gui.cpp:889
Window::SetWidgetDirty
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:621
WID_GO_CURRENCY_DROPDOWN
@ WID_GO_CURRENCY_DROPDOWN
Currency dropdown.
Definition: settings_widget.h:16
_languages
LanguageList _languages
The actual list of language meta data.
Definition: strings.cpp:46
GetMaskOfAllowedCurrencies
uint64 GetMaskOfAllowedCurrencies()
get a mask of the allowed currencies depending on the year
Definition: currency.cpp:122
BaseSet::GetNumInvalid
int GetNumInvalid() const
Get the number of invalid files.
Definition: base_media_base.h:98
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:69
GameSettingsWindow::manually_changed_folding
bool manually_changed_folding
Whether the user expanded/collapsed something manually.
Definition: settings_gui.cpp:1947
WC_DROPDOWN_MENU
@ WC_DROPDOWN_MENU
Drop down menu; Window numbers:
Definition: window_type.h:149
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:1023
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:2142
AWV_INCREASE
@ AWV_INCREASE
Arrow to the right or in case of RTL to the left.
Definition: widget_type.h:36
SetWindowClassesDirty
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
Definition: window.cpp:3182
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:608
Window::DisableWidget
void DisableWidget(byte widget_index)
Sets a widget to disabled.
Definition: window_gui.h:331
CLRBITS
#define CLRBITS(x, y)
Clears several bits in a variable.
Definition: bitmath_func.hpp:166
WC_TEXTFILE
@ WC_TEXTFILE
textfile; Window numbers:
Definition: window_type.h:180
WHR_NONE
@ WHR_NONE
Nothing was filtering matches away.
Definition: settings_gui.cpp:1915
SettingsContainer::GetFoldingState
void GetFoldingState(bool &all_folded, bool &all_unfolded) const
Recursively accumulate the folding state of the tree.
Definition: settings_gui.cpp:1305
WDP_CENTER
@ WDP_CENTER
Center the window.
Definition: window_gui.h:91
ChangeMusicSet
void ChangeMusicSet(int index)
Change the configured music set and reset playback.
Definition: music_gui.cpp:433
Window::SetWidgetLoweredState
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:382
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:1940
ReadLanguagePack
bool ReadLanguagePack(const LanguageMetadata *lang)
Read a particular language.
Definition: strings.cpp:1784
MusicSettings::music_vol
byte music_vol
The requested music volume.
Definition: settings_type.h:226
GameOptionsWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: settings_gui.cpp:571
_left_button_clicked
bool _left_button_clicked
Is left mouse button clicked?
Definition: gfx.cpp:42
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:49
GameSettingsWindow::OnEditboxChanged
void OnEditboxChanged(int wid) override
The text in an editbox has been edited.
Definition: settings_gui.cpp:2454
_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:61
CS_NUMERAL
@ CS_NUMERAL
Only numeric ones.
Definition: string_type.h:28
SettingsPage::UnFoldAll
virtual void UnFoldAll()
Recursively open all (filtered) folds of sub-pages.
Definition: settings_gui.cpp:1453
CharSetFilter
CharSetFilter
Valid filter types for IsValidChar.
Definition: string_type.h:26
SetupWidgetDimensions
void SetupWidgetDimensions()
Set up pre-scaled versions of Widget Dimensions.
Definition: widget.cpp:199
_currency_specs
CurrencySpec _currency_specs[CURRENCY_END]
Array of currencies used by the system.
Definition: currency.cpp:74
IntSettingDesc::def
int32 def
default value given when none is present
Definition: settings_internal.h:160
GameSettingsWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: settings_gui.cpp:2148
StringFilter
String filter and state.
Definition: stringfilter_type.h:31
GameOptionsWindow::SetMediaSet
void SetMediaSet(int index)
Set the base media set.
Definition: settings_gui.cpp:558
SetDParamStr
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
Definition: strings.cpp:297
CURRENCY_CUSTOM
@ CURRENCY_CUSTOM
Custom currency.
Definition: currency.h:57
_settings_newgame
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
Definition: settings.cpp:55
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:53
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:604
WID_GS_TYPE_DROPDOWN
@ WID_GS_TYPE_DROPDOWN
The drop down box to choose client/game/company/all settings.
Definition: settings_widget.h:57
GameOptionsWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: settings_gui.cpp:350
mixer.h
AWV_DECREASE
@ AWV_DECREASE
Arrow to the left or in case of RTL to the right.
Definition: widget_type.h:35
SetMinimalTextLines
static NWidgetPart SetMinimalTextLines(uint8 lines, uint8 spacing, FontSize size=FS_NORMAL)
Widget part function for setting the minimal text lines.
Definition: widget_type.h:1032
WWT_DROPDOWN
@ WWT_DROPDOWN
Drop down list.
Definition: widget_type.h:68
SettingDesc::AsIntSetting
const struct IntSettingDesc * AsIntSetting() const
Get the setting description of this setting as an integer setting.
Definition: settings.cpp:833
WID_CC_SUFFIX
@ WID_CC_SUFFIX
Current suffix.
Definition: settings_widget.h:70
BaseSettingEntry::IsFiltered
bool IsFiltered() const
Check whether an entry is hidden due to filters.
Definition: settings_gui.cpp:860
MAX_YEAR
static const Year MAX_YEAR
MAX_YEAR, nicely rounded value of the number of years that can be encoded in a single 32 bits date,...
Definition: date_type.h:95
RM_ADVANCED
@ RM_ADVANCED
Display settings associated to the "advanced" list.
Definition: settings_gui.cpp:814
WN_GAME_OPTIONS_GAME_SETTINGS
@ WN_GAME_OPTIONS_GAME_SETTINGS
Game settings.
Definition: window_type.h:20
Window::Close
virtual void Close()
Hide the window and all its child windows, and mark them for a later deletion.
Definition: window.cpp:1107
ShowGameOptions
void ShowGameOptions()
Open the game options window.
Definition: settings_gui.cpp:790
SettingEntryFlags
SettingEntryFlags
Flags for SettingEntry.
Definition: settings_gui.cpp:802
DropDownListStringItem::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.cpp:54
WidgetDimensions::vsep_normal
int vsep_normal
Normal vertical spacing.
Definition: window_gui.h:61