OpenTTD Source 20250312-master-gcdcc6b491d
SettingEntry Struct Reference

Standard setting. More...

#include <settingentry_gui.h>

Inheritance diagram for SettingEntry:
BaseSettingEntry

Public Member Functions

 SettingEntry (const char *name)
 Constructor for a single setting in the 'advanced settings' window.
 
void Init (uint8_t level=0) override
 Initialization of a setting entry.
 
void ResetAll () override
 
uint Length () const override
 Return number of rows needed to display the (filtered) entry.
 
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.
 
void SetButtons (SettingEntryFlags new_val)
 Set the button-depressed flags (#SettingsEntryFlag::LeftDepressed and #SettingsEntryFlag::RightDepressed) to a specified value.
 
- Public Member Functions inherited from BaseSettingEntry
virtual void FoldAll ()
 
virtual void UnFoldAll ()
 
void SetLastField (bool last_field)
 Set whether this is the last visible entry of the parent node.
 
virtual void GetFoldingState (bool &all_folded, bool &all_unfolded) const
 
virtual bool IsVisible (const BaseSettingEntry *item) const
 Check whether an entry is visible and not folded or filtered away.
 
virtual BaseSettingEntryFindEntry (uint row, uint *cur_row)
 Find setting entry at row row_num.
 
bool IsFiltered () const
 Check whether an entry is hidden due to filters.
 
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.
 

Data Fields

const char * name
 Name of the setting.
 
const IntSettingDescsetting
 Setting description of the setting.
 
- Data Fields inherited from BaseSettingEntry
SettingEntryFlags flags
 Flags of the setting entry.
 
uint8_t level
 Nesting level of this setting entry.
 

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)
 

Private Member Functions

bool IsVisibleByRestrictionMode (RestrictionMode mode) const
 Checks whether an entry shall be made visible based on the restriction mode.
 

Detailed Description

Standard setting.

Definition at line 94 of file settingentry_gui.h.

Constructor & Destructor Documentation

◆ SettingEntry()

SettingEntry::SettingEntry ( const char *  name)

Constructor for a single setting in the 'advanced settings' window.

Parameters
nameName of the setting in the setting table

Definition at line 130 of file settingentry_gui.cpp.

References name, and setting.

Member Function Documentation

◆ DrawSetting()

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

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

Parameters
settings_ptrPointer to current values of all settings
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
highlightHighlight entry.

Implements BaseSettingEntry.

Definition at line 277 of file settingentry_gui.cpp.

References _current_text_dir, DrawArrowButtons(), DrawBoolButton(), DrawDropDownButton(), DrawString(), BaseSettingEntry::flags, SettingDesc::flags, FS_NORMAL, GetCharacterHeight(), IntSettingDesc::GetRange(), GetString(), IntSettingDesc::GetTitle(), IntSettingDesc::GetValueParams(), GuiDropdown, GuiZeroIsSpecial, WidgetDimensions::hsep_wide, IntSettingDesc::IsBoolSetting(), SettingDesc::IsEditable(), IntSettingDesc::Read(), WidgetDimensions::scaled, SEF_BUTTONS_MASK, setting, SETTING_BUTTON_HEIGHT, SETTING_BUTTON_WIDTH, SETTING_HEIGHT, TD_RTL, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

◆ GetMaxHelpHeight()

uint SettingEntry::GetMaxHelpHeight ( int  maxw)
overridevirtual

Get the biggest height of the help text(s), 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 node (and its descendants).

Reimplemented from BaseSettingEntry.

Definition at line 175 of file settingentry_gui.cpp.

References IntSettingDesc::GetHelp(), GetStringHeight(), and setting.

◆ Init()

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

Initialization of a setting entry.

Parameters
levelPage nesting level of this entry

Reimplemented from BaseSettingEntry.

Definition at line 140 of file settingentry_gui.cpp.

References SettingDesc::AsIntSetting(), GetSettingFromName(), BaseSettingEntry::Init(), BaseSettingEntry::level, name, and setting.

◆ IsVisibleByRestrictionMode()

bool SettingEntry::IsVisibleByRestrictionMode ( RestrictionMode  mode) const
private

Checks whether an entry shall be made visible based on the restriction mode.

Parameters
modeThe current status of the restriction drop down box.
Returns
true if the entry shall be visible.

Definition at line 185 of file settingentry_gui.cpp.

References _settings_newgame, IntSettingDesc::cat, IntSettingDesc::GetDefaultValue(), GetGameSettings(), IntSettingDesc::Read(), RM_ADVANCED, RM_ALL, RM_BASIC, RM_CHANGED_AGAINST_DEFAULT, RM_CHANGED_AGAINST_NEW, SC_ADVANCED_LIST, SC_BASIC_LIST, and setting.

Referenced by UpdateFilterState().

◆ Length()

uint SettingEntry::Length ( ) const
overridevirtual

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

Implements BaseSettingEntry.

Definition at line 165 of file settingentry_gui.cpp.

References BaseSettingEntry::IsFiltered().

◆ ResetAll()

void SettingEntry::ResetAll ( )
overridevirtual

Implements BaseSettingEntry.

Definition at line 147 of file settingentry_gui.cpp.

◆ SetButtons()

void SettingEntry::SetButtons ( SettingEntryFlags  new_val)

Set the button-depressed flags (#SettingsEntryFlag::LeftDepressed and #SettingsEntryFlag::RightDepressed) to a specified value.

Parameters
new_valNew value for the button flags
See also
SettingEntryFlags

Definition at line 157 of file settingentry_gui.cpp.

References BaseSettingEntry::flags, LeftDepressed, RightDepressed, SEF_BUTTONS_MASK, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

Referenced by GameSettingsWindow::OnClick(), GameSettingsWindow::OnPaint(), and GameSettingsWindow::OnTimeout().

◆ UpdateFilterState()

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

Field Documentation

◆ name

const char* SettingEntry::name

Name of the setting.

Definition at line 95 of file settingentry_gui.h.

Referenced by Init(), and SettingEntry().

◆ setting


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