OpenTTD Source  13.0-beta1
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 
43 #include <vector>
44 #include <iterator>
45 
46 #include "safeguards.h"
47 #include "video/video_driver.hpp"
48 
49 
50 static const StringID _autosave_dropdown[] = {
51  STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_OFF,
52  STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_1_MONTH,
53  STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_3_MONTHS,
54  STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_6_MONTHS,
55  STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_12_MONTHS,
57 };
58 
59 static const StringID _gui_zoom_dropdown[] = {
60  STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_AUTO,
61  STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_NORMAL,
62  STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_2X_ZOOM,
63  STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_4X_ZOOM,
65 };
66 
67 static const StringID _font_zoom_dropdown[] = {
68  STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_AUTO,
69  STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_NORMAL,
70  STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_2X_ZOOM,
71  STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_4X_ZOOM,
73 };
74 
76 
77 static const void *ResolveObject(const GameSettings *settings_ptr, const IntSettingDesc *sd);
78 
84 {
85  auto it = std::find(_resolutions.begin(), _resolutions.end(), Dimension(_screen.width, _screen.height));
86  return std::distance(_resolutions.begin(), it);
87 }
88 
89 static void ShowCustCurrency();
90 
91 template <class T>
92 static DropDownList BuildSetDropDownList(int *selected_index, bool allow_selection)
93 {
94  int n = T::GetNumSets();
95  *selected_index = T::GetIndexOfUsedSet();
96 
97  DropDownList list;
98  for (int i = 0; i < n; i++) {
99  list.emplace_back(new DropDownListCharStringItem(T::GetSet(i)->name, i, !allow_selection && (*selected_index != i)));
100  }
101 
102  return list;
103 }
104 
105 DropDownList BuildMusicSetDropDownList(int *selected_index)
106 {
107  return BuildSetDropDownList<BaseMusic>(selected_index, true);
108 }
109 
111 template <class TBaseSet>
113  const TBaseSet* baseset;
115 
117  {
118  const char *textfile = this->baseset->GetTextfile(file_type);
119  this->LoadTextfile(textfile, BASESET_DIR);
120  }
121 
122  void SetStringParameters(int widget) const override
123  {
124  if (widget == WID_TF_CAPTION) {
126  SetDParamStr(1, this->baseset->name);
127  }
128  }
129 };
130 
137 template <class TBaseSet>
138 void ShowBaseSetTextfileWindow(TextfileType file_type, const TBaseSet* baseset, StringID content_type)
139 {
140  CloseWindowById(WC_TEXTFILE, file_type);
141  new BaseSetTextfileWindow<TBaseSet>(file_type, baseset, content_type);
142 }
143 
144 std::set<int> _refresh_rates = { 30, 60, 75, 90, 100, 120, 144, 240 };
145 
151 {
152  /* Add the refresh rate as selected in the config. */
153  _refresh_rates.insert(_settings_client.gui.refresh_rate);
154 
155  /* Add all the refresh rates of all monitors connected to the machine. */
156  std::vector<int> monitorRates = VideoDriver::GetInstance()->GetListOfMonitorRefreshRates();
157  std::copy(monitorRates.begin(), monitorRates.end(), std::inserter(_refresh_rates, _refresh_rates.end()));
158 }
159 
161  GameSettings *opt;
162  bool reload;
163 
164  GameOptionsWindow(WindowDesc *desc) : Window(desc)
165  {
166  this->opt = &GetGameSettings();
167  this->reload = false;
168 
170 
172  this->OnInvalidateData(0);
173  }
174 
175  void Close() override
176  {
179  if (this->reload) _switch_mode = SM_MENU;
180  this->Window::Close();
181  }
182 
189  DropDownList BuildDropDownList(int widget, int *selected_index) const
190  {
191  DropDownList list;
192  switch (widget) {
193  case WID_GO_CURRENCY_DROPDOWN: { // Setup currencies dropdown
194  *selected_index = this->opt->locale.currency;
195  StringID *items = BuildCurrencyDropdown();
196  uint64 disabled = _game_mode == GM_MENU ? 0LL : ~GetMaskOfAllowedCurrencies();
197 
198  /* Add non-custom currencies; sorted naturally */
199  for (uint i = 0; i < CURRENCY_END; items++, i++) {
200  if (i == CURRENCY_CUSTOM) continue;
201  list.emplace_back(new DropDownListStringItem(*items, i, HasBit(disabled, i)));
202  }
203  std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
204 
205  /* Append custom currency at the end */
206  list.emplace_back(new DropDownListItem(-1, false)); // separator line
207  list.emplace_back(new DropDownListStringItem(STR_GAME_OPTIONS_CURRENCY_CUSTOM, CURRENCY_CUSTOM, HasBit(disabled, CURRENCY_CUSTOM)));
208  break;
209  }
210 
211  case WID_GO_AUTOSAVE_DROPDOWN: { // Setup autosave dropdown
212  *selected_index = _settings_client.gui.autosave;
213  const StringID *items = _autosave_dropdown;
214  for (uint i = 0; *items != INVALID_STRING_ID; items++, i++) {
215  list.emplace_back(new DropDownListStringItem(*items, i, false));
216  }
217  break;
218  }
219 
220  case WID_GO_LANG_DROPDOWN: { // Setup interface language dropdown
221  for (uint i = 0; i < _languages.size(); i++) {
222  bool hide_language = IsReleasedVersion() && !_languages[i].IsReasonablyFinished();
223  if (hide_language) continue;
224  bool hide_percentage = IsReleasedVersion() || _languages[i].missing < _settings_client.gui.missing_strings_threshold;
225  auto item = new DropDownListParamStringItem(hide_percentage ? STR_JUST_RAW_STRING : STR_GAME_OPTIONS_LANGUAGE_PERCENTAGE, i, false);
226  if (&_languages[i] == _current_language) {
227  *selected_index = i;
228  item->SetParamStr(0, _languages[i].own_name);
229  } else {
230  /* Especially with sprite-fonts, not all localized
231  * names can be rendered. So instead, we use the
232  * international names for anything but the current
233  * selected language. This avoids showing a few ????
234  * entries in the dropdown list. */
235  item->SetParamStr(0, _languages[i].name);
236  }
237  item->SetParam(1, (LANGUAGE_TOTAL_STRINGS - _languages[i].missing) * 100 / LANGUAGE_TOTAL_STRINGS);
238  list.emplace_back(item);
239  }
240  std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
241  break;
242  }
243 
244  case WID_GO_RESOLUTION_DROPDOWN: // Setup resolution dropdown
245  if (_resolutions.empty()) break;
246 
247  *selected_index = GetCurrentResolutionIndex();
248  for (uint i = 0; i < _resolutions.size(); i++) {
249  auto item = new DropDownListParamStringItem(STR_GAME_OPTIONS_RESOLUTION_ITEM, i, false);
250  item->SetParam(0, _resolutions[i].width);
251  item->SetParam(1, _resolutions[i].height);
252  list.emplace_back(item);
253  }
254  break;
255 
256  case WID_GO_REFRESH_RATE_DROPDOWN: // Setup refresh rate dropdown
257  for (auto it = _refresh_rates.begin(); it != _refresh_rates.end(); it++) {
258  auto i = std::distance(_refresh_rates.begin(), it);
259  if (*it == _settings_client.gui.refresh_rate) *selected_index = i;
260  auto item = new DropDownListParamStringItem(STR_GAME_OPTIONS_REFRESH_RATE_ITEM, i, false);
261  item->SetParam(0, *it);
262  list.emplace_back(item);
263  }
264  break;
265 
267  *selected_index = _gui_zoom_cfg != ZOOM_LVL_CFG_AUTO ? ZOOM_LVL_OUT_4X - _gui_zoom + 1 : 0;
268  const StringID *items = _gui_zoom_dropdown;
269  for (int i = 0; *items != INVALID_STRING_ID; items++, i++) {
270  list.emplace_back(new DropDownListStringItem(*items, i, i != 0 && _settings_client.gui.zoom_min > ZOOM_LVL_OUT_4X - i + 1));
271  }
272  break;
273  }
274 
276  *selected_index = _font_zoom_cfg != ZOOM_LVL_CFG_AUTO ? ZOOM_LVL_OUT_4X - _font_zoom + 1 : 0;
277  const StringID *items = _font_zoom_dropdown;
278  for (int i = 0; *items != INVALID_STRING_ID; items++, i++) {
279  list.emplace_back(new DropDownListStringItem(*items, i, false));
280  }
281  break;
282  }
283 
285  list = BuildSetDropDownList<BaseGraphics>(selected_index, (_game_mode == GM_MENU));
286  break;
287 
289  list = BuildSetDropDownList<BaseSounds>(selected_index, (_game_mode == GM_MENU));
290  break;
291 
293  list = BuildMusicSetDropDownList(selected_index);
294  break;
295  }
296 
297  return list;
298  }
299 
300  void SetStringParameters(int widget) const override
301  {
302  switch (widget) {
303  case WID_GO_CURRENCY_DROPDOWN: SetDParam(0, _currency_specs[this->opt->locale.currency].name); break;
304  case WID_GO_AUTOSAVE_DROPDOWN: SetDParam(0, _autosave_dropdown[_settings_client.gui.autosave]); break;
306  case WID_GO_GUI_ZOOM_DROPDOWN: SetDParam(0, _gui_zoom_dropdown[_gui_zoom_cfg != ZOOM_LVL_CFG_AUTO ? ZOOM_LVL_OUT_4X - _gui_zoom_cfg + 1 : 0]); break;
307  case WID_GO_FONT_ZOOM_DROPDOWN: SetDParam(0, _font_zoom_dropdown[_font_zoom_cfg != ZOOM_LVL_CFG_AUTO ? ZOOM_LVL_OUT_4X - _font_zoom_cfg + 1 : 0]); break;
309  case WID_GO_BASE_GRF_STATUS: SetDParam(0, BaseGraphics::GetUsedSet()->GetNumInvalid()); break;
312  case WID_GO_BASE_MUSIC_STATUS: SetDParam(0, BaseMusic::GetUsedSet()->GetNumInvalid()); break;
313  case WID_GO_VIDEO_DRIVER_INFO: SetDParamStr(0, VideoDriver::GetInstance()->GetInfoString()); break;
316  auto current_resolution = GetCurrentResolutionIndex();
317 
318  if (current_resolution == _resolutions.size()) {
319  SetDParam(0, STR_GAME_OPTIONS_RESOLUTION_OTHER);
320  } else {
321  SetDParam(0, STR_GAME_OPTIONS_RESOLUTION_ITEM);
322  SetDParam(1, _resolutions[current_resolution].width);
323  SetDParam(2, _resolutions[current_resolution].height);
324  }
325  break;
326  }
327  }
328  }
329 
330  void DrawWidget(const Rect &r, int widget) const override
331  {
332  switch (widget) {
335  DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_BLACK_RAW_STRING);
336  break;
337 
340  DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_BLACK_RAW_STRING);
341  break;
342 
345  DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_BLACK_RAW_STRING);
346  break;
347 
350  break;
351 
354  break;
355  }
356  }
357 
358  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
359  {
360  switch (widget) {
362  /* Find the biggest description for the default size. */
363  for (int i = 0; i < BaseGraphics::GetNumSets(); i++) {
365  size->height = std::max(size->height, (uint)GetStringHeight(STR_BLACK_RAW_STRING, size->width));
366  }
367  break;
368 
370  /* Find the biggest description for the default size. */
371  for (int i = 0; i < BaseGraphics::GetNumSets(); i++) {
372  uint invalid_files = BaseGraphics::GetSet(i)->GetNumInvalid();
373  if (invalid_files == 0) continue;
374 
375  SetDParam(0, invalid_files);
376  *size = maxdim(*size, GetStringBoundingBox(STR_GAME_OPTIONS_BASE_GRF_STATUS));
377  }
378  break;
379 
381  /* Find the biggest description for the default size. */
382  for (int i = 0; i < BaseSounds::GetNumSets(); i++) {
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  SetDParamStr(0, BaseMusic::GetSet(i)->GetDescription(GetCurrentLanguageIsoCode()));
392  size->height = std::max(size->height, (uint)GetStringHeight(STR_BLACK_RAW_STRING, size->width));
393  }
394  break;
395 
397  /* Find the biggest description for the default size. */
398  for (int i = 0; i < BaseMusic::GetNumSets(); i++) {
399  uint invalid_files = BaseMusic::GetSet(i)->GetNumInvalid();
400  if (invalid_files == 0) continue;
401 
402  SetDParam(0, invalid_files);
403  *size = maxdim(*size, GetStringBoundingBox(STR_GAME_OPTIONS_BASE_MUSIC_STATUS));
404  }
405  break;
406 
407  default: {
408  int selected;
409  DropDownList list = this->BuildDropDownList(widget, &selected);
410  if (!list.empty()) {
411  /* Find the biggest item for the default size. */
412  for (const auto &ddli : list) {
413  Dimension string_dim;
414  int width = ddli->Width();
415  string_dim.width = width + padding.width;
416  string_dim.height = ddli->Height(width) + padding.height;
417  *size = maxdim(*size, string_dim);
418  }
419  }
420  }
421  }
422  }
423 
424  void OnClick(Point pt, int widget, int click_count) override
425  {
426  if (widget >= WID_GO_BASE_GRF_TEXTFILE && widget < WID_GO_BASE_GRF_TEXTFILE + TFT_END) {
427  if (BaseGraphics::GetUsedSet() == nullptr) return;
428 
429  ShowBaseSetTextfileWindow((TextfileType)(widget - WID_GO_BASE_GRF_TEXTFILE), BaseGraphics::GetUsedSet(), STR_CONTENT_TYPE_BASE_GRAPHICS);
430  return;
431  }
432  if (widget >= WID_GO_BASE_SFX_TEXTFILE && widget < WID_GO_BASE_SFX_TEXTFILE + TFT_END) {
433  if (BaseSounds::GetUsedSet() == nullptr) return;
434 
435  ShowBaseSetTextfileWindow((TextfileType)(widget - WID_GO_BASE_SFX_TEXTFILE), BaseSounds::GetUsedSet(), STR_CONTENT_TYPE_BASE_SOUNDS);
436  return;
437  }
438  if (widget >= WID_GO_BASE_MUSIC_TEXTFILE && widget < WID_GO_BASE_MUSIC_TEXTFILE + TFT_END) {
439  if (BaseMusic::GetUsedSet() == nullptr) return;
440 
441  ShowBaseSetTextfileWindow((TextfileType)(widget - WID_GO_BASE_MUSIC_TEXTFILE), BaseMusic::GetUsedSet(), STR_CONTENT_TYPE_BASE_MUSIC);
442  return;
443  }
444  switch (widget) {
445  case WID_GO_FULLSCREEN_BUTTON: // Click fullscreen on/off
446  /* try to toggle full-screen on/off */
447  if (!ToggleFullScreen(!_fullscreen)) {
448  ShowErrorMessage(STR_ERROR_FULLSCREEN_FAILED, INVALID_STRING_ID, WL_ERROR);
449  }
452  break;
453 
456  ShowErrorMessage(STR_GAME_OPTIONS_VIDEO_ACCELERATION_RESTART, INVALID_STRING_ID, WL_INFO);
459 #ifndef __APPLE__
462 #endif
463  break;
464 
466  if (!_video_hw_accel) break;
467 
470 
475  break;
476 
480  if (ClickVolumeSliderWidget(this->GetWidget<NWidgetBase>(widget)->GetCurrentRect(), pt, vol)) {
482  this->SetWidgetDirty(widget);
484  }
485 
486  if (click_count > 0) this->mouse_capture_widget = widget;
487  break;
488  }
489 
490  default: {
491  int selected;
492  DropDownList list = this->BuildDropDownList(widget, &selected);
493  if (!list.empty()) {
494  ShowDropDownList(this, std::move(list), selected, widget);
495  } else {
496  if (widget == WID_GO_RESOLUTION_DROPDOWN) ShowErrorMessage(STR_ERROR_RESOLUTION_LIST_FAILED, INVALID_STRING_ID, WL_ERROR);
497  }
498  break;
499  }
500  }
501  }
502 
508  template <class T>
509  void SetMediaSet(int index)
510  {
511  if (_game_mode == GM_MENU) {
512  auto name = T::GetSet(index)->name;
513 
514  T::ini_set = name;
515 
516  T::SetSet(name);
517  this->reload = true;
518  this->InvalidateData();
519  }
520  }
521 
522  void OnDropdownSelect(int widget, int index) override
523  {
524  switch (widget) {
525  case WID_GO_CURRENCY_DROPDOWN: // Currency
526  if (index == CURRENCY_CUSTOM) ShowCustCurrency();
527  this->opt->locale.currency = index;
528  ReInitAllWindows(false);
529  break;
530 
531  case WID_GO_AUTOSAVE_DROPDOWN: // Autosave options
532  _settings_client.gui.autosave = index;
533  this->SetDirty();
534  break;
535 
536  case WID_GO_LANG_DROPDOWN: // Change interface language
537  ReadLanguagePack(&_languages[index]);
540  ClearAllCachedNames();
542  CheckBlitter();
543  ReInitAllWindows(false);
544  break;
545 
546  case WID_GO_RESOLUTION_DROPDOWN: // Change resolution
547  if ((uint)index < _resolutions.size() && ChangeResInGame(_resolutions[index].width, _resolutions[index].height)) {
548  this->SetDirty();
549  }
550  break;
551 
553  _settings_client.gui.refresh_rate = *std::next(_refresh_rates.begin(), index);
554  if (_settings_client.gui.refresh_rate > 60) {
555  /* Show warning to the user that this refresh rate might not be suitable on
556  * larger maps with many NewGRFs and vehicles. */
557  ShowErrorMessage(STR_GAME_OPTIONS_REFRESH_RATE_WARNING, INVALID_STRING_ID, WL_INFO);
558  }
559  break;
560  }
561 
563  int8 new_zoom = index > 0 ? ZOOM_LVL_OUT_4X - index + 1 : ZOOM_LVL_CFG_AUTO;
564  if (new_zoom != _gui_zoom_cfg) {
566  _gui_zoom_cfg = new_zoom;
567  UpdateGUIZoom();
570  FixTitleGameZoom();
571  ReInitAllWindows(true);
572  }
573  break;
574  }
575 
577  int8 new_zoom = index > 0 ? ZOOM_LVL_OUT_4X - index + 1 : ZOOM_LVL_CFG_AUTO;
578  if (new_zoom != _font_zoom_cfg) {
580  _font_zoom_cfg = new_zoom;
581  UpdateGUIZoom();
582  ClearFontCache();
585  ReInitAllWindows(true);
586  }
587  break;
588  }
589 
591  this->SetMediaSet<BaseGraphics>(index);
592  break;
593 
595  this->SetMediaSet<BaseSounds>(index);
596  break;
597 
599  ChangeMusicSet(index);
600  break;
601  }
602  }
603 
609  void OnInvalidateData(int data = 0, bool gui_scope = true) override
610  {
611  if (!gui_scope) return;
615 
616 #ifndef __APPLE__
619 #endif
620 
621  bool missing_files = BaseGraphics::GetUsedSet()->GetNumMissing() == 0;
622  this->GetWidget<NWidgetCore>(WID_GO_BASE_GRF_STATUS)->SetDataTip(missing_files ? STR_EMPTY : STR_GAME_OPTIONS_BASE_GRF_STATUS, STR_NULL);
623 
624  for (TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) {
628  }
629 
630  missing_files = BaseMusic::GetUsedSet()->GetNumInvalid() == 0;
631  this->GetWidget<NWidgetCore>(WID_GO_BASE_MUSIC_STATUS)->SetDataTip(missing_files ? STR_EMPTY : STR_GAME_OPTIONS_BASE_MUSIC_STATUS, STR_NULL);
632  }
633 };
634 
635 static const NWidgetPart _nested_game_options_widgets[] = {
637  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
638  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
639  EndContainer(),
640  NWidget(WWT_PANEL, COLOUR_GREY, WID_GO_BACKGROUND), SetPIP(6, 6, 10),
641  NWidget(NWID_HORIZONTAL), SetPIP(10, 10, 10),
642  NWidget(NWID_VERTICAL), SetPIP(0, 6, 0),
643  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_AUTOSAVE_FRAME, STR_NULL),
644  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),
645  EndContainer(),
646  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_GUI_ZOOM_FRAME, STR_NULL),
647  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_GUI_ZOOM_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_TOOLTIP), SetFill(1, 0),
648  EndContainer(),
649  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_CURRENCY_UNITS_FRAME, STR_NULL),
650  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),
651  EndContainer(),
652  EndContainer(),
653 
654  NWidget(NWID_VERTICAL), SetPIP(0, 6, 0),
655  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_LANGUAGE, STR_NULL),
656  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),
657  EndContainer(),
658  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_FONT_ZOOM, STR_NULL),
659  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_FONT_ZOOM_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_TOOLTIP), SetFill(1, 0),
660  EndContainer(),
661  EndContainer(),
662  EndContainer(),
663 
664  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_GRAPHICS, STR_NULL), SetPadding(0, 10, 0, 10),
666  NWidget(NWID_VERTICAL), SetPIP(0, 2, 0),
668  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12),SetDataTip(STR_GAME_OPTIONS_RESOLUTION, STR_NULL),
669  NWidget(NWID_SPACER), SetMinimalSize(1, 0), SetFill(1, 0),
670  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_RESOLUTION_DROPDOWN), SetMinimalSize(200, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_RESOLUTION_TOOLTIP),
671  EndContainer(),
673  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetDataTip(STR_GAME_OPTIONS_REFRESH_RATE, STR_NULL),
674  NWidget(NWID_SPACER), SetMinimalSize(1, 0), SetFill(1, 0),
675  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),
676  EndContainer(),
678  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetDataTip(STR_GAME_OPTIONS_FULLSCREEN, STR_NULL),
679  NWidget(NWID_SPACER), SetMinimalSize(1, 0), SetFill(1, 0),
680  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_FULLSCREEN_BUTTON), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_FULLSCREEN_TOOLTIP),
681  EndContainer(),
683  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetDataTip(STR_GAME_OPTIONS_VIDEO_ACCELERATION, STR_NULL),
684  NWidget(NWID_SPACER), SetMinimalSize(1, 0), SetFill(1, 0),
685  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_VIDEO_ACCEL_BUTTON), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_VIDEO_ACCELERATION_TOOLTIP),
686  EndContainer(),
687 #ifndef __APPLE__
689  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetDataTip(STR_GAME_OPTIONS_VIDEO_VSYNC, STR_NULL),
690  NWidget(NWID_SPACER), SetMinimalSize(1, 0), SetFill(1, 0),
691  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_VIDEO_VSYNC_BUTTON), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_VIDEO_VSYNC_TOOLTIP),
692  EndContainer(),
693 #endif
695  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),
696  EndContainer(),
697  EndContainer(),
698  EndContainer(),
699  EndContainer(),
700 
701  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_BASE_GRF, STR_NULL), SetPadding(0, 10, 0, 10),
702  NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 0),
703  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_GRF_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_RAW_STRING, STR_GAME_OPTIONS_BASE_GRF_TOOLTIP),
704  NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_BASE_GRF_STATUS), SetMinimalSize(150, 12), SetDataTip(STR_EMPTY, STR_NULL), SetFill(1, 0),
705  EndContainer(),
706  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),
708  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),
709  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),
710  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),
711  EndContainer(),
712  EndContainer(),
713 
714  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_BASE_SFX, STR_NULL), SetPadding(0, 10, 0, 10),
715  NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 7),
716  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_SFX_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_RAW_STRING, STR_GAME_OPTIONS_BASE_SFX_TOOLTIP),
717  NWidget(NWID_SPACER), SetMinimalSize(150, 12), SetFill(1, 0),
718  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),
719  EndContainer(),
720  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),
722  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),
723  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),
724  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),
725  EndContainer(),
726  EndContainer(),
727 
728  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_BASE_MUSIC, STR_NULL), SetPadding(0, 10, 0, 10),
729  NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 7),
730  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_MUSIC_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_RAW_STRING, STR_GAME_OPTIONS_BASE_MUSIC_TOOLTIP),
731  NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_BASE_MUSIC_STATUS), SetMinimalSize(150, 12), SetDataTip(STR_EMPTY, STR_NULL), SetFill(1, 0),
732  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),
733  EndContainer(),
734  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),
736  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),
737  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),
738  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),
739  EndContainer(),
740  EndContainer(),
741  EndContainer(),
742 };
743 
744 static WindowDesc _game_options_desc(
745  WDP_CENTER, "settings_game", 0, 0,
747  0,
748  _nested_game_options_widgets, lengthof(_nested_game_options_widgets)
749 );
750 
753 {
755  new GameOptionsWindow(&_game_options_desc);
756 }
757 
758 static int SETTING_HEIGHT = 11;
759 static const int LEVEL_WIDTH = 15;
760 
769 
770  SEF_LAST_FIELD = 0x04,
771  SEF_FILTERED = 0x08,
772 };
773 
782 };
784 
785 
789  bool type_hides;
792 };
793 
796  byte flags;
797  byte level;
798 
799  BaseSettingEntry() : flags(0), level(0) {}
800  virtual ~BaseSettingEntry() {}
801 
802  virtual void Init(byte level = 0);
803  virtual void FoldAll() {}
804  virtual void UnFoldAll() {}
805  virtual void ResetAll() = 0;
806 
811  void SetLastField(bool last_field) { if (last_field) SETBITS(this->flags, SEF_LAST_FIELD); else CLRBITS(this->flags, SEF_LAST_FIELD); }
812 
813  virtual uint Length() const = 0;
814  virtual void GetFoldingState(bool &all_folded, bool &all_unfolded) const {}
815  virtual bool IsVisible(const BaseSettingEntry *item) const;
816  virtual BaseSettingEntry *FindEntry(uint row, uint *cur_row);
817  virtual uint GetMaxHelpHeight(int maxw) { return 0; }
818 
823  bool IsFiltered() const { return (this->flags & SEF_FILTERED) != 0; }
824 
825  virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible) = 0;
826 
827  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;
828 
829 protected:
830  virtual void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const = 0;
831 };
832 
835  const char *name;
837 
838  SettingEntry(const char *name);
839 
840  virtual void Init(byte level = 0);
841  virtual void ResetAll();
842  virtual uint Length() const;
843  virtual uint GetMaxHelpHeight(int maxw);
844  virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible);
845 
846  void SetButtons(byte new_val);
847 
852  inline StringID GetHelpText() const
853  {
854  return this->setting->str_help;
855  }
856 
857  void SetValueDParams(uint first_param, int32 value) const;
858 
859 protected:
860  virtual void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const;
861 
862 private:
864 };
865 
868  typedef std::vector<BaseSettingEntry*> EntryVector;
869  EntryVector entries;
870 
871  template<typename T>
872  T *Add(T *item)
873  {
874  this->entries.push_back(item);
875  return item;
876  }
877 
878  void Init(byte level = 0);
879  void ResetAll();
880  void FoldAll();
881  void UnFoldAll();
882 
883  uint Length() const;
884  void GetFoldingState(bool &all_folded, bool &all_unfolded) const;
885  bool IsVisible(const BaseSettingEntry *item) const;
886  BaseSettingEntry *FindEntry(uint row, uint *cur_row);
887  uint GetMaxHelpHeight(int maxw);
888 
889  bool UpdateFilterState(SettingFilter &filter, bool force_visible);
890 
891  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;
892 };
893 
897  bool folded;
898 
900 
901  virtual void Init(byte level = 0);
902  virtual void ResetAll();
903  virtual void FoldAll();
904  virtual void UnFoldAll();
905 
906  virtual uint Length() const;
907  virtual void GetFoldingState(bool &all_folded, bool &all_unfolded) const;
908  virtual bool IsVisible(const BaseSettingEntry *item) const;
909  virtual BaseSettingEntry *FindEntry(uint row, uint *cur_row);
910  virtual uint GetMaxHelpHeight(int maxw) { return SettingsContainer::GetMaxHelpHeight(maxw); }
911 
912  virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible);
913 
914  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;
915 
916 protected:
917  virtual void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const;
918 };
919 
920 /* == BaseSettingEntry methods == */
921 
926 void BaseSettingEntry::Init(byte level)
927 {
928  this->level = level;
929 }
930 
938 {
939  if (this->IsFiltered()) return false;
940  return this == item;
941 }
942 
949 BaseSettingEntry *BaseSettingEntry::FindEntry(uint row_num, uint *cur_row)
950 {
951  if (this->IsFiltered()) return nullptr;
952  if (row_num == *cur_row) return this;
953  (*cur_row)++;
954  return nullptr;
955 }
956 
986 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
987 {
988  if (this->IsFiltered()) return cur_row;
989  if (cur_row >= max_row) return cur_row;
990 
991  bool rtl = _current_text_dir == TD_RTL;
992  int offset = rtl ? -4 : 4;
993  int level_width = rtl ? -LEVEL_WIDTH : LEVEL_WIDTH;
994 
995  int x = rtl ? right : left;
996  if (cur_row >= first_row) {
997  int colour = _colour_gradient[COLOUR_ORANGE][4];
998  y += (cur_row - first_row) * SETTING_HEIGHT; // Compute correct y start position
999 
1000  /* Draw vertical for parent nesting levels */
1001  for (uint lvl = 0; lvl < this->level; lvl++) {
1002  if (!HasBit(parent_last, lvl)) GfxDrawLine(x + offset, y, x + offset, y + SETTING_HEIGHT - 1, colour);
1003  x += level_width;
1004  }
1005  /* draw own |- prefix */
1006  int halfway_y = y + SETTING_HEIGHT / 2;
1007  int bottom_y = (flags & SEF_LAST_FIELD) ? halfway_y : y + SETTING_HEIGHT - 1;
1008  GfxDrawLine(x + offset, y, x + offset, bottom_y, colour);
1009  /* Small horizontal line from the last vertical line */
1010  GfxDrawLine(x + offset, halfway_y, x + level_width - offset, halfway_y, colour);
1011  x += level_width;
1012 
1013  this->DrawSetting(settings_ptr, rtl ? left : x, rtl ? x : right, y, this == selected);
1014  }
1015  cur_row++;
1016 
1017  return cur_row;
1018 }
1019 
1020 /* == SettingEntry methods == */
1021 
1027 {
1028  this->name = name;
1029  this->setting = nullptr;
1030 }
1031 
1036 void SettingEntry::Init(byte level)
1037 {
1039  this->setting = GetSettingFromName(this->name)->AsIntSetting();
1040 }
1041 
1042 /* Sets the given setting entry to its default value */
1043 void SettingEntry::ResetAll()
1044 {
1045  SetSettingValue(this->setting, this->setting->def);
1046 }
1047 
1053 void SettingEntry::SetButtons(byte new_val)
1054 {
1055  assert((new_val & ~SEF_BUTTONS_MASK) == 0); // Should not touch any flags outside the buttons
1056  this->flags = (this->flags & ~SEF_BUTTONS_MASK) | new_val;
1057 }
1058 
1061 {
1062  return this->IsFiltered() ? 0 : 1;
1063 }
1064 
1071 {
1072  return GetStringHeight(this->GetHelpText(), maxw);
1073 }
1074 
1081 {
1082  /* There shall not be any restriction, i.e. all settings shall be visible. */
1083  if (mode == RM_ALL) return true;
1084 
1085  const IntSettingDesc *sd = this->setting;
1086 
1087  if (mode == RM_BASIC) return (this->setting->cat & SC_BASIC_LIST) != 0;
1088  if (mode == RM_ADVANCED) return (this->setting->cat & SC_ADVANCED_LIST) != 0;
1089 
1090  /* Read the current value. */
1091  const void *object = ResolveObject(&GetGameSettings(), sd);
1092  int64 current_value = sd->Read(object);
1093  int64 filter_value;
1094 
1095  if (mode == RM_CHANGED_AGAINST_DEFAULT) {
1096  /* This entry shall only be visible, if the value deviates from its default value. */
1097 
1098  /* Read the default value. */
1099  filter_value = sd->def;
1100  } else {
1101  assert(mode == RM_CHANGED_AGAINST_NEW);
1102  /* This entry shall only be visible, if the value deviates from
1103  * its value is used when starting a new game. */
1104 
1105  /* Make sure we're not comparing the new game settings against itself. */
1106  assert(&GetGameSettings() != &_settings_newgame);
1107 
1108  /* Read the new game's value. */
1109  filter_value = sd->Read(ResolveObject(&_settings_newgame, sd));
1110  }
1111 
1112  return current_value != filter_value;
1113 }
1114 
1121 bool SettingEntry::UpdateFilterState(SettingFilter &filter, bool force_visible)
1122 {
1123  CLRBITS(this->flags, SEF_FILTERED);
1124 
1125  bool visible = true;
1126 
1127  const IntSettingDesc *sd = this->setting;
1128  if (!force_visible && !filter.string.IsEmpty()) {
1129  /* Process the search text filter for this item. */
1130  filter.string.ResetState();
1131 
1132  SetDParam(0, STR_EMPTY);
1133  filter.string.AddLine(sd->str);
1134  filter.string.AddLine(this->GetHelpText());
1135 
1136  visible = filter.string.GetState();
1137  }
1138 
1139  if (visible) {
1140  if (filter.type != ST_ALL && sd->GetType() != filter.type) {
1141  filter.type_hides = true;
1142  visible = false;
1143  }
1144  if (!this->IsVisibleByRestrictionMode(filter.mode)) {
1145  while (filter.min_cat < RM_ALL && (filter.min_cat == filter.mode || !this->IsVisibleByRestrictionMode(filter.min_cat))) filter.min_cat++;
1146  visible = false;
1147  }
1148  }
1149 
1150  if (!visible) SETBITS(this->flags, SEF_FILTERED);
1151  return visible;
1152 }
1153 
1154 static const void *ResolveObject(const GameSettings *settings_ptr, const IntSettingDesc *sd)
1155 {
1156  if ((sd->flags & SF_PER_COMPANY) != 0) {
1157  if (Company::IsValidID(_local_company) && _game_mode != GM_MENU) {
1158  return &Company::Get(_local_company)->settings;
1159  }
1160  return &_settings_client.company;
1161  }
1162  return settings_ptr;
1163 }
1164 
1170 void SettingEntry::SetValueDParams(uint first_param, int32 value) const
1171 {
1172  if (this->setting->IsBoolSetting()) {
1173  SetDParam(first_param++, value != 0 ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
1174  } else {
1175  if ((this->setting->flags & SF_GUI_DROPDOWN) != 0) {
1176  SetDParam(first_param++, this->setting->str_val - this->setting->min + value);
1177  } else if ((this->setting->flags & SF_GUI_NEGATIVE_IS_SPECIAL) != 0) {
1178  SetDParam(first_param++, this->setting->str_val + ((value >= 0) ? 1 : 0));
1179  value = abs(value);
1180  } else {
1181  SetDParam(first_param++, this->setting->str_val + ((value == 0 && (this->setting->flags & SF_GUI_0_IS_SPECIAL) != 0) ? 1 : 0));
1182  }
1183  SetDParam(first_param++, value);
1184  }
1185 }
1186 
1195 void SettingEntry::DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const
1196 {
1197  const IntSettingDesc *sd = this->setting;
1198  int state = this->flags & SEF_BUTTONS_MASK;
1199 
1200  bool rtl = _current_text_dir == TD_RTL;
1201  uint buttons_left = rtl ? right + 1 - SETTING_BUTTON_WIDTH : left;
1202  uint text_left = left + (rtl ? 0 : SETTING_BUTTON_WIDTH + 5);
1203  uint text_right = right - (rtl ? SETTING_BUTTON_WIDTH + 5 : 0);
1204  uint button_y = y + (SETTING_HEIGHT - SETTING_BUTTON_HEIGHT) / 2;
1205 
1206  /* We do not allow changes of some items when we are a client in a networkgame */
1207  bool editable = sd->IsEditable();
1208 
1209  SetDParam(0, highlight ? STR_ORANGE_STRING1_WHITE : STR_ORANGE_STRING1_LTBLUE);
1210  int32 value = sd->Read(ResolveObject(settings_ptr, sd));
1211  if (sd->IsBoolSetting()) {
1212  /* Draw checkbox for boolean-value either on/off */
1213  DrawBoolButton(buttons_left, button_y, value != 0, editable);
1214  } else if ((sd->flags & SF_GUI_DROPDOWN) != 0) {
1215  /* Draw [v] button for settings of an enum-type */
1216  DrawDropDownButton(buttons_left, button_y, COLOUR_YELLOW, state != 0, editable);
1217  } else {
1218  /* Draw [<][>] boxes for settings of an integer-type */
1219  DrawArrowButtons(buttons_left, button_y, COLOUR_YELLOW, state,
1220  editable && value != (sd->flags & SF_GUI_0_IS_SPECIAL ? 0 : sd->min), editable && (uint32)value != sd->max);
1221  }
1222  this->SetValueDParams(1, value);
1223  DrawString(text_left, text_right, y + (SETTING_HEIGHT - FONT_HEIGHT_NORMAL) / 2, sd->str, highlight ? TC_WHITE : TC_LIGHT_BLUE);
1224 }
1225 
1226 /* == SettingsContainer methods == */
1227 
1232 void SettingsContainer::Init(byte level)
1233 {
1234  for (EntryVector::iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1235  (*it)->Init(level);
1236  }
1237 }
1238 
1241 {
1242  for (auto settings_entry : this->entries) {
1243  settings_entry->ResetAll();
1244  }
1245 }
1246 
1249 {
1250  for (EntryVector::iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1251  (*it)->FoldAll();
1252  }
1253 }
1254 
1257 {
1258  for (EntryVector::iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1259  (*it)->UnFoldAll();
1260  }
1261 }
1262 
1268 void SettingsContainer::GetFoldingState(bool &all_folded, bool &all_unfolded) const
1269 {
1270  for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1271  (*it)->GetFoldingState(all_folded, all_unfolded);
1272  }
1273 }
1274 
1281 bool SettingsContainer::UpdateFilterState(SettingFilter &filter, bool force_visible)
1282 {
1283  bool visible = false;
1284  bool first_visible = true;
1285  for (EntryVector::reverse_iterator it = this->entries.rbegin(); it != this->entries.rend(); ++it) {
1286  visible |= (*it)->UpdateFilterState(filter, force_visible);
1287  (*it)->SetLastField(first_visible);
1288  if (visible && first_visible) first_visible = false;
1289  }
1290  return visible;
1291 }
1292 
1293 
1301 {
1302  for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1303  if ((*it)->IsVisible(item)) return true;
1304  }
1305  return false;
1306 }
1307 
1310 {
1311  uint length = 0;
1312  for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1313  length += (*it)->Length();
1314  }
1315  return length;
1316 }
1317 
1324 BaseSettingEntry *SettingsContainer::FindEntry(uint row_num, uint *cur_row)
1325 {
1326  BaseSettingEntry *pe = nullptr;
1327  for (EntryVector::iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1328  pe = (*it)->FindEntry(row_num, cur_row);
1329  if (pe != nullptr) {
1330  break;
1331  }
1332  }
1333  return pe;
1334 }
1335 
1342 {
1343  uint biggest = 0;
1344  for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1345  biggest = std::max(biggest, (*it)->GetMaxHelpHeight(maxw));
1346  }
1347  return biggest;
1348 }
1349 
1350 
1365 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
1366 {
1367  for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1368  cur_row = (*it)->Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1369  if (cur_row >= max_row) {
1370  break;
1371  }
1372  }
1373  return cur_row;
1374 }
1375 
1376 /* == SettingsPage methods == */
1377 
1383 {
1384  this->title = title;
1385  this->folded = true;
1386 }
1387 
1392 void SettingsPage::Init(byte level)
1393 {
1396 }
1397 
1400 {
1401  for (auto settings_entry : this->entries) {
1402  settings_entry->ResetAll();
1403  }
1404 }
1405 
1408 {
1409  if (this->IsFiltered()) return;
1410  this->folded = true;
1411 
1413 }
1414 
1417 {
1418  if (this->IsFiltered()) return;
1419  this->folded = false;
1420 
1422 }
1423 
1429 void SettingsPage::GetFoldingState(bool &all_folded, bool &all_unfolded) const
1430 {
1431  if (this->IsFiltered()) return;
1432 
1433  if (this->folded) {
1434  all_unfolded = false;
1435  } else {
1436  all_folded = false;
1437  }
1438 
1439  SettingsContainer::GetFoldingState(all_folded, all_unfolded);
1440 }
1441 
1448 bool SettingsPage::UpdateFilterState(SettingFilter &filter, bool force_visible)
1449 {
1450  if (!force_visible && !filter.string.IsEmpty()) {
1451  filter.string.ResetState();
1452  filter.string.AddLine(this->title);
1453  force_visible = filter.string.GetState();
1454  }
1455 
1456  bool visible = SettingsContainer::UpdateFilterState(filter, force_visible);
1457  if (visible) {
1458  CLRBITS(this->flags, SEF_FILTERED);
1459  } else {
1460  SETBITS(this->flags, SEF_FILTERED);
1461  }
1462  return visible;
1463 }
1464 
1472 {
1473  if (this->IsFiltered()) return false;
1474  if (this == item) return true;
1475  if (this->folded) return false;
1476 
1477  return SettingsContainer::IsVisible(item);
1478 }
1479 
1482 {
1483  if (this->IsFiltered()) return 0;
1484  if (this->folded) return 1; // Only displaying the title
1485 
1486  return 1 + SettingsContainer::Length();
1487 }
1488 
1495 BaseSettingEntry *SettingsPage::FindEntry(uint row_num, uint *cur_row)
1496 {
1497  if (this->IsFiltered()) return nullptr;
1498  if (row_num == *cur_row) return this;
1499  (*cur_row)++;
1500  if (this->folded) return nullptr;
1501 
1502  return SettingsContainer::FindEntry(row_num, cur_row);
1503 }
1504 
1519 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
1520 {
1521  if (this->IsFiltered()) return cur_row;
1522  if (cur_row >= max_row) return cur_row;
1523 
1524  cur_row = BaseSettingEntry::Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1525 
1526  if (!this->folded) {
1527  if (this->flags & SEF_LAST_FIELD) {
1528  assert(this->level < 8 * sizeof(parent_last));
1529  SetBit(parent_last, this->level); // Add own last-field state
1530  }
1531 
1532  cur_row = SettingsContainer::Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1533  }
1534 
1535  return cur_row;
1536 }
1537 
1546 void SettingsPage::DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const
1547 {
1548  bool rtl = _current_text_dir == TD_RTL;
1549  DrawSprite((this->folded ? SPR_CIRCLE_FOLDED : SPR_CIRCLE_UNFOLDED), PAL_NONE, rtl ? right - _circle_size.width : left, y + (SETTING_HEIGHT - _circle_size.height) / 2);
1550  DrawString(rtl ? left : left + _circle_size.width + 2, rtl ? right - _circle_size.width - 2 : right, y + (SETTING_HEIGHT - FONT_HEIGHT_NORMAL) / 2, this->title);
1551 }
1552 
1555 {
1556  static SettingsContainer *main = nullptr;
1557 
1558  if (main == nullptr)
1559  {
1560  /* Build up the dynamic settings-array only once per OpenTTD session */
1561  main = new SettingsContainer();
1562 
1563  SettingsPage *localisation = main->Add(new SettingsPage(STR_CONFIG_SETTING_LOCALISATION));
1564  {
1565  localisation->Add(new SettingEntry("locale.units_velocity"));
1566  localisation->Add(new SettingEntry("locale.units_power"));
1567  localisation->Add(new SettingEntry("locale.units_weight"));
1568  localisation->Add(new SettingEntry("locale.units_volume"));
1569  localisation->Add(new SettingEntry("locale.units_force"));
1570  localisation->Add(new SettingEntry("locale.units_height"));
1571  localisation->Add(new SettingEntry("gui.date_format_in_default_names"));
1572  }
1573 
1574  SettingsPage *graphics = main->Add(new SettingsPage(STR_CONFIG_SETTING_GRAPHICS));
1575  {
1576  graphics->Add(new SettingEntry("gui.zoom_min"));
1577  graphics->Add(new SettingEntry("gui.zoom_max"));
1578  graphics->Add(new SettingEntry("gui.sprite_zoom_min"));
1579  graphics->Add(new SettingEntry("gui.smallmap_land_colour"));
1580  graphics->Add(new SettingEntry("gui.linkgraph_colours"));
1581  graphics->Add(new SettingEntry("gui.graph_line_thickness"));
1582  }
1583 
1584  SettingsPage *sound = main->Add(new SettingsPage(STR_CONFIG_SETTING_SOUND));
1585  {
1586  sound->Add(new SettingEntry("sound.click_beep"));
1587  sound->Add(new SettingEntry("sound.confirm"));
1588  sound->Add(new SettingEntry("sound.news_ticker"));
1589  sound->Add(new SettingEntry("sound.news_full"));
1590  sound->Add(new SettingEntry("sound.new_year"));
1591  sound->Add(new SettingEntry("sound.disaster"));
1592  sound->Add(new SettingEntry("sound.vehicle"));
1593  sound->Add(new SettingEntry("sound.ambient"));
1594  }
1595 
1596  SettingsPage *interface = main->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE));
1597  {
1598  SettingsPage *general = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_GENERAL));
1599  {
1600  general->Add(new SettingEntry("gui.osk_activation"));
1601  general->Add(new SettingEntry("gui.hover_delay_ms"));
1602  general->Add(new SettingEntry("gui.errmsg_duration"));
1603  general->Add(new SettingEntry("gui.window_snap_radius"));
1604  general->Add(new SettingEntry("gui.window_soft_limit"));
1605  general->Add(new SettingEntry("gui.right_mouse_wnd_close"));
1606  }
1607 
1608  SettingsPage *viewports = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_VIEWPORTS));
1609  {
1610  viewports->Add(new SettingEntry("gui.auto_scrolling"));
1611  viewports->Add(new SettingEntry("gui.scroll_mode"));
1612  viewports->Add(new SettingEntry("gui.smooth_scroll"));
1613  /* While the horizontal scrollwheel scrolling is written as general code, only
1614  * the cocoa (OSX) driver generates input for it.
1615  * Since it's also able to completely disable the scrollwheel will we display it on all platforms anyway */
1616  viewports->Add(new SettingEntry("gui.scrollwheel_scrolling"));
1617  viewports->Add(new SettingEntry("gui.scrollwheel_multiplier"));
1618 #ifdef __APPLE__
1619  /* We might need to emulate a right mouse button on mac */
1620  viewports->Add(new SettingEntry("gui.right_mouse_btn_emulation"));
1621 #endif
1622  viewports->Add(new SettingEntry("gui.population_in_label"));
1623  viewports->Add(new SettingEntry("gui.liveries"));
1624  viewports->Add(new SettingEntry("construction.train_signal_side"));
1625  viewports->Add(new SettingEntry("gui.measure_tooltip"));
1626  viewports->Add(new SettingEntry("gui.loading_indicators"));
1627  viewports->Add(new SettingEntry("gui.show_track_reservation"));
1628  }
1629 
1630  SettingsPage *construction = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_CONSTRUCTION));
1631  {
1632  construction->Add(new SettingEntry("gui.link_terraform_toolbar"));
1633  construction->Add(new SettingEntry("gui.persistent_buildingtools"));
1634  construction->Add(new SettingEntry("gui.quick_goto"));
1635  construction->Add(new SettingEntry("gui.default_rail_type"));
1636  }
1637 
1638  interface->Add(new SettingEntry("gui.fast_forward_speed_limit"));
1639  interface->Add(new SettingEntry("gui.autosave"));
1640  interface->Add(new SettingEntry("gui.toolbar_pos"));
1641  interface->Add(new SettingEntry("gui.statusbar_pos"));
1642  interface->Add(new SettingEntry("gui.prefer_teamchat"));
1643  interface->Add(new SettingEntry("gui.advanced_vehicle_list"));
1644  interface->Add(new SettingEntry("gui.timetable_in_ticks"));
1645  interface->Add(new SettingEntry("gui.timetable_arrival_departure"));
1646  interface->Add(new SettingEntry("gui.show_newgrf_name"));
1647  }
1648 
1649  SettingsPage *advisors = main->Add(new SettingsPage(STR_CONFIG_SETTING_ADVISORS));
1650  {
1651  advisors->Add(new SettingEntry("gui.coloured_news_year"));
1652  advisors->Add(new SettingEntry("news_display.general"));
1653  advisors->Add(new SettingEntry("news_display.new_vehicles"));
1654  advisors->Add(new SettingEntry("news_display.accident"));
1655  advisors->Add(new SettingEntry("news_display.accident_other"));
1656  advisors->Add(new SettingEntry("news_display.company_info"));
1657  advisors->Add(new SettingEntry("news_display.acceptance"));
1658  advisors->Add(new SettingEntry("news_display.arrival_player"));
1659  advisors->Add(new SettingEntry("news_display.arrival_other"));
1660  advisors->Add(new SettingEntry("news_display.advice"));
1661  advisors->Add(new SettingEntry("gui.order_review_system"));
1662  advisors->Add(new SettingEntry("gui.vehicle_income_warn"));
1663  advisors->Add(new SettingEntry("gui.lost_vehicle_warn"));
1664  advisors->Add(new SettingEntry("gui.show_finances"));
1665  advisors->Add(new SettingEntry("news_display.economy"));
1666  advisors->Add(new SettingEntry("news_display.subsidies"));
1667  advisors->Add(new SettingEntry("news_display.open"));
1668  advisors->Add(new SettingEntry("news_display.close"));
1669  advisors->Add(new SettingEntry("news_display.production_player"));
1670  advisors->Add(new SettingEntry("news_display.production_other"));
1671  advisors->Add(new SettingEntry("news_display.production_nobody"));
1672  }
1673 
1674  SettingsPage *company = main->Add(new SettingsPage(STR_CONFIG_SETTING_COMPANY));
1675  {
1676  company->Add(new SettingEntry("gui.semaphore_build_before"));
1677  company->Add(new SettingEntry("gui.cycle_signal_types"));
1678  company->Add(new SettingEntry("gui.signal_gui_mode"));
1679  company->Add(new SettingEntry("gui.drag_signals_fixed_distance"));
1680  company->Add(new SettingEntry("gui.auto_remove_signals"));
1681  company->Add(new SettingEntry("gui.new_nonstop"));
1682  company->Add(new SettingEntry("gui.stop_location"));
1683  company->Add(new SettingEntry("gui.starting_colour"));
1684  company->Add(new SettingEntry("company.engine_renew"));
1685  company->Add(new SettingEntry("company.engine_renew_months"));
1686  company->Add(new SettingEntry("company.engine_renew_money"));
1687  company->Add(new SettingEntry("vehicle.servint_ispercent"));
1688  company->Add(new SettingEntry("vehicle.servint_trains"));
1689  company->Add(new SettingEntry("vehicle.servint_roadveh"));
1690  company->Add(new SettingEntry("vehicle.servint_ships"));
1691  company->Add(new SettingEntry("vehicle.servint_aircraft"));
1692  }
1693 
1694  SettingsPage *accounting = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCOUNTING));
1695  {
1696  accounting->Add(new SettingEntry("economy.inflation"));
1697  accounting->Add(new SettingEntry("difficulty.initial_interest"));
1698  accounting->Add(new SettingEntry("difficulty.max_loan"));
1699  accounting->Add(new SettingEntry("difficulty.subsidy_multiplier"));
1700  accounting->Add(new SettingEntry("difficulty.subsidy_duration"));
1701  accounting->Add(new SettingEntry("economy.feeder_payment_share"));
1702  accounting->Add(new SettingEntry("economy.infrastructure_maintenance"));
1703  accounting->Add(new SettingEntry("difficulty.vehicle_costs"));
1704  accounting->Add(new SettingEntry("difficulty.construction_cost"));
1705  }
1706 
1707  SettingsPage *vehicles = main->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES));
1708  {
1709  SettingsPage *physics = vehicles->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES_PHYSICS));
1710  {
1711  physics->Add(new SettingEntry("vehicle.train_acceleration_model"));
1712  physics->Add(new SettingEntry("vehicle.train_slope_steepness"));
1713  physics->Add(new SettingEntry("vehicle.wagon_speed_limits"));
1714  physics->Add(new SettingEntry("vehicle.freight_trains"));
1715  physics->Add(new SettingEntry("vehicle.roadveh_acceleration_model"));
1716  physics->Add(new SettingEntry("vehicle.roadveh_slope_steepness"));
1717  physics->Add(new SettingEntry("vehicle.smoke_amount"));
1718  physics->Add(new SettingEntry("vehicle.plane_speed"));
1719  }
1720 
1721  SettingsPage *routing = vehicles->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES_ROUTING));
1722  {
1723  routing->Add(new SettingEntry("pf.pathfinder_for_trains"));
1724  routing->Add(new SettingEntry("difficulty.line_reverse_mode"));
1725  routing->Add(new SettingEntry("pf.reverse_at_signals"));
1726  routing->Add(new SettingEntry("pf.forbid_90_deg"));
1727  routing->Add(new SettingEntry("pf.pathfinder_for_roadvehs"));
1728  routing->Add(new SettingEntry("pf.pathfinder_for_ships"));
1729  }
1730 
1731  vehicles->Add(new SettingEntry("order.no_servicing_if_no_breakdowns"));
1732  vehicles->Add(new SettingEntry("order.serviceathelipad"));
1733  }
1734 
1735  SettingsPage *limitations = main->Add(new SettingsPage(STR_CONFIG_SETTING_LIMITATIONS));
1736  {
1737  limitations->Add(new SettingEntry("construction.command_pause_level"));
1738  limitations->Add(new SettingEntry("construction.autoslope"));
1739  limitations->Add(new SettingEntry("construction.extra_dynamite"));
1740  limitations->Add(new SettingEntry("construction.map_height_limit"));
1741  limitations->Add(new SettingEntry("construction.max_bridge_length"));
1742  limitations->Add(new SettingEntry("construction.max_bridge_height"));
1743  limitations->Add(new SettingEntry("construction.max_tunnel_length"));
1744  limitations->Add(new SettingEntry("station.never_expire_airports"));
1745  limitations->Add(new SettingEntry("vehicle.never_expire_vehicles"));
1746  limitations->Add(new SettingEntry("vehicle.max_trains"));
1747  limitations->Add(new SettingEntry("vehicle.max_roadveh"));
1748  limitations->Add(new SettingEntry("vehicle.max_aircraft"));
1749  limitations->Add(new SettingEntry("vehicle.max_ships"));
1750  limitations->Add(new SettingEntry("vehicle.max_train_length"));
1751  limitations->Add(new SettingEntry("station.station_spread"));
1752  limitations->Add(new SettingEntry("station.distant_join_stations"));
1753  limitations->Add(new SettingEntry("construction.road_stop_on_town_road"));
1754  limitations->Add(new SettingEntry("construction.road_stop_on_competitor_road"));
1755  limitations->Add(new SettingEntry("vehicle.disable_elrails"));
1756  }
1757 
1758  SettingsPage *disasters = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCIDENTS));
1759  {
1760  disasters->Add(new SettingEntry("difficulty.disasters"));
1761  disasters->Add(new SettingEntry("difficulty.economy"));
1762  disasters->Add(new SettingEntry("difficulty.vehicle_breakdowns"));
1763  disasters->Add(new SettingEntry("vehicle.plane_crashes"));
1764  }
1765 
1766  SettingsPage *genworld = main->Add(new SettingsPage(STR_CONFIG_SETTING_GENWORLD));
1767  {
1768  genworld->Add(new SettingEntry("game_creation.landscape"));
1769  genworld->Add(new SettingEntry("game_creation.land_generator"));
1770  genworld->Add(new SettingEntry("difficulty.terrain_type"));
1771  genworld->Add(new SettingEntry("game_creation.tgen_smoothness"));
1772  genworld->Add(new SettingEntry("game_creation.variety"));
1773  genworld->Add(new SettingEntry("game_creation.snow_coverage"));
1774  genworld->Add(new SettingEntry("game_creation.snow_line_height"));
1775  genworld->Add(new SettingEntry("game_creation.desert_coverage"));
1776  genworld->Add(new SettingEntry("game_creation.amount_of_rivers"));
1777  genworld->Add(new SettingEntry("game_creation.tree_placer"));
1778  genworld->Add(new SettingEntry("vehicle.road_side"));
1779  genworld->Add(new SettingEntry("economy.larger_towns"));
1780  genworld->Add(new SettingEntry("economy.initial_city_size"));
1781  genworld->Add(new SettingEntry("economy.town_layout"));
1782  genworld->Add(new SettingEntry("difficulty.industry_density"));
1783  genworld->Add(new SettingEntry("gui.pause_on_newgame"));
1784  genworld->Add(new SettingEntry("game_creation.ending_year"));
1785  }
1786 
1787  SettingsPage *environment = main->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT));
1788  {
1789  SettingsPage *authorities = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_AUTHORITIES));
1790  {
1791  authorities->Add(new SettingEntry("difficulty.town_council_tolerance"));
1792  authorities->Add(new SettingEntry("economy.bribe"));
1793  authorities->Add(new SettingEntry("economy.exclusive_rights"));
1794  authorities->Add(new SettingEntry("economy.fund_roads"));
1795  authorities->Add(new SettingEntry("economy.fund_buildings"));
1796  authorities->Add(new SettingEntry("economy.station_noise_level"));
1797  }
1798 
1799  SettingsPage *towns = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_TOWNS));
1800  {
1801  towns->Add(new SettingEntry("economy.town_growth_rate"));
1802  towns->Add(new SettingEntry("economy.allow_town_roads"));
1803  towns->Add(new SettingEntry("economy.allow_town_level_crossings"));
1804  towns->Add(new SettingEntry("economy.found_town"));
1805  towns->Add(new SettingEntry("economy.town_cargogen_mode"));
1806  }
1807 
1808  SettingsPage *industries = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_INDUSTRIES));
1809  {
1810  industries->Add(new SettingEntry("construction.raw_industry_construction"));
1811  industries->Add(new SettingEntry("construction.industry_platform"));
1812  industries->Add(new SettingEntry("economy.multiple_industry_per_town"));
1813  industries->Add(new SettingEntry("game_creation.oil_refinery_limit"));
1814  industries->Add(new SettingEntry("economy.type"));
1815  industries->Add(new SettingEntry("station.serve_neutral_industries"));
1816  }
1817 
1818  SettingsPage *cdist = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST));
1819  {
1820  cdist->Add(new SettingEntry("linkgraph.recalc_time"));
1821  cdist->Add(new SettingEntry("linkgraph.recalc_interval"));
1822  cdist->Add(new SettingEntry("linkgraph.distribution_pax"));
1823  cdist->Add(new SettingEntry("linkgraph.distribution_mail"));
1824  cdist->Add(new SettingEntry("linkgraph.distribution_armoured"));
1825  cdist->Add(new SettingEntry("linkgraph.distribution_default"));
1826  cdist->Add(new SettingEntry("linkgraph.accuracy"));
1827  cdist->Add(new SettingEntry("linkgraph.demand_distance"));
1828  cdist->Add(new SettingEntry("linkgraph.demand_size"));
1829  cdist->Add(new SettingEntry("linkgraph.short_path_saturation"));
1830  }
1831 
1832  environment->Add(new SettingEntry("station.modified_catchment"));
1833  environment->Add(new SettingEntry("construction.extra_tree_placement"));
1834  }
1835 
1836  SettingsPage *ai = main->Add(new SettingsPage(STR_CONFIG_SETTING_AI));
1837  {
1838  SettingsPage *npc = ai->Add(new SettingsPage(STR_CONFIG_SETTING_AI_NPC));
1839  {
1840  npc->Add(new SettingEntry("script.settings_profile"));
1841  npc->Add(new SettingEntry("script.script_max_opcode_till_suspend"));
1842  npc->Add(new SettingEntry("script.script_max_memory_megabytes"));
1843  npc->Add(new SettingEntry("difficulty.competitor_speed"));
1844  npc->Add(new SettingEntry("ai.ai_in_multiplayer"));
1845  npc->Add(new SettingEntry("ai.ai_disable_veh_train"));
1846  npc->Add(new SettingEntry("ai.ai_disable_veh_roadveh"));
1847  npc->Add(new SettingEntry("ai.ai_disable_veh_aircraft"));
1848  npc->Add(new SettingEntry("ai.ai_disable_veh_ship"));
1849  }
1850 
1851  ai->Add(new SettingEntry("economy.give_money"));
1852  ai->Add(new SettingEntry("economy.allow_shares"));
1853  ai->Add(new SettingEntry("economy.min_years_for_shares"));
1854  }
1855 
1856  SettingsPage *network = main->Add(new SettingsPage(STR_CONFIG_SETTING_NETWORK));
1857  {
1858  network->Add(new SettingEntry("network.use_relay_service"));
1859  }
1860 
1861  main->Init();
1862  }
1863  return *main;
1864 }
1865 
1866 static const StringID _game_settings_restrict_dropdown[] = {
1867  STR_CONFIG_SETTING_RESTRICT_BASIC, // RM_BASIC
1868  STR_CONFIG_SETTING_RESTRICT_ADVANCED, // RM_ADVANCED
1869  STR_CONFIG_SETTING_RESTRICT_ALL, // RM_ALL
1870  STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_DEFAULT, // RM_CHANGED_AGAINST_DEFAULT
1871  STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_NEW, // RM_CHANGED_AGAINST_NEW
1872 };
1873 static_assert(lengthof(_game_settings_restrict_dropdown) == RM_END);
1874 
1881 };
1882 
1888 static void ResetAllSettingsConfirmationCallback(Window *w, bool confirmed)
1889 {
1890  if (confirmed) {
1893  w->InvalidateData();
1894  }
1895 }
1896 
1899  static const int SETTINGTREE_LEFT_OFFSET = 5;
1900  static const int SETTINGTREE_RIGHT_OFFSET = 5;
1901  static const int SETTINGTREE_TOP_OFFSET = 5;
1902  static const int SETTINGTREE_BOTTOM_OFFSET = 5;
1903 
1905 
1911 
1917 
1918  Scrollbar *vscroll;
1919 
1921  {
1922  this->warn_missing = WHR_NONE;
1923  this->warn_lines = 0;
1925  this->filter.min_cat = RM_ALL;
1926  this->filter.type = ST_ALL;
1927  this->filter.type_hides = false;
1928  this->settings_ptr = &GetGameSettings();
1929 
1930  _circle_size = maxdim(GetSpriteSize(SPR_CIRCLE_FOLDED), GetSpriteSize(SPR_CIRCLE_UNFOLDED));
1931  GetSettingsTree().FoldAll(); // Close all sub-pages
1932 
1933  this->valuewindow_entry = nullptr; // No setting entry for which a entry window is opened
1934  this->clicked_entry = nullptr; // No numeric setting buttons are depressed
1935  this->last_clicked = nullptr;
1936  this->valuedropdown_entry = nullptr;
1937  this->closing_dropdown = false;
1938  this->manually_changed_folding = false;
1939 
1940  this->CreateNestedTree();
1941  this->vscroll = this->GetScrollbar(WID_GS_SCROLLBAR);
1943 
1944  this->querystrings[WID_GS_FILTER] = &this->filter_editbox;
1945  this->filter_editbox.cancel_button = QueryString::ACTION_CLEAR;
1947 
1948  this->InvalidateData();
1949  }
1950 
1951  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1952  {
1953  switch (widget) {
1954  case WID_GS_OPTIONSPANEL:
1955  resize->height = SETTING_HEIGHT = std::max({(int)_circle_size.height, SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL}) + 1;
1956  resize->width = 1;
1957 
1958  size->height = 5 * resize->height + SETTINGTREE_TOP_OFFSET + SETTINGTREE_BOTTOM_OFFSET;
1959  break;
1960 
1961  case WID_GS_HELP_TEXT: {
1962  static const StringID setting_types[] = {
1963  STR_CONFIG_SETTING_TYPE_CLIENT,
1964  STR_CONFIG_SETTING_TYPE_COMPANY_MENU, STR_CONFIG_SETTING_TYPE_COMPANY_INGAME,
1965  STR_CONFIG_SETTING_TYPE_GAME_MENU, STR_CONFIG_SETTING_TYPE_GAME_INGAME,
1966  };
1967  for (uint i = 0; i < lengthof(setting_types); i++) {
1968  SetDParam(0, setting_types[i]);
1969  size->width = std::max(size->width, GetStringBoundingBox(STR_CONFIG_SETTING_TYPE).width);
1970  }
1971  size->height = 2 * FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL +
1972  std::max(size->height, GetSettingsTree().GetMaxHelpHeight(size->width));
1973  break;
1974  }
1975 
1977  case WID_GS_RESTRICT_TYPE:
1978  size->width = std::max(GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_CATEGORY).width, GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_TYPE).width);
1979  break;
1980 
1981  default:
1982  break;
1983  }
1984  }
1985 
1986  void OnPaint() override
1987  {
1988  if (this->closing_dropdown) {
1989  this->closing_dropdown = false;
1990  assert(this->valuedropdown_entry != nullptr);
1991  this->valuedropdown_entry->SetButtons(0);
1992  this->valuedropdown_entry = nullptr;
1993  }
1994 
1995  /* Reserve the correct number of lines for the 'some search results are hidden' notice in the central settings display panel. */
1996  const NWidgetBase *panel = this->GetWidget<NWidgetBase>(WID_GS_OPTIONSPANEL);
1997  StringID warn_str = STR_CONFIG_SETTING_CATEGORY_HIDES - 1 + this->warn_missing;
1998  int new_warn_lines;
1999  if (this->warn_missing == WHR_NONE) {
2000  new_warn_lines = 0;
2001  } else {
2002  SetDParam(0, _game_settings_restrict_dropdown[this->filter.min_cat]);
2003  new_warn_lines = GetStringLineCount(warn_str, panel->current_x);
2004  }
2005  if (this->warn_lines != new_warn_lines) {
2006  this->vscroll->SetCount(this->vscroll->GetCount() - this->warn_lines + new_warn_lines);
2007  this->warn_lines = new_warn_lines;
2008  }
2009 
2010  this->DrawWidgets();
2011 
2012  /* Draw the 'some search results are hidden' notice. */
2013  if (this->warn_missing != WHR_NONE) {
2014  const int left = panel->pos_x;
2015  const int right = left + panel->current_x - 1;
2016  const int top = panel->pos_y + WD_FRAMETEXT_TOP + (SETTING_HEIGHT - FONT_HEIGHT_NORMAL) * this->warn_lines / 2;
2017  SetDParam(0, _game_settings_restrict_dropdown[this->filter.min_cat]);
2018  if (this->warn_lines == 1) {
2019  /* If the warning fits at one line, center it. */
2020  DrawString(left + WD_FRAMETEXT_LEFT, right - WD_FRAMETEXT_RIGHT, top, warn_str, TC_FROMSTRING, SA_HOR_CENTER);
2021  } else {
2022  DrawStringMultiLine(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, INT32_MAX, warn_str, TC_FROMSTRING, SA_HOR_CENTER);
2023  }
2024  }
2025  }
2026 
2027  void SetStringParameters(int widget) const override
2028  {
2029  switch (widget) {
2031  SetDParam(0, _game_settings_restrict_dropdown[this->filter.mode]);
2032  break;
2033 
2034  case WID_GS_TYPE_DROPDOWN:
2035  switch (this->filter.type) {
2036  case ST_GAME: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME); break;
2037  case ST_COMPANY: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME); break;
2038  case ST_CLIENT: SetDParam(0, STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT); break;
2039  default: SetDParam(0, STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL); break;
2040  }
2041  break;
2042  }
2043  }
2044 
2045  DropDownList BuildDropDownList(int widget) const
2046  {
2047  DropDownList list;
2048  switch (widget) {
2050  for (int mode = 0; mode != RM_END; mode++) {
2051  /* If we are in adv. settings screen for the new game's settings,
2052  * we don't want to allow comparing with new game's settings. */
2053  bool disabled = mode == RM_CHANGED_AGAINST_NEW && settings_ptr == &_settings_newgame;
2054 
2055  list.emplace_back(new DropDownListStringItem(_game_settings_restrict_dropdown[mode], mode, disabled));
2056  }
2057  break;
2058 
2059  case WID_GS_TYPE_DROPDOWN:
2060  list.emplace_back(new DropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL, ST_ALL, false));
2061  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));
2062  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));
2063  list.emplace_back(new DropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT, ST_CLIENT, false));
2064  break;
2065  }
2066  return list;
2067  }
2068 
2069  void DrawWidget(const Rect &r, int widget) const override
2070  {
2071  switch (widget) {
2072  case WID_GS_OPTIONSPANEL: {
2073  int top_pos = r.top + SETTINGTREE_TOP_OFFSET + 1 + this->warn_lines * SETTING_HEIGHT;
2074  uint last_row = this->vscroll->GetPosition() + this->vscroll->GetCapacity() - this->warn_lines;
2075  int next_row = GetSettingsTree().Draw(settings_ptr, r.left + SETTINGTREE_LEFT_OFFSET, r.right - SETTINGTREE_RIGHT_OFFSET, top_pos,
2076  this->vscroll->GetPosition(), last_row, this->last_clicked);
2077  if (next_row == 0) DrawString(r.left + SETTINGTREE_LEFT_OFFSET, r.right - SETTINGTREE_RIGHT_OFFSET, top_pos, STR_CONFIG_SETTINGS_NONE);
2078  break;
2079  }
2080 
2081  case WID_GS_HELP_TEXT:
2082  if (this->last_clicked != nullptr) {
2083  const IntSettingDesc *sd = this->last_clicked->setting;
2084 
2085  int y = r.top;
2086  switch (sd->GetType()) {
2087  case ST_COMPANY: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_COMPANY_INGAME); break;
2088  case ST_CLIENT: SetDParam(0, STR_CONFIG_SETTING_TYPE_CLIENT); break;
2089  case ST_GAME: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_GAME_MENU : STR_CONFIG_SETTING_TYPE_GAME_INGAME); break;
2090  default: NOT_REACHED();
2091  }
2092  DrawString(r.left, r.right, y, STR_CONFIG_SETTING_TYPE);
2093  y += FONT_HEIGHT_NORMAL;
2094 
2095  this->last_clicked->SetValueDParams(0, sd->def);
2096  DrawString(r.left, r.right, y, STR_CONFIG_SETTING_DEFAULT_VALUE);
2098 
2099  DrawStringMultiLine(r.left, r.right, y, r.bottom, this->last_clicked->GetHelpText(), TC_WHITE);
2100  }
2101  break;
2102 
2103  default:
2104  break;
2105  }
2106  }
2107 
2113  {
2114  if (this->last_clicked != pe) this->SetDirty();
2115  this->last_clicked = pe;
2116  }
2117 
2118  void OnClick(Point pt, int widget, int click_count) override
2119  {
2120  switch (widget) {
2121  case WID_GS_EXPAND_ALL:
2122  this->manually_changed_folding = true;
2124  this->InvalidateData();
2125  break;
2126 
2127  case WID_GS_COLLAPSE_ALL:
2128  this->manually_changed_folding = true;
2130  this->InvalidateData();
2131  break;
2132 
2133  case WID_GS_RESET_ALL:
2134  ShowQuery(
2135  STR_CONFIG_SETTING_RESET_ALL_CONFIRMATION_DIALOG_CAPTION,
2136  STR_CONFIG_SETTING_RESET_ALL_CONFIRMATION_DIALOG_TEXT,
2137  this,
2139  );
2140  break;
2141 
2142  case WID_GS_RESTRICT_DROPDOWN: {
2143  DropDownList list = this->BuildDropDownList(widget);
2144  if (!list.empty()) {
2145  ShowDropDownList(this, std::move(list), this->filter.mode, widget);
2146  }
2147  break;
2148  }
2149 
2150  case WID_GS_TYPE_DROPDOWN: {
2151  DropDownList list = this->BuildDropDownList(widget);
2152  if (!list.empty()) {
2153  ShowDropDownList(this, std::move(list), this->filter.type, widget);
2154  }
2155  break;
2156  }
2157  }
2158 
2159  if (widget != WID_GS_OPTIONSPANEL) return;
2160 
2161  uint btn = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GS_OPTIONSPANEL, SETTINGTREE_TOP_OFFSET);
2162  if (btn == INT_MAX || (int)btn < this->warn_lines) return;
2163  btn -= this->warn_lines;
2164 
2165  uint cur_row = 0;
2167 
2168  if (clicked_entry == nullptr) return; // Clicked below the last setting of the page
2169 
2170  int x = (_current_text_dir == TD_RTL ? this->width - 1 - pt.x : pt.x) - SETTINGTREE_LEFT_OFFSET - (clicked_entry->level + 1) * LEVEL_WIDTH; // Shift x coordinate
2171  if (x < 0) return; // Clicked left of the entry
2172 
2173  SettingsPage *clicked_page = dynamic_cast<SettingsPage*>(clicked_entry);
2174  if (clicked_page != nullptr) {
2175  this->SetDisplayedHelpText(nullptr);
2176  clicked_page->folded = !clicked_page->folded; // Flip 'folded'-ness of the sub-page
2177 
2178  this->manually_changed_folding = true;
2179 
2180  this->InvalidateData();
2181  return;
2182  }
2183 
2184  SettingEntry *pe = dynamic_cast<SettingEntry*>(clicked_entry);
2185  assert(pe != nullptr);
2186  const IntSettingDesc *sd = pe->setting;
2187 
2188  /* return if action is only active in network, or only settable by server */
2189  if (!sd->IsEditable()) {
2190  this->SetDisplayedHelpText(pe);
2191  return;
2192  }
2193 
2194  int32 value = sd->Read(ResolveObject(settings_ptr, sd));
2195 
2196  /* clicked on the icon on the left side. Either scroller, bool on/off or dropdown */
2197  if (x < SETTING_BUTTON_WIDTH && (sd->flags & SF_GUI_DROPDOWN)) {
2198  this->SetDisplayedHelpText(pe);
2199 
2200  if (this->valuedropdown_entry == pe) {
2201  /* unclick the dropdown */
2202  HideDropDownMenu(this);
2203  this->closing_dropdown = false;
2204  this->valuedropdown_entry->SetButtons(0);
2205  this->valuedropdown_entry = nullptr;
2206  } else {
2207  if (this->valuedropdown_entry != nullptr) this->valuedropdown_entry->SetButtons(0);
2208  this->closing_dropdown = false;
2209 
2210  const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_GS_OPTIONSPANEL);
2211  int rel_y = (pt.y - (int)wid->pos_y - SETTINGTREE_TOP_OFFSET) % wid->resize_y;
2212 
2213  Rect wi_rect;
2214  wi_rect.left = pt.x - (_current_text_dir == TD_RTL ? SETTING_BUTTON_WIDTH - 1 - x : x);
2215  wi_rect.right = wi_rect.left + SETTING_BUTTON_WIDTH - 1;
2216  wi_rect.top = pt.y - rel_y + (SETTING_HEIGHT - SETTING_BUTTON_HEIGHT) / 2;
2217  wi_rect.bottom = wi_rect.top + SETTING_BUTTON_HEIGHT - 1;
2218 
2219  /* For dropdowns we also have to check the y position thoroughly, the mouse may not above the just opening dropdown */
2220  if (pt.y >= wi_rect.top && pt.y <= wi_rect.bottom) {
2221  this->valuedropdown_entry = pe;
2222  this->valuedropdown_entry->SetButtons(SEF_LEFT_DEPRESSED);
2223 
2224  DropDownList list;
2225  for (int i = sd->min; i <= (int)sd->max; i++) {
2226  list.emplace_back(new DropDownListStringItem(sd->str_val + i - sd->min, i, false));
2227  }
2228 
2229  ShowDropDownListAt(this, std::move(list), value, -1, wi_rect, COLOUR_ORANGE, true);
2230  }
2231  }
2232  this->SetDirty();
2233  } else if (x < SETTING_BUTTON_WIDTH) {
2234  this->SetDisplayedHelpText(pe);
2235  int32 oldvalue = value;
2236 
2237  if (sd->IsBoolSetting()) {
2238  value ^= 1;
2239  } else {
2240  /* Add a dynamic step-size to the scroller. In a maximum of
2241  * 50-steps you should be able to get from min to max,
2242  * unless specified otherwise in the 'interval' variable
2243  * of the current setting. */
2244  uint32 step = (sd->interval == 0) ? ((sd->max - sd->min) / 50) : sd->interval;
2245  if (step == 0) step = 1;
2246 
2247  /* don't allow too fast scrolling */
2248  if ((this->flags & WF_TIMEOUT) && this->timeout_timer > 1) {
2249  _left_button_clicked = false;
2250  return;
2251  }
2252 
2253  /* Increase or decrease the value and clamp it to extremes */
2254  if (x >= SETTING_BUTTON_WIDTH / 2) {
2255  value += step;
2256  if (sd->min < 0) {
2257  assert((int32)sd->max >= 0);
2258  if (value > (int32)sd->max) value = (int32)sd->max;
2259  } else {
2260  if ((uint32)value > sd->max) value = (int32)sd->max;
2261  }
2262  if (value < sd->min) value = sd->min; // skip between "disabled" and minimum
2263  } else {
2264  value -= step;
2265  if (value < sd->min) value = (sd->flags & SF_GUI_0_IS_SPECIAL) ? 0 : sd->min;
2266  }
2267 
2268  /* Set up scroller timeout for numeric values */
2269  if (value != oldvalue) {
2270  if (this->clicked_entry != nullptr) { // Release previous buttons if any
2271  this->clicked_entry->SetButtons(0);
2272  }
2273  this->clicked_entry = pe;
2274  this->clicked_entry->SetButtons((x >= SETTING_BUTTON_WIDTH / 2) != (_current_text_dir == TD_RTL) ? SEF_RIGHT_DEPRESSED : SEF_LEFT_DEPRESSED);
2275  this->SetTimeout();
2276  _left_button_clicked = false;
2277  }
2278  }
2279 
2280  if (value != oldvalue) {
2281  SetSettingValue(sd, value);
2282  this->SetDirty();
2283  }
2284  } else {
2285  /* Only open editbox if clicked for the second time, and only for types where it is sensible for. */
2286  if (this->last_clicked == pe && !sd->IsBoolSetting() && !(sd->flags & SF_GUI_DROPDOWN)) {
2287  int64 value64 = value;
2288  /* Show the correct currency-translated value */
2289  if (sd->flags & SF_GUI_CURRENCY) value64 *= _currency->rate;
2290 
2291  this->valuewindow_entry = pe;
2292  SetDParam(0, value64);
2293  /* Limit string length to 14 so that MAX_INT32 * max currency rate doesn't exceed MAX_INT64. */
2294  ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 15, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
2295  }
2296  this->SetDisplayedHelpText(pe);
2297  }
2298  }
2299 
2300  void OnTimeout() override
2301  {
2302  if (this->clicked_entry != nullptr) { // On timeout, release any depressed buttons
2303  this->clicked_entry->SetButtons(0);
2304  this->clicked_entry = nullptr;
2305  this->SetDirty();
2306  }
2307  }
2308 
2309  void OnQueryTextFinished(char *str) override
2310  {
2311  /* The user pressed cancel */
2312  if (str == nullptr) return;
2313 
2314  assert(this->valuewindow_entry != nullptr);
2315  const IntSettingDesc *sd = this->valuewindow_entry->setting;
2316 
2317  int32 value;
2318  if (!StrEmpty(str)) {
2319  long long llvalue = atoll(str);
2320 
2321  /* Save the correct currency-translated value */
2322  if (sd->flags & SF_GUI_CURRENCY) llvalue /= _currency->rate;
2323 
2324  value = (int32)ClampToI32(llvalue);
2325  } else {
2326  value = sd->def;
2327  }
2328 
2329  SetSettingValue(this->valuewindow_entry->setting, value);
2330  this->SetDirty();
2331  }
2332 
2333  void OnDropdownSelect(int widget, int index) override
2334  {
2335  switch (widget) {
2337  this->filter.mode = (RestrictionMode)index;
2338  if (this->filter.mode == RM_CHANGED_AGAINST_DEFAULT ||
2339  this->filter.mode == RM_CHANGED_AGAINST_NEW) {
2340 
2341  if (!this->manually_changed_folding) {
2342  /* Expand all when selecting 'changes'. Update the filter state first, in case it becomes less restrictive in some cases. */
2343  GetSettingsTree().UpdateFilterState(this->filter, false);
2345  }
2346  } else {
2347  /* Non-'changes' filter. Save as default. */
2349  }
2350  this->InvalidateData();
2351  break;
2352 
2353  case WID_GS_TYPE_DROPDOWN:
2354  this->filter.type = (SettingType)index;
2355  this->InvalidateData();
2356  break;
2357 
2358  default:
2359  if (widget < 0) {
2360  /* Deal with drop down boxes on the panel. */
2361  assert(this->valuedropdown_entry != nullptr);
2362  const IntSettingDesc *sd = this->valuedropdown_entry->setting;
2363  assert(sd->flags & SF_GUI_DROPDOWN);
2364 
2365  SetSettingValue(sd, index);
2366  this->SetDirty();
2367  }
2368  break;
2369  }
2370  }
2371 
2372  void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override
2373  {
2374  if (widget >= 0) {
2375  /* Normally the default implementation of OnDropdownClose() takes care of
2376  * a few things. We want that behaviour here too, but only for
2377  * "normal" dropdown boxes. The special dropdown boxes added for every
2378  * setting that needs one can't have this call. */
2379  Window::OnDropdownClose(pt, widget, index, instant_close);
2380  } else {
2381  /* We cannot raise the dropdown button just yet. OnClick needs some hint, whether
2382  * the same dropdown button was clicked again, and then not open the dropdown again.
2383  * So, we only remember that it was closed, and process it on the next OnPaint, which is
2384  * after OnClick. */
2385  assert(this->valuedropdown_entry != nullptr);
2386  this->closing_dropdown = true;
2387  this->SetDirty();
2388  }
2389  }
2390 
2391  void OnInvalidateData(int data = 0, bool gui_scope = true) override
2392  {
2393  if (!gui_scope) return;
2394 
2395  /* Update which settings are to be visible. */
2396  RestrictionMode min_level = (this->filter.mode <= RM_ALL) ? this->filter.mode : RM_BASIC;
2397  this->filter.min_cat = min_level;
2398  this->filter.type_hides = false;
2399  GetSettingsTree().UpdateFilterState(this->filter, false);
2400 
2401  if (this->filter.string.IsEmpty()) {
2402  this->warn_missing = WHR_NONE;
2403  } else if (min_level < this->filter.min_cat) {
2404  this->warn_missing = this->filter.type_hides ? WHR_CATEGORY_TYPE : WHR_CATEGORY;
2405  } else {
2406  this->warn_missing = this->filter.type_hides ? WHR_TYPE : WHR_NONE;
2407  }
2408  this->vscroll->SetCount(GetSettingsTree().Length() + this->warn_lines);
2409 
2410  if (this->last_clicked != nullptr && !GetSettingsTree().IsVisible(this->last_clicked)) {
2411  this->SetDisplayedHelpText(nullptr);
2412  }
2413 
2414  bool all_folded = true;
2415  bool all_unfolded = true;
2416  GetSettingsTree().GetFoldingState(all_folded, all_unfolded);
2417  this->SetWidgetDisabledState(WID_GS_EXPAND_ALL, all_unfolded);
2418  this->SetWidgetDisabledState(WID_GS_COLLAPSE_ALL, all_folded);
2419  }
2420 
2421  void OnEditboxChanged(int wid) override
2422  {
2423  if (wid == WID_GS_FILTER) {
2424  this->filter.string.SetFilterTerm(this->filter_editbox.text.buf);
2425  if (!this->filter.string.IsEmpty() && !this->manually_changed_folding) {
2426  /* User never expanded/collapsed single pages and entered a filter term.
2427  * Expand everything, to save weird expand clicks, */
2429  }
2430  this->InvalidateData();
2431  }
2432  }
2433 
2434  void OnResize() override
2435  {
2437  }
2438 };
2439 
2441 
2442 static const NWidgetPart _nested_settings_selection_widgets[] = {
2444  NWidget(WWT_CLOSEBOX, COLOUR_MAUVE),
2445  NWidget(WWT_CAPTION, COLOUR_MAUVE), SetDataTip(STR_CONFIG_SETTING_TREE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
2446  NWidget(WWT_DEFSIZEBOX, COLOUR_MAUVE),
2447  EndContainer(),
2448  NWidget(WWT_PANEL, COLOUR_MAUVE),
2451  NWidget(WWT_TEXT, COLOUR_MAUVE, WID_GS_RESTRICT_CATEGORY), SetDataTip(STR_CONFIG_SETTING_RESTRICT_CATEGORY, STR_NULL),
2452  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),
2453  EndContainer(),
2455  NWidget(WWT_TEXT, COLOUR_MAUVE, WID_GS_RESTRICT_TYPE), SetDataTip(STR_CONFIG_SETTING_RESTRICT_TYPE, STR_NULL),
2456  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),
2457  EndContainer(),
2459  NWidget(WWT_TEXT, COLOUR_MAUVE), SetFill(0, 1), SetDataTip(STR_CONFIG_SETTING_FILTER_TITLE, STR_NULL),
2460  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),
2461  EndContainer(),
2462  EndContainer(),
2463  EndContainer(),
2466  NWidget(NWID_VSCROLLBAR, COLOUR_MAUVE, WID_GS_SCROLLBAR),
2467  EndContainer(),
2468  NWidget(WWT_PANEL, COLOUR_MAUVE),
2469  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GS_HELP_TEXT), SetMinimalSize(300, 25), SetFill(1, 1), SetResize(1, 0),
2471  EndContainer(),
2473  NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, WID_GS_EXPAND_ALL), SetDataTip(STR_CONFIG_SETTING_EXPAND_ALL, STR_NULL),
2474  NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, WID_GS_COLLAPSE_ALL), SetDataTip(STR_CONFIG_SETTING_COLLAPSE_ALL, STR_NULL),
2475  NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, WID_GS_RESET_ALL), SetDataTip(STR_CONFIG_SETTING_RESET_ALL, STR_NULL),
2476  NWidget(WWT_PANEL, COLOUR_MAUVE), SetFill(1, 0), SetResize(1, 0),
2477  EndContainer(),
2478  NWidget(WWT_RESIZEBOX, COLOUR_MAUVE),
2479  EndContainer(),
2480 };
2481 
2482 static WindowDesc _settings_selection_desc(
2483  WDP_CENTER, "settings", 510, 450,
2485  0,
2486  _nested_settings_selection_widgets, lengthof(_nested_settings_selection_widgets)
2487 );
2488 
2491 {
2493  new GameSettingsWindow(&_settings_selection_desc);
2494 }
2495 
2496 
2506 void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right)
2507 {
2508  int colour = _colour_gradient[button_colour][2];
2509  Dimension dim = NWidgetScrollbar::GetHorizontalDimension();
2510 
2511  DrawFrameRect(x, y, x + dim.width - 1, y + dim.height - 1, button_colour, (state == 1) ? FR_LOWERED : FR_NONE);
2512  DrawFrameRect(x + dim.width, y, x + dim.width + dim.width - 1, y + dim.height - 1, button_colour, (state == 2) ? FR_LOWERED : FR_NONE);
2513  DrawSprite(SPR_ARROW_LEFT, PAL_NONE, x + WD_IMGBTN_LEFT, y + WD_IMGBTN_TOP);
2514  DrawSprite(SPR_ARROW_RIGHT, PAL_NONE, x + WD_IMGBTN_LEFT + dim.width, y + WD_IMGBTN_TOP);
2515 
2516  /* Grey out the buttons that aren't clickable */
2517  bool rtl = _current_text_dir == TD_RTL;
2518  if (rtl ? !clickable_right : !clickable_left) {
2519  GfxFillRect(x + 1, y, x + dim.width - 1, y + dim.height - 2, colour, FILLRECT_CHECKER);
2520  }
2521  if (rtl ? !clickable_left : !clickable_right) {
2522  GfxFillRect(x + dim.width + 1, y, x + dim.width + dim.width - 1, y + dim.height - 2, colour, FILLRECT_CHECKER);
2523  }
2524 }
2525 
2534 void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
2535 {
2536  int colour = _colour_gradient[button_colour][2];
2537 
2538  DrawFrameRect(x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1, button_colour, state ? FR_LOWERED : FR_NONE);
2539  DrawSprite(SPR_ARROW_DOWN, PAL_NONE, x + (SETTING_BUTTON_WIDTH - NWidgetScrollbar::GetVerticalDimension().width) / 2 + state, y + 2 + state);
2540 
2541  if (!clickable) {
2542  GfxFillRect(x + 1, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 2, colour, FILLRECT_CHECKER);
2543  }
2544 }
2545 
2553 void DrawBoolButton(int x, int y, bool state, bool clickable)
2554 {
2555  static const Colours _bool_ctabs[2][2] = {{COLOUR_CREAM, COLOUR_RED}, {COLOUR_DARK_GREEN, COLOUR_GREEN}};
2556  DrawFrameRect(x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1, _bool_ctabs[state][clickable], state ? FR_LOWERED : FR_NONE);
2557 }
2558 
2560  int query_widget;
2561 
2562  CustomCurrencyWindow(WindowDesc *desc) : Window(desc)
2563  {
2564  this->InitNested();
2565 
2566  SetButtonState();
2567  }
2568 
2569  void SetButtonState()
2570  {
2571  this->SetWidgetDisabledState(WID_CC_RATE_DOWN, _custom_currency.rate == 1);
2572  this->SetWidgetDisabledState(WID_CC_RATE_UP, _custom_currency.rate == UINT16_MAX);
2573  this->SetWidgetDisabledState(WID_CC_YEAR_DOWN, _custom_currency.to_euro == CF_NOEURO);
2574  this->SetWidgetDisabledState(WID_CC_YEAR_UP, _custom_currency.to_euro == MAX_YEAR);
2575  }
2576 
2577  void SetStringParameters(int widget) const override
2578  {
2579  switch (widget) {
2580  case WID_CC_RATE: SetDParam(0, 1); SetDParam(1, 1); break;
2581  case WID_CC_SEPARATOR: SetDParamStr(0, _custom_currency.separator); break;
2582  case WID_CC_PREFIX: SetDParamStr(0, _custom_currency.prefix); break;
2583  case WID_CC_SUFFIX: SetDParamStr(0, _custom_currency.suffix); break;
2584  case WID_CC_YEAR:
2585  SetDParam(0, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER);
2586  SetDParam(1, _custom_currency.to_euro);
2587  break;
2588 
2589  case WID_CC_PREVIEW:
2590  SetDParam(0, 10000);
2591  break;
2592  }
2593  }
2594 
2595  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
2596  {
2597  switch (widget) {
2598  /* Set the appropriate width for the edit 'buttons' */
2599  case WID_CC_SEPARATOR_EDIT:
2600  case WID_CC_PREFIX_EDIT:
2601  case WID_CC_SUFFIX_EDIT:
2602  size->width = this->GetWidget<NWidgetBase>(WID_CC_RATE_DOWN)->smallest_x + this->GetWidget<NWidgetBase>(WID_CC_RATE_UP)->smallest_x;
2603  break;
2604 
2605  /* Make sure the window is wide enough for the widest exchange rate */
2606  case WID_CC_RATE:
2607  SetDParam(0, 1);
2608  SetDParam(1, INT32_MAX);
2609  *size = GetStringBoundingBox(STR_CURRENCY_EXCHANGE_RATE);
2610  break;
2611  }
2612  }
2613 
2614  void OnClick(Point pt, int widget, int click_count) override
2615  {
2616  int line = 0;
2617  int len = 0;
2618  StringID str = 0;
2619  CharSetFilter afilter = CS_ALPHANUMERAL;
2620 
2621  switch (widget) {
2622  case WID_CC_RATE_DOWN:
2623  if (_custom_currency.rate > 1) _custom_currency.rate--;
2624  if (_custom_currency.rate == 1) this->DisableWidget(WID_CC_RATE_DOWN);
2626  break;
2627 
2628  case WID_CC_RATE_UP:
2629  if (_custom_currency.rate < UINT16_MAX) _custom_currency.rate++;
2630  if (_custom_currency.rate == UINT16_MAX) this->DisableWidget(WID_CC_RATE_UP);
2632  break;
2633 
2634  case WID_CC_RATE:
2635  SetDParam(0, _custom_currency.rate);
2636  str = STR_JUST_INT;
2637  len = 5;
2638  line = WID_CC_RATE;
2639  afilter = CS_NUMERAL;
2640  break;
2641 
2642  case WID_CC_SEPARATOR_EDIT:
2643  case WID_CC_SEPARATOR:
2644  SetDParamStr(0, _custom_currency.separator);
2645  str = STR_JUST_RAW_STRING;
2646  len = 7;
2647  line = WID_CC_SEPARATOR;
2648  break;
2649 
2650  case WID_CC_PREFIX_EDIT:
2651  case WID_CC_PREFIX:
2652  SetDParamStr(0, _custom_currency.prefix);
2653  str = STR_JUST_RAW_STRING;
2654  len = 15;
2655  line = WID_CC_PREFIX;
2656  break;
2657 
2658  case WID_CC_SUFFIX_EDIT:
2659  case WID_CC_SUFFIX:
2660  SetDParamStr(0, _custom_currency.suffix);
2661  str = STR_JUST_RAW_STRING;
2662  len = 15;
2663  line = WID_CC_SUFFIX;
2664  break;
2665 
2666  case WID_CC_YEAR_DOWN:
2667  _custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ? CF_NOEURO : _custom_currency.to_euro - 1;
2668  if (_custom_currency.to_euro == CF_NOEURO) this->DisableWidget(WID_CC_YEAR_DOWN);
2670  break;
2671 
2672  case WID_CC_YEAR_UP:
2673  _custom_currency.to_euro = Clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR);
2674  if (_custom_currency.to_euro == MAX_YEAR) this->DisableWidget(WID_CC_YEAR_UP);
2676  break;
2677 
2678  case WID_CC_YEAR:
2679  SetDParam(0, _custom_currency.to_euro);
2680  str = STR_JUST_INT;
2681  len = 7;
2682  line = WID_CC_YEAR;
2683  afilter = CS_NUMERAL;
2684  break;
2685  }
2686 
2687  if (len != 0) {
2688  this->query_widget = line;
2689  ShowQueryString(str, STR_CURRENCY_CHANGE_PARAMETER, len + 1, this, afilter, QSF_NONE);
2690  }
2691 
2692  this->SetTimeout();
2693  this->SetDirty();
2694  }
2695 
2696  void OnQueryTextFinished(char *str) override
2697  {
2698  if (str == nullptr) return;
2699 
2700  switch (this->query_widget) {
2701  case WID_CC_RATE:
2702  _custom_currency.rate = Clamp(atoi(str), 1, UINT16_MAX);
2703  break;
2704 
2705  case WID_CC_SEPARATOR: // Thousands separator
2706  _custom_currency.separator = str;
2707  break;
2708 
2709  case WID_CC_PREFIX:
2710  _custom_currency.prefix = str;
2711  break;
2712 
2713  case WID_CC_SUFFIX:
2714  _custom_currency.suffix = str;
2715  break;
2716 
2717  case WID_CC_YEAR: { // Year to switch to euro
2718  int val = atoi(str);
2719 
2720  _custom_currency.to_euro = (val < 2000 ? CF_NOEURO : std::min(val, MAX_YEAR));
2721  break;
2722  }
2723  }
2725  SetButtonState();
2726  }
2727 
2728  void OnTimeout() override
2729  {
2730  this->SetDirty();
2731  }
2732 };
2733 
2734 static const NWidgetPart _nested_cust_currency_widgets[] = {
2736  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
2737  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_CURRENCY_WINDOW, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
2738  EndContainer(),
2739  NWidget(WWT_PANEL, COLOUR_GREY),
2741  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
2742  NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_RATE_DOWN), SetDataTip(AWV_DECREASE, STR_CURRENCY_DECREASE_EXCHANGE_RATE_TOOLTIP),
2743  NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_RATE_UP), SetDataTip(AWV_INCREASE, STR_CURRENCY_INCREASE_EXCHANGE_RATE_TOOLTIP),
2745  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_RATE), SetDataTip(STR_CURRENCY_EXCHANGE_RATE, STR_CURRENCY_SET_EXCHANGE_RATE_TOOLTIP), SetFill(1, 0),
2746  EndContainer(),
2747  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
2748  NWidget(WWT_PUSHBTN, COLOUR_DARK_BLUE, WID_CC_SEPARATOR_EDIT), SetDataTip(0x0, STR_CURRENCY_SET_CUSTOM_CURRENCY_SEPARATOR_TOOLTIP), SetFill(0, 1),
2750  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_SEPARATOR), SetDataTip(STR_CURRENCY_SEPARATOR, STR_CURRENCY_SET_CUSTOM_CURRENCY_SEPARATOR_TOOLTIP), SetFill(1, 0),
2751  EndContainer(),
2752  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
2753  NWidget(WWT_PUSHBTN, COLOUR_DARK_BLUE, WID_CC_PREFIX_EDIT), SetDataTip(0x0, STR_CURRENCY_SET_CUSTOM_CURRENCY_PREFIX_TOOLTIP), SetFill(0, 1),
2755  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_PREFIX), SetDataTip(STR_CURRENCY_PREFIX, STR_CURRENCY_SET_CUSTOM_CURRENCY_PREFIX_TOOLTIP), SetFill(1, 0),
2756  EndContainer(),
2757  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
2758  NWidget(WWT_PUSHBTN, COLOUR_DARK_BLUE, WID_CC_SUFFIX_EDIT), SetDataTip(0x0, STR_CURRENCY_SET_CUSTOM_CURRENCY_SUFFIX_TOOLTIP), SetFill(0, 1),
2760  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_SUFFIX), SetDataTip(STR_CURRENCY_SUFFIX, STR_CURRENCY_SET_CUSTOM_CURRENCY_SUFFIX_TOOLTIP), SetFill(1, 0),
2761  EndContainer(),
2762  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
2763  NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_YEAR_DOWN), SetDataTip(AWV_DECREASE, STR_CURRENCY_DECREASE_CUSTOM_CURRENCY_TO_EURO_TOOLTIP),
2764  NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_YEAR_UP), SetDataTip(AWV_INCREASE, STR_CURRENCY_INCREASE_CUSTOM_CURRENCY_TO_EURO_TOOLTIP),
2766  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_YEAR), SetDataTip(STR_JUST_STRING, STR_CURRENCY_SET_CUSTOM_CURRENCY_TO_EURO_TOOLTIP), SetFill(1, 0),
2767  EndContainer(),
2768  EndContainer(),
2769  NWidget(WWT_LABEL, COLOUR_BLUE, WID_CC_PREVIEW),
2770  SetDataTip(STR_CURRENCY_PREVIEW, STR_CURRENCY_CUSTOM_CURRENCY_PREVIEW_TOOLTIP), SetPadding(15, 1, 18, 2),
2771  EndContainer(),
2772 };
2773 
2774 static WindowDesc _cust_currency_desc(
2775  WDP_CENTER, nullptr, 0, 0,
2777  0,
2778  _nested_cust_currency_widgets, lengthof(_nested_cust_currency_widgets)
2779 );
2780 
2782 static void ShowCustCurrency()
2783 {
2785  new CustomCurrencyWindow(&_cust_currency_desc);
2786 }
WID_GO_REFRESH_RATE_DROPDOWN
@ WID_GO_REFRESH_RATE_DROPDOWN
Dropdown for all available refresh rates.
Definition: settings_widget.h:39
LoadStringWidthTable
void LoadStringWidthTable(bool monospace)
Initialize _stringwidth_table cache.
Definition: gfx.cpp:1432
SettingEntry::Length
virtual uint Length() const
Return number of rows needed to display the (filtered) entry.
Definition: settings_gui.cpp:1060
WC_CUSTOM_CURRENCY
@ WC_CUSTOM_CURRENCY
Custom currency; Window numbers:
Definition: window_type.h:610
SEF_RIGHT_DEPRESSED
@ SEF_RIGHT_DEPRESSED
Of a numeric setting entry, the right button is depressed.
Definition: settings_gui.cpp:767
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:360
SettingEntry::UpdateFilterState
virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible)
Update the filter state.
Definition: settings_gui.cpp:1121
CustomCurrencyWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: settings_gui.cpp:2728
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:141
factory.hpp
GUISettings::refresh_rate
uint16 refresh_rate
How often we refresh the screen (time between draw-ticks).
Definition: settings_type.h:174
WID_GO_FONT_ZOOM_DROPDOWN
@ WID_GO_FONT_ZOOM_DROPDOWN
Dropdown for the font zoom level.
Definition: settings_widget.h:36
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:340
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:766
Window::timeout_timer
uint8 timeout_timer
Timer value of the WF_TIMEOUT for flags.
Definition: window_gui.h:309
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:1190
GetCurrentLanguageIsoCode
const char * GetCurrentLanguageIsoCode()
Get the ISO language code of the currently loaded language.
Definition: strings.cpp:2003
SEF_BUTTONS_MASK
@ SEF_BUTTONS_MASK
Bit-mask for button flags.
Definition: settings_gui.cpp:768
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:664
WID_GS_OPTIONSPANEL
@ WID_GS_OPTIONSPANEL
Panel widget containing the option lists.
Definition: settings_widget.h:46
command_func.h
BaseSetTextfileWindow::baseset
const TBaseSet * baseset
View the textfile of this BaseSet.
Definition: settings_gui.cpp:113
WID_GS_COLLAPSE_ALL
@ WID_GS_COLLAPSE_ALL
Collapse all button.
Definition: settings_widget.h:50
WID_GS_HELP_TEXT
@ WID_GS_HELP_TEXT
Information area to display help text of the selected option.
Definition: settings_widget.h:48
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:1141
Window::GetScrollbar
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:320
BaseSetTextfileWindow::content_type
StringID content_type
STR_CONTENT_TYPE_xxx for title.
Definition: settings_gui.cpp:114
dropdown_func.h
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:24
GameSettingsWindow
Window to edit settings of the game.
Definition: settings_gui.cpp:1898
StringFilter::IsEmpty
bool IsEmpty() const
Check whether any filter words were entered.
Definition: stringfilter_type.h:59
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:2614
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:1546
company_base.h
WID_CC_SEPARATOR_EDIT
@ WID_CC_SEPARATOR_EDIT
Separator edit button.
Definition: settings_widget.h:63
GameSettingsWindow::settings_ptr
static GameSettings * settings_ptr
Pointer to the game settings being displayed and modified.
Definition: settings_gui.cpp:1904
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
WID_GO_BASE_SFX_TEXTFILE
@ WID_GO_BASE_SFX_TEXTFILE
Open base SFX readme, changelog (+1) or license (+2).
Definition: settings_widget.h:29
DrawVolumeSliderWidget
void DrawVolumeSliderWidget(Rect r, byte value)
Draw a volume slider widget with know at given value.
Definition: slider.cpp:26
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:51
SettingFilter::type
SettingType type
Filter based on type.
Definition: settings_gui.cpp:791
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
WID_GO_GUI_ZOOM_DROPDOWN
@ WID_GO_GUI_ZOOM_DROPDOWN
Dropdown for the GUI zoom level.
Definition: settings_widget.h:22
SettingEntry::setting
const IntSettingDesc * setting
Setting description of the setting.
Definition: settings_gui.cpp:836
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:71
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:1392
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:1760
SettingsPage::Length
virtual uint Length() const
Return number of rows needed to display the (filtered) entry.
Definition: settings_gui.cpp:1481
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:26
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
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:2372
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:1341
GameSettingsWindow::filter_editbox
QueryString filter_editbox
Filter editbox;.
Definition: settings_gui.cpp:1913
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:811
WID_CC_RATE
@ WID_CC_RATE
Rate of currency.
Definition: settings_widget.h:62
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:112
Scrollbar::SetCount
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:712
FILLRECT_CHECKER
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
Definition: gfx_type.h:288
SettingFilter::string
StringFilter string
Filter string.
Definition: settings_gui.cpp:787
_font_zoom_cfg
int8 _font_zoom_cfg
Font zoom level in config.
Definition: gfx.cpp:68
SettingEntry::Init
virtual void Init(byte level=0)
Initialization of a setting entry.
Definition: settings_gui.cpp:1036
GameOptionsWindow
Definition: settings_gui.cpp:160
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:995
zoom_func.h
ST_COMPANY
@ ST_COMPANY
Company setting.
Definition: settings_internal.h:63
WD_FRAMETEXT_TOP
@ WD_FRAMETEXT_TOP
Top offset of the text of the frame.
Definition: window_gui.h:74
WID_GS_EXPAND_ALL
@ WID_GS_EXPAND_ALL
Expand all button.
Definition: settings_widget.h:49
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:869
_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:1951
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:645
GameSettingsWindow::last_clicked
SettingEntry * last_clicked
If non-nullptr, pointer to the last clicked setting.
Definition: settings_gui.cpp:1908
GUISettings::autosave
byte autosave
how often should we do autosaves?
Definition: settings_type.h:135
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:32
WID_GS_FILTER
@ WID_GS_FILTER
Text filter.
Definition: settings_widget.h:45
StringFilter::AddLine
void AddLine(const char *str)
Pass another text line from the current item to the filter.
Definition: stringfilter.cpp:104
GameSettingsWindow::SETTINGTREE_TOP_OFFSET
static const int SETTINGTREE_TOP_OFFSET
Position of top edge of setting values.
Definition: settings_gui.cpp:1901
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:293
FR_LOWERED
@ FR_LOWERED
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
Definition: window_gui.h:31
settings_internal.h
WID_CC_PREFIX
@ WID_CC_PREFIX
Current prefix.
Definition: settings_widget.h:66
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:771
WID_GO_BASE_MUSIC_DROPDOWN
@ WID_GO_BASE_MUSIC_DROPDOWN
Use to select a base music set.
Definition: settings_widget.h:31
WC_MUSIC_WINDOW
@ WC_MUSIC_WINDOW
Music window; Window numbers:
Definition: window_type.h:588
GameSettingsWindow::SETTINGTREE_LEFT_OFFSET
static const int SETTINGTREE_LEFT_OFFSET
Position of left edge of setting values.
Definition: settings_gui.cpp:1899
_gui_zoom
ZoomLevel _gui_zoom
GUI Zoom level.
Definition: gfx.cpp:64
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:2138
SettingEntry::IsVisibleByRestrictionMode
bool IsVisibleByRestrictionMode(RestrictionMode mode) const
Checks whether an entry shall be made visible based on the restriction mode.
Definition: settings_gui.cpp:1080
SettingsPage::SettingsPage
SettingsPage(StringID title)
Constructor for a sub-page in the 'advanced settings' window.
Definition: settings_gui.cpp:1382
BaseSettingEntry::Init
virtual void Init(byte level=0)
Initialization of a setting entry.
Definition: settings_gui.cpp:926
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:631
SettingsPage
Data structure describing one page of settings in the settings window.
Definition: settings_gui.cpp:895
WD_FRAMETEXT_LEFT
@ WD_FRAMETEXT_LEFT
Left offset of the text of the frame.
Definition: window_gui.h:72
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:1281
_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
Window::Window
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition: window.cpp:1799
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:2559
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:973
textfile_gui.h
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1109
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:2300
GetStringBoundingBox
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:891
GameOptionsWindow::Close
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
Definition: settings_gui.cpp:175
GetStringLineCount
int GetStringLineCount(StringID str, int maxw)
Calculates number of lines of string.
Definition: gfx.cpp:741
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:323
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:383
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:790
GameOptionsWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: settings_gui.cpp:300
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:1070
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:64
UpdateCursorSize
void UpdateCursorSize()
Update cursor dimension.
Definition: gfx.cpp:1822
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:622
WN_GAME_OPTIONS_GAME_OPTIONS
@ WN_GAME_OPTIONS_GAME_OPTIONS
Game options.
Definition: window_type.h:18
WindowDesc
High level window description.
Definition: window_gui.h:168
GameSettingsWindow::warn_missing
WarnHiddenResult warn_missing
Whether and how to warn about missing search results.
Definition: settings_gui.cpp:1915
BaseSettingEntry::level
byte level
Nesting level of this setting entry.
Definition: settings_gui.cpp:797
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
SettingsPage::title
StringID title
Title of the sub-page.
Definition: settings_gui.cpp:896
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:788
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:464
WC_QUERY_STRING
@ WC_QUERY_STRING
Query string window; Window numbers:
Definition: window_type.h:115
GameOptionsWindow::BuildDropDownList
DropDownList BuildDropDownList(int widget, int *selected_index) const
Build the dropdown list for a specific widget.
Definition: settings_gui.cpp:189
DrawDropDownButton
void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
Draw a dropdown button.
Definition: settings_gui.cpp:2534
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:317
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:52
GameSettingsWindow::warn_lines
int warn_lines
Number of lines used for warning about missing search results.
Definition: settings_gui.cpp:1916
ResetAllSettingsConfirmationCallback
static void ResetAllSettingsConfirmationCallback(Window *w, bool confirmed)
Callback function for the reset all settings button.
Definition: settings_gui.cpp:1888
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:655
SETTING_HEIGHT
static int SETTING_HEIGHT
Height of a single setting in the tree view in pixels.
Definition: settings_gui.cpp:758
Window::EnableWidget
void EnableWidget(byte widget_index)
Sets a widget to Enabled.
Definition: window_gui.h:405
MusicDriver::GetInstance
static MusicDriver * GetInstance()
Get the currently active instance of the music driver.
Definition: music_driver.hpp:46
RestrictionMode
RestrictionMode
How the list of advanced settings is filtered.
Definition: settings_gui.cpp:775
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1789
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:1906
ReInitAllWindows
void ReInitAllWindows(bool zoom_changed)
Re-initialize all windows.
Definition: window.cpp:3354
GfxClearSpriteCache
void GfxClearSpriteCache()
Remove all encoded sprites from the sprite cache without discarding sprite location information.
Definition: spritecache.cpp:1042
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:1195
WHR_TYPE
@ WHR_TYPE
Type setting filtered matches away.
Definition: settings_gui.cpp:1879
Window::height
int height
Height of the window (number of pixels down in y direction)
Definition: window_gui.h:315
WID_CC_SUFFIX_EDIT
@ WID_CC_SUFFIX_EDIT
Suffix edit button.
Definition: settings_widget.h:67
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:35
CustomCurrencyWindow::OnQueryTextFinished
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: settings_gui.cpp:2696
GameSettingsWindow::SETTINGTREE_BOTTOM_OFFSET
static const int SETTINGTREE_BOTTOM_OFFSET
Position of bottom edge of setting values.
Definition: settings_gui.cpp:1902
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:993
highscore.h
WD_FRAMERECT_LEFT
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
Definition: window_gui.h:62
SettingsContainer::ResetAll
void ResetAll()
Resets all settings to their default values.
Definition: settings_gui.cpp:1240
GameSettingsWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: settings_gui.cpp:2333
GUISettings::missing_strings_threshold
byte missing_strings_threshold
the number of missing strings before showing the warning
Definition: settings_type.h:168
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:795
GameSettingsWindow::OnQueryTextFinished
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: settings_gui.cpp:2309
WD_PAR_VSEP_NORMAL
@ WD_PAR_VSEP_NORMAL
Normal amount of vertical space between two paragraphs of text.
Definition: window_gui.h:139
WD_FRAMERECT_RIGHT
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
Definition: window_gui.h:63
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
WD_FRAMETEXT_BOTTOM
@ WD_FRAMETEXT_BOTTOM
Bottom offset of the text of the frame.
Definition: window_gui.h:75
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:443
GameOptionsWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: settings_gui.cpp:330
RM_END
@ RM_END
End for iteration.
Definition: settings_gui.cpp:781
SettingFilter::mode
RestrictionMode mode
Filter based on category.
Definition: settings_gui.cpp:790
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:40
SettingEntry::name
const char * name
Name of the setting.
Definition: settings_gui.cpp:835
Window::SetWidgetDisabledState
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:386
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:1407
_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:46
SEF_LAST_FIELD
@ SEF_LAST_FIELD
This entry is the last one in a (sub-)page.
Definition: settings_gui.cpp:770
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:1125
RM_ALL
@ RM_ALL
List all settings regardless of the default/newgame/... values.
Definition: settings_gui.cpp:778
Window::left
int left
x position of left edge of the window
Definition: window_gui.h:312
music_driver.hpp
Window::flags
WindowFlags flags
Window flags.
Definition: window_gui.h:305
_resolutions
std::vector< Dimension > _resolutions
List of resolutions.
Definition: driver.cpp:24
WF_TIMEOUT
@ WF_TIMEOUT
Window timeout counter.
Definition: window_gui.h:234
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:579
SettingsPage::folded
bool folded
Sub-page is folded (not visible except for its title)
Definition: settings_gui.cpp:897
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:1044
WID_GO_BASE_GRF_DROPDOWN
@ WID_GO_BASE_GRF_DROPDOWN
Use to select a base GRF.
Definition: settings_widget.h:23
WID_CC_YEAR_UP
@ WID_CC_YEAR_UP
Up button.
Definition: settings_widget.h:70
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:1909
SettingsContainer::Init
void Init(byte level=0)
Initialization of an entire setting page.
Definition: settings_gui.cpp:1232
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:776
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:150
WID_CC_YEAR_DOWN
@ WID_CC_YEAR_DOWN
Down button.
Definition: settings_widget.h:69
WHR_CATEGORY
@ WHR_CATEGORY
Category setting filtered matches away.
Definition: settings_gui.cpp:1878
SettingsPage::FindEntry
virtual BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find setting entry at row row_num.
Definition: settings_gui.cpp:1495
BaseSetTextfileWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: settings_gui.cpp:122
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:2577
WD_FRAMETEXT_RIGHT
@ WD_FRAMETEXT_RIGHT
Right offset of the text of the frame.
Definition: window_gui.h:73
Window::SetFocusedWidget
bool SetFocusedWidget(int widget_index)
Set focus within this window to the given widget.
Definition: window.cpp:506
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:2506
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:789
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:119
ShowCustCurrency
static void ShowCustCurrency()
Open custom currency window.
Definition: settings_gui.cpp:2782
WID_CC_RATE_DOWN
@ WID_CC_RATE_DOWN
Down button.
Definition: settings_widget.h:60
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:1365
WarnHiddenResult
WarnHiddenResult
Warnings about hidden search results.
Definition: settings_gui.cpp:1876
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:3174
VideoDriver::GetInstance
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
Definition: video_driver.hpp:204
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:330
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:37
SA_HOR_CENTER
@ SA_HOR_CENTER
Horizontally center the text.
Definition: gfx_type.h:329
WHR_CATEGORY_TYPE
@ WHR_CATEGORY_TYPE
Both category and type settings filtered matches away.
Definition: settings_gui.cpp:1880
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:138
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:61
ClickVolumeSliderWidget
bool ClickVolumeSliderWidget(Rect r, Point pt, byte &value)
Handle click on a volume slider widget to change the value.
Definition: slider.cpp:55
GetStringHeight
int GetStringHeight(const char *str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Definition: gfx.cpp:716
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:979
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
GUISettings::zoom_min
ZoomLevel zoom_min
minimum zoom out level
Definition: settings_type.h:132
GameSettingsWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: settings_gui.cpp:2027
WID_GO_BACKGROUND
@ WID_GO_BACKGROUND
Background of the window.
Definition: settings_widget.h:15
_gui_zoom_cfg
int8 _gui_zoom_cfg
GUI zoom level in config.
Definition: gfx.cpp:67
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:1053
TFT_LICENSE
@ TFT_LICENSE
NewGRF license.
Definition: textfile_type.h:19
_switch_mode
SwitchMode _switch_mode
The next mainloop command.
Definition: gfx.cpp:49
_font_zoom
ZoomLevel _font_zoom
Font Zoom level.
Definition: gfx.cpp:65
GameSettingsWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: settings_gui.cpp:2434
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
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:1274
WID_GS_SCROLLBAR
@ WID_GS_SCROLLBAR
Scrollbar.
Definition: settings_widget.h:47
WID_CC_PREFIX_EDIT
@ WID_CC_PREFIX_EDIT
Prefix edit button.
Definition: settings_widget.h:65
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:604
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:1094
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:416
NWidgetBase::pos_x
int pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:189
LocaleSettings::currency
byte currency
currency we currently use
Definition: settings_type.h:231
WID_GO_BASE_SFX_DROPDOWN
@ WID_GO_BASE_SFX_DROPDOWN
Use to select a base SFX.
Definition: settings_widget.h:27
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:34
BaseSettingEntry::FindEntry
virtual BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find setting entry at row row_num.
Definition: settings_gui.cpp:949
HideDropDownMenu
int HideDropDownMenu(Window *pw)
Delete the drop-down menu from window pw.
Definition: dropdown.cpp:498
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:1256
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:1300
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:1429
SettingsContainer::Length
uint Length() const
Return number of rows needed to display the whole page.
Definition: settings_gui.cpp:1309
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:53
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:168
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:1209
GameSettingsWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: settings_gui.cpp:2069
RM_CHANGED_AGAINST_DEFAULT
@ RM_CHANGED_AGAINST_DEFAULT
Show only settings which are different compared to default values.
Definition: settings_gui.cpp:779
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:28
geometry_func.hpp
CloseWindowByClass
void CloseWindowByClass(WindowClass cls)
Close all windows of a given class.
Definition: window.cpp:1188
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:1012
GameSettingsWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: settings_gui.cpp:1986
UpdateAllVirtCoords
void UpdateAllVirtCoords()
Update the viewport coordinates of all signs.
Definition: afterload.cpp:217
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:1448
_video_hw_accel
bool _video_hw_accel
Whether to consider hardware accelerated video drivers.
Definition: video_driver.cpp:23
NWidgetBase::resize_y
uint resize_y
Vertical resize step (0 means not resizable).
Definition: widget_type.h:179
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:1324
Scrollbar::GetPosition
uint16 GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:673
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:2595
StringFilter::GetState
bool GetState() const
Get the matching state of the current item.
Definition: stringfilter_type.h:69
WD_IMGBTN_TOP
@ WD_IMGBTN_TOP
Top offset of image in the button.
Definition: window_gui.h:42
WID_GO_BASE_MUSIC_STATUS
@ WID_GO_BASE_MUSIC_STATUS
Info about corrupted files etc.
Definition: settings_widget.h:33
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:1776
WID_GS_RESTRICT_DROPDOWN
@ WID_GS_RESTRICT_DROPDOWN
The drop down box to restrict the list of settings.
Definition: settings_widget.h:54
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:38
GameSettingsWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: settings_gui.cpp:2391
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:83
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:1519
Window::top
int top
y position of top edge of the window
Definition: window_gui.h:313
abs
static T abs(const T a)
Returns the absolute value of (scalar) variable.
Definition: math_func.hpp:21
WID_GO_BASE_GRF_TEXTFILE
@ WID_GO_BASE_GRF_TEXTFILE
Open base GRF readme, changelog (+1) or license (+2).
Definition: settings_widget.h:25
LEVEL_WIDTH
static const int LEVEL_WIDTH
Indenting width of a sub-page in pixels.
Definition: settings_gui.cpp:759
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:424
SettingEntry::SetValueDParams
void SetValueDParams(uint first_param, int32 value) const
Set the DParams for drawing the value of a setting.
Definition: settings_gui.cpp:1170
DrawFrameRect
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
Draw frame rectangle.
Definition: widget.cpp:209
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:1471
SettingsContainer::FoldAll
void FoldAll()
Recursively close all folds of sub-pages.
Definition: settings_gui.cpp:1248
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:356
_video_vsync
bool _video_vsync
Whether we should use vsync (only if _video_hw_accel is enabled).
Definition: video_driver.cpp:24
GUISettings::settings_restriction_mode
uint8 settings_restriction_mode
selected restriction mode in adv. settings GUI.
Definition: settings_type.h:192
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:2110
GameSettingsWindow::filter
SettingFilter filter
Filter for the list.
Definition: settings_gui.cpp:1912
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:314
MusicSettings::effect_vol
byte effect_vol
The requested effects volume.
Definition: settings_type.h:222
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:2212
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition: gfx.cpp:1753
GameSettings::locale
LocaleSettings locale
settings related to used currency/unit system in the current game
Definition: settings_type.h:593
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1171
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:1176
NWidgetBase::pos_y
int pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:190
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:937
SettingEntry::SettingEntry
SettingEntry(const char *name)
Constructor for a single setting in the 'advanced settings' window.
Definition: settings_gui.cpp:1026
WID_GO_VIDEO_ACCEL_BUTTON
@ WID_GO_VIDEO_ACCEL_BUTTON
Toggle for video acceleration.
Definition: settings_widget.h:37
GameSettingsWindow::SETTINGTREE_RIGHT_OFFSET
static const int SETTINGTREE_RIGHT_OFFSET
Position of right edge of setting values.
Definition: settings_gui.cpp:1900
SettingFilter
Filter for settings list.
Definition: settings_gui.cpp:786
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:780
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1078
TextfileWindow
Window for displaying a textfile.
Definition: textfile_gui.h:21
WID_CC_PREVIEW
@ WID_CC_PREVIEW
Preview.
Definition: settings_widget.h:72
GameOptionsWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: settings_gui.cpp:609
GetSettingsTree
static SettingsContainer & GetSettingsTree()
Construct settings tree.
Definition: settings_gui.cpp:1554
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:600
SettingsContainer
Containers for BaseSettingEntry.
Definition: settings_gui.cpp:867
GameSettingsWindow::closing_dropdown
bool closing_dropdown
True, if the dropdown list is currently closing.
Definition: settings_gui.cpp:1910
BaseSettingEntry::flags
byte flags
Flags of the setting entry.
Definition: settings_gui.cpp:796
Window
Data structure for an opened window.
Definition: window_gui.h:279
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:30
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:834
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:1399
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:636
ZOOM_LVL_OUT_4X
@ ZOOM_LVL_OUT_4X
Zoomed 4 times out.
Definition: zoom_type.h:26
ShowGameSettings
void ShowGameSettings()
Open advanced settings window.
Definition: settings_gui.cpp:2490
DrawBoolButton
void DrawBoolButton(int x, int y, bool state, bool clickable)
Draw a toggle button.
Definition: settings_gui.cpp:2553
settings_gui.h
WD_IMGBTN_LEFT
@ WD_IMGBTN_LEFT
Left offset of the image in the button.
Definition: window_gui.h:40
WID_TF_CAPTION
@ WID_TF_CAPTION
The caption of the window.
Definition: misc_widget.h:51
SettingEntry::GetHelpText
StringID GetHelpText() const
Get the help text of a single setting.
Definition: settings_gui.cpp:852
Window::SetWidgetDirty
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:608
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:45
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:47
GameSettingsWindow::manually_changed_folding
bool manually_changed_folding
Whether the user expanded/collapsed something manually.
Definition: settings_gui.cpp:1914
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:986
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:2112
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:3162
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:602
Window::DisableWidget
void DisableWidget(byte widget_index)
Sets a widget to disabled.
Definition: window_gui.h:396
CLRBITS
#define CLRBITS(x, y)
Clears several bits in a variable.
Definition: bitmath_func.hpp:166
NWidgetBase::current_x
uint current_x
Current horizontal size (after resizing).
Definition: widget_type.h:186
WC_TEXTFILE
@ WC_TEXTFILE
textfile; Window numbers:
Definition: window_type.h:179
WHR_NONE
@ WHR_NONE
Nothing was filtering matches away.
Definition: settings_gui.cpp:1877
UpdateGUIZoom
void UpdateGUIZoom()
Resolve GUI zoom level, if auto-suggestion is requested.
Definition: gfx.cpp:2026
SettingsContainer::GetFoldingState
void GetFoldingState(bool &all_folded, bool &all_unfolded) const
Recursively accumulate the folding state of the tree.
Definition: settings_gui.cpp:1268
WDP_CENTER
@ WDP_CENTER
Center the window.
Definition: window_gui.h:157
ChangeMusicSet
void ChangeMusicSet(int index)
Change the configured music set and reset playback.
Definition: music_gui.cpp:432
Window::SetWidgetLoweredState
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:447
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:1907
ReadLanguagePack
bool ReadLanguagePack(const LanguageMetadata *lang)
Read a particular language.
Definition: strings.cpp:1736
MusicSettings::music_vol
byte music_vol
The requested music volume.
Definition: settings_type.h:221
GameOptionsWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: settings_gui.cpp:522
_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:48
GameSettingsWindow::OnEditboxChanged
void OnEditboxChanged(int wid) override
The text in an editbox has been edited.
Definition: settings_gui.cpp:2421
_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:75
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:1416
CharSetFilter
CharSetFilter
Valid filter types for IsValidChar.
Definition: string_type.h:26
_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:2118
WD_TEXTPANEL_BOTTOM
@ WD_TEXTPANEL_BOTTOM
Offset at bottom to draw below the text.
Definition: window_gui.h:69
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:509
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:296
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:598
WID_GS_TYPE_DROPDOWN
@ WID_GS_TYPE_DROPDOWN
The drop down box to choose client/game/company/all settings.
Definition: settings_widget.h:55
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:358
AWV_DECREASE
@ AWV_DECREASE
Arrow to the left or in case of RTL to the right.
Definition: widget_type.h:35
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
WD_TEXTPANEL_TOP
@ WD_TEXTPANEL_TOP
Offset at top to draw above the text.
Definition: window_gui.h:68
WID_CC_SUFFIX
@ WID_CC_SUFFIX
Current suffix.
Definition: settings_widget.h:68
BaseSettingEntry::IsFiltered
bool IsFiltered() const
Check whether an entry is hidden due to filters.
Definition: settings_gui.cpp:823
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:777
WN_GAME_OPTIONS_GAME_SETTINGS
@ WN_GAME_OPTIONS_GAME_SETTINGS
Game settings.
Definition: window_type.h:19
Window::Close
virtual void Close()
Hide the window and all its child windows, and mark them for a later deletion.
Definition: window.cpp:1092
ShowGameOptions
void ShowGameOptions()
Open the game options window.
Definition: settings_gui.cpp:752
SettingEntryFlags
SettingEntryFlags
Flags for SettingEntry.
Definition: settings_gui.cpp:765
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:52