OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

Data Structures | Enumerations | Functions | Variables
settings_gui.cpp File Reference

GUI for settings. More...

`#include "stdafx.h"`
`#include "currency.h"`
`#include "error.h"`
`#include "settings_gui.h"`
`#include "textbuf_gui.h"`
`#include "command_func.h"`
`#include "network/network.h"`
`#include "town.h"`
`#include "settings_internal.h"`
`#include "newgrf_townname.h"`
`#include "strings_func.h"`
`#include "window_func.h"`
`#include "string_func.h"`
`#include "widgets/dropdown_type.h"`
`#include "widgets/dropdown_func.h"`
`#include "highscore.h"`
`#include "base_media_base.h"`
`#include "company_base.h"`
`#include "company_func.h"`
`#include "viewport_func.h"`
`#include "core/geometry_func.hpp"`
`#include "ai/ai.hpp"`
`#include "blitter/factory.hpp"`
`#include "language.h"`
`#include "textfile_gui.h"`
`#include "stringfilter_type.h"`
`#include "querystring_gui.h"`
`#include <vector>`
`#include "safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | BaseSetTextfileWindow< TBaseSet >
| Window for displaying the textfile of a BaseSet. More...
struct | GameOptionsWindow
struct | SettingFilter
| Filter for settings list. More...
struct | BaseSettingEntry
| Data structure describing a single setting in a tab. More...
struct | SettingEntry
| Standard setting. More...
struct | SettingsContainer
| Containers for BaseSettingEntry. More...
struct | SettingsPage
| Data structure describing one page of settings in the settings window. More...
struct | GameSettingsWindow
| Window to edit settings of the game. More...
struct | CustomCurrencyWindow

## Enumerations
enum | SettingEntryFlags { SEF_LEFT_DEPRESSED = 0x01, SEF_RIGHT_DEPRESSED = 0x02, SEF_BUTTONS_MASK = (SEF_LEFT_DEPRESSED | SEF_RIGHT_DEPRESSED), SEF_LAST_FIELD = 0x04, SEF_FILTERED = 0x08 }
| Flags for SettingEntry. More...
enum | RestrictionMode { RM_BASIC, RM_ADVANCED, RM_ALL, RM_CHANGED_AGAINST_DEFAULT, RM_CHANGED_AGAINST_NEW, RM_END }
| How the list of advanced settings is filtered. More...
enum | WarnHiddenResult { WHR_NONE, WHR_CATEGORY, WHR_TYPE, WHR_CATEGORY_TYPE }
| Warnings about hidden search results. More...

## Functions
static const void * | ResolveVariableAddress (const GameSettings *settings_ptr, const SettingDesc *sd)
void | InitGRFTownGeneratorNames ()
| Allocate memory for the NewGRF town names.
static StringID | TownName (int town_name)
| Get a town name.
static int | GetCurRes ()
| Get index of the current screen resolution.
static void | ShowCustCurrency ()
| Open custom currency window.
template<class T >
static DropDownList * | BuiltSetDropDownList (int *selected_index)
template<class TBaseSet >
void | ShowBaseSetTextfileWindow (TextfileType file_type, const TBaseSet *baseset, StringID content_type)
| Open the BaseSet version of the textfile window.
void | ShowGameOptions ()
| Open the game options window.
static SettingsContainer & | GetSettingsTree ()
| Construct settings tree.
| assert_compile (lengthof(_game_settings_restrict_dropdown)==RM_END)
void | ShowGameSettings ()
| Open advanced settings window.
void | DrawArrowButtons (int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right)
| Draw [<][>] boxes.
void | DrawDropDownButton (int x, int y, Colours button_colour, bool state, bool clickable)
| Draw a dropdown button.
void | DrawBoolButton (int x, int y, bool state, bool clickable)
| Draw a toggle button.

## Variables
static const StringID | _driveside_dropdown []
static const StringID | _autosave_dropdown []
static const StringID | _gui_zoom_dropdown []
int | _nb_orig_names = SPECSTR_TOWNNAME_LAST - SPECSTR_TOWNNAME_START + 1
| Number of original town names.
static StringID * | _grf_names = NULL
| Pointer to town names defined by NewGRFs.
static int | _nb_grf_names = 0
| Number of town names defined by NewGRFs.
static Dimension | _circle_size
| Dimension of the circle +/- icon. This is here as not all users are within the class of the settings window.
static const NWidgetPart | _nested_game_options_widgets []
static WindowDesc | _game_options_desc (WDP_CENTER,"settings_game", 0, 0, WC_GAME_OPTIONS, WC_NONE, 0, _nested_game_options_widgets, lengthof(_nested_game_options_widgets))
static int | SETTING_HEIGHT = 11
| Height of a single setting in the tree view in pixels.
static const int | LEVEL_WIDTH = 15
| Indenting width of a sub-page in pixels.
static const StringID | _game_settings_restrict_dropdown []
static const NWidgetPart | _nested_settings_selection_widgets []
static WindowDesc | _settings_selection_desc (WDP_CENTER,"settings", 510, 450, WC_GAME_OPTIONS, WC_NONE, 0, _nested_settings_selection_widgets, lengthof(_nested_settings_selection_widgets))
static const NWidgetPart | _nested_cust_currency_widgets []
static WindowDesc | _cust_currency_desc (WDP_CENTER, NULL, 0, 0, WC_CUSTOM_CURRENCY, WC_NONE, 0, _nested_cust_currency_widgets, lengthof(_nested_cust_currency_widgets))

## Detailed Description

GUI for settings.

Definition in file settings_gui.cpp.

## Enumeration Type Documentation

enum RestrictionMode

How the list of advanced settings is filtered.

Enumerator:

  RM_BASIC | Display settings associated to the "basic" list.
  RM_ADVANCED | Display settings associated to the "advanced" list.
  RM_ALL | List all settings regardless of the default/newgame/... values.
  RM_CHANGED_AGAINST_DEFAULT | Show only settings which are different compared to default values.
  RM_CHANGED_AGAINST_NEW | Show only settings which are different compared to the user's new game setting values.
  RM_END | End for iteration.

Definition at line 688 of file settings_gui.cpp.

enum SettingEntryFlags

Flags for SettingEntry.

Note
  The SEF_BUTTONS_MASK matches expectations of the formal parameter 'state' of DrawArrowButtons

Enumerator:

  SEF_LEFT_DEPRESSED | Of a numeric setting entry, the left button is depressed.
  SEF_RIGHT_DEPRESSED | Of a numeric setting entry, the right button is depressed.
  SEF_BUTTONS_MASK | Bit-mask for button flags.
  SEF_LAST_FIELD | This entry is the last one in a (sub-)page.
  SEF_FILTERED | Entry is hidden by the string filter.

Definition at line 678 of file settings_gui.cpp.

enum WarnHiddenResult

Warnings about hidden search results.

Enumerator:

  WHR_NONE | Nothing was filtering matches away.
  WHR_CATEGORY | Category setting filtered matches away.
  WHR_TYPE | Type setting filtered matches away.
  WHR_CATEGORY_TYPE | Both category and type settings filtered matches away.

Definition at line 1762 of file settings_gui.cpp.

## Function Documentation

void DrawArrowButtons | ( | int | x,
|  | int | y,
|  | Colours | button_colour,
|  | byte | state,
|  | bool | clickable_left,
|  | bool | clickable_right
| ) |  |

Draw [<][>] boxes.

Parameters

  x | the x position to draw
  y | the y position to draw
  button_colour | the colour of the button
  state | 0 = none clicked, 1 = first clicked, 2 = second clicked
  clickable_left | is the left button clickable?
  clickable_right | is the right button clickable?

Definition at line 2391 of file settings_gui.cpp.

References _colour_gradient, _current_text_dir, DrawFrameRect(), DrawSprite(), FILLRECT_CHECKER, FR_LOWERED, GfxFillRect(), TD_RTL, WD_IMGBTN_LEFT, and WD_IMGBTN_TOP.

Referenced by IndustryViewWindow::DrawInfo(), SettingEntry::DrawSetting(), CheatWindow::DrawWidget(), NewGRFParametersWindow::DrawWidget(), and AISettingsWindow::DrawWidget().

void DrawBoolButton | ( | int | x,
|  | int | y,
|  | bool | state,
|  | bool | clickable
| ) |  |

Draw a toggle button.

Parameters

  x | the x position to draw
  y | the y position to draw
  state | true = lowered
  clickable | is the button clickable?

Definition at line 2438 of file settings_gui.cpp.

References DrawFrameRect(), FR_LOWERED, SETTING_BUTTON_HEIGHT, and SETTING_BUTTON_WIDTH.

Referenced by SettingEntry::DrawSetting(), CheatWindow::DrawWidget(), NewGRFParametersWindow::DrawWidget(), and AISettingsWindow::DrawWidget().

void DrawDropDownButton | ( | int | x,
|  | int | y,
|  | Colours | button_colour,
|  | bool | state,
|  | bool | clickable
| ) |  |

Draw a dropdown button.

Parameters

  x | the x position to draw
  y | the y position to draw
  button_colour | the colour of the button
  state | true = lowered
  clickable | is the button clickable?

Definition at line 2419 of file settings_gui.cpp.

References _colour_gradient, DrawFrameRect(), DrawSprite(), FILLRECT_CHECKER, FR_LOWERED, GfxFillRect(), SETTING_BUTTON_HEIGHT, and SETTING_BUTTON_WIDTH.

Referenced by SettingEntry::DrawSetting(), NewGRFParametersWindow::DrawWidget(), and AISettingsWindow::DrawWidget().

static int GetCurRes | ( |  | ) |
| static

Get index of the current screen resolution.

Returns
  Index of the current screen resolution if it is a known resolution, _num_resolutions otherwise.

Definition at line 101 of file settings_gui.cpp.

References _num_resolutions, and _resolutions.

Referenced by GameOptionsWindow::BuildDropDownList(), and GameOptionsWindow::SetStringParameters().

void InitGRFTownGeneratorNames | ( |  | ) |

Allocate memory for the NewGRF town names.

Definition at line 76 of file settings_gui.cpp.

References _grf_names, _nb_grf_names, free(), and INVALID_STRING_ID.

Referenced by AfterLoadGRFs().

template<class TBaseSet >

void ShowBaseSetTextfileWindow | ( | TextfileType | file_type,
|  | const TBaseSet * | baseset,
|  | StringID | content_type
| ) |  |

Open the BaseSet version of the textfile window.

Parameters

  file_type | The type of textfile to display.
  baseset | The BaseSet to use.
  content_type | STR_CONTENT_TYPE_xxx for title.

Definition at line 158 of file settings_gui.cpp.

References DeleteWindowByClass(), and WC_TEXTFILE.

Referenced by GameOptionsWindow::OnClick().

static void ShowCustCurrency | ( |  | ) |
| static

Open custom currency window.

Definition at line 2667 of file settings_gui.cpp.

References DeleteWindowById(), and WC_CUSTOM_CURRENCY.

Referenced by GameOptionsWindow::OnDropdownSelect().

void ShowGameOptions | ( |  | ) |

Open the game options window.

Definition at line 665 of file settings_gui.cpp.

References DeleteWindowByClass(), and WC_GAME_OPTIONS.

Referenced by MenuClickSettings(), SelectGameWindow::OnClick(), MainToolbarWindow::OnHotkey(), and ScenarioEditorToolbarWindow::OnHotkey().

void ShowGameSettings | ( |  | ) |

Open advanced settings window.

Definition at line 2375 of file settings_gui.cpp.

References DeleteWindowByClass(), and WC_GAME_OPTIONS.

Referenced by MenuClickSettings(), and SelectGameWindow::OnClick().

static StringID TownName | ( | int | town_name | ) |
| inline static

Get a town name.

Parameters

  town_name | Number of the wanted town name.

Returns
  Name of the town as string ID.

Definition at line 89 of file settings_gui.cpp.

References _grf_names, _nb_grf_names, and _nb_orig_names.

Referenced by GameOptionsWindow::SetStringParameters().

## Variable Documentation

const StringID _autosave_dropdown[]
| static

Initial value:
{
STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_OFF,
STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_1_MONTH,
STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_3_MONTHS,
STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_6_MONTHS,
STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_12_MONTHS,
INVALID_STRING_ID,
}

Definition at line 51 of file settings_gui.cpp.

const StringID _driveside_dropdown[]
| static

Initial value:
{
STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_LEFT,
STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_RIGHT,
INVALID_STRING_ID
}

Definition at line 45 of file settings_gui.cpp.

const StringID _game_settings_restrict_dropdown[]
| static

Initial value:
{
STR_CONFIG_SETTING_RESTRICT_BASIC,
STR_CONFIG_SETTING_RESTRICT_ADVANCED,
STR_CONFIG_SETTING_RESTRICT_ALL,
STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_DEFAULT,
STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_NEW,
}

Definition at line 1752 of file settings_gui.cpp.

const StringID _gui_zoom_dropdown[]
| static

Initial value:
{
STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_NORMAL,
STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_2X_ZOOM,
STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_4X_ZOOM,
INVALID_STRING_ID,
}

Definition at line 60 of file settings_gui.cpp.