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

Standard setting. More...

Inheritance diagram for SettingEntry:
BaseSettingEntry

Public Member Functions

 SettingEntry (const char *name)
 Constructor for a single setting in the 'advanced settings' window.
virtual void Init (byte level=0)
 Initialization of a setting entry.
virtual uint Length () const
 Return number of rows needed to display the (filtered) entry.
virtual uint GetMaxHelpHeight (int maxw)
 Get the biggest height of the help text(s), if the width is at least maxw.
virtual bool UpdateFilterState (SettingFilter &filter, bool force_visible)
 Update the filter state.
void SetButtons (byte new_val)
 Set the button-depressed flags (SEF_LEFT_DEPRESSED and SEF_RIGHT_DEPRESSED) to a specified value.
StringID GetHelpText () const
 Get the help text of a single setting.
void SetValueDParams (uint first_param, int32 value) const
 Set the DParams for drawing the value of a setting.
- 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 SettingDescsetting
 Setting description of the setting.
uint index
 Index of the setting in the settings table.
- Data Fields inherited from BaseSettingEntry
byte flags
 Flags of the setting entry.
byte level
 Nesting level of this setting entry.

Protected Member Functions

virtual void DrawSetting (GameSettings *settings_ptr, int left, int right, int y, bool highlight) const
 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 745 of file settings_gui.cpp.

Constructor & Destructor Documentation

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

References index, name, and setting.

Member Function Documentation

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

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

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

StringID SettingEntry::GetHelpText ( ) const
inline

Get the help text of a single setting.

Returns
The requested help text.

Definition at line 763 of file settings_gui.cpp.

References SettingDesc::desc, setting, and SettingDescBase::str_help.

Referenced by GetMaxHelpHeight(), and UpdateFilterState().

uint SettingEntry::GetMaxHelpHeight ( int  maxw)
virtual

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

References GetHelpText(), and GetStringHeight().

void SettingEntry::Init ( byte  level = 0)
virtual

Initialization of a setting entry.

Parameters
levelPage nesting level of this entry

Reimplemented from BaseSettingEntry.

Definition at line 947 of file settings_gui.cpp.

References GetSettingFromName(), index, name, and setting.

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

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

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_valNew value for the button flags
See Also
SettingEntryFlags

Definition at line 959 of file settings_gui.cpp.

References BaseSettingEntry::flags, and SEF_BUTTONS_MASK.

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

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

Set the DParams for drawing the value of a setting.

Parameters
first_paramFirst DParam to use
valueSetting value to set params for.

Definition at line 1084 of file settings_gui.cpp.

References abs(), SettingDescBase::cmd, SettingDesc::desc, SettingDescBase::flags, SettingDescBase::min, SDT_BOOLX, SetDParam(), setting, 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 
)
virtual

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

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


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