|
OpenTTD Source
14.0-beta1
|
Go to the documentation of this file.
24 #include "widgets/slider_func.h"
54 #if defined(WITH_FREETYPE) || defined(_WIN32) || defined(WITH_COCOA)
55 # define HAS_TRUETYPE_FONT
58 static const StringID _autosave_dropdown[] = {
59 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_OFF,
60 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_10_MINUTES,
61 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_30_MINUTES,
62 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_60_MINUTES,
63 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_120_MINUTES,
93 template <
class TBaseSet>
100 this->ConstructWindow();
102 auto textfile = this->baseset->GetTextfile(
file_type);
106 void SetStringParameters(
WidgetID widget)
const override
121 template <
class TBaseSet>
128 std::set<int> _refresh_rates = { 30, 60, 75, 90, 100, 120, 144, 240 };
141 std::copy(monitorRates.begin(), monitorRates.end(), std::inserter(_refresh_rates, _refresh_rates.end()));
144 static const std::map<int, StringID> _scale_labels = {
145 { 100, STR_GAME_OPTIONS_GUI_SCALE_1X },
149 { 200, STR_GAME_OPTIONS_GUI_SCALE_2X },
153 { 300, STR_GAME_OPTIONS_GUI_SCALE_3X },
157 { 400, STR_GAME_OPTIONS_GUI_SCALE_4X },
161 { 500, STR_GAME_OPTIONS_GUI_SCALE_5X },
164 static const std::map<int, StringID> _volume_labels = {
165 { 0, STR_GAME_OPTIONS_VOLUME_0 },
167 { 31, STR_GAME_OPTIONS_VOLUME_25 },
169 { 63, STR_GAME_OPTIONS_VOLUME_50 },
171 { 95, STR_GAME_OPTIONS_VOLUME_75 },
173 { 127, STR_GAME_OPTIONS_VOLUME_100 },
176 static const NWidgetPart _nested_social_plugins_widgets[] = {
191 static const NWidgetPart _nested_social_plugins_none_widgets[] = {
203 if (this->plugins.empty()) {
204 auto widget =
MakeNWidgets(std::begin(_nested_social_plugins_none_widgets), std::end(_nested_social_plugins_none_widgets),
nullptr);
205 this->
Add(std::move(widget));
207 for (
size_t i = 0; i < this->plugins.size(); i++) {
208 auto widget =
MakeNWidgets(std::begin(_nested_social_plugins_widgets), std::end(_nested_social_plugins_widgets),
nullptr);
209 this->
Add(std::move(widget));
224 this->current_index = -1;
234 template <
typename T>
237 std::string *longest = &(this->plugins[0]->*member);
238 int longest_length = 0;
240 for (
auto *plugin : this->plugins) {
242 if (length > longest_length) {
243 longest_length = length;
244 longest = &(plugin->*member);
251 void SetStringParameters(
int widget)
const
256 if (this->current_index < 0) {
262 if (this->plugins[this->current_index]->name.empty()) {
264 SetDParamStr(1, this->plugins[this->current_index]->basepath);
266 SetDParam(0, STR_GAME_OPTIONS_SOCIAL_PLUGIN_TITLE);
267 SetDParamStr(1, this->plugins[this->current_index]->name);
268 SetDParamStr(2, this->plugins[this->current_index]->version);
274 if (this->current_index < 0) {
279 SetDParamStr(0, this->plugins[this->current_index]->social_platform);
283 static const std::pair<SocialIntegrationPlugin::State, StringID> state_to_string[] = {
294 if (this->current_index < 0) {
301 int longest_length = 0;
302 for (
auto state : state_to_string) {
304 if (length > longest_length) {
305 longest_length = length;
306 longest = state.second;
315 auto plugin = this->plugins[this->current_index];
318 SetDParam(0, STR_GAME_OPTIONS_SOCIAL_PLUGIN_STATE_FAILED);
322 for (
auto state : state_to_string) {
323 if (plugin->state == state.first) {
335 this->current_index = 0;
339 this->current_index++;
344 int current_index = -1;
345 std::vector<SocialIntegrationPlugin *> plugins;
351 return std::make_unique<NWidgetSocialPlugins>();
363 this->reload =
false;
371 this->SetTab(GameOptionsWindow::active_tab);
373 if constexpr (!NetworkSurveyHandler::IsSurveyPossible()) this->GetWidget<NWidgetStacked>(
WID_GO_SURVEY_SEL)->SetDisplayedPlane(
SZSP_NONE);
376 void Close([[maybe_unused]]
int data = 0)
override
402 if (currency.code.empty()) {
403 list.push_back(std::make_unique<DropDownListStringItem>(currency.name, i,
HasBit(disabled, i)));
407 list.push_back(std::make_unique<DropDownListStringItem>(STR_GAME_OPTIONS_CURRENCY_CODE, i,
HasBit(disabled, i)));
413 list.push_back(std::make_unique<DropDownListDividerItem>(-1,
false));
424 *selected_index = index - 1;
426 const StringID *items = _autosave_dropdown;
428 list.push_back(std::make_unique<DropDownListStringItem>(*items, i,
false));
434 for (uint i = 0; i <
_languages.size(); i++) {
435 bool hide_language = IsReleasedVersion() && !
_languages[i].IsReasonablyFinished();
436 if (hide_language)
continue;
449 SetDParam(1, (LANGUAGE_TOTAL_STRINGS -
_languages[i].missing) * 100 / LANGUAGE_TOTAL_STRINGS);
450 list.push_back(std::make_unique<DropDownListStringItem>(hide_percentage ? STR_JUST_RAW_STRING : STR_GAME_OPTIONS_LANGUAGE_PERCENTAGE, i,
false));
463 list.push_back(std::make_unique<DropDownListStringItem>(STR_GAME_OPTIONS_RESOLUTION_ITEM, i,
false));
468 for (
auto it = _refresh_rates.begin(); it != _refresh_rates.end(); it++) {
469 auto i = std::distance(_refresh_rates.begin(), it);
472 list.push_back(std::make_unique<DropDownListStringItem>(STR_GAME_OPTIONS_REFRESH_RATE_ITEM, i,
false));
477 list = BuildSetDropDownList<BaseGraphics>(selected_index);
481 list = BuildSetDropDownList<BaseSounds>(selected_index);
485 list = BuildSetDropDownList<BaseMusic>(selected_index);
492 void SetStringParameters(
WidgetID widget)
const override
497 if (currency.
code.empty()) {
500 SetDParam(0, STR_GAME_OPTIONS_CURRENCY_CODE);
512 SetDParam(0, _autosave_dropdown[index - 1]);
524 SetDParam(0, STR_GAME_OPTIONS_RESOLUTION_OTHER);
526 SetDParam(0, STR_GAME_OPTIONS_RESOLUTION_ITEM);
537 assert(plugin !=
nullptr);
539 plugin->SetStringParameters(widget);
545 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
564 DrawSliderWidget(r, MIN_INTERFACE_SCALE, MAX_INTERFACE_SCALE, this->gui_scale, _scale_labels);
586 GameOptionsWindow::active_tab = widget;
594 default: NOT_REACHED();
603 bool changed =
false;
643 d.width += padding.width;
644 d.height += padding.height;
664 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
689 this->SetTab(widget);
713 ShowSurveyResultTextfileWindow();
718 if (!ToggleFullScreen(!_fullscreen)) {
759 #ifdef HAS_TRUETYPE_FONT
787 if (
ClickSliderWidget(this->GetWidget<NWidgetBase>(widget)->GetCurrentRect(), pt, MIN_INTERFACE_SCALE, MAX_INTERFACE_SCALE, this->gui_scale)) {
788 if (!
_ctrl_pressed) this->gui_scale = ((this->gui_scale + 12) / 25) * 25;
812 if (used_set ==
nullptr || !used_set->IsConfigurable())
break;
813 GRFConfig &extra_cfg = used_set->GetOrCreateExtraConfig();
815 OpenGRFParameterWindow(
true, &extra_cfg, _game_mode == GM_MENU);
816 if (_game_mode == GM_MENU) this->reload =
true;
823 if (
ClickSliderWidget(this->GetWidget<NWidgetBase>(widget)->GetCurrentRect(), pt, 0, INT8_MAX, vol)) {
827 SetEffectVolume(vol);
890 void OnDropdownSelect(
WidgetID widget,
int index)
override
909 ClearAllCachedNames();
932 if (_game_mode == GM_MENU) {
942 if (_game_mode == GM_MENU) {
962 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
964 if (!gui_scope)
return;
977 #ifdef HAS_TRUETYPE_FONT
992 for (
TextfileType tft = TFT_CONTENT_BEGIN; tft < TFT_CONTENT_END; tft++) {
1000 static constexpr
NWidgetPart _nested_game_options_widgets[] = {
1047 NWidget(
WWT_EMPTY, COLOUR_GREY,
WID_GO_GUI_SCALE),
SetMinimalSize(67, 0),
SetMinimalTextLines(1, 12 +
WidgetDimensions::unscaled.vsep_normal,
FS_SMALL),
SetFill(0, 0),
SetDataTip(0x0, STR_GAME_OPTIONS_GUI_SCALE_TOOLTIP),
1056 #ifdef HAS_TRUETYPE_FONT
1123 NWidget(
WWT_EMPTY, COLOUR_GREY,
WID_GO_BASE_SFX_VOLUME),
SetMinimalSize(67, 0),
SetMinimalTextLines(1, 12 +
WidgetDimensions::unscaled.vsep_normal,
FS_SMALL),
SetFill(1, 0),
SetDataTip(0x0, STR_MUSIC_TOOLTIP_DRAG_SLIDERS_TO_SET_MUSIC),
1127 NWidget(
WWT_EMPTY, COLOUR_GREY,
WID_GO_BASE_MUSIC_VOLUME),
SetMinimalSize(67, 0),
SetMinimalTextLines(1, 12 +
WidgetDimensions::unscaled.vsep_normal,
FS_SMALL),
SetFill(1, 0),
SetDataTip(0x0, STR_MUSIC_TOOLTIP_DRAG_SLIDERS_TO_SET_MUSIC),
1133 NWidget(
WWT_EMPTY, INVALID_COLOUR,
WID_GO_BASE_SFX_DESCRIPTION),
SetMinimalSize(200, 0),
SetMinimalTextLines(1, 0),
SetDataTip(STR_NULL, STR_GAME_OPTIONS_BASE_SFX_DESCRIPTION_TOOLTIP),
SetFill(1, 0),
1149 NWidget(
WWT_EMPTY, INVALID_COLOUR,
WID_GO_BASE_MUSIC_DESCRIPTION),
SetMinimalSize(200, 0),
SetMinimalTextLines(1, 0),
SetDataTip(STR_NULL, STR_GAME_OPTIONS_BASE_MUSIC_DESCRIPTION_TOOLTIP),
SetFill(1, 0),
1175 static WindowDesc _game_options_desc(__FILE__, __LINE__,
1179 std::begin(_nested_game_options_widgets), std::end(_nested_game_options_widgets)
1233 virtual void FoldAll() {}
1234 virtual void UnFoldAll() {}
1235 virtual void ResetAll() = 0;
1243 virtual uint Length()
const = 0;
1244 virtual void GetFoldingState([[maybe_unused]]
bool &all_folded, [[maybe_unused]]
bool &all_unfolded)
const {}
1247 virtual uint GetMaxHelpHeight([[maybe_unused]]
int maxw) {
return 0; }
1255 virtual bool UpdateFilterState(
SettingFilter &filter,
bool force_visible) = 0;
1257 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;
1260 virtual void DrawSetting(
GameSettings *settings_ptr,
int left,
int right,
int y,
bool highlight)
const = 0;
1271 void ResetAll()
override;
1272 uint
Length()
const override;
1287 typedef std::vector<BaseSettingEntry*> EntryVector;
1290 template<
typename T>
1293 this->entries.push_back(item);
1297 void Init(
byte level = 0);
1310 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;
1325 uint
Length()
const override;
1326 void GetFoldingState(
bool &all_folded,
bool &all_unfolded)
const override;
1333 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 override;
1347 this->level =
level;
1359 return this == item;
1371 if (row_num == *cur_row)
return this;
1408 if (cur_row >= max_row)
return cur_row;
1414 int x = rtl ? right : left;
1415 if (cur_row >= first_row) {
1420 for (uint lvl = 0; lvl < this->
level; lvl++) {
1421 if (!
HasBit(parent_last, lvl)) GfxDrawLine(x + offset, y, x + offset, y +
SETTING_HEIGHT - 1, colour);
1427 GfxDrawLine(x + offset, y, x + offset, bottom_y, colour);
1432 this->DrawSetting(settings_ptr, rtl ? left : x, rtl ? x : right, y,
this == selected);
1462 void SettingEntry::ResetAll()
1502 if (mode ==
RM_ALL)
return true;
1511 int64_t current_value = sd->
Read(
object);
1512 int64_t filter_value;
1518 filter_value = sd->
def;
1531 return current_value != filter_value;
1544 bool visible =
true;
1581 return settings_ptr;
1607 int32_t value = sd->
Read(ResolveObject(settings_ptr, sd));
1631 for (
auto &it : this->
entries) {
1639 for (
auto settings_entry : this->
entries) {
1640 settings_entry->ResetAll();
1647 for (
auto &it : this->
entries) {
1655 for (
auto &it : this->
entries) {
1667 for (
auto &it : this->
entries) {
1668 it->GetFoldingState(all_folded, all_unfolded);
1680 bool visible =
false;
1681 bool first_visible =
true;
1682 for (EntryVector::reverse_iterator it = this->
entries.rbegin(); it != this->entries.rend(); ++it) {
1683 visible |= (*it)->UpdateFilterState(filter, force_visible);
1684 (*it)->SetLastField(first_visible);
1685 if (visible && first_visible) first_visible =
false;
1699 for (
const auto &it : this->
entries) {
1700 if (it->IsVisible(item))
return true;
1709 for (
const auto &it : this->
entries) {
1710 length += it->Length();
1724 for (
const auto &it : this->
entries) {
1726 if (pe !=
nullptr) {
1741 for (
const auto &it : this->
entries) {
1742 biggest = std::max(biggest, it->GetMaxHelpHeight(maxw));
1764 for (
const auto &it : this->
entries) {
1765 cur_row = it->Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1766 if (cur_row >= max_row)
break;
1779 this->title =
title;
1796 for (
auto settings_entry : this->
entries) {
1797 settings_entry->ResetAll();
1829 all_unfolded =
false;
1869 if (
this == item)
return true;
1870 if (this->
folded)
return false;
1879 if (this->
folded)
return 1;
1893 if (row_num == *cur_row)
return this;
1895 if (this->
folded)
return nullptr;
1917 if (cur_row >= max_row)
return cur_row;
1919 cur_row =
BaseSettingEntry::Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1923 assert(this->
level < 8 *
sizeof(parent_last));
1927 cur_row =
SettingsContainer::Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1951 if (
main ==
nullptr)
1958 localisation->Add(
new SettingEntry(
"locale.units_velocity"));
1959 localisation->Add(
new SettingEntry(
"locale.units_velocity_nautical"));
1960 localisation->Add(
new SettingEntry(
"locale.units_power"));
1961 localisation->Add(
new SettingEntry(
"locale.units_weight"));
1962 localisation->Add(
new SettingEntry(
"locale.units_volume"));
1963 localisation->Add(
new SettingEntry(
"locale.units_force"));
1964 localisation->Add(
new SettingEntry(
"locale.units_height"));
1965 localisation->Add(
new SettingEntry(
"gui.date_format_in_default_names"));
1972 graphics->Add(
new SettingEntry(
"gui.sprite_zoom_min"));
1973 graphics->Add(
new SettingEntry(
"gui.smallmap_land_colour"));
1974 graphics->Add(
new SettingEntry(
"gui.linkgraph_colours"));
1975 graphics->Add(
new SettingEntry(
"gui.graph_line_thickness"));
1997 general->Add(
new SettingEntry(
"gui.window_snap_radius"));
1998 general->Add(
new SettingEntry(
"gui.window_soft_limit"));
1999 general->Add(
new SettingEntry(
"gui.right_click_wnd_close"));
2004 viewports->Add(
new SettingEntry(
"gui.auto_scrolling"));
2010 viewports->Add(
new SettingEntry(
"gui.scrollwheel_scrolling"));
2011 viewports->Add(
new SettingEntry(
"gui.scrollwheel_multiplier"));
2014 viewports->Add(
new SettingEntry(
"gui.right_mouse_btn_emulation"));
2016 viewports->Add(
new SettingEntry(
"gui.population_in_label"));
2018 viewports->Add(
new SettingEntry(
"construction.train_signal_side"));
2019 viewports->Add(
new SettingEntry(
"gui.measure_tooltip"));
2020 viewports->Add(
new SettingEntry(
"gui.loading_indicators"));
2021 viewports->Add(
new SettingEntry(
"gui.show_track_reservation"));
2026 construction->Add(
new SettingEntry(
"gui.link_terraform_toolbar"));
2027 construction->Add(
new SettingEntry(
"gui.persistent_buildingtools"));
2028 construction->Add(
new SettingEntry(
"gui.default_rail_type"));
2029 construction->Add(
new SettingEntry(
"gui.semaphore_build_before"));
2030 construction->Add(
new SettingEntry(
"gui.signal_gui_mode"));
2031 construction->Add(
new SettingEntry(
"gui.cycle_signal_types"));
2032 construction->Add(
new SettingEntry(
"gui.drag_signals_fixed_distance"));
2033 construction->Add(
new SettingEntry(
"gui.auto_remove_signals"));
2038 interface->Add(
new SettingEntry(
"gui.prefer_teamchat"));
2039 interface->Add(
new SettingEntry(
"gui.advanced_vehicle_list"));
2040 interface->Add(
new SettingEntry(
"gui.timetable_mode"));
2041 interface->Add(
new SettingEntry(
"gui.timetable_arrival_departure"));
2042 interface->Add(
new SettingEntry(
"gui.show_newgrf_name"));
2043 interface->Add(
new SettingEntry(
"gui.show_cargo_in_vehicle_lists"));
2048 advisors->Add(
new SettingEntry(
"gui.coloured_news_year"));
2049 advisors->Add(
new SettingEntry(
"news_display.general"));
2050 advisors->Add(
new SettingEntry(
"news_display.new_vehicles"));
2051 advisors->Add(
new SettingEntry(
"news_display.accident"));
2052 advisors->Add(
new SettingEntry(
"news_display.accident_other"));
2053 advisors->Add(
new SettingEntry(
"news_display.company_info"));
2054 advisors->Add(
new SettingEntry(
"news_display.acceptance"));
2055 advisors->Add(
new SettingEntry(
"news_display.arrival_player"));
2056 advisors->Add(
new SettingEntry(
"news_display.arrival_other"));
2057 advisors->Add(
new SettingEntry(
"news_display.advice"));
2058 advisors->Add(
new SettingEntry(
"gui.order_review_system"));
2059 advisors->Add(
new SettingEntry(
"gui.vehicle_income_warn"));
2060 advisors->Add(
new SettingEntry(
"gui.lost_vehicle_warn"));
2062 advisors->Add(
new SettingEntry(
"news_display.economy"));
2063 advisors->Add(
new SettingEntry(
"news_display.subsidies"));
2066 advisors->Add(
new SettingEntry(
"news_display.production_player"));
2067 advisors->Add(
new SettingEntry(
"news_display.production_other"));
2068 advisors->Add(
new SettingEntry(
"news_display.production_nobody"));
2074 company->Add(
new SettingEntry(
"gui.starting_colour_secondary"));
2075 company->Add(
new SettingEntry(
"company.engine_renew"));
2076 company->Add(
new SettingEntry(
"company.engine_renew_months"));
2077 company->Add(
new SettingEntry(
"company.engine_renew_money"));
2078 company->Add(
new SettingEntry(
"vehicle.servint_ispercent"));
2079 company->Add(
new SettingEntry(
"vehicle.servint_trains"));
2080 company->Add(
new SettingEntry(
"vehicle.servint_roadveh"));
2081 company->Add(
new SettingEntry(
"vehicle.servint_ships"));
2082 company->Add(
new SettingEntry(
"vehicle.servint_aircraft"));
2087 accounting->Add(
new SettingEntry(
"difficulty.infinite_money"));
2088 accounting->Add(
new SettingEntry(
"economy.inflation"));
2089 accounting->Add(
new SettingEntry(
"difficulty.initial_interest"));
2090 accounting->Add(
new SettingEntry(
"difficulty.max_loan"));
2091 accounting->Add(
new SettingEntry(
"difficulty.subsidy_multiplier"));
2092 accounting->Add(
new SettingEntry(
"difficulty.subsidy_duration"));
2093 accounting->Add(
new SettingEntry(
"economy.feeder_payment_share"));
2094 accounting->Add(
new SettingEntry(
"economy.infrastructure_maintenance"));
2095 accounting->Add(
new SettingEntry(
"difficulty.vehicle_costs"));
2096 accounting->Add(
new SettingEntry(
"difficulty.construction_cost"));
2103 physics->Add(
new SettingEntry(
"vehicle.train_acceleration_model"));
2104 physics->Add(
new SettingEntry(
"vehicle.train_slope_steepness"));
2105 physics->Add(
new SettingEntry(
"vehicle.wagon_speed_limits"));
2106 physics->Add(
new SettingEntry(
"vehicle.freight_trains"));
2107 physics->Add(
new SettingEntry(
"vehicle.roadveh_acceleration_model"));
2108 physics->Add(
new SettingEntry(
"vehicle.roadveh_slope_steepness"));
2109 physics->Add(
new SettingEntry(
"vehicle.smoke_amount"));
2116 routing->Add(
new SettingEntry(
"pf.pathfinder_for_trains"));
2117 routing->Add(
new SettingEntry(
"difficulty.line_reverse_mode"));
2118 routing->Add(
new SettingEntry(
"pf.reverse_at_signals"));
2120 routing->Add(
new SettingEntry(
"pf.pathfinder_for_roadvehs"));
2121 routing->Add(
new SettingEntry(
"pf.pathfinder_for_ships"));
2134 limitations->Add(
new SettingEntry(
"construction.command_pause_level"));
2135 limitations->Add(
new SettingEntry(
"construction.autoslope"));
2136 limitations->Add(
new SettingEntry(
"construction.extra_dynamite"));
2137 limitations->Add(
new SettingEntry(
"construction.map_height_limit"));
2138 limitations->Add(
new SettingEntry(
"construction.max_bridge_length"));
2139 limitations->Add(
new SettingEntry(
"construction.max_bridge_height"));
2140 limitations->Add(
new SettingEntry(
"construction.max_tunnel_length"));
2141 limitations->Add(
new SettingEntry(
"station.never_expire_airports"));
2142 limitations->Add(
new SettingEntry(
"vehicle.never_expire_vehicles"));
2143 limitations->Add(
new SettingEntry(
"vehicle.max_trains"));
2144 limitations->Add(
new SettingEntry(
"vehicle.max_roadveh"));
2145 limitations->Add(
new SettingEntry(
"vehicle.max_aircraft"));
2146 limitations->Add(
new SettingEntry(
"vehicle.max_ships"));
2147 limitations->Add(
new SettingEntry(
"vehicle.max_train_length"));
2148 limitations->Add(
new SettingEntry(
"station.station_spread"));
2149 limitations->Add(
new SettingEntry(
"station.distant_join_stations"));
2150 limitations->Add(
new SettingEntry(
"station.modified_catchment"));
2151 limitations->Add(
new SettingEntry(
"construction.road_stop_on_town_road"));
2152 limitations->Add(
new SettingEntry(
"construction.road_stop_on_competitor_road"));
2153 limitations->Add(
new SettingEntry(
"construction.crossing_with_competitor"));
2154 limitations->Add(
new SettingEntry(
"vehicle.disable_elrails"));
2155 limitations->Add(
new SettingEntry(
"order.station_length_loading_penalty"));
2160 disasters->Add(
new SettingEntry(
"difficulty.disasters"));
2161 disasters->Add(
new SettingEntry(
"difficulty.economy"));
2162 disasters->Add(
new SettingEntry(
"vehicle.plane_crashes"));
2163 disasters->Add(
new SettingEntry(
"difficulty.vehicle_breakdowns"));
2164 disasters->Add(
new SettingEntry(
"order.no_servicing_if_no_breakdowns"));
2165 disasters->Add(
new SettingEntry(
"order.serviceathelipad"));
2170 genworld->Add(
new SettingEntry(
"game_creation.landscape"));
2171 genworld->Add(
new SettingEntry(
"game_creation.land_generator"));
2172 genworld->Add(
new SettingEntry(
"difficulty.terrain_type"));
2173 genworld->Add(
new SettingEntry(
"game_creation.tgen_smoothness"));
2174 genworld->Add(
new SettingEntry(
"game_creation.variety"));
2175 genworld->Add(
new SettingEntry(
"game_creation.snow_coverage"));
2176 genworld->Add(
new SettingEntry(
"game_creation.snow_line_height"));
2177 genworld->Add(
new SettingEntry(
"game_creation.desert_coverage"));
2178 genworld->Add(
new SettingEntry(
"game_creation.amount_of_rivers"));
2185 time->Add(
new SettingEntry(
"economy.timekeeping_units"));
2186 time->Add(
new SettingEntry(
"economy.minutes_per_calendar_year"));
2187 time->Add(
new SettingEntry(
"game_creation.ending_year"));
2189 time->Add(
new SettingEntry(
"gui.fast_forward_speed_limit"));
2194 authorities->Add(
new SettingEntry(
"difficulty.town_council_tolerance"));
2196 authorities->Add(
new SettingEntry(
"economy.exclusive_rights"));
2197 authorities->Add(
new SettingEntry(
"economy.fund_roads"));
2198 authorities->Add(
new SettingEntry(
"economy.fund_buildings"));
2199 authorities->Add(
new SettingEntry(
"economy.station_noise_level"));
2204 towns->Add(
new SettingEntry(
"economy.town_cargo_scale"));
2205 towns->Add(
new SettingEntry(
"economy.town_growth_rate"));
2206 towns->Add(
new SettingEntry(
"economy.allow_town_roads"));
2207 towns->Add(
new SettingEntry(
"economy.allow_town_level_crossings"));
2211 towns->Add(
new SettingEntry(
"economy.initial_city_size"));
2212 towns->Add(
new SettingEntry(
"economy.town_cargogen_mode"));
2217 industries->Add(
new SettingEntry(
"economy.industry_cargo_scale"));
2218 industries->Add(
new SettingEntry(
"difficulty.industry_density"));
2219 industries->Add(
new SettingEntry(
"construction.raw_industry_construction"));
2220 industries->Add(
new SettingEntry(
"construction.industry_platform"));
2221 industries->Add(
new SettingEntry(
"economy.multiple_industry_per_town"));
2222 industries->Add(
new SettingEntry(
"game_creation.oil_refinery_limit"));
2224 industries->Add(
new SettingEntry(
"station.serve_neutral_industries"));
2230 cdist->Add(
new SettingEntry(
"linkgraph.recalc_interval"));
2231 cdist->Add(
new SettingEntry(
"linkgraph.distribution_pax"));
2232 cdist->Add(
new SettingEntry(
"linkgraph.distribution_mail"));
2233 cdist->Add(
new SettingEntry(
"linkgraph.distribution_armoured"));
2234 cdist->Add(
new SettingEntry(
"linkgraph.distribution_default"));
2236 cdist->Add(
new SettingEntry(
"linkgraph.demand_distance"));
2238 cdist->Add(
new SettingEntry(
"linkgraph.short_path_saturation"));
2243 trees->Add(
new SettingEntry(
"game_creation.tree_placer"));
2244 trees->Add(
new SettingEntry(
"construction.extra_tree_placement"));
2252 npc->Add(
new SettingEntry(
"script.script_max_opcode_till_suspend"));
2253 npc->Add(
new SettingEntry(
"script.script_max_memory_megabytes"));
2254 npc->Add(
new SettingEntry(
"difficulty.competitor_speed"));
2257 npc->Add(
new SettingEntry(
"ai.ai_disable_veh_roadveh"));
2258 npc->Add(
new SettingEntry(
"ai.ai_disable_veh_aircraft"));
2267 network->Add(
new SettingEntry(
"network.use_relay_service"));
2275 static const StringID _game_settings_restrict_dropdown[] = {
2276 STR_CONFIG_SETTING_RESTRICT_BASIC,
2277 STR_CONFIG_SETTING_RESTRICT_ADVANCED,
2278 STR_CONFIG_SETTING_RESTRICT_ALL,
2279 STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_DEFAULT,
2280 STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_NEW,
2282 static_assert(
lengthof(_game_settings_restrict_dropdown) ==
RM_END);
2327 this->warn_lines = 0;
2329 this->filter.min_cat =
RM_ALL;
2330 this->filter.type =
ST_ALL;
2331 this->filter.type_hides =
false;
2336 this->valuewindow_entry =
nullptr;
2337 this->clicked_entry =
nullptr;
2338 this->last_clicked =
nullptr;
2339 this->valuedropdown_entry =
nullptr;
2340 this->closing_dropdown =
false;
2341 this->manually_changed_folding =
false;
2370 static const StringID setting_types[] = {
2371 STR_CONFIG_SETTING_TYPE_CLIENT,
2372 STR_CONFIG_SETTING_TYPE_COMPANY_MENU, STR_CONFIG_SETTING_TYPE_COMPANY_INGAME,
2373 STR_CONFIG_SETTING_TYPE_GAME_MENU, STR_CONFIG_SETTING_TYPE_GAME_INGAME,
2375 for (uint i = 0; i <
lengthof(setting_types); i++) {
2380 std::max(size->height,
GetSettingsTree().GetMaxHelpHeight(size->width));
2396 if (this->closing_dropdown) {
2397 this->closing_dropdown =
false;
2398 assert(this->valuedropdown_entry !=
nullptr);
2400 this->valuedropdown_entry =
nullptr;
2407 if (this->warn_missing ==
WHR_NONE) {
2413 if (this->warn_lines != new_warn_lines) {
2414 this->vscroll->
SetCount(this->vscroll->
GetCount() - this->warn_lines + new_warn_lines);
2415 this->warn_lines = new_warn_lines;
2421 if (this->warn_missing !=
WHR_NONE) {
2427 void SetStringParameters(
WidgetID widget)
const override
2431 SetDParam(0, _game_settings_restrict_dropdown[this->filter.
mode]);
2435 switch (this->filter.
type) {
2436 case ST_GAME:
SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME);
break;
2437 case ST_COMPANY:
SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME);
break;
2439 default:
SetDParam(0, STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL);
break;
2450 for (
int mode = 0; mode !=
RM_END; mode++) {
2455 list.push_back(std::make_unique<DropDownListStringItem>(_game_settings_restrict_dropdown[mode], mode, disabled));
2460 list.push_back(std::make_unique<DropDownListStringItem>(STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL,
ST_ALL,
false));
2461 list.push_back(std::make_unique<DropDownListStringItem>(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME,
ST_GAME,
false));
2462 list.push_back(std::make_unique<DropDownListStringItem>(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME,
ST_COMPANY,
false));
2463 list.push_back(std::make_unique<DropDownListStringItem>(STR_CONFIG_SETTING_TYPE_DROPDOWN_CLIENT,
ST_CLIENT,
false));
2469 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
2477 this->vscroll->GetPosition(), last_row, this->last_clicked);
2478 if (next_row == 0)
DrawString(tr, STR_CONFIG_SETTINGS_NONE);
2483 if (this->last_clicked !=
nullptr) {
2488 case ST_COMPANY:
SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_COMPANY_INGAME);
break;
2490 case ST_GAME:
SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_GAME_MENU : STR_CONFIG_SETTING_TYPE_GAME_INGAME);
break;
2491 default: NOT_REACHED();
2497 DrawString(tr, STR_CONFIG_SETTING_DEFAULT_VALUE);
2515 if (this->last_clicked != pe) this->
SetDirty();
2516 this->last_clicked = pe;
2519 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
2523 this->manually_changed_folding =
true;
2529 this->manually_changed_folding =
true;
2536 STR_CONFIG_SETTING_RESET_ALL_CONFIRMATION_DIALOG_CAPTION,
2537 STR_CONFIG_SETTING_RESET_ALL_CONFIRMATION_DIALOG_TEXT,
2545 if (!list.empty()) {
2553 if (!list.empty()) {
2563 if (btn == INT_MAX || (
int)btn < this->
warn_lines)
return;
2575 if (clicked_page !=
nullptr) {
2579 this->manually_changed_folding =
true;
2586 assert(pe !=
nullptr);
2601 if (this->valuedropdown_entry == pe) {
2604 this->closing_dropdown =
false;
2606 this->valuedropdown_entry =
nullptr;
2608 if (this->valuedropdown_entry !=
nullptr) this->valuedropdown_entry->
SetButtons(0);
2609 this->closing_dropdown =
false;
2621 if (pt.y >= wi_rect.top && pt.y <= wi_rect.bottom) {
2622 this->valuedropdown_entry = pe;
2626 for (
int i = sd->
min; i <= (
int)sd->
max; i++) {
2628 list.push_back(std::make_unique<DropDownListStringItem>(STR_JUST_STRING2, i,
false));
2637 int32_t oldvalue = value;
2647 if (step == 0) step = 1;
2659 assert((int32_t)sd->
max >= 0);
2660 if (value > (int32_t)sd->
max) value = (int32_t)sd->
max;
2662 if ((uint32_t)value > sd->
max) value = (int32_t)sd->
max;
2664 if (value < sd->min) value = sd->
min;
2671 if (value != oldvalue) {
2672 if (this->clicked_entry !=
nullptr) {
2673 this->clicked_entry->SetButtons(0);
2675 this->clicked_entry = pe;
2682 if (value != oldvalue) {
2689 int64_t value64 = value;
2696 this->valuewindow_entry = pe;
2707 if (this->clicked_entry !=
nullptr) {
2708 this->clicked_entry->SetButtons(0);
2709 this->clicked_entry =
nullptr;
2714 void OnQueryTextFinished(
char *str)
override
2717 if (str ==
nullptr)
return;
2719 assert(this->valuewindow_entry !=
nullptr);
2724 long long llvalue = atoll(str);
2729 value = ClampTo<int32_t>(llvalue);
2738 void OnDropdownSelect(
WidgetID widget,
int index)
override
2746 if (!this->manually_changed_folding) {
2765 assert(this->valuedropdown_entry !=
nullptr);
2788 assert(this->valuedropdown_entry !=
nullptr);
2789 this->closing_dropdown =
true;
2794 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
2796 if (!gui_scope)
return;
2800 this->filter.min_cat = min_level;
2801 this->filter.type_hides =
false;
2817 bool all_folded =
true;
2818 bool all_unfolded =
true;
2824 void OnEditboxChanged(
WidgetID wid)
override
2828 if (!this->filter.
string.
IsEmpty() && !this->manually_changed_folding) {
2845 static constexpr
NWidgetPart _nested_settings_selection_widgets[] = {
2855 NWidget(
WWT_DROPDOWN, COLOUR_MAUVE,
WID_GS_RESTRICT_DROPDOWN),
SetMinimalSize(100, 12),
SetDataTip(STR_JUST_STRING, STR_CONFIG_SETTING_RESTRICT_DROPDOWN_HELPTEXT),
SetFill(1, 0),
SetResize(1, 0),
2859 NWidget(
WWT_DROPDOWN, COLOUR_MAUVE,
WID_GS_TYPE_DROPDOWN),
SetMinimalSize(100, 12),
SetDataTip(STR_JUST_STRING, STR_CONFIG_SETTING_TYPE_DROPDOWN_HELPTEXT),
SetFill(1, 0),
SetResize(1, 0),
2863 NWidget(
WWT_EDITBOX, COLOUR_MAUVE,
WID_GS_FILTER),
SetMinimalSize(50, 12),
SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
SetFill(1, 0),
SetResize(1, 0),
2885 static WindowDesc _settings_selection_desc(__FILE__, __LINE__,
2889 std::begin(_nested_settings_selection_widgets), std::end(_nested_settings_selection_widgets)
2909 void DrawArrowButtons(
int x,
int y, Colours button_colour,
byte state,
bool clickable_left,
bool clickable_right)
2912 Dimension dim = NWidgetScrollbar::GetHorizontalDimension();
2914 Rect lr = {x, y, x + (int)dim.width - 1, y + (
int)dim.height - 1};
2915 Rect rr = {x + (int)dim.width, y, x + (
int)dim.width * 2 - 1, y + (int)dim.height - 1};
2919 DrawSpriteIgnorePadding(SPR_ARROW_LEFT, PAL_NONE, lr,
SA_CENTER);
2920 DrawSpriteIgnorePadding(SPR_ARROW_RIGHT, PAL_NONE, rr,
SA_CENTER);
2924 if (rtl ? !clickable_right : !clickable_left) {
2927 if (rtl ? !clickable_left : !clickable_right) {
2947 DrawSpriteIgnorePadding(SPR_ARROW_DOWN, PAL_NONE, r,
SA_CENTER);
2963 static const Colours _bool_ctabs[2][2] = {{COLOUR_CREAM, COLOUR_RED}, {COLOUR_DARK_GREEN, COLOUR_GREEN}};
2979 void SetButtonState()
2987 void SetStringParameters(
WidgetID widget)
const override
2995 SetDParam(0, (_custom_currency.to_euro !=
CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER);
3032 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
3041 if (_custom_currency.rate > 1) _custom_currency.rate--;
3047 if (_custom_currency.rate < UINT16_MAX) _custom_currency.rate++;
3063 str = STR_JUST_RAW_STRING;
3071 str = STR_JUST_RAW_STRING;
3079 str = STR_JUST_RAW_STRING;
3085 _custom_currency.to_euro = (_custom_currency.to_euro <=
MIN_EURO_YEAR) ?
CF_NOEURO : _custom_currency.to_euro - 1;
3106 this->query_widget = line;
3107 ShowQueryString(str, STR_CURRENCY_CHANGE_PARAMETER, len + 1,
this, afilter, QSF_NONE);
3114 void OnQueryTextFinished(
char *str)
override
3116 if (str ==
nullptr)
return;
3118 switch (this->query_widget) {
3120 _custom_currency.rate =
Clamp(atoi(str), 1, UINT16_MAX);
3124 _custom_currency.separator = str;
3128 _custom_currency.prefix = str;
3132 _custom_currency.suffix = str;
3152 static constexpr
NWidgetPart _nested_cust_currency_widgets[] = {
3188 SetDataTip(STR_CURRENCY_PREVIEW, STR_CURRENCY_CUSTOM_CURRENCY_PREVIEW_TOOLTIP),
3193 static WindowDesc _cust_currency_desc(__FILE__, __LINE__,
3197 std::begin(_nested_cust_currency_widgets), std::end(_nested_cust_currency_widgets)
uint8_t timeout_timer
Timer value of the WF_TIMEOUT for flags.
@ WC_CUSTOM_CURRENCY
Custom currency; Window numbers:
@ SEF_RIGHT_DEPRESSED
Of a numeric setting entry, the right button is depressed.
static const uint32_t _autosave_dropdown_to_minutes[]
Available settings for autosave intervals.
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
void OnTimeout() override
Called when this window's timeout has been reached.
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
bool SetSettingValue(const IntSettingDesc *sd, int32_t value, bool force_newgame)
Top function to save the new value of an element of the Settings struct.
@ FAILED
The plugin failed to initialize.
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
std::string name
Name of the plugin.
static Titem * Get(size_t index)
Returns Titem with given index.
@ SEF_LEFT_DEPRESSED
Of a numeric setting entry, the left button is depressed.
const char * GetCurrentLanguageIsoCode()
Get the ISO language code of the currently loaded language.
@ SEF_BUTTONS_MASK
Bit-mask for button flags.
void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback, bool focus)
Show a confirmation window with standard 'yes' and 'no' buttons The window is aligned to the centre o...
Dimensions (a width and height) of a rectangle in 2D.
const TBaseSet * baseset
View the textfile of this BaseSet.
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc)
Display an error message in a window.
static bool NatSortFunc(std::unique_ptr< const DropDownListItem > const &first, std::unique_ptr< const DropDownListItem > const &second)
Natural sorting comparator function for DropDownList::sort().
StringID content_type
STR_CONTENT_TYPE_xxx for title.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
static const SettingDesc * GetSettingFromName(const std::string_view name, const SettingTable &settings)
Given a name of setting, return a setting description from the table.
Window to edit settings of the game.
bool IsEmpty() const
Check whether any filter words were entered.
bool _left_button_down
Is left mouse button pressed?
void GetFoldingState(bool &all_folded, bool &all_unfolded) const override
Recursively accumulate the folding state of the (filtered) tree.
uint Length() const override
Return number of rows needed to display the (filtered) entry.
static GameSettings * settings_ptr
Pointer to the game settings being displayed and modified.
virtual void OnDropdownClose(Point pt, WidgetID widget, int index, bool instant_close)
A dropdown window associated to this window has been closed.
SettingCategory cat
assigned categories of the setting
void SetFilterTerm(const char *str)
Set the term to filter on.
void OnInit() override
Notification that the nested widget tree gets initialized.
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
SettingType type
Filter based on type.
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
@ BASESET_DIR
Subdirectory for all base data (base sets, intro game)
virtual void SetVolume(byte vol)=0
Set the volume, if possible.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
const IntSettingDesc * setting
Setting description of the setting.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
SettingType GetType() const
Return the type of the setting.
virtual void ToggleVsync([[maybe_unused]] bool vsync)
Change the vsync setting.
bool IsEditable(bool do_command=false) const
Check whether the setting is editable in the current gamemode.
uint GetMaxHelpHeight(int maxw)
Get the biggest height of the help texts, if the width is at least maxw.
QueryString filter_editbox
Filter editbox;.
@ ST_CLIENT
Client setting.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
void SetLastField(bool last_field)
Set whether this is the last visible entry of the parent node.
void EnableWidget(WidgetID widget_index)
Sets a widget to Enabled.
Window for displaying the textfile of a BaseSet.
bool _ctrl_pressed
Is Ctrl pressed?
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
StringFilter string
Filter string.
@ ST_COMPANY
Company setting.
EntryVector entries
Settings on this page.
ClientSettings _settings_client
The current settings for this game.
SettingEntry * last_clicked
If non-nullptr, pointer to the last clicked setting.
BaseSettingEntry * FindEntry(uint row, uint *cur_row) override
Find setting entry at row row_num.
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Templated helper to make a type-safe 'typedef' representing a single POD value.
void AddLine(const char *str)
Pass another text line from the current item to the filter.
@ FR_LOWERED
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
SettingFlag flags
Handles how a setting would show up in the GUI (text/currency, etc.).
@ SA_RIGHT
Right align the text (must be a single bit).
@ SEF_FILTERED
Entry is hidden by the string filter.
@ WC_MUSIC_WINDOW
Music window; Window numbers:
bool IsVisibleByRestrictionMode(RestrictionMode mode) const
Checks whether an entry shall be made visible based on the restriction mode.
SettingsPage(StringID title)
Constructor for a sub-page in the 'advanced settings' window.
virtual void Init(byte level=0)
Initialization of a setting entry.
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
Data structure describing one page of settings in the settings window.
bool StrEmpty(const char *s)
Check if a string buffer is empty.
TextfileType file_type
Type of textfile to view.
@ TFT_CHANGELOG
Content changelog.
bool UpdateFilterState(SettingFilter &filter, bool force_visible)
Update the filter state.
Rect WithHeight(int height, bool end=false) const
Copy Rect and set its height.
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
void Init(byte level=0) override
Initialization of a setting entry.
Data stored about a string that can be modified in the GUI.
@ WC_GRF_PARAMETERS
NewGRF parameters; Window numbers:
#define SETBITS(x, y)
Sets several bits in a variable.
void OnTimeout() override
Called when this window's timeout has been reached.
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
int _gui_scale
GUI scale, 100 is 100%.
int GetStringLineCount(StringID str, int maxw)
Calculates number of lines of string.
char *const buf
buffer in which text is saved
std::unique_ptr< NWidgetBase > MakeNWidgetSocialPlugins()
Construct nested container widget for managing the list of social plugins.
@ WN_GAME_OPTIONS_GAME_OPTIONS
Game options.
void FoldAll() override
Recursively close all (filtered) folds of sub-pages.
High level window description.
WarnHiddenResult warn_missing
Whether and how to warn about missing search results.
bool AdjustGUIZoom(bool automatic)
Resolve GUI zoom level and adjust GUI to new zoom, if auto-suggestion is requested.
byte level
Nesting level of this setting entry.
@ INVALID_SIGNATURE
The signature of the plugin is invalid.
SettingType
Type of settings for filtering.
#define DECLARE_POSTFIX_INCREMENT(enum_type)
Some enums need to have allowed incrementing (i.e.
int _gui_scale_cfg
GUI scale in config.
uint16_t refresh_rate
How often we refresh the screen (time between draw-ticks).
void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const override
Function to draw setting value (button + text + current value)
StringID title
Title of the sub-page.
RestrictionMode min_cat
Minimum category needed to display all filtered strings (RM_BASIC, RM_ADVANCED, or RM_ALL).
@ SF_GUI_CURRENCY
The number represents money, so when reading value multiply by exchange rate.
bool UpdateFilterState(SettingFilter &filter, bool force_visible) override
Update the filter state.
@ WC_QUERY_STRING
Query string window; Window numbers:
@ UNLOADED
The plugin is unloaded upon request.
@ SF_GUI_0_IS_SPECIAL
A value of zero is possible and has a custom string (the one after "strval").
void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
Draw a dropdown button.
static constexpr TimerGameCalendar::Year MIN_EURO_YEAR
The earliest year custom currencies may switch to the Euro.
void ResetAll() override
Resets all settings to their default values.
ResizeInfo resize
Resize information.
int warn_lines
Number of lines used for warning about missing search results.
static void ResetAllSettingsConfirmationCallback(Window *w, bool confirmed)
Callback function for the reset all settings button.
virtual std::vector< int > GetListOfMonitorRefreshRates()
Get a list of refresh rates of each available monitor.
static int SETTING_HEIGHT
Height of a single setting in the tree view in pixels.
Information about GRF, used in the game and (part of it) in savegames.
static MusicDriver * GetInstance()
Get the currently active instance of the music driver.
@ FS_NORMAL
Index of the normal font in the font tables.
RestrictionMode
How the list of advanced settings is filtered.
bool UpdateFilterState(SettingFilter &filter, bool force_visible) override
Update the filter state.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
SettingEntry * valuewindow_entry
If non-nullptr, pointer to setting for which a value-entering window has been opened.
void ReInitAllWindows(bool zoom_changed)
Re-initialize all windows.
@ WHR_TYPE
Type setting filtered matches away.
int height
Height of the window (number of pixels down in y direction)
@ WF_CENTERED
Window is centered and shall stay centered after ReInit.
Base integer type, including boolean, settings.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
void SetParameterDefaults()
Set the default value for all parameters as specified by action14.
std::optional< std::string > GetTextfile(TextfileType type, Subdirectory dir, const std::string &filename)
Search a textfile file next to the given content.
@ FS_SMALL
Index of the small font in the font tables.
void ResetAll()
Resets all settings to their default values.
void Init(byte level=0) override
Initialization of an entire setting page.
byte missing_strings_threshold
the number of missing strings before showing the warning
Data structure describing a single setting in a tab.
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
void InitFontCache(bool monospace)
(Re)initialize the font cache related things, i.e.
int32_t def
default value given when none is present
@ RM_END
End for iteration.
bool prefer_sprite
Whether to prefer the built-in sprite font over resizable fonts.
RestrictionMode mode
Filter based on category.
bool IsVisible(const BaseSettingEntry *item) const override
Check whether an entry is visible and not folded or filtered away.
@ DUPLICATE
Another plugin of the same Social Platform is already loaded.
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
void OnDropdownClose(Point pt, WidgetID widget, int index, bool instant_close) override
A dropdown window associated to this window has been closed.
int32_t min
minimum values
const char * name
Name of the setting.
virtual void LoadTextfile(const std::string &textfile, Subdirectory dir)
Loads the textfile text from file and setup lines.
@ WL_INFO
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
const LanguageMetadata * _current_language
The currently loaded language.
void DrawSliderWidget(Rect r, int min_value, int max_value, int value, const std::map< int, StringID > &labels)
Draw a slider widget with knob at given value.
std::string code
3 letter untranslated code to identify the currency.
@ SEF_LAST_FIELD
This entry is the last one in a (sub-)page.
uint64_t GetMaskOfAllowedCurrencies()
get a mask of the allowed currencies depending on the year
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
@ RM_ALL
List all settings regardless of the default/newgame/... values.
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
WindowFlags flags
Window flags.
std::vector< Dimension > _resolutions
List of resolutions.
@ WF_TIMEOUT
Window timeout counter.
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
All settings together for the game.
static const std::string NETWORK_SURVEY_DETAILS_LINK
Link with more details & privacy statement of the survey.
bool folded
Sub-page is folded (not visible except for its title)
void ChangeAutosaveFrequency(bool reset)
Reset the interval of the autosave.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
void OnMouseLoop() override
Called for every mouse loop run, which is at least once per (game) tick.
SettingEntry * valuedropdown_entry
If non-nullptr, pointer to the value for which a dropdown window is currently opened.
void Init(byte level=0)
Initialization of an entire setting page.
Coordinates of a point in 2D.
void CheckBlitter()
Check whether we still use the right blitter, or use another (better) one.
static constexpr TimerGame< struct Calendar >::Year MAX_YEAR
MAX_YEAR, nicely rounded value of the number of years that can be encoded in a single 32 bits date,...
@ RM_BASIC
Display settings associated to the "basic" list.
static void AddCustomRefreshRates()
Add the refresh rate from the config and the refresh rates from all the monitors to our list of refre...
@ WHR_CATEGORY
Category setting filtered matches away.
#define SETTING_BUTTON_WIDTH
Width of setting buttons.
void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right)
Draw [<][>] boxes.
bool type_hides
Whether the type hides filtered strings.
bool SetFocusedWidget(WidgetID widget_index)
Set focus within this window to the given widget.
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
static void ShowCustCurrency()
Open custom currency window.
StringID GetHelp() const
Get the help text of the setting.
@ TFT_README
Content readme.
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.
Specification of a currency.
WarnHiddenResult
Warnings about hidden search results.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
@ CS_ALPHANUMERAL
Both numeric and alphabetic and spaces and stuff.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ WHR_CATEGORY_TYPE
Both category and type settings filtered matches away.
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
@ RUNNING
The plugin is successfully loaded and running.
void ShowBaseSetTextfileWindow(TextfileType file_type, const TBaseSet *baseset, StringID content_type)
Open the BaseSet version of the textfile window.
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
void SetButtons(byte new_val)
Set the button-depressed flags (SEF_LEFT_DEPRESSED and SEF_RIGHT_DEPRESSED) to a specified value.
@ TFT_LICENSE
Content license.
SwitchMode _switch_mode
The next mainloop command.
void OnResize() override
Called after the window got resized.
std::map< WidgetID, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
int DrawStringMultiLine(int left, int right, int top, int bottom, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
@ WC_GAME_OPTIONS
Game options window; Window numbers:
std::string version
Version of the plugin.
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
StringID GetTitle() const
Get the title of the setting.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, bool instant_close)
Show a drop down list.
int CDECL main(int argc, char *argv[])
And the main program (what else?)
int32_t interval
the interval to use between settings in the 'settings' window. If interval is '0' the interval is dyn...
byte currency
currency we currently use
virtual BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find setting entry at row row_num.
void UnFoldAll()
Recursively open all folds of sub-pages.
void DisableWidget(WidgetID widget_index)
Sets a widget to disabled.
void CloseChildWindows(WindowClass wc=WC_INVALID) const
Close all children a window might have in a head-recursive manner.
bool IsVisible(const BaseSettingEntry *item) const
Check whether an entry is visible and not folded or filtered away.
uint Length() const
Return number of rows needed to display the whole page.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
@ RM_CHANGED_AGAINST_DEFAULT
Show only settings which are different compared to default values.
@ SC_BASIC_LIST
Settings displayed in the list of basic settings.
uint32_t autosave_interval
how often should we do autosaves?
bool ClickSliderWidget(Rect r, Point pt, int min_value, int max_value, int &value)
Handle click on a slider widget to change the value.
uint32_t max
maximum values
void OnPaint() override
The window must be repainted.
void UpdateAllVirtCoords()
Update the viewport coordinates of all signs.
void ResetState()
Reset the matching state to process a new item.
int32_t Read(const void *object) const
Read the integer from the the actual setting.
bool _video_hw_accel
Whether to consider hardware accelerated video drivers.
virtual bool IsBoolSetting() const
Check whether this setting is a boolean type setting.
BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find the setting entry at row number row_num.
WidgetID mouse_capture_widget
ID of current mouse capture widget (e.g. dragged scrollbar). -1 if no widget has mouse capture.
bool GetState() const
Get the matching state of the current item.
void SetDParamStr(size_t n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
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 override
Draw a row in the settings panel.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
void SetValueDParams(uint first_param, int32_t value) const
Set the DParams for drawing the value of the setting.
@ WL_ERROR
Errors (eg. saving/loading failed)
@ UNSUPPORTED_API
The plugin does not support the current API version.
@ SM_MENU
Switch to game intro menu.
static uint GetCurrentResolutionIndex()
Get index of the current screen resolution.
static const int ACTION_CLEAR
Clear editbox.
@ CS_NUMERAL_SIGNED
Only numbers and '-' for negative values.
void SetWidgetsLoweredState(bool lowered_stat, Args... widgets)
Sets the lowered/raised status of a list of widgets.
void UnFoldAll() override
Recursively open all (filtered) folds of sub-pages.
static constexpr TimerGameCalendar::Year CF_NOEURO
Currency never switches to the Euro (as far as known).
void FoldAll()
Recursively close all folds of sub-pages.
void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const override
Function to draw setting value (button + text + current value)
bool _video_vsync
Whether we should use vsync (only if _video_hw_accel is enabled).
void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher)
Check whether the currently loaded language pack uses characters that the currently loaded font does ...
@ SA_CENTER
Center both horizontally and vertically.
@ PLATFORM_NOT_RUNNING
The plugin failed to initialize because the Social Platform is not running.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
SettingFilter filter
Filter for the list.
#define lengthof(x)
Return the length of an fixed size array.
int width
width of the window (number of pixels to the right in x direction)
byte effect_vol
The requested effects volume.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
NetworkSettings network
settings related to the network
uint8_t num_params
Number of used parameters.
LocaleSettings locale
settings related to used currency/unit system in the current game
std::string social_platform
Social platform this plugin is for.
virtual bool IsVisible(const BaseSettingEntry *item) const
Check whether an entry is visible and not folded or filtered away.
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
SettingEntry(const char *name)
Constructor for a single setting in the 'advanced settings' window.
Filter for settings list.
@ RM_CHANGED_AGAINST_NEW
Show only settings which are different compared to the user's new game setting values.
Window for displaying a textfile.
static SettingsContainer & GetSettingsTree()
Construct settings tree.
@ ST_ALL
Used in setting filter to match all types.
GameSettings & GetGameSettings()
Get the settings-object applicable for the current situation: the newgame settings when we're in the ...
CompanySettings company
default values for per-company settings
Containers for BaseSettingEntry.
bool closing_dropdown
True, if the dropdown list is currently closing.
byte flags
Flags of the setting entry.
Data structure for an opened window.
TextfileType
Additional text files accompanying Tar archives.
static std::string ini_set
The set as saved in the config file.
@ SC_ADVANCED_LIST
Settings displayed in the list of advanced settings.
void OnResize() override
Called after the window got resized.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
void DrawWidgets() const
Paint all widgets of a window.
@ SF_GUI_DROPDOWN
The value represents a limited number of string-options (internally integer) presented as dropdown.
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
void ShowGameSettings()
Open advanced settings window.
Dimension GetDropDownListDimension(const DropDownList &list)
Determine width and height required to fully display a DropDownList.
void DrawBoolButton(int x, int y, bool state, bool clickable)
Draw a toggle button.
int Width() const
Get width of Rect.
bool scale_bevels
bevels are scaled with GUI scale.
@ SF_PER_COMPANY
This setting can be different for each company (saved in company struct).
LanguageList _languages
The actual list of language meta data.
DropDownList BuildDropDownList(WidgetID widget, int *selected_index) const
Build the dropdown list for a specific widget.
Specification of a rectangle with absolute coordinates of all edges.
bool manually_changed_folding
Whether the user expanded/collapsed something manually.
bool global_aa
Whether to anti alias all font sizes.
@ WC_DROPDOWN_MENU
Drop down menu; Window numbers:
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.
void SetDisplayedHelpText(SettingEntry *pe)
Set the entry that should have its help text displayed, and mark the window dirty so it gets repainte...
uint Length() const override
Return number of rows needed to display the (filtered) entry.
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
@ QSF_ENABLE_DEFAULT
enable the 'Default' button ("\0" is returned)
MusicSettings music
settings related to music/sound
#define CLRBITS(x, y)
Clears several bits in a variable.
@ WC_TEXTFILE
textfile; Window numbers:
@ WHR_NONE
Nothing was filtering matches away.
void GetFoldingState(bool &all_folded, bool &all_unfolded) const
Recursively accumulate the folding state of the tree.
@ WDP_CENTER
Center the window.
void ChangeMusicSet(int index)
Change the configured music set and reset playback.
#define SETTING_BUTTON_HEIGHT
Height of setting buttons.
SettingEntry * clicked_entry
If non-nullptr, pointer to a clicked numeric setting (with a depressed left or right button).
bool ReadLanguagePack(const LanguageMetadata *lang)
Read a particular language.
byte music_vol
The requested music volume.
bool _left_button_clicked
Is left mouse button clicked?
@ TD_RTL
Text is written right-to-left by default.
TextDirection _current_text_dir
Text direction of the currently selected language.
static Dimension _circle_size
Dimension of the circle +/- icon. This is here as not all users are within the class of the settings ...
@ CS_NUMERAL
Only numeric ones.
CharSetFilter
Valid filter types for IsValidChar.
static std::vector< SocialIntegrationPlugin * > GetPlugins()
Get the list of loaded social integration plugins.
CurrencySpec _currency_specs[CURRENCY_END]
Array of currencies used by the system.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
@ CURRENCY_CUSTOM
Custom currency.
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
GUISettings gui
settings related to the GUI
void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, WidgetID button, Rect wi_rect, Colours wi_colour, bool instant_close)
Show a drop down list.
const struct IntSettingDesc * AsIntSetting() const
Get the setting description of this setting as an integer setting.
uint GetMaxHelpHeight(int maxw) override
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.
ParticipateSurvey participate_survey
Participate in the automated survey.
@ RM_ADVANCED
Display settings associated to the "advanced" list.
@ WN_GAME_OPTIONS_GAME_SETTINGS
Game settings.
void ShowGameOptions()
Open the game options window.
SettingEntryFlags
Flags for SettingEntry.
uint8_t settings_restriction_mode
selected restriction mode in adv. settings GUI.
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.