OpenTTD Source: SettingEntry Struct Reference

OpenTTD Source 14.0-beta3

Public Member Functions | Data Fields | Protected Member Functions | Private Member Functions
SettingEntry Struct Reference

Standard setting. More...

Inheritance diagram for SettingEntry:

## Public Member Functions
| SettingEntry (const char *name)
| Constructor for a single setting in the 'advanced settings' window. More...
void | Init (byte level=0) override
| Initialization of a setting entry. More...
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. More...
bool | UpdateFilterState (SettingFilter &filter, bool force_visible) override
| Update the filter state. More...
void | SetButtons (byte new_val)
| Set the button-depressed flags (SEF_LEFT_DEPRESSED and SEF_RIGHT_DEPRESSED) to a specified value. More...
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. More...
virtual void | GetFoldingState ([[maybe_unused]] bool &all_folded, [[maybe_unused]] bool &all_unfolded) const
virtual bool | IsVisible (const BaseSettingEntry *item) const
| Check whether an entry is visible and not folded or filtered away. More...
virtual BaseSettingEntry * | FindEntry (uint row, uint *cur_row)
| Find setting entry at row row_num. More...
virtual uint | GetMaxHelpHeight ([[maybe_unused]] int maxw)
bool | IsFiltered () const
| Check whether an entry is hidden due to filters. More...
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. More...

## Data Fields
const char * | name
| Name of the setting.
const IntSettingDesc * | setting
| Setting description of the setting.
Data Fields inherited from BaseSettingEntry
byte | flags
| Flags of the setting entry. More...
byte | 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) More...

## Private Member Functions
bool | IsVisibleByRestrictionMode (RestrictionMode mode) const
| Checks whether an entry shall be made visible based on the restriction mode. More...

## Detailed Description

Standard setting.

Definition at line 1264 of file settings_gui.cpp.

## Constructor & Destructor Documentation

## ◆ SettingEntry()

SettingEntry::SettingEntry | ( | const char * | name | ) |

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

Parameters

  name | Name of the setting in the setting table

Definition at line 1445 of file settings_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_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 | Highlight entry.

Implements BaseSettingEntry.

Definition at line 1592 of file settings_gui.cpp.

## ◆ GetMaxHelpHeight()

uint SettingEntry::GetMaxHelpHeight | ( | int | maxw | ) |
| override

Get the biggest height of the help text(s), if the width is at least maxw.

Help text gets wrapped if needed.

Parameters

  maxw | Maximal width of a line help text.

Returns
  Biggest height needed to display any help text of this node (and its descendants).

Definition at line 1489 of file settings_gui.cpp.

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

## ◆ Init()

void SettingEntry::Init | ( | byte | level = `0` | ) |
| overridevirtual

Initialization of a setting entry.

Parameters

  level | Page nesting level of this entry

Reimplemented from BaseSettingEntry.

Definition at line 1455 of file settings_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

  mode | The current status of the restriction drop down box.

Returns
  true if the entry shall be visible.

Definition at line 1499 of file settings_gui.cpp.

References IntSettingDesc::cat, RM_ADVANCED, RM_ALL, RM_BASIC, SC_ADVANCED_LIST, SC_BASIC_LIST, and setting.

Referenced by UpdateFilterState().

## ◆ SetButtons()

void SettingEntry::SetButtons | ( | byte | new_val | ) |

Set the button-depressed flags (SEF_LEFT_DEPRESSED and SEF_RIGHT_DEPRESSED) to a specified value.

Parameters

  new_val | New value for the button flags

See also
  SettingEntryFlags

Definition at line 1472 of file settings_gui.cpp.

References BaseSettingEntry::flags, and SEF_BUTTONS_MASK.

Referenced by GameSettingsWindow::OnPaint().

## ◆ UpdateFilterState()

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

Update the filter state.

Parameters

  filter | Filter
  force_visible | Whether 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 1540 of file settings_gui.cpp.

References StringFilter::AddLine(), CLRBITS, BaseSettingEntry::flags, IntSettingDesc::GetHelp(), StringFilter::GetState(), IntSettingDesc::GetTitle(), SettingDesc::GetType(), StringFilter::IsEmpty(), IsVisibleByRestrictionMode(), SettingFilter::min_cat, SettingFilter::mode, StringFilter::ResetState(), RM_ALL, SEF_FILTERED, SETBITS, SetDParam(), setting, ST_ALL, SettingFilter::string, SettingFilter::type, and SettingFilter::type_hides.

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

- src/settings_gui.cpp