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