OpenTTD Source 20241224-master-gee860a5c8e
SettingsContainer Struct Reference

Containers for BaseSettingEntry. More...

Inheritance diagram for SettingsContainer:
SettingsPage

Public Types

typedef std::vector< BaseSettingEntry * > EntryVector
 

Public Member Functions

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

EntryVector entries
 Settings on this page.
 

Detailed Description

Containers for BaseSettingEntry.

Definition at line 1303 of file settings_gui.cpp.

Member Typedef Documentation

◆ EntryVector

typedef std::vector<BaseSettingEntry*> SettingsContainer::EntryVector

Definition at line 1304 of file settings_gui.cpp.

Member Function Documentation

◆ Add()

template<typename T >
T * SettingsContainer::Add ( T *  item)
inline

Definition at line 1308 of file settings_gui.cpp.

◆ Draw()

uint SettingsContainer::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.

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

Definition at line 1779 of file settings_gui.cpp.

References entries.

Referenced by SettingsPage::Draw(), and GameSettingsWindow::DrawWidget().

◆ FindEntry()

BaseSettingEntry * SettingsContainer::FindEntry ( uint  row_num,
uint *  cur_row 
)

Find the setting entry at row number row_num.

Parameters
row_numIndex of entry to return
cur_rowVariable used for keeping track of the current row number. Should point to memory initialized to 0 when first called.
Returns
The requested setting entry or nullptr if it does not exist

Definition at line 1738 of file settings_gui.cpp.

References entries, and BaseSettingEntry::FindEntry().

Referenced by SettingsPage::FindEntry(), and GameSettingsWindow::OnClick().

◆ FoldAll()

void SettingsContainer::FoldAll ( )

Recursively close all folds of sub-pages.

Definition at line 1662 of file settings_gui.cpp.

References entries.

Referenced by SettingsPage::FoldAll(), GameSettingsWindow::OnClick(), and ResetAllSettingsConfirmationCallback().

◆ GetFoldingState()

void SettingsContainer::GetFoldingState ( bool &  all_folded,
bool &  all_unfolded 
) const

Recursively accumulate the folding state of the 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.

Definition at line 1682 of file settings_gui.cpp.

References entries.

Referenced by SettingsPage::GetFoldingState(), and GameSettingsWindow::OnInvalidateData().

◆ GetMaxHelpHeight()

uint SettingsContainer::GetMaxHelpHeight ( int  maxw)

Get the biggest height of the help texts, if the width is at least maxw.

Help text gets wrapped if needed.

Parameters
maxwMaximal width of a line help text.
Returns
Biggest height needed to display any help text of this (sub-)tree.

Definition at line 1755 of file settings_gui.cpp.

References entries.

◆ Init()

void SettingsContainer::Init ( uint8_t  level = 0)

Initialization of an entire setting page.

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

Definition at line 1646 of file settings_gui.cpp.

References entries.

Referenced by SettingsPage::Init().

◆ IsVisible()

bool SettingsContainer::IsVisible ( const BaseSettingEntry item) const

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.

Definition at line 1714 of file settings_gui.cpp.

References entries.

Referenced by SettingsPage::IsVisible().

◆ Length()

uint SettingsContainer::Length ( ) const

Return number of rows needed to display the whole page.

Definition at line 1723 of file settings_gui.cpp.

References entries.

Referenced by SettingsPage::Length().

◆ ResetAll()

void SettingsContainer::ResetAll ( )

Resets all settings to their default values.

Definition at line 1654 of file settings_gui.cpp.

References entries.

Referenced by ResetAllSettingsConfirmationCallback().

◆ UnFoldAll()

void SettingsContainer::UnFoldAll ( )

Recursively open all folds of sub-pages.

Definition at line 1670 of file settings_gui.cpp.

References entries.

Referenced by GameSettingsWindow::OnClick(), GameSettingsWindow::OnDropdownSelect(), GameSettingsWindow::OnEditboxChanged(), and SettingsPage::UnFoldAll().

◆ UpdateFilterState()

bool SettingsContainer::UpdateFilterState ( SettingFilter filter,
bool  force_visible 
)

Update the filter state.

Parameters
filterFilter
force_visibleWhether to force all items visible, no matter what
Returns
true if item remains visible

Definition at line 1695 of file settings_gui.cpp.

References entries.

Referenced by GameSettingsWindow::OnDropdownSelect(), GameSettingsWindow::OnInvalidateData(), and SettingsPage::UpdateFilterState().

Field Documentation

◆ entries

EntryVector SettingsContainer::entries

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