OpenTTD Source 20250312-master-gcdcc6b491d
|
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 "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 "dropdown_common_type.h"
#include "slider_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 "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 "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 | GameSettingsWindow |
Window to edit settings of the game. More... | |
struct | CustomCurrencyWindow |
Enumerations | |
enum | WarnHiddenResult : uint8_t { 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 (TextfileType file_type, const TBaseSet *baseset, StringID content_type) |
Open the BaseSet version of the textfile 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. | |
void | ShowGameOptions () |
Open the game options window. | |
static void | ResetAllSettingsConfirmationCallback (Window *w, bool confirmed) |
Callback function for the reset all settings button. | |
void | ShowGameSettings () |
Open advanced settings window. | |
void | DrawArrowButtons (int x, int y, Colours button_colour, uint8_t 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 | _autosave_dropdown [] |
static const uint32_t | _autosave_dropdown_to_minutes [] |
Available settings for autosave intervals. | |
Dimension | _circle_size |
Dimension of the circle +/- icon. This is here as not all users are within the class of the settings window. | |
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 |
static const int | VOLUME_NMARKS = 9 |
static constexpr NWidgetPart | _nested_social_plugins_widgets [] |
static constexpr NWidgetPart | _nested_social_plugins_none_widgets [] |
static constexpr NWidgetPart | _nested_game_options_widgets [] |
static WindowDesc | _game_options_desc (WDP_CENTER, nullptr, 0, 0, WC_GAME_OPTIONS, WC_NONE, {}, _nested_game_options_widgets) |
int | SETTING_HEIGHT = 11 |
Height of a single setting in the tree view in pixels. | |
static const StringID | _game_settings_restrict_dropdown [] |
static constexpr NWidgetPart | _nested_settings_selection_widgets [] |
static WindowDesc | _settings_selection_desc (WDP_CENTER, "settings", 510, 450, WC_GAME_OPTIONS, WC_NONE, {}, _nested_settings_selection_widgets) |
static constexpr NWidgetPart | _nested_cust_currency_widgets [] |
static WindowDesc | _cust_currency_desc (WDP_CENTER, nullptr, 0, 0, WC_CUSTOM_CURRENCY, WC_NONE, {}, _nested_cust_currency_widgets) |
GUI for settings.
Definition in file settings_gui.cpp.
#define HAS_TRUETYPE_FONT |
Definition at line 59 of file settings_gui.cpp.
enum WarnHiddenResult : uint8_t |
Warnings about hidden search results.
Definition at line 1189 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 146 of file settings_gui.cpp.
References _settings_client, VideoDriver::GetInstance(), VideoDriver::GetListOfMonitorRefreshRates(), ClientSettings::gui, and GUISettings::refresh_rate.
DropDownList BuildSetDropDownList | ( | int * | selected_index | ) |
Definition at line 129 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 1805 of file settings_gui.cpp.
References _current_text_dir, WidgetDimensions::bevel, DrawFrameRect(), FILLRECT_CHECKER, GetColourGradient(), GfxFillRect(), Lowered, SA_CENTER, WidgetDimensions::scaled, Rect::Shrink(), and TD_RTL.
Referenced by IndustryViewWindow::DrawInfo(), SettingEntry::DrawSetting(), GSConfigWindow::DrawWidget(), NewGRFParametersWindow::DrawWidget(), and ScriptSettingsWindow::DrawWidget().
void DrawBoolButton | ( | int | x, |
int | y, | ||
bool | state, | ||
bool | clickable | ||
) |
Draw a toggle button.
x | the x position to draw |
y | the y position to draw |
state | true = lowered |
clickable | is the button clickable? |
Definition at line 1857 of file settings_gui.cpp.
References DrawFrameRect(), Lowered, SETTING_BUTTON_HEIGHT, and SETTING_BUTTON_WIDTH.
Referenced by SettingEntry::DrawSetting(), GSConfigWindow::DrawWidget(), NewGRFParametersWindow::DrawWidget(), and ScriptSettingsWindow::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 1836 of file settings_gui.cpp.
References WidgetDimensions::bevel, DrawFrameRect(), FILLRECT_CHECKER, GetColourGradient(), GfxFillRect(), Lowered, SA_CENTER, WidgetDimensions::scaled, SETTING_BUTTON_HEIGHT, SETTING_BUTTON_WIDTH, and Rect::Shrink().
Referenced by SettingEntry::DrawSetting(), GSConfigWindow::DrawWidget(), NewGRFParametersWindow::DrawWidget(), and ScriptSettingsWindow::DrawWidget().
|
static |
Get index of the current screen resolution.
Definition at line 86 of file settings_gui.cpp.
References _resolutions.
Referenced by GameOptionsWindow::BuildDropDownList(), and GameOptionsWindow::GetWidgetString().
std::unique_ptr< NWidgetBase > MakeNWidgetSocialPlugins | ( | ) |
Construct nested container widget for managing the list of social plugins.
Definition at line 336 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 1201 of file settings_gui.cpp.
References SettingsContainer::FoldAll(), GetSettingsTree(), Window::InvalidateData(), and SettingsContainer::ResetAll().
Referenced by GameSettingsWindow::OnClick().
|
static |
Definition at line 159 of file settings_gui.cpp.
void ShowBaseSetTextfileWindow | ( | TextfileType | file_type, |
const TBaseSet * | baseset, | ||
StringID | content_type | ||
) |
Open the BaseSet version of the textfile 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 122 of file settings_gui.cpp.
References CloseWindowById(), and WC_TEXTFILE.
Referenced by GameOptionsWindow::OnClick().
|
static |
Open custom currency window.
Definition at line 2090 of file settings_gui.cpp.
References CloseWindowById(), and WC_CUSTOM_CURRENCY.
Referenced by GameOptionsWindow::OnDropdownSelect().
void ShowGameOptions | ( | ) |
Open the game options window.
Definition at line 1171 of file settings_gui.cpp.
References CloseWindowByClass(), and WC_GAME_OPTIONS.
Referenced by MenuClickSettings(), SelectGameWindow::OnClick(), MainToolbarWindow::OnHotkey(), and ScenarioEditorToolbarWindow::OnHotkey().
void ShowGameSettings | ( | ) |
Open advanced settings window.
Definition at line 1789 of file settings_gui.cpp.
References CloseWindowByClass(), and WC_GAME_OPTIONS.
Referenced by MenuClickSettings(), and SelectGameWindow::OnClick().
|
static |
Definition at line 167 of file settings_gui.cpp.
|
static |
Definition at line 62 of file settings_gui.cpp.
|
static |
Available settings for autosave intervals.
Definition at line 72 of file settings_gui.cpp.
Referenced by GameOptionsWindow::BuildDropDownList(), GameOptionsWindow::GetWidgetString(), and GameOptionsWindow::OnDropdownSelect().
Dimension _circle_size |
Dimension of the circle +/- icon. This is here as not all users are within the class of the settings window.
Definition at line 80 of file settings_gui.cpp.
Referenced by BaseSettingEntry::Draw(), SettingsPage::DrawSetting(), and GameSettingsWindow::UpdateWidgetSize().
|
static |
Definition at line 1179 of file settings_gui.cpp.
|
staticconstexpr |
Definition at line 2041 of file settings_gui.cpp.
|
staticconstexpr |
Definition at line 981 of file settings_gui.cpp.
|
staticconstexpr |
Definition at line 1741 of file settings_gui.cpp.
|
staticconstexpr |
Definition at line 191 of file settings_gui.cpp.
|
staticconstexpr |
Definition at line 176 of file settings_gui.cpp.
std::set<int> _refresh_rates = { 30, 60, 75, 90, 100, 120, 144, 240 } |
Definition at line 140 of file settings_gui.cpp.
|
static |
Definition at line 156 of file settings_gui.cpp.
int SETTING_HEIGHT = 11 |
Height of a single setting in the tree view in pixels.
Definition at line 1177 of file settings_gui.cpp.
Referenced by BaseSettingEntry::Draw(), SettingEntry::DrawSetting(), SettingsPage::DrawSetting(), GameSettingsWindow::DrawWidget(), GameSettingsWindow::OnClick(), and GameSettingsWindow::UpdateWidgetSize().
|
static |
Definition at line 157 of file settings_gui.cpp.