OpenTTD Source 20241224-master-gf74b0cf984
SettingsPage Struct Reference

Data structure describing one page of settings in the settings window. More...

Inheritance diagram for SettingsPage:
BaseSettingEntry SettingsContainer

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 an entire setting page.
 
void ResetAll () override
 Resets all settings to their default values.
 
void FoldAll () override
 Recursively close all (filtered) folds of sub-pages.
 
void UnFoldAll () override
 Recursively open all (filtered) folds of sub-pages.
 
uint Length () const override
 Return number of rows needed to display the (filtered) entry.
 
void GetFoldingState (bool &all_folded, bool &all_unfolded) const override
 Recursively accumulate the folding state of the (filtered) tree.
 
bool IsVisible (const BaseSettingEntry *item) const override
 Check whether an entry is visible and not folded or filtered away.
 
BaseSettingEntryFindEntry (uint row, uint *cur_row) override
 Find setting entry at row row_num.
 
uint GetMaxHelpHeight (int maxw) override
 
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)
 
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.
 
BaseSettingEntryFindEntry (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
uint8_t 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
typedef std::vector< BaseSettingEntry * > EntryVector
 

Detailed Description

Data structure describing one page of settings in the settings window.

Definition at line 1331 of file settings_gui.cpp.

Constructor & Destructor Documentation

◆ SettingsPage()

SettingsPage::SettingsPage ( StringID  title)

Constructor for a sub-page in the 'advanced settings' window.

Parameters
titleTitle of the sub-page

Definition at line 1794 of file settings_gui.cpp.

References folded, and title.

Member Function Documentation

◆ Draw()

uint SettingsPage::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
overridevirtual

Draw a row in the settings panel.

Parameters
settings_ptrPointer to current values of all settings
leftLeft-most position in window/panel to start drawing first_row
rightRight-most x position to draw strings at.
yUpper-most position in window/panel to start drawing first_row
first_rowFirst row number to draw
max_rowRow-number to stop drawing (the row-number of the row below the last row to draw)
selectedSelected entry by the user.
cur_rowCurrent row number (internal variable)
parent_lastLast-field booleans of parent page level (page level i sets bit i to 1 if it is its last field)
Returns
Row number of the next row to draw

Reimplemented from BaseSettingEntry.

Definition at line 1931 of file settings_gui.cpp.

References BaseSettingEntry::Draw(), SettingsContainer::Draw(), BaseSettingEntry::flags, folded, BaseSettingEntry::IsFiltered(), BaseSettingEntry::level, SEF_LAST_FIELD, and SetBit().

◆ DrawSetting()

void SettingsPage::DrawSetting ( GameSettings settings_ptr,
int  left,
int  right,
int  y,
bool  highlight 
) const
overrideprotectedvirtual

Function to draw setting value (button + text + current value)

Parameters
leftLeft-most position in window/panel to start drawing
rightRight-most position in window/panel to draw
yUpper-most position in window/panel to start drawing

Implements BaseSettingEntry.

Definition at line 1956 of file settings_gui.cpp.

References _circle_size, _current_text_dir, DrawSprite(), DrawString(), folded, FS_NORMAL, GetCharacterHeight(), WidgetDimensions::hsep_normal, WidgetDimensions::scaled, SETTING_HEIGHT, TD_RTL, and title.

◆ FindEntry()

BaseSettingEntry * SettingsPage::FindEntry ( uint  row_num,
uint *  cur_row 
)
overridevirtual

Find setting entry at row row_num.

Parameters
row_numIndex of entry to return
cur_rowCurrent row number
Returns
The requested setting entry or nullptr if it not found (folded or filtered)

Reimplemented from BaseSettingEntry.

Definition at line 1907 of file settings_gui.cpp.

References SettingsContainer::FindEntry(), folded, and BaseSettingEntry::IsFiltered().

◆ FoldAll()

void SettingsPage::FoldAll ( )
overridevirtual

Recursively close all (filtered) folds of sub-pages.

Reimplemented from BaseSettingEntry.

Definition at line 1819 of file settings_gui.cpp.

References SettingsContainer::FoldAll(), folded, and BaseSettingEntry::IsFiltered().

◆ GetFoldingState()

void SettingsPage::GetFoldingState ( bool &  all_folded,
bool &  all_unfolded 
) const
overridevirtual

Recursively accumulate the folding state of the (filtered) tree.

Parameters
[in,out]all_foldedSet to false, if one entry is not folded.
[in,out]all_unfoldedSet to false, if one entry is folded.

Reimplemented from BaseSettingEntry.

Definition at line 1841 of file settings_gui.cpp.

References folded, SettingsContainer::GetFoldingState(), and BaseSettingEntry::IsFiltered().

◆ GetMaxHelpHeight()

uint SettingsPage::GetMaxHelpHeight ( int  maxw)
inlineoverridevirtual

Reimplemented from BaseSettingEntry.

Definition at line 1346 of file settings_gui.cpp.

◆ Init()

void SettingsPage::Init ( uint8_t  level = 0)
overridevirtual

Initialization of an entire setting page.

Parameters
levelNesting level of this page (internal variable, do not provide a value for it when calling)

Reimplemented from BaseSettingEntry.

Definition at line 1804 of file settings_gui.cpp.

References BaseSettingEntry::Init(), SettingsContainer::Init(), and BaseSettingEntry::level.

◆ IsVisible()

bool SettingsPage::IsVisible ( const BaseSettingEntry item) const
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.

Parameters
itemEntry to search for.
Returns
true if entry is visible.

Reimplemented from BaseSettingEntry.

Definition at line 1883 of file settings_gui.cpp.

References folded, BaseSettingEntry::IsFiltered(), and SettingsContainer::IsVisible().

◆ Length()

uint SettingsPage::Length ( ) const
overridevirtual

Return number of rows needed to display the (filtered) entry.

Implements BaseSettingEntry.

Definition at line 1893 of file settings_gui.cpp.

References folded, BaseSettingEntry::IsFiltered(), and SettingsContainer::Length().

◆ ResetAll()

void SettingsPage::ResetAll ( )
overridevirtual

Resets all settings to their default values.

Implements BaseSettingEntry.

Definition at line 1811 of file settings_gui.cpp.

References SettingsContainer::entries.

◆ UnFoldAll()

void SettingsPage::UnFoldAll ( )
overridevirtual

Recursively open all (filtered) folds of sub-pages.

Reimplemented from BaseSettingEntry.

Definition at line 1828 of file settings_gui.cpp.

References folded, BaseSettingEntry::IsFiltered(), and SettingsContainer::UnFoldAll().

◆ UpdateFilterState()

bool SettingsPage::UpdateFilterState ( SettingFilter filter,
bool  force_visible 
)
overridevirtual

Update the filter state.

Parameters
filterFilter
force_visibleWhether to force all items visible, no matter what (due to filter text; not affected by restriction drop down box).
Returns
true if item remains visible

Implements BaseSettingEntry.

Definition at line 1860 of file settings_gui.cpp.

References StringFilter::AddLine(), CLRBITS, BaseSettingEntry::flags, StringFilter::GetState(), StringFilter::IsEmpty(), StringFilter::ResetState(), SEF_FILTERED, SETBITS, SettingFilter::string, title, and SettingsContainer::UpdateFilterState().

Field Documentation

◆ folded

bool SettingsPage::folded

Sub-page is folded (not visible except for its title)

Definition at line 1333 of file settings_gui.cpp.

Referenced by Draw(), DrawSetting(), FindEntry(), FoldAll(), GetFoldingState(), IsVisible(), Length(), GameSettingsWindow::OnClick(), SettingsPage(), and UnFoldAll().

◆ title

StringID SettingsPage::title

Title of the sub-page.

Definition at line 1332 of file settings_gui.cpp.

Referenced by DrawSetting(), SettingsPage(), and UpdateFilterState().


The documentation for this struct was generated from the following file: