OpenTTD Source  1.11.2
settings_gui.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #include "stdafx.h"
11 #include "currency.h"
12 #include "error.h"
13 #include "settings_gui.h"
14 #include "textbuf_gui.h"
15 #include "command_func.h"
16 #include "network/network.h"
17 #include "town.h"
18 #include "settings_internal.h"
19 #include "strings_func.h"
20 #include "window_func.h"
21 #include "string_func.h"
22 #include "widgets/dropdown_type.h"
23 #include "widgets/dropdown_func.h"
24 #include "widgets/slider_func.h"
25 #include "highscore.h"
26 #include "base_media_base.h"
27 #include "company_base.h"
28 #include "company_func.h"
29 #include "viewport_func.h"
30 #include "core/geometry_func.hpp"
31 #include "ai/ai.hpp"
32 #include "blitter/factory.hpp"
33 #include "language.h"
34 #include "textfile_gui.h"
35 #include "stringfilter_type.h"
36 #include "querystring_gui.h"
37 #include "fontcache.h"
38 #include "zoom_func.h"
39 #include "video/video_driver.hpp"
40 #include "music/music_driver.hpp"
41 
42 #include <vector>
43 #include <iterator>
44 
45 #include "safeguards.h"
46 #include "video/video_driver.hpp"
47 
48 
49 static const StringID _autosave_dropdown[] = {
50  STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_OFF,
51  STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_1_MONTH,
52  STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_3_MONTHS,
53  STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_6_MONTHS,
54  STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_12_MONTHS,
56 };
57 
58 static const StringID _gui_zoom_dropdown[] = {
59  STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_AUTO,
60  STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_NORMAL,
61  STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_2X_ZOOM,
62  STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_4X_ZOOM,
64 };
65 
66 static const StringID _font_zoom_dropdown[] = {
67  STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_AUTO,
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 
75 
76 static const void *ResolveVariableAddress(const GameSettings *settings_ptr, const SettingDesc *sd);
77 
83 {
84  auto it = std::find(_resolutions.begin(), _resolutions.end(), Dimension(_screen.width, _screen.height));
85  return std::distance(_resolutions.begin(), it);
86 }
87 
88 static void ShowCustCurrency();
89 
90 template <class T>
91 static DropDownList BuildSetDropDownList(int *selected_index, bool allow_selection)
92 {
93  int n = T::GetNumSets();
94  *selected_index = T::GetIndexOfUsedSet();
95 
96  DropDownList list;
97  for (int i = 0; i < n; i++) {
98  list.emplace_back(new DropDownListCharStringItem(T::GetSet(i)->name, i, !allow_selection && (*selected_index != i)));
99  }
100 
101  return list;
102 }
103 
104 DropDownList BuildMusicSetDropDownList(int *selected_index)
105 {
106  return BuildSetDropDownList<BaseMusic>(selected_index, true);
107 }
108 
110 template <class TBaseSet>
112  const TBaseSet* baseset;
114 
116  {
117  const char *textfile = this->baseset->GetTextfile(file_type);
118  this->LoadTextfile(textfile, BASESET_DIR);
119  }
120 
121  void SetStringParameters(int widget) const override
122  {
123  if (widget == WID_TF_CAPTION) {
125  SetDParamStr(1, this->baseset->name.c_str());
126  }
127  }
128 };
129 
136 template <class TBaseSet>
137 void ShowBaseSetTextfileWindow(TextfileType file_type, const TBaseSet* baseset, StringID content_type)
138 {
139  DeleteWindowById(WC_TEXTFILE, file_type);
140  new BaseSetTextfileWindow<TBaseSet>(file_type, baseset, content_type);
141 }
142 
143 std::set<int> _refresh_rates = { 30, 60, 75, 90, 100, 120, 144, 240 };
144 
150 {
151  /* Add the refresh rate as selected in the config. */
152  _refresh_rates.insert(_settings_client.gui.refresh_rate);
153 
154  /* Add all the refresh rates of all monitors connected to the machine. */
155  std::vector<int> monitorRates = VideoDriver::GetInstance()->GetListOfMonitorRefreshRates();
156  std::copy(monitorRates.begin(), monitorRates.end(), std::inserter(_refresh_rates, _refresh_rates.end()));
157 }
158 
160  GameSettings *opt;
161  bool reload;
162 
163  GameOptionsWindow(WindowDesc *desc) : Window(desc)
164  {
165  this->opt = &GetGameSettings();
166  this->reload = false;
167 
169 
171  this->OnInvalidateData(0);
172  }
173 
175  {
178  if (this->reload) _switch_mode = SM_MENU;
179  }
180 
187  DropDownList BuildDropDownList(int widget, int *selected_index) const
188  {
189  DropDownList list;
190  switch (widget) {
191  case WID_GO_CURRENCY_DROPDOWN: { // Setup currencies dropdown
192  *selected_index = this->opt->locale.currency;
193  StringID *items = BuildCurrencyDropdown();
194  uint64 disabled = _game_mode == GM_MENU ? 0LL : ~GetMaskOfAllowedCurrencies();
195 
196  /* Add non-custom currencies; sorted naturally */
197  for (uint i = 0; i < CURRENCY_END; items++, i++) {
198  if (i == CURRENCY_CUSTOM) continue;
199  list.emplace_back(new DropDownListStringItem(*items, i, HasBit(disabled, i)));
200  }
201  std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
202 
203  /* Append custom currency at the end */
204  list.emplace_back(new DropDownListItem(-1, false)); // separator line
205  list.emplace_back(new DropDownListStringItem(STR_GAME_OPTIONS_CURRENCY_CUSTOM, CURRENCY_CUSTOM, HasBit(disabled, CURRENCY_CUSTOM)));
206  break;
207  }
208 
209  case WID_GO_AUTOSAVE_DROPDOWN: { // Setup autosave dropdown
210  *selected_index = _settings_client.gui.autosave;
211  const StringID *items = _autosave_dropdown;
212  for (uint i = 0; *items != INVALID_STRING_ID; items++, i++) {
213  list.emplace_back(new DropDownListStringItem(*items, i, false));
214  }
215  break;
216  }
217 
218  case WID_GO_LANG_DROPDOWN: { // Setup interface language dropdown
219  for (uint i = 0; i < _languages.size(); i++) {
220  auto item = new DropDownListParamStringItem(STR_JUST_RAW_STRING, i, false);
221  if (&_languages[i] == _current_language) {
222  *selected_index = i;
223  item->SetParamStr(0, _languages[i].own_name);
224  } else {
225  /* Especially with sprite-fonts, not all localized
226  * names can be rendered. So instead, we use the
227  * international names for anything but the current
228  * selected language. This avoids showing a few ????
229  * entries in the dropdown list. */
230  item->SetParamStr(0, _languages[i].name);
231  }
232  list.emplace_back(item);
233  }
234  std::sort(list.begin(), list.end(), DropDownListStringItem::NatSortFunc);
235  break;
236  }
237 
238  case WID_GO_RESOLUTION_DROPDOWN: // Setup resolution dropdown
239  if (_resolutions.empty()) break;
240 
241  *selected_index = GetCurrentResolutionIndex();
242  for (uint i = 0; i < _resolutions.size(); i++) {
243  auto item = new DropDownListParamStringItem(STR_GAME_OPTIONS_RESOLUTION_ITEM, i, false);
244  item->SetParam(0, _resolutions[i].width);
245  item->SetParam(1, _resolutions[i].height);
246  list.emplace_back(item);
247  }
248  break;
249 
250  case WID_GO_REFRESH_RATE_DROPDOWN: // Setup refresh rate dropdown
251  for (auto it = _refresh_rates.begin(); it != _refresh_rates.end(); it++) {
252  auto i = std::distance(_refresh_rates.begin(), it);
253  if (*it == _settings_client.gui.refresh_rate) *selected_index = i;
254  auto item = new DropDownListParamStringItem(STR_GAME_OPTIONS_REFRESH_RATE_ITEM, i, false);
255  item->SetParam(0, *it);
256  list.emplace_back(item);
257  }
258  break;
259 
261  *selected_index = _gui_zoom_cfg != ZOOM_LVL_CFG_AUTO ? ZOOM_LVL_OUT_4X - _gui_zoom + 1 : 0;
262  const StringID *items = _gui_zoom_dropdown;
263  for (int i = 0; *items != INVALID_STRING_ID; items++, i++) {
264  list.emplace_back(new DropDownListStringItem(*items, i, i != 0 && _settings_client.gui.zoom_min > ZOOM_LVL_OUT_4X - i + 1));
265  }
266  break;
267  }
268 
270  *selected_index = _font_zoom_cfg != ZOOM_LVL_CFG_AUTO ? ZOOM_LVL_OUT_4X - _font_zoom + 1 : 0;
271  const StringID *items = _font_zoom_dropdown;
272  for (int i = 0; *items != INVALID_STRING_ID; items++, i++) {
273  list.emplace_back(new DropDownListStringItem(*items, i, false));
274  }
275  break;
276  }
277 
279  list = BuildSetDropDownList<BaseGraphics>(selected_index, (_game_mode == GM_MENU));
280  break;
281 
283  list = BuildSetDropDownList<BaseSounds>(selected_index, (_game_mode == GM_MENU));
284  break;
285 
287  list = BuildMusicSetDropDownList(selected_index);
288  break;
289  }
290 
291  return list;
292  }
293 
294  void SetStringParameters(int widget) const override
295  {
296  switch (widget) {
297  case WID_GO_CURRENCY_DROPDOWN: SetDParam(0, _currency_specs[this->opt->locale.currency].name); break;
298  case WID_GO_AUTOSAVE_DROPDOWN: SetDParam(0, _autosave_dropdown[_settings_client.gui.autosave]); break;
300  case WID_GO_GUI_ZOOM_DROPDOWN: SetDParam(0, _gui_zoom_dropdown[_gui_zoom_cfg != ZOOM_LVL_CFG_AUTO ? ZOOM_LVL_OUT_4X - _gui_zoom_cfg + 1 : 0]); break;
301  case WID_GO_FONT_ZOOM_DROPDOWN: SetDParam(0, _font_zoom_dropdown[_font_zoom_cfg != ZOOM_LVL_CFG_AUTO ? ZOOM_LVL_OUT_4X - _font_zoom_cfg + 1 : 0]); break;
302  case WID_GO_BASE_GRF_DROPDOWN: SetDParamStr(0, BaseGraphics::GetUsedSet()->name.c_str()); break;
303  case WID_GO_BASE_GRF_STATUS: SetDParam(0, BaseGraphics::GetUsedSet()->GetNumInvalid()); break;
304  case WID_GO_BASE_SFX_DROPDOWN: SetDParamStr(0, BaseSounds::GetUsedSet()->name.c_str()); break;
305  case WID_GO_BASE_MUSIC_DROPDOWN: SetDParamStr(0, BaseMusic::GetUsedSet()->name.c_str()); break;
306  case WID_GO_BASE_MUSIC_STATUS: SetDParam(0, BaseMusic::GetUsedSet()->GetNumInvalid()); break;
309  auto current_resolution = GetCurrentResolutionIndex();
310 
311  if (current_resolution == _resolutions.size()) {
312  SetDParam(0, STR_GAME_OPTIONS_RESOLUTION_OTHER);
313  } else {
314  SetDParam(0, STR_GAME_OPTIONS_RESOLUTION_ITEM);
315  SetDParam(1, _resolutions[current_resolution].width);
316  SetDParam(2, _resolutions[current_resolution].height);
317  }
318  break;
319  }
320  }
321  }
322 
323  void DrawWidget(const Rect &r, int widget) const override
324  {
325  switch (widget) {
328  DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_BLACK_RAW_STRING);
329  break;
330 
333  DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_BLACK_RAW_STRING);
334  break;
335 
338  DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, STR_BLACK_RAW_STRING);
339  break;
340 
343  break;
344 
347  break;
348  }
349  }
350 
351  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
352  {
353  switch (widget) {
355  /* Find the biggest description for the default size. */
356  for (int i = 0; i < BaseGraphics::GetNumSets(); i++) {
358  size->height = std::max(size->height, (uint)GetStringHeight(STR_BLACK_RAW_STRING, size->width));
359  }
360  break;
361 
363  /* Find the biggest description for the default size. */
364  for (int i = 0; i < BaseGraphics::GetNumSets(); i++) {
365  uint invalid_files = BaseGraphics::GetSet(i)->GetNumInvalid();
366  if (invalid_files == 0) continue;
367 
368  SetDParam(0, invalid_files);
369  *size = maxdim(*size, GetStringBoundingBox(STR_GAME_OPTIONS_BASE_GRF_STATUS));
370  }
371  break;
372 
374  /* Find the biggest description for the default size. */
375  for (int i = 0; i < BaseSounds::GetNumSets(); i++) {
377  size->height = std::max(size->height, (uint)GetStringHeight(STR_BLACK_RAW_STRING, size->width));
378  }
379  break;
380 
382  /* Find the biggest description for the default size. */
383  for (int i = 0; i < BaseMusic::GetNumSets(); i++) {
384  SetDParamStr(0, BaseMusic::GetSet(i)->GetDescription(GetCurrentLanguageIsoCode()));
385  size->height = std::max(size->height, (uint)GetStringHeight(STR_BLACK_RAW_STRING, size->width));
386  }
387  break;
388 
390  /* Find the biggest description for the default size. */
391  for (int i = 0; i < BaseMusic::GetNumSets(); i++) {
392  uint invalid_files = BaseMusic::GetSet(i)->GetNumInvalid();
393  if (invalid_files == 0) continue;
394 
395  SetDParam(0, invalid_files);
396  *size = maxdim(*size, GetStringBoundingBox(STR_GAME_OPTIONS_BASE_MUSIC_STATUS));
397  }
398  break;
399 
402  size->width = ScaleGUITrad(67);
403  size->height = ScaleGUITrad(12);
404  resize->width = 0;
405  resize->height = 0;
406  fill->width = 0;
407  fill->height = 0;
408  break;
409 
410  default: {
411  int selected;
412  DropDownList list = this->BuildDropDownList(widget, &selected);
413  if (!list.empty()) {
414  /* Find the biggest item for the default size. */
415  for (const auto &ddli : list) {
416  Dimension string_dim;
417  int width = ddli->Width();
418  string_dim.width = width + padding.width;
419  string_dim.height = ddli->Height(width) + padding.height;
420  *size = maxdim(*size, string_dim);
421  }
422  }
423  }
424  }
425  }
426 
427  void OnClick(Point pt, int widget, int click_count) override
428  {
429  if (widget >= WID_GO_BASE_GRF_TEXTFILE && widget < WID_GO_BASE_GRF_TEXTFILE + TFT_END) {
430  if (BaseGraphics::GetUsedSet() == nullptr) return;
431 
432  ShowBaseSetTextfileWindow((TextfileType)(widget - WID_GO_BASE_GRF_TEXTFILE), BaseGraphics::GetUsedSet(), STR_CONTENT_TYPE_BASE_GRAPHICS);
433  return;
434  }
435  if (widget >= WID_GO_BASE_SFX_TEXTFILE && widget < WID_GO_BASE_SFX_TEXTFILE + TFT_END) {
436  if (BaseSounds::GetUsedSet() == nullptr) return;
437 
438  ShowBaseSetTextfileWindow((TextfileType)(widget - WID_GO_BASE_SFX_TEXTFILE), BaseSounds::GetUsedSet(), STR_CONTENT_TYPE_BASE_SOUNDS);
439  return;
440  }
441  if (widget >= WID_GO_BASE_MUSIC_TEXTFILE && widget < WID_GO_BASE_MUSIC_TEXTFILE + TFT_END) {
442  if (BaseMusic::GetUsedSet() == nullptr) return;
443 
444  ShowBaseSetTextfileWindow((TextfileType)(widget - WID_GO_BASE_MUSIC_TEXTFILE), BaseMusic::GetUsedSet(), STR_CONTENT_TYPE_BASE_MUSIC);
445  return;
446  }
447  switch (widget) {
448  case WID_GO_FULLSCREEN_BUTTON: // Click fullscreen on/off
449  /* try to toggle full-screen on/off */
450  if (!ToggleFullScreen(!_fullscreen)) {
451  ShowErrorMessage(STR_ERROR_FULLSCREEN_FAILED, INVALID_STRING_ID, WL_ERROR);
452  }
454  this->SetDirty();
455  break;
456 
459  ShowErrorMessage(STR_GAME_OPTIONS_VIDEO_ACCELERATION_RESTART, INVALID_STRING_ID, WL_INFO);
461 #ifndef __APPLE__
463 #endif
464  this->SetDirty();
465  break;
466 
468  if (!_video_hw_accel) break;
469 
472 
474  this->SetDirty();
475  break;
476 
480  if (ClickVolumeSliderWidget(this->GetWidget<NWidgetBase>(widget)->GetCurrentRect(), pt, vol)) {
482  this->SetDirty();
484  }
485 
486  if (click_count > 0) this->mouse_capture_widget = widget;
487  break;
488  }
489 
490  default: {
491  int selected;
492  DropDownList list = this->BuildDropDownList(widget, &selected);
493  if (!list.empty()) {
494  ShowDropDownList(this, std::move(list), selected, widget);
495  } else {
496  if (widget == WID_GO_RESOLUTION_DROPDOWN) ShowErrorMessage(STR_ERROR_RESOLUTION_LIST_FAILED, INVALID_STRING_ID, WL_ERROR);
497  }
498  break;
499  }
500  }
501  }
502 
508  template <class T>
509  void SetMediaSet(int index)
510  {
511  if (_game_mode == GM_MENU) {
512  auto name = T::GetSet(index)->name;
513 
514  T::ini_set = name;
515 
516  T::SetSet(name);
517  this->reload = true;
518  this->InvalidateData();
519  }
520  }
521 
522  void OnDropdownSelect(int widget, int index) override
523  {
524  switch (widget) {
525  case WID_GO_CURRENCY_DROPDOWN: // Currency
526  if (index == CURRENCY_CUSTOM) ShowCustCurrency();
527  this->opt->locale.currency = index;
529  break;
530 
531  case WID_GO_AUTOSAVE_DROPDOWN: // Autosave options
532  _settings_client.gui.autosave = index;
533  this->SetDirty();
534  break;
535 
536  case WID_GO_LANG_DROPDOWN: // Change interface language
537  ReadLanguagePack(&_languages[index]);
540  ClearAllCachedNames();
542  CheckBlitter();
544  break;
545 
546  case WID_GO_RESOLUTION_DROPDOWN: // Change resolution
547  if ((uint)index < _resolutions.size() && ChangeResInGame(_resolutions[index].width, _resolutions[index].height)) {
548  this->SetDirty();
549  }
550  break;
551 
553  _settings_client.gui.refresh_rate = *std::next(_refresh_rates.begin(), index);
554  if (_settings_client.gui.refresh_rate > 60) {
555  /* Show warning to the user that this refresh rate might not be suitable on
556  * larger maps with many NewGRFs and vehicles. */
557  ShowErrorMessage(STR_GAME_OPTIONS_REFRESH_RATE_WARNING, INVALID_STRING_ID, WL_INFO);
558  }
559  break;
560  }
561 
563  int8 new_zoom = index > 0 ? ZOOM_LVL_OUT_4X - index + 1 : ZOOM_LVL_CFG_AUTO;
564  if (new_zoom != _gui_zoom_cfg) {
566  _gui_zoom_cfg = new_zoom;
567  UpdateGUIZoom();
570  FixTitleGameZoom();
572  }
573  break;
574  }
575 
577  int8 new_zoom = index > 0 ? ZOOM_LVL_OUT_4X - index + 1 : ZOOM_LVL_CFG_AUTO;
578  if (new_zoom != _font_zoom_cfg) {
580  _font_zoom_cfg = new_zoom;
581  UpdateGUIZoom();
582  ClearFontCache();
585  }
586  break;
587  }
588 
590  this->SetMediaSet<BaseGraphics>(index);
591  break;
592 
594  this->SetMediaSet<BaseSounds>(index);
595  break;
596 
598  ChangeMusicSet(index);
599  break;
600  }
601  }
602 
608  void OnInvalidateData(int data = 0, bool gui_scope = true) override
609  {
610  if (!gui_scope) return;
613 
614 #ifndef __APPLE__
617 #endif
618 
619  bool missing_files = BaseGraphics::GetUsedSet()->GetNumMissing() == 0;
620  this->GetWidget<NWidgetCore>(WID_GO_BASE_GRF_STATUS)->SetDataTip(missing_files ? STR_EMPTY : STR_GAME_OPTIONS_BASE_GRF_STATUS, STR_NULL);
621 
622  for (TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) {
626  }
627 
628  missing_files = BaseMusic::GetUsedSet()->GetNumInvalid() == 0;
629  this->GetWidget<NWidgetCore>(WID_GO_BASE_MUSIC_STATUS)->SetDataTip(missing_files ? STR_EMPTY : STR_GAME_OPTIONS_BASE_MUSIC_STATUS, STR_NULL);
630  }
631 };
632 
633 static const NWidgetPart _nested_game_options_widgets[] = {
635  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
636  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
637  EndContainer(),
638  NWidget(WWT_PANEL, COLOUR_GREY, WID_GO_BACKGROUND), SetPIP(6, 6, 10),
639  NWidget(NWID_HORIZONTAL), SetPIP(10, 10, 10),
640  NWidget(NWID_VERTICAL), SetPIP(0, 6, 0),
641  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_AUTOSAVE_FRAME, STR_NULL),
642  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),
643  EndContainer(),
644  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_GUI_ZOOM_FRAME, STR_NULL),
645  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),
646  EndContainer(),
647  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_CURRENCY_UNITS_FRAME, STR_NULL),
648  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),
649  EndContainer(),
650  EndContainer(),
651 
652  NWidget(NWID_VERTICAL), SetPIP(0, 6, 0),
653  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_LANGUAGE, STR_NULL),
654  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),
655  EndContainer(),
656  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_FONT_ZOOM, STR_NULL),
657  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),
658  EndContainer(),
659  EndContainer(),
660  EndContainer(),
661 
662  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_GRAPHICS, STR_NULL), SetPadding(0, 10, 0, 10),
664  NWidget(NWID_VERTICAL), SetPIP(0, 2, 0),
666  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12),SetDataTip(STR_GAME_OPTIONS_RESOLUTION, STR_NULL),
667  NWidget(NWID_SPACER), SetMinimalSize(1, 0), SetFill(1, 0),
668  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_RESOLUTION_DROPDOWN), SetMinimalSize(200, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_RESOLUTION_TOOLTIP),
669  EndContainer(),
671  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetDataTip(STR_GAME_OPTIONS_REFRESH_RATE, STR_NULL),
672  NWidget(NWID_SPACER), SetMinimalSize(1, 0), SetFill(1, 0),
673  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_REFRESH_RATE_DROPDOWN), SetMinimalSize(200, 12), SetDataTip(STR_GAME_OPTIONS_REFRESH_RATE_ITEM, STR_GAME_OPTIONS_REFRESH_RATE_TOOLTIP),
674  EndContainer(),
676  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetDataTip(STR_GAME_OPTIONS_FULLSCREEN, STR_NULL),
677  NWidget(NWID_SPACER), SetMinimalSize(1, 0), SetFill(1, 0),
678  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_FULLSCREEN_BUTTON), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_FULLSCREEN_TOOLTIP),
679  EndContainer(),
681  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetDataTip(STR_GAME_OPTIONS_VIDEO_ACCELERATION, STR_NULL),
682  NWidget(NWID_SPACER), SetMinimalSize(1, 0), SetFill(1, 0),
683  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_VIDEO_ACCEL_BUTTON), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_VIDEO_ACCELERATION_TOOLTIP),
684  EndContainer(),
685 #ifndef __APPLE__
687  NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetDataTip(STR_GAME_OPTIONS_VIDEO_VSYNC, STR_NULL),
688  NWidget(NWID_SPACER), SetMinimalSize(1, 0), SetFill(1, 0),
689  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_VIDEO_VSYNC_BUTTON), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_VIDEO_VSYNC_TOOLTIP),
690  EndContainer(),
691 #endif
692  EndContainer(),
693  EndContainer(),
694  EndContainer(),
695 
696  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_BASE_GRF, STR_NULL), SetPadding(0, 10, 0, 10),
697  NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 0),
698  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_GRF_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_RAW_STRING, STR_GAME_OPTIONS_BASE_GRF_TOOLTIP),
699  NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_BASE_GRF_STATUS), SetMinimalSize(150, 12), SetDataTip(STR_EMPTY, STR_NULL), SetFill(1, 0),
700  EndContainer(),
701  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),
703  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),
704  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),
705  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),
706  EndContainer(),
707  EndContainer(),
708 
709  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_BASE_SFX, STR_NULL), SetPadding(0, 10, 0, 10),
710  NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 7),
711  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_SFX_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_RAW_STRING, STR_GAME_OPTIONS_BASE_SFX_TOOLTIP),
712  NWidget(NWID_SPACER), SetMinimalSize(150, 12), SetFill(1, 0),
713  NWidget(WWT_EMPTY, COLOUR_GREY, WID_GO_BASE_SFX_VOLUME), SetMinimalSize(67, 12), SetMinimalTextLines(1, 0), SetDataTip(0x0, STR_MUSIC_TOOLTIP_DRAG_SLIDERS_TO_SET_MUSIC),
714  EndContainer(),
715  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),
717  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),
718  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),
719  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),
720  EndContainer(),
721  EndContainer(),
722 
723  NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_BASE_MUSIC, STR_NULL), SetPadding(0, 10, 0, 10),
724  NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 7),
725  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BASE_MUSIC_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_RAW_STRING, STR_GAME_OPTIONS_BASE_MUSIC_TOOLTIP),
726  NWidget(WWT_TEXT, COLOUR_GREY, WID_GO_BASE_MUSIC_STATUS), SetMinimalSize(150, 12), SetDataTip(STR_EMPTY, STR_NULL), SetFill(1, 0),
727  NWidget(WWT_EMPTY, COLOUR_GREY, WID_GO_BASE_MUSIC_VOLUME), SetMinimalSize(67, 12), SetMinimalTextLines(1, 0), SetDataTip(0x0, STR_MUSIC_TOOLTIP_DRAG_SLIDERS_TO_SET_MUSIC),
728  EndContainer(),
729  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),
731  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),
732  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),
733  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),
734  EndContainer(),
735  EndContainer(),
736  EndContainer(),
737 };
738 
739 static WindowDesc _game_options_desc(
740  WDP_CENTER, "settings_game", 0, 0,
742  0,
743  _nested_game_options_widgets, lengthof(_nested_game_options_widgets)
744 );
745 
748 {
750  new GameOptionsWindow(&_game_options_desc);
751 }
752 
753 static int SETTING_HEIGHT = 11;
754 static const int LEVEL_WIDTH = 15;
755 
764 
765  SEF_LAST_FIELD = 0x04,
766  SEF_FILTERED = 0x08,
767 };
768 
777 };
779 
780 
784  bool type_hides;
787 };
788 
791  byte flags;
792  byte level;
793 
794  BaseSettingEntry() : flags(0), level(0) {}
795  virtual ~BaseSettingEntry() {}
796 
797  virtual void Init(byte level = 0);
798  virtual void FoldAll() {}
799  virtual void UnFoldAll() {}
800 
805  void SetLastField(bool last_field) { if (last_field) SETBITS(this->flags, SEF_LAST_FIELD); else CLRBITS(this->flags, SEF_LAST_FIELD); }
806 
807  virtual uint Length() const = 0;
808  virtual void GetFoldingState(bool &all_folded, bool &all_unfolded) const {}
809  virtual bool IsVisible(const BaseSettingEntry *item) const;
810  virtual BaseSettingEntry *FindEntry(uint row, uint *cur_row);
811  virtual uint GetMaxHelpHeight(int maxw) { return 0; }
812 
817  bool IsFiltered() const { return (this->flags & SEF_FILTERED) != 0; }
818 
819  virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible) = 0;
820 
821  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;
822 
823 protected:
824  virtual void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const = 0;
825 };
826 
829  const char *name;
831  uint index;
832 
833  SettingEntry(const char *name);
834 
835  virtual void Init(byte level = 0);
836  virtual uint Length() const;
837  virtual uint GetMaxHelpHeight(int maxw);
838  virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible);
839 
840  void SetButtons(byte new_val);
841 
846  inline StringID GetHelpText() const
847  {
848  return this->setting->desc.str_help;
849  }
850 
851  void SetValueDParams(uint first_param, int32 value) const;
852 
853 protected:
854  virtual void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const;
855 
856 private:
858 };
859 
862  typedef std::vector<BaseSettingEntry*> EntryVector;
863  EntryVector entries;
864 
865  template<typename T>
866  T *Add(T *item)
867  {
868  this->entries.push_back(item);
869  return item;
870  }
871 
872  void Init(byte level = 0);
873  void FoldAll();
874  void UnFoldAll();
875 
876  uint Length() const;
877  void GetFoldingState(bool &all_folded, bool &all_unfolded) const;
878  bool IsVisible(const BaseSettingEntry *item) const;
879  BaseSettingEntry *FindEntry(uint row, uint *cur_row);
880  uint GetMaxHelpHeight(int maxw);
881 
882  bool UpdateFilterState(SettingFilter &filter, bool force_visible);
883 
884  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;
885 };
886 
890  bool folded;
891 
893 
894  virtual void Init(byte level = 0);
895  virtual void FoldAll();
896  virtual void UnFoldAll();
897 
898  virtual uint Length() const;
899  virtual void GetFoldingState(bool &all_folded, bool &all_unfolded) const;
900  virtual bool IsVisible(const BaseSettingEntry *item) const;
901  virtual BaseSettingEntry *FindEntry(uint row, uint *cur_row);
902  virtual uint GetMaxHelpHeight(int maxw) { return SettingsContainer::GetMaxHelpHeight(maxw); }
903 
904  virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible);
905 
906  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;
907 
908 protected:
909  virtual void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const;
910 };
911 
912 /* == BaseSettingEntry methods == */
913 
918 void BaseSettingEntry::Init(byte level)
919 {
920  this->level = level;
921 }
922 
930 {
931  if (this->IsFiltered()) return false;
932  if (this == item) return true;
933  return false;
934 }
935 
942 BaseSettingEntry *BaseSettingEntry::FindEntry(uint row_num, uint *cur_row)
943 {
944  if (this->IsFiltered()) return nullptr;
945  if (row_num == *cur_row) return this;
946  (*cur_row)++;
947  return nullptr;
948 }
949 
979 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
980 {
981  if (this->IsFiltered()) return cur_row;
982  if (cur_row >= max_row) return cur_row;
983 
984  bool rtl = _current_text_dir == TD_RTL;
985  int offset = rtl ? -4 : 4;
986  int level_width = rtl ? -LEVEL_WIDTH : LEVEL_WIDTH;
987 
988  int x = rtl ? right : left;
989  if (cur_row >= first_row) {
990  int colour = _colour_gradient[COLOUR_ORANGE][4];
991  y += (cur_row - first_row) * SETTING_HEIGHT; // Compute correct y start position
992 
993  /* Draw vertical for parent nesting levels */
994  for (uint lvl = 0; lvl < this->level; lvl++) {
995  if (!HasBit(parent_last, lvl)) GfxDrawLine(x + offset, y, x + offset, y + SETTING_HEIGHT - 1, colour);
996  x += level_width;
997  }
998  /* draw own |- prefix */
999  int halfway_y = y + SETTING_HEIGHT / 2;
1000  int bottom_y = (flags & SEF_LAST_FIELD) ? halfway_y : y + SETTING_HEIGHT - 1;
1001  GfxDrawLine(x + offset, y, x + offset, bottom_y, colour);
1002  /* Small horizontal line from the last vertical line */
1003  GfxDrawLine(x + offset, halfway_y, x + level_width - offset, halfway_y, colour);
1004  x += level_width;
1005 
1006  this->DrawSetting(settings_ptr, rtl ? left : x, rtl ? x : right, y, this == selected);
1007  }
1008  cur_row++;
1009 
1010  return cur_row;
1011 }
1012 
1013 /* == SettingEntry methods == */
1014 
1020 {
1021  this->name = name;
1022  this->setting = nullptr;
1023  this->index = 0;
1024 }
1025 
1030 void SettingEntry::Init(byte level)
1031 {
1033  this->setting = GetSettingFromName(this->name, &this->index);
1034  assert(this->setting != nullptr);
1035 }
1036 
1042 void SettingEntry::SetButtons(byte new_val)
1043 {
1044  assert((new_val & ~SEF_BUTTONS_MASK) == 0); // Should not touch any flags outside the buttons
1045  this->flags = (this->flags & ~SEF_BUTTONS_MASK) | new_val;
1046 }
1047 
1050 {
1051  return this->IsFiltered() ? 0 : 1;
1052 }
1053 
1060 {
1061  return GetStringHeight(this->GetHelpText(), maxw);
1062 }
1063 
1070 {
1071  /* There shall not be any restriction, i.e. all settings shall be visible. */
1072  if (mode == RM_ALL) return true;
1073 
1074  GameSettings *settings_ptr = &GetGameSettings();
1075  const SettingDesc *sd = this->setting;
1076 
1077  if (mode == RM_BASIC) return (this->setting->desc.cat & SC_BASIC_LIST) != 0;
1078  if (mode == RM_ADVANCED) return (this->setting->desc.cat & SC_ADVANCED_LIST) != 0;
1079 
1080  /* Read the current value. */
1081  const void *var = ResolveVariableAddress(settings_ptr, sd);
1082  int64 current_value = ReadValue(var, sd->save.conv);
1083 
1084  int64 filter_value;
1085 
1086  if (mode == RM_CHANGED_AGAINST_DEFAULT) {
1087  /* This entry shall only be visible, if the value deviates from its default value. */
1088 
1089  /* Read the default value. */
1090  filter_value = ReadValue(&sd->desc.def, sd->save.conv);
1091  } else {
1092  assert(mode == RM_CHANGED_AGAINST_NEW);
1093  /* This entry shall only be visible, if the value deviates from
1094  * its value is used when starting a new game. */
1095 
1096  /* Make sure we're not comparing the new game settings against itself. */
1097  assert(settings_ptr != &_settings_newgame);
1098 
1099  /* Read the new game's value. */
1100  var = ResolveVariableAddress(&_settings_newgame, sd);
1101  filter_value = ReadValue(var, sd->save.conv);
1102  }
1103 
1104  return current_value != filter_value;
1105 }
1106 
1113 bool SettingEntry::UpdateFilterState(SettingFilter &filter, bool force_visible)
1114 {
1115  CLRBITS(this->flags, SEF_FILTERED);
1116 
1117  bool visible = true;
1118 
1119  const SettingDesc *sd = this->setting;
1120  if (!force_visible && !filter.string.IsEmpty()) {
1121  /* Process the search text filter for this item. */
1122  filter.string.ResetState();
1123 
1124  const SettingDescBase *sdb = &sd->desc;
1125 
1126  SetDParam(0, STR_EMPTY);
1127  filter.string.AddLine(sdb->str);
1128  filter.string.AddLine(this->GetHelpText());
1129 
1130  visible = filter.string.GetState();
1131  }
1132 
1133  if (visible) {
1134  if (filter.type != ST_ALL && sd->GetType() != filter.type) {
1135  filter.type_hides = true;
1136  visible = false;
1137  }
1138  if (!this->IsVisibleByRestrictionMode(filter.mode)) {
1139  while (filter.min_cat < RM_ALL && (filter.min_cat == filter.mode || !this->IsVisibleByRestrictionMode(filter.min_cat))) filter.min_cat++;
1140  visible = false;
1141  }
1142  }
1143 
1144  if (!visible) SETBITS(this->flags, SEF_FILTERED);
1145  return visible;
1146 }
1147 
1148 
1149 static const void *ResolveVariableAddress(const GameSettings *settings_ptr, const SettingDesc *sd)
1150 {
1151  if ((sd->desc.flags & SGF_PER_COMPANY) != 0) {
1152  if (Company::IsValidID(_local_company) && _game_mode != GM_MENU) {
1154  } else {
1156  }
1157  } else {
1158  return GetVariableAddress(settings_ptr, &sd->save);
1159  }
1160 }
1161 
1167 void SettingEntry::SetValueDParams(uint first_param, int32 value) const
1168 {
1169  const SettingDescBase *sdb = &this->setting->desc;
1170  if (sdb->cmd == SDT_BOOLX) {
1171  SetDParam(first_param++, value != 0 ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
1172  } else {
1173  if ((sdb->flags & SGF_MULTISTRING) != 0) {
1174  SetDParam(first_param++, sdb->str_val - sdb->min + value);
1175  } else if ((sdb->flags & SGF_DISPLAY_ABS) != 0) {
1176  SetDParam(first_param++, sdb->str_val + ((value >= 0) ? 1 : 0));
1177  value = abs(value);
1178  } else {
1179  SetDParam(first_param++, sdb->str_val + ((value == 0 && (sdb->flags & SGF_0ISDISABLED) != 0) ? 1 : 0));
1180  }
1181  SetDParam(first_param++, value);
1182  }
1183 }
1184 
1193 void SettingEntry::DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const
1194 {
1195  const SettingDesc *sd = this->setting;
1196  const SettingDescBase *sdb = &sd->desc;
1197  const void *var = ResolveVariableAddress(settings_ptr, sd);
1198  int state = this->flags & SEF_BUTTONS_MASK;
1199 
1200  bool rtl = _current_text_dir == TD_RTL;
1201  uint buttons_left = rtl ? right + 1 - SETTING_BUTTON_WIDTH : left;
1202  uint text_left = left + (rtl ? 0 : SETTING_BUTTON_WIDTH + 5);
1203  uint text_right = right - (rtl ? SETTING_BUTTON_WIDTH + 5 : 0);
1204  uint button_y = y + (SETTING_HEIGHT - SETTING_BUTTON_HEIGHT) / 2;
1205 
1206  /* We do not allow changes of some items when we are a client in a networkgame */
1207  bool editable = sd->IsEditable();
1208 
1209  SetDParam(0, highlight ? STR_ORANGE_STRING1_WHITE : STR_ORANGE_STRING1_LTBLUE);
1210  int32 value = (int32)ReadValue(var, sd->save.conv);
1211  if (sdb->cmd == SDT_BOOLX) {
1212  /* Draw checkbox for boolean-value either on/off */
1213  DrawBoolButton(buttons_left, button_y, value != 0, editable);
1214  } else if ((sdb->flags & SGF_MULTISTRING) != 0) {
1215  /* Draw [v] button for settings of an enum-type */
1216  DrawDropDownButton(buttons_left, button_y, COLOUR_YELLOW, state != 0, editable);
1217  } else {
1218  /* Draw [<][>] boxes for settings of an integer-type */
1219  DrawArrowButtons(buttons_left, button_y, COLOUR_YELLOW, state,
1220  editable && value != (sdb->flags & SGF_0ISDISABLED ? 0 : sdb->min), editable && (uint32)value != sdb->max);
1221  }
1222  this->SetValueDParams(1, value);
1223  DrawString(text_left, text_right, y + (SETTING_HEIGHT - FONT_HEIGHT_NORMAL) / 2, sdb->str, highlight ? TC_WHITE : TC_LIGHT_BLUE);
1224 }
1225 
1226 /* == SettingsContainer methods == */
1227 
1232 void SettingsContainer::Init(byte level)
1233 {
1234  for (EntryVector::iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1235  (*it)->Init(level);
1236  }
1237 }
1238 
1241 {
1242  for (EntryVector::iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1243  (*it)->FoldAll();
1244  }
1245 }
1246 
1249 {
1250  for (EntryVector::iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1251  (*it)->UnFoldAll();
1252  }
1253 }
1254 
1260 void SettingsContainer::GetFoldingState(bool &all_folded, bool &all_unfolded) const
1261 {
1262  for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1263  (*it)->GetFoldingState(all_folded, all_unfolded);
1264  }
1265 }
1266 
1273 bool SettingsContainer::UpdateFilterState(SettingFilter &filter, bool force_visible)
1274 {
1275  bool visible = false;
1276  bool first_visible = true;
1277  for (EntryVector::reverse_iterator it = this->entries.rbegin(); it != this->entries.rend(); ++it) {
1278  visible |= (*it)->UpdateFilterState(filter, force_visible);
1279  (*it)->SetLastField(first_visible);
1280  if (visible && first_visible) first_visible = false;
1281  }
1282  return visible;
1283 }
1284 
1285 
1293 {
1294  for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1295  if ((*it)->IsVisible(item)) return true;
1296  }
1297  return false;
1298 }
1299 
1302 {
1303  uint length = 0;
1304  for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1305  length += (*it)->Length();
1306  }
1307  return length;
1308 }
1309 
1316 BaseSettingEntry *SettingsContainer::FindEntry(uint row_num, uint *cur_row)
1317 {
1318  BaseSettingEntry *pe = nullptr;
1319  for (EntryVector::iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1320  pe = (*it)->FindEntry(row_num, cur_row);
1321  if (pe != nullptr) {
1322  break;
1323  }
1324  }
1325  return pe;
1326 }
1327 
1334 {
1335  uint biggest = 0;
1336  for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1337  biggest = std::max(biggest, (*it)->GetMaxHelpHeight(maxw));
1338  }
1339  return biggest;
1340 }
1341 
1342 
1357 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
1358 {
1359  for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1360  cur_row = (*it)->Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1361  if (cur_row >= max_row) {
1362  break;
1363  }
1364  }
1365  return cur_row;
1366 }
1367 
1368 /* == SettingsPage methods == */
1369 
1375 {
1376  this->title = title;
1377  this->folded = true;
1378 }
1379 
1384 void SettingsPage::Init(byte level)
1385 {
1388 }
1389 
1392 {
1393  if (this->IsFiltered()) return;
1394  this->folded = true;
1395 
1397 }
1398 
1401 {
1402  if (this->IsFiltered()) return;
1403  this->folded = false;
1404 
1406 }
1407 
1413 void SettingsPage::GetFoldingState(bool &all_folded, bool &all_unfolded) const
1414 {
1415  if (this->IsFiltered()) return;
1416 
1417  if (this->folded) {
1418  all_unfolded = false;
1419  } else {
1420  all_folded = false;
1421  }
1422 
1423  SettingsContainer::GetFoldingState(all_folded, all_unfolded);
1424 }
1425 
1432 bool SettingsPage::UpdateFilterState(SettingFilter &filter, bool force_visible)
1433 {
1434  if (!force_visible && !filter.string.IsEmpty()) {
1435  filter.string.ResetState();
1436  filter.string.AddLine(this->title);
1437  force_visible = filter.string.GetState();
1438  }
1439 
1440  bool visible = SettingsContainer::UpdateFilterState(filter, force_visible);
1441  if (visible) {
1442  CLRBITS(this->flags, SEF_FILTERED);
1443  } else {
1444  SETBITS(this->flags, SEF_FILTERED);
1445  }
1446  return visible;
1447 }
1448 
1456 {
1457  if (this->IsFiltered()) return false;
1458  if (this == item) return true;
1459  if (this->folded) return false;
1460 
1461  return SettingsContainer::IsVisible(item);
1462 }
1463 
1466 {
1467  if (this->IsFiltered()) return 0;
1468  if (this->folded) return 1; // Only displaying the title
1469 
1470  return 1 + SettingsContainer::Length();
1471 }
1472 
1479 BaseSettingEntry *SettingsPage::FindEntry(uint row_num, uint *cur_row)
1480 {
1481  if (this->IsFiltered()) return nullptr;
1482  if (row_num == *cur_row) return this;
1483  (*cur_row)++;
1484  if (this->folded) return nullptr;
1485 
1486  return SettingsContainer::FindEntry(row_num, cur_row);
1487 }
1488 
1503 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
1504 {
1505  if (this->IsFiltered()) return cur_row;
1506  if (cur_row >= max_row) return cur_row;
1507 
1508  cur_row = BaseSettingEntry::Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1509 
1510  if (!this->folded) {
1511  if (this->flags & SEF_LAST_FIELD) {
1512  assert(this->level < 8 * sizeof(parent_last));
1513  SetBit(parent_last, this->level); // Add own last-field state
1514  }
1515 
1516  cur_row = SettingsContainer::Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1517  }
1518 
1519  return cur_row;
1520 }
1521 
1530 void SettingsPage::DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const
1531 {
1532  bool rtl = _current_text_dir == TD_RTL;
1533  DrawSprite((this->folded ? SPR_CIRCLE_FOLDED : SPR_CIRCLE_UNFOLDED), PAL_NONE, rtl ? right - _circle_size.width : left, y + (SETTING_HEIGHT - _circle_size.height) / 2);
1534  DrawString(rtl ? left : left + _circle_size.width + 2, rtl ? right - _circle_size.width - 2 : right, y + (SETTING_HEIGHT - FONT_HEIGHT_NORMAL) / 2, this->title);
1535 }
1536 
1539 {
1540  static SettingsContainer *main = nullptr;
1541 
1542  if (main == nullptr)
1543  {
1544  /* Build up the dynamic settings-array only once per OpenTTD session */
1545  main = new SettingsContainer();
1546 
1547  SettingsPage *localisation = main->Add(new SettingsPage(STR_CONFIG_SETTING_LOCALISATION));
1548  {
1549  localisation->Add(new SettingEntry("locale.units_velocity"));
1550  localisation->Add(new SettingEntry("locale.units_power"));
1551  localisation->Add(new SettingEntry("locale.units_weight"));
1552  localisation->Add(new SettingEntry("locale.units_volume"));
1553  localisation->Add(new SettingEntry("locale.units_force"));
1554  localisation->Add(new SettingEntry("locale.units_height"));
1555  localisation->Add(new SettingEntry("gui.date_format_in_default_names"));
1556  }
1557 
1558  SettingsPage *graphics = main->Add(new SettingsPage(STR_CONFIG_SETTING_GRAPHICS));
1559  {
1560  graphics->Add(new SettingEntry("gui.zoom_min"));
1561  graphics->Add(new SettingEntry("gui.zoom_max"));
1562  graphics->Add(new SettingEntry("gui.sprite_zoom_min"));
1563  graphics->Add(new SettingEntry("gui.smallmap_land_colour"));
1564  graphics->Add(new SettingEntry("gui.graph_line_thickness"));
1565  }
1566 
1567  SettingsPage *sound = main->Add(new SettingsPage(STR_CONFIG_SETTING_SOUND));
1568  {
1569  sound->Add(new SettingEntry("sound.click_beep"));
1570  sound->Add(new SettingEntry("sound.confirm"));
1571  sound->Add(new SettingEntry("sound.news_ticker"));
1572  sound->Add(new SettingEntry("sound.news_full"));
1573  sound->Add(new SettingEntry("sound.new_year"));
1574  sound->Add(new SettingEntry("sound.disaster"));
1575  sound->Add(new SettingEntry("sound.vehicle"));
1576  sound->Add(new SettingEntry("sound.ambient"));
1577  }
1578 
1579  SettingsPage *interface = main->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE));
1580  {
1581  SettingsPage *general = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_GENERAL));
1582  {
1583  general->Add(new SettingEntry("gui.osk_activation"));
1584  general->Add(new SettingEntry("gui.hover_delay_ms"));
1585  general->Add(new SettingEntry("gui.errmsg_duration"));
1586  general->Add(new SettingEntry("gui.window_snap_radius"));
1587  general->Add(new SettingEntry("gui.window_soft_limit"));
1588  general->Add(new SettingEntry("gui.right_mouse_wnd_close"));
1589  }
1590 
1591  SettingsPage *viewports = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_VIEWPORTS));
1592  {
1593  viewports->Add(new SettingEntry("gui.auto_scrolling"));
1594  viewports->Add(new SettingEntry("gui.scroll_mode"));
1595  viewports->Add(new SettingEntry("gui.smooth_scroll"));
1596  /* While the horizontal scrollwheel scrolling is written as general code, only
1597  * the cocoa (OSX) driver generates input for it.
1598  * Since it's also able to completely disable the scrollwheel will we display it on all platforms anyway */
1599  viewports->Add(new SettingEntry("gui.scrollwheel_scrolling"));
1600  viewports->Add(new SettingEntry("gui.scrollwheel_multiplier"));
1601 #ifdef __APPLE__
1602  /* We might need to emulate a right mouse button on mac */
1603  viewports->Add(new SettingEntry("gui.right_mouse_btn_emulation"));
1604 #endif
1605  viewports->Add(new SettingEntry("gui.population_in_label"));
1606  viewports->Add(new SettingEntry("gui.liveries"));
1607  viewports->Add(new SettingEntry("construction.train_signal_side"));
1608  viewports->Add(new SettingEntry("gui.measure_tooltip"));
1609  viewports->Add(new SettingEntry("gui.loading_indicators"));
1610  viewports->Add(new SettingEntry("gui.show_track_reservation"));
1611  }
1612 
1613  SettingsPage *construction = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_CONSTRUCTION));
1614  {
1615  construction->Add(new SettingEntry("gui.link_terraform_toolbar"));
1616  construction->Add(new SettingEntry("gui.enable_signal_gui"));
1617  construction->Add(new SettingEntry("gui.persistent_buildingtools"));
1618  construction->Add(new SettingEntry("gui.quick_goto"));
1619  construction->Add(new SettingEntry("gui.default_rail_type"));
1620  }
1621 
1622  interface->Add(new SettingEntry("gui.fast_forward_speed_limit"));
1623  interface->Add(new SettingEntry("gui.autosave"));
1624  interface->Add(new SettingEntry("gui.toolbar_pos"));
1625  interface->Add(new SettingEntry("gui.statusbar_pos"));
1626  interface->Add(new SettingEntry("gui.prefer_teamchat"));
1627  interface->Add(new SettingEntry("gui.advanced_vehicle_list"));
1628  interface->Add(new SettingEntry("gui.timetable_in_ticks"));
1629  interface->Add(new SettingEntry("gui.timetable_arrival_departure"));
1630  interface->Add(new SettingEntry("gui.expenses_layout"));
1631  interface->Add(new SettingEntry("gui.show_newgrf_name"));
1632  }
1633 
1634  SettingsPage *advisors = main->Add(new SettingsPage(STR_CONFIG_SETTING_ADVISORS));
1635  {
1636  advisors->Add(new SettingEntry("gui.coloured_news_year"));
1637  advisors->Add(new SettingEntry("news_display.general"));
1638  advisors->Add(new SettingEntry("news_display.new_vehicles"));
1639  advisors->Add(new SettingEntry("news_display.accident"));
1640  advisors->Add(new SettingEntry("news_display.company_info"));
1641  advisors->Add(new SettingEntry("news_display.acceptance"));
1642  advisors->Add(new SettingEntry("news_display.arrival_player"));
1643  advisors->Add(new SettingEntry("news_display.arrival_other"));
1644  advisors->Add(new SettingEntry("news_display.advice"));
1645  advisors->Add(new SettingEntry("gui.order_review_system"));
1646  advisors->Add(new SettingEntry("gui.vehicle_income_warn"));
1647  advisors->Add(new SettingEntry("gui.lost_vehicle_warn"));
1648  advisors->Add(new SettingEntry("gui.show_finances"));
1649  advisors->Add(new SettingEntry("news_display.economy"));
1650  advisors->Add(new SettingEntry("news_display.subsidies"));
1651  advisors->Add(new SettingEntry("news_display.open"));
1652  advisors->Add(new SettingEntry("news_display.close"));
1653  advisors->Add(new SettingEntry("news_display.production_player"));
1654  advisors->Add(new SettingEntry("news_display.production_other"));
1655  advisors->Add(new SettingEntry("news_display.production_nobody"));
1656  }
1657 
1658  SettingsPage *company = main->Add(new SettingsPage(STR_CONFIG_SETTING_COMPANY));
1659  {
1660  company->Add(new SettingEntry("gui.semaphore_build_before"));
1661  company->Add(new SettingEntry("gui.default_signal_type"));
1662  company->Add(new SettingEntry("gui.cycle_signal_types"));
1663  company->Add(new SettingEntry("gui.drag_signals_fixed_distance"));
1664  company->Add(new SettingEntry("gui.auto_remove_signals"));
1665  company->Add(new SettingEntry("gui.new_nonstop"));
1666  company->Add(new SettingEntry("gui.stop_location"));
1667  company->Add(new SettingEntry("gui.starting_colour"));
1668  company->Add(new SettingEntry("company.engine_renew"));
1669  company->Add(new SettingEntry("company.engine_renew_months"));
1670  company->Add(new SettingEntry("company.engine_renew_money"));
1671  company->Add(new SettingEntry("vehicle.servint_ispercent"));
1672  company->Add(new SettingEntry("vehicle.servint_trains"));
1673  company->Add(new SettingEntry("vehicle.servint_roadveh"));
1674  company->Add(new SettingEntry("vehicle.servint_ships"));
1675  company->Add(new SettingEntry("vehicle.servint_aircraft"));
1676  }
1677 
1678  SettingsPage *accounting = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCOUNTING));
1679  {
1680  accounting->Add(new SettingEntry("economy.inflation"));
1681  accounting->Add(new SettingEntry("difficulty.initial_interest"));
1682  accounting->Add(new SettingEntry("difficulty.max_loan"));
1683  accounting->Add(new SettingEntry("difficulty.subsidy_multiplier"));
1684  accounting->Add(new SettingEntry("economy.feeder_payment_share"));
1685  accounting->Add(new SettingEntry("economy.infrastructure_maintenance"));
1686  accounting->Add(new SettingEntry("difficulty.vehicle_costs"));
1687  accounting->Add(new SettingEntry("difficulty.construction_cost"));
1688  }
1689 
1690  SettingsPage *vehicles = main->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES));
1691  {
1692  SettingsPage *physics = vehicles->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES_PHYSICS));
1693  {
1694  physics->Add(new SettingEntry("vehicle.train_acceleration_model"));
1695  physics->Add(new SettingEntry("vehicle.train_slope_steepness"));
1696  physics->Add(new SettingEntry("vehicle.wagon_speed_limits"));
1697  physics->Add(new SettingEntry("vehicle.freight_trains"));
1698  physics->Add(new SettingEntry("vehicle.roadveh_acceleration_model"));
1699  physics->Add(new SettingEntry("vehicle.roadveh_slope_steepness"));
1700  physics->Add(new SettingEntry("vehicle.smoke_amount"));
1701  physics->Add(new SettingEntry("vehicle.plane_speed"));
1702  }
1703 
1704  SettingsPage *routing = vehicles->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES_ROUTING));
1705  {
1706  routing->Add(new SettingEntry("pf.pathfinder_for_trains"));
1707  routing->Add(new SettingEntry("difficulty.line_reverse_mode"));
1708  routing->Add(new SettingEntry("pf.reverse_at_signals"));
1709  routing->Add(new SettingEntry("pf.forbid_90_deg"));
1710  routing->Add(new SettingEntry("pf.pathfinder_for_roadvehs"));
1711  routing->Add(new SettingEntry("pf.pathfinder_for_ships"));
1712  }
1713 
1714  vehicles->Add(new SettingEntry("order.no_servicing_if_no_breakdowns"));
1715  vehicles->Add(new SettingEntry("order.serviceathelipad"));
1716  }
1717 
1718  SettingsPage *limitations = main->Add(new SettingsPage(STR_CONFIG_SETTING_LIMITATIONS));
1719  {
1720  limitations->Add(new SettingEntry("construction.command_pause_level"));
1721  limitations->Add(new SettingEntry("construction.autoslope"));
1722  limitations->Add(new SettingEntry("construction.extra_dynamite"));
1723  limitations->Add(new SettingEntry("construction.map_height_limit"));
1724  limitations->Add(new SettingEntry("construction.max_bridge_length"));
1725  limitations->Add(new SettingEntry("construction.max_bridge_height"));
1726  limitations->Add(new SettingEntry("construction.max_tunnel_length"));
1727  limitations->Add(new SettingEntry("station.never_expire_airports"));
1728  limitations->Add(new SettingEntry("vehicle.never_expire_vehicles"));
1729  limitations->Add(new SettingEntry("vehicle.max_trains"));
1730  limitations->Add(new SettingEntry("vehicle.max_roadveh"));
1731  limitations->Add(new SettingEntry("vehicle.max_aircraft"));
1732  limitations->Add(new SettingEntry("vehicle.max_ships"));
1733  limitations->Add(new SettingEntry("vehicle.max_train_length"));
1734  limitations->Add(new SettingEntry("station.station_spread"));
1735  limitations->Add(new SettingEntry("station.distant_join_stations"));
1736  limitations->Add(new SettingEntry("construction.road_stop_on_town_road"));
1737  limitations->Add(new SettingEntry("construction.road_stop_on_competitor_road"));
1738  limitations->Add(new SettingEntry("vehicle.disable_elrails"));
1739  }
1740 
1741  SettingsPage *disasters = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCIDENTS));
1742  {
1743  disasters->Add(new SettingEntry("difficulty.disasters"));
1744  disasters->Add(new SettingEntry("difficulty.economy"));
1745  disasters->Add(new SettingEntry("difficulty.vehicle_breakdowns"));
1746  disasters->Add(new SettingEntry("vehicle.plane_crashes"));
1747  }
1748 
1749  SettingsPage *genworld = main->Add(new SettingsPage(STR_CONFIG_SETTING_GENWORLD));
1750  {
1751  genworld->Add(new SettingEntry("game_creation.landscape"));
1752  genworld->Add(new SettingEntry("game_creation.land_generator"));
1753  genworld->Add(new SettingEntry("difficulty.terrain_type"));
1754  genworld->Add(new SettingEntry("game_creation.tgen_smoothness"));
1755  genworld->Add(new SettingEntry("game_creation.variety"));
1756  genworld->Add(new SettingEntry("game_creation.snow_coverage"));
1757  genworld->Add(new SettingEntry("game_creation.snow_line_height"));
1758  genworld->Add(new SettingEntry("game_creation.desert_coverage"));
1759  genworld->Add(new SettingEntry("game_creation.amount_of_rivers"));
1760  genworld->Add(new SettingEntry("game_creation.tree_placer"));
1761  genworld->Add(new SettingEntry("vehicle.road_side"));
1762  genworld->Add(new SettingEntry("economy.larger_towns"));
1763  genworld->Add(new SettingEntry("economy.initial_city_size"));
1764  genworld->Add(new SettingEntry("economy.town_layout"));
1765  genworld->Add(new SettingEntry("difficulty.industry_density"));
1766  genworld->Add(new SettingEntry("gui.pause_on_newgame"));
1767  genworld->Add(new SettingEntry("game_creation.ending_year"));
1768  }
1769 
1770  SettingsPage *environment = main->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT));
1771  {
1772  SettingsPage *authorities = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_AUTHORITIES));
1773  {
1774  authorities->Add(new SettingEntry("difficulty.town_council_tolerance"));
1775  authorities->Add(new SettingEntry("economy.bribe"));
1776  authorities->Add(new SettingEntry("economy.exclusive_rights"));
1777  authorities->Add(new SettingEntry("economy.fund_roads"));
1778  authorities->Add(new SettingEntry("economy.fund_buildings"));
1779  authorities->Add(new SettingEntry("economy.station_noise_level"));
1780  }
1781 
1782  SettingsPage *towns = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_TOWNS));
1783  {
1784  towns->Add(new SettingEntry("economy.town_growth_rate"));
1785  towns->Add(new SettingEntry("economy.allow_town_roads"));
1786  towns->Add(new SettingEntry("economy.allow_town_level_crossings"));
1787  towns->Add(new SettingEntry("economy.found_town"));
1788  towns->Add(new SettingEntry("economy.town_cargogen_mode"));
1789  }
1790 
1791  SettingsPage *industries = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_INDUSTRIES));
1792  {
1793  industries->Add(new SettingEntry("construction.raw_industry_construction"));
1794  industries->Add(new SettingEntry("construction.industry_platform"));
1795  industries->Add(new SettingEntry("economy.multiple_industry_per_town"));
1796  industries->Add(new SettingEntry("game_creation.oil_refinery_limit"));
1797  industries->Add(new SettingEntry("economy.type"));
1798  industries->Add(new SettingEntry("station.serve_neutral_industries"));
1799  }
1800 
1801  SettingsPage *cdist = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST));
1802  {
1803  cdist->Add(new SettingEntry("linkgraph.recalc_time"));
1804  cdist->Add(new SettingEntry("linkgraph.recalc_interval"));
1805  cdist->Add(new SettingEntry("linkgraph.distribution_pax"));
1806  cdist->Add(new SettingEntry("linkgraph.distribution_mail"));
1807  cdist->Add(new SettingEntry("linkgraph.distribution_armoured"));
1808  cdist->Add(new SettingEntry("linkgraph.distribution_default"));
1809  cdist->Add(new SettingEntry("linkgraph.accuracy"));
1810  cdist->Add(new SettingEntry("linkgraph.demand_distance"));
1811  cdist->Add(new SettingEntry("linkgraph.demand_size"));
1812  cdist->Add(new SettingEntry("linkgraph.short_path_saturation"));
1813  }
1814 
1815  environment->Add(new SettingEntry("station.modified_catchment"));
1816  environment->Add(new SettingEntry("construction.extra_tree_placement"));
1817  }
1818 
1819  SettingsPage *ai = main->Add(new SettingsPage(STR_CONFIG_SETTING_AI));
1820  {
1821  SettingsPage *npc = ai->Add(new SettingsPage(STR_CONFIG_SETTING_AI_NPC));
1822  {
1823  npc->Add(new SettingEntry("script.settings_profile"));
1824  npc->Add(new SettingEntry("script.script_max_opcode_till_suspend"));
1825  npc->Add(new SettingEntry("script.script_max_memory_megabytes"));
1826  npc->Add(new SettingEntry("difficulty.competitor_speed"));
1827  npc->Add(new SettingEntry("ai.ai_in_multiplayer"));
1828  npc->Add(new SettingEntry("ai.ai_disable_veh_train"));
1829  npc->Add(new SettingEntry("ai.ai_disable_veh_roadveh"));
1830  npc->Add(new SettingEntry("ai.ai_disable_veh_aircraft"));
1831  npc->Add(new SettingEntry("ai.ai_disable_veh_ship"));
1832  }
1833 
1834  ai->Add(new SettingEntry("economy.give_money"));
1835  ai->Add(new SettingEntry("economy.allow_shares"));
1836  ai->Add(new SettingEntry("economy.min_years_for_shares"));
1837  }
1838 
1839  main->Init();
1840  }
1841  return *main;
1842 }
1843 
1844 static const StringID _game_settings_restrict_dropdown[] = {
1845  STR_CONFIG_SETTING_RESTRICT_BASIC, // RM_BASIC
1846  STR_CONFIG_SETTING_RESTRICT_ADVANCED, // RM_ADVANCED
1847  STR_CONFIG_SETTING_RESTRICT_ALL, // RM_ALL
1848  STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_DEFAULT, // RM_CHANGED_AGAINST_DEFAULT
1849  STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_NEW, // RM_CHANGED_AGAINST_NEW
1850 };
1851 static_assert(lengthof(_game_settings_restrict_dropdown) == RM_END);
1852 
1859 };
1860 
1863  static const int SETTINGTREE_LEFT_OFFSET = 5;
1864  static const int SETTINGTREE_RIGHT_OFFSET = 5;
1865  static const int SETTINGTREE_TOP_OFFSET = 5;
1866  static const int SETTINGTREE_BOTTOM_OFFSET = 5;
1867 
1869 
1875 
1881 
1882  Scrollbar *vscroll;
1883 
1885  {
1886  this->warn_missing = WHR_NONE;
1887  this->warn_lines = 0;
1889  this->filter.min_cat = RM_ALL;
1890  this->filter.type = ST_ALL;
1891  this->filter.type_hides = false;
1892  this->settings_ptr = &GetGameSettings();
1893 
1894  _circle_size = maxdim(GetSpriteSize(SPR_CIRCLE_FOLDED), GetSpriteSize(SPR_CIRCLE_UNFOLDED));
1895  GetSettingsTree().FoldAll(); // Close all sub-pages
1896 
1897  this->valuewindow_entry = nullptr; // No setting entry for which a entry window is opened
1898  this->clicked_entry = nullptr; // No numeric setting buttons are depressed
1899  this->last_clicked = nullptr;
1900  this->valuedropdown_entry = nullptr;
1901  this->closing_dropdown = false;
1902  this->manually_changed_folding = false;
1903 
1904  this->CreateNestedTree();
1905  this->vscroll = this->GetScrollbar(WID_GS_SCROLLBAR);
1907 
1908  this->querystrings[WID_GS_FILTER] = &this->filter_editbox;
1909  this->filter_editbox.cancel_button = QueryString::ACTION_CLEAR;
1911 
1912  this->InvalidateData();
1913  }
1914 
1915  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1916  {
1917  switch (widget) {
1918  case WID_GS_OPTIONSPANEL:
1919  resize->height = SETTING_HEIGHT = std::max({(int)_circle_size.height, SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL}) + 1;
1920  resize->width = 1;
1921 
1922  size->height = 5 * resize->height + SETTINGTREE_TOP_OFFSET + SETTINGTREE_BOTTOM_OFFSET;
1923  break;
1924 
1925  case WID_GS_HELP_TEXT: {
1926  static const StringID setting_types[] = {
1927  STR_CONFIG_SETTING_TYPE_CLIENT,
1928  STR_CONFIG_SETTING_TYPE_COMPANY_MENU, STR_CONFIG_SETTING_TYPE_COMPANY_INGAME,
1929  STR_CONFIG_SETTING_TYPE_GAME_MENU, STR_CONFIG_SETTING_TYPE_GAME_INGAME,
1930  };
1931  for (uint i = 0; i < lengthof(setting_types); i++) {
1932  SetDParam(0, setting_types[i]);
1933  size->width = std::max(size->width, GetStringBoundingBox(STR_CONFIG_SETTING_TYPE).width);
1934  }
1935  size->height = 2 * FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL +
1936  std::max(size->height, GetSettingsTree().GetMaxHelpHeight(size->width));
1937  break;
1938  }
1939 
1941  case WID_GS_RESTRICT_TYPE:
1942  size->width = std::max(GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_CATEGORY).width, GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_TYPE).width);
1943  break;
1944 
1945  default:
1946  break;
1947  }
1948  }
1949 
1950  void OnPaint() override
1951  {
1952  if (this->closing_dropdown) {
1953  this->closing_dropdown = false;
1954  assert(this->valuedropdown_entry != nullptr);
1955  this->valuedropdown_entry->SetButtons(0);
1956  this->valuedropdown_entry = nullptr;
1957  }
1958 
1959  /* Reserve the correct number of lines for the 'some search results are hidden' notice in the central settings display panel. */
1960  const NWidgetBase *panel = this->GetWidget<NWidgetBase>(WID_GS_OPTIONSPANEL);
1961  StringID warn_str = STR_CONFIG_SETTING_CATEGORY_HIDES - 1 + this->warn_missing;
1962  int new_warn_lines;
1963  if (this->warn_missing == WHR_NONE) {
1964  new_warn_lines = 0;
1965  } else {
1966  SetDParam(0, _game_settings_restrict_dropdown[this->filter.min_cat]);
1967  new_warn_lines = GetStringLineCount(warn_str, panel->current_x);
1968  }
1969  if (this->warn_lines != new_warn_lines) {
1970  this->vscroll->SetCount(this->vscroll->GetCount() - this->warn_lines + new_warn_lines);
1971  this->warn_lines = new_warn_lines;
1972  }
1973 
1974  this->DrawWidgets();
1975 
1976  /* Draw the 'some search results are hidden' notice. */
1977  if (this->warn_missing != WHR_NONE) {
1978  const int left = panel->pos_x;
1979  const int right = left + panel->current_x - 1;
1980  const int top = panel->pos_y + WD_FRAMETEXT_TOP + (SETTING_HEIGHT - FONT_HEIGHT_NORMAL) * this->warn_lines / 2;
1981  SetDParam(0, _game_settings_restrict_dropdown[this->filter.min_cat]);
1982  if (this->warn_lines == 1) {
1983  /* If the warning fits at one line, center it. */
1984  DrawString(left + WD_FRAMETEXT_LEFT, right - WD_FRAMETEXT_RIGHT, top, warn_str, TC_FROMSTRING, SA_HOR_CENTER);
1985  } else {
1986  DrawStringMultiLine(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, INT32_MAX, warn_str, TC_FROMSTRING, SA_HOR_CENTER);
1987  }
1988  }
1989  }
1990 
1991  void SetStringParameters(int widget) const override
1992  {
1993  switch (widget) {
1995  SetDParam(0, _game_settings_restrict_dropdown[this->filter.mode]);
1996  break;
1997 
1998  case WID_GS_TYPE_DROPDOWN:
1999  switch (this->filter.type) {
2000  case ST_GAME: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME); break;
2001  case ST_COMPANY: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME); break;
2002  case ST_CLIENT: SetDParam(0, STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT); break;
2003  default: SetDParam(0, STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL); break;
2004  }
2005  break;
2006  }
2007  }
2008 
2009  DropDownList BuildDropDownList(int widget) const
2010  {
2011  DropDownList list;
2012  switch (widget) {
2014  for (int mode = 0; mode != RM_END; mode++) {
2015  /* If we are in adv. settings screen for the new game's settings,
2016  * we don't want to allow comparing with new game's settings. */
2017  bool disabled = mode == RM_CHANGED_AGAINST_NEW && settings_ptr == &_settings_newgame;
2018 
2019  list.emplace_back(new DropDownListStringItem(_game_settings_restrict_dropdown[mode], mode, disabled));
2020  }
2021  break;
2022 
2023  case WID_GS_TYPE_DROPDOWN:
2024  list.emplace_back(new DropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL, ST_ALL, false));
2025  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));
2026  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));
2027  list.emplace_back(new DropDownListStringItem(STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT, ST_CLIENT, false));
2028  break;
2029  }
2030  return list;
2031  }
2032 
2033  void DrawWidget(const Rect &r, int widget) const override
2034  {
2035  switch (widget) {
2036  case WID_GS_OPTIONSPANEL: {
2037  int top_pos = r.top + SETTINGTREE_TOP_OFFSET + 1 + this->warn_lines * SETTING_HEIGHT;
2038  uint last_row = this->vscroll->GetPosition() + this->vscroll->GetCapacity() - this->warn_lines;
2039  int next_row = GetSettingsTree().Draw(settings_ptr, r.left + SETTINGTREE_LEFT_OFFSET, r.right - SETTINGTREE_RIGHT_OFFSET, top_pos,
2040  this->vscroll->GetPosition(), last_row, this->last_clicked);
2041  if (next_row == 0) DrawString(r.left + SETTINGTREE_LEFT_OFFSET, r.right - SETTINGTREE_RIGHT_OFFSET, top_pos, STR_CONFIG_SETTINGS_NONE);
2042  break;
2043  }
2044 
2045  case WID_GS_HELP_TEXT:
2046  if (this->last_clicked != nullptr) {
2047  const SettingDesc *sd = this->last_clicked->setting;
2048 
2049  int y = r.top;
2050  switch (sd->GetType()) {
2051  case ST_COMPANY: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_COMPANY_INGAME); break;
2052  case ST_CLIENT: SetDParam(0, STR_CONFIG_SETTING_TYPE_CLIENT); break;
2053  case ST_GAME: SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_GAME_MENU : STR_CONFIG_SETTING_TYPE_GAME_INGAME); break;
2054  default: NOT_REACHED();
2055  }
2056  DrawString(r.left, r.right, y, STR_CONFIG_SETTING_TYPE);
2057  y += FONT_HEIGHT_NORMAL;
2058 
2059  int32 default_value = ReadValue(&sd->desc.def, sd->save.conv);
2060  this->last_clicked->SetValueDParams(0, default_value);
2061  DrawString(r.left, r.right, y, STR_CONFIG_SETTING_DEFAULT_VALUE);
2063 
2064  DrawStringMultiLine(r.left, r.right, y, r.bottom, this->last_clicked->GetHelpText(), TC_WHITE);
2065  }
2066  break;
2067 
2068  default:
2069  break;
2070  }
2071  }
2072 
2078  {
2079  if (this->last_clicked != pe) this->SetDirty();
2080  this->last_clicked = pe;
2081  }
2082 
2083  void OnClick(Point pt, int widget, int click_count) override
2084  {
2085  switch (widget) {
2086  case WID_GS_EXPAND_ALL:
2087  this->manually_changed_folding = true;
2089  this->InvalidateData();
2090  break;
2091 
2092  case WID_GS_COLLAPSE_ALL:
2093  this->manually_changed_folding = true;
2095  this->InvalidateData();
2096  break;
2097 
2098  case WID_GS_RESTRICT_DROPDOWN: {
2099  DropDownList list = this->BuildDropDownList(widget);
2100  if (!list.empty()) {
2101  ShowDropDownList(this, std::move(list), this->filter.mode, widget);
2102  }
2103  break;
2104  }
2105 
2106  case WID_GS_TYPE_DROPDOWN: {
2107  DropDownList list = this->BuildDropDownList(widget);
2108  if (!list.empty()) {
2109  ShowDropDownList(this, std::move(list), this->filter.type, widget);
2110  }
2111  break;
2112  }
2113  }
2114 
2115  if (widget != WID_GS_OPTIONSPANEL) return;
2116 
2117  uint btn = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_GS_OPTIONSPANEL, SETTINGTREE_TOP_OFFSET);
2118  if (btn == INT_MAX || (int)btn < this->warn_lines) return;
2119  btn -= this->warn_lines;
2120 
2121  uint cur_row = 0;
2123 
2124  if (clicked_entry == nullptr) return; // Clicked below the last setting of the page
2125 
2126  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
2127  if (x < 0) return; // Clicked left of the entry
2128 
2129  SettingsPage *clicked_page = dynamic_cast<SettingsPage*>(clicked_entry);
2130  if (clicked_page != nullptr) {
2131  this->SetDisplayedHelpText(nullptr);
2132  clicked_page->folded = !clicked_page->folded; // Flip 'folded'-ness of the sub-page
2133 
2134  this->manually_changed_folding = true;
2135 
2136  this->InvalidateData();
2137  return;
2138  }
2139 
2140  SettingEntry *pe = dynamic_cast<SettingEntry*>(clicked_entry);
2141  assert(pe != nullptr);
2142  const SettingDesc *sd = pe->setting;
2143 
2144  /* return if action is only active in network, or only settable by server */
2145  if (!sd->IsEditable()) {
2146  this->SetDisplayedHelpText(pe);
2147  return;
2148  }
2149 
2150  const void *var = ResolveVariableAddress(settings_ptr, sd);
2151  int32 value = (int32)ReadValue(var, sd->save.conv);
2152 
2153  /* clicked on the icon on the left side. Either scroller, bool on/off or dropdown */
2154  if (x < SETTING_BUTTON_WIDTH && (sd->desc.flags & SGF_MULTISTRING)) {
2155  const SettingDescBase *sdb = &sd->desc;
2156  this->SetDisplayedHelpText(pe);
2157 
2158  if (this->valuedropdown_entry == pe) {
2159  /* unclick the dropdown */
2160  HideDropDownMenu(this);
2161  this->closing_dropdown = false;
2162  this->valuedropdown_entry->SetButtons(0);
2163  this->valuedropdown_entry = nullptr;
2164  } else {
2165  if (this->valuedropdown_entry != nullptr) this->valuedropdown_entry->SetButtons(0);
2166  this->closing_dropdown = false;
2167 
2168  const NWidgetBase *wid = this->GetWidget<NWidgetBase>(WID_GS_OPTIONSPANEL);
2169  int rel_y = (pt.y - (int)wid->pos_y - SETTINGTREE_TOP_OFFSET) % wid->resize_y;
2170 
2171  Rect wi_rect;
2172  wi_rect.left = pt.x - (_current_text_dir == TD_RTL ? SETTING_BUTTON_WIDTH - 1 - x : x);
2173  wi_rect.right = wi_rect.left + SETTING_BUTTON_WIDTH - 1;
2174  wi_rect.top = pt.y - rel_y + (SETTING_HEIGHT - SETTING_BUTTON_HEIGHT) / 2;
2175  wi_rect.bottom = wi_rect.top + SETTING_BUTTON_HEIGHT - 1;
2176 
2177  /* For dropdowns we also have to check the y position thoroughly, the mouse may not above the just opening dropdown */
2178  if (pt.y >= wi_rect.top && pt.y <= wi_rect.bottom) {
2179  this->valuedropdown_entry = pe;
2180  this->valuedropdown_entry->SetButtons(SEF_LEFT_DEPRESSED);
2181 
2182  DropDownList list;
2183  for (int i = sdb->min; i <= (int)sdb->max; i++) {
2184  list.emplace_back(new DropDownListStringItem(sdb->str_val + i - sdb->min, i, false));
2185  }
2186 
2187  ShowDropDownListAt(this, std::move(list), value, -1, wi_rect, COLOUR_ORANGE, true);
2188  }
2189  }
2190  this->SetDirty();
2191  } else if (x < SETTING_BUTTON_WIDTH) {
2192  this->SetDisplayedHelpText(pe);
2193  const SettingDescBase *sdb = &sd->desc;
2194  int32 oldvalue = value;
2195 
2196  switch (sdb->cmd) {
2197  case SDT_BOOLX: value ^= 1; break;
2198  case SDT_ONEOFMANY:
2199  case SDT_NUMX: {
2200  /* Add a dynamic step-size to the scroller. In a maximum of
2201  * 50-steps you should be able to get from min to max,
2202  * unless specified otherwise in the 'interval' variable
2203  * of the current setting. */
2204  uint32 step = (sdb->interval == 0) ? ((sdb->max - sdb->min) / 50) : sdb->interval;
2205  if (step == 0) step = 1;
2206 
2207  /* don't allow too fast scrolling */
2208  if ((this->flags & WF_TIMEOUT) && this->timeout_timer > 1) {
2209  _left_button_clicked = false;
2210  return;
2211  }
2212 
2213  /* Increase or decrease the value and clamp it to extremes */
2214  if (x >= SETTING_BUTTON_WIDTH / 2) {
2215  value += step;
2216  if (sdb->min < 0) {
2217  assert((int32)sdb->max >= 0);
2218  if (value > (int32)sdb->max) value = (int32)sdb->max;
2219  } else {
2220  if ((uint32)value > sdb->max) value = (int32)sdb->max;
2221  }
2222  if (value < sdb->min) value = sdb->min; // skip between "disabled" and minimum
2223  } else {
2224  value -= step;
2225  if (value < sdb->min) value = (sdb->flags & SGF_0ISDISABLED) ? 0 : sdb->min;
2226  }
2227 
2228  /* Set up scroller timeout for numeric values */
2229  if (value != oldvalue) {
2230  if (this->clicked_entry != nullptr) { // Release previous buttons if any
2231  this->clicked_entry->SetButtons(0);
2232  }
2233  this->clicked_entry = pe;
2234  this->clicked_entry->SetButtons((x >= SETTING_BUTTON_WIDTH / 2) != (_current_text_dir == TD_RTL) ? SEF_RIGHT_DEPRESSED : SEF_LEFT_DEPRESSED);
2235  this->SetTimeout();
2236  _left_button_clicked = false;
2237  }
2238  break;
2239  }
2240 
2241  default: NOT_REACHED();
2242  }
2243 
2244  if (value != oldvalue) {
2245  if ((sd->desc.flags & SGF_PER_COMPANY) != 0) {
2246  SetCompanySetting(pe->index, value);
2247  } else {
2248  SetSettingValue(pe->index, value);
2249  }
2250  this->SetDirty();
2251  }
2252  } else {
2253  /* Only open editbox if clicked for the second time, and only for types where it is sensible for. */
2254  if (this->last_clicked == pe && sd->desc.cmd != SDT_BOOLX && !(sd->desc.flags & SGF_MULTISTRING)) {
2255  int64 value64 = value;
2256  /* Show the correct currency-translated value */
2257  if (sd->desc.flags & SGF_CURRENCY) value64 *= _currency->rate;
2258 
2259  this->valuewindow_entry = pe;
2260  SetDParam(0, value64);
2261  /* Limit string length to 14 so that MAX_INT32 * max currency rate doesn't exceed MAX_INT64. */
2262  ShowQueryString(STR_JUST_INT, STR_CONFIG_SETTING_QUERY_CAPTION, 15, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
2263  }
2264  this->SetDisplayedHelpText(pe);
2265  }
2266  }
2267 
2268  void OnTimeout() override
2269  {
2270  if (this->clicked_entry != nullptr) { // On timeout, release any depressed buttons
2271  this->clicked_entry->SetButtons(0);
2272  this->clicked_entry = nullptr;
2273  this->SetDirty();
2274  }
2275  }
2276 
2277  void OnQueryTextFinished(char *str) override
2278  {
2279  /* The user pressed cancel */
2280  if (str == nullptr) return;
2281 
2282  assert(this->valuewindow_entry != nullptr);
2283  const SettingDesc *sd = this->valuewindow_entry->setting;
2284 
2285  int32 value;
2286  if (!StrEmpty(str)) {
2287  long long llvalue = atoll(str);
2288 
2289  /* Save the correct currency-translated value */
2290  if (sd->desc.flags & SGF_CURRENCY) llvalue /= _currency->rate;
2291 
2292  value = (int32)ClampToI32(llvalue);
2293  } else {
2294  value = (int32)(size_t)sd->desc.def;
2295  }
2296 
2297  if ((sd->desc.flags & SGF_PER_COMPANY) != 0) {
2298  SetCompanySetting(this->valuewindow_entry->index, value);
2299  } else {
2300  SetSettingValue(this->valuewindow_entry->index, value);
2301  }
2302  this->SetDirty();
2303  }
2304 
2305  void OnDropdownSelect(int widget, int index) override
2306  {
2307  switch (widget) {
2309  this->filter.mode = (RestrictionMode)index;
2310  if (this->filter.mode == RM_CHANGED_AGAINST_DEFAULT ||
2311  this->filter.mode == RM_CHANGED_AGAINST_NEW) {
2312 
2313  if (!this->manually_changed_folding) {
2314  /* Expand all when selecting 'changes'. Update the filter state first, in case it becomes less restrictive in some cases. */
2315  GetSettingsTree().UpdateFilterState(this->filter, false);
2317  }
2318  } else {
2319  /* Non-'changes' filter. Save as default. */
2321  }
2322  this->InvalidateData();
2323  break;
2324 
2325  case WID_GS_TYPE_DROPDOWN:
2326  this->filter.type = (SettingType)index;
2327  this->InvalidateData();
2328  break;
2329 
2330  default:
2331  if (widget < 0) {
2332  /* Deal with drop down boxes on the panel. */
2333  assert(this->valuedropdown_entry != nullptr);
2334  const SettingDesc *sd = this->valuedropdown_entry->setting;
2335  assert(sd->desc.flags & SGF_MULTISTRING);
2336 
2337  if ((sd->desc.flags & SGF_PER_COMPANY) != 0) {
2338  SetCompanySetting(this->valuedropdown_entry->index, index);
2339  } else {
2340  SetSettingValue(this->valuedropdown_entry->index, index);
2341  }
2342 
2343  this->SetDirty();
2344  }
2345  break;
2346  }
2347  }
2348 
2349  void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override
2350  {
2351  if (widget >= 0) {
2352  /* Normally the default implementation of OnDropdownClose() takes care of
2353  * a few things. We want that behaviour here too, but only for
2354  * "normal" dropdown boxes. The special dropdown boxes added for every
2355  * setting that needs one can't have this call. */
2356  Window::OnDropdownClose(pt, widget, index, instant_close);
2357  } else {
2358  /* We cannot raise the dropdown button just yet. OnClick needs some hint, whether
2359  * the same dropdown button was clicked again, and then not open the dropdown again.
2360  * So, we only remember that it was closed, and process it on the next OnPaint, which is
2361  * after OnClick. */
2362  assert(this->valuedropdown_entry != nullptr);
2363  this->closing_dropdown = true;
2364  this->SetDirty();
2365  }
2366  }
2367 
2368  void OnInvalidateData(int data = 0, bool gui_scope = true) override
2369  {
2370  if (!gui_scope) return;
2371 
2372  /* Update which settings are to be visible. */
2373  RestrictionMode min_level = (this->filter.mode <= RM_ALL) ? this->filter.mode : RM_BASIC;
2374  this->filter.min_cat = min_level;
2375  this->filter.type_hides = false;
2376  GetSettingsTree().UpdateFilterState(this->filter, false);
2377 
2378  if (this->filter.string.IsEmpty()) {
2379  this->warn_missing = WHR_NONE;
2380  } else if (min_level < this->filter.min_cat) {
2381  this->warn_missing = this->filter.type_hides ? WHR_CATEGORY_TYPE : WHR_CATEGORY;
2382  } else {
2383  this->warn_missing = this->filter.type_hides ? WHR_TYPE : WHR_NONE;
2384  }
2385  this->vscroll->SetCount(GetSettingsTree().Length() + this->warn_lines);
2386 
2387  if (this->last_clicked != nullptr && !GetSettingsTree().IsVisible(this->last_clicked)) {
2388  this->SetDisplayedHelpText(nullptr);
2389  }
2390 
2391  bool all_folded = true;
2392  bool all_unfolded = true;
2393  GetSettingsTree().GetFoldingState(all_folded, all_unfolded);
2394  this->SetWidgetDisabledState(WID_GS_EXPAND_ALL, all_unfolded);
2395  this->SetWidgetDisabledState(WID_GS_COLLAPSE_ALL, all_folded);
2396  }
2397 
2398  void OnEditboxChanged(int wid) override
2399  {
2400  if (wid == WID_GS_FILTER) {
2401  this->filter.string.SetFilterTerm(this->filter_editbox.text.buf);
2402  if (!this->filter.string.IsEmpty() && !this->manually_changed_folding) {
2403  /* User never expanded/collapsed single pages and entered a filter term.
2404  * Expand everything, to save weird expand clicks, */
2406  }
2407  this->InvalidateData();
2408  }
2409  }
2410 
2411  void OnResize() override
2412  {
2414  }
2415 };
2416 
2418 
2419 static const NWidgetPart _nested_settings_selection_widgets[] = {
2421  NWidget(WWT_CLOSEBOX, COLOUR_MAUVE),
2422  NWidget(WWT_CAPTION, COLOUR_MAUVE), SetDataTip(STR_CONFIG_SETTING_TREE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
2423  NWidget(WWT_DEFSIZEBOX, COLOUR_MAUVE),
2424  EndContainer(),
2425  NWidget(WWT_PANEL, COLOUR_MAUVE),
2428  NWidget(WWT_TEXT, COLOUR_MAUVE, WID_GS_RESTRICT_CATEGORY), SetDataTip(STR_CONFIG_SETTING_RESTRICT_CATEGORY, STR_NULL),
2429  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),
2430  EndContainer(),
2432  NWidget(WWT_TEXT, COLOUR_MAUVE, WID_GS_RESTRICT_TYPE), SetDataTip(STR_CONFIG_SETTING_RESTRICT_TYPE, STR_NULL),
2433  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),
2434  EndContainer(),
2435  EndContainer(),
2438  NWidget(WWT_TEXT, COLOUR_MAUVE), SetFill(0, 1), SetDataTip(STR_CONFIG_SETTING_FILTER_TITLE, STR_NULL),
2439  NWidget(WWT_EDITBOX, COLOUR_MAUVE, WID_GS_FILTER), SetFill(1, 0), SetMinimalSize(50, 12), SetResize(1, 0),
2440  SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
2441  EndContainer(),
2442  EndContainer(),
2445  NWidget(NWID_VSCROLLBAR, COLOUR_MAUVE, WID_GS_SCROLLBAR),
2446  EndContainer(),
2447  NWidget(WWT_PANEL, COLOUR_MAUVE), SetMinimalSize(400, 40),
2448  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GS_HELP_TEXT), SetMinimalSize(300, 25), SetFill(1, 1), SetResize(1, 0),
2450  EndContainer(),
2452  NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, WID_GS_EXPAND_ALL), SetDataTip(STR_CONFIG_SETTING_EXPAND_ALL, STR_NULL),
2453  NWidget(WWT_PUSHTXTBTN, COLOUR_MAUVE, WID_GS_COLLAPSE_ALL), SetDataTip(STR_CONFIG_SETTING_COLLAPSE_ALL, STR_NULL),
2454  NWidget(WWT_PANEL, COLOUR_MAUVE), SetFill(1, 0), SetResize(1, 0),
2455  EndContainer(),
2456  NWidget(WWT_RESIZEBOX, COLOUR_MAUVE),
2457  EndContainer(),
2458 };
2459 
2460 static WindowDesc _settings_selection_desc(
2461  WDP_CENTER, "settings", 510, 450,
2463  0,
2464  _nested_settings_selection_widgets, lengthof(_nested_settings_selection_widgets)
2465 );
2466 
2469 {
2471  new GameSettingsWindow(&_settings_selection_desc);
2472 }
2473 
2474 
2484 void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right)
2485 {
2486  int colour = _colour_gradient[button_colour][2];
2487  Dimension dim = NWidgetScrollbar::GetHorizontalDimension();
2488 
2489  DrawFrameRect(x, y, x + dim.width - 1, y + dim.height - 1, button_colour, (state == 1) ? FR_LOWERED : FR_NONE);
2490  DrawFrameRect(x + dim.width, y, x + dim.width + dim.width - 1, y + dim.height - 1, button_colour, (state == 2) ? FR_LOWERED : FR_NONE);
2491  DrawSprite(SPR_ARROW_LEFT, PAL_NONE, x + WD_IMGBTN_LEFT, y + WD_IMGBTN_TOP);
2492  DrawSprite(SPR_ARROW_RIGHT, PAL_NONE, x + WD_IMGBTN_LEFT + dim.width, y + WD_IMGBTN_TOP);
2493 
2494  /* Grey out the buttons that aren't clickable */
2495  bool rtl = _current_text_dir == TD_RTL;
2496  if (rtl ? !clickable_right : !clickable_left) {
2497  GfxFillRect(x + 1, y, x + dim.width - 1, y + dim.height - 2, colour, FILLRECT_CHECKER);
2498  }
2499  if (rtl ? !clickable_left : !clickable_right) {
2500  GfxFillRect(x + dim.width + 1, y, x + dim.width + dim.width - 1, y + dim.height - 2, colour, FILLRECT_CHECKER);
2501  }
2502 }
2503 
2512 void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
2513 {
2514  int colour = _colour_gradient[button_colour][2];
2515 
2516  DrawFrameRect(x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1, button_colour, state ? FR_LOWERED : FR_NONE);
2517  DrawSprite(SPR_ARROW_DOWN, PAL_NONE, x + (SETTING_BUTTON_WIDTH - NWidgetScrollbar::GetVerticalDimension().width) / 2 + state, y + 2 + state);
2518 
2519  if (!clickable) {
2520  GfxFillRect(x + 1, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 2, colour, FILLRECT_CHECKER);
2521  }
2522 }
2523 
2531 void DrawBoolButton(int x, int y, bool state, bool clickable)
2532 {
2533  static const Colours _bool_ctabs[2][2] = {{COLOUR_CREAM, COLOUR_RED}, {COLOUR_DARK_GREEN, COLOUR_GREEN}};
2534  DrawFrameRect(x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1, _bool_ctabs[state][clickable], state ? FR_LOWERED : FR_NONE);
2535 }
2536 
2538  int query_widget;
2539 
2540  CustomCurrencyWindow(WindowDesc *desc) : Window(desc)
2541  {
2542  this->InitNested();
2543 
2544  SetButtonState();
2545  }
2546 
2547  void SetButtonState()
2548  {
2549  this->SetWidgetDisabledState(WID_CC_RATE_DOWN, _custom_currency.rate == 1);
2550  this->SetWidgetDisabledState(WID_CC_RATE_UP, _custom_currency.rate == UINT16_MAX);
2551  this->SetWidgetDisabledState(WID_CC_YEAR_DOWN, _custom_currency.to_euro == CF_NOEURO);
2552  this->SetWidgetDisabledState(WID_CC_YEAR_UP, _custom_currency.to_euro == MAX_YEAR);
2553  }
2554 
2555  void SetStringParameters(int widget) const override
2556  {
2557  switch (widget) {
2558  case WID_CC_RATE: SetDParam(0, 1); SetDParam(1, 1); break;
2559  case WID_CC_SEPARATOR: SetDParamStr(0, _custom_currency.separator); break;
2560  case WID_CC_PREFIX: SetDParamStr(0, _custom_currency.prefix); break;
2561  case WID_CC_SUFFIX: SetDParamStr(0, _custom_currency.suffix); break;
2562  case WID_CC_YEAR:
2563  SetDParam(0, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER);
2564  SetDParam(1, _custom_currency.to_euro);
2565  break;
2566 
2567  case WID_CC_PREVIEW:
2568  SetDParam(0, 10000);
2569  break;
2570  }
2571  }
2572 
2573  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
2574  {
2575  switch (widget) {
2576  /* Set the appropriate width for the edit 'buttons' */
2577  case WID_CC_SEPARATOR_EDIT:
2578  case WID_CC_PREFIX_EDIT:
2579  case WID_CC_SUFFIX_EDIT:
2580  size->width = this->GetWidget<NWidgetBase>(WID_CC_RATE_DOWN)->smallest_x + this->GetWidget<NWidgetBase>(WID_CC_RATE_UP)->smallest_x;
2581  break;
2582 
2583  /* Make sure the window is wide enough for the widest exchange rate */
2584  case WID_CC_RATE:
2585  SetDParam(0, 1);
2586  SetDParam(1, INT32_MAX);
2587  *size = GetStringBoundingBox(STR_CURRENCY_EXCHANGE_RATE);
2588  break;
2589  }
2590  }
2591 
2592  void OnClick(Point pt, int widget, int click_count) override
2593  {
2594  int line = 0;
2595  int len = 0;
2596  StringID str = 0;
2597  CharSetFilter afilter = CS_ALPHANUMERAL;
2598 
2599  switch (widget) {
2600  case WID_CC_RATE_DOWN:
2601  if (_custom_currency.rate > 1) _custom_currency.rate--;
2602  if (_custom_currency.rate == 1) this->DisableWidget(WID_CC_RATE_DOWN);
2604  break;
2605 
2606  case WID_CC_RATE_UP:
2607  if (_custom_currency.rate < UINT16_MAX) _custom_currency.rate++;
2608  if (_custom_currency.rate == UINT16_MAX) this->DisableWidget(WID_CC_RATE_UP);
2610  break;
2611 
2612  case WID_CC_RATE:
2613  SetDParam(0, _custom_currency.rate);
2614  str = STR_JUST_INT;
2615  len = 5;
2616  line = WID_CC_RATE;
2617  afilter = CS_NUMERAL;
2618  break;
2619 
2620  case WID_CC_SEPARATOR_EDIT:
2621  case WID_CC_SEPARATOR:
2622  SetDParamStr(0, _custom_currency.separator);
2623  str = STR_JUST_RAW_STRING;
2624  len = 1;
2625  line = WID_CC_SEPARATOR;
2626  break;
2627 
2628  case WID_CC_PREFIX_EDIT:
2629  case WID_CC_PREFIX:
2630  SetDParamStr(0, _custom_currency.prefix);
2631  str = STR_JUST_RAW_STRING;
2632  len = 12;
2633  line = WID_CC_PREFIX;
2634  break;
2635 
2636  case WID_CC_SUFFIX_EDIT:
2637  case WID_CC_SUFFIX:
2638  SetDParamStr(0, _custom_currency.suffix);
2639  str = STR_JUST_RAW_STRING;
2640  len = 12;
2641  line = WID_CC_SUFFIX;
2642  break;
2643 
2644  case WID_CC_YEAR_DOWN:
2645  _custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ? CF_NOEURO : _custom_currency.to_euro - 1;
2646  if (_custom_currency.to_euro == CF_NOEURO) this->DisableWidget(WID_CC_YEAR_DOWN);
2648  break;
2649 
2650  case WID_CC_YEAR_UP:
2651  _custom_currency.to_euro = Clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR);
2652  if (_custom_currency.to_euro == MAX_YEAR) this->DisableWidget(WID_CC_YEAR_UP);
2654  break;
2655 
2656  case WID_CC_YEAR:
2657  SetDParam(0, _custom_currency.to_euro);
2658  str = STR_JUST_INT;
2659  len = 7;
2660  line = WID_CC_YEAR;
2661  afilter = CS_NUMERAL;
2662  break;
2663  }
2664 
2665  if (len != 0) {
2666  this->query_widget = line;
2667  ShowQueryString(str, STR_CURRENCY_CHANGE_PARAMETER, len + 1, this, afilter, QSF_NONE);
2668  }
2669 
2670  this->SetTimeout();
2671  this->SetDirty();
2672  }
2673 
2674  void OnQueryTextFinished(char *str) override
2675  {
2676  if (str == nullptr) return;
2677 
2678  switch (this->query_widget) {
2679  case WID_CC_RATE:
2680  _custom_currency.rate = Clamp(atoi(str), 1, UINT16_MAX);
2681  break;
2682 
2683  case WID_CC_SEPARATOR: // Thousands separator
2684  strecpy(_custom_currency.separator, str, lastof(_custom_currency.separator));
2685  break;
2686 
2687  case WID_CC_PREFIX:
2688  strecpy(_custom_currency.prefix, str, lastof(_custom_currency.prefix));
2689  break;
2690 
2691  case WID_CC_SUFFIX:
2692  strecpy(_custom_currency.suffix, str, lastof(_custom_currency.suffix));
2693  break;
2694 
2695  case WID_CC_YEAR: { // Year to switch to euro
2696  int val = atoi(str);
2697 
2698  _custom_currency.to_euro = (val < 2000 ? CF_NOEURO : std::min(val, MAX_YEAR));
2699  break;
2700  }
2701  }
2703  SetButtonState();
2704  }
2705 
2706  void OnTimeout() override
2707  {
2708  this->SetDirty();
2709  }
2710 };
2711 
2712 static const NWidgetPart _nested_cust_currency_widgets[] = {
2714  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
2715  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_CURRENCY_WINDOW, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
2716  EndContainer(),
2717  NWidget(WWT_PANEL, COLOUR_GREY),
2719  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
2720  NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_RATE_DOWN), SetDataTip(AWV_DECREASE, STR_CURRENCY_DECREASE_EXCHANGE_RATE_TOOLTIP),
2721  NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_RATE_UP), SetDataTip(AWV_INCREASE, STR_CURRENCY_INCREASE_EXCHANGE_RATE_TOOLTIP),
2723  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_RATE), SetDataTip(STR_CURRENCY_EXCHANGE_RATE, STR_CURRENCY_SET_EXCHANGE_RATE_TOOLTIP), SetFill(1, 0),
2724  EndContainer(),
2725  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
2726  NWidget(WWT_PUSHBTN, COLOUR_DARK_BLUE, WID_CC_SEPARATOR_EDIT), SetDataTip(0x0, STR_CURRENCY_SET_CUSTOM_CURRENCY_SEPARATOR_TOOLTIP), SetFill(0, 1),
2728  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_SEPARATOR), SetDataTip(STR_CURRENCY_SEPARATOR, STR_CURRENCY_SET_CUSTOM_CURRENCY_SEPARATOR_TOOLTIP), SetFill(1, 0),
2729  EndContainer(),
2730  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
2731  NWidget(WWT_PUSHBTN, COLOUR_DARK_BLUE, WID_CC_PREFIX_EDIT), SetDataTip(0x0, STR_CURRENCY_SET_CUSTOM_CURRENCY_PREFIX_TOOLTIP), SetFill(0, 1),
2733  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_PREFIX), SetDataTip(STR_CURRENCY_PREFIX, STR_CURRENCY_SET_CUSTOM_CURRENCY_PREFIX_TOOLTIP), SetFill(1, 0),
2734  EndContainer(),
2735  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
2736  NWidget(WWT_PUSHBTN, COLOUR_DARK_BLUE, WID_CC_SUFFIX_EDIT), SetDataTip(0x0, STR_CURRENCY_SET_CUSTOM_CURRENCY_SUFFIX_TOOLTIP), SetFill(0, 1),
2738  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_SUFFIX), SetDataTip(STR_CURRENCY_SUFFIX, STR_CURRENCY_SET_CUSTOM_CURRENCY_SUFFIX_TOOLTIP), SetFill(1, 0),
2739  EndContainer(),
2740  NWidget(NWID_HORIZONTAL), SetPIP(10, 0, 5),
2741  NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_YEAR_DOWN), SetDataTip(AWV_DECREASE, STR_CURRENCY_DECREASE_CUSTOM_CURRENCY_TO_EURO_TOOLTIP),
2742  NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_YEAR_UP), SetDataTip(AWV_INCREASE, STR_CURRENCY_INCREASE_CUSTOM_CURRENCY_TO_EURO_TOOLTIP),
2744  NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_YEAR), SetDataTip(STR_JUST_STRING, STR_CURRENCY_SET_CUSTOM_CURRENCY_TO_EURO_TOOLTIP), SetFill(1, 0),
2745  EndContainer(),
2746  EndContainer(),
2747  NWidget(WWT_LABEL, COLOUR_BLUE, WID_CC_PREVIEW),
2748  SetDataTip(STR_CURRENCY_PREVIEW, STR_CURRENCY_CUSTOM_CURRENCY_PREVIEW_TOOLTIP), SetPadding(15, 1, 18, 2),
2749  EndContainer(),
2750 };
2751 
2752 static WindowDesc _cust_currency_desc(
2753  WDP_CENTER, nullptr, 0, 0,
2755  0,
2756  _nested_cust_currency_widgets, lengthof(_nested_cust_currency_widgets)
2757 );
2758 
2760 static void ShowCustCurrency()
2761 {
2763  new CustomCurrencyWindow(&_cust_currency_desc);
2764 }
WID_GO_REFRESH_RATE_DROPDOWN
@ WID_GO_REFRESH_RATE_DROPDOWN
Dropdown for all available refresh rates.
Definition: settings_widget.h:39
LoadStringWidthTable
void LoadStringWidthTable(bool monospace)
Initialize _stringwidth_table cache.
Definition: gfx.cpp:1276
SettingEntry::Length
virtual uint Length() const
Return number of rows needed to display the (filtered) entry.
Definition: settings_gui.cpp:1049
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:762
WID_GO_FULLSCREEN_BUTTON
@ WID_GO_FULLSCREEN_BUTTON
Toggle fullscreen.
Definition: settings_widget.h:21
Window::SetTimeout
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
Definition: window_gui.h:367
SettingEntry::UpdateFilterState
virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible)
Update the filter state.
Definition: settings_gui.cpp:1113
CustomCurrencyWindow::OnTimeout
void OnTimeout() override
Called when this window's timeout has been reached.
Definition: settings_gui.cpp:2706
CF_NOEURO
static const int CF_NOEURO
Currency never switches to the Euro (as far as known).
Definition: currency.h:17
ClampToI32
static int32 ClampToI32(const int64 a)
Reduce a signed 64-bit int to a signed 32-bit one.
Definition: math_func.hpp:141
factory.hpp
GUISettings::refresh_rate
uint16 refresh_rate
How often we refresh the screen (time between draw-ticks).
Definition: settings_type.h:160
ReInitAllWindows
void ReInitAllWindows()
Re-initialize all windows.
Definition: window.cpp:3456
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:317
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:18
SEF_LEFT_DEPRESSED
@ SEF_LEFT_DEPRESSED
Of a numeric setting entry, the left button is depressed.
Definition: settings_gui.cpp:761
Window::timeout_timer
uint8 timeout_timer
Timer value of the WF_TIMEOUT for flags.
Definition: window_gui.h:315
querystring_gui.h
DropDownListParamStringItem
String list item with parameters.
Definition: dropdown_type.h:56
SetScrollbar
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1104
GetCurrentLanguageIsoCode
const char * GetCurrentLanguageIsoCode()
Get the ISO language code of the currently loaded language.
Definition: strings.cpp:1984
SEF_BUTTONS_MASK
@ SEF_BUTTONS_MASK
Bit-mask for button flags.
Definition: settings_gui.cpp:763
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:631
WID_GS_OPTIONSPANEL
@ WID_GS_OPTIONSPANEL
Panel widget containing the option lists.
Definition: settings_widget.h:45
command_func.h
BaseSetTextfileWindow::baseset
const TBaseSet * baseset
View the textfile of this BaseSet.
Definition: settings_gui.cpp:112
WID_GS_COLLAPSE_ALL
@ WID_GS_COLLAPSE_ALL
Collapse all button.
Definition: settings_widget.h:49
WID_GS_HELP_TEXT
@ WID_GS_HELP_TEXT
Information area to display help text of the selected option.
Definition: settings_widget.h:47
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:1055
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:113
dropdown_func.h
WID_GO_BASE_GRF_STATUS
@ WID_GO_BASE_GRF_STATUS
Info about missing files etc.
Definition: settings_widget.h:24
GameSettingsWindow
Window to edit settings of the game.
Definition: settings_gui.cpp:1862
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:106
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:2592
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:1530
company_base.h
WID_CC_SEPARATOR_EDIT
@ WID_CC_SEPARATOR_EDIT
Separator edit button.
Definition: settings_widget.h:61
GameSettingsWindow::settings_ptr
static GameSettings * settings_ptr
Pointer to the game settings being displayed and modified.
Definition: settings_gui.cpp:1868
StringFilter::SetFilterTerm
void SetFilterTerm(const char *str)
Set the term to filter on.
Definition: stringfilter.cpp:27
WID_GO_BASE_SFX_TEXTFILE
@ WID_GO_BASE_SFX_TEXTFILE
Open base SFX readme, changelog (+1) or license (+2).
Definition: settings_widget.h:29
SettingDescBase::str_val
StringID str_val
(Translated) first string describing the value.
Definition: settings_internal.h:103
DrawVolumeSliderWidget
void DrawVolumeSliderWidget(Rect r, byte value)
Draw a volume slider widget with know at given value.
Definition: slider.cpp:25
SettingFilter::type
SettingType type
Filter based on type.
Definition: settings_gui.cpp:786
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:1972
MusicDriver::SetVolume
virtual void SetVolume(byte vol)=0
Set the volume, if possible.
ST_GAME
@ ST_GAME
Game setting.
Definition: settings_internal.h:81
WID_GO_GUI_ZOOM_DROPDOWN
@ WID_GO_GUI_ZOOM_DROPDOWN
Dropdown for the GUI zoom level.
Definition: settings_widget.h:22
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:112
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:69
SettingDesc::GetType
SettingType GetType() const
Return the type of the setting.
Definition: settings.cpp:837
SettingsPage::Init
virtual void Init(byte level=0)
Initialization of an entire setting page.
Definition: settings_gui.cpp:1384
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:1465
SettingDesc::IsEditable
bool IsEditable(bool do_command=false) const
Check whether the setting is editable in the current gamemode.
Definition: settings.cpp:821
WID_GO_BASE_GRF_DESCRIPTION
@ WID_GO_BASE_GRF_DESCRIPTION
Description of selected base GRF.
Definition: settings_widget.h:26
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
GameSettingsWindow::OnDropdownClose
void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override
A dropdown window associated to this window has been closed.
Definition: settings_gui.cpp:2349
DropDownListCharStringItem
List item containing a C char string.
Definition: dropdown_type.h:70
SettingsContainer::GetMaxHelpHeight
uint GetMaxHelpHeight(int maxw)
Get the biggest height of the help texts, if the width is at least maxw.
Definition: settings_gui.cpp:1333
SDT_BOOLX
@ SDT_BOOLX
a boolean number
Definition: settings_internal.h:25
GameSettingsWindow::filter_editbox
QueryString filter_editbox
Filter editbox;.
Definition: settings_gui.cpp:1877
ST_CLIENT
@ ST_CLIENT
Client setting.
Definition: settings_internal.h:83
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:805
WID_CC_RATE
@ WID_CC_RATE
Rate of currency.
Definition: settings_widget.h:60
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
BaseSetTextfileWindow
Window for displaying the textfile of a BaseSet.
Definition: settings_gui.cpp:111
Scrollbar::SetCount
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:679
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:782
_font_zoom_cfg
int8 _font_zoom_cfg
Font zoom level in config.
Definition: gfx.cpp:63
SettingEntry::Init
virtual void Init(byte level=0)
Initialization of a setting entry.
Definition: settings_gui.cpp:1030
GameOptionsWindow
Definition: settings_gui.cpp:159
SettingEntry::setting
const SettingDesc * setting
Setting description of the setting.
Definition: settings_gui.cpp:830
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:939
zoom_func.h
ST_COMPANY
@ ST_COMPANY
Company setting.
Definition: settings_internal.h:82
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:48
SGF_DISPLAY_ABS
@ SGF_DISPLAY_ABS
display absolute value of the setting
Definition: settings_internal.h:41
base_media_base.h
DropDownListItem
Base list item class from which others are derived.
Definition: dropdown_type.h:22
SettingsContainer::entries
EntryVector entries
Settings on this page.
Definition: settings_gui.cpp:863
_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:1915
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:640
GameSettingsWindow::last_clicked
SettingEntry * last_clicked
If non-nullptr, pointer to the last clicked setting.
Definition: settings_gui.cpp:1872
GUISettings::autosave
byte autosave
how often should we do autosaves?
Definition: settings_type.h:121
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_GO_BASE_MUSIC_VOLUME
@ WID_GO_BASE_MUSIC_VOLUME
Change music volume.
Definition: settings_widget.h:32
WID_GS_FILTER
@ WID_GS_FILTER
Text filter.
Definition: settings_widget.h:44
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:1865
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:64
SEF_FILTERED
@ SEF_FILTERED
Entry is hidden by the string filter.
Definition: settings_gui.cpp:766
WID_GO_BASE_MUSIC_DROPDOWN
@ WID_GO_BASE_MUSIC_DROPDOWN
Use to select a base music set.
Definition: settings_widget.h:31
WC_MUSIC_WINDOW
@ WC_MUSIC_WINDOW
Music window; Window numbers:
Definition: window_type.h:590
GameSettingsWindow::SETTINGTREE_LEFT_OFFSET
static const int SETTINGTREE_LEFT_OFFSET
Position of left edge of setting values.
Definition: settings_gui.cpp:1863
SaveLoad::conv
VarType conv
type of the variable to be saved, int
Definition: saveload.h:519
_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:97
SettingEntry::IsVisibleByRestrictionMode
bool IsVisibleByRestrictionMode(RestrictionMode mode) const
Checks whether an entry shall be made visible based on the restriction mode.
Definition: settings_gui.cpp:1069
SettingsPage::SettingsPage
SettingsPage(StringID title)
Constructor for a sub-page in the 'advanced settings' window.
Definition: settings_gui.cpp:1374
BaseSettingEntry::Init
virtual void Init(byte level=0)
Initialization of a setting entry.
Definition: settings_gui.cpp:918
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:598
SettingsPage
Data structure describing one page of settings in the settings window.
Definition: settings_gui.cpp:888
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:101
SettingsContainer::UpdateFilterState
bool UpdateFilterState(SettingFilter &filter, bool force_visible)
Update the filter state.
Definition: settings_gui.cpp:1273
_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:2537
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:919
textfile_gui.h
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1023
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:97
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:2268
GetStringBoundingBox
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:842
GetStringLineCount
int GetStringLineCount(StringID str, int maxw)
Calculates number of lines of string.
Definition: gfx.cpp:714
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:329
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:763
GameOptionsWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: settings_gui.cpp:294
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:1059
BuildCurrencyDropdown
StringID * BuildCurrencyDropdown()
Build a list of currency names StringIDs to use in a dropdown list.
Definition: currency.cpp:169
ai.hpp
WID_CC_SEPARATOR
@ WID_CC_SEPARATOR
Current separator.
Definition: settings_widget.h:62
UpdateCursorSize
void UpdateCursorSize()
Update cursor dimension.
Definition: gfx.cpp:1666
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:605
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:1879
BaseSettingEntry::level
byte level
Nesting level of this setting entry.
Definition: settings_gui.cpp:792
SettingType
SettingType
Type of settings for filtering.
Definition: settings_internal.h:80
DECLARE_POSTFIX_INCREMENT
#define DECLARE_POSTFIX_INCREMENT(enum_type)
Some enums need to have allowed incrementing (i.e.
Definition: enum_type.hpp:14
SettingDescBase::cmd
SettingDescType cmd
various flags for the variable
Definition: settings_internal.h:95
SettingsPage::title
StringID title
Title of the sub-page.
Definition: settings_gui.cpp:889
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:783
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:438
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:187
DrawDropDownButton
void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
Draw a dropdown button.
Definition: settings_gui.cpp:2512
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:323
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:50
SettingDescBase
Properties of config file settings.
Definition: settings_internal.h:92
GameSettingsWindow::warn_lines
int warn_lines
Number of lines used for warning about missing search results.
Definition: settings_gui.cpp:1880
VideoDriver::GetListOfMonitorRefreshRates
virtual std::vector< int > GetListOfMonitorRefreshRates()
Get a list of refresh rates of each available monitor.
Definition: video_driver.hpp:164
Scrollbar::GetCount
uint16 GetCount() const
Gets the number of elements in the list.
Definition: widget_type.h:622
SETTING_HEIGHT
static int SETTING_HEIGHT
Height of a single setting in the tree view in pixels.
Definition: settings_gui.cpp:753
Window::EnableWidget
void EnableWidget(byte widget_index)
Sets a widget to Enabled.
Definition: window_gui.h:412
MusicDriver::GetInstance
static MusicDriver * GetInstance()
Get the currently active instance of the music driver.
Definition: music_driver.hpp:46
RestrictionMode
RestrictionMode
How the list of advanced settings is filtered.
Definition: settings_gui.cpp:770
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:1870
SettingDescBase::max
uint32 max
maximum values
Definition: settings_internal.h:98
GfxClearSpriteCache
void GfxClearSpriteCache()
Remove all encoded sprites from the sprite cache without discarding sprite location information.
Definition: spritecache.cpp:976
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:1193
WHR_TYPE
@ WHR_TYPE
Type setting filtered matches away.
Definition: settings_gui.cpp:1857
Window::height
int height
Height of the window (number of pixels down in y direction)
Definition: window_gui.h:321
WID_CC_SUFFIX_EDIT
@ WID_CC_SUFFIX_EDIT
Suffix edit button.
Definition: settings_widget.h:65
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:2674
GameSettingsWindow::SETTINGTREE_BOTTOM_OFFSET
static const int SETTINGTREE_BOTTOM_OFFSET
Position of bottom edge of setting values.
Definition: settings_gui.cpp:1866
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:2305
VideoDriver::ToggleVsync
virtual void ToggleVsync(bool vsync)
Change the vsync setting.
Definition: video_driver.hpp:75
BaseSettingEntry
Data structure describing a single setting in a tab.
Definition: settings_gui.cpp:790
GameSettingsWindow::OnQueryTextFinished
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: settings_gui.cpp:2277
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:447
GameOptionsWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: settings_gui.cpp:323
RM_END
@ RM_END
End for iteration.
Definition: settings_gui.cpp:776
SettingFilter::mode
RestrictionMode mode
Filter based on category.
Definition: settings_gui.cpp:785
dropdown_type.h
SettingEntry::name
const char * name
Name of the setting.
Definition: settings_gui.cpp:829
Window::SetWidgetDisabledState
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:393
WL_INFO
@ WL_INFO
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
Definition: error.h:22
SettingsPage::FoldAll
virtual void FoldAll()
Recursively close all (filtered) folds of sub-pages.
Definition: settings_gui.cpp:1391
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:46
_current_language
const LanguageMetadata * _current_language
The currently loaded language.
Definition: strings.cpp:46
SettingDescBase::def
const void * def
default value given when none is present
Definition: settings_internal.h:94
SEF_LAST_FIELD
@ SEF_LAST_FIELD
This entry is the last one in a (sub-)page.
Definition: settings_gui.cpp:765
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:1141
RM_ALL
@ RM_ALL
List all settings regardless of the default/newgame/... values.
Definition: settings_gui.cpp:773
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:99
Window::left
int left
x position of left edge of the window
Definition: window_gui.h:318
music_driver.hpp
Window::flags
WindowFlags flags
Window flags.
Definition: window_gui.h:311
_resolutions
std::vector< Dimension > _resolutions
List of resolutions.
Definition: driver.cpp:24
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:2019
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:562
GetSettingFromName
const SettingDesc * GetSettingFromName(const char *name, uint *i)
Given a name of setting, return a setting description of it.
Definition: settings.cpp:2107
SettingsPage::folded
bool folded
Sub-page is folded (not visible except for its title)
Definition: settings_gui.cpp:890
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:978
WID_GO_BASE_GRF_DROPDOWN
@ WID_GO_BASE_GRF_DROPDOWN
Use to select a base GRF.
Definition: settings_widget.h:23
WID_CC_YEAR_UP
@ WID_CC_YEAR_UP
Up button.
Definition: settings_widget.h:68
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:1873
SettingsContainer::Init
void Init(byte level=0)
Initialization of an entire setting page.
Definition: settings_gui.cpp:1232
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
error.h
CheckBlitter
void CheckBlitter()
Check whether we still use the right blitter, or use another (better) one.
Definition: gfxinit.cpp:342
RM_BASIC
@ RM_BASIC
Display settings associated to the "basic" list.
Definition: settings_gui.cpp:771
WWT_FRAME
@ WWT_FRAME
Frame.
Definition: widget_type.h:58
language.h
AddCustomRefreshRates
static void AddCustomRefreshRates()
Add the refresh rate from the config and the refresh rates from all the monitors to our list of refre...
Definition: settings_gui.cpp:149
WID_CC_YEAR_DOWN
@ WID_CC_YEAR_DOWN
Down button.
Definition: settings_widget.h:67
WHR_CATEGORY
@ WHR_CATEGORY
Category setting filtered matches away.
Definition: settings_gui.cpp:1856
SettingsPage::FindEntry
virtual BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find setting entry at row row_num.
Definition: settings_gui.cpp:1479
BaseSetTextfileWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: settings_gui.cpp:121
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:2555
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:2484
WID_GO_LANG_DROPDOWN
@ WID_GO_LANG_DROPDOWN
Language dropdown.
Definition: settings_widget.h:19
SettingFilter::type_hides
bool type_hides
Whether the type hides filtered strings.
Definition: settings_gui.cpp:784
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:114
ShowCustCurrency
static void ShowCustCurrency()
Open custom currency window.
Definition: settings_gui.cpp:2760
WID_CC_RATE_DOWN
@ WID_CC_RATE_DOWN
Down button.
Definition: settings_widget.h:58
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:1357
WarnHiddenResult
WarnHiddenResult
Warnings about hidden search results.
Definition: settings_gui.cpp:1854
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:3261
VideoDriver::GetInstance
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
Definition: video_driver.hpp:199
CS_ALPHANUMERAL
@ CS_ALPHANUMERAL
Both numeric and alphabetic and spaces and stuff.
Definition: string_type.h:27
viewport_func.h
Window::mouse_capture_widget
int mouse_capture_widget
Widgetindex of current mouse capture widget (e.g. dragged scrollbar). -1 if no widget has mouse captu...
Definition: window_gui.h:336
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:1858
SettingEntry::index
uint index
Index of the setting in the settings table.
Definition: settings_gui.cpp:831
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:137
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:96
WID_CC_RATE_UP
@ WID_CC_RATE_UP
Up button.
Definition: settings_widget.h:59
ClickVolumeSliderWidget
bool ClickVolumeSliderWidget(Rect r, Point pt, byte &value)
Handle click on a volume slider widget to change the value.
Definition: slider.cpp:56
GetStringHeight
int GetStringHeight(const char *str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Definition: gfx.cpp:689
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:913
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:118
GameSettingsWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: settings_gui.cpp:1991
WID_GO_BACKGROUND
@ WID_GO_BACKGROUND
Background of the window.
Definition: settings_widget.h:15
_gui_zoom_cfg
int8 _gui_zoom_cfg
GUI zoom level in config.
Definition: gfx.cpp:62
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:1042
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:2411
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:46
WID_CC_PREFIX_EDIT
@ WID_CC_PREFIX_EDIT
Prefix edit button.
Definition: settings_widget.h:63
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:68
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1008
Clamp
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:77
WID_GO_RESOLUTION_DROPDOWN
@ WID_GO_RESOLUTION_DROPDOWN
Dropdown for the resolution.
Definition: settings_widget.h:20
strings_func.h
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:82
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:455
GetTextfile
const char * GetTextfile(TextfileType type, Subdirectory dir, const char *filename)
Search a textfile file next to the given content.
Definition: textfile_gui.cpp:385
NWidgetBase::pos_x
int pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:185
LocaleSettings::currency
byte currency
currency we currently use
Definition: settings_type.h:217
WID_GO_BASE_SFX_DROPDOWN
@ WID_GO_BASE_SFX_DROPDOWN
Use to select a base SFX.
Definition: settings_widget.h:27
GRFConfig::name
GRFTextWrapper name
NOSAVE: GRF name (Action 0x08)
Definition: newgrf_config.h: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
BaseSettingEntry::FindEntry
virtual BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find setting entry at row row_num.
Definition: settings_gui.cpp:942
HideDropDownMenu
int HideDropDownMenu(Window *pw)
Delete the drop-down menu from window pw.
Definition: dropdown.cpp:506
SettingsContainer::UnFoldAll
void UnFoldAll()
Recursively open all folds of sub-pages.
Definition: settings_gui.cpp:1248
SettingDesc
Definition: settings_internal.h:110
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:1292
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:1413
SettingsContainer::Length
uint Length() const
Return number of rows needed to display the whole page.
Definition: settings_gui.cpp:1301
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:51
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:179
video_driver.hpp
ScaleGUITrad
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
Definition: zoom_func.h:76
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1123
GameSettingsWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: settings_gui.cpp:2033
RM_CHANGED_AGAINST_DEFAULT
@ RM_CHANGED_AGAINST_DEFAULT
Show only settings which are different compared to default values.
Definition: settings_gui.cpp:774
SC_BASIC_LIST
@ SC_BASIC_LIST
Settings displayed in the list of basic settings.
Definition: settings_internal.h:65
WID_GO_BASE_SFX_VOLUME
@ WID_GO_BASE_SFX_VOLUME
Change sound effects volume.
Definition: settings_widget.h:28
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:956
GameSettingsWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: settings_gui.cpp:1950
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:1432
_video_hw_accel
bool _video_hw_accel
Whether to consider hardware accelerated video drivers.
Definition: video_driver.cpp:23
NWidgetBase::resize_y
uint resize_y
Vertical resize step (0 means not resizable).
Definition: widget_type.h:175
SettingsContainer::FindEntry
BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find the setting entry at row number row_num.
Definition: settings_gui.cpp:1316
Scrollbar::GetPosition
uint16 GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:640
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:2573
StringFilter::GetState
bool GetState() const
Get the matching state of the current item.
Definition: stringfilter_type.h:69
WD_IMGBTN_TOP
@ WD_IMGBTN_TOP
Top offset of image in the button.
Definition: window_gui.h: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:111
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:52
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:77
WID_GO_VIDEO_VSYNC_BUTTON
@ WID_GO_VIDEO_VSYNC_BUTTON
Toggle for video vsync.
Definition: settings_widget.h:38
GameSettingsWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: settings_gui.cpp:2368
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
GetCurrentResolutionIndex
static uint GetCurrentResolutionIndex()
Get index of the current screen resolution.
Definition: settings_gui.cpp:82
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:1503
Window::top
int top
y position of top edge of the window
Definition: window_gui.h:319
abs
static T abs(const T a)
Returns the absolute value of (scalar) variable.
Definition: math_func.hpp:21
WID_GO_BASE_GRF_TEXTFILE
@ WID_GO_BASE_GRF_TEXTFILE
Open base GRF readme, changelog (+1) or license (+2).
Definition: settings_widget.h:25
LEVEL_WIDTH
static const int LEVEL_WIDTH
Indenting width of a sub-page in pixels.
Definition: settings_gui.cpp:754
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:427
SettingEntry::SetValueDParams
void SetValueDParams(uint first_param, int32 value) const
Set the DParams for drawing the value of a setting.
Definition: settings_gui.cpp:1167
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:1455
SettingsContainer::FoldAll
void FoldAll()
Recursively close all folds of sub-pages.
Definition: settings_gui.cpp:1240
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:360
_video_vsync
bool _video_vsync
Whether we should use vsync (only if _video_hw_accel is enabled).
Definition: video_driver.cpp:24
GUISettings::settings_restriction_mode
uint8 settings_restriction_mode
selected restriction mode in adv. settings GUI.
Definition: settings_type.h:178
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:2091
GameSettingsWindow::filter
SettingFilter filter
Filter for the list.
Definition: settings_gui.cpp:1876
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:369
Window::width
int width
width of the window (number of pixels to the right in x direction)
Definition: window_gui.h:320
MusicSettings::effect_vol
byte effect_vol
The requested effects volume.
Definition: settings_type.h:208
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:1986
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition: gfx.cpp:1597
GameSettings::locale
LocaleSettings locale
settings related to used currency/unit system in the current game
Definition: settings_type.h:576
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1085
NWidgetBase::pos_y
int pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:186
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:929
SettingEntry::SettingEntry
SettingEntry(const char *name)
Constructor for a single setting in the 'advanced settings' window.
Definition: settings_gui.cpp:1019
WID_GO_VIDEO_ACCEL_BUTTON
@ WID_GO_VIDEO_ACCEL_BUTTON
Toggle for video acceleration.
Definition: settings_widget.h:37
GameSettingsWindow::SETTINGTREE_RIGHT_OFFSET
static const int SETTINGTREE_RIGHT_OFFSET
Position of right edge of setting values.
Definition: settings_gui.cpp:1864
SettingFilter
Filter for settings list.
Definition: settings_gui.cpp:781
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:775
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:992
TextfileWindow
Window for displaying a textfile.
Definition: textfile_gui.h:21
WID_CC_PREVIEW
@ WID_CC_PREVIEW
Preview.
Definition: settings_widget.h:70
GameOptionsWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: settings_gui.cpp:608
GetSettingsTree
static SettingsContainer & GetSettingsTree()
Construct settings tree.
Definition: settings_gui.cpp:1538
ST_ALL
@ ST_ALL
Used in setting filter to match all types.
Definition: settings_internal.h:85
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:583
SettingsContainer
Containers for BaseSettingEntry.
Definition: settings_gui.cpp:861
GameSettingsWindow::closing_dropdown
bool closing_dropdown
True, if the dropdown list is currently closing.
Definition: settings_gui.cpp:1874
BaseSettingEntry::flags
byte flags
Flags of the setting entry.
Definition: settings_gui.cpp:791
Window
Data structure for an opened window.
Definition: window_gui.h:277
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:1975
WID_GO_BASE_SFX_DESCRIPTION
@ WID_GO_BASE_SFX_DESCRIPTION
Description of selected base SFX.
Definition: settings_widget.h:30
SC_ADVANCED_LIST
@ SC_ADVANCED_LIST
Settings displayed in the list of advanced settings.
Definition: settings_internal.h:66
SettingEntry
Standard setting.
Definition: settings_gui.cpp:828
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:26
ShowGameSettings
void ShowGameSettings()
Open advanced settings window.
Definition: settings_gui.cpp:2468
DrawBoolButton
void DrawBoolButton(int x, int y, bool state, bool clickable)
Draw a toggle button.
Definition: settings_gui.cpp:2531
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
SettingEntry::GetHelpText
StringID GetHelpText() const
Get the help text of a single setting.
Definition: settings_gui.cpp:846
WID_GO_CURRENCY_DROPDOWN
@ WID_GO_CURRENCY_DROPDOWN
Currency dropdown.
Definition: settings_widget.h:16
_languages
LanguageList _languages
The actual list of language meta data.
Definition: strings.cpp:45
GetMaskOfAllowedCurrencies
uint64 GetMaskOfAllowedCurrencies()
get a mask of the allowed currencies depending on the year
Definition: currency.cpp:122
BaseSet::GetNumInvalid
int GetNumInvalid() const
Get the number of invalid files.
Definition: base_media_base.h:98
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:47
GameSettingsWindow::manually_changed_folding
bool manually_changed_folding
Whether the user expanded/collapsed something manually.
Definition: settings_gui.cpp:1878
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:979
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:2077
AWV_INCREASE
@ AWV_INCREASE
Arrow to the right or in case of RTL to the left.
Definition: widget_type.h:36
SetWindowClassesDirty
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
Definition: window.cpp:3248
QSF_ENABLE_DEFAULT
@ QSF_ENABLE_DEFAULT
enable the 'Default' button ("\0" is returned)
Definition: textbuf_gui.h:21
ClientSettings::music
MusicSettings music
settings related to music/sound
Definition: settings_type.h:585
Window::DisableWidget
void DisableWidget(byte widget_index)
Sets a widget to disabled.
Definition: window_gui.h:403
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:182
GetVariableAddress
static void * GetVariableAddress(const void *object, const SaveLoad *sld)
Get the address of the variable.
Definition: saveload.h:888
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:385
WHR_NONE
@ WHR_NONE
Nothing was filtering matches away.
Definition: settings_gui.cpp:1855
UpdateGUIZoom
void UpdateGUIZoom()
Resolve GUI zoom level, if auto-suggestion is requested.
Definition: gfx.cpp:1870
SettingsContainer::GetFoldingState
void GetFoldingState(bool &all_folded, bool &all_unfolded) const
Recursively accumulate the folding state of the tree.
Definition: settings_gui.cpp:1260
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:432
Window::SetWidgetLoweredState
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:454
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:1871
ReadLanguagePack
bool ReadLanguagePack(const LanguageMetadata *lang)
Read a particular language.
Definition: strings.cpp:1718
MusicSettings::music_vol
byte music_vol
The requested music volume.
Definition: settings_type.h:207
GameOptionsWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: settings_gui.cpp:522
_left_button_clicked
bool _left_button_clicked
Is left mouse button clicked?
Definition: gfx.cpp:39
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:2398
_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:74
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:1400
CharSetFilter
CharSetFilter
Valid filter types for IsValidChar.
Definition: string_type.h:26
_currency_specs
CurrencySpec _currency_specs[CURRENCY_END]
Array of currencies used by the system.
Definition: currency.cpp:74
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:2083
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:509
SettingDescBase::str_help
StringID str_help
(Translated) string with help text; gui only.
Definition: settings_internal.h:102
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:57
_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:581
WID_GS_TYPE_DROPDOWN
@ WID_GS_TYPE_DROPDOWN
The drop down box to choose client/game/company/all settings.
Definition: settings_widget.h:53
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:351
AWV_DECREASE
@ AWV_DECREASE
Arrow to the left or in case of RTL to the right.
Definition: widget_type.h:35
SetMinimalTextLines
static NWidgetPart SetMinimalTextLines(uint8 lines, uint8 spacing, FontSize size=FS_NORMAL)
Widget part function for setting the minimal text lines.
Definition: widget_type.h:974
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:66
BaseSettingEntry::IsFiltered
bool IsFiltered() const
Check whether an entry is hidden due to filters.
Definition: settings_gui.cpp:817
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:772
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:747
SettingEntryFlags
SettingEntryFlags
Flags for SettingEntry.
Definition: settings_gui.cpp:760
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