OpenTTD Source: src/settingentry_gui.cpp Source File

OpenTTD Source 15.0-RC2

settingentry_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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#include "stdafx.h"
11#include "company_base.h"
12#include "company_func.h"
13#include "settingentry_gui.h"
14#include "settings_gui.h"
15#include "settings_internal.h"
16#include "stringfilter_type.h"
17#include "strings_func.h"
18
19#include "table/sprites.h"
20#include "table/strings.h"
21
22#include "safeguards.h"
23
24
25/* == BaseSettingEntry methods == */
26
31 void BaseSettingEntry::Init(uint8_t level)
32{
33 this->level = level;
34}
35
42 bool BaseSettingEntry::IsVisible(const BaseSettingEntry *item) const
43{
44 if (this->IsFiltered()) return false;
45 return this == item;
46}
47
54 BaseSettingEntry *BaseSettingEntry::FindEntry(uint row_num, uint *cur_row)
55{
56 if (this->IsFiltered()) return nullptr;
57 if (row_num == *cur_row) return this;
58 (*cur_row)++;
59 return nullptr;
60}
61
91uint 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
92{
93 if (this->IsFiltered()) return cur_row;
94 if (cur_row >= max_row) return cur_row;
95
96 bool rtl = _current_text_dir == TD_RTL;
97 int offset = (rtl ? -static_cast<int>(BaseSettingEntry::circle_size.width) : static_cast<int>(BaseSettingEntry::circle_size.width)) / 2;
98 int level_width = rtl ? -WidgetDimensions::scaled.hsep_indent : WidgetDimensions::scaled.hsep_indent;
99
100 int x = rtl ? right : left;
101 if (cur_row >= first_row) {
102 PixelColour colour = GetColourGradient(COLOUR_ORANGE, SHADE_NORMAL);
103 y += (cur_row - first_row) * BaseSettingEntry::line_height; // Compute correct y start position
104
105 /* Draw vertical for parent nesting levels */
106 for (uint lvl = 0; lvl < this->level; lvl++) {
107 if (!HasBit(parent_last, lvl)) GfxDrawLine(x + offset, y, x + offset, y + BaseSettingEntry::line_height - 1, colour);
108 x += level_width;
109 }
110 /* draw own |- prefix */
111 int halfway_y = y + BaseSettingEntry::line_height / 2;
112 int bottom_y = flags.Test(SettingEntryFlag::LastField) ? halfway_y : y + BaseSettingEntry::line_height - 1;
113 GfxDrawLine(x + offset, y, x + offset, bottom_y, colour);
114 /* Small horizontal line from the last vertical line */
115 GfxDrawLine(x + offset, halfway_y, x + level_width - (rtl ? -WidgetDimensions::scaled.hsep_normal : WidgetDimensions::scaled.hsep_normal), halfway_y, colour);
116 x += level_width;
117
118 this->DrawSetting(settings_ptr, rtl ? left : x, rtl ? x : right, y, this == selected);
119 }
120 cur_row++;
121
122 return cur_row;
123}
124
125/* == SettingEntry methods == */
126
131 void SettingEntry::Init(uint8_t level)
132{
133 BaseSettingEntry::Init(level);
134 this->setting = GetSettingFromName(this->name)->AsIntSetting();
135}
136
137/* Sets the given setting entry to its default value */
138void SettingEntry::ResetAll()
139{
140 SetSettingValue(this->setting, this->setting->GetDefaultValue());
141}
142
148 void SettingEntry::SetButtons(SettingEntryFlags new_val)
149{
150 assert((new_val & SEF_BUTTONS_MASK) == new_val); // Should not touch any flags outside the buttons
151 this->flags.Set(SettingEntryFlag::LeftDepressed, new_val.Test(SettingEntryFlag::LeftDepressed));
152 this->flags.Set(SettingEntryFlag::RightDepressed, new_val.Test(SettingEntryFlag::RightDepressed));
153}
154
156uint SettingEntry::Length() const
157{
158 return this->IsFiltered() ? 0 : 1;
159}
160
166uint SettingEntry::GetMaxHelpHeight(int maxw)
167{
168 return GetStringHeight(this->setting->GetHelp(), maxw);
169}
170
176 bool SettingEntry::IsVisibleByRestrictionMode(RestrictionMode mode) const
177{
178 /* There shall not be any restriction, i.e. all settings shall be visible. */
179 if (mode == RM_ALL) return true;
180
181 const IntSettingDesc *sd = this->setting;
182
183 if (mode == RM_BASIC) return (this->setting->cat & SC_BASIC_LIST) != 0;
184 if (mode == RM_ADVANCED) return (this->setting->cat & SC_ADVANCED_LIST) != 0;
185
186 /* Read the current value. */
187 const void *object = ResolveObject(&GetGameSettings(), sd);
188 int64_t current_value = sd->Read(object);
189 int64_t filter_value;
190
191 if (mode == RM_CHANGED_AGAINST_DEFAULT) {
192 /* This entry shall only be visible, if the value deviates from its default value. */
193
194 /* Read the default value. */
195 filter_value = sd->GetDefaultValue();
196 } else {
197 assert(mode == RM_CHANGED_AGAINST_NEW);
198 /* This entry shall only be visible, if the value deviates from
199 * its value is used when starting a new game. */
200
201 /* Make sure we're not comparing the new game settings against itself. */
202 assert(&GetGameSettings() != &_settings_newgame);
203
204 /* Read the new game's value. */
205 filter_value = sd->Read(ResolveObject(&_settings_newgame, sd));
206 }
207
208 return current_value != filter_value;
209}
210
217 bool SettingEntry::UpdateFilterState(SettingFilter &filter, bool force_visible)
218{
219 this->flags.Reset(SettingEntryFlag::Filtered);
220
221 bool visible = true;
222
223 const IntSettingDesc *sd = this->setting;
224 if (!force_visible && !filter.string.IsEmpty()) {
225 /* Process the search text filter for this item. */
226 filter.string.ResetState();
227
228 filter.string.AddLine(GetString(sd->GetTitle(), STR_EMPTY));
229 filter.string.AddLine(GetString(sd->GetHelp()));
230
231 visible = filter.string.GetState();
232 }
233
234 if (visible) {
235 if (filter.type != ST_ALL && sd->GetType() != filter.type) {
236 filter.type_hides = true;
237 visible = false;
238 }
239 if (!this->IsVisibleByRestrictionMode(filter.mode)) {
240 while (filter.min_cat < RM_ALL && (filter.min_cat == filter.mode || !this->IsVisibleByRestrictionMode(filter.min_cat))) filter.min_cat++;
241 visible = false;
242 }
243 }
244
245 if (!visible) this->flags.Set(SettingEntryFlag::Filtered);
246 return visible;
247}
248
249const void *ResolveObject(const GameSettings *settings_ptr, const IntSettingDesc *sd)
250{
251 if (sd->flags.Test(SettingFlag::PerCompany)) {
252 if (Company::IsValidID(_local_company) && _game_mode != GM_MENU) {
253 return &Company::Get(_local_company)->settings;
254 }
255 return &_settings_client.company;
256 }
257 return settings_ptr;
258}
259
268 void SettingEntry::DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const
269{
270 const IntSettingDesc *sd = this->setting;
271 int state = (this->flags & SEF_BUTTONS_MASK).base();
272
273 bool rtl = _current_text_dir == TD_RTL;
274 uint buttons_left = rtl ? right + 1 - SETTING_BUTTON_WIDTH : left;
275 uint text_left = left + (rtl ? 0 : SETTING_BUTTON_WIDTH + WidgetDimensions::scaled.hsep_wide);
276 uint text_right = right - (rtl ? SETTING_BUTTON_WIDTH + WidgetDimensions::scaled.hsep_wide : 0);
277 uint button_y = y + (BaseSettingEntry::line_height - SETTING_BUTTON_HEIGHT) / 2;
278
279 /* We do not allow changes of some items when we are a client in a networkgame */
280 bool editable = sd->IsEditable();
281
282 auto [min_val, max_val] = sd->GetRange();
283 int32_t value = sd->Read(ResolveObject(settings_ptr, sd));
284 if (sd->IsBoolSetting()) {
285 /* Draw checkbox for boolean-value either on/off */
286 DrawBoolButton(buttons_left, button_y, COLOUR_YELLOW, COLOUR_MAUVE, value != 0, editable);
287 } else if (sd->flags.Test(SettingFlag::GuiDropdown)) {
288 /* Draw [v] button for settings of an enum-type */
289 DrawDropDownButton(buttons_left, button_y, COLOUR_YELLOW, state != 0, editable);
290 } else {
291 /* Draw [<][>] boxes for settings of an integer-type */
292 DrawArrowButtons(buttons_left, button_y, COLOUR_YELLOW, state,
293 editable && value != (sd->flags.Test(SettingFlag::GuiZeroIsSpecial) ? 0 : min_val), editable && static_cast<uint32_t>(value) != max_val);
294 }
295 auto [param1, param2] = sd->GetValueParams(value);
296 DrawString(text_left, text_right, y + (BaseSettingEntry::line_height - GetCharacterHeight(FS_NORMAL)) / 2, GetString(sd->GetTitle(), STR_CONFIG_SETTING_VALUE, param1, param2), highlight ? TC_WHITE : TC_LIGHT_BLUE);
297}
298
299/* == SettingsContainer methods == */
300
305 void SettingsContainer::Init(uint8_t level)
306{
307 for (auto &it : this->entries) {
308 it->Init(level);
309 }
310}
311
313 void SettingsContainer::ResetAll()
314{
315 for (auto settings_entry : this->entries) {
316 settings_entry->ResetAll();
317 }
318}
319
321 void SettingsContainer::FoldAll()
322{
323 for (auto &it : this->entries) {
324 it->FoldAll();
325 }
326}
327
329 void SettingsContainer::UnFoldAll()
330{
331 for (auto &it : this->entries) {
332 it->UnFoldAll();
333 }
334}
335
341 void SettingsContainer::GetFoldingState(bool &all_folded, bool &all_unfolded) const
342{
343 for (auto &it : this->entries) {
344 it->GetFoldingState(all_folded, all_unfolded);
345 }
346}
347
354 bool SettingsContainer::UpdateFilterState(SettingFilter &filter, bool force_visible)
355{
356 bool visible = false;
357 bool first_visible = true;
358 for (EntryVector::reverse_iterator it = this->entries.rbegin(); it != this->entries.rend(); ++it) {
359 visible |= (*it)->UpdateFilterState(filter, force_visible);
360 (*it)->SetLastField(first_visible);
361 if (visible && first_visible) first_visible = false;
362 }
363 return visible;
364}
365
366
373 bool SettingsContainer::IsVisible(const BaseSettingEntry *item) const
374{
375 for (const auto &it : this->entries) {
376 if (it->IsVisible(item)) return true;
377 }
378 return false;
379}
380
382uint SettingsContainer::Length() const
383{
384 uint length = 0;
385 for (const auto &it : this->entries) {
386 length += it->Length();
387 }
388 return length;
389}
390
397 BaseSettingEntry *SettingsContainer::FindEntry(uint row_num, uint *cur_row)
398{
399 BaseSettingEntry *pe = nullptr;
400 for (const auto &it : this->entries) {
401 pe = it->FindEntry(row_num, cur_row);
402 if (pe != nullptr) {
403 break;
404 }
405 }
406 return pe;
407}
408
414uint SettingsContainer::GetMaxHelpHeight(int maxw)
415{
416 uint biggest = 0;
417 for (const auto &it : this->entries) {
418 biggest = std::max(biggest, it->GetMaxHelpHeight(maxw));
419 }
420 return biggest;
421}
422
423
438uint 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
439{
440 for (const auto &it : this->entries) {
441 cur_row = it->Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
442 if (cur_row >= max_row) break;
443 }
444 return cur_row;
445}
446
447/* == SettingsPage methods == */
448
453SettingsPage::SettingsPage(StringID title)
454{
455 this->title = title;
456 this->folded = true;
457}
458
463 void SettingsPage::Init(uint8_t level)
464{
465 BaseSettingEntry::Init(level);
466 SettingsContainer::Init(level + 1);
467}
468
470 void SettingsPage::ResetAll()
471{
472 for (auto settings_entry : this->entries) {
473 settings_entry->ResetAll();
474 }
475}
476
478 void SettingsPage::FoldAll()
479{
480 if (this->IsFiltered()) return;
481 this->folded = true;
482
483 SettingsContainer::FoldAll();
484}
485
487 void SettingsPage::UnFoldAll()
488{
489 if (this->IsFiltered()) return;
490 this->folded = false;
491
492 SettingsContainer::UnFoldAll();
493}
494
500 void SettingsPage::GetFoldingState(bool &all_folded, bool &all_unfolded) const
501{
502 if (this->IsFiltered()) return;
503
504 if (this->folded) {
505 all_unfolded = false;
506 } else {
507 all_folded = false;
508 }
509
510 SettingsContainer::GetFoldingState(all_folded, all_unfolded);
511}
512
519 bool SettingsPage::UpdateFilterState(SettingFilter &filter, bool force_visible)
520{
521 if (!force_visible && !filter.string.IsEmpty()) {
522 filter.string.ResetState();
523 filter.string.AddLine(GetString(this->title));
524 force_visible = filter.string.GetState();
525 }
526
527 bool visible = SettingsContainer::UpdateFilterState(filter, force_visible);
528 this->flags.Set(SettingEntryFlag::Filtered, !visible);
529 return visible;
530}
531
538 bool SettingsPage::IsVisible(const BaseSettingEntry *item) const
539{
540 if (this->IsFiltered()) return false;
541 if (this == item) return true;
542 if (this->folded) return false;
543
544 return SettingsContainer::IsVisible(item);
545}
546
548uint SettingsPage::Length() const
549{
550 if (this->IsFiltered()) return 0;
551 if (this->folded) return 1; // Only displaying the title
552
553 return 1 + SettingsContainer::Length();
554}
555
562 BaseSettingEntry *SettingsPage::FindEntry(uint row_num, uint *cur_row)
563{
564 if (this->IsFiltered()) return nullptr;
565 if (row_num == *cur_row) return this;
566 (*cur_row)++;
567 if (this->folded) return nullptr;
568
569 return SettingsContainer::FindEntry(row_num, cur_row);
570}
571
586uint 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
587{
588 if (this->IsFiltered()) return cur_row;
589 if (cur_row >= max_row) return cur_row;
590
591 cur_row = BaseSettingEntry::Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
592
593 if (!this->folded) {
594 if (this->flags.Test(SettingEntryFlag::LastField)) {
595 assert(this->level < 8 * sizeof(parent_last));
596 SetBit(parent_last, this->level); // Add own last-field state
597 }
598
599 cur_row = SettingsContainer::Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
600 }
601
602 return cur_row;
603}
604
611 void SettingsPage::DrawSetting(GameSettings *, int left, int right, int y, bool) const
612{
613 bool rtl = _current_text_dir == TD_RTL;
614 DrawSprite((this->folded ? SPR_CIRCLE_FOLDED : SPR_CIRCLE_UNFOLDED), PAL_NONE, rtl ? right - BaseSettingEntry::circle_size.width : left, y + (BaseSettingEntry::line_height - BaseSettingEntry::circle_size.height) / 2);
615 DrawString(rtl ? left : left + BaseSettingEntry::circle_size.width + WidgetDimensions::scaled.hsep_normal, rtl ? right - BaseSettingEntry::circle_size.width - WidgetDimensions::scaled.hsep_normal : right, y + (BaseSettingEntry::line_height - GetCharacterHeight(FS_NORMAL)) / 2, this->title, TC_ORANGE);
616}
617
619 SettingsContainer &GetSettingsTree()
620{
621 static SettingsContainer *main = nullptr;
622
623 if (main == nullptr)
624 {
625 /* Build up the dynamic settings-array only once per OpenTTD session */
626 main = new SettingsContainer();
627
628 SettingsPage *localisation = main->Add(new SettingsPage(STR_CONFIG_SETTING_LOCALISATION));
629 {
630 localisation->Add(new SettingEntry("locale.units_velocity"));
631 localisation->Add(new SettingEntry("locale.units_velocity_nautical"));
632 localisation->Add(new SettingEntry("locale.units_power"));
633 localisation->Add(new SettingEntry("locale.units_weight"));
634 localisation->Add(new SettingEntry("locale.units_volume"));
635 localisation->Add(new SettingEntry("locale.units_force"));
636 localisation->Add(new SettingEntry("locale.units_height"));
637 localisation->Add(new SettingEntry("gui.date_format_in_default_names"));
638 }
639
640 SettingsPage *graphics = main->Add(new SettingsPage(STR_CONFIG_SETTING_GRAPHICS));
641 {
642 graphics->Add(new SettingEntry("gui.zoom_min"));
643 graphics->Add(new SettingEntry("gui.zoom_max"));
644 graphics->Add(new SettingEntry("gui.sprite_zoom_min"));
645 graphics->Add(new SettingEntry("gui.smallmap_land_colour"));
646 graphics->Add(new SettingEntry("gui.linkgraph_colours"));
647 graphics->Add(new SettingEntry("gui.graph_line_thickness"));
648 }
649
650 SettingsPage *sound = main->Add(new SettingsPage(STR_CONFIG_SETTING_SOUND));
651 {
652 sound->Add(new SettingEntry("sound.click_beep"));
653 sound->Add(new SettingEntry("sound.confirm"));
654 sound->Add(new SettingEntry("sound.news_ticker"));
655 sound->Add(new SettingEntry("sound.news_full"));
656 sound->Add(new SettingEntry("sound.new_year"));
657 sound->Add(new SettingEntry("sound.disaster"));
658 sound->Add(new SettingEntry("sound.vehicle"));
659 sound->Add(new SettingEntry("sound.ambient"));
660 }
661
662 SettingsPage *interface = main->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE));
663 {
664 SettingsPage *general = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_GENERAL));
665 {
666 general->Add(new SettingEntry("gui.osk_activation"));
667 general->Add(new SettingEntry("gui.hover_delay_ms"));
668 general->Add(new SettingEntry("gui.errmsg_duration"));
669 general->Add(new SettingEntry("gui.window_snap_radius"));
670 general->Add(new SettingEntry("gui.window_soft_limit"));
671 general->Add(new SettingEntry("gui.right_click_wnd_close"));
672 general->Add(new SettingEntry("gui.toolbar_dropdown_autoselect"));
673 }
674
675 SettingsPage *viewports = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_VIEWPORTS));
676 {
677 viewports->Add(new SettingEntry("gui.auto_scrolling"));
678 viewports->Add(new SettingEntry("gui.scroll_mode"));
679 viewports->Add(new SettingEntry("gui.smooth_scroll"));
680 /* While the horizontal scrollwheel scrolling is written as general code, only
681 * the cocoa (OSX) driver generates input for it.
682 * Since it's also able to completely disable the scrollwheel will we display it on all platforms anyway */
683 viewports->Add(new SettingEntry("gui.scrollwheel_scrolling"));
684 viewports->Add(new SettingEntry("gui.scrollwheel_multiplier"));
685#ifdef __APPLE__
686 /* We might need to emulate a right mouse button on mac */
687 viewports->Add(new SettingEntry("gui.right_mouse_btn_emulation"));
688#endif
689 viewports->Add(new SettingEntry("gui.population_in_label"));
690 viewports->Add(new SettingEntry("gui.liveries"));
691 viewports->Add(new SettingEntry("construction.train_signal_side"));
692 viewports->Add(new SettingEntry("gui.measure_tooltip"));
693 viewports->Add(new SettingEntry("gui.loading_indicators"));
694 viewports->Add(new SettingEntry("gui.show_track_reservation"));
695 }
696
697 SettingsPage *construction = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_CONSTRUCTION));
698 {
699 construction->Add(new SettingEntry("gui.link_terraform_toolbar"));
700 construction->Add(new SettingEntry("gui.persistent_buildingtools"));
701 construction->Add(new SettingEntry("gui.default_rail_type"));
702 construction->Add(new SettingEntry("gui.semaphore_build_before"));
703 construction->Add(new SettingEntry("gui.signal_gui_mode"));
704 construction->Add(new SettingEntry("gui.cycle_signal_types"));
705 construction->Add(new SettingEntry("gui.drag_signals_fixed_distance"));
706 construction->Add(new SettingEntry("gui.auto_remove_signals"));
707 }
708
709 interface->Add(new SettingEntry("gui.toolbar_pos"));
710 interface->Add(new SettingEntry("gui.statusbar_pos"));
711 interface->Add(new SettingEntry("gui.prefer_teamchat"));
712 interface->Add(new SettingEntry("gui.advanced_vehicle_list"));
713 interface->Add(new SettingEntry("gui.timetable_mode"));
714 interface->Add(new SettingEntry("gui.timetable_arrival_departure"));
715 interface->Add(new SettingEntry("gui.show_newgrf_name"));
716 interface->Add(new SettingEntry("gui.show_cargo_in_vehicle_lists"));
717 }
718
719 SettingsPage *advisors = main->Add(new SettingsPage(STR_CONFIG_SETTING_ADVISORS));
720 {
721 advisors->Add(new SettingEntry("gui.coloured_news_year"));
722 advisors->Add(new SettingEntry("news_display.general"));
723 advisors->Add(new SettingEntry("news_display.new_vehicles"));
724 advisors->Add(new SettingEntry("news_display.accident"));
725 advisors->Add(new SettingEntry("news_display.accident_other"));
726 advisors->Add(new SettingEntry("news_display.company_info"));
727 advisors->Add(new SettingEntry("news_display.acceptance"));
728 advisors->Add(new SettingEntry("news_display.arrival_player"));
729 advisors->Add(new SettingEntry("news_display.arrival_other"));
730 advisors->Add(new SettingEntry("news_display.advice"));
731 advisors->Add(new SettingEntry("gui.order_review_system"));
732 advisors->Add(new SettingEntry("gui.vehicle_income_warn"));
733 advisors->Add(new SettingEntry("gui.lost_vehicle_warn"));
734 advisors->Add(new SettingEntry("gui.old_vehicle_warn"));
735 advisors->Add(new SettingEntry("gui.show_finances"));
736 advisors->Add(new SettingEntry("news_display.economy"));
737 advisors->Add(new SettingEntry("news_display.subsidies"));
738 advisors->Add(new SettingEntry("news_display.open"));
739 advisors->Add(new SettingEntry("news_display.close"));
740 advisors->Add(new SettingEntry("news_display.production_player"));
741 advisors->Add(new SettingEntry("news_display.production_other"));
742 advisors->Add(new SettingEntry("news_display.production_nobody"));
743 }
744
745 SettingsPage *company = main->Add(new SettingsPage(STR_CONFIG_SETTING_COMPANY));
746 {
747 company->Add(new SettingEntry("gui.starting_colour"));
748 company->Add(new SettingEntry("gui.starting_colour_secondary"));
749 company->Add(new SettingEntry("company.engine_renew"));
750 company->Add(new SettingEntry("company.engine_renew_months"));
751 company->Add(new SettingEntry("company.engine_renew_money"));
752 company->Add(new SettingEntry("vehicle.servint_ispercent"));
753 company->Add(new SettingEntry("vehicle.servint_trains"));
754 company->Add(new SettingEntry("vehicle.servint_roadveh"));
755 company->Add(new SettingEntry("vehicle.servint_ships"));
756 company->Add(new SettingEntry("vehicle.servint_aircraft"));
757 }
758
759 SettingsPage *accounting = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCOUNTING));
760 {
761 accounting->Add(new SettingEntry("difficulty.infinite_money"));
762 accounting->Add(new SettingEntry("economy.inflation"));
763 accounting->Add(new SettingEntry("difficulty.initial_interest"));
764 accounting->Add(new SettingEntry("difficulty.max_loan"));
765 accounting->Add(new SettingEntry("difficulty.subsidy_multiplier"));
766 accounting->Add(new SettingEntry("difficulty.subsidy_duration"));
767 accounting->Add(new SettingEntry("economy.feeder_payment_share"));
768 accounting->Add(new SettingEntry("economy.infrastructure_maintenance"));
769 accounting->Add(new SettingEntry("difficulty.vehicle_costs"));
770 accounting->Add(new SettingEntry("difficulty.construction_cost"));
771 }
772
773 SettingsPage *vehicles = main->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES));
774 {
775 SettingsPage *physics = vehicles->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES_PHYSICS));
776 {
777 physics->Add(new SettingEntry("vehicle.train_acceleration_model"));
778 physics->Add(new SettingEntry("vehicle.train_slope_steepness"));
779 physics->Add(new SettingEntry("vehicle.wagon_speed_limits"));
780 physics->Add(new SettingEntry("vehicle.freight_trains"));
781 physics->Add(new SettingEntry("vehicle.roadveh_acceleration_model"));
782 physics->Add(new SettingEntry("vehicle.roadveh_slope_steepness"));
783 physics->Add(new SettingEntry("vehicle.smoke_amount"));
784 physics->Add(new SettingEntry("vehicle.plane_speed"));
785 }
786
787 SettingsPage *routing = vehicles->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES_ROUTING));
788 {
789 routing->Add(new SettingEntry("vehicle.road_side"));
790 routing->Add(new SettingEntry("difficulty.line_reverse_mode"));
791 routing->Add(new SettingEntry("pf.reverse_at_signals"));
792 routing->Add(new SettingEntry("pf.forbid_90_deg"));
793 }
794
795 SettingsPage *orders = vehicles->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES_ORDERS));
796 {
797 orders->Add(new SettingEntry("gui.new_nonstop"));
798 orders->Add(new SettingEntry("gui.quick_goto"));
799 orders->Add(new SettingEntry("gui.stop_location"));
800 }
801 }
802
803 SettingsPage *limitations = main->Add(new SettingsPage(STR_CONFIG_SETTING_LIMITATIONS));
804 {
805 limitations->Add(new SettingEntry("construction.command_pause_level"));
806 limitations->Add(new SettingEntry("construction.autoslope"));
807 limitations->Add(new SettingEntry("construction.extra_dynamite"));
808 limitations->Add(new SettingEntry("construction.map_height_limit"));
809 limitations->Add(new SettingEntry("construction.max_bridge_length"));
810 limitations->Add(new SettingEntry("construction.max_bridge_height"));
811 limitations->Add(new SettingEntry("construction.max_tunnel_length"));
812 limitations->Add(new SettingEntry("station.never_expire_airports"));
813 limitations->Add(new SettingEntry("vehicle.never_expire_vehicles"));
814 limitations->Add(new SettingEntry("vehicle.max_trains"));
815 limitations->Add(new SettingEntry("vehicle.max_roadveh"));
816 limitations->Add(new SettingEntry("vehicle.max_aircraft"));
817 limitations->Add(new SettingEntry("vehicle.max_ships"));
818 limitations->Add(new SettingEntry("vehicle.max_train_length"));
819 limitations->Add(new SettingEntry("station.station_spread"));
820 limitations->Add(new SettingEntry("station.distant_join_stations"));
821 limitations->Add(new SettingEntry("station.modified_catchment"));
822 limitations->Add(new SettingEntry("construction.road_stop_on_town_road"));
823 limitations->Add(new SettingEntry("construction.road_stop_on_competitor_road"));
824 limitations->Add(new SettingEntry("construction.crossing_with_competitor"));
825 limitations->Add(new SettingEntry("vehicle.disable_elrails"));
826 limitations->Add(new SettingEntry("order.station_length_loading_penalty"));
827 }
828
829 SettingsPage *disasters = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCIDENTS));
830 {
831 disasters->Add(new SettingEntry("difficulty.disasters"));
832 disasters->Add(new SettingEntry("difficulty.economy"));
833 disasters->Add(new SettingEntry("vehicle.plane_crashes"));
834 disasters->Add(new SettingEntry("difficulty.vehicle_breakdowns"));
835 disasters->Add(new SettingEntry("order.no_servicing_if_no_breakdowns"));
836 disasters->Add(new SettingEntry("order.serviceathelipad"));
837 }
838
839 SettingsPage *genworld = main->Add(new SettingsPage(STR_CONFIG_SETTING_GENWORLD));
840 {
841 genworld->Add(new SettingEntry("game_creation.landscape"));
842 genworld->Add(new SettingEntry("game_creation.land_generator"));
843 genworld->Add(new SettingEntry("difficulty.terrain_type"));
844 genworld->Add(new SettingEntry("game_creation.tgen_smoothness"));
845 genworld->Add(new SettingEntry("game_creation.variety"));
846 genworld->Add(new SettingEntry("game_creation.snow_coverage"));
847 genworld->Add(new SettingEntry("game_creation.snow_line_height"));
848 genworld->Add(new SettingEntry("game_creation.desert_coverage"));
849 genworld->Add(new SettingEntry("game_creation.amount_of_rivers"));
850 }
851
852 SettingsPage *environment = main->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT));
853 {
854 SettingsPage *time = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_TIME));
855 {
856 time->Add(new SettingEntry("economy.timekeeping_units"));
857 time->Add(new SettingEntry("economy.minutes_per_calendar_year"));
858 time->Add(new SettingEntry("game_creation.ending_year"));
859 time->Add(new SettingEntry("gui.pause_on_newgame"));
860 time->Add(new SettingEntry("gui.fast_forward_speed_limit"));
861 }
862
863 SettingsPage *authorities = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_AUTHORITIES));
864 {
865 authorities->Add(new SettingEntry("difficulty.town_council_tolerance"));
866 authorities->Add(new SettingEntry("economy.bribe"));
867 authorities->Add(new SettingEntry("economy.exclusive_rights"));
868 authorities->Add(new SettingEntry("economy.fund_roads"));
869 authorities->Add(new SettingEntry("economy.fund_buildings"));
870 authorities->Add(new SettingEntry("economy.station_noise_level"));
871 }
872
873 SettingsPage *towns = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_TOWNS));
874 {
875 towns->Add(new SettingEntry("economy.town_cargo_scale"));
876 towns->Add(new SettingEntry("economy.town_growth_rate"));
877 towns->Add(new SettingEntry("economy.allow_town_roads"));
878 towns->Add(new SettingEntry("economy.allow_town_level_crossings"));
879 towns->Add(new SettingEntry("economy.found_town"));
880 towns->Add(new SettingEntry("economy.place_houses"));
881 towns->Add(new SettingEntry("economy.town_layout"));
882 towns->Add(new SettingEntry("economy.larger_towns"));
883 towns->Add(new SettingEntry("economy.initial_city_size"));
884 towns->Add(new SettingEntry("economy.town_cargogen_mode"));
885 }
886
887 SettingsPage *industries = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_INDUSTRIES));
888 {
889 industries->Add(new SettingEntry("economy.industry_cargo_scale"));
890 industries->Add(new SettingEntry("difficulty.industry_density"));
891 industries->Add(new SettingEntry("construction.raw_industry_construction"));
892 industries->Add(new SettingEntry("construction.industry_platform"));
893 industries->Add(new SettingEntry("economy.multiple_industry_per_town"));
894 industries->Add(new SettingEntry("game_creation.oil_refinery_limit"));
895 industries->Add(new SettingEntry("economy.type"));
896 industries->Add(new SettingEntry("station.serve_neutral_industries"));
897 }
898
899 SettingsPage *cdist = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST));
900 {
901 cdist->Add(new SettingEntry("linkgraph.recalc_time"));
902 cdist->Add(new SettingEntry("linkgraph.recalc_interval"));
903 cdist->Add(new SettingEntry("linkgraph.distribution_pax"));
904 cdist->Add(new SettingEntry("linkgraph.distribution_mail"));
905 cdist->Add(new SettingEntry("linkgraph.distribution_armoured"));
906 cdist->Add(new SettingEntry("linkgraph.distribution_default"));
907 cdist->Add(new SettingEntry("linkgraph.accuracy"));
908 cdist->Add(new SettingEntry("linkgraph.demand_distance"));
909 cdist->Add(new SettingEntry("linkgraph.demand_size"));
910 cdist->Add(new SettingEntry("linkgraph.short_path_saturation"));
911 }
912
913 SettingsPage *trees = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_TREES));
914 {
915 trees->Add(new SettingEntry("game_creation.tree_placer"));
916 trees->Add(new SettingEntry("construction.extra_tree_placement"));
917 }
918 }
919
920 SettingsPage *ai = main->Add(new SettingsPage(STR_CONFIG_SETTING_AI));
921 {
922 SettingsPage *npc = ai->Add(new SettingsPage(STR_CONFIG_SETTING_AI_NPC));
923 {
924 npc->Add(new SettingEntry("script.script_max_opcode_till_suspend"));
925 npc->Add(new SettingEntry("script.script_max_memory_megabytes"));
926 npc->Add(new SettingEntry("difficulty.competitor_speed"));
927 npc->Add(new SettingEntry("ai.ai_in_multiplayer"));
928 npc->Add(new SettingEntry("ai.ai_disable_veh_train"));
929 npc->Add(new SettingEntry("ai.ai_disable_veh_roadveh"));
930 npc->Add(new SettingEntry("ai.ai_disable_veh_aircraft"));
931 npc->Add(new SettingEntry("ai.ai_disable_veh_ship"));
932 }
933
934 ai->Add(new SettingEntry("economy.give_money"));
935 }
936
937 SettingsPage *network = main->Add(new SettingsPage(STR_CONFIG_SETTING_NETWORK));
938 {
939 network->Add(new SettingEntry("network.use_relay_service"));
940 }
941
942 main->Init();
943 }
944 return *main;
945}
SetBit
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
Definition bitmath_func.hpp:121
HasBit
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Definition bitmath_func.hpp:103
BaseBitSet::Test
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
Definition base_bitset_type.hpp:141
BaseBitSet::Reset
constexpr Timpl & Reset()
Reset all bits.
Definition base_bitset_type.hpp:83
BaseBitSet::Set
constexpr Timpl & Set()
Set all bits.
Definition base_bitset_type.hpp:40
EnumBitSet< SettingEntryFlag, uint8_t >
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition window_gui.h:30
WidgetDimensions::hsep_wide
int hsep_wide
Wide horizontal spacing.
Definition window_gui.h:62
WidgetDimensions::hsep_normal
int hsep_normal
Normal horizontal spacing.
Definition window_gui.h:61
WidgetDimensions::hsep_indent
int hsep_indent
Width of indentation for tree layouts.
Definition window_gui.h:63
company_base.h
Definition of stuff that is very close to a company, like the company struct itself.
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition company_cmd.cpp:55
company_func.h
Functions related to companies.
GetCharacterHeight
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition fontcache.cpp:87
GetStringHeight
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Definition gfx.cpp:712
DrawString
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition gfx.cpp:665
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:1031
FS_NORMAL
@ FS_NORMAL
Index of the normal font in the font tables.
Definition gfx_type.h:249
GetColourGradient
PixelColour GetColourGradient(Colours colour, ColourShade shade)
Get colour gradient palette index.
Definition palette.cpp:388
safeguards.h
A number of safeguards to prevent using unsafe methods.
GetSettingsTree
SettingsContainer & GetSettingsTree()
Construct settings tree.
Definition settingentry_gui.cpp:619
settingentry_gui.h
Declarations of classes for handling display of individual configuration settings.
RestrictionMode
RestrictionMode
How the list of advanced settings is filtered.
Definition settingentry_gui.h:32
RM_CHANGED_AGAINST_DEFAULT
@ RM_CHANGED_AGAINST_DEFAULT
Show only settings which are different compared to default values.
Definition settingentry_gui.h:36
RM_ADVANCED
@ RM_ADVANCED
Display settings associated to the "advanced" list.
Definition settingentry_gui.h:34
RM_ALL
@ RM_ALL
List all settings regardless of the default/newgame/... values.
Definition settingentry_gui.h:35
RM_CHANGED_AGAINST_NEW
@ RM_CHANGED_AGAINST_NEW
Show only settings which are different compared to the user's new game setting values.
Definition settingentry_gui.h:37
RM_BASIC
@ RM_BASIC
Display settings associated to the "basic" list.
Definition settingentry_gui.h:33
SEF_BUTTONS_MASK
static constexpr SettingEntryFlags SEF_BUTTONS_MASK
Mask for button flags.
Definition settingentry_gui.h:29
SettingEntryFlag::LeftDepressed
@ LeftDepressed
Of a numeric setting entry, the left button is depressed.
SettingEntryFlag::LastField
@ LastField
This entry is the last one in a (sub-)page.
SettingEntryFlag::RightDepressed
@ RightDepressed
Of a numeric setting entry, the right button is depressed.
SettingEntryFlag::Filtered
@ Filtered
Entry is hidden by the string filter.
SetSettingValue
bool SetSettingValue(const IntSettingDesc *sd, int32_t value, bool force_newgame)
Top function to save the new value of an element of the Settings struct.
Definition settings.cpp:1818
_settings_newgame
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
Definition settings.cpp:62
GetSettingFromName
static const SettingDesc * GetSettingFromName(std::string_view name, const SettingTable &settings)
Given a name of setting, return a setting description from the table.
Definition settings.cpp:1640
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition settings.cpp:60
DrawArrowButtons
void DrawArrowButtons(int x, int y, Colours button_colour, uint8_t state, bool clickable_left, bool clickable_right)
Draw [<][>] boxes.
Definition settings_gui.cpp:1866
DrawBoolButton
void DrawBoolButton(int x, int y, Colours button_colour, Colours background, bool state, bool clickable)
Draw a toggle button.
Definition settings_gui.cpp:1947
DrawDropDownButton
void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
Draw a dropdown button.
Definition settings_gui.cpp:1924
settings_gui.h
Functions for setting GUIs.
SETTING_BUTTON_WIDTH
#define SETTING_BUTTON_WIDTH
Width of setting buttons.
Definition settings_gui.h:17
SETTING_BUTTON_HEIGHT
#define SETTING_BUTTON_HEIGHT
Height of setting buttons.
Definition settings_gui.h:19
settings_internal.h
Functions and types used internally for the settings configurations.
SettingFlag::PerCompany
@ PerCompany
This setting can be different for each company (saved in company struct).
SettingFlag::GuiZeroIsSpecial
@ GuiZeroIsSpecial
A value of zero is possible and has a custom string (the one after "strval").
SettingFlag::GuiDropdown
@ GuiDropdown
The value represents a limited number of string-options (internally integer) presented as dropdown.
ST_ALL
@ ST_ALL
Used in setting filter to match all types.
Definition settings_internal.h:65
SC_ADVANCED_LIST
@ SC_ADVANCED_LIST
Settings displayed in the list of advanced settings.
Definition settings_internal.h:46
SC_BASIC_LIST
@ SC_BASIC_LIST
Settings displayed in the list of basic settings.
Definition settings_internal.h:45
GetGameSettings
GameSettings & GetGameSettings()
Get the settings-object applicable for the current situation: the newgame settings when we're in the ...
Definition settings_type.h:674
sprites.h
This file contains all sprite-related enums and defines.
stdafx.h
Definition of base types and functions in a cross-platform compatible way.
stringfilter_type.h
Searching and filtering using a stringterm.
GetString
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
Definition strings.cpp:424
_current_text_dir
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition strings.cpp:56
strings_func.h
Functions related to OTTD's strings.
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition strings_type.h:19
TD_RTL
@ TD_RTL
Text is written right-to-left by default.
Definition strings_type.h:27
BaseSettingEntry
Data structure describing a single setting in a tab.
Definition settingentry_gui.h:52
BaseSettingEntry::IsFiltered
bool IsFiltered() const
Check whether an entry is hidden due to filters.
Definition settingentry_gui.h:80
BaseSettingEntry::FindEntry
virtual BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find setting entry at row row_num.
Definition settingentry_gui.cpp:54
BaseSettingEntry::circle_size
static Dimension circle_size
Dimension of the circle +/- icon.
Definition settingentry_gui.h:86
BaseSettingEntry::Init
virtual void Init(uint8_t level=0)
Initialization of a setting entry.
Definition settingentry_gui.cpp:31
BaseSettingEntry::line_height
static int line_height
Height of a single setting.
Definition settingentry_gui.h:87
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 settingentry_gui.cpp:91
BaseSettingEntry::flags
SettingEntryFlags flags
Flags of the setting entry.
Definition settingentry_gui.h:53
BaseSettingEntry::IsVisible
virtual bool IsVisible(const BaseSettingEntry *item) const
Check whether an entry is visible and not folded or filtered away.
Definition settingentry_gui.cpp:42
BaseSettingEntry::level
uint8_t level
Nesting level of this setting entry.
Definition settingentry_gui.h:54
ClientSettings::company
CompanySettings company
default values for per-company settings
Definition settings_type.h:652
GameSettings
All settings together for the game.
Definition settings_type.h:632
IntSettingDesc
Base integer type, including boolean, settings.
Definition settings_internal.h:148
IntSettingDesc::cat
SettingCategory cat
assigned categories of the setting
Definition settings_internal.h:213
IntSettingDesc::GetRange
std::tuple< int32_t, uint32_t > GetRange() const
Get the min/max range for the setting.
Definition settings.cpp:476
IntSettingDesc::GetTitle
StringID GetTitle() const
Get the title of the setting.
Definition settings.cpp:427
IntSettingDesc::GetDefaultValue
int32_t GetDefaultValue() const
Get the default value of the setting.
Definition settings.cpp:467
IntSettingDesc::GetHelp
StringID GetHelp() const
Get the help text of the setting.
Definition settings.cpp:436
IntSettingDesc::IsBoolSetting
virtual bool IsBoolSetting() const
Check whether this setting is a boolean type setting.
Definition settings_internal.h:232
IntSettingDesc::GetValueParams
std::pair< StringParameter, StringParameter > GetValueParams(int32_t value) const
Get parameters for drawing the value of the setting.
Definition settings.cpp:445
IntSettingDesc::Read
int32_t Read(const void *object) const
Read the integer from the the actual setting.
Definition settings.cpp:567
PixelColour
Colour for pixel/line drawing.
Definition gfx_type.h:405
Pool::PoolItem<&_company_pool >::Get
static Titem * Get(auto index)
Returns Titem with given index.
Definition pool_type.hpp:387
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(auto index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition pool_type.hpp:376
SettingDesc::IsEditable
bool IsEditable(bool do_command=false) const
Check whether the setting is editable in the current gamemode.
Definition settings.cpp:894
SettingDesc::flags
SettingFlags flags
Handles how a setting would show up in the GUI (text/currency, etc.).
Definition settings_internal.h:76
SettingDesc::GetType
SettingType GetType() const
Return the type of the setting.
Definition settings.cpp:911
SettingDesc::AsIntSetting
const struct IntSettingDesc * AsIntSetting() const
Get the setting description of this setting as an integer setting.
Definition settings.cpp:921
SettingEntry
Standard setting.
Definition settingentry_gui.h:94
SettingEntry::Length
uint Length() const override
Return number of rows needed to display the (filtered) entry.
Definition settingentry_gui.cpp:156
SettingEntry::SetButtons
void SetButtons(SettingEntryFlags new_val)
Set the button-depressed flags (#SettingsEntryFlag::LeftDepressed and #SettingsEntryFlag::RightDepres...
Definition settingentry_gui.cpp:148
SettingEntry::DrawSetting
void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const override
Function to draw setting value (button + text + current value)
Definition settingentry_gui.cpp:268
SettingEntry::IsVisibleByRestrictionMode
bool IsVisibleByRestrictionMode(RestrictionMode mode) const
Checks whether an entry shall be made visible based on the restriction mode.
Definition settingentry_gui.cpp:176
SettingEntry::name
const std::string_view name
Name of the setting.
Definition settingentry_gui.h:95
SettingEntry::GetMaxHelpHeight
uint GetMaxHelpHeight(int maxw) override
Get the biggest height of the help text(s), if the width is at least maxw.
Definition settingentry_gui.cpp:166
SettingEntry::Init
void Init(uint8_t level=0) override
Initialization of a setting entry.
Definition settingentry_gui.cpp:131
SettingEntry::setting
const IntSettingDesc * setting
Setting description of the setting.
Definition settingentry_gui.h:96
SettingEntry::UpdateFilterState
bool UpdateFilterState(SettingFilter &filter, bool force_visible) override
Update the filter state.
Definition settingentry_gui.cpp:217
SettingFilter
Filter for settings list.
Definition settingentry_gui.h:43
SettingFilter::type
SettingType type
Filter based on type.
Definition settingentry_gui.h:48
SettingFilter::type_hides
bool type_hides
Whether the type hides filtered strings.
Definition settingentry_gui.h:46
SettingFilter::mode
RestrictionMode mode
Filter based on category.
Definition settingentry_gui.h:47
SettingFilter::min_cat
RestrictionMode min_cat
Minimum category needed to display all filtered strings (RM_BASIC, RM_ADVANCED, or RM_ALL).
Definition settingentry_gui.h:45
SettingFilter::string
StringFilter string
Filter string.
Definition settingentry_gui.h:44
SettingsContainer
Containers for BaseSettingEntry.
Definition settingentry_gui.h:116
SettingsContainer::UpdateFilterState
bool UpdateFilterState(SettingFilter &filter, bool force_visible)
Update the filter state.
Definition settingentry_gui.cpp:354
SettingsContainer::GetFoldingState
void GetFoldingState(bool &all_folded, bool &all_unfolded) const
Recursively accumulate the folding state of the tree.
Definition settingentry_gui.cpp:341
SettingsContainer::GetMaxHelpHeight
uint GetMaxHelpHeight(int maxw)
Get the biggest height of the help texts, if the width is at least maxw.
Definition settingentry_gui.cpp:414
SettingsContainer::ResetAll
void ResetAll()
Resets all settings to their default values.
Definition settingentry_gui.cpp:313
SettingsContainer::IsVisible
bool IsVisible(const BaseSettingEntry *item) const
Check whether an entry is visible and not folded or filtered away.
Definition settingentry_gui.cpp:373
SettingsContainer::FoldAll
void FoldAll()
Recursively close all folds of sub-pages.
Definition settingentry_gui.cpp:321
SettingsContainer::UnFoldAll
void UnFoldAll()
Recursively open all folds of sub-pages.
Definition settingentry_gui.cpp:329
SettingsContainer::FindEntry
BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find the setting entry at row number row_num.
Definition settingentry_gui.cpp:397
SettingsContainer::entries
EntryVector entries
Settings on this page.
Definition settingentry_gui.h:118
SettingsContainer::Length
uint Length() const
Return number of rows needed to display the whole page.
Definition settingentry_gui.cpp:382
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 settingentry_gui.cpp:438
SettingsContainer::Init
void Init(uint8_t level=0)
Initialization of an entire setting page.
Definition settingentry_gui.cpp:305
SettingsPage
Data structure describing one page of settings in the settings window.
Definition settingentry_gui.h:144
SettingsPage::title
StringID title
Title of the sub-page.
Definition settingentry_gui.h:145
SettingsPage::IsVisible
bool IsVisible(const BaseSettingEntry *item) const override
Check whether an entry is visible and not folded or filtered away.
Definition settingentry_gui.cpp:538
SettingsPage::SettingsPage
SettingsPage(StringID title)
Constructor for a sub-page in the 'advanced settings' window.
Definition settingentry_gui.cpp:453
SettingsPage::UnFoldAll
void UnFoldAll() override
Recursively open all (filtered) folds of sub-pages.
Definition settingentry_gui.cpp:487
SettingsPage::FoldAll
void FoldAll() override
Recursively close all (filtered) folds of sub-pages.
Definition settingentry_gui.cpp:478
SettingsPage::Length
uint Length() const override
Return number of rows needed to display the (filtered) entry.
Definition settingentry_gui.cpp:548
SettingsPage::FindEntry
BaseSettingEntry * FindEntry(uint row, uint *cur_row) override
Find setting entry at row row_num.
Definition settingentry_gui.cpp:562
SettingsPage::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 override
Draw a row in the settings panel.
Definition settingentry_gui.cpp:586
SettingsPage::Init
void Init(uint8_t level=0) override
Initialization of an entire setting page.
Definition settingentry_gui.cpp:463
SettingsPage::GetFoldingState
void GetFoldingState(bool &all_folded, bool &all_unfolded) const override
Recursively accumulate the folding state of the (filtered) tree.
Definition settingentry_gui.cpp:500
SettingsPage::ResetAll
void ResetAll() override
Resets all settings to their default values.
Definition settingentry_gui.cpp:470
SettingsPage::folded
bool folded
Sub-page is folded (not visible except for its title)
Definition settingentry_gui.h:146
SettingsPage::UpdateFilterState
bool UpdateFilterState(SettingFilter &filter, bool force_visible) override
Update the filter state.
Definition settingentry_gui.cpp:519
SettingsPage::DrawSetting
void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const override
Function to draw setting value (button + text + current value)
Definition settingentry_gui.cpp:611
StringFilter::IsEmpty
bool IsEmpty() const
Check whether any filter words were entered.
Definition stringfilter_type.h:57
StringFilter::ResetState
void ResetState()
Reset the matching state to process a new item.
Definition stringfilter.cpp:80
StringFilter::GetState
bool GetState() const
Get the matching state of the current item.
Definition stringfilter_type.h:67