|
OpenTTD Source 20260731-master-g77ba2b244a
|
GUI for settings. More...
#include "stdafx.h"#include "currency_func.h"#include "error.h"#include "settings_gui.h"#include "textbuf_gui.h"#include "command_func.h"#include "network/network.h"#include "network/network_content.h"#include "town.h"#include "settings_internal.h"#include "strings_func.h"#include "window_func.h"#include "string_func.h"#include "dropdown_type.h"#include "dropdown_func.h"#include "slider_func.h"#include "highscore.h"#include "base_media_base.h"#include "base_media_graphics.h"#include "base_media_music.h"#include "base_media_sounds.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 "fontcache.h"#include "zoom_func.h"#include "rev.h"#include "video/video_driver.hpp"#include "music/music_driver.hpp"#include "gui.h"#include "mixer.h"#include "newgrf_config.h"#include "network/core/config.h"#include "network/network_gui.h"#include "network/network_survey.h"#include "social_integration.h"#include "sound_func.h"#include "settingentry_gui.h"#include "core/string_consumer.hpp"#include "widgets/settings_widget.h"#include "widgets/misc_widget.h"#include "table/strings.h"#include "dropdown_common_type.h"#include "safeguards.h"Go to the source code of this file.
Data Structures | |
| struct | BaseSetTextfileWindow |
| Window for displaying the textfile of a BaseSet. More... | |
| class | NWidgetSocialPlugins |
| struct | GameOptionsWindow |
| struct | CustomCurrencyWindow |
Enumerations | |
| enum | WarnHiddenResult { WHR_NONE , WHR_CATEGORY , WHR_TYPE , WHR_CATEGORY_TYPE } |
| Warnings about hidden search results. More... | |
Functions | |
| static uint | GetCurrentResolutionIndex () |
| Get index of the current screen resolution. | |
| static void | ShowCustCurrency () |
| Open custom currency window. | |
| template<class TBaseSet> | |
| void | ShowBaseSetTextfileWindow (Window *parent, TextfileType file_type, const TBaseSet *baseset, StringID content_type) |
| Open the BaseSet version of the textfile window. | |
| template<typename TBaseSet> | |
| static std::string | GetListLabel (const TBaseSet *baseset) |
| Get string to use when listing this set in the settings window. | |
| template<class T> | |
| DropDownList | BuildSetDropDownList (int *selected_index) |
| static void | AddCustomRefreshRates () |
| Add the refresh rate from the config and the refresh rates from all the monitors to our list of refresh rates shown in the GUI. | |
| static std::optional< std::string > | ScaleMarkFunc (int, int, int value) |
| static std::optional< std::string > | VolumeMarkFunc (int, int mark, int value) |
| std::unique_ptr< NWidgetBase > | MakeNWidgetSocialPlugins () |
| Construct nested container widget for managing the list of social plugins. | |
| static void | ResetAllSettingsConfirmationCallback (Window *w, bool confirmed) |
| Callback function for the reset all settings button. | |
| void | ShowGameOptions () |
| Open the game options window. | |
| void | DrawArrowButtons (int x, int y, Colours button_colour, uint8_t state, bool clickable_left, bool clickable_right) |
| Draw [<][>] boxes. | |
| void | DrawUpDownButtons (int x, int y, Colours button_colour, uint8_t state, bool clickable_up, bool clickable_down) |
| Draw [^][v] buttons. | |
| void | DrawDropDownButton (int x, int y, Colours button_colour, bool state, bool clickable) |
| Draw a dropdown button. | |
| void | DrawBoolButton (int x, int y, Colours button_colour, Colours background, bool state, bool clickable) |
| Draw a toggle button. | |
Variables | |
| static const StringID | _autosave_dropdown [] |
| static const uint32_t | _autosave_dropdown_to_minutes [] |
| Available settings for autosave intervals. | |
| std::set< int > | _refresh_rates = { 30, 60, 75, 90, 100, 120, 144, 240 } |
| static const int | SCALE_NMARKS = (MAX_INTERFACE_SCALE - MIN_INTERFACE_SCALE) / 25 + 1 |
| Show marks at 25% increments. | |
| static const int | VOLUME_NMARKS = 9 |
| Show 5 values and 4 empty marks. | |
| static constexpr Colours | GAME_OPTIONS_BACKGROUND = Colours::Mauve |
| Colour for background of game options. | |
| static constexpr Colours | GAME_OPTIONS_BUTTON = Colours::Yellow |
| Colour for buttons of game options. | |
| static constexpr TextColour | GAME_OPTIONS_FRAME = TextColour::Orange |
| Colour for frame text of game options. | |
| static constexpr TextColour | GAME_OPTIONS_LABEL = TextColour::LightBlue |
| Colour for label text of game options. | |
| static constexpr TextColour | GAME_OPTIONS_SELECTED = TextColour::White |
| Colour for selected text of game options. | |
| static constexpr std::initializer_list< NWidgetPart > | _nested_social_plugins_widgets |
| static constexpr std::initializer_list< NWidgetPart > | _nested_social_plugins_none_widgets |
| static const StringID | _game_settings_restrict_dropdown [] |
| static constexpr std::initializer_list< NWidgetPart > | _nested_game_options_widgets |
| static WindowDesc | _game_options_desc (WindowPosition::Center, "game_options", 0, 0, WindowClass::GameOptions, WindowClass::None, {}, _nested_game_options_widgets) |
| Window definition for the game options window. | |
| static constexpr std::initializer_list< NWidgetPart > | _nested_cust_currency_widgets |
| static WindowDesc | _cust_currency_desc (WindowPosition::Center, {}, 0, 0, WindowClass::CustomCurrenty, WindowClass::None, {}, _nested_cust_currency_widgets) |
| Window definition for the custom currency window. | |
GUI for settings.
Definition in file settings_gui.cpp.
| #define HAS_TRUETYPE_FONT |
Definition at line 69 of file settings_gui.cpp.
| enum WarnHiddenResult |
Warnings about hidden search results.
Definition at line 379 of file settings_gui.cpp.
|
static |
Add the refresh rate from the config and the refresh rates from all the monitors to our list of refresh rates shown in the GUI.
Definition at line 169 of file settings_gui.cpp.
References _settings_client, VideoDriver::GetInstance(), and VideoDriver::GetListOfMonitorRefreshRates().
| DropDownList BuildSetDropDownList | ( | int * | selected_index | ) |
Definition at line 152 of file settings_gui.cpp.
| void DrawArrowButtons | ( | int | x, |
| int | y, | ||
| Colours | button_colour, | ||
| uint8_t | state, | ||
| bool | clickable_left, | ||
| bool | clickable_right ) |
Draw [<][>] boxes.
| 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 1884 of file settings_gui.cpp.
References _current_text_dir, Centre, Checker, Darker, DrawFrameRect(), DrawSpriteIgnorePadding(), GetColourGradient(), GfxFillRect(), Lowered, Middle, Rect, WidgetDimensions::scaled, Rect::Shrink(), SPR_ARROW_LEFT, SPR_ARROW_RIGHT, and TD_RTL.
Referenced by IndustryViewWindow::DrawInfo(), SettingEntry::DrawSetting(), GSConfigWindow::DrawWidget(), NewGRFParametersWindow::DrawWidget(), ScriptSettingsWindow::DrawWidget(), and SelectCompanyManagerFaceWindow::DrawWidget().
| void DrawBoolButton | ( | int | x, |
| int | y, | ||
| Colours | button_colour, | ||
| Colours | background, | ||
| bool | state, | ||
| bool | clickable ) |
Draw a toggle button.
| x | the x position to draw |
| y | the y position to draw |
| button_colour | the colour of the button. |
| background | background colour. |
| state | true = lowered |
| clickable | is the button clickable? |
Definition at line 1965 of file settings_gui.cpp.
References _current_text_dir, BorderOnly, Checker, Darker, DrawFrameRect(), GetColourGradient(), GfxFillRect(), Green, Lowered, Rect, WidgetDimensions::scaled, SETTING_BUTTON_HEIGHT, SETTING_BUTTON_WIDTH, Rect::Shrink(), TD_RTL, and Rect::WithWidth().
Referenced by NWidgetLeaf::Draw(), SettingEntry::DrawSetting(), GSConfigWindow::DrawWidget(), NewGRFParametersWindow::DrawWidget(), ScriptSettingsWindow::DrawWidget(), and SelectCompanyManagerFaceWindow::DrawWidget().
| void DrawDropDownButton | ( | int | x, |
| int | y, | ||
| Colours | button_colour, | ||
| bool | state, | ||
| bool | clickable ) |
Draw a dropdown button.
| 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 1942 of file settings_gui.cpp.
References Centre, Checker, Darker, DrawFrameRect(), DrawSpriteIgnorePadding(), GetColourGradient(), GfxFillRect(), Lowered, Middle, Rect, WidgetDimensions::scaled, SETTING_BUTTON_HEIGHT, SETTING_BUTTON_WIDTH, Rect::Shrink(), and SPR_ARROW_DOWN.
Referenced by SettingEntry::DrawSetting(), GSConfigWindow::DrawWidget(), NewGRFParametersWindow::DrawWidget(), and ScriptSettingsWindow::DrawWidget().
| void DrawUpDownButtons | ( | int | x, |
| int | y, | ||
| Colours | button_colour, | ||
| uint8_t | state, | ||
| bool | clickable_up, | ||
| bool | clickable_down ) |
Draw [^][v] buttons.
| 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_up | is the up button clickable? |
| clickable_down | is the down button clickable? |
Definition at line 1916 of file settings_gui.cpp.
References _current_text_dir, Centre, Checker, Darker, DrawFrameRect(), DrawSpriteIgnorePadding(), GetColourGradient(), GfxFillRect(), Lowered, Middle, Rect, WidgetDimensions::scaled, SETTING_BUTTON_HEIGHT, SETTING_BUTTON_WIDTH, Rect::Shrink(), SPR_ARROW_DOWN, SPR_ARROW_UP, TD_RTL, and Rect::WithWidth().
|
static |
Get index of the current screen resolution.
Definition at line 94 of file settings_gui.cpp.
References _resolutions.
Referenced by GameOptionsWindow::BuildDropDownList(), and GameOptionsWindow::GetWidgetString().
|
static |
Get string to use when listing this set in the settings window.
If there are no invalid files, then this is just the set name, otherwise a string is formatted including the number of invalid files.
| baseset | The selected baseset. |
Definition at line 145 of file settings_gui.cpp.
References GetString().
Referenced by GameOptionsWindow::GetWidgetString().
| std::unique_ptr< NWidgetBase > MakeNWidgetSocialPlugins | ( | ) |
Construct nested container widget for managing the list of social plugins.
Pointer to function returning a nested widget.
Definition at line 364 of file settings_gui.cpp.
|
static |
Callback function for the reset all settings button.
| w | Window which is calling this callback |
| confirmed | boolean value, true when yes was clicked, false otherwise |
Definition at line 391 of file settings_gui.cpp.
References SettingsContainer::FoldAll(), GetSettingsTree(), Window::InvalidateData(), and SettingsContainer::ResetAll().
Referenced by GameOptionsWindow::OnClick().
|
static |
Definition at line 182 of file settings_gui.cpp.
| void ShowBaseSetTextfileWindow | ( | Window * | parent, |
| TextfileType | file_type, | ||
| const TBaseSet * | baseset, | ||
| StringID | content_type ) |
Open the BaseSet version of the textfile window.
| parent | The parent of this window, |
| file_type | The type of textfile to display. |
| baseset | The BaseSet to use. |
| content_type | STR_CONTENT_TYPE_xxx for title. |
Definition at line 131 of file settings_gui.cpp.
References Window::CloseChildWindowById().
Referenced by GameOptionsWindow::OnClick().
|
static |
Open custom currency window.
Definition at line 2213 of file settings_gui.cpp.
References _cust_currency_desc, and CloseWindowById().
Referenced by GameOptionsWindow::OnDropdownSelect().
| void ShowGameOptions | ( | ) |
Open the game options window.
Definition at line 1869 of file settings_gui.cpp.
References _game_options_desc, and CloseWindowByClass().
Referenced by MenuClickSettings(), SelectGameWindow::OnClick(), MainToolbarWindow::OnHotkey(), and ScenarioEditorToolbarWindow::OnHotkey().
|
static |
Definition at line 190 of file settings_gui.cpp.
|
static |
Definition at line 72 of file settings_gui.cpp.
|
static |
Available settings for autosave intervals.
Definition at line 82 of file settings_gui.cpp.
Referenced by GameOptionsWindow::BuildDropDownList(), GameOptionsWindow::GetWidgetString(), and GameOptionsWindow::OnDropdownSelect().
|
static |
Definition at line 369 of file settings_gui.cpp.
|
staticconstexpr |
Definition at line 2163 of file settings_gui.cpp.
|
staticconstexpr |
Definition at line 1622 of file settings_gui.cpp.
|
staticconstexpr |
Definition at line 225 of file settings_gui.cpp.
|
staticconstexpr |
Definition at line 210 of file settings_gui.cpp.
| std::set<int> _refresh_rates = { 30, 60, 75, 90, 100, 120, 144, 240 } |
Definition at line 163 of file settings_gui.cpp.
|
staticconstexpr |
Colour for background of game options.
Definition at line 200 of file settings_gui.cpp.
Referenced by GameOptionsWindow::DrawWidget().
|
staticconstexpr |
Colour for buttons of game options.
Definition at line 202 of file settings_gui.cpp.
Referenced by GameOptionsWindow::DrawWidget().
|
staticconstexpr |
Colour for frame text of game options.
Definition at line 204 of file settings_gui.cpp.
|
staticconstexpr |
Colour for label text of game options.
Definition at line 206 of file settings_gui.cpp.
|
staticconstexpr |
Colour for selected text of game options.
Definition at line 208 of file settings_gui.cpp.
Referenced by GameOptionsWindow::DrawWidget().
|
static |
Show marks at 25% increments.
Definition at line 179 of file settings_gui.cpp.
Referenced by GameOptionsWindow::DrawWidget(), and GameOptionsWindow::OnClick().
|
static |
Show 5 values and 4 empty marks.
Definition at line 180 of file settings_gui.cpp.
Referenced by GameOptionsWindow::DrawWidget().