OpenTTD Source  1.11.0-beta1
settings_gui.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #include "stdafx.h"
11 #include "currency.h"
12 #include "error.h"
13 #include "settings_gui.h"
14 #include "textbuf_gui.h"
15 #include "command_func.h"
16 #include "network/network.h"
17 #include "town.h"
18 #include "settings_internal.h"
19 #include "newgrf_townname.h"
20 #include "strings_func.h"
21 #include "window_func.h"
22 #include "string_func.h"
23 #include "widgets/dropdown_type.h"
24 #include "widgets/dropdown_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 
40 #include <vector>
41 
42 #include "safeguards.h"
43 
44 
45 static const StringID _driveside_dropdown[] = {
46  STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_LEFT,
47  STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_RIGHT,
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 
60 static const StringID _gui_zoom_dropdown[] = {
61  STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_NORMAL,
62  STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_2X_ZOOM,
63  STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_4X_ZOOM,
65 };
66 
67 static const StringID _font_zoom_dropdown[] = {
68  STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_NORMAL,
69  STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_2X_ZOOM,
70  STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_4X_ZOOM,
72 };
73 
74 int _nb_orig_names = SPECSTR_TOWNNAME_LAST - SPECSTR_TOWNNAME_START + 1;
75 static StringID *_grf_names = nullptr;
76 static int _nb_grf_names = 0;
77 
79 
80 static const void *ResolveVariableAddress(const GameSettings *settings_ptr, const SettingDesc *sd);
81 
84 {
86  _grf_names = GetGRFTownNameList();
87  _nb_grf_names = 0;
88  for (StringID *s = _grf_names; *s != INVALID_STRING_ID; s++) _nb_grf_names++;
89 }
90 
96 static inline StringID TownName(int town_name)
97 {
98  if (town_name < _nb_orig_names) return STR_GAME_OPTIONS_TOWN_NAME_ORIGINAL_ENGLISH + town_name;
99  town_name -= _nb_orig_names;
100  if (town_name < _nb_grf_names) return _grf_names[town_name];
101  return STR_UNDEFINED;
102 }
103 
108 static uint GetCurRes()
109 {
110  uint i;
111 
112  for (i = 0; i != _resolutions.size(); i++) {
113  if (_resolutions[i] == Dimension(_screen.width, _screen.height)) break;
114  }
115  return i;
116 }
117 
118 static void ShowCustCurrency();
119 
120 template <class T>
121 static DropDownList BuildSetDropDownList(int *selected_index, bool allow_selection)
122 {
123  int n = T::GetNumSets();
124  *selected_index = T::GetIndexOfUsedSet();
125 
126  DropDownList list;
127  for (int i = 0; i < n; i++) {
128  list.emplace_back(new DropDownListCharStringItem(T::GetSet(i)->name, i, !allow_selection && (*selected_index != i)));
129  }
130 
131  return list;
132 }
133 
134 DropDownList BuildMusicSetDropDownList(int *selected_index)
135 {
136  return BuildSetDropDownList<BaseMusic>(selected_index, true);
137 }
138 
140 template <class TBaseSet>
142  const TBaseSet* baseset;
144 
146  {
147  const char *textfile = this->baseset->GetTextfile(file_type);
148  this->LoadTextfile(textfile, BASESET_DIR);
149  }
150 
151  void SetStringParameters(int widget) const override
152  {
153  if (widget == WID_TF_CAPTION) {
155  SetDParamStr(1, this->baseset->name.c_str());
156  }
157  }
158 };
159 
166 template <class TBaseSet>
167 void ShowBaseSetTextfileWindow(TextfileType file_type, const TBaseSet* baseset, StringID content_type)
168 {
169  DeleteWindowById(WC_TEXTFILE, file_type);
170  new BaseSetTextfileWindow<TBaseSet>(file_type, baseset, content_type);
171 }
172 
174  GameSettings *opt;
175  bool reload;
176 
177  GameOptionsWindow(WindowDesc *desc) : Window(desc)
178  {
179  this->opt = &GetGameSettings();
180  this->reload = false;
181 
183  this->OnInvalidateData(0);
184  }
185 
187  {
190  if (this->reload) _switch_mode = SM_MENU;
191  }
192 
199  DropDownList BuildDropDownList(int widget, int *selected_index) const
200  {
201  DropDownList list;
202  switch (widget) {
203  case WID_GO_CURRENCY_DROPDOWN: { // Setup currencies dropdown
204  *selected_index = this->opt->locale.currency;
205  StringID *items = BuildCurrencyDropdown();
206  uint64 disabled = _game_mode == GM_MENU ? 0LL : ~GetMaskOfAllowedCurrencies();
207 
208  /* Add non-custom currencies; sorted naturally */
209  for (uint i = 0; i < CURRENCY_END; items++, i++) {
210  if (i == CURRENCY_CUSTOM) continue;
211  list.emplace_back(new DropDownListStringItem(*items, i, HasBit(disabled, i)));
212  }
213  std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
214 
215  /* Append custom currency at the end */
216  list.emplace_back(new DropDownListItem(-1, false)); // separator line
217  list.emplace_back(new DropDownListStringItem(STR_GAME_OPTIONS_CURRENCY_CUSTOM, CURRENCY_CUSTOM, HasBit(disabled, CURRENCY_CUSTOM)));
218  break;
219  }
220 
221  case WID_GO_ROADSIDE_DROPDOWN: { // Setup road-side dropdown
222  *selected_index = this->opt->vehicle.road_side;
223  const StringID *items = _driveside_dropdown;
224  uint disabled = 0;
225 
226  /* You can only change the drive side if you are in the menu or ingame with
227  * no vehicles present. In a networking game only the server can change it */
228  extern bool RoadVehiclesAreBuilt();
229  if ((_game_mode != GM_MENU && RoadVehiclesAreBuilt()) || (_networking && !_network_server)) {
230  disabled = ~(1 << this->opt->vehicle.road_side); // disable the other value
231  }
232 
233  for (uint i = 0; *items != INVALID_STRING_ID; items++, i++) {
234  list.emplace_back(new DropDownListStringItem(*items, i, HasBit(disabled, i)));
235  }
236  break;
237  }
238 
239  case WID_GO_TOWNNAME_DROPDOWN: { // Setup townname dropdown
240  *selected_index = this->opt->game_creation.town_name;
241 
242  int enabled_item = (_game_mode == GM_MENU || Town::GetNumItems() == 0) ? -1 : *selected_index;
243 
244  /* Add and sort newgrf townnames generators */
245  for (int i = 0; i < _nb_grf_names; i++) {
246  int result = _nb_orig_names + i;
247  list.emplace_back(new DropDownListStringItem(_grf_names[i], result, enabled_item != result && enabled_item >= 0));
248  }
249  std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
250 
251  size_t newgrf_size = list.size();
252  /* Insert newgrf_names at the top of the list */
253  if (newgrf_size > 0) {
254  list.emplace_back(new DropDownListItem(-1, false)); // separator line
255  newgrf_size++;
256  }
257 
258  /* Add and sort original townnames generators */
259  for (int i = 0; i < _nb_orig_names; i++) {
260  list.emplace_back(new DropDownListStringItem(STR_GAME_OPTIONS_TOWN_NAME_ORIGINAL_ENGLISH + i, i, enabled_item != i && enabled_item >= 0));
261  }
262  std::sort(list.begin() + newgrf_size, list.end(), DropDownListStringItem::NatSortFunc);
263  break;
264  }
265 
266  case WID_GO_AUTOSAVE_DROPDOWN: { // Setup autosave dropdown
267  *selected_index = _settings_client.gui.autosave;
268  const StringID *items = _autosave_dropdown;
269  for (uint i = 0; *items != INVALID_STRING_ID; items++, i++) {
270  list.emplace_back(new DropDownListStringItem(*items, i, false));
271  }
272  break;
273  }
274 
275  case WID_GO_LANG_DROPDOWN: { // Setup interface language dropdown
276  for (uint i = 0; i < _languages.size(); i++) {
277  if (&_languages[i] == _current_language) *selected_index = i;
278  list.emplace_back(new DropDownListStringItem(SPECSTR_LANGUAGE_START + i, i, false));
279  }
280  std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
281  break;
282  }
283 
284  case WID_GO_RESOLUTION_DROPDOWN: // Setup resolution dropdown
285  if (_resolutions.empty()) break;
286 
287  *selected_index = GetCurRes();
288  for (uint i = 0; i < _resolutions.size(); i++) {
289  list.emplace_back(new DropDownListStringItem(SPECSTR_RESOLUTION_START + i, i, false));
290  }
291  break;
292 
294  *selected_index = ZOOM_LVL_OUT_4X - _gui_zoom;
295  const StringID *items = _gui_zoom_dropdown;
296  for (int i = 0; *items != INVALID_STRING_ID; items++, i++) {
297  list.emplace_back(new DropDownListStringItem(*items, i, _settings_client.gui.zoom_min > ZOOM_LVL_OUT_4X - i));
298  }
299  break;
300  }
301 
303  *selected_index = ZOOM_LVL_OUT_4X - _font_zoom;
304  const StringID *items = _font_zoom_dropdown;
305  for (int i = 0; *items != INVALID_STRING_ID; items++, i++) {
306  list.emplace_back(new DropDownListStringItem(*items, i, false));
307  }
308  break;
309  }
310 
312  list = BuildSetDropDownList<BaseGraphics>(selected_index, (_game_mode == GM_MENU));
313  break;
314 
316  list = BuildSetDropDownList<BaseSounds>(selected_index, (_game_mode == GM_MENU));
317  break;
318 
320  list = BuildMusicSetDropDownList(selected_index);
321  break;
322  }
323 
324  return list;
325  }
326 
327  void SetStringParameters(int widget) const override
328  {
329  switch (widget) {
330  case WID_GO_CURRENCY_DROPDOWN: SetDParam(0, _currency_specs[this->opt->locale.currency].name); break;
331  case WID_GO_ROADSIDE_DROPDOWN: SetDParam(0, STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_LEFT + this->opt->vehicle.road_side); break;
333  case WID_GO_AUTOSAVE_DROPDOWN: SetDParam(0, _autosave_dropdown[_settings_client.gui.autosave]); break;
335  case WID_GO_RESOLUTION_DROPDOWN: SetDParam(0, GetCurRes() == _resolutions.size() ? STR_GAME_OPTIONS_RESOLUTION_OTHER : SPECSTR_RESOLUTION_START + GetCurRes()); break;
336  case WID_GO_GUI_ZOOM_DROPDOWN: SetDParam(0, _gui_zoom_dropdown[ZOOM_LVL_OUT_4X - _gui_zoom]); break;
337  case WID_GO_FONT_ZOOM_DROPDOWN: SetDParam(0, _font_zoom_dropdown[ZOOM_LVL_OUT_4X - _font_zoom]); break;
338  case WID_GO_BASE_GRF_DROPDOWN: SetDParamStr(0, BaseGraphics::GetUsedSet()->name.c_str()); break;
339  case WID_GO_BASE_GRF_STATUS: SetDParam(0, BaseGraphics::GetUsedSet()->GetNumInvalid()); break;
340  case WID_GO_BASE_SFX_DROPDOWN: SetDParamStr(0, BaseSounds::GetUsedSet()->name.c_str()); break;
341  case WID_GO_BASE_MUSIC_DROPDOWN: SetDParamStr(0, BaseMusic::GetUsedSet()->name.c_str()); break;
342  case WID_GO_BASE_MUSIC_STATUS: SetDParam(0, BaseMusic::GetUsedSet()->GetNumInvalid()); break;
343  }
344  }
345 
346  void DrawWidget(const Rect &r, int widget) const override
347  {
348  switch (widget) {
351  DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_BLACK_RAW_STRING);
352  break;
353 
356  DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_BLACK_RAW_STRING);
357  break;
358 
361  DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_BLACK_RAW_STRING);
362  break;
363  }
364  }
365 
366  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
367  {
368  switch (widget) {
370  /* Find the biggest description for the default size. */
371  for (int i = 0; i < BaseGraphics::GetNumSets(); i++) {
373  size->height = std::max(size->height, (uint)GetStringHeight(STR_BLACK_RAW_STRING, size->width));
374  }
375  break;
376 
378  /* Find the biggest description for the default size. */
379  for (int i = 0; i < BaseGraphics::GetNumSets(); i++) {
380  uint invalid_files = BaseGraphics::GetSet(i)->GetNumInvalid();
381  if (invalid_files == 0) continue;
382 
383  SetDParam(0, invalid_files);
384  *size = maxdim(*size, GetStringBoundingBox(STR_GAME_OPTIONS_BASE_GRF_STATUS));
385  }
386  break;
387 
389  /* Find the biggest description for the default size. */
390  for (int i = 0; i < BaseSounds::GetNumSets(); i++) {
392  size->height = std::max(size->height, (uint)GetStringHeight(STR_BLACK_RAW_STRING, size->width));
393  }
394  break;
395 
397  /* Find the biggest description for the default size. */
398  for (int i = 0; i < BaseMusic::GetNumSets(); i++) {
399  SetDParamStr(0, BaseMusic::GetSet(i)->GetDescription(GetCurrentLanguageIsoCode()));
400  size->height = std::max(size->height, (uint)GetStringHeight(STR_BLACK_RAW_STRING, size->width));
401  }
402  break;
403 
405  /* Find the biggest description for the default size. */
406  for (int i = 0; i < BaseMusic::GetNumSets(); i++) {
407  uint invalid_files = BaseMusic::GetSet(i)->GetNumInvalid();
408  if (invalid_files == 0) continue;
409 
410  SetDParam(0, invalid_files);
411  *size = maxdim(*size, GetStringBoundingBox(STR_GAME_OPTIONS_BASE_MUSIC_STATUS));
412  }
413  break;
414 
415  default: {
416  int selected;
417  DropDownList list = this->BuildDropDownList(widget, &selected);
418  if (!list.empty()) {
419  /* Find the biggest item for the default size. */
420  for (const auto &ddli : list) {
421  Dimension string_dim;
422  int width = ddli->Width();
423  string_dim.width = width + padding.width;
424  string_dim.height = ddli->Height(width) + padding.height;
425  *size = maxdim(*size, string_dim);
426  }
427  }
428  }
429  }
430  }
431 
432  void OnClick(Point pt, int widget, int click_count) override
433  {
434  if (widget >= WID_GO_BASE_GRF_TEXTFILE && widget < WID_GO_BASE_GRF_TEXTFILE + TFT_END) {
435  if (BaseGraphics::GetUsedSet() == nullptr) return;
436 
437  ShowBaseSetTextfileWindow((TextfileType)(widget - WID_GO_BASE_GRF_TEXTFILE), BaseGraphics::GetUsedSet(), STR_CONTENT_TYPE_BASE_GRAPHICS);
438  return;
439  }
440  if (widget >= WID_GO_BASE_SFX_TEXTFILE && widget < WID_GO_BASE_SFX_TEXTFILE + TFT_END) {
441  if (BaseSounds::GetUsedSet() == nullptr) return;
442 
443  ShowBaseSetTextfileWindow((TextfileType)(widget - WID_GO_BASE_SFX_TEXTFILE), BaseSounds::GetUsedSet(), STR_CONTENT_TYPE_BASE_SOUNDS);
444  return;
445  }
446  if (widget >= WID_GO_BASE_MUSIC_TEXTFILE && widget < WID_GO_BASE_MUSIC_TEXTFILE + TFT_END) {
447  if (BaseMusic::GetUsedSet() == nullptr) return;
448 
449  ShowBaseSetTextfileWindow((TextfileType)(widget - WID_GO_BASE_MUSIC_TEXTFILE), BaseMusic::GetUsedSet(), STR_CONTENT_TYPE_BASE_MUSIC);
450  return;
451  }
452  switch (widget) {
453  case WID_GO_FULLSCREEN_BUTTON: // Click fullscreen on/off
454  /* try to toggle full-screen on/off */
455  if (!ToggleFullScreen(!_fullscreen)) {
456  ShowErrorMessage(STR_ERROR_FULLSCREEN_FAILED, INVALID_STRING_ID, WL_ERROR);
457  }
459  this->SetDirty();
460  break;
461 
462  default: {
463  int selected;
464  DropDownList list = this->BuildDropDownList(widget, &selected);
465  if (!list.empty()) {
466  ShowDropDownList(this, std::move(list), selected, widget);
467  } else {
468  if (widget == WID_GO_RESOLUTION_DROPDOWN) ShowErrorMessage(STR_ERROR_RESOLUTION_LIST_FAILED, INVALID_STRING_ID, WL_ERROR);
469  }
470  break;
471  }
472  }
473  }
474 
480  template <class T>
481  void SetMediaSet(int index)
482  {
483  if (_game_mode == GM_MENU) {
484  auto name = T::GetSet(index)->name;
485 
486  T::ini_set = name;
487 
488  T::SetSet(name);
489  this->reload = true;
490  this->InvalidateData();
491  }
492  }
493 
494  void OnDropdownSelect(int widget, int index) override
495  {
496  switch (widget) {
497  case WID_GO_CURRENCY_DROPDOWN: // Currency
498  if (index == CURRENCY_CUSTOM) ShowCustCurrency();
499  this->opt->locale.currency = index;
501  break;
502 
503  case WID_GO_ROADSIDE_DROPDOWN: // Road side
504  if (this->opt->vehicle.road_side != index) { // only change if setting changed
505  uint i;
506  if (GetSettingFromName("vehicle.road_side", &i) == nullptr) NOT_REACHED();
507  SetSettingValue(i, index);
509  }
510  break;
511 
512  case WID_GO_TOWNNAME_DROPDOWN: // Town names
513  if (_game_mode == GM_MENU || Town::GetNumItems() == 0) {
514  this->opt->game_creation.town_name = index;
516  }
517  break;
518 
519  case WID_GO_AUTOSAVE_DROPDOWN: // Autosave options
520  _settings_client.gui.autosave = index;
521  this->SetDirty();
522  break;
523 
524  case WID_GO_LANG_DROPDOWN: // Change interface language
525  ReadLanguagePack(&_languages[index]);
528  ClearAllCachedNames();
531  break;
532 
533  case WID_GO_RESOLUTION_DROPDOWN: // Change resolution
534  if ((uint)index < _resolutions.size() && ChangeResInGame(_resolutions[index].width, _resolutions[index].height)) {
535  this->SetDirty();
536  }
537  break;
538 
541  _gui_zoom = (ZoomLevel)(ZOOM_LVL_OUT_4X - index);
544  FixTitleGameZoom();
546  break;
547 
550  _font_zoom = (ZoomLevel)(ZOOM_LVL_OUT_4X - index);
551  ClearFontCache();
554  break;
555 
557  this->SetMediaSet<BaseGraphics>(index);
558  break;
559 
561  this->SetMediaSet<BaseSounds>(index);
562  break;
563 
565  ChangeMusicSet(index);
566  break;
567  }
568  }
569 
575  void OnInvalidateData(int data = 0, bool gui_scope = true) override
576  {
577  if (!gui_scope) return;
579 
580  bool missing_files = BaseGraphics::GetUsedSet()->GetNumMissing() == 0;
581  this->GetWidget<NWidgetCore>(WID_GO_BASE_GRF_STATUS)->SetDataTip(missing_files ? STR_EMPTY : STR_GAME_OPTIONS_BASE_GRF_STATUS, STR_NULL);
582 
583  for (TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) {
587  }
588 
589  missing_files = BaseMusic::GetUsedSet()->GetNumInvalid() == 0;
590  this->GetWidget<NWidgetCore>(WID_GO_BASE_MUSIC_STATUS)->SetDataTip(missing_files ? STR_EMPTY : STR_GAME_OPTIONS_BASE_MUSIC_STATUS, STR_NULL);
591  }
592 };
593 
594 static const NWidgetPart _nested_game_options_widgets[] = {
596  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
597  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
598  EndContainer(),
599  NWidget(WWT_PANEL, COLOUR_GREY, WID_GO_BACKGROUND), SetPIP(6, 6, 10),
600  NWidget(NWID_HORIZONTAL), SetPIP(10, 10, 10),
601  NWidget(NWID_VERTICAL), SetPIP(0, 6, 0),
602  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_ROAD_VEHICLES_FRAME, STR_NULL),
603  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_ROADSIDE_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_TOOLTIP), SetFill(1, 0),
604  EndContainer(),
605  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_AUTOSAVE_FRAME, STR_NULL),
606  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),
607  EndContainer(),
608  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_RESOLUTION, STR_NULL),
609  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_RESOLUTION_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_RESOLUTION_TOOLTIP), SetFill(1, 0), SetPadding(0, 0, 3, 0),
611  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 0), SetDataTip(STR_GAME_OPTIONS_FULLSCREEN, STR_NULL),
612  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_FULLSCREEN_BUTTON), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_FULLSCREEN_TOOLTIP),
613  EndContainer(),
614  EndContainer(),
615  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_GUI_ZOOM_FRAME, STR_NULL),
616  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_GUI_ZOOM_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_TOOLTIP), SetFill(1, 0),
617  EndContainer(),
618  EndContainer(),
619 
620  NWidget(NWID_VERTICAL), SetPIP(0, 6, 0),
621  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_TOWN_NAMES_FRAME, STR_NULL),
622  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_TOWNNAME_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_TOWN_NAMES_DROPDOWN_TOOLTIP), SetFill(1, 0),
623  EndContainer(),
624  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_LANGUAGE, STR_NULL),
625  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),
626  EndContainer(),
627  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_CURRENCY_UNITS_FRAME, STR_NULL),
628  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),
629  EndContainer(),
630  NWidget(NWID_SPACER), SetMinimalSize(0, 0), SetFill(0, 1),
631  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_FONT_ZOOM, STR_NULL),
632  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_FONT_ZOOM_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_TOOLTIP), SetFill(1, 0),
633  EndContainer(),
634  EndContainer(),
635  EndContainer(),
636 
637  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_BASE_GRF, STR_NULL), SetPadding(0, 10, 0, 10),
638  NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 0),
639  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_GRF_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_RAW_STRING, STR_GAME_OPTIONS_BASE_GRF_TOOLTIP),
640  NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_BASE_GRF_STATUS), SetMinimalSize(150, 12), SetDataTip(STR_EMPTY, STR_NULL), SetFill(1, 0),
641  EndContainer(),
642  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),
644  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),
645  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),
646  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),
647  EndContainer(),
648  EndContainer(),
649 
650  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_BASE_SFX, STR_NULL), SetPadding(0, 10, 0, 10),
651  NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 0),
652  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_SFX_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_RAW_STRING, STR_GAME_OPTIONS_BASE_SFX_TOOLTIP),
653  NWidget(NWID_SPACER), SetFill(1, 0),
654  EndContainer(),
655  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),
657  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),
658  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),
659  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),
660  EndContainer(),
661  EndContainer(),
662 
663  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_BASE_MUSIC, STR_NULL), SetPadding(0, 10, 0, 10),
664  NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 0),
665  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_MUSIC_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_RAW_STRING, STR_GAME_OPTIONS_BASE_MUSIC_TOOLTIP),
666  NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_BASE_MUSIC_STATUS), SetMinimalSize(150, 12), SetDataTip(STR_EMPTY, STR_NULL), SetFill(1, 0),
667  EndContainer(),
668  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),
670  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),
671  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),
672  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),
673  EndContainer(),
674  EndContainer(),
675  EndContainer(),
676 };
677 
678 static WindowDesc _game_options_desc(
679  WDP_CENTER, "settings_game", 0, 0,
681  0,
682  _nested_game_options_widgets, lengthof(_nested_game_options_widgets)
683 );
684 
687 {
689  new GameOptionsWindow(&_game_options_desc);
690 }
691 
692 static int SETTING_HEIGHT = 11;
693 static const int LEVEL_WIDTH = 15;
694 
703 
704  SEF_LAST_FIELD = 0x04,
705  SEF_FILTERED = 0x08,
706 };
707 
716 };
718 
719 
723  bool type_hides;
726 };
727 
730  byte flags;
731  byte level;
732 
733  BaseSettingEntry() : flags(0), level(0) {}
734  virtual ~BaseSettingEntry() {}
735 
736  virtual void Init(byte level = 0);
737  virtual void FoldAll() {}
738  virtual void UnFoldAll() {}
739 
744  void SetLastField(bool last_field) { if (last_field) SETBITS(this->flags, SEF_LAST_FIELD); else CLRBITS(this->flags, SEF_LAST_FIELD); }
745 
746  virtual uint Length() const = 0;
747  virtual void GetFoldingState(bool &all_folded, bool &all_unfolded) const {}
748  virtual bool IsVisible(const BaseSettingEntry *item) const;
749  virtual BaseSettingEntry *FindEntry(uint row, uint *cur_row);
750  virtual uint GetMaxHelpHeight(int maxw) { return 0; }
751 
756  bool IsFiltered() const { return (this->flags & SEF_FILTERED) != 0; }
757 
758  virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible) = 0;
759 
760  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;
761 
762 protected:
763  virtual void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const = 0;
764 };
765 
768  const char *name;
770  uint index;
771 
772  SettingEntry(const char *name);
773 
774  virtual void Init(byte level = 0);
775  virtual uint Length() const;
776  virtual uint GetMaxHelpHeight(int maxw);
777  virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible);
778 
779  void SetButtons(byte new_val);
780 
785  inline StringID GetHelpText() const
786  {
787  return this->setting->desc.str_help;
788  }
789 
790  void SetValueDParams(uint first_param, int32 value) const;
791 
792 protected:
793  virtual void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const;
794 
795 private:
797 };
798 
801  typedef std::vector<BaseSettingEntry*> EntryVector;
802  EntryVector entries;
803 
804  template<typename T>
805  T *Add(T *item)
806  {
807  this->entries.push_back(item);
808  return item;
809  }
810 
811  void Init(byte level = 0);
812  void FoldAll();
813  void UnFoldAll();
814 
815  uint Length() const;
816  void GetFoldingState(bool &all_folded, bool &all_unfolded) const;
817  bool IsVisible(const BaseSettingEntry *item) const;
818  BaseSettingEntry *FindEntry(uint row, uint *cur_row);
819  uint GetMaxHelpHeight(int maxw);
820 
821  bool UpdateFilterState(SettingFilter &filter, bool force_visible);
822 
823  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;
824 };
825 
829  bool folded;
830 
832 
833  virtual void Init(byte level = 0);
834  virtual void FoldAll();
835  virtual void UnFoldAll();
836 
837  virtual uint Length() const;
838  virtual void GetFoldingState(bool &all_folded, bool &all_unfolded) const;
839  virtual bool IsVisible(const BaseSettingEntry *item) const;
840  virtual BaseSettingEntry *FindEntry(uint row, uint *cur_row);
841  virtual uint GetMaxHelpHeight(int maxw) { return SettingsContainer::GetMaxHelpHeight(maxw); }
842 
843  virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible);
844 
845  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;
846 
847 protected:
848  virtual void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const;
849 };
850 
851 /* == BaseSettingEntry methods == */
852 
857 void BaseSettingEntry::Init(byte level)
858 {
859  this->level = level;
860 }
861 
869 {
870  if (this->IsFiltered()) return false;
871  if (this == item) return true;
872  return false;
873 }
874 
881 BaseSettingEntry *BaseSettingEntry::FindEntry(uint row_num, uint *cur_row)
882 {
883  if (this->IsFiltered()) return nullptr;
884  if (row_num == *cur_row) return this;
885  (*cur_row)++;
886  return nullptr;
887 }
888 
918 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
919 {
920  if (this->IsFiltered()) return cur_row;
921  if (cur_row >= max_row) return cur_row;
922 
923  bool rtl = _current_text_dir == TD_RTL;
924  int offset = rtl ? -4 : 4;
925  int level_width = rtl ? -LEVEL_WIDTH : LEVEL_WIDTH;
926 
927  int x = rtl ? right : left;
928  if (cur_row >= first_row) {
929  int colour = _colour_gradient[COLOUR_ORANGE][4];
930  y += (cur_row - first_row) * SETTING_HEIGHT; // Compute correct y start position
931 
932  /* Draw vertical for parent nesting levels */
933  for (uint lvl = 0; lvl < this->level; lvl++) {
934  if (!HasBit(parent_last, lvl)) GfxDrawLine(x + offset, y, x + offset, y + SETTING_HEIGHT - 1, colour);
935  x += level_width;
936  }
937  /* draw own |- prefix */
938  int halfway_y = y + SETTING_HEIGHT / 2;
939  int bottom_y = (flags & SEF_LAST_FIELD) ? halfway_y : y + SETTING_HEIGHT - 1;
940  GfxDrawLine(x + offset, y, x + offset, bottom_y, colour);
941  /* Small horizontal line from the last vertical line */
942  GfxDrawLine(x + offset, halfway_y, x + level_width - offset, halfway_y, colour);
943  x += level_width;
944 
945  this->DrawSetting(settings_ptr, rtl ? left : x, rtl ? x : right, y, this == selected);
946  }
947  cur_row++;
948 
949  return cur_row;
950 }
951 
952 /* == SettingEntry methods == */
953 
958 SettingEntry::SettingEntry(const char *name)
959 {
960  this->name = name;
961  this->setting = nullptr;
962  this->index = 0;
963 }
964 
969 void SettingEntry::Init(byte level)
970 {
972  this->setting = GetSettingFromName(this->name, &this->index);
973  assert(this->setting != nullptr);
974 }
975 
981 void SettingEntry::SetButtons(byte new_val)
982 {
983  assert((new_val & ~SEF_BUTTONS_MASK) == 0); // Should not touch any flags outside the buttons
984  this->flags = (this->flags & ~SEF_BUTTONS_MASK) | new_val;
985 }
986 
989 {
990  return this->IsFiltered() ? 0 : 1;
991 }
992 
999 {
1000  return GetStringHeight(this->GetHelpText(), maxw);
1001 }
1002 
1009 {
1010  /* There shall not be any restriction, i.e. all settings shall be visible. */
1011  if (mode == RM_ALL) return true;
1012 
1013  GameSettings *settings_ptr = &GetGameSettings();
1014  const SettingDesc *sd = this->setting;
1015 
1016  if (mode == RM_BASIC) return (this->setting->desc.cat & SC_BASIC_LIST) != 0;
1017  if (mode == RM_ADVANCED) return (this->setting->desc.cat & SC_ADVANCED_LIST) != 0;
1018 
1019  /* Read the current value. */
1020  const void *var = ResolveVariableAddress(settings_ptr, sd);
1021  int64 current_value = ReadValue(var, sd->save.conv);
1022 
1023  int64 filter_value;
1024 
1025  if (mode == RM_CHANGED_AGAINST_DEFAULT) {
1026  /* This entry shall only be visible, if the value deviates from its default value. */
1027 
1028  /* Read the default value. */
1029  filter_value = ReadValue(&sd->desc.def, sd->save.conv);
1030  } else {
1031  assert(mode == RM_CHANGED_AGAINST_NEW);
1032  /* This entry shall only be visible, if the value deviates from
1033  * its value is used when starting a new game. */
1034 
1035  /* Make sure we're not comparing the new game settings against itself. */
1036  assert(settings_ptr != &_settings_newgame);
1037 
1038  /* Read the new game's value. */
1039  var = ResolveVariableAddress(&_settings_newgame, sd);
1040  filter_value = ReadValue(var, sd->save.conv);
1041  }
1042 
1043  return current_value != filter_value;
1044 }
1045 
1052 bool SettingEntry::UpdateFilterState(SettingFilter &filter, bool force_visible)
1053 {
1054  CLRBITS(this->flags, SEF_FILTERED);
1055 
1056  bool visible = true;
1057 
1058  const SettingDesc *sd = this->setting;
1059  if (!force_visible && !filter.string.IsEmpty()) {
1060  /* Process the search text filter for this item. */
1061  filter.string.ResetState();
1062 
1063  const SettingDescBase *sdb = &sd->desc;
1064 
1065  SetDParam(0, STR_EMPTY);
1066  filter.string.AddLine(sdb->str);
1067  filter.string.AddLine(this->GetHelpText());
1068 
1069  visible = filter.string.GetState();
1070  }
1071 
1072  if (visible) {
1073  if (filter.type != ST_ALL && sd->GetType() != filter.type) {
1074  filter.type_hides = true;
1075  visible = false;
1076  }
1077  if (!this->IsVisibleByRestrictionMode(filter.mode)) {
1078  while (filter.min_cat < RM_ALL && (filter.min_cat == filter.mode || !this->IsVisibleByRestrictionMode(filter.min_cat))) filter.min_cat++;
1079  visible = false;
1080  }
1081  }
1082 
1083  if (!visible) SETBITS(this->flags, SEF_FILTERED);
1084  return visible;
1085 }
1086 
1087 
1088 static const void *ResolveVariableAddress(const GameSettings *settings_ptr, const SettingDesc *sd)
1089 {
1090  if ((sd->desc.flags & SGF_PER_COMPANY) != 0) {
1091  if (Company::IsValidID(_local_company) && _game_mode != GM_MENU) {
1093  } else {
1095  }
1096  } else {
1097  return GetVariableAddress(settings_ptr, &sd->save);
1098  }
1099 }
1100 
1106 void SettingEntry::SetValueDParams(uint first_param, int32 value) const
1107 {
1108  const SettingDescBase *sdb = &this->setting->desc;
1109  if (sdb->cmd == SDT_BOOLX) {
1110  SetDParam(first_param++, value != 0 ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
1111  } else {
1112  if ((sdb->flags & SGF_MULTISTRING) != 0) {
1113  SetDParam(first_param++, sdb->str_val - sdb->min + value);
1114  } else if ((sdb->flags & SGF_DISPLAY_ABS) != 0) {
1115  SetDParam(first_param++, sdb->str_val + ((value >= 0) ? 1 : 0));
1116  value = abs(value);
1117  } else {
1118  SetDParam(first_param++, sdb->str_val + ((value == 0 && (sdb->flags & SGF_0ISDISABLED) != 0) ? 1 : 0));
1119  }
1120  SetDParam(first_param++, value);
1121  }
1122 }
1123 
1132 void SettingEntry::DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const
1133 {
1134  const SettingDesc *sd = this->setting;
1135  const SettingDescBase *sdb = &sd->desc;
1136  const void *var = ResolveVariableAddress(settings_ptr, sd);
1137  int state = this->flags & SEF_BUTTONS_MASK;
1138 
1139  bool rtl = _current_text_dir == TD_RTL;
1140  uint buttons_left = rtl ? right + 1 - SETTING_BUTTON_WIDTH : left;
1141  uint text_left = left + (rtl ? 0 : SETTING_BUTTON_WIDTH + 5);
1142  uint text_right = right - (rtl ? SETTING_BUTTON_WIDTH + 5 : 0);
1143  uint button_y = y + (SETTING_HEIGHT - SETTING_BUTTON_HEIGHT) / 2;
1144 
1145  /* We do not allow changes of some items when we are a client in a networkgame */
1146  bool editable = sd->IsEditable();
1147 
1148  SetDParam(0, highlight ? STR_ORANGE_STRING1_WHITE : STR_ORANGE_STRING1_LTBLUE);
1149  int32 value = (int32)ReadValue(var, sd->save.conv);
1150  if (sdb->cmd == SDT_BOOLX) {
1151  /* Draw checkbox for boolean-value either on/off */
1152  DrawBoolButton(buttons_left, button_y, value != 0, editable);
1153  } else if ((sdb->flags & SGF_MULTISTRING) != 0) {
1154  /* Draw [v] button for settings of an enum-type */
1155  DrawDropDownButton(buttons_left, button_y, COLOUR_YELLOW, state != 0, editable);
1156  } else {
1157  /* Draw [<][>] boxes for settings of an integer-type */
1158  DrawArrowButtons(buttons_left, button_y, COLOUR_YELLOW, state,
1159  editable && value != (sdb->flags & SGF_0ISDISABLED ? 0 : sdb->min), editable && (uint32)value != sdb->max);
1160  }
1161  this->SetValueDParams(1, value);
1162  DrawString(text_left, text_right, y + (SETTING_HEIGHT - FONT_HEIGHT_NORMAL) / 2, sdb->str, highlight ? TC_WHITE : TC_LIGHT_BLUE);
1163 }
1164 
1165 /* == SettingsContainer methods == */
1166 
1171 void SettingsContainer::Init(byte level)
1172 {
1173  for (EntryVector::iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1174  (*it)->Init(level);
1175  }
1176 }
1177 
1180 {
1181  for (EntryVector::iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1182  (*it)->FoldAll();
1183  }
1184 }
1185 
1188 {
1189  for (EntryVector::iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1190  (*it)->UnFoldAll();
1191  }
1192 }
1193 
1199 void SettingsContainer::GetFoldingState(bool &all_folded, bool &all_unfolded) const
1200 {
1201  for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1202  (*it)->GetFoldingState(all_folded, all_unfolded);
1203  }
1204 }
1205 
1212 bool SettingsContainer::UpdateFilterState(SettingFilter &filter, bool force_visible)
1213 {
1214  bool visible = false;
1215  bool first_visible = true;
1216  for (EntryVector::reverse_iterator it = this->entries.rbegin(); it != this->entries.rend(); ++it) {
1217  visible |= (*it)->UpdateFilterState(filter, force_visible);
1218  (*it)->SetLastField(first_visible);
1219  if (visible && first_visible) first_visible = false;
1220  }
1221  return visible;
1222 }
1223 
1224 
1232 {
1233  for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1234  if ((*it)->IsVisible(item)) return true;
1235  }
1236  return false;
1237 }
1238 
1241 {
1242  uint length = 0;
1243  for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1244  length += (*it)->Length();
1245  }
1246  return length;
1247 }
1248 
1255 BaseSettingEntry *SettingsContainer::FindEntry(uint row_num, uint *cur_row)
1256 {
1257  BaseSettingEntry *pe = nullptr;
1258  for (EntryVector::iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1259  pe = (*it)->FindEntry(row_num, cur_row);
1260  if (pe != nullptr) {
1261  break;
1262  }
1263  }
1264  return pe;
1265 }
1266 
1273 {
1274  uint biggest = 0;
1275  for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1276  biggest = std::max(biggest, (*it)->GetMaxHelpHeight(maxw));
1277  }
1278  return biggest;
1279 }
1280 
1281 
1296 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
1297 {
1298  for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1299  cur_row = (*it)->Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1300  if (cur_row >= max_row) {
1301  break;
1302  }
1303  }
1304  return cur_row;
1305 }
1306 
1307 /* == SettingsPage methods == */
1308 
1314 {
1315  this->title = title;
1316  this->folded = true;
1317 }
1318 
1323 void SettingsPage::Init(byte level)
1324 {
1327 }
1328 
1331 {
1332  if (this->IsFiltered()) return;
1333  this->folded = true;
1334 
1336 }
1337 
1340 {
1341  if (this->IsFiltered()) return;
1342  this->folded = false;
1343 
1345 }
1346 
1352 void SettingsPage::GetFoldingState(bool &all_folded, bool &all_unfolded) const
1353 {
1354  if (this->IsFiltered()) return;
1355 
1356  if (this->folded) {
1357  all_unfolded = false;
1358  } else {
1359  all_folded = false;
1360  }
1361 
1362  SettingsContainer::GetFoldingState(all_folded, all_unfolded);
1363 }
1364 
1371 bool SettingsPage::UpdateFilterState(SettingFilter &filter, bool force_visible)
1372 {
1373  if (!force_visible && !filter.string.IsEmpty()) {
1374  filter.string.ResetState();
1375  filter.string.AddLine(this->title);
1376  force_visible = filter.string.GetState();
1377  }
1378 
1379  bool visible = SettingsContainer::UpdateFilterState(filter, force_visible);
1380  if (visible) {
1381  CLRBITS(this->flags, SEF_FILTERED);
1382  } else {
1383  SETBITS(this->flags, SEF_FILTERED);
1384  }
1385  return visible;
1386 }
1387 
1395 {
1396  if (this->IsFiltered()) return false;
1397  if (this == item) return true;
1398  if (this->folded) return false;
1399 
1400  return SettingsContainer::IsVisible(item);
1401 }
1402 
1405 {
1406  if (this->IsFiltered()) return 0;
1407  if (this->folded) return 1; // Only displaying the title
1408 
1409  return 1 + SettingsContainer::Length();
1410 }
1411 
1418 BaseSettingEntry *SettingsPage::FindEntry(uint row_num, uint *cur_row)
1419 {
1420  if (this->IsFiltered()) return nullptr;
1421  if (row_num == *cur_row) return this;
1422  (*cur_row)++;
1423  if (this->folded) return nullptr;
1424 
1425  return SettingsContainer::FindEntry(row_num, cur_row);
1426 }
1427 
1442 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
1443 {
1444  if (this->IsFiltered()) return cur_row;
1445  if (cur_row >= max_row) return cur_row;
1446 
1447  cur_row = BaseSettingEntry::Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1448 
1449  if (!this->folded) {
1450  if (this->flags & SEF_LAST_FIELD) {
1451  assert(this->level < 8 * sizeof(parent_last));
1452  SetBit(parent_last, this->level); // Add own last-field state
1453  }
1454 
1455  cur_row = SettingsContainer::Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1456  }
1457 
1458  return cur_row;
1459 }
1460 
1469 void SettingsPage::DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const
1470 {
1471  bool rtl = _current_text_dir == TD_RTL;
1472  DrawSprite((this->folded ? SPR_CIRCLE_FOLDED : SPR_CIRCLE_UNFOLDED), PAL_NONE, rtl ? right - _circle_size.width : left, y + (SETTING_HEIGHT - _circle_size.height) / 2);
1473  DrawString(rtl ? left : left + _circle_size.width + 2, rtl ? right - _circle_size.width - 2 : right, y + (SETTING_HEIGHT - FONT_HEIGHT_NORMAL) / 2, this->title);
1474 }
1475 
1478 {
1479  static SettingsContainer *main = nullptr;
1480 
1481  if (main == nullptr)
1482  {
1483  /* Build up the dynamic settings-array only once per OpenTTD session */
1484  main = new SettingsContainer();
1485 
1486  SettingsPage *localisation = main->Add(new SettingsPage(STR_CONFIG_SETTING_LOCALISATION));
1487  {
1488  localisation->Add(new SettingEntry("locale.units_velocity"));
1489  localisation->Add(new SettingEntry("locale.units_power"));
1490  localisation->Add(new SettingEntry("locale.units_weight"));
1491  localisation->Add(new SettingEntry("locale.units_volume"));
1492  localisation->Add(new SettingEntry("locale.units_force"));
1493  localisation->Add(new SettingEntry("locale.units_height"));
1494  localisation->Add(new SettingEntry("gui.date_format_in_default_names"));
1495  }
1496 
1497  SettingsPage *graphics = main->Add(new SettingsPage(STR_CONFIG_SETTING_GRAPHICS));
1498  {
1499  graphics->Add(new SettingEntry("gui.zoom_min"));
1500  graphics->Add(new SettingEntry("gui.zoom_max"));
1501  graphics->Add(new SettingEntry("gui.smallmap_land_colour"));
1502  graphics->Add(new SettingEntry("gui.graph_line_thickness"));
1503  }
1504 
1505  SettingsPage *sound = main->Add(new SettingsPage(STR_CONFIG_SETTING_SOUND));
1506  {
1507  sound->Add(new SettingEntry("sound.click_beep"));
1508  sound->Add(new SettingEntry("sound.confirm"));
1509  sound->Add(new SettingEntry("sound.news_ticker"));
1510  sound->Add(new SettingEntry("sound.news_full"));
1511  sound->Add(new SettingEntry("sound.new_year"));
1512  sound->Add(new SettingEntry("sound.disaster"));
1513  sound->Add(new SettingEntry("sound.vehicle"));
1514  sound->Add(new SettingEntry("sound.ambient"));
1515  }
1516 
1517  SettingsPage *interface = main->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE));
1518  {
1519  SettingsPage *general = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_GENERAL));
1520  {
1521  general->Add(new SettingEntry("gui.osk_activation"));
1522  general->Add(new SettingEntry("gui.hover_delay_ms"));
1523  general->Add(new SettingEntry("gui.errmsg_duration"));
1524  general->Add(new SettingEntry("gui.window_snap_radius"));
1525  general->Add(new SettingEntry("gui.window_soft_limit"));
1526  general->Add(new SettingEntry("gui.right_mouse_wnd_close"));
1527  }
1528 
1529  SettingsPage *viewports = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_VIEWPORTS));
1530  {
1531  viewports->Add(new SettingEntry("gui.auto_scrolling"));
1532  viewports->Add(new SettingEntry("gui.scroll_mode"));
1533  viewports->Add(new SettingEntry("gui.smooth_scroll"));
1534  /* While the horizontal scrollwheel scrolling is written as general code, only
1535  * the cocoa (OSX) driver generates input for it.
1536  * Since it's also able to completely disable the scrollwheel will we display it on all platforms anyway */
1537  viewports->Add(new SettingEntry("gui.scrollwheel_scrolling"));
1538  viewports->Add(new SettingEntry("gui.scrollwheel_multiplier"));
1539 #ifdef __APPLE__
1540  /* We might need to emulate a right mouse button on mac */
1541  viewports->Add(new SettingEntry("gui.right_mouse_btn_emulation"));
1542 #endif
1543  viewports->Add(new SettingEntry("gui.population_in_label"));
1544  viewports->Add(new SettingEntry("gui.liveries"));
1545  viewports->Add(new SettingEntry("construction.train_signal_side"));
1546  viewports->Add(new SettingEntry("gui.measure_tooltip"));
1547  viewports->Add(new SettingEntry("gui.loading_indicators"));
1548  viewports->Add(new SettingEntry("gui.show_track_reservation"));
1549  }
1550 
1551  SettingsPage *construction = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_CONSTRUCTION));
1552  {
1553  construction->Add(new SettingEntry("gui.link_terraform_toolbar"));
1554  construction->Add(new SettingEntry("gui.enable_signal_gui"));
1555  construction->Add(new SettingEntry("gui.persistent_buildingtools"));
1556  construction->Add(new SettingEntry("gui.quick_goto"));
1557  construction->Add(new SettingEntry("gui.default_rail_type"));
1558  }
1559 
1560  interface->Add(new SettingEntry("gui.autosave"));
1561  interface->Add(new SettingEntry("gui.toolbar_pos"));
1562  interface->Add(new SettingEntry("gui.statusbar_pos"));
1563  interface->Add(new SettingEntry("gui.prefer_teamchat"));
1564  interface->Add(new SettingEntry("gui.advanced_vehicle_list"));
1565  interface->Add(new SettingEntry("gui.timetable_in_ticks"));
1566  interface->Add(new SettingEntry("gui.timetable_arrival_departure"));
1567  interface->Add(new SettingEntry("gui.expenses_layout"));
1568  interface->Add(new SettingEntry("gui.show_newgrf_name"));
1569  }
1570 
1571  SettingsPage *advisors = main->Add(new SettingsPage(STR_CONFIG_SETTING_ADVISORS));
1572  {
1573  advisors->Add(new SettingEntry("gui.coloured_news_year"));
1574  advisors->Add(new SettingEntry("news_display.general"));
1575  advisors->Add(new SettingEntry("news_display.new_vehicles"));
1576  advisors->Add(new SettingEntry("news_display.accident"));
1577  advisors->Add(new SettingEntry("news_display.company_info"));
1578  advisors->Add(new SettingEntry("news_display.acceptance"));
1579  advisors->Add(new SettingEntry("news_display.arrival_player"));
1580  advisors->Add(new SettingEntry("news_display.arrival_other"));
1581  advisors->Add(new SettingEntry("news_display.advice"));
1582  advisors->Add(new SettingEntry("gui.order_review_system"));
1583  advisors->Add(new SettingEntry("gui.vehicle_income_warn"));
1584  advisors->Add(new SettingEntry("gui.lost_vehicle_warn"));
1585  advisors->Add(new SettingEntry("gui.show_finances"));
1586  advisors->Add(new SettingEntry("news_display.economy"));
1587  advisors->Add(new SettingEntry("news_display.subsidies"));
1588  advisors->Add(new SettingEntry("news_display.open"));
1589  advisors->Add(new SettingEntry("news_display.close"));
1590  advisors->Add(new SettingEntry("news_display.production_player"));
1591  advisors->Add(new SettingEntry("news_display.production_other"));
1592  advisors->Add(new SettingEntry("news_display.production_nobody"));
1593  }
1594 
1595  SettingsPage *company = main->Add(new SettingsPage(STR_CONFIG_SETTING_COMPANY));
1596  {
1597  company->Add(new SettingEntry("gui.semaphore_build_before"));
1598  company->Add(new SettingEntry("gui.default_signal_type"));
1599  company->Add(new SettingEntry("gui.cycle_signal_types"));
1600  company->Add(new SettingEntry("gui.drag_signals_fixed_distance"));
1601  company->Add(new SettingEntry("gui.auto_remove_signals"));
1602  company->Add(new SettingEntry("gui.new_nonstop"));
1603  company->Add(new SettingEntry("gui.stop_location"));
1604  company->Add(new SettingEntry("gui.starting_colour"));
1605  company->Add(new SettingEntry("company.engine_renew"));
1606  company->Add(new SettingEntry("company.engine_renew_months"));
1607  company->Add(new SettingEntry("company.engine_renew_money"));
1608  company->Add(new SettingEntry("vehicle.servint_ispercent"));
1609  company->Add(new SettingEntry("vehicle.servint_trains"));
1610  company->Add(new SettingEntry("vehicle.servint_roadveh"));
1611  company->Add(new SettingEntry("vehicle.servint_ships"));
1612  company->Add(new SettingEntry("vehicle.servint_aircraft"));
1613  }
1614 
1615  SettingsPage *accounting = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCOUNTING));
1616  {
1617  accounting->Add(new SettingEntry("economy.inflation"));
1618  accounting->Add(new SettingEntry("difficulty.initial_interest"));
1619  accounting->Add(new SettingEntry("difficulty.max_loan"));
1620  accounting->Add(new SettingEntry("difficulty.subsidy_multiplier"));
1621  accounting->Add(new SettingEntry("economy.feeder_payment_share"));
1622  accounting->Add(new SettingEntry("economy.infrastructure_maintenance"));
1623  accounting->Add(new SettingEntry("difficulty.vehicle_costs"));
1624  accounting->Add(new SettingEntry("difficulty.construction_cost"));
1625  }
1626 
1627  SettingsPage *vehicles = main->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES));
1628  {
1629  SettingsPage *physics = vehicles->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES_PHYSICS));
1630  {
1631  physics->Add(new SettingEntry("vehicle.train_acceleration_model"));
1632  physics->Add(new SettingEntry("vehicle.train_slope_steepness"));
1633  physics->Add(new SettingEntry("vehicle.wagon_speed_limits"));
1634  physics->Add(new SettingEntry("vehicle.freight_trains"));
1635  physics->Add(new SettingEntry("vehicle.roadveh_acceleration_model"));
1636  physics->Add(new SettingEntry("vehicle.roadveh_slope_steepness"));
1637  physics->Add(new SettingEntry("vehicle.smoke_amount"));
1638  physics->Add(new SettingEntry("vehicle.plane_speed"));
1639  }
1640 
1641  SettingsPage *routing = vehicles->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES_ROUTING));
1642  {
1643  routing->Add(new SettingEntry("pf.pathfinder_for_trains"));
1644  routing->Add(new SettingEntry("difficulty.line_reverse_mode"));
1645  routing->Add(new SettingEntry("pf.reverse_at_signals"));
1646  routing->Add(new SettingEntry("pf.forbid_90_deg"));
1647  routing->Add(new SettingEntry("pf.pathfinder_for_roadvehs"));
1648  routing->Add(new SettingEntry("pf.pathfinder_for_ships"));
1649  }
1650 
1651  vehicles->Add(new SettingEntry("order.no_servicing_if_no_breakdowns"));
1652  vehicles->Add(new SettingEntry("order.serviceathelipad"));
1653  }
1654 
1655  SettingsPage *limitations = main->Add(new SettingsPage(STR_CONFIG_SETTING_LIMITATIONS));
1656  {
1657  limitations->Add(new SettingEntry("construction.command_pause_level"));
1658  limitations->Add(new SettingEntry("construction.autoslope"));
1659  limitations->Add(new SettingEntry("construction.extra_dynamite"));
1660  limitations->Add(new SettingEntry("construction.max_heightlevel"));
1661  limitations->Add(new SettingEntry("construction.max_bridge_length"));
1662  limitations->Add(new SettingEntry("construction.max_bridge_height"));
1663  limitations->Add(new SettingEntry("construction.max_tunnel_length"));
1664  limitations->Add(new SettingEntry("station.never_expire_airports"));
1665  limitations->Add(new SettingEntry("vehicle.never_expire_vehicles"));
1666  limitations->Add(new SettingEntry("vehicle.max_trains"));
1667  limitations->Add(new SettingEntry("vehicle.max_roadveh"));
1668  limitations->Add(new SettingEntry("vehicle.max_aircraft"));
1669  limitations->Add(new SettingEntry("vehicle.max_ships"));
1670  limitations->Add(new SettingEntry("vehicle.max_train_length"));
1671  limitations->Add(new SettingEntry("station.station_spread"));
1672  limitations->Add(new SettingEntry("station.distant_join_stations"));
1673  limitations->Add(new SettingEntry("construction.road_stop_on_town_road"));
1674  limitations->Add(new SettingEntry("construction.road_stop_on_competitor_road"));
1675  limitations->Add(new SettingEntry("vehicle.disable_elrails"));
1676  }
1677 
1678  SettingsPage *disasters = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCIDENTS));
1679  {
1680  disasters->Add(new SettingEntry("difficulty.disasters"));
1681  disasters->Add(new SettingEntry("difficulty.economy"));
1682  disasters->Add(new SettingEntry("difficulty.vehicle_breakdowns"));
1683  disasters->Add(new SettingEntry("vehicle.plane_crashes"));
1684  }
1685 
1686  SettingsPage *genworld = main->Add(new SettingsPage(STR_CONFIG_SETTING_GENWORLD));
1687  {
1688  genworld->Add(new SettingEntry("game_creation.landscape"));
1689  genworld->Add(new SettingEntry("game_creation.land_generator"));
1690  genworld->Add(new SettingEntry("difficulty.terrain_type"));
1691  genworld->Add(new SettingEntry("game_creation.tgen_smoothness"));
1692  genworld->Add(new SettingEntry("game_creation.variety"));
1693  genworld->Add(new SettingEntry("game_creation.snow_line_height"));
1694  genworld->Add(new SettingEntry("game_creation.amount_of_rivers"));
1695  genworld->Add(new SettingEntry("game_creation.tree_placer"));
1696  genworld->Add(new SettingEntry("vehicle.road_side"));
1697  genworld->Add(new SettingEntry("economy.larger_towns"));
1698  genworld->Add(new SettingEntry("economy.initial_city_size"));
1699  genworld->Add(new SettingEntry("economy.town_layout"));
1700  genworld->Add(new SettingEntry("difficulty.industry_density"));
1701  genworld->Add(new SettingEntry("gui.pause_on_newgame"));
1702  genworld->Add(new SettingEntry("game_creation.ending_year"));
1703  }
1704 
1705  SettingsPage *environment = main->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT));
1706  {
1707  SettingsPage *authorities = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_AUTHORITIES));
1708  {
1709  authorities->Add(new SettingEntry("difficulty.town_council_tolerance"));
1710  authorities->Add(new SettingEntry("economy.bribe"));
1711  authorities->Add(new SettingEntry("economy.exclusive_rights"));
1712  authorities->Add(new SettingEntry("economy.fund_roads"));
1713  authorities->Add(new SettingEntry("economy.fund_buildings"));
1714  authorities->Add(new SettingEntry("economy.station_noise_level"));
1715  }
1716 
1717  SettingsPage *towns = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_TOWNS));
1718  {
1719  towns->Add(new SettingEntry("economy.town_growth_rate"));
1720  towns->Add(new SettingEntry("economy.allow_town_roads"));
1721  towns->Add(new SettingEntry("economy.allow_town_level_crossings"));
1722  towns->Add(new SettingEntry("economy.found_town"));
1723  towns->Add(new SettingEntry("economy.town_cargogen_mode"));
1724  }
1725 
1726  SettingsPage *industries = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_INDUSTRIES));
1727  {
1728  industries->Add(new SettingEntry("construction.raw_industry_construction"));
1729  industries->Add(new SettingEntry("construction.industry_platform"));
1730  industries->Add(new SettingEntry("economy.multiple_industry_per_town"));
1731  industries->Add(new SettingEntry("game_creation.oil_refinery_limit"));
1732  industries->Add(new SettingEntry("economy.type"));
1733  industries->Add(new SettingEntry("station.serve_neutral_industries"));
1734  }
1735 
1736  SettingsPage *cdist = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST));
1737  {
1738  cdist->Add(new SettingEntry("linkgraph.recalc_time"));
1739  cdist->Add(new SettingEntry("linkgraph.recalc_interval"));
1740  cdist->Add(new SettingEntry("linkgraph.distribution_pax"));
1741  cdist->Add(new SettingEntry("linkgraph.distribution_mail"));
1742  cdist->Add(new SettingEntry("linkgraph.distribution_armoured"));
1743  cdist->Add(new SettingEntry("linkgraph.distribution_default"));
1744  cdist->Add(new SettingEntry("linkgraph.accuracy"));
1745  cdist->Add(new SettingEntry("linkgraph.demand_distance"));
1746  cdist->Add(new SettingEntry("linkgraph.demand_size"));
1747  cdist->Add(new SettingEntry("linkgraph.short_path_saturation"));
1748  }
1749 
1750  environment->Add(new SettingEntry("station.modified_catchment"));
1751  environment->Add(new SettingEntry("construction.extra_tree_placement"));
1752  }
1753 
1754  SettingsPage *ai = main->Add(new SettingsPage(STR_CONFIG_SETTING_AI));
1755  {
1756  SettingsPage *npc = ai->Add(new SettingsPage(STR_CONFIG_SETTING_AI_NPC));
1757  {
1758  npc->Add(new SettingEntry("script.settings_profile"));
1759  npc->Add(new SettingEntry("script.script_max_opcode_till_suspend"));
1760  npc->Add(new SettingEntry("script.script_max_memory_megabytes"));
1761  npc->Add(new SettingEntry("difficulty.competitor_speed"));
1762  npc->Add(new SettingEntry("ai.ai_in_multiplayer"));
1763  npc->Add(new SettingEntry("ai.ai_disable_veh_train"));
1764  npc->Add(new SettingEntry("ai.ai_disable_veh_roadveh"));
1765  npc->Add(new SettingEntry("ai.ai_disable_veh_aircraft"));
1766  npc->Add(new SettingEntry("ai.ai_disable_veh_ship"));
1767  }
1768 
1769  ai->Add(new SettingEntry("economy.give_money"));
1770  ai->Add(new SettingEntry("economy.allow_shares"));
1771  ai->Add(new SettingEntry("economy.min_years_for_shares"));
1772  }
1773 
1774  main->Init();
1775  }
1776  return *main;
1777 }
1778 
1779 static const StringID _game_settings_restrict_dropdown[] = {
1780  STR_CONFIG_SETTING_RESTRICT_BASIC, // RM_BASIC
1781  STR_CONFIG_SETTING_RESTRICT_ADVANCED, // RM_ADVANCED
1782  STR_CONFIG_SETTING_RESTRICT_ALL, // RM_ALL
1783  STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_DEFAULT, // RM_CHANGED_AGAINST_DEFAULT
1784  STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_NEW, // RM_CHANGED_AGAINST_NEW
1785 };
1786 static_assert(lengthof(_game_settings_restrict_dropdown) == RM_END);
1787 
1794 };
1795 
1798  static const int SETTINGTREE_LEFT_OFFSET = 5;
1799  static const int SETTINGTREE_RIGHT_OFFSET = 5;
1800  static const int SETTINGTREE_TOP_OFFSET = 5;
1801  static const int SETTINGTREE_BOTTOM_OFFSET = 5;
1802 
1804 
1810 
1816 
1817  Scrollbar *vscroll;
1818 
1820  {
1821  this->warn_missing = WHR_NONE;
1822  this->warn_lines = 0;
1824  this->filter.min_cat = RM_ALL;
1825  this->filter.type = ST_ALL;
1826  this->filter.type_hides = false;
1827  this->settings_ptr = &GetGameSettings();
1828 
1829  _circle_size = maxdim(GetSpriteSize(SPR_CIRCLE_FOLDED), GetSpriteSize(SPR_CIRCLE_UNFOLDED));
1830  GetSettingsTree().FoldAll(); // Close all sub-pages
1831 
1832  this->valuewindow_entry = nullptr; // No setting entry for which a entry window is opened
1833  this->clicked_entry = nullptr; // No numeric setting buttons are depressed
1834  this->last_clicked = nullptr;
1835  this->valuedropdown_entry = nullptr;
1836  this->closing_dropdown = false;
1837  this->manually_changed_folding = false;
1838 
1839  this->CreateNestedTree();
1840  this->vscroll = this->GetScrollbar(WID_GS_SCROLLBAR);
1842 
1843  this->querystrings[WID_GS_FILTER] = &this->filter_editbox;
1844  this->filter_editbox.cancel_button = QueryString::ACTION_CLEAR;
1846 
1847  this->InvalidateData();
1848  }
1849 
1850  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1851  {
1852  switch (widget) {
1853  case WID_GS_OPTIONSPANEL:
1854  resize->height = SETTING_HEIGHT = std::max({(int)_circle_size.height, SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL}) + 1;
1855  resize->width = 1;
1856 
1857  size->height = 5 * resize->height + SETTINGTREE_TOP_OFFSET + SETTINGTREE_BOTTOM_OFFSET;
1858  break;
1859 
1860  case WID_GS_HELP_TEXT: {
1861  static const StringID setting_types[] = {
1862  STR_CONFIG_SETTING_TYPE_CLIENT,
1863  STR_CONFIG_SETTING_TYPE_COMPANY_MENU, STR_CONFIG_SETTING_TYPE_COMPANY_INGAME,
1864  STR_CONFIG_SETTING_TYPE_GAME_MENU, STR_CONFIG_SETTING_TYPE_GAME_INGAME,
1865  };
1866  for (uint i = 0; i < lengthof(setting_types); i++) {
1867  SetDParam(0, setting_types[i]);
1868  size->width = std::max(size->width, GetStringBoundingBox(STR_CONFIG_SETTING_TYPE).width);
1869  }
1870  size->height = 2 * FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL +
1871  std::max(size->height, GetSettingsTree().GetMaxHelpHeight(size->width));
1872  break;
1873  }
1874 
1876  case WID_GS_RESTRICT_TYPE:
1877  size->width = std::max(GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_CATEGORY).width, GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_TYPE).width);
1878  break;
1879 
1880  default:
1881  break;
1882  }
1883  }
1884 
1885  void OnPaint() override
1886  {
1887  if (this->closing_dropdown) {
1888  this->closing_dropdown = false;
1889  assert(this->valuedropdown_entry != nullptr);
1890  this->valuedropdown_entry->SetButtons(0);
1891  this->valuedropdown_entry = nullptr;
1892  }
1893 
1894  /* Reserve the correct number of lines for the 'some search results are hidden' notice in the central settings display panel. */
1895  const NWidgetBase *panel = this->GetWidget<NWidgetBase>(WID_GS_OPTIONSPANEL);
1896  StringID warn_str = STR_CONFIG_SETTING_CATEGORY_HIDES - 1 + this->warn_missing;
1897  int new_warn_lines;
1898  if (this->warn_missing == WHR_NONE) {
1899  new_warn_lines = 0;
1900  } else {
1901  SetDParam(0, _game_settings_restrict_dropdown[this->filter.min_cat]);
1902  new_warn_lines = GetStringLineCount(warn_str, panel->current_x);
1903  }
1904  if (this->warn_lines != new_warn_lines) {
1905  this->vscroll->SetCount(this->vscroll->GetCount() - this->warn_lines + new_warn_lines);
1906  this->warn_lines = new_warn_lines;
1907  }
1908 
1909  this->DrawWidgets();
1910 
1911  /* Draw the 'some search results are hidden' notice. */
1912  if (this->warn_missing != WHR_NONE) {
1913  const int left = panel->pos_x;
1914  const int right = left + panel->current_x - 1;
1915  const int top = panel->pos_y + WD_FRAMETEXT_TOP + (SETTING_HEIGHT - FONT_HEIGHT_NORMAL) * this->warn_lines / 2;
1916  SetDParam(0, _game_settings_restrict_dropdown[this->filter.min_cat]);
1917  if (this->warn_lines == 1) {
1918  /* If the warning fits at one line, center it. */
1919  DrawString(left + WD_FRAMETEXT_LEFT, right - WD_FRAMETEXT_RIGHT, top, warn_str, TC_FROMSTRING, SA_HOR_CENTER);
1920  } else {
1921  DrawStringMultiLine(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, INT32_MAX, warn_str, TC_FROMSTRING, SA_HOR_CENTER);
1922  }
1923  }
1924  }
1925 
1926  void SetStringParameters(int widget) const override
1927  {
1928  switch (widget) {
1930  SetDParam(0, _game_settings_restrict_dropdown[this->filter.mode]);
1931  break;
1932 
1933  case WID_GS_TYPE_DROPDOWN:
1934  switch (this->filter.type) {
1935  case ST_GAME: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME); break;
1936  case ST_COMPANY: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME); break;
1937  case ST_CLIENT: SetDParam(0, STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT); break;
1938  default: SetDParam(0, STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL); break;
1939  }
1940  break;
1941  }
1942  }
1943 
1944  DropDownList BuildDropDownList(int widget) const
1945  {
1946  DropDownList list;
1947  switch (widget) {
1949  for (int mode = 0; mode != RM_END; mode++) {
1950  /* If we are in adv. settings screen for the new game's settings,
1951  * we don't want to allow comparing with new game's settings. */
1952  bool disabled = mode == RM_CHANGED_AGAINST_NEW && settings_ptr == &_settings_newgame;
1953 
1954  list.emplace_back(new DropDownListStringItem(_game_settings_restrict_dropdown[mode], mode, disabled));
1955  }
1956  break;
1957 
1958  case WID_GS_TYPE_DROPDOWN:
1959  list.emplace_back(new DropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL, ST_ALL, false));
1960  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));
1961  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));
1962  list.emplace_back(new DropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT, ST_CLIENT, false));
1963  break;
1964  }
1965  return list;
1966  }
1967 
1968  void DrawWidget(const Rect &r, int widget) const override
1969  {
1970  switch (widget) {
1971  case WID_GS_OPTIONSPANEL: {
1972  int top_pos = r.top + SETTINGTREE_TOP_OFFSET + 1 + this->warn_lines * SETTING_HEIGHT;
1973  uint last_row = this->vscroll->GetPosition() + this->vscroll->GetCapacity() - this->warn_lines;
1974  int next_row = GetSettingsTree().Draw(settings_ptr, r.left + SETTINGTREE_LEFT_OFFSET, r.right - SETTINGTREE_RIGHT_OFFSET, top_pos,
1975  this->vscroll->GetPosition(), last_row, this->last_clicked);
1976  if (next_row == 0) DrawString(r.left + SETTINGTREE_LEFT_OFFSET, r.right - SETTINGTREE_RIGHT_OFFSET, top_pos, STR_CONFIG_SETTINGS_NONE);
1977  break;
1978  }
1979 
1980  case WID_GS_HELP_TEXT:
1981  if (this->last_clicked != nullptr) {
1982  const SettingDesc *sd = this->last_clicked->setting;
1983 
1984  int y = r.top;
1985  switch (sd->GetType()) {
1986  case ST_COMPANY: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_COMPANY_INGAME); break;
1987  case ST_CLIENT: SetDParam(0, STR_CONFIG_SETTING_TYPE_CLIENT); break;
1988  case ST_GAME: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_GAME_MENU : STR_CONFIG_SETTING_TYPE_GAME_INGAME); break;
1989  default: NOT_REACHED();
1990  }
1991  DrawString(r.left, r.right, y, STR_CONFIG_SETTING_TYPE);
1992  y += FONT_HEIGHT_NORMAL;
1993 
1994  int32 default_value = ReadValue(&sd->desc.def, sd->save.conv);
1995  this->last_clicked->SetValueDParams(0, default_value);
1996  DrawString(r.left, r.right, y, STR_CONFIG_SETTING_DEFAULT_VALUE);
1998 
1999  DrawStringMultiLine(r.left, r.right, y, r.bottom, this->last_clicked->GetHelpText(), TC_WHITE);
2000  }
2001  break;
2002 
2003  default:
2004  break;
2005  }
2006  }
2007 
2013  {
2014  if (this->last_clicked != pe) this->SetDirty();
2015  this->last_clicked = pe;
2016  }
2017 
2018  void OnClick(Point pt, int widget, int click_count) override
2019  {
2020  switch (widget) {
2021  case WID_GS_EXPAND_ALL:
2022  this->manually_changed_folding = true;
2024  this->InvalidateData();
2025  break;
2026 
2027  case WID_GS_COLLAPSE_ALL:
2028  this->manually_changed_folding = true;
2030  this->InvalidateData();
2031  break;
2032 
2033  case WID_GS_RESTRICT_DROPDOWN: {
2034  DropDownList list = this->BuildDropDownList(widget);
2035  if (!list.empty()) {
2036  ShowDropDownList(this, std::move(list), this->filter.mode, widget);
2037  }
2038  break;
2039  }
2040 
2041  case WID_GS_TYPE_DROPDOWN: {
2042  DropDownList list = this->BuildDropDownList(widget);
2043  if (!list.empty()) {
2044  ShowDropDownList(this, std::move(list), this->filter.type, widget);
2045  }
2046  break;
2047  }
2048  }
2049 
2050  if (widget != WID_GS_OPTIONSPANEL) return;
2051 
2052  uint btn = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GS_OPTIONSPANEL, SETTINGTREE_TOP_OFFSET);
2053  if (btn == INT_MAX || (int)btn < this->warn_lines) return;
2054  btn -= this->warn_lines;
2055 
2056  uint cur_row = 0;
2058 
2059  if (clicked_entry == nullptr) return; // Clicked below the last setting of the page
2060 
2061  int x = (_current_text_dir == TD_RTL ? this->width - 1 - pt.x : pt.x) - SETTINGTREE_LEFT_OFFSET - (clicked_entry->level + 1) * LEVEL_WIDTH; // Shift x coordinate
2062  if (x < 0) return; // Clicked left of the entry
2063 
2064  SettingsPage *clicked_page = dynamic_cast<SettingsPage*>(clicked_entry);
2065  if (clicked_page != nullptr) {
2066  this->SetDisplayedHelpText(nullptr);
2067  clicked_page->folded = !clicked_page->folded; // Flip 'folded'-ness of the sub-page
2068 
2069  this->manually_changed_folding = true;
2070 
2071  this->InvalidateData();
2072  return;
2073  }
2074 
2075  SettingEntry *pe = dynamic_cast<SettingEntry*>(clicked_entry);
2076  assert(pe != nullptr);
2077  const SettingDesc *sd = pe->setting;
2078 
2079  /* return if action is only active in network, or only settable by server */
2080  if (!sd->IsEditable()) {
2081  this->SetDisplayedHelpText(pe);
2082  return;
2083  }
2084 
2085  const void *var = ResolveVariableAddress(settings_ptr, sd);
2086  int32 value = (int32)ReadValue(var, sd->save.conv);
2087 
2088  /* clicked on the icon on the left side. Either scroller, bool on/off or dropdown */
2089  if (x < SETTING_BUTTON_WIDTH && (sd->desc.flags & SGF_MULTISTRING)) {
2090  const SettingDescBase *sdb = &sd->desc;
2091  this->SetDisplayedHelpText(pe);
2092 
2093  if (this->valuedropdown_entry == pe) {
2094  /* unclick the dropdown */
2095  HideDropDownMenu(this);
2096  this->closing_dropdown = false;
2097  this->valuedropdown_entry->SetButtons(0);
2098  this->valuedropdown_entry = nullptr;
2099  } else {
2100  if (this->valuedropdown_entry != nullptr) this->valuedropdown_entry->SetButtons(0);
2101  this->closing_dropdown = false;
2102 
2103  const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_GS_OPTIONSPANEL);
2104  int rel_y = (pt.y - (int)wid->pos_y - SETTINGTREE_TOP_OFFSET) % wid->resize_y;
2105 
2106  Rect wi_rect;
2107  wi_rect.left = pt.x - (_current_text_dir == TD_RTL ? SETTING_BUTTON_WIDTH - 1 - x : x);
2108  wi_rect.right = wi_rect.left + SETTING_BUTTON_WIDTH - 1;
2109  wi_rect.top = pt.y - rel_y + (SETTING_HEIGHT - SETTING_BUTTON_HEIGHT) / 2;
2110  wi_rect.bottom = wi_rect.top + SETTING_BUTTON_HEIGHT - 1;
2111 
2112  /* For dropdowns we also have to check the y position thoroughly, the mouse may not above the just opening dropdown */
2113  if (pt.y >= wi_rect.top && pt.y <= wi_rect.bottom) {
2114  this->valuedropdown_entry = pe;
2115  this->valuedropdown_entry->SetButtons(SEF_LEFT_DEPRESSED);
2116 
2117  DropDownList list;
2118  for (int i = sdb->min; i <= (int)sdb->max; i++) {
2119  list.emplace_back(new DropDownListStringItem(sdb->str_val + i - sdb->min, i, false));
2120  }
2121 
2122  ShowDropDownListAt(this, std::move(list), value, -1, wi_rect, COLOUR_ORANGE, true);
2123  }
2124  }
2125  this->SetDirty();
2126  } else if (x < SETTING_BUTTON_WIDTH) {
2127  this->SetDisplayedHelpText(pe);
2128  const SettingDescBase *sdb = &sd->desc;
2129  int32 oldvalue = value;
2130 
2131  switch (sdb->cmd) {
2132  case SDT_BOOLX: value ^= 1; break;
2133  case SDT_ONEOFMANY:
2134  case SDT_NUMX: {
2135  /* Add a dynamic step-size to the scroller. In a maximum of
2136  * 50-steps you should be able to get from min to max,
2137  * unless specified otherwise in the 'interval' variable
2138  * of the current setting. */
2139  uint32 step = (sdb->interval == 0) ? ((sdb->max - sdb->min) / 50) : sdb->interval;
2140  if (step == 0) step = 1;
2141 
2142  /* don't allow too fast scrolling */
2143  if ((this->flags & WF_TIMEOUT) && this->timeout_timer > 1) {
2144  _left_button_clicked = false;
2145  return;
2146  }
2147 
2148  /* Increase or decrease the value and clamp it to extremes */
2149  if (x >= SETTING_BUTTON_WIDTH / 2) {
2150  value += step;
2151  if (sdb->min < 0) {
2152  assert((int32)sdb->max >= 0);
2153  if (value > (int32)sdb->max) value = (int32)sdb->max;
2154  } else {
2155  if ((uint32)value > sdb->max) value = (int32)sdb->max;
2156  }
2157  if (value < sdb->min) value = sdb->min; // skip between "disabled" and minimum
2158  } else {
2159  value -= step;
2160  if (value < sdb->min) value = (sdb->flags & SGF_0ISDISABLED) ? 0 : sdb->min;
2161  }
2162 
2163  /* Set up scroller timeout for numeric values */
2164  if (value != oldvalue) {
2165  if (this->clicked_entry != nullptr) { // Release previous buttons if any
2166  this->clicked_entry->SetButtons(0);
2167  }
2168  this->clicked_entry = pe;
2169  this->clicked_entry->SetButtons((x >= SETTING_BUTTON_WIDTH / 2) != (_current_text_dir == TD_RTL) ? SEF_RIGHT_DEPRESSED : SEF_LEFT_DEPRESSED);
2170  this->SetTimeout();
2171  _left_button_clicked = false;
2172  }
2173  break;
2174  }
2175 
2176  default: NOT_REACHED();
2177  }
2178 
2179  if (value != oldvalue) {
2180  if ((sd->desc.flags & SGF_PER_COMPANY) != 0) {
2181  SetCompanySetting(pe->index, value);
2182  } else {
2183  SetSettingValue(pe->index, value);
2184  }
2185  this->SetDirty();
2186  }
2187  } else {
2188  /* Only open editbox if clicked for the second time, and only for types where it is sensible for. */
2189  if (this->last_clicked == pe && sd->desc.cmd != SDT_BOOLX && !(sd->desc.flags & SGF_MULTISTRING)) {
2190  int64 value64 = value;
2191  /* Show the correct currency-translated value */
2192  if (sd->desc.flags & SGF_CURRENCY) value64 *= _currency->rate;
2193 
2194  this->valuewindow_entry = pe;
2195  SetDParam(0, value64);
2196  /* Limit string length to 14 so that MAX_INT32 * max currency rate doesn't exceed MAX_INT64. */
2197  ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 15, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
2198  }
2199  this->SetDisplayedHelpText(pe);
2200  }
2201  }
2202 
2203  void OnTimeout() override
2204  {
2205  if (this->clicked_entry != nullptr) { // On timeout, release any depressed buttons
2206  this->clicked_entry->SetButtons(0);
2207  this->clicked_entry = nullptr;
2208  this->SetDirty();
2209  }
2210  }
2211 
2212  void OnQueryTextFinished(char *str) override
2213  {
2214  /* The user pressed cancel */
2215  if (str == nullptr) return;
2216 
2217  assert(this->valuewindow_entry != nullptr);
2218  const SettingDesc *sd = this->valuewindow_entry->setting;
2219 
2220  int32 value;
2221  if (!StrEmpty(str)) {
2222  long long llvalue = atoll(str);
2223 
2224  /* Save the correct currency-translated value */
2225  if (sd->desc.flags & SGF_CURRENCY) llvalue /= _currency->rate;
2226 
2227  value = (int32)ClampToI32(llvalue);
2228  } else {
2229  value = (int32)(size_t)sd->desc.def;
2230  }
2231 
2232  if ((sd->desc.flags & SGF_PER_COMPANY) != 0) {
2233  SetCompanySetting(this->valuewindow_entry->index, value);
2234  } else {
2235  SetSettingValue(this->valuewindow_entry->index, value);
2236  }
2237  this->SetDirty();
2238  }
2239 
2240  void OnDropdownSelect(int widget, int index) override
2241  {
2242  switch (widget) {
2244  this->filter.mode = (RestrictionMode)index;
2245  if (this->filter.mode == RM_CHANGED_AGAINST_DEFAULT ||
2246  this->filter.mode == RM_CHANGED_AGAINST_NEW) {
2247 
2248  if (!this->manually_changed_folding) {
2249  /* Expand all when selecting 'changes'. Update the filter state first, in case it becomes less restrictive in some cases. */
2250  GetSettingsTree().UpdateFilterState(this->filter, false);
2252  }
2253  } else {
2254  /* Non-'changes' filter. Save as default. */
2256  }
2257  this->InvalidateData();
2258  break;
2259 
2260  case WID_GS_TYPE_DROPDOWN:
2261  this->filter.type = (SettingType)index;
2262  this->InvalidateData();
2263  break;
2264 
2265  default:
2266  if (widget < 0) {
2267  /* Deal with drop down boxes on the panel. */
2268  assert(this->valuedropdown_entry != nullptr);
2269  const SettingDesc *sd = this->valuedropdown_entry->setting;
2270  assert(sd->desc.flags & SGF_MULTISTRING);
2271 
2272  if ((sd->desc.flags & SGF_PER_COMPANY) != 0) {
2273  SetCompanySetting(this->valuedropdown_entry->index, index);
2274  } else {
2275  SetSettingValue(this->valuedropdown_entry->index, index);
2276  }
2277 
2278  this->SetDirty();
2279  }
2280  break;
2281  }
2282  }
2283 
2284  void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override
2285  {
2286  if (widget >= 0) {
2287  /* Normally the default implementation of OnDropdownClose() takes care of
2288  * a few things. We want that behaviour here too, but only for
2289  * "normal" dropdown boxes. The special dropdown boxes added for every
2290  * setting that needs one can't have this call. */
2291  Window::OnDropdownClose(pt, widget, index, instant_close);
2292  } else {
2293  /* We cannot raise the dropdown button just yet. OnClick needs some hint, whether
2294  * the same dropdown button was clicked again, and then not open the dropdown again.
2295  * So, we only remember that it was closed, and process it on the next OnPaint, which is
2296  * after OnClick. */
2297  assert(this->valuedropdown_entry != nullptr);
2298  this->closing_dropdown = true;
2299  this->SetDirty();
2300  }
2301  }
2302 
2303  void OnInvalidateData(int data = 0, bool gui_scope = true) override
2304  {
2305  if (!gui_scope) return;
2306 
2307  /* Update which settings are to be visible. */
2308  RestrictionMode min_level = (this->filter.mode <= RM_ALL) ? this->filter.mode : RM_BASIC;
2309  this->filter.min_cat = min_level;
2310  this->filter.type_hides = false;
2311  GetSettingsTree().UpdateFilterState(this->filter, false);
2312 
2313  if (this->filter.string.IsEmpty()) {
2314  this->warn_missing = WHR_NONE;
2315  } else if (min_level < this->filter.min_cat) {
2316  this->warn_missing = this->filter.type_hides ? WHR_CATEGORY_TYPE : WHR_CATEGORY;
2317  } else {
2318  this->warn_missing = this->filter.type_hides ? WHR_TYPE : WHR_NONE;
2319  }
2320  this->vscroll->SetCount(GetSettingsTree().Length() + this->warn_lines);
2321 
2322  if (this->last_clicked != nullptr && !GetSettingsTree().IsVisible(this->last_clicked)) {
2323  this->SetDisplayedHelpText(nullptr);
2324  }
2325 
2326  bool all_folded = true;
2327  bool all_unfolded = true;
2328  GetSettingsTree().GetFoldingState(all_folded, all_unfolded);
2329  this->SetWidgetDisabledState(WID_GS_EXPAND_ALL, all_unfolded);
2330  this->SetWidgetDisabledState(WID_GS_COLLAPSE_ALL, all_folded);
2331  }
2332 
2333  void OnEditboxChanged(int wid) override
2334  {
2335  if (wid == WID_GS_FILTER) {
2336  this->filter.string.SetFilterTerm(this->filter_editbox.text.buf);
2337  if (!this->filter.string.IsEmpty() && !this->manually_changed_folding) {
2338  /* User never expanded/collapsed single pages and entered a filter term.
2339  * Expand everything, to save weird expand clicks, */
2341  }
2342  this->InvalidateData();
2343  }
2344  }
2345 
2346  void OnResize() override
2347  {
2349  }
2350 };
2351 
2353 
2354 static const NWidgetPart _nested_settings_selection_widgets[] = {
2356  NWidget(WWT_CLOSEBOX, COLOUR_MAUVE),
2357  NWidget(WWT_CAPTION, COLOUR_MAUVE), SetDataTip(STR_CONFIG_SETTING_TREE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
2358  NWidget(WWT_DEFSIZEBOX, COLOUR_MAUVE),
2359  EndContainer(),
2360  NWidget(WWT_PANEL, COLOUR_MAUVE),
2363  NWidget(WWT_TEXT, COLOUR_MAUVE, WID_GS_RESTRICT_CATEGORY), SetDataTip(STR_CONFIG_SETTING_RESTRICT_CATEGORY, STR_NULL),
2364  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),
2365  EndContainer(),
2367  NWidget(WWT_TEXT, COLOUR_MAUVE, WID_GS_RESTRICT_TYPE), SetDataTip(STR_CONFIG_SETTING_RESTRICT_TYPE, STR_NULL),
2368  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),
2369  EndContainer(),
2370  EndContainer(),
2373  NWidget(WWT_TEXT, COLOUR_MAUVE), SetFill(0, 1), SetDataTip(STR_CONFIG_SETTING_FILTER_TITLE, STR_NULL),
2374  NWidget(WWT_EDITBOX, COLOUR_MAUVE, WID_GS_FILTER), SetFill(1, 0), SetMinimalSize(50, 12), SetResize(1, 0),
2375  SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
2376  EndContainer(),
2377  EndContainer(),
2380  NWidget(NWID_VSCROLLBAR, COLOUR_MAUVE, WID_GS_SCROLLBAR),
2381  EndContainer(),
2382  NWidget(WWT_PANEL, COLOUR_MAUVE), SetMinimalSize(400, 40),
2383  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GS_HELP_TEXT), SetMinimalSize(300, 25), SetFill(1, 1), SetResize(1, 0),
2385  EndContainer(),
2387  NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, WID_GS_EXPAND_ALL), SetDataTip(STR_CONFIG_SETTING_EXPAND_ALL, STR_NULL),
2388  NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, WID_GS_COLLAPSE_ALL), SetDataTip(STR_CONFIG_SETTING_COLLAPSE_ALL, STR_NULL),
2389  NWidget(WWT_PANEL, COLOUR_MAUVE), SetFill(1, 0), SetResize(1, 0),
2390  EndContainer(),
2391  NWidget(WWT_RESIZEBOX, COLOUR_MAUVE),
2392  EndContainer(),
2393 };
2394 
2395 static WindowDesc _settings_selection_desc(
2396  WDP_CENTER, "settings", 510, 450,
2398  0,
2399  _nested_settings_selection_widgets, lengthof(_nested_settings_selection_widgets)
2400 );
2401 
2404 {
2406  new GameSettingsWindow(&_settings_selection_desc);
2407 }
2408 
2409 
2419 void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right)
2420 {
2421  int colour = _colour_gradient[button_colour][2];
2422  Dimension dim = NWidgetScrollbar::GetHorizontalDimension();
2423 
2424  DrawFrameRect(x, y, x + dim.width - 1, y + dim.height - 1, button_colour, (state == 1) ? FR_LOWERED : FR_NONE);
2425  DrawFrameRect(x + dim.width, y, x + dim.width + dim.width - 1, y + dim.height - 1, button_colour, (state == 2) ? FR_LOWERED : FR_NONE);
2426  DrawSprite(SPR_ARROW_LEFT, PAL_NONE, x + WD_IMGBTN_LEFT, y + WD_IMGBTN_TOP);
2427  DrawSprite(SPR_ARROW_RIGHT, PAL_NONE, x + WD_IMGBTN_LEFT + dim.width, y + WD_IMGBTN_TOP);
2428 
2429  /* Grey out the buttons that aren't clickable */
2430  bool rtl = _current_text_dir == TD_RTL;
2431  if (rtl ? !clickable_right : !clickable_left) {
2432  GfxFillRect(x + 1, y, x + dim.width - 1, y + dim.height - 2, colour, FILLRECT_CHECKER);
2433  }
2434  if (rtl ? !clickable_left : !clickable_right) {
2435  GfxFillRect(x + dim.width + 1, y, x + dim.width + dim.width - 1, y + dim.height - 2, colour, FILLRECT_CHECKER);
2436  }
2437 }
2438 
2447 void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
2448 {
2449  int colour = _colour_gradient[button_colour][2];
2450 
2451  DrawFrameRect(x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1, button_colour, state ? FR_LOWERED : FR_NONE);
2452  DrawSprite(SPR_ARROW_DOWN, PAL_NONE, x + (SETTING_BUTTON_WIDTH - NWidgetScrollbar::GetVerticalDimension().width) / 2 + state, y + 2 + state);
2453 
2454  if (!clickable) {
2455  GfxFillRect(x + 1, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 2, colour, FILLRECT_CHECKER);
2456  }
2457 }
2458 
2466 void DrawBoolButton(int x, int y, bool state, bool clickable)
2467 {
2468  static const Colours _bool_ctabs[2][2] = {{COLOUR_CREAM, COLOUR_RED}, {COLOUR_DARK_GREEN, COLOUR_GREEN}};
2469  DrawFrameRect(x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1, _bool_ctabs[state][clickable], state ? FR_LOWERED : FR_NONE);
2470 }
2471 
2473  int query_widget;
2474 
2475  CustomCurrencyWindow(WindowDesc *desc) : Window(desc)
2476  {
2477  this->InitNested();
2478 
2479  SetButtonState();
2480  }
2481 
2482  void SetButtonState()
2483  {
2484  this->SetWidgetDisabledState(WID_CC_RATE_DOWN, _custom_currency.rate == 1);
2485  this->SetWidgetDisabledState(WID_CC_RATE_UP, _custom_currency.rate == UINT16_MAX);
2486  this->SetWidgetDisabledState(WID_CC_YEAR_DOWN, _custom_currency.to_euro == CF_NOEURO);
2487  this->SetWidgetDisabledState(WID_CC_YEAR_UP, _custom_currency.to_euro == MAX_YEAR);
2488  }
2489 
2490  void SetStringParameters(int widget) const override
2491  {
2492  switch (widget) {
2493  case WID_CC_RATE: SetDParam(0, 1); SetDParam(1, 1); break;
2494  case WID_CC_SEPARATOR: SetDParamStr(0, _custom_currency.separator); break;
2495  case WID_CC_PREFIX: SetDParamStr(0, _custom_currency.prefix); break;
2496  case WID_CC_SUFFIX: SetDParamStr(0, _custom_currency.suffix); break;
2497  case WID_CC_YEAR:
2498  SetDParam(0, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER);
2499  SetDParam(1, _custom_currency.to_euro);
2500  break;
2501 
2502  case WID_CC_PREVIEW:
2503  SetDParam(0, 10000);
2504  break;
2505  }
2506  }
2507 
2508  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
2509  {
2510  switch (widget) {
2511  /* Set the appropriate width for the edit 'buttons' */
2512  case WID_CC_SEPARATOR_EDIT:
2513  case WID_CC_PREFIX_EDIT:
2514  case WID_CC_SUFFIX_EDIT:
2515  size->width = this->GetWidget<NWidgetBase>(WID_CC_RATE_DOWN)->smallest_x + this->GetWidget<NWidgetBase>(WID_CC_RATE_UP)->smallest_x;
2516  break;
2517 
2518  /* Make sure the window is wide enough for the widest exchange rate */
2519  case WID_CC_RATE:
2520  SetDParam(0, 1);
2521  SetDParam(1, INT32_MAX);
2522  *size = GetStringBoundingBox(STR_CURRENCY_EXCHANGE_RATE);
2523  break;
2524  }
2525  }
2526 
2527  void OnClick(Point pt, int widget, int click_count) override
2528  {
2529  int line = 0;
2530  int len = 0;
2531  StringID str = 0;
2532  CharSetFilter afilter = CS_ALPHANUMERAL;
2533 
2534  switch (widget) {
2535  case WID_CC_RATE_DOWN:
2536  if (_custom_currency.rate > 1) _custom_currency.rate--;
2537  if (_custom_currency.rate == 1) this->DisableWidget(WID_CC_RATE_DOWN);
2539  break;
2540 
2541  case WID_CC_RATE_UP:
2542  if (_custom_currency.rate < UINT16_MAX) _custom_currency.rate++;
2543  if (_custom_currency.rate == UINT16_MAX) this->DisableWidget(WID_CC_RATE_UP);
2545  break;
2546 
2547  case WID_CC_RATE:
2548  SetDParam(0, _custom_currency.rate);
2549  str = STR_JUST_INT;
2550  len = 5;
2551  line = WID_CC_RATE;
2552  afilter = CS_NUMERAL;
2553  break;
2554 
2555  case WID_CC_SEPARATOR_EDIT:
2556  case WID_CC_SEPARATOR:
2557  SetDParamStr(0, _custom_currency.separator);
2558  str = STR_JUST_RAW_STRING;
2559  len = 1;
2560  line = WID_CC_SEPARATOR;
2561  break;
2562 
2563  case WID_CC_PREFIX_EDIT:
2564  case WID_CC_PREFIX:
2565  SetDParamStr(0, _custom_currency.prefix);
2566  str = STR_JUST_RAW_STRING;
2567  len = 12;
2568  line = WID_CC_PREFIX;
2569  break;
2570 
2571  case WID_CC_SUFFIX_EDIT:
2572  case WID_CC_SUFFIX:
2573  SetDParamStr(0, _custom_currency.suffix);
2574  str = STR_JUST_RAW_STRING;
2575  len = 12;
2576  line = WID_CC_SUFFIX;
2577  break;
2578 
2579  case WID_CC_YEAR_DOWN:
2580  _custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ? CF_NOEURO : _custom_currency.to_euro - 1;
2581  if (_custom_currency.to_euro == CF_NOEURO) this->DisableWidget(WID_CC_YEAR_DOWN);
2583  break;
2584 
2585  case WID_CC_YEAR_UP:
2586  _custom_currency.to_euro = Clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR);
2587  if (_custom_currency.to_euro == MAX_YEAR) this->DisableWidget(WID_CC_YEAR_UP);
2589  break;
2590 
2591  case WID_CC_YEAR:
2592  SetDParam(0, _custom_currency.to_euro);
2593  str = STR_JUST_INT;
2594  len = 7;
2595  line = WID_CC_YEAR;
2596  afilter = CS_NUMERAL;
2597  break;
2598  }
2599 
2600  if (len != 0) {
2601  this->query_widget = line;
2602  ShowQueryString(str, STR_CURRENCY_CHANGE_PARAMETER, len + 1, this, afilter, QSF_NONE);
2603  }
2604 
2605  this->SetTimeout();
2606  this->SetDirty();
2607  }
2608 
2609  void OnQueryTextFinished(char *str) override
2610  {
2611  if (str == nullptr) return;
2612 
2613  switch (this->query_widget) {
2614  case WID_CC_RATE:
2615  _custom_currency.rate = Clamp(atoi(str), 1, UINT16_MAX);
2616  break;
2617 
2618  case WID_CC_SEPARATOR: // Thousands separator
2619  strecpy(_custom_currency.separator, str, lastof(_custom_currency.separator));
2620  break;
2621 
2622  case WID_CC_PREFIX:
2623  strecpy(_custom_currency.prefix, str, lastof(_custom_currency.prefix));
2624  break;
2625 
2626  case WID_CC_SUFFIX:
2627  strecpy(_custom_currency.suffix, str, lastof(_custom_currency.suffix));
2628  break;
2629 
2630  case WID_CC_YEAR: { // Year to switch to euro
2631  int val = atoi(str);
2632 
2633  _custom_currency.to_euro = (val < 2000 ? CF_NOEURO : std::min(val, MAX_YEAR));
2634  break;
2635  }
2636  }
2638  SetButtonState();
2639  }
2640 
2641  void OnTimeout() override
2642  {
2643  this->SetDirty();
2644  }
2645 };
2646 
2647 static const NWidgetPart _nested_cust_currency_widgets[] = {
2649  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
2650  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_CURRENCY_WINDOW, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
2651  EndContainer(),
2652  NWidget(WWT_PANEL, COLOUR_GREY),
2654  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
2655  NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_RATE_DOWN), SetDataTip(AWV_DECREASE, STR_CURRENCY_DECREASE_EXCHANGE_RATE_TOOLTIP),
2656  NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_RATE_UP), SetDataTip(AWV_INCREASE, STR_CURRENCY_INCREASE_EXCHANGE_RATE_TOOLTIP),
2658  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_RATE), SetDataTip(STR_CURRENCY_EXCHANGE_RATE, STR_CURRENCY_SET_EXCHANGE_RATE_TOOLTIP), SetFill(1, 0),
2659  EndContainer(),
2660  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
2661  NWidget(WWT_PUSHBTN, COLOUR_DARK_BLUE, WID_CC_SEPARATOR_EDIT), SetDataTip(0x0, STR_CURRENCY_SET_CUSTOM_CURRENCY_SEPARATOR_TOOLTIP), SetFill(0, 1),
2663  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_SEPARATOR), SetDataTip(STR_CURRENCY_SEPARATOR, STR_CURRENCY_SET_CUSTOM_CURRENCY_SEPARATOR_TOOLTIP), SetFill(1, 0),
2664  EndContainer(),
2665  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
2666  NWidget(WWT_PUSHBTN, COLOUR_DARK_BLUE, WID_CC_PREFIX_EDIT), SetDataTip(0x0, STR_CURRENCY_SET_CUSTOM_CURRENCY_PREFIX_TOOLTIP), SetFill(0, 1),
2668  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_PREFIX), SetDataTip(STR_CURRENCY_PREFIX, STR_CURRENCY_SET_CUSTOM_CURRENCY_PREFIX_TOOLTIP), SetFill(1, 0),
2669  EndContainer(),
2670  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
2671  NWidget(WWT_PUSHBTN, COLOUR_DARK_BLUE, WID_CC_SUFFIX_EDIT), SetDataTip(0x0, STR_CURRENCY_SET_CUSTOM_CURRENCY_SUFFIX_TOOLTIP), SetFill(0, 1),
2673  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_SUFFIX), SetDataTip(STR_CURRENCY_SUFFIX, STR_CURRENCY_SET_CUSTOM_CURRENCY_SUFFIX_TOOLTIP), SetFill(1, 0),
2674  EndContainer(),
2675  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
2676  NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_YEAR_DOWN), SetDataTip(AWV_DECREASE, STR_CURRENCY_DECREASE_CUSTOM_CURRENCY_TO_EURO_TOOLTIP),
2677  NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_YEAR_UP), SetDataTip(AWV_INCREASE, STR_CURRENCY_INCREASE_CUSTOM_CURRENCY_TO_EURO_TOOLTIP),
2679  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_YEAR), SetDataTip(STR_JUST_STRING, STR_CURRENCY_SET_CUSTOM_CURRENCY_TO_EURO_TOOLTIP), SetFill(1, 0),
2680  EndContainer(),
2681  EndContainer(),
2682  NWidget(WWT_LABEL, COLOUR_BLUE, WID_CC_PREVIEW),
2683  SetDataTip(STR_CURRENCY_PREVIEW, STR_CURRENCY_CUSTOM_CURRENCY_PREVIEW_TOOLTIP), SetPadding(15, 1, 18, 2),
2684  EndContainer(),
2685 };
2686 
2687 static WindowDesc _cust_currency_desc(
2688  WDP_CENTER, nullptr, 0, 0,
2690  0,
2691  _nested_cust_currency_widgets, lengthof(_nested_cust_currency_widgets)
2692 );
2693 
2695 static void ShowCustCurrency()
2696 {
2698  new CustomCurrencyWindow(&_cust_currency_desc);
2699 }
LoadStringWidthTable
void LoadStringWidthTable(bool monospace)
Initialize _stringwidth_table cache.
Definition: gfx.cpp:1272
SettingEntry::Length
virtual uint Length() const
Return number of rows needed to display the (filtered) entry.
Definition: settings_gui.cpp:988
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:701
WID_GO_FULLSCREEN_BUTTON
@ WID_GO_FULLSCREEN_BUTTON
Toggle fullscreen.
Definition: settings_widget.h:23
Window::SetTimeout
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
Definition: window_gui.h:366
SettingEntry::UpdateFilterState
virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible)
Update the filter state.
Definition: settings_gui.cpp:1052
TownName
static StringID TownName(int town_name)
Get a town name.
Definition: settings_gui.cpp:96
CustomCurrencyWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: settings_gui.cpp:2641
CF_NOEURO
static const int CF_NOEURO
Currency never switches to the Euro (as far as known).
Definition: currency.h:16
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
ReInitAllWindows
void ReInitAllWindows()
Re-initialize all windows.
Definition: window.cpp:3454
WID_GO_FONT_ZOOM_DROPDOWN
@ WID_GO_FONT_ZOOM_DROPDOWN
Dropdown for the font zoom level.
Definition: settings_widget.h:36
TextfileWindow::LoadTextfile
virtual void LoadTextfile(const char *textfile, Subdirectory dir)
Loads the textfile text from file and setup lines.
Definition: textfile_gui.cpp:318
Pool::PoolItem<&_company_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:329
WID_GO_AUTOSAVE_DROPDOWN
@ WID_GO_AUTOSAVE_DROPDOWN
Dropdown to say how often to autosave.
Definition: settings_widget.h:20
SEF_LEFT_DEPRESSED
@ SEF_LEFT_DEPRESSED
Of a numeric setting entry, the left button is depressed.
Definition: settings_gui.cpp:700
Window::timeout_timer
uint8 timeout_timer
Timer value of the WF_TIMEOUT for flags.
Definition: window_gui.h:314
SetWindowDirty
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Definition: window.cpp:3218
querystring_gui.h
SetScrollbar
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1094
GetCurrentLanguageIsoCode
const char * GetCurrentLanguageIsoCode()
Get the ISO language code of the currently loaded language.
Definition: strings.cpp:1994
SEF_BUTTONS_MASK
@ SEF_BUTTONS_MASK
Bit-mask for button flags.
Definition: settings_gui.cpp:702
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:621
WID_GS_OPTIONSPANEL
@ WID_GS_OPTIONSPANEL
Panel widget containing the option lists.
Definition: settings_widget.h:42
command_func.h
BaseSetTextfileWindow::baseset
const TBaseSet * baseset
View the textfile of this BaseSet.
Definition: settings_gui.cpp:142
WID_GS_COLLAPSE_ALL
@ WID_GS_COLLAPSE_ALL
Collapse all button.
Definition: settings_widget.h:46
WID_GS_HELP_TEXT
@ WID_GS_HELP_TEXT
Information area to display help text of the selected option.
Definition: settings_widget.h:44
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:1045
Window::GetScrollbar
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:309
BaseSetTextfileWindow::content_type
StringID content_type
STR_CONTENT_TYPE_xxx for title.
Definition: settings_gui.cpp:143
dropdown_func.h
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:1797
StringFilter::IsEmpty
bool IsEmpty() const
Check whether any filter words were entered.
Definition: stringfilter_type.h:59
SettingDescBase::cat
SettingCategory cat
assigned categories of the setting
Definition: settings_internal.h:105
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:2527
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:1469
company_base.h
WID_CC_SEPARATOR_EDIT
@ WID_CC_SEPARATOR_EDIT
Separator edit button.
Definition: settings_widget.h:58
GameSettingsWindow::settings_ptr
static GameSettings * settings_ptr
Pointer to the game settings being displayed and modified.
Definition: settings_gui.cpp:1803
StringFilter::SetFilterTerm
void SetFilterTerm(const char *str)
Set the term to filter on.
Definition: stringfilter.cpp:27
WID_GO_BASE_SFX_TEXTFILE
@ WID_GO_BASE_SFX_TEXTFILE
Open base SFX readme, changelog (+1) or license (+2).
Definition: settings_widget.h:30
SettingDescBase::str_val
StringID str_val
(Translated) first string describing the value.
Definition: settings_internal.h:102
SettingFilter::type
SettingType type
Filter based on type.
Definition: settings_gui.cpp:725
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
SGF_PER_COMPANY
@ SGF_PER_COMPANY
this setting can be different for each company (saved in company struct)
Definition: settings_internal.h:48
BASESET_DIR
@ BASESET_DIR
Subdirectory for all base data (base sets, intro game)
Definition: fileio_type.h:116
currency.h
Scrollbar::GetScrolledRowFromWidget
int GetScrolledRowFromWidget(int clickpos, const Window *const w, int widget, int padding=0, int line_height=-1) const
Compute the row of a scrolled widget that a user clicked in.
Definition: widget.cpp:1966
InitGRFTownGeneratorNames
void InitGRFTownGeneratorNames()
Allocate memory for the NewGRF town names.
Definition: settings_gui.cpp:83
ST_GAME
@ ST_GAME
Game setting.
Definition: settings_internal.h:80
_network_server
bool _network_server
network-server is active
Definition: network.cpp:53
WID_GO_GUI_ZOOM_DROPDOWN
@ WID_GO_GUI_ZOOM_DROPDOWN
Dropdown for the GUI zoom level.
Definition: settings_widget.h:24
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition: widget_type.h:55
SettingDesc::save
SaveLoad save
Internal structure (going to savegame, parts to config)
Definition: settings_internal.h:110
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:66
SettingDesc::GetType
SettingType GetType() const
Return the type of the setting.
Definition: settings.cpp:834
SettingsPage::Init
virtual void Init(byte level=0)
Initialization of an entire setting page.
Definition: settings_gui.cpp:1323
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:1832
SettingsPage::Length
virtual uint Length() const
Return number of rows needed to display the (filtered) entry.
Definition: settings_gui.cpp:1404
SettingDesc::IsEditable
bool IsEditable(bool do_command=false) const
Check whether the setting is editable in the current gamemode.
Definition: settings.cpp:819
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
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:2284
DropDownListCharStringItem
List item containing a C char string.
Definition: dropdown_type.h:69
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:1272
SDT_BOOLX
@ SDT_BOOLX
a boolean number
Definition: settings_internal.h:25
GameSettingsWindow::filter_editbox
QueryString filter_editbox
Filter editbox;.
Definition: settings_gui.cpp:1812
ST_CLIENT
@ ST_CLIENT
Client setting.
Definition: settings_internal.h:82
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:744
WID_CC_RATE
@ WID_CC_RATE
Rate of currency.
Definition: settings_widget.h:57
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
_nb_orig_names
int _nb_orig_names
Number of original town names.
Definition: settings_gui.cpp:74
BaseSetTextfileWindow
Window for displaying the textfile of a BaseSet.
Definition: settings_gui.cpp:141
Scrollbar::SetCount
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:669
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:721
SettingEntry::Init
virtual void Init(byte level=0)
Initialization of a setting entry.
Definition: settings_gui.cpp:969
GameOptionsWindow
Definition: settings_gui.cpp:173
SettingEntry::setting
const SettingDesc * setting
Setting description of the setting.
Definition: settings_gui.cpp:769
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:929
zoom_func.h
GameCreationSettings::town_name
byte town_name
the town name generator used for town names
Definition: settings_type.h:292
ST_COMPANY
@ ST_COMPANY
Company setting.
Definition: settings_internal.h:81
WD_FRAMETEXT_TOP
@ WD_FRAMETEXT_TOP
Top offset of the text of the frame.
Definition: window_gui.h:72
WID_GS_EXPAND_ALL
@ WID_GS_EXPAND_ALL
Expand all button.
Definition: settings_widget.h:45
SGF_DISPLAY_ABS
@ SGF_DISPLAY_ABS
display absolute value of the setting
Definition: settings_internal.h:41
base_media_base.h
ZoomLevel
ZoomLevel
All zoom levels we know.
Definition: zoom_type.h:19
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:802
newgrf_townname.h
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:79
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:1850
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:636
GameSettingsWindow::last_clicked
SettingEntry * last_clicked
If non-nullptr, pointer to the last clicked setting.
Definition: settings_gui.cpp:1807
GUISettings::autosave
byte autosave
how often should we do autosaves?
Definition: settings_type.h:111
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:46
DeleteWindowByClass
void DeleteWindowByClass(WindowClass cls)
Delete all windows of a given class.
Definition: window.cpp:1178
town.h
WWT_PUSHARROWBTN
@ WWT_PUSHARROWBTN
Normal push-button (no toggle button) with arrow caption.
Definition: widget_type.h:104
WID_GS_FILTER
@ WID_GS_FILTER
Text filter.
Definition: settings_widget.h:41
StringFilter::AddLine
void AddLine(const char *str)
Pass another text line from the current item to the filter.
Definition: stringfilter.cpp:104
GameSettingsWindow::SETTINGTREE_TOP_OFFSET
static const int SETTINGTREE_TOP_OFFSET
Position of top edge of setting values.
Definition: settings_gui.cpp:1800
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:282
FR_LOWERED
@ FR_LOWERED
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
Definition: window_gui.h:29
settings_internal.h
SDT_NUMX
@ SDT_NUMX
any number-type
Definition: settings_internal.h:24
WID_CC_PREFIX
@ WID_CC_PREFIX
Current prefix.
Definition: settings_widget.h:61
VehicleSettings::road_side
byte road_side
the side of the road vehicles drive on
Definition: settings_type.h:465
SEF_FILTERED
@ SEF_FILTERED
Entry is hidden by the string filter.
Definition: settings_gui.cpp:705
WID_GO_BASE_MUSIC_DROPDOWN
@ WID_GO_BASE_MUSIC_DROPDOWN
Use to select a base music set.
Definition: settings_widget.h:32
GameSettingsWindow::SETTINGTREE_LEFT_OFFSET
static const int SETTINGTREE_LEFT_OFFSET
Position of left edge of setting values.
Definition: settings_gui.cpp:1798
SaveLoad::conv
VarType conv
type of the variable to be saved, int
Definition: saveload.h:523
_gui_zoom
ZoomLevel _gui_zoom
GUI Zoom level.
Definition: gfx.cpp:59
SA_HOR_CENTER
@ SA_HOR_CENTER
Horizontally center the text.
Definition: gfx_func.h:95
SettingEntry::IsVisibleByRestrictionMode
bool IsVisibleByRestrictionMode(RestrictionMode mode) const
Checks whether an entry shall be made visible based on the restriction mode.
Definition: settings_gui.cpp:1008
SettingsPage::SettingsPage
SettingsPage(StringID title)
Constructor for a sub-page in the 'advanced settings' window.
Definition: settings_gui.cpp:1313
BaseSettingEntry::Init
virtual void Init(byte level=0)
Initialization of a setting entry.
Definition: settings_gui.cpp:857
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:588
SettingsPage
Data structure describing one page of settings in the settings window.
Definition: settings_gui.cpp:827
WD_FRAMETEXT_LEFT
@ WD_FRAMETEXT_LEFT
Left offset of the text of the frame.
Definition: window_gui.h:70
TextfileWindow::file_type
TextfileType file_type
Type of textfile to view.
Definition: textfile_gui.h:22
TFT_CHANGELOG
@ TFT_CHANGELOG
NewGRF changelog.
Definition: textfile_type.h:18
SettingDescBase::str
StringID str
(translated) string with descriptive text; gui and console
Definition: settings_internal.h:100
SettingsContainer::UpdateFilterState
bool UpdateFilterState(SettingFilter &filter, bool force_visible)
Update the filter state.
Definition: settings_gui.cpp:1212
_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:52
Window::Window
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition: window.cpp:1871
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:199
CustomCurrencyWindow
Definition: settings_gui.cpp:2472
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:909
textfile_gui.h
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1013
QueryString
Data stored about a string that can be modified in the GUI.
Definition: querystring_gui.h:20
SettingDescBase::min
int32 min
minimum values
Definition: settings_internal.h:96
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:2203
GetStringBoundingBox
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:838
GetStringLineCount
int GetStringLineCount(StringID str, int maxw)
Calculates number of lines of string.
Definition: gfx.cpp:710
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:328
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:372
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:759
GameOptionsWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: settings_gui.cpp:327
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:998
BuildCurrencyDropdown
StringID * BuildCurrencyDropdown()
Build a list of currency names StringIDs to use in a dropdown list.
Definition: currency.cpp:167
GameSettings::game_creation
GameCreationSettings game_creation
settings used during the creation of a game (map)
Definition: settings_type.h:548
ai.hpp
WID_CC_SEPARATOR
@ WID_CC_SEPARATOR
Current separator.
Definition: settings_widget.h:59
UpdateCursorSize
void UpdateCursorSize()
Update cursor dimension.
Definition: gfx.cpp:1679
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:589
WN_GAME_OPTIONS_GAME_OPTIONS
@ WN_GAME_OPTIONS_GAME_OPTIONS
Game options.
Definition: window_type.h:18
WindowDesc
High level window description.
Definition: window_gui.h:166
GameSettingsWindow::warn_missing
WarnHiddenResult warn_missing
Whether and how to warn about missing search results.
Definition: settings_gui.cpp:1814
BaseSettingEntry::level
byte level
Nesting level of this setting entry.
Definition: settings_gui.cpp:731
SettingType
SettingType
Type of settings for filtering.
Definition: settings_internal.h:79
DECLARE_POSTFIX_INCREMENT
#define DECLARE_POSTFIX_INCREMENT(enum_type)
Some enums need to have allowed incrementing (i.e.
Definition: enum_type.hpp:14
RoadVehiclesAreBuilt
bool RoadVehiclesAreBuilt()
Verify whether a road vehicle is available.
Definition: road_cmd.cpp:183
SettingDescBase::cmd
SettingDescType cmd
various flags for the variable
Definition: settings_internal.h:94
SettingsPage::title
StringID title
Title of the sub-page.
Definition: settings_gui.cpp:828
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:722
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:428
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:199
DrawDropDownButton
void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
Draw a dropdown button.
Definition: settings_gui.cpp:2447
WWT_PUSHBTN
@ WWT_PUSHBTN
Normal push-button (no toggle button) with custom drawing.
Definition: widget_type.h:101
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:322
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:47
SettingDescBase
Properties of config file settings.
Definition: settings_internal.h:91
GameSettingsWindow::warn_lines
int warn_lines
Number of lines used for warning about missing search results.
Definition: settings_gui.cpp:1815
Scrollbar::GetCount
uint16 GetCount() const
Gets the number of elements in the list.
Definition: widget_type.h:612
SETTING_HEIGHT
static int SETTING_HEIGHT
Height of a single setting in the tree view in pixels.
Definition: settings_gui.cpp:692
Window::EnableWidget
void EnableWidget(byte widget_index)
Sets a widget to Enabled.
Definition: window_gui.h:411
RestrictionMode
RestrictionMode
How the list of advanced settings is filtered.
Definition: settings_gui.cpp:709
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1861
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:1805
SettingDescBase::max
uint32 max
maximum values
Definition: settings_internal.h:97
GfxClearSpriteCache
void GfxClearSpriteCache()
Remove all encoded sprites from the sprite cache without discarding sprite location information.
Definition: spritecache.cpp:950
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:1132
WHR_TYPE
@ WHR_TYPE
Type setting filtered matches away.
Definition: settings_gui.cpp:1792
Window::height
int height
Height of the window (number of pixels down in y direction)
Definition: window_gui.h:320
WID_CC_SUFFIX_EDIT
@ WID_CC_SUFFIX_EDIT
Suffix edit button.
Definition: settings_widget.h:62
WID_GO_BASE_MUSIC_DESCRIPTION
@ WID_GO_BASE_MUSIC_DESCRIPTION
Description of selected base music set.
Definition: settings_widget.h:35
CustomCurrencyWindow::OnQueryTextFinished
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: settings_gui.cpp:2609
GameSettingsWindow::SETTINGTREE_BOTTOM_OFFSET
static const int SETTINGTREE_BOTTOM_OFFSET
Position of bottom edge of setting values.
Definition: settings_gui.cpp:1801
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:984
highscore.h
WD_FRAMERECT_LEFT
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
Definition: window_gui.h:60
GameSettingsWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: settings_gui.cpp:2240
BaseSettingEntry
Data structure describing a single setting in a tab.
Definition: settings_gui.cpp:729
GameSettingsWindow::OnQueryTextFinished
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: settings_gui.cpp:2212
WD_PAR_VSEP_NORMAL
@ WD_PAR_VSEP_NORMAL
Normal amount of vertical space between two paragraphs of text.
Definition: window_gui.h:137
WD_FRAMERECT_RIGHT
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
Definition: window_gui.h:61
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:102
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:124
WD_FRAMETEXT_BOTTOM
@ WD_FRAMETEXT_BOTTOM
Bottom offset of the text of the frame.
Definition: window_gui.h:73
SDT_ONEOFMANY
@ SDT_ONEOFMANY
bitmasked number where only ONE bit may be set
Definition: settings_internal.h:26
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:453
GameOptionsWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: settings_gui.cpp:346
RM_END
@ RM_END
End for iteration.
Definition: settings_gui.cpp:715
SettingFilter::mode
RestrictionMode mode
Filter based on category.
Definition: settings_gui.cpp:724
dropdown_type.h
SettingEntry::name
const char * name
Name of the setting.
Definition: settings_gui.cpp:768
Window::SetWidgetDisabledState
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:392
SettingsPage::FoldAll
virtual void FoldAll()
Recursively close all (filtered) folds of sub-pages.
Definition: settings_gui.cpp:1330
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:45
_current_language
const LanguageMetadata * _current_language
The currently loaded language.
Definition: strings.cpp:46
SettingDescBase::def
const void * def
default value given when none is present
Definition: settings_internal.h:93
SEF_LAST_FIELD
@ SEF_LAST_FIELD
This entry is the last one in a (sub-)page.
Definition: settings_gui.cpp:704
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:1131
RM_ALL
@ RM_ALL
List all settings regardless of the default/newgame/... values.
Definition: settings_gui.cpp:712
SettingDescBase::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:98
Window::left
int left
x position of left edge of the window
Definition: window_gui.h:317
Window::flags
WindowFlags flags
Window flags.
Definition: window_gui.h:310
_resolutions
std::vector< Dimension > _resolutions
List of resolutions.
Definition: driver.cpp:22
WF_TIMEOUT
@ WF_TIMEOUT
Window timeout counter.
Definition: window_gui.h:232
SetCompanySetting
void SetCompanySetting(uint index, int32 value)
Top function to save the new value of an element of the Settings struct.
Definition: settings.cpp:2011
StrEmpty
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition: string_func.h:60
settings
fluid_settings_t * settings
FluidSynth settings handle.
Definition: fluidsynth.cpp:21
GameSettings
All settings together for the game.
Definition: settings_type.h:546
GetSettingFromName
const SettingDesc * GetSettingFromName(const char *name, uint *i)
Given a name of setting, return a setting description of it.
Definition: settings.cpp:2099
_networking
bool _networking
are we in networking mode?
Definition: network.cpp:52
SettingsPage::folded
bool folded
Sub-page is folded (not visible except for its title)
Definition: settings_gui.cpp:829
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:974
WID_GO_BASE_GRF_DROPDOWN
@ WID_GO_BASE_GRF_DROPDOWN
Use to select a base GRF.
Definition: settings_widget.h:25
WID_CC_YEAR_UP
@ WID_CC_YEAR_UP
Up button.
Definition: settings_widget.h:65
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:1808
SettingsContainer::Init
void Init(byte level=0)
Initialization of an entire setting page.
Definition: settings_gui.cpp:1171
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
error.h
RM_BASIC
@ RM_BASIC
Display settings associated to the "basic" list.
Definition: settings_gui.cpp:710
WWT_FRAME
@ WWT_FRAME
Frame.
Definition: widget_type.h:58
language.h
WID_CC_YEAR_DOWN
@ WID_CC_YEAR_DOWN
Down button.
Definition: settings_widget.h:64
WHR_CATEGORY
@ WHR_CATEGORY
Category setting filtered matches away.
Definition: settings_gui.cpp:1791
SettingsPage::FindEntry
virtual BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find setting entry at row row_num.
Definition: settings_gui.cpp:1418
BaseSetTextfileWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: settings_gui.cpp:151
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:2490
WD_FRAMETEXT_RIGHT
@ WD_FRAMETEXT_RIGHT
Right offset of the text of the frame.
Definition: window_gui.h:71
Window::SetFocusedWidget
bool SetFocusedWidget(int widget_index)
Set focus within this window to the given widget.
Definition: window.cpp:495
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:2419
WID_GO_LANG_DROPDOWN
@ WID_GO_LANG_DROPDOWN
Language dropdown.
Definition: settings_widget.h:21
SettingFilter::type_hides
bool type_hides
Whether the type hides filtered strings.
Definition: settings_gui.cpp:723
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:110
ShowCustCurrency
static void ShowCustCurrency()
Open custom currency window.
Definition: settings_gui.cpp:2695
WID_CC_RATE_DOWN
@ WID_CC_RATE_DOWN
Down button.
Definition: settings_widget.h:55
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:1296
WarnHiddenResult
WarnHiddenResult
Warnings about hidden search results.
Definition: settings_gui.cpp:1789
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:3259
CS_ALPHANUMERAL
@ CS_ALPHANUMERAL
Both numeric and alphabetic and spaces and stuff.
Definition: string_type.h:27
viewport_func.h
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:1793
SettingEntry::index
uint index
Index of the setting in the settings table.
Definition: settings_gui.cpp:770
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:167
BaseSet::GetNumMissing
int GetNumMissing() const
Get the number of missing files.
Definition: base_media_base.h:88
SettingDescBase::flags
SettingGuiFlag flags
handles how a setting would show up in the GUI (text/currency, etc.)
Definition: settings_internal.h:95
WID_CC_RATE_UP
@ WID_CC_RATE_UP
Up button.
Definition: settings_widget.h:56
GetStringHeight
int GetStringHeight(const char *str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Definition: gfx.cpp:685
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:909
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:67
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:66
GUISettings::zoom_min
ZoomLevel zoom_min
minimum zoom out level
Definition: settings_type.h:109
GetCurRes
static uint GetCurRes()
Get index of the current screen resolution.
Definition: settings_gui.cpp:108
GameSettingsWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: settings_gui.cpp:1926
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:981
TFT_LICENSE
@ TFT_LICENSE
NewGRF license.
Definition: textfile_type.h:19
_switch_mode
SwitchMode _switch_mode
The next mainloop command.
Definition: gfx.cpp:46
_font_zoom
ZoomLevel _font_zoom
Font Zoom level.
Definition: gfx.cpp:60
GameSettingsWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: settings_gui.cpp:2346
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
WID_GS_SCROLLBAR
@ WID_GS_SCROLLBAR
Scrollbar.
Definition: settings_widget.h:43
WID_CC_PREFIX_EDIT
@ WID_CC_PREFIX_EDIT
Prefix edit button.
Definition: settings_widget.h:60
QueryString::cancel_button
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
Definition: querystring_gui.h:28
SGF_MULTISTRING
@ SGF_MULTISTRING
the value represents a limited number of string-options (internally integer)
Definition: settings_internal.h:42
SGF_0ISDISABLED
@ SGF_0ISDISABLED
a value of zero means the feature is disabled
Definition: settings_internal.h:40
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:65
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:998
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:22
strings_func.h
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:82
DeleteWindowById
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
Definition: window.cpp:1165
main
int CDECL main(int argc, char *argv[])
And the main program (what else?)
Definition: settingsgen.cpp:433
GetTextfile
const char * GetTextfile(TextfileType type, Subdirectory dir, const char *filename)
Search a textfile file next to the given content.
Definition: textfile_gui.cpp:386
NWidgetBase::pos_x
int pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:175
LocaleSettings::currency
byte currency
currency we currently use
Definition: settings_type.h:205
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:160
WID_GO_BASE_MUSIC_TEXTFILE
@ WID_GO_BASE_MUSIC_TEXTFILE
Open base music readme, changelog (+1) or license (+2).
Definition: settings_widget.h:34
Pool::PoolItem<&_town_pool >::GetNumItems
static size_t GetNumItems()
Returns number of valid items in the pool.
Definition: pool_type.hpp:359
BaseSettingEntry::FindEntry
virtual BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find setting entry at row row_num.
Definition: settings_gui.cpp:881
HideDropDownMenu
int HideDropDownMenu(Window *pw)
Delete the drop-down menu from window pw.
Definition: dropdown.cpp:512
SettingsContainer::UnFoldAll
void UnFoldAll()
Recursively open all folds of sub-pages.
Definition: settings_gui.cpp:1187
SettingDesc
Definition: settings_internal.h:108
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:1231
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:1352
SettingsContainer::Length
uint Length() const
Return number of rows needed to display the whole page.
Definition: settings_gui.cpp:1240
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:48
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:177
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1113
GameSettingsWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: settings_gui.cpp:1968
RM_CHANGED_AGAINST_DEFAULT
@ RM_CHANGED_AGAINST_DEFAULT
Show only settings which are different compared to default values.
Definition: settings_gui.cpp:713
SC_BASIC_LIST
@ SC_BASIC_LIST
Settings displayed in the list of basic settings.
Definition: settings_internal.h:64
geometry_func.hpp
SGF_CURRENCY
@ SGF_CURRENCY
the number represents money, so when reading value multiply by exchange rate
Definition: settings_internal.h:44
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:946
GameSettingsWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: settings_gui.cpp:1885
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:1371
WID_GO_ROADSIDE_DROPDOWN
@ WID_GO_ROADSIDE_DROPDOWN
Dropdown to select the road side (to set the right side ;)).
Definition: settings_widget.h:18
NWidgetBase::resize_y
uint resize_y
Vertical resize step (0 means not resizable).
Definition: widget_type.h:165
SettingsContainer::FindEntry
BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find the setting entry at row number row_num.
Definition: settings_gui.cpp:1255
Scrollbar::GetPosition
uint16 GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:630
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:2508
StringFilter::GetState
bool GetState() const
Get the matching state of the current item.
Definition: stringfilter_type.h:69
width
int width
Width in pixels of our display surface.
Definition: win32_v.cpp:48
WD_IMGBTN_TOP
@ WD_IMGBTN_TOP
Top offset of image in the button.
Definition: window_gui.h:40
WID_GO_BASE_MUSIC_STATUS
@ WID_GO_BASE_MUSIC_STATUS
Info about corrupted files etc.
Definition: settings_widget.h:33
SettingDesc::desc
SettingDescBase desc
Settings structure (going to configuration file)
Definition: settings_internal.h:109
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1848
WID_GS_RESTRICT_DROPDOWN
@ WID_GS_RESTRICT_DROPDOWN
The drop down box to restrict the list of settings.
Definition: settings_widget.h:49
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:77
_grf_names
static StringID * _grf_names
Pointer to town names defined by NewGRFs.
Definition: settings_gui.cpp:75
GameSettingsWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: settings_gui.cpp:2303
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:31
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:1442
Window::top
int top
y position of top edge of the window
Definition: window_gui.h:318
abs
static T abs(const T a)
Returns the absolute value of (scalar) variable.
Definition: math_func.hpp:21
WID_GO_BASE_GRF_TEXTFILE
@ WID_GO_BASE_GRF_TEXTFILE
Open base GRF readme, changelog (+1) or license (+2).
Definition: settings_widget.h:27
LEVEL_WIDTH
static const int LEVEL_WIDTH
Indenting width of a sub-page in pixels.
Definition: settings_gui.cpp:693
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:432
SettingEntry::SetValueDParams
void SetValueDParams(uint first_param, int32 value) const
Set the DParams for drawing the value of a setting.
Definition: settings_gui.cpp:1106
DrawFrameRect
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
Draw frame rectangle.
Definition: widget.cpp:175
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:1394
SettingsContainer::FoldAll
void FoldAll()
Recursively close all folds of sub-pages.
Definition: settings_gui.cpp:1179
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:366
GUISettings::settings_restriction_mode
uint8 settings_restriction_mode
selected restriction mode in adv. settings GUI.
Definition: settings_type.h:166
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:2102
GameSettingsWindow::filter
SettingFilter filter
Filter for the list.
Definition: settings_gui.cpp:1811
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:377
Window::width
int width
width of the window (number of pixels to the right in x direction)
Definition: window_gui.h:319
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:1980
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition: gfx.cpp:1610
GameSettings::locale
LocaleSettings locale
settings related to used currency/unit system in the current game
Definition: settings_type.h:560
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1075
NWidgetBase::pos_y
int pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:176
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:868
SettingEntry::SettingEntry
SettingEntry(const char *name)
Constructor for a single setting in the 'advanced settings' window.
Definition: settings_gui.cpp:958
GameSettingsWindow::SETTINGTREE_RIGHT_OFFSET
static const int SETTINGTREE_RIGHT_OFFSET
Position of right edge of setting values.
Definition: settings_gui.cpp:1799
SettingFilter
Filter for settings list.
Definition: settings_gui.cpp:720
_nb_grf_names
static int _nb_grf_names
Number of town names defined by NewGRFs.
Definition: settings_gui.cpp:76
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:714
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:982
TextfileWindow
Window for displaying a textfile.
Definition: textfile_gui.h:21
WID_CC_PREVIEW
@ WID_CC_PREVIEW
Preview.
Definition: settings_widget.h:67
GameOptionsWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: settings_gui.cpp:575
GetSettingsTree
static SettingsContainer & GetSettingsTree()
Construct settings tree.
Definition: settings_gui.cpp:1477
ST_ALL
@ ST_ALL
Used in setting filter to match all types.
Definition: settings_internal.h:84
ReadValue
int64 ReadValue(const void *ptr, VarType conv)
Return a signed-long version of the value of a setting.
Definition: saveload.cpp:749
ClientSettings::company
CompanySettings company
default values for per-company settings
Definition: settings_type.h:567
SettingsContainer
Containers for BaseSettingEntry.
Definition: settings_gui.cpp:800
GameSettings::vehicle
VehicleSettings vehicle
options for vehicles
Definition: settings_type.h:556
GameSettingsWindow::closing_dropdown
bool closing_dropdown
True, if the dropdown list is currently closing.
Definition: settings_gui.cpp:1809
BaseSettingEntry::flags
byte flags
Flags of the setting entry.
Definition: settings_gui.cpp:730
Window
Data structure for an opened window.
Definition: window_gui.h:276
TextfileType
TextfileType
Additional text files accompanying Tar archives.
Definition: textfile_type.h:14
SetSettingValue
bool SetSettingValue(uint index, int32 value, bool force_newgame)
Top function to save the new value of an element of the Settings struct.
Definition: settings.cpp:1967
WID_GO_BASE_SFX_DESCRIPTION
@ WID_GO_BASE_SFX_DESCRIPTION
Description of selected base SFX.
Definition: settings_widget.h:31
SC_ADVANCED_LIST
@ SC_ADVANCED_LIST
Settings displayed in the list of advanced settings.
Definition: settings_internal.h:65
SettingEntry
Standard setting.
Definition: settings_gui.cpp:767
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:318
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:602
ZOOM_LVL_OUT_4X
@ ZOOM_LVL_OUT_4X
Zoomed 4 times out.
Definition: zoom_type.h:24
ShowGameSettings
void ShowGameSettings()
Open advanced settings window.
Definition: settings_gui.cpp:2403
DrawBoolButton
void DrawBoolButton(int x, int y, bool state, bool clickable)
Draw a toggle button.
Definition: settings_gui.cpp:2466
settings_gui.h
WD_IMGBTN_LEFT
@ WD_IMGBTN_LEFT
Left offset of the image in the button.
Definition: window_gui.h:38
strecpy
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
Definition: string.cpp:112
WID_TF_CAPTION
@ WID_TF_CAPTION
The caption of the window.
Definition: misc_widget.h:51
free
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
Definition: stdafx.h:469
SettingEntry::GetHelpText
StringID GetHelpText() const
Get the help text of a single setting.
Definition: settings_gui.cpp:785
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:120
BaseSet::GetNumInvalid
int GetNumInvalid() const
Get the number of invalid files.
Definition: base_media_base.h:98
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:47
GameSettingsWindow::manually_changed_folding
bool manually_changed_folding
Whether the user expanded/collapsed something manually.
Definition: settings_gui.cpp:1813
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:918
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:2012
AWV_INCREASE
@ AWV_INCREASE
Arrow to the right or in case of RTL to the left.
Definition: widget_type.h:36
QSF_ENABLE_DEFAULT
@ QSF_ENABLE_DEFAULT
enable the 'Default' button ("\0" is returned)
Definition: textbuf_gui.h:21
Window::DisableWidget
void DisableWidget(byte widget_index)
Sets a widget to disabled.
Definition: window_gui.h:402
CLRBITS
#define CLRBITS(x, y)
Clears several bits in a variable.
Definition: bitmath_func.hpp:166
NWidgetBase::current_x
uint current_x
Current horizontal size (after resizing).
Definition: widget_type.h:172
GetVariableAddress
static void * GetVariableAddress(const void *object, const SaveLoad *sld)
Get the address of the variable.
Definition: saveload.h:894
WC_TEXTFILE
@ WC_TEXTFILE
textfile; Window numbers:
Definition: window_type.h:180
lastof
#define lastof(x)
Get the last element of an fixed size array.
Definition: stdafx.h:393
WHR_NONE
@ WHR_NONE
Nothing was filtering matches away.
Definition: settings_gui.cpp:1790
SettingsContainer::GetFoldingState
void GetFoldingState(bool &all_folded, bool &all_unfolded) const
Recursively accumulate the folding state of the tree.
Definition: settings_gui.cpp:1199
WDP_CENTER
@ WDP_CENTER
Center the window.
Definition: window_gui.h:155
ChangeMusicSet
void ChangeMusicSet(int index)
Change the configured music set and reset playback.
Definition: music_gui.cpp:431
Window::SetWidgetLoweredState
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:453
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:1806
ReadLanguagePack
bool ReadLanguagePack(const LanguageMetadata *lang)
Read a particular language.
Definition: strings.cpp:1728
GameOptionsWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: settings_gui.cpp:494
_left_button_clicked
bool _left_button_clicked
Is left mouse button clicked?
Definition: gfx.cpp:39
WID_GO_TOWNNAME_DROPDOWN
@ WID_GO_TOWNNAME_DROPDOWN
Town name dropdown.
Definition: settings_widget.h:19
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:2333
_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:78
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:1339
CharSetFilter
CharSetFilter
Valid filter types for IsValidChar.
Definition: string_type.h:26
_currency_specs
CurrencySpec _currency_specs[CURRENCY_END]
Array of currencies used by the system.
Definition: currency.cpp:72
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:2018
WD_TEXTPANEL_BOTTOM
@ WD_TEXTPANEL_BOTTOM
Offset at bottom to draw below the text.
Definition: window_gui.h:67
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:481
SettingDescBase::str_help
StringID str_help
(Translated) string with help text; gui only.
Definition: settings_internal.h:101
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:286
CURRENCY_CUSTOM
@ CURRENCY_CUSTOM
Custom currency.
Definition: currency.h:56
_settings_newgame
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
Definition: settings.cpp:81
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:565
WID_GS_TYPE_DROPDOWN
@ WID_GS_TYPE_DROPDOWN
The drop down box to choose client/game/company/all settings.
Definition: settings_widget.h:50
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:366
AWV_DECREASE
@ AWV_DECREASE
Arrow to the left or in case of RTL to the right.
Definition: widget_type.h:35
WWT_DROPDOWN
@ WWT_DROPDOWN
Drop down list.
Definition: widget_type.h:68
WD_TEXTPANEL_TOP
@ WD_TEXTPANEL_TOP
Offset at top to draw above the text.
Definition: window_gui.h:66
WID_CC_SUFFIX
@ WID_CC_SUFFIX
Current suffix.
Definition: settings_widget.h:63
BaseSettingEntry::IsFiltered
bool IsFiltered() const
Check whether an entry is hidden due to filters.
Definition: settings_gui.cpp:756
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:94
RM_ADVANCED
@ RM_ADVANCED
Display settings associated to the "advanced" list.
Definition: settings_gui.cpp:711
WN_GAME_OPTIONS_GAME_SETTINGS
@ WN_GAME_OPTIONS_GAME_SETTINGS
Game settings.
Definition: window_type.h:19
ShowGameOptions
void ShowGameOptions()
Open the game options window.
Definition: settings_gui.cpp:686
SettingEntryFlags
SettingEntryFlags
Flags for SettingEntry.
Definition: settings_gui.cpp:699
DropDownListStringItem::NatSortFunc
static bool NatSortFunc(std::unique_ptr< const DropDownListItem > const &first, std::unique_ptr< const DropDownListItem > const &second)
Natural sorting comparator function for DropDownList::sort().
Definition: dropdown.cpp:52