|
OpenTTD Source 20260218-master-g2123fca5ea
|
Data structure describing one page of settings in the settings window. More...
#include <settingentry_gui.h>
Public Member Functions | |
| SettingsPage (StringID title) | |
| Constructor for a sub-page in the 'advanced settings' window. | |
| void | Init (uint8_t level=0) override |
| Initialization of a setting entry. | |
| void | ResetAll () override |
| Resets all settings to their default values. | |
| void | FoldAll () override |
| Recursively close all folds of sub-pages. | |
| void | UnFoldAll () override |
| Recursively open all folds of sub-pages. | |
| uint | Length () const override |
| Get the number of rows needed to show this entry. | |
| void | GetFoldingState (bool &all_folded, bool &all_unfolded) const override |
| Recursively accumulate the folding state of the tree. | |
| bool | IsVisible (const BaseSettingEntry *item) const override |
| Check whether an entry is visible and not folded or filtered away. | |
| BaseSettingEntry * | FindEntry (uint row, uint *cur_row) override |
| Find setting entry at row row_num. | |
| uint | GetMaxHelpHeight (int maxw) override |
| Get the biggest height of the help text(s), if the width is at least maxw. | |
| bool | UpdateFilterState (SettingFilter &filter, bool force_visible) override |
| Update the filter state. | |
| 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. | |
| Public Member Functions inherited from BaseSettingEntry | |
| void | SetLastField (bool last_field) |
| Set whether this is the last visible entry of the parent node. | |
| bool | IsFiltered () const |
| Check whether an entry is hidden due to filters. | |
| Public Member Functions inherited from SettingsContainer | |
| template<typename T> | |
| T * | Add (T *item) |
| Add an item to the container. | |
| void | Init (uint8_t level=0) |
| Initialization of an entire setting page. | |
| void | ResetAll () |
| Resets all settings to their default values. | |
| void | FoldAll () |
| Recursively close all folds of sub-pages. | |
| void | UnFoldAll () |
| Recursively open all folds of sub-pages. | |
| uint | Length () const |
| Return number of rows needed to display the whole page. | |
| void | GetFoldingState (bool &all_folded, bool &all_unfolded) const |
| Recursively accumulate the folding state of the tree. | |
| bool | IsVisible (const BaseSettingEntry *item) const |
| Check whether an entry is visible and not folded or filtered away. | |
| BaseSettingEntry * | FindEntry (uint row, uint *cur_row) |
| Find the setting entry at row number row_num. | |
| uint | GetMaxHelpHeight (int maxw) |
| Get the biggest height of the help texts, if the width is at least maxw. | |
| bool | UpdateFilterState (SettingFilter &filter, bool force_visible) |
| Update the filter state. | |
| 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. | |
Data Fields | |
| StringID | title |
| Title of the sub-page. | |
| bool | folded |
| Sub-page is folded (not visible except for its title). | |
| Data Fields inherited from BaseSettingEntry | |
| SettingEntryFlags | flags |
| Flags of the setting entry. | |
| uint8_t | level |
| Nesting level of this setting entry. | |
| Data Fields inherited from SettingsContainer | |
| EntryVector | entries |
| Settings on this page. | |
Protected Member Functions | |
| void | DrawSetting (GameSettings *settings_ptr, int left, int right, int y, bool highlight) const override |
| Function to draw setting value (button + text + current value). | |
Additional Inherited Members | |
| Public Types inherited from SettingsContainer | |
| using | EntryVector = std::vector<BaseSettingEntry*> |
| Vector of pointers. | |
| Static Public Attributes inherited from BaseSettingEntry | |
| static Dimension | circle_size |
| Dimension of the circle +/- icon. | |
| static int | line_height |
| Height of a single setting. | |
Data structure describing one page of settings in the settings window.
Definition at line 184 of file settingentry_gui.h.
| SettingsPage::SettingsPage | ( | StringID | title | ) |
Constructor for a sub-page in the 'advanced settings' window.
| title | Title of the sub-page |
Definition at line 445 of file settingentry_gui.cpp.
|
overridevirtual |
Draw a row in the settings panel.
The scrollbar uses rows of the page, while the page data structure is a tree of SettingsPage and SettingEntry objects. As a result, the drawing routing traverses the tree from top to bottom, counting rows in cur_row until it reaches first_row. Then it enables drawing rows while traversing until max_row is reached, at which point drawing is terminated.
The parent_last parameter ensures that the vertical lines at the left are only drawn when another entry follows, that it prevents output like
* |-- setting * |-- (-) - Title * | |-- setting * | |-- setting *
The left-most vertical line is not wanted. It is prevented by setting the appropriate bit in the parent_last parameter.
| settings_ptr | Pointer to current values of all settings |
| left | Left-most position in window/panel to start drawing first_row |
| right | Right-most x position to draw strings at. |
| y | Upper-most position in window/panel to start drawing first_row |
| first_row | First row number to draw |
| max_row | Row-number to stop drawing (the row-number of the row below the last row to draw) |
| selected | Selected entry by the user. |
| cur_row | Current row number (internal variable) |
| parent_last | Last-field booleans of parent page level (page level i sets bit i to 1 if it is its last field) |
Reimplemented from BaseSettingEntry.
Definition at line 539 of file settingentry_gui.cpp.
References BaseSettingEntry::Draw(), SettingsContainer::Draw(), BaseSettingEntry::flags, folded, BaseSettingEntry::IsFiltered(), LastField, BaseSettingEntry::level, and SetBit().
|
overrideprotectedvirtual |
Function to draw setting value (button + text + current value).
| settings_ptr | Pointer to current values of all settings. |
| left | Left-most position in window/panel to start drawing. |
| right | Right-most position in window/panel to draw. |
| y | Upper-most position in window/panel to start drawing. |
| highlight | Whether to highlight the entry. |
Implements BaseSettingEntry.
Definition at line 558 of file settingentry_gui.cpp.
References _current_text_dir, BaseSettingEntry::circle_size, DrawSprite(), DrawString(), folded, FS_NORMAL, GetCharacterHeight(), BaseSettingEntry::line_height, WidgetDimensions::scaled, TD_RTL, and title.
|
overridevirtual |
Find setting entry at row row_num.
| row_num | Index of entry to return |
| cur_row | Current row number |
nullptr if it not found (folded or filtered) Reimplemented from BaseSettingEntry.
Definition at line 529 of file settingentry_gui.cpp.
References SettingsContainer::FindEntry(), folded, and BaseSettingEntry::IsFiltered().
|
overridevirtual |
Recursively close all folds of sub-pages.
Reimplemented from BaseSettingEntry.
Definition at line 464 of file settingentry_gui.cpp.
References SettingsContainer::FoldAll(), folded, and BaseSettingEntry::IsFiltered().
|
overridevirtual |
Recursively accumulate the folding state of the tree.
| [in,out] | all_folded | Set to false, if one entry is not folded. |
| [in,out] | all_unfolded | Set to false, if one entry is folded. |
Reimplemented from BaseSettingEntry.
Definition at line 480 of file settingentry_gui.cpp.
References folded, SettingsContainer::GetFoldingState(), and BaseSettingEntry::IsFiltered().
|
inlineoverridevirtual |
Get the biggest height of the help text(s), if the width is at least maxw.
Help text gets wrapped if needed.
| maxw | Maximal width of a line help text. |
Reimplemented from BaseSettingEntry.
Definition at line 199 of file settingentry_gui.h.
References SettingsContainer::GetMaxHelpHeight().
|
overridevirtual |
Initialization of a setting entry.
| level | Page nesting level of this entry |
Reimplemented from BaseSettingEntry.
Definition at line 451 of file settingentry_gui.cpp.
References BaseSettingEntry::Init(), SettingsContainer::Init(), and BaseSettingEntry::level.
|
overridevirtual |
Check whether an entry is visible and not folded or filtered away.
Note: This does not consider the scrolling range; it might still require scrolling to make the setting really visible.
| item | Entry to search for. |
Reimplemented from BaseSettingEntry.
Definition at line 506 of file settingentry_gui.cpp.
References folded, BaseSettingEntry::IsFiltered(), and SettingsContainer::IsVisible().
|
overridevirtual |
Get the number of rows needed to show this entry.
Implements BaseSettingEntry.
Definition at line 515 of file settingentry_gui.cpp.
References folded, BaseSettingEntry::IsFiltered(), and SettingsContainer::Length().
|
overridevirtual |
Resets all settings to their default values.
Implements BaseSettingEntry.
Definition at line 457 of file settingentry_gui.cpp.
References SettingsContainer::entries.
|
overridevirtual |
Recursively open all folds of sub-pages.
Reimplemented from BaseSettingEntry.
Definition at line 472 of file settingentry_gui.cpp.
References folded, BaseSettingEntry::IsFiltered(), and SettingsContainer::UnFoldAll().
|
overridevirtual |
Update the filter state.
| filter | Filter |
| force_visible | Whether to force all items visible, no matter what |
Implements BaseSettingEntry.
Definition at line 493 of file settingentry_gui.cpp.
References Filtered, BaseSettingEntry::flags, StringFilter::GetState(), GetString(), StringFilter::IsEmpty(), StringFilter::ResetState(), SettingFilter::string, title, and SettingsContainer::UpdateFilterState().
| bool SettingsPage::folded |
Sub-page is folded (not visible except for its title).
Definition at line 186 of file settingentry_gui.h.
Referenced by Draw(), DrawSetting(), FindEntry(), FoldAll(), GetFoldingState(), IsVisible(), Length(), SettingsPage(), and UnFoldAll().
| StringID SettingsPage::title |
Title of the sub-page.
Definition at line 185 of file settingentry_gui.h.
Referenced by DrawSetting(), SettingsPage(), and UpdateFilterState().