Public Member Functions | Data Fields | Private Member Functions

# SettingEntry Struct Reference

Data structure describing a single setting in a tab. More...

## Public Member Functions
| SettingEntry (const char *nm)
| Constructor for a single setting in the 'advanced settings' window.
| SettingEntry (SettingsPage *sub, StringID title)
| Constructor for a sub-page in the 'advanced settings' window.
void | Init (byte level)
| Initialization of a setting entry.
void | FoldAll ()
| Recursively close all (filtered) folds of sub-pages.
void | UnFoldAll ()
| Recursively open all (filtered) folds of sub-pages.
void | SetButtons (byte new_val)
| Set the button-depressed flags (SEF_LEFT_DEPRESSED and SEF_RIGHT_DEPRESSED) to a specified value.
void | SetLastField (bool last_field)
| Set whether this is the last visible entry of the parent node.
uint | Length () const
| Return numbers of rows needed to display the (filtered) entry.
void | GetFoldingState (bool &all_folded, bool &all_unfolded) const
| Recursively accumulate the folding state of the (filtered) tree.
bool | IsVisible (const SettingEntry *item) const
| Check whether an entry is visible and not folded or filtered away.
SettingEntry * | FindEntry (uint row, uint *cur_row)
| Find setting entry at row row_num.
uint | GetMaxHelpHeight (int maxw)
| Get the biggest height of the help text(s), if the width is at least maxw.
bool | IsFiltered () const
| Check whether an entry is hidden due to filters.
bool | UpdateFilterState (SettingFilter &filter, bool force_visible)
| Update the filter state.
uint | Draw (GameSettings *settings_ptr, int base_x, int base_y, int max_x, uint first_row, uint max_row, uint cur_row, uint parent_last, SettingEntry *selected)
| Draw a row in the settings panel.
StringID | GetHelpText ()
| Get the help text of a single setting.
void | SetValueDParams (uint first_param, int32 value)
| Set the DParams for drawing the value of a setting.
## Data Fields
byte | flags
| Flags of the setting entry.
byte | level
| Nesting level of this setting entry.
union {
SettingEntrySetting entry
| Data fields if entry is a setting.
SettingEntrySubtree sub
| Data fields if entry is a sub-page.
} | d
| Data fields for each kind.
## Private Member Functions
void | DrawSetting (GameSettings *settings_ptr, int x, int y, int max_x, int state, bool highlight)
| Private function to draw setting value (button + text + current value).
bool | IsVisibleByRestrictionMode (RestrictionMode mode) const
| Checks whether an entry shall be made visible based on the restriction mode.

## Detailed Description

Data structure describing a single setting in a tab.

Definition at line 740 of file settings_gui.cpp.

## Constructor & Destructor Documentation

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

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

Parameters:

  | nm | Name of the setting in the setting table

Definition at line 817 of file settings_gui.cpp.

References d, flags, and level.

SettingEntry::SettingEntry | ( | SettingsPage * | sub,
|  | StringID | title |
| ) |  |  |

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

Parameters:

  | sub | Sub-page
  | title | Title of the sub-page

Definition at line 831 of file settings_gui.cpp.

References d, flags, and level.

## Member Function Documentation

uint SettingEntry::Draw | ( | GameSettings * | settings_ptr,
|  | int | left,
|  | int | right,
|  | int | base_y,
|  | uint | first_row,
|  | uint | max_row,
|  | uint | cur_row,
|  | uint | parent_last,
|  | SettingEntry * | selected |
| ) |  |  |

Draw a row in the settings panel.

See SettingsPage::Draw() for an explanation about how drawing is performed.

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.

Parameters:

  | 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.
  | base_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)
  | 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)
  | selected | Selected entry by the user.

Returns:
  Row number of the next row to draw

Definition at line 1137 of file settings_gui.cpp.

References _colour_gradient, _current_text_dir, d, DrawSetting(), DrawSprite(), DrawString(), flags, HasBit(), IsFiltered(), level, SEF_BUTTONS_MASK, SEF_KIND_MASK, SEF_LAST_FIELD, SEF_SETTING_KIND, SEF_SUBTREE_KIND, and SetBit().

Referenced by SettingsPage::Draw().

void SettingEntry::DrawSetting | ( | GameSettings * | settings_ptr,
|  | int | left,
|  | int | right,
|  | int | y,
|  | int | state,
|  | bool | highlight |
| ) |  |  | `[private]`

Private 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
  | state | State of the left + right arrow buttons to draw for the setting
  | highlight | Highlight entry.

Definition at line 1240 of file settings_gui.cpp.

References _current_text_dir, SettingDescBase::cmd, SaveLoad::conv, d, SettingDesc::desc, DrawArrowButtons(), DrawBoolButton(), DrawDropDownButton(), DrawString(), SettingDescBase::flags, SettingDesc::IsEditable(), SettingDescBase::max, SettingDescBase::min, ReadValue(), SettingDesc::save, SDT_BOOLX, SetDParam(), SETTING_BUTTON_HEIGHT, SETTING_BUTTON_WIDTH, SetValueDParams(), SGF_0ISDISABLED, SGF_MULTISTRING, and SettingDescBase::str.

Referenced by Draw().

SettingEntry * SettingEntry::FindEntry | ( | uint | row_num,
|  | uint * | cur_row |
| ) |  |  |

Find setting entry at row row_num.

Parameters:

  | row_num | Index of entry to return
  | cur_row | Current row number

Returns:
  The requested setting entry or `NULL` if it not found (folded or filtered)

Definition at line 973 of file settings_gui.cpp.

References d, flags, IsFiltered(), SEF_KIND_MASK, SEF_SETTING_KIND, and SEF_SUBTREE_KIND.

Referenced by SettingsPage::FindEntry().

void SettingEntry::GetFoldingState | ( | bool & | all_folded,
|  | bool & | all_unfolded |
| ) |  |  | const

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

Parameters:

  `[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.

Definition at line 899 of file settings_gui.cpp.

References d, flags, IsFiltered(), SEF_KIND_MASK, SEF_SETTING_KIND, and SEF_SUBTREE_KIND.

Referenced by SettingsPage::GetFoldingState().

StringID SettingEntry::GetHelpText | ( |  | ) | `[inline]`

Get the help text of a single setting.

Returns:
  The requested help text.

Definition at line 777 of file settings_gui.cpp.

References d, flags, SEF_KIND_MASK, and SEF_SETTING_KIND.

Referenced by GetMaxHelpHeight(), and UpdateFilterState().

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

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 1000 of file settings_gui.cpp.

References d, flags, GetHelpText(), GetStringHeight(), SEF_KIND_MASK, SEF_SETTING_KIND, and SEF_SUBTREE_KIND.

void SettingEntry::Init | ( | byte | level | ) |

Initialization of a setting entry.

Parameters:

  | level | Page nesting level of this entry

Definition at line 844 of file settings_gui.cpp.

References d, flags, GetSettingFromName(), SEF_KIND_MASK, SEF_SETTING_KIND, and SEF_SUBTREE_KIND.

Referenced by SettingsPage::Init().

bool SettingEntry::IsFiltered | ( |  | ) | const

Check whether an entry is hidden due to filters.

Returns:
  true if hidden.

Definition at line 1013 of file settings_gui.cpp.

References flags, and SEF_FILTERED.

Referenced by Draw(), FindEntry(), FoldAll(), GetFoldingState(), IsVisible(), Length(), and UnFoldAll().

bool SettingEntry::IsVisible | ( | const SettingEntry * | 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:

  | item | Entry to search for.

Returns:
  true if entry is visible.

Definition at line 925 of file settings_gui.cpp.

References d, flags, IsFiltered(), SEF_KIND_MASK, SEF_SETTING_KIND, and SEF_SUBTREE_KIND.

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 1023 of file settings_gui.cpp.

References _settings_newgame, SaveLoad::conv, d, SettingDescBase::def, SettingDesc::desc, flags, GetGameSettings(), ReadValue(), RM_ADVANCED, RM_ALL, RM_BASIC, RM_CHANGED_AGAINST_DEFAULT, RM_CHANGED_AGAINST_NEW, SettingDesc::save, SC_ADVANCED_LIST, SC_BASIC_LIST, SEF_KIND_MASK, and SEF_SETTING_KIND.

Referenced by UpdateFilterState().

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 946 of file settings_gui.cpp.

References flags, and SEF_BUTTONS_MASK.

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

void SettingEntry::SetLastField | ( | bool | last_field | ) | `[inline]`

Set whether this is the last visible entry of the parent node.

Parameters:

  | last_field | Value to set

Definition at line 760 of file settings_gui.cpp.

References CLRBITS, flags, SEF_LAST_FIELD, and SETBITS.

Referenced by SettingsPage::UpdateFilterState().

void SettingEntry::SetValueDParams | ( | uint | first_param,
|  | int32 | value |
| ) |  |  |

Set the DParams for drawing the value of a setting.

Parameters:

  | first_param | First DParam to use
  | value | Setting value to set params for.

Definition at line 1212 of file settings_gui.cpp.

References abs(), SettingDescBase::cmd, d, SettingDescBase::flags, flags, SettingDescBase::min, SDT_BOOLX, SEF_KIND_MASK, SEF_SETTING_KIND, SetDParam(), SGF_0ISDISABLED, SGF_DISPLAY_ABS, SGF_MULTISTRING, and SettingDescBase::str_val.

Referenced by DrawSetting(), and GameSettingsWindow::DrawWidget().

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

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

Definition at line 1068 of file settings_gui.cpp.

References StringFilter::AddLine(), CLRBITS, d, SettingDesc::desc, flags, GetHelpText(), StringFilter::GetState(), SettingDesc::GetType(), StringFilter::IsEmpty(), IsVisibleByRestrictionMode(), SettingFilter::mode, StringFilter::ResetState(), SEF_FILTERED, SEF_KIND_MASK, SEF_SETTING_KIND, SEF_SUBTREE_KIND, SETBITS, SetDParam(), ST_ALL, SettingDescBase::str, SettingFilter::string, and SettingFilter::type.

Referenced by SettingsPage::UpdateFilterState().

## Field Documentation

byte SettingEntry::flags

Flags of the setting entry.

See also:
  SettingEntryFlags

Definition at line 741 of file settings_gui.cpp.

Referenced by Draw(), FindEntry(), FoldAll(), GetFoldingState(), GetHelpText(), GetMaxHelpHeight(), Init(), IsFiltered(), IsVisible(), IsVisibleByRestrictionMode(), Length(), GameSettingsWindow::OnClick(), GameSettingsWindow::OnQueryTextFinished(), SetButtons(), SetLastField(), SettingEntry(), SetValueDParams(), UnFoldAll(), and UpdateFilterState().

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

- src/settings_gui.cpp