26#include "slider_func.h"
57#if defined(WITH_FREETYPE) || defined(_WIN32) || defined(WITH_COCOA)
58# define HAS_TRUETYPE_FONT
61static const StringID _autosave_dropdown[] = {
62 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_OFF,
63 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_10_MINUTES,
64 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_30_MINUTES,
65 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_60_MINUTES,
66 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_120_MINUTES,
102 this->ConstructWindow();
121template <
class TBaseSet>
131 int n = T::GetNumSets();
132 *selected_index = T::GetIndexOfUsedSet();
134 for (
int i = 0; i < n; i++) {
135 list.push_back(MakeDropDownListStringItem(T::GetSet(i)->GetListLabel(), i));
140std::set<int> _refresh_rates = { 30, 60, 75, 90, 100, 120, 144, 240 };
153 std::copy(monitorRates.begin(), monitorRates.end(), std::inserter(_refresh_rates, _refresh_rates.end()));
156static const int SCALE_NMARKS = (MAX_INTERFACE_SCALE - MIN_INTERFACE_SCALE) / 25 + 1;
157static const int VOLUME_NMARKS = 9;
159static StringID ScaleMarkFunc(
int,
int,
int value)
162 if (value % 100 != 0)
return STR_NULL;
166 return STR_GAME_OPTIONS_GUI_SCALE_MARK;
169static StringID VolumeMarkFunc(
int,
int mark,
int value)
172 if (mark % 2 != 0)
return STR_NULL;
175 return STR_GAME_OPTIONS_VOLUME_MARK;
178static constexpr NWidgetPart _nested_social_plugins_widgets[] = {
193static constexpr NWidgetPart _nested_social_plugins_none_widgets[] = {
205 if (this->plugins.empty()) {
206 auto widget =
MakeNWidgets(_nested_social_plugins_none_widgets,
nullptr);
207 this->
Add(std::move(widget));
209 for (
size_t i = 0; i < this->plugins.size(); i++) {
210 auto widget =
MakeNWidgets(_nested_social_plugins_widgets,
nullptr);
211 this->
Add(std::move(widget));
226 this->current_index = -1;
236 template <
typename T>
239 std::string *longest = &(this->plugins[0]->*member);
240 int longest_length = 0;
242 for (
auto *plugin : this->plugins) {
244 if (length > longest_length) {
245 longest_length = length;
246 longest = &(plugin->*member);
253 void SetStringParameters(
int widget)
const
258 if (this->current_index < 0) {
259 SetDParam(0, STR_GAME_OPTIONS_SOCIAL_PLUGIN_TITLE);
265 if (this->plugins[this->current_index]->name.empty()) {
267 SetDParamStr(1, this->plugins[this->current_index]->basepath);
269 SetDParam(0, STR_GAME_OPTIONS_SOCIAL_PLUGIN_TITLE);
270 SetDParamStr(1, this->plugins[this->current_index]->name);
271 SetDParamStr(2, this->plugins[this->current_index]->version);
277 if (this->current_index < 0) {
282 SetDParamStr(0, this->plugins[this->current_index]->social_platform);
286 static const std::pair<SocialIntegrationPlugin::State, StringID> state_to_string[] = {
297 if (this->current_index < 0) {
304 int longest_length = 0;
305 for (
auto state : state_to_string) {
307 if (length > longest_length) {
308 longest_length = length;
309 longest = state.second;
318 auto plugin = this->plugins[this->current_index];
321 SetDParam(0, STR_GAME_OPTIONS_SOCIAL_PLUGIN_STATE_FAILED);
325 for (
auto state : state_to_string) {
326 if (plugin->state == state.first) {
338 this->current_index = 0;
342 this->current_index++;
347 int current_index = -1;
348 std::vector<SocialIntegrationPlugin *> plugins;
354 return std::make_unique<NWidgetSocialPlugins>();
366 this->reload =
false;
374 this->SetTab(GameOptionsWindow::active_tab);
405 if (currency.code.empty()) {
406 list.push_back(MakeDropDownListStringItem(currency.name, i,
HasBit(disabled, i)));
416 list.push_back(MakeDropDownListDividerItem());
429 const StringID *items = _autosave_dropdown;
431 list.push_back(MakeDropDownListStringItem(*items, i));
437 for (uint i = 0; i <
_languages.size(); i++) {
471 for (
auto it = _refresh_rates.begin(); it != _refresh_rates.end(); it++) {
472 auto i = std::distance(_refresh_rates.begin(), it);
500 if (currency.
code.empty()) {
515 SetDParam(0, _autosave_dropdown[index - 1]);
540 assert(plugin !=
nullptr);
542 plugin->SetStringParameters(widget);
567 DrawSliderWidget(r, MIN_INTERFACE_SCALE, MAX_INTERFACE_SCALE, SCALE_NMARKS, this->gui_scale, ScaleMarkFunc);
589 GameOptionsWindow::active_tab = widget;
597 default: NOT_REACHED();
646 d.width += padding.width;
647 d.height += padding.height;
692 this->SetTab(widget);
716 ShowSurveyResultTextfileWindow();
721 if (!ToggleFullScreen(!_fullscreen)) {
763#ifdef HAS_TRUETYPE_FONT
815 if (used_set ==
nullptr || !used_set->IsConfigurable())
break;
816 GRFConfig &extra_cfg = used_set->GetOrCreateExtraConfig();
818 OpenGRFParameterWindow(
true, &extra_cfg, _game_mode == GM_MENU);
819 if (_game_mode == GM_MENU) this->reload =
true;
830 SetEffectVolume(
vol);
924 ClearAllCachedNames();
947 if (_game_mode == GM_MENU) {
986#ifdef HAS_TRUETYPE_FONT
1010static constexpr NWidgetPart _nested_game_options_widgets[] = {
1057 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),
1066#ifdef HAS_TRUETYPE_FONT
1134 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),
1138 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),
1147 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),
1166 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),
1196 _nested_game_options_widgets
1250 virtual void FoldAll() {}
1251 virtual void UnFoldAll() {}
1252 virtual void ResetAll() = 0;
1260 virtual uint Length()
const = 0;
1261 virtual void GetFoldingState([[maybe_unused]]
bool &all_folded, [[maybe_unused]]
bool &all_unfolded)
const {}
1264 virtual uint GetMaxHelpHeight([[maybe_unused]]
int maxw) {
return 0; }
1272 virtual bool UpdateFilterState(
SettingFilter &filter,
bool force_visible) = 0;
1274 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;
1277 virtual void DrawSetting(
GameSettings *settings_ptr,
int left,
int right,
int y,
bool highlight)
const = 0;
1288 void ResetAll()
override;
1289 uint
Length()
const override;
1304 typedef std::vector<BaseSettingEntry*> EntryVector;
1307 template<
typename T>
1310 this->entries.push_back(item);
1314 void Init(uint8_t level = 0);
1327 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;
1342 uint
Length()
const override;
1343 void GetFoldingState(
bool &all_folded,
bool &all_unfolded)
const override;
1350 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;
1364 this->level =
level;
1376 return this == item;
1388 if (row_num == *cur_row)
return this;
1425 if (cur_row >= max_row)
return cur_row;
1431 int x = rtl ? right : left;
1432 if (cur_row >= first_row) {
1437 for (uint lvl = 0; lvl < this->
level; lvl++) {
1438 if (!
HasBit(parent_last, lvl)) GfxDrawLine(x + offset, y, x + offset, y +
SETTING_HEIGHT - 1, colour);
1444 GfxDrawLine(x + offset, y, x + offset, bottom_y, colour);
1449 this->DrawSetting(settings_ptr, rtl ? left : x, rtl ? x : right, y,
this == selected);
1479void SettingEntry::ResetAll()
1492 this->
flags = (this->
flags & ~SEF_BUTTONS_MASK) | new_val;
1519 if (mode ==
RM_ALL)
return true;
1528 int64_t current_value = sd->
Read(
object);
1529 int64_t filter_value;
1535 filter_value = sd->
def;
1548 return current_value != filter_value;
1561 bool visible =
true;
1598 return settings_ptr;
1624 int32_t value = sd->
Read(ResolveObject(settings_ptr, sd));
1648 for (
auto &it : this->
entries) {
1656 for (
auto settings_entry : this->
entries) {
1657 settings_entry->ResetAll();
1664 for (
auto &it : this->
entries) {
1672 for (
auto &it : this->
entries) {
1684 for (
auto &it : this->
entries) {
1685 it->GetFoldingState(all_folded, all_unfolded);
1697 bool visible =
false;
1698 bool first_visible =
true;
1699 for (EntryVector::reverse_iterator it = this->
entries.rbegin(); it != this->
entries.rend(); ++it) {
1700 visible |= (*it)->UpdateFilterState(filter, force_visible);
1701 (*it)->SetLastField(first_visible);
1702 if (visible && first_visible) first_visible =
false;
1716 for (
const auto &it : this->
entries) {
1717 if (it->IsVisible(item))
return true;
1726 for (
const auto &it : this->
entries) {
1727 length += it->Length();
1741 for (
const auto &it : this->
entries) {
1743 if (pe !=
nullptr) {
1758 for (
const auto &it : this->
entries) {
1759 biggest = std::max(biggest, it->GetMaxHelpHeight(maxw));
1781 for (
const auto &it : this->
entries) {
1782 cur_row = it->Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1783 if (cur_row >= max_row)
break;
1796 this->title =
title;
1813 for (
auto settings_entry : this->
entries) {
1814 settings_entry->ResetAll();
1846 all_unfolded =
false;
1886 if (
this == item)
return true;
1887 if (this->
folded)
return false;
1896 if (this->
folded)
return 1;
1910 if (row_num == *cur_row)
return this;
1912 if (this->
folded)
return nullptr;
1934 if (cur_row >= max_row)
return cur_row;
1936 cur_row =
BaseSettingEntry::Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1940 assert(this->
level < 8 *
sizeof(parent_last));
1944 cur_row =
SettingsContainer::Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1968 if (main ==
nullptr)
1975 localisation->Add(
new SettingEntry(
"locale.units_velocity"));
1976 localisation->Add(
new SettingEntry(
"locale.units_velocity_nautical"));
1977 localisation->Add(
new SettingEntry(
"locale.units_power"));
1978 localisation->Add(
new SettingEntry(
"locale.units_weight"));
1979 localisation->Add(
new SettingEntry(
"locale.units_volume"));
1980 localisation->Add(
new SettingEntry(
"locale.units_force"));
1981 localisation->Add(
new SettingEntry(
"locale.units_height"));
1982 localisation->Add(
new SettingEntry(
"gui.date_format_in_default_names"));
1989 graphics->Add(
new SettingEntry(
"gui.sprite_zoom_min"));
1990 graphics->Add(
new SettingEntry(
"gui.smallmap_land_colour"));
1991 graphics->Add(
new SettingEntry(
"gui.linkgraph_colours"));
1992 graphics->Add(
new SettingEntry(
"gui.graph_line_thickness"));
2014 general->Add(
new SettingEntry(
"gui.window_snap_radius"));
2015 general->Add(
new SettingEntry(
"gui.window_soft_limit"));
2016 general->Add(
new SettingEntry(
"gui.right_click_wnd_close"));
2021 viewports->Add(
new SettingEntry(
"gui.auto_scrolling"));
2027 viewports->Add(
new SettingEntry(
"gui.scrollwheel_scrolling"));
2028 viewports->Add(
new SettingEntry(
"gui.scrollwheel_multiplier"));
2031 viewports->Add(
new SettingEntry(
"gui.right_mouse_btn_emulation"));
2033 viewports->Add(
new SettingEntry(
"gui.population_in_label"));
2035 viewports->Add(
new SettingEntry(
"construction.train_signal_side"));
2036 viewports->Add(
new SettingEntry(
"gui.measure_tooltip"));
2037 viewports->Add(
new SettingEntry(
"gui.loading_indicators"));
2038 viewports->Add(
new SettingEntry(
"gui.show_track_reservation"));
2043 construction->Add(
new SettingEntry(
"gui.link_terraform_toolbar"));
2044 construction->Add(
new SettingEntry(
"gui.persistent_buildingtools"));
2045 construction->Add(
new SettingEntry(
"gui.default_rail_type"));
2046 construction->Add(
new SettingEntry(
"gui.semaphore_build_before"));
2047 construction->Add(
new SettingEntry(
"gui.signal_gui_mode"));
2048 construction->Add(
new SettingEntry(
"gui.cycle_signal_types"));
2049 construction->Add(
new SettingEntry(
"gui.drag_signals_fixed_distance"));
2050 construction->Add(
new SettingEntry(
"gui.auto_remove_signals"));
2055 interface->Add(
new SettingEntry(
"gui.prefer_teamchat"));
2056 interface->Add(
new SettingEntry(
"gui.advanced_vehicle_list"));
2057 interface->Add(
new SettingEntry(
"gui.timetable_mode"));
2058 interface->Add(
new SettingEntry(
"gui.timetable_arrival_departure"));
2059 interface->Add(
new SettingEntry(
"gui.show_newgrf_name"));
2060 interface->Add(
new SettingEntry(
"gui.show_cargo_in_vehicle_lists"));
2065 advisors->Add(
new SettingEntry(
"gui.coloured_news_year"));
2066 advisors->Add(
new SettingEntry(
"news_display.general"));
2067 advisors->Add(
new SettingEntry(
"news_display.new_vehicles"));
2068 advisors->Add(
new SettingEntry(
"news_display.accident"));
2069 advisors->Add(
new SettingEntry(
"news_display.accident_other"));
2070 advisors->Add(
new SettingEntry(
"news_display.company_info"));
2071 advisors->Add(
new SettingEntry(
"news_display.acceptance"));
2072 advisors->Add(
new SettingEntry(
"news_display.arrival_player"));
2073 advisors->Add(
new SettingEntry(
"news_display.arrival_other"));
2074 advisors->Add(
new SettingEntry(
"news_display.advice"));
2075 advisors->Add(
new SettingEntry(
"gui.order_review_system"));
2076 advisors->Add(
new SettingEntry(
"gui.vehicle_income_warn"));
2077 advisors->Add(
new SettingEntry(
"gui.lost_vehicle_warn"));
2078 advisors->Add(
new SettingEntry(
"gui.old_vehicle_warn"));
2080 advisors->Add(
new SettingEntry(
"news_display.economy"));
2081 advisors->Add(
new SettingEntry(
"news_display.subsidies"));
2084 advisors->Add(
new SettingEntry(
"news_display.production_player"));
2085 advisors->Add(
new SettingEntry(
"news_display.production_other"));
2086 advisors->Add(
new SettingEntry(
"news_display.production_nobody"));
2092 company->Add(
new SettingEntry(
"gui.starting_colour_secondary"));
2093 company->Add(
new SettingEntry(
"company.engine_renew"));
2094 company->Add(
new SettingEntry(
"company.engine_renew_months"));
2095 company->Add(
new SettingEntry(
"company.engine_renew_money"));
2096 company->Add(
new SettingEntry(
"vehicle.servint_ispercent"));
2097 company->Add(
new SettingEntry(
"vehicle.servint_trains"));
2098 company->Add(
new SettingEntry(
"vehicle.servint_roadveh"));
2099 company->Add(
new SettingEntry(
"vehicle.servint_ships"));
2100 company->Add(
new SettingEntry(
"vehicle.servint_aircraft"));
2105 accounting->Add(
new SettingEntry(
"difficulty.infinite_money"));
2106 accounting->Add(
new SettingEntry(
"economy.inflation"));
2107 accounting->Add(
new SettingEntry(
"difficulty.initial_interest"));
2108 accounting->Add(
new SettingEntry(
"difficulty.max_loan"));
2109 accounting->Add(
new SettingEntry(
"difficulty.subsidy_multiplier"));
2110 accounting->Add(
new SettingEntry(
"difficulty.subsidy_duration"));
2111 accounting->Add(
new SettingEntry(
"economy.feeder_payment_share"));
2112 accounting->Add(
new SettingEntry(
"economy.infrastructure_maintenance"));
2113 accounting->Add(
new SettingEntry(
"difficulty.vehicle_costs"));
2114 accounting->Add(
new SettingEntry(
"difficulty.construction_cost"));
2121 physics->Add(
new SettingEntry(
"vehicle.train_acceleration_model"));
2122 physics->Add(
new SettingEntry(
"vehicle.train_slope_steepness"));
2123 physics->Add(
new SettingEntry(
"vehicle.wagon_speed_limits"));
2124 physics->Add(
new SettingEntry(
"vehicle.freight_trains"));
2125 physics->Add(
new SettingEntry(
"vehicle.roadveh_acceleration_model"));
2126 physics->Add(
new SettingEntry(
"vehicle.roadveh_slope_steepness"));
2127 physics->Add(
new SettingEntry(
"vehicle.smoke_amount"));
2134 routing->Add(
new SettingEntry(
"difficulty.line_reverse_mode"));
2135 routing->Add(
new SettingEntry(
"pf.reverse_at_signals"));
2149 limitations->Add(
new SettingEntry(
"construction.command_pause_level"));
2150 limitations->Add(
new SettingEntry(
"construction.autoslope"));
2151 limitations->Add(
new SettingEntry(
"construction.extra_dynamite"));
2152 limitations->Add(
new SettingEntry(
"construction.map_height_limit"));
2153 limitations->Add(
new SettingEntry(
"construction.max_bridge_length"));
2154 limitations->Add(
new SettingEntry(
"construction.max_bridge_height"));
2155 limitations->Add(
new SettingEntry(
"construction.max_tunnel_length"));
2156 limitations->Add(
new SettingEntry(
"station.never_expire_airports"));
2157 limitations->Add(
new SettingEntry(
"vehicle.never_expire_vehicles"));
2158 limitations->Add(
new SettingEntry(
"vehicle.max_trains"));
2159 limitations->Add(
new SettingEntry(
"vehicle.max_roadveh"));
2160 limitations->Add(
new SettingEntry(
"vehicle.max_aircraft"));
2161 limitations->Add(
new SettingEntry(
"vehicle.max_ships"));
2162 limitations->Add(
new SettingEntry(
"vehicle.max_train_length"));
2163 limitations->Add(
new SettingEntry(
"station.station_spread"));
2164 limitations->Add(
new SettingEntry(
"station.distant_join_stations"));
2165 limitations->Add(
new SettingEntry(
"station.modified_catchment"));
2166 limitations->Add(
new SettingEntry(
"construction.road_stop_on_town_road"));
2167 limitations->Add(
new SettingEntry(
"construction.road_stop_on_competitor_road"));
2168 limitations->Add(
new SettingEntry(
"construction.crossing_with_competitor"));
2169 limitations->Add(
new SettingEntry(
"vehicle.disable_elrails"));
2170 limitations->Add(
new SettingEntry(
"order.station_length_loading_penalty"));
2175 disasters->Add(
new SettingEntry(
"difficulty.disasters"));
2176 disasters->Add(
new SettingEntry(
"difficulty.economy"));
2177 disasters->Add(
new SettingEntry(
"vehicle.plane_crashes"));
2178 disasters->Add(
new SettingEntry(
"difficulty.vehicle_breakdowns"));
2179 disasters->Add(
new SettingEntry(
"order.no_servicing_if_no_breakdowns"));
2180 disasters->Add(
new SettingEntry(
"order.serviceathelipad"));
2185 genworld->Add(
new SettingEntry(
"game_creation.landscape"));
2186 genworld->Add(
new SettingEntry(
"game_creation.land_generator"));
2187 genworld->Add(
new SettingEntry(
"difficulty.terrain_type"));
2188 genworld->Add(
new SettingEntry(
"game_creation.tgen_smoothness"));
2189 genworld->Add(
new SettingEntry(
"game_creation.variety"));
2190 genworld->Add(
new SettingEntry(
"game_creation.snow_coverage"));
2191 genworld->Add(
new SettingEntry(
"game_creation.snow_line_height"));
2192 genworld->Add(
new SettingEntry(
"game_creation.desert_coverage"));
2193 genworld->Add(
new SettingEntry(
"game_creation.amount_of_rivers"));
2200 time->Add(
new SettingEntry(
"economy.timekeeping_units"));
2201 time->Add(
new SettingEntry(
"economy.minutes_per_calendar_year"));
2202 time->Add(
new SettingEntry(
"game_creation.ending_year"));
2204 time->Add(
new SettingEntry(
"gui.fast_forward_speed_limit"));
2209 authorities->Add(
new SettingEntry(
"difficulty.town_council_tolerance"));
2211 authorities->Add(
new SettingEntry(
"economy.exclusive_rights"));
2212 authorities->Add(
new SettingEntry(
"economy.fund_roads"));
2213 authorities->Add(
new SettingEntry(
"economy.fund_buildings"));
2214 authorities->Add(
new SettingEntry(
"economy.station_noise_level"));
2219 towns->Add(
new SettingEntry(
"economy.town_cargo_scale"));
2220 towns->Add(
new SettingEntry(
"economy.town_growth_rate"));
2221 towns->Add(
new SettingEntry(
"economy.allow_town_roads"));
2222 towns->Add(
new SettingEntry(
"economy.allow_town_level_crossings"));
2226 towns->Add(
new SettingEntry(
"economy.initial_city_size"));
2227 towns->Add(
new SettingEntry(
"economy.town_cargogen_mode"));
2232 industries->Add(
new SettingEntry(
"economy.industry_cargo_scale"));
2233 industries->Add(
new SettingEntry(
"difficulty.industry_density"));
2234 industries->Add(
new SettingEntry(
"construction.raw_industry_construction"));
2235 industries->Add(
new SettingEntry(
"construction.industry_platform"));
2236 industries->Add(
new SettingEntry(
"economy.multiple_industry_per_town"));
2237 industries->Add(
new SettingEntry(
"game_creation.oil_refinery_limit"));
2239 industries->Add(
new SettingEntry(
"station.serve_neutral_industries"));
2245 cdist->Add(
new SettingEntry(
"linkgraph.recalc_interval"));
2246 cdist->Add(
new SettingEntry(
"linkgraph.distribution_pax"));
2247 cdist->Add(
new SettingEntry(
"linkgraph.distribution_mail"));
2248 cdist->Add(
new SettingEntry(
"linkgraph.distribution_armoured"));
2249 cdist->Add(
new SettingEntry(
"linkgraph.distribution_default"));
2251 cdist->Add(
new SettingEntry(
"linkgraph.demand_distance"));
2253 cdist->Add(
new SettingEntry(
"linkgraph.short_path_saturation"));
2258 trees->Add(
new SettingEntry(
"game_creation.tree_placer"));
2259 trees->Add(
new SettingEntry(
"construction.extra_tree_placement"));
2267 npc->Add(
new SettingEntry(
"script.script_max_opcode_till_suspend"));
2268 npc->Add(
new SettingEntry(
"script.script_max_memory_megabytes"));
2269 npc->Add(
new SettingEntry(
"difficulty.competitor_speed"));
2272 npc->Add(
new SettingEntry(
"ai.ai_disable_veh_roadveh"));
2273 npc->Add(
new SettingEntry(
"ai.ai_disable_veh_aircraft"));
2282 network->Add(
new SettingEntry(
"network.use_relay_service"));
2290static const StringID _game_settings_restrict_dropdown[] = {
2291 STR_CONFIG_SETTING_RESTRICT_BASIC,
2292 STR_CONFIG_SETTING_RESTRICT_ADVANCED,
2293 STR_CONFIG_SETTING_RESTRICT_ALL,
2294 STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_DEFAULT,
2295 STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_NEW,
2297static_assert(
lengthof(_game_settings_restrict_dropdown) ==
RM_END);
2342 this->warn_lines = 0;
2351 this->valuewindow_entry =
nullptr;
2352 this->clicked_entry =
nullptr;
2353 this->last_clicked =
nullptr;
2354 this->valuedropdown_entry =
nullptr;
2355 this->closing_dropdown =
false;
2356 this->manually_changed_folding =
false;
2395 std::max(size.height,
GetSettingsTree().GetMaxHelpHeight(size.width));
2411 if (this->closing_dropdown) {
2412 this->closing_dropdown =
false;
2413 assert(this->valuedropdown_entry !=
nullptr);
2415 this->valuedropdown_entry =
nullptr;
2422 if (this->warn_missing ==
WHR_NONE) {
2436 if (this->warn_missing !=
WHR_NONE) {
2446 SetDParam(0, _game_settings_restrict_dropdown[this->filter.
mode]);
2450 switch (this->filter.
type) {
2465 for (
int mode = 0; mode !=
RM_END; mode++) {
2470 list.push_back(MakeDropDownListStringItem(_game_settings_restrict_dropdown[mode], mode, disabled));
2498 if (this->last_clicked !=
nullptr) {
2502 switch (
sd->GetType()) {
2506 default: NOT_REACHED();
2531 if (this->last_clicked != pe) this->
SetDirty();
2532 this->last_clicked = pe;
2539 this->manually_changed_folding =
true;
2545 this->manually_changed_folding =
true;
2561 if (!list.empty()) {
2569 if (!list.empty()) {
2595 this->manually_changed_folding =
true;
2606 if (!
sd->IsEditable()) {
2617 if (this->valuedropdown_entry == pe) {
2620 this->closing_dropdown =
false;
2622 this->valuedropdown_entry =
nullptr;
2624 if (this->valuedropdown_entry !=
nullptr) this->valuedropdown_entry->
SetButtons(0);
2625 this->closing_dropdown =
false;
2637 if (
pt.y >= wi_rect.top &&
pt.y <= wi_rect.bottom) {
2638 this->valuedropdown_entry = pe;
2642 for (
int i =
sd->min; i <= (
int)
sd->max; i++) {
2643 sd->SetValueDParams(0, i);
2655 if (
sd->IsBoolSetting()) {
2688 if (this->clicked_entry !=
nullptr) {
2689 this->clicked_entry->SetButtons(0);
2691 this->clicked_entry = pe;
2712 this->valuewindow_entry = pe;
2723 if (this->clicked_entry !=
nullptr) {
2725 this->clicked_entry =
nullptr;
2733 if (!str.has_value())
return;
2735 assert(this->valuewindow_entry !=
nullptr);
2739 if (!str->empty()) {
2746 }
else if (
sd->get_def_cb !=
nullptr) {
2747 value =
sd->get_def_cb();
2764 if (!this->manually_changed_folding) {
2783 assert(this->valuedropdown_entry !=
nullptr);
2806 assert(this->valuedropdown_entry !=
nullptr);
2807 this->closing_dropdown =
true;
2831 if (this->last_clicked !=
nullptr && !
GetSettingsTree().IsVisible(this->last_clicked)) {
2863static constexpr NWidgetPart _nested_settings_selection_widgets[] = {
2873 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),
2877 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),
2907 _nested_settings_selection_widgets
2927void DrawArrowButtons(
int x,
int y, Colours button_colour, uint8_t state,
bool clickable_left,
bool clickable_right)
2930 Dimension dim = NWidgetScrollbar::GetHorizontalDimension();
2932 Rect lr = {x, y, x + (int)dim.width - 1, y + (
int)dim.height - 1};
2933 Rect rr = {x + (int)dim.width, y, x + (
int)dim.width * 2 - 1, y + (int)dim.height - 1};
2937 DrawSpriteIgnorePadding(SPR_ARROW_LEFT, PAL_NONE, lr,
SA_CENTER);
2938 DrawSpriteIgnorePadding(SPR_ARROW_RIGHT, PAL_NONE, rr,
SA_CENTER);
2942 if (rtl ? !clickable_right : !clickable_left) {
2945 if (rtl ? !clickable_left : !clickable_right) {
2965 DrawSpriteIgnorePadding(SPR_ARROW_DOWN, PAL_NONE, r,
SA_CENTER);
2981 static const Colours _bool_ctabs[2][2] = {{COLOUR_CREAM, COLOUR_RED}, {COLOUR_DARK_GREEN, COLOUR_GREEN}};
2997 void SetButtonState()
3124 this->query_widget = line;
3134 if (!str.has_value())
return;
3136 switch (this->query_widget) {
3170static constexpr NWidgetPart _nested_cust_currency_widgets[] = {
3206 SetDataTip(STR_CURRENCY_PREVIEW, STR_CURRENCY_CUSTOM_CURRENCY_PREVIEW_TOOLTIP),
3215 _nested_cust_currency_widgets
void UpdateAllVirtCoords()
Update the viewport coordinates of all signs.
Base functions for all AIs.
debug_inline constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
#define CLRBITS(x, y)
Clears several bits in a variable.
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
#define SETBITS(x, y)
Sets several bits in a variable.
static bool NatSortFunc(std::unique_ptr< const DropDownListItem > const &first, std::unique_ptr< const DropDownListItem > const &second)
Natural sorting comparator function for DropDownList::sort().
static MusicDriver * GetInstance()
Get the currently active instance of the music driver.
virtual void SetVolume(uint8_t vol)=0
Set the volume, if possible.
@ PLATFORM_NOT_RUNNING
The plugin failed to initialize because the Social Platform is not running.
@ UNSUPPORTED_API
The plugin does not support the current API version.
@ RUNNING
The plugin is successfully loaded and running.
@ FAILED
The plugin failed to initialize.
@ DUPLICATE
Another plugin of the same Social Platform is already loaded.
@ INVALID_SIGNATURE
The signature of the plugin is invalid.
@ UNLOADED
The plugin is unloaded upon request.
std::string social_platform
Social platform this plugin is for.
std::string name
Name of the plugin.
std::string version
Version of the plugin.
static std::vector< SocialIntegrationPlugin * > GetPlugins()
Get the list of loaded social integration plugins.
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,...
virtual void ToggleVsync(bool vsync)
Change the vsync setting.
static VideoDriver * GetInstance()
Get the currently active instance of the video driver.
virtual std::vector< int > GetListOfMonitorRefreshRates()
Get a list of refresh rates of each available monitor.
Functions related to commands.
Definition of stuff that is very close to a company, like the company struct itself.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Functions related to companies.
Configuration options of the network stuff.
static const std::string NETWORK_SURVEY_DETAILS_LINK
Link with more details & privacy statement of the survey.
std::array< CurrencySpec, CURRENCY_END > _currency_specs
Array of currencies used by the system.
Functions to handle different currencies.
static constexpr TimerGameCalendar::Year MIN_EURO_YEAR
The earliest year custom currencies may switch to the Euro.
CurrencySpec & GetCustomCurrency()
Get the custom currency.
static constexpr TimerGameCalendar::Year CF_NOEURO
Currency never switches to the Euro (as far as known).
const CurrencySpec & GetCurrency()
Get the currently selected currency.
@ CURRENCY_CUSTOM
Custom currency.
std::vector< Dimension > _resolutions
List of resolutions.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, bool instant_close, bool persist)
Show a drop down list.
Dimension GetDropDownListDimension(const DropDownList &list)
Determine width and height required to fully display a DropDownList.
void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, WidgetID button, Rect wi_rect, Colours wi_colour, bool instant_close, bool persist)
Show a drop down list.
Common drop down list components.
Functions related to the drop down widget.
Types related to the drop down widget.
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
#define DECLARE_POSTFIX_INCREMENT(enum_type)
Some enums need to have allowed incrementing (i.e.
Functions related to errors.
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc)
Display an error message in a window.
@ WL_ERROR
Errors (eg. saving/loading failed)
@ WL_INFO
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
Factory to 'query' all available blitters.
@ BASESET_DIR
Subdirectory for all base data (base sets, intro game)
void InitFontCache(bool monospace)
(Re)initialize the font cache related things, i.e.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Functions to read fonts from files and cache them.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
bool _left_button_down
Is left mouse button pressed?
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
int GetStringLineCount(StringID str, int maxw)
Calculates number of lines of string.
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.
bool _ctrl_pressed
Is Ctrl pressed?
bool _left_button_clicked
Is left mouse button clicked?
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.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
int _gui_scale_cfg
GUI scale in config.
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.
SwitchMode _switch_mode
The next mainloop command.
bool AdjustGUIZoom(bool automatic)
Resolve GUI zoom level and adjust GUI to new zoom, if auto-suggestion is requested.
int _gui_scale
GUI scale, 100 is 100%.
void CheckBlitter()
Check whether we still use the right blitter, or use another (better) one.
@ SA_RIGHT
Right align the text (must be a single bit).
@ SA_CENTER
Center both horizontally and vertically.
@ FS_SMALL
Index of the small font in the font tables.
@ FS_NORMAL
Index of the normal font in the font tables.
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
GUI functions that shouldn't be here.
Declaration of functions and types defined in highscore.h and highscore_gui.h.
Information about languages and their files.
LanguageList _languages
The actual list of language meta data.
const LanguageMetadata * _current_language
The currently loaded language.
bool ReadLanguagePack(const LanguageMetadata *lang)
Read a particular language.
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
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...
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
Functions to mix sound samples.
Base for all music playback.
void ChangeMusicSet(int index)
Change the configured music set and reset playback.
bool _network_available
is network mode available?
Basic functions/variables used all over the place.
Part of the network protocol handling content distribution.
void ShowNetworkContentListWindow(ContentVector *cv=nullptr, ContentType type1=CONTENT_TYPE_END, ContentType type2=CONTENT_TYPE_END)
Show the content list window with a given set of content.
GUIs related to networking.
Part of the network protocol handling opt-in survey.
Functions to find and configure NewGRFs.
void ChangeAutosaveFrequency(bool reset)
Reset the interval of the autosave.
@ SM_MENU
Switch to game intro menu.
uint8_t GetColourGradient(Colours colour, ColourShade shade)
Get colour gradient palette index.
Base for the GUIs that have an edit box in them.
declaration of OTTD revision dependent variables
A number of safeguards to prevent using unsafe methods.
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.
static const SettingDesc * GetSettingFromName(const std::string_view name, const SettingTable &settings)
Given a name of setting, return a setting description from the table.
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
ClientSettings _settings_client
The current settings for this game.
WarnHiddenResult
Warnings about hidden search results.
@ WHR_CATEGORY_TYPE
Both category and type settings filtered matches away.
@ WHR_CATEGORY
Category setting filtered matches away.
@ WHR_NONE
Nothing was filtering matches away.
@ WHR_TYPE
Type setting filtered matches away.
void DrawArrowButtons(int x, int y, Colours button_colour, uint8_t state, bool clickable_left, bool clickable_right)
Draw [<][>] boxes.
static void ResetAllSettingsConfirmationCallback(Window *w, bool confirmed)
Callback function for the reset all settings button.
static const uint32_t _autosave_dropdown_to_minutes[]
Available settings for autosave intervals.
static SettingsContainer & GetSettingsTree()
Construct settings tree.
static void AddCustomRefreshRates()
Add the refresh rate from the config and the refresh rates from all the monitors to our list of refre...
SettingEntryFlags
Flags for SettingEntry.
@ SEF_FILTERED
Entry is hidden by the string filter.
@ SEF_BUTTONS_MASK
Bit-mask for button flags.
@ SEF_LEFT_DEPRESSED
Of a numeric setting entry, the left button is depressed.
@ SEF_LAST_FIELD
This entry is the last one in a (sub-)page.
@ SEF_RIGHT_DEPRESSED
Of a numeric setting entry, the right button is depressed.
std::unique_ptr< NWidgetBase > MakeNWidgetSocialPlugins()
Construct nested container widget for managing the list of social plugins.
RestrictionMode
How the list of advanced settings is filtered.
@ RM_CHANGED_AGAINST_DEFAULT
Show only settings which are different compared to default values.
@ RM_ADVANCED
Display settings associated to the "advanced" list.
@ RM_ALL
List all settings regardless of the default/newgame/... 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.
@ RM_BASIC
Display settings associated to the "basic" list.
void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
Draw a dropdown button.
void ShowBaseSetTextfileWindow(TextfileType file_type, const TBaseSet *baseset, StringID content_type)
Open the BaseSet version of the textfile window.
static int SETTING_HEIGHT
Height of a single setting in the tree view in pixels.
void ShowGameSettings()
Open advanced settings window.
static uint GetCurrentResolutionIndex()
Get index of the current screen resolution.
void DrawBoolButton(int x, int y, bool state, bool clickable)
Draw a toggle button.
static void ShowCustCurrency()
Open custom currency window.
void ShowGameOptions()
Open the game options window.
static Dimension _circle_size
Dimension of the circle +/- icon. This is here as not all users are within the class of the settings ...
Functions for setting GUIs.
#define SETTING_BUTTON_WIDTH
Width of setting buttons.
#define SETTING_BUTTON_HEIGHT
Height of setting buttons.
Functions and types used internally for the settings configurations.
SettingType
Type of settings for filtering.
@ ST_CLIENT
Client setting.
@ ST_ALL
Used in setting filter to match all types.
@ ST_COMPANY
Company setting.
@ SF_GUI_DROPDOWN
The value represents a limited number of string-options (internally integer) presented as dropdown.
@ SF_PER_COMPANY
This setting can be different for each company (saved in company struct).
@ SF_GUI_CURRENCY
The number represents money, so when reading value multiply by exchange rate.
@ SF_GUI_0_IS_SPECIAL
A value of zero is possible and has a custom string (the one after "strval").
@ SC_ADVANCED_LIST
Settings displayed in the list of advanced settings.
@ SC_BASIC_LIST
Settings displayed in the list of basic settings.
GameSettings & GetGameSettings()
Get the settings-object applicable for the current situation: the newgame settings when we're in the ...
void DrawSliderWidget(Rect r, int min_value, int max_value, int nmarks, int value, SliderMarkFunc *mark_func)
Draw a slider widget with knob at given value.
bool ClickSliderWidget(Rect r, Point pt, int min_value, int max_value, int nmarks, int &value)
Handle click on a slider widget to change the value.
Interface definitions for game to report/respond to social integration.
void ChangeSoundSet(int index)
Change the configured sound set and reset sounds.
Functions related to sound.
Definition of base types and functions in a cross-platform compatible way.
#define lengthof(array)
Return the length of an fixed size array.
Functions related to low-level strings.
CharSetFilter
Valid filter types for IsValidChar.
@ CS_NUMERAL
Only numeric ones.
@ CS_NUMERAL_SIGNED
Only numbers and '-' for negative values.
@ CS_ALPHANUMERAL
Both numeric and alphabetic and spaces and stuff.
Searching and filtering using a stringterm.
const char * GetCurrentLanguageIsoCode()
Get the ISO language code of the currently loaded language.
void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher)
Check whether the currently loaded language pack uses characters that the currently loaded font does ...
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
TextDirection _current_text_dir
Text direction of the currently selected language.
void SetDParamStr(size_t n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
Functions related to OTTD's strings.
@ TD_RTL
Text is written right-to-left by default.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Window for displaying the textfile of a BaseSet.
const std::string name
Name of the content.
const StringID content_type
STR_CONTENT_TYPE_xxx for title.
void SetStringParameters(WidgetID widget) const override
Initialize string parameters for a widget.
Data structure describing a single setting in a tab.
void SetLastField(bool last_field)
Set whether this is the last visible entry of the parent node.
bool IsFiltered() const
Check whether an entry is hidden due to filters.
virtual BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find setting entry at row row_num.
virtual void Init(uint8_t level=0)
Initialization of a setting entry.
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.
uint8_t flags
Flags of the setting entry.
virtual bool IsVisible(const BaseSettingEntry *item) const
Check whether an entry is visible and not folded or filtered away.
uint8_t level
Nesting level of this setting entry.
CompanySettings company
default values for per-company settings
MusicSettings music
settings related to music/sound
NetworkSettings network
settings related to the network
GUISettings gui
settings related to the GUI
Specification of a currency.
std::string separator
The thousands separator for this currency.
std::string prefix
Prefix to apply when formatting money in this currency.
TimerGameCalendar::Year to_euro
Year of switching to the Euro. May also be CF_NOEURO or CF_ISEURO.
std::string suffix
Suffix to apply when formatting money in this currency.
std::string code
3 letter untranslated code to identify the currency.
uint16_t rate
The conversion rate compared to the base currency.
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
void OnTimeout() override
Called when this window's timeout has been reached.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void SetStringParameters(WidgetID widget) const override
Initialize string parameters for a widget.
void OnQueryTextFinished(std::optional< std::string > str) override
The query window opened from this window has closed.
Dimensions (a width and height) of a rectangle in 2D.
bool prefer_sprite
Whether to prefer the built-in sprite font over resizable fonts.
bool global_aa
Whether to anti alias all font sizes.
Information about GRF, used in the game and (part of it) in savegames.
void SetParameterDefaults()
Set the default value for all parameters as specified by action14.
std::vector< uint32_t > param
GRF parameters.
uint8_t settings_restriction_mode
selected restriction mode in adv. settings GUI.
uint16_t refresh_rate
How often we refresh the screen (time between draw-ticks).
uint32_t autosave_interval
how often should we do autosaves?
uint8_t missing_strings_threshold
the number of missing strings before showing the warning
bool scale_bevels
bevels are scaled with GUI scale.
void OnResize() override
Called after the window got resized.
void SetStringParameters(WidgetID widget) const override
Initialize string parameters for a widget.
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
void OnDropdownSelect(WidgetID widget, int index) override
A dropdown option associated to this window has been selected.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void OnMouseLoop() override
Called for every mouse loop run, which is at least once per (game) tick.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
DropDownList BuildDropDownList(WidgetID widget, int *selected_index) const
Build the dropdown list for a specific widget.
Window to edit settings of the game.
bool manually_changed_folding
Whether the user expanded/collapsed something manually.
void OnEditboxChanged(WidgetID wid) override
The text in an editbox has been edited.
SettingEntry * valuewindow_entry
If non-nullptr, pointer to setting for which a value-entering window has been opened.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
SettingEntry * clicked_entry
If non-nullptr, pointer to a clicked numeric setting (with a depressed left or right button).
void OnTimeout() override
Called when this window's timeout has been reached.
QueryString filter_editbox
Filter editbox;.
SettingEntry * valuedropdown_entry
If non-nullptr, pointer to the value for which a dropdown window is currently opened.
void SetStringParameters(WidgetID widget) const override
Initialize string parameters for a widget.
bool closing_dropdown
True, if the dropdown list is currently closing.
void OnInit() override
Notification that the nested widget tree gets initialized.
SettingFilter filter
Filter for the list.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void SetDisplayedHelpText(SettingEntry *pe)
Set the entry that should have its help text displayed, and mark the window dirty so it gets repainte...
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
void OnResize() override
Called after the window got resized.
SettingEntry * last_clicked
If non-nullptr, pointer to the last clicked setting.
void OnDropdownClose(Point pt, WidgetID widget, int index, bool instant_close) override
A dropdown window associated to this window has been closed.
WarnHiddenResult warn_missing
Whether and how to warn about missing search results.
void OnDropdownSelect(WidgetID widget, int index) override
A dropdown option associated to this window has been selected.
void OnPaint() override
The window must be repainted.
static GameSettings * settings_ptr
Pointer to the game settings being displayed and modified.
void OnQueryTextFinished(std::optional< std::string > str) override
The query window opened from this window has closed.
int warn_lines
Number of lines used for warning about missing search results.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
All settings together for the game.
LocaleSettings locale
settings related to used currency/unit system in the current game
Base integer type, including boolean, settings.
void SetValueDParams(uint first_param, int32_t value) const
Set the DParams for drawing the value of the setting.
int32_t def
default value given when none is present
SettingCategory cat
assigned categories of the setting
StringID GetTitle() const
Get the title of the setting.
uint32_t max
maximum values
int32_t min
minimum values
StringID GetHelp() const
Get the help text of the setting.
virtual bool IsBoolSetting() const
Check whether this setting is a boolean type setting.
int32_t Read(const void *object) const
Read the integer from the the actual setting.
uint8_t currency
currency we currently use
uint8_t effect_vol
The requested effects volume.
uint8_t music_vol
The requested music volume.
ParticipateSurvey participate_survey
Participate in the automated survey.
Coordinates of a point in 2D.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
static Titem * Get(size_t index)
Returns Titem with given index.
Data stored about a string that can be modified in the GUI.
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
static const int ACTION_CLEAR
Clear editbox.
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Specification of a rectangle with absolute coordinates of all edges.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
bool IsEditable(bool do_command=false) const
Check whether the setting is editable in the current gamemode.
SettingType GetType() const
Return the type of the setting.
const struct IntSettingDesc * AsIntSetting() const
Get the setting description of this setting as an integer setting.
SettingFlag flags
Handles how a setting would show up in the GUI (text/currency, etc.).
uint Length() const override
Return number of rows needed to display the (filtered) entry.
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 IsVisibleByRestrictionMode(RestrictionMode mode) const
Checks whether an entry shall be made visible based on the restriction mode.
void SetButtons(uint8_t new_val)
Set the button-depressed flags (SEF_LEFT_DEPRESSED and SEF_RIGHT_DEPRESSED) to a specified value.
uint GetMaxHelpHeight(int maxw) override
Get the biggest height of the help text(s), if the width is at least maxw.
void Init(uint8_t level=0) override
Initialization of a setting entry.
const IntSettingDesc * setting
Setting description of the setting.
SettingEntry(const char *name)
Constructor for a single setting in the 'advanced settings' window.
bool UpdateFilterState(SettingFilter &filter, bool force_visible) override
Update the filter state.
const char * name
Name of the setting.
Filter for settings list.
SettingType type
Filter based on type.
bool type_hides
Whether the type hides filtered strings.
RestrictionMode mode
Filter based on category.
RestrictionMode min_cat
Minimum category needed to display all filtered strings (RM_BASIC, RM_ADVANCED, or RM_ALL).
StringFilter string
Filter string.
Containers for BaseSettingEntry.
bool UpdateFilterState(SettingFilter &filter, bool force_visible)
Update the filter state.
void GetFoldingState(bool &all_folded, bool &all_unfolded) const
Recursively accumulate the folding state of the tree.
uint GetMaxHelpHeight(int maxw)
Get the biggest height of the help texts, if the width is at least maxw.
void ResetAll()
Resets all settings to their default values.
bool IsVisible(const BaseSettingEntry *item) const
Check whether an entry is visible and not folded or filtered away.
void FoldAll()
Recursively close all folds of sub-pages.
void UnFoldAll()
Recursively open all folds of sub-pages.
BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find the setting entry at row number row_num.
EntryVector entries
Settings on this page.
uint Length() const
Return number of rows needed to display the whole page.
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 Init(uint8_t level=0)
Initialization of an entire setting page.
Data structure describing one page of settings in the settings window.
StringID title
Title of the sub-page.
bool IsVisible(const BaseSettingEntry *item) const override
Check whether an entry is visible and not folded or filtered away.
SettingsPage(StringID title)
Constructor for a sub-page in the 'advanced settings' window.
void UnFoldAll() override
Recursively open all (filtered) folds of sub-pages.
void FoldAll() override
Recursively close all (filtered) folds of sub-pages.
uint Length() const override
Return number of rows needed to display the (filtered) entry.
BaseSettingEntry * FindEntry(uint row, uint *cur_row) override
Find setting entry at row row_num.
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 Init(uint8_t level=0) override
Initialization of an entire setting page.
void GetFoldingState(bool &all_folded, bool &all_unfolded) const override
Recursively accumulate the folding state of the (filtered) tree.
void ResetAll() override
Resets all settings to their default values.
bool folded
Sub-page is folded (not visible except for its title)
bool UpdateFilterState(SettingFilter &filter, bool force_visible) override
Update the filter state.
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 IsEmpty() const
Check whether any filter words were entered.
void SetFilterTerm(const char *str)
Set the term to filter on.
void ResetState()
Reset the matching state to process a new item.
void AddLine(const char *str)
Pass another text line from the current item to the filter.
bool GetState() const
Get the matching state of the current item.
Templated helper to make a type-safe 'typedef' representing a single POD value.
char *const buf
buffer in which text is saved
Window for displaying a textfile.
TextfileType file_type
Type of textfile to view.
virtual void LoadTextfile(const std::string &textfile, Subdirectory dir)
Loads the textfile text from file and setup lines.
High level window description.
Data structure for an opened window.
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
std::map< WidgetID, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
void DrawWidgets() const
Paint all widgets of a window.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
uint8_t timeout_timer
Timer value of the WF_TIMEOUT for flags.
WidgetID mouse_capture_widget
ID of current mouse capture widget (e.g. dragged scrollbar). -1 if no widget has mouse capture.
void CloseChildWindows(WindowClass wc=WC_INVALID) const
Close all children a window might have in a head-recursive manner.
ResizeInfo resize
Resize information.
void DisableWidget(WidgetID widget_index)
Sets a widget to disabled.
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
bool SetFocusedWidget(WidgetID widget_index)
Set focus within this window to the given widget.
virtual void OnDropdownClose(Point pt, WidgetID widget, int index, bool instant_close)
A dropdown window associated to this window has been closed.
void SetWidgetsLoweredState(bool lowered_stat, Args... widgets)
Sets the lowered/raised status of a list of widgets.
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
void EnableWidget(WidgetID widget_index)
Sets a widget to Enabled.
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
WindowFlags flags
Window flags.
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
int height
Height of the window (number of pixels down in y direction)
int width
width of the window (number of pixels to the right in x direction)
@ CONTENT_TYPE_BASE_SOUNDS
The content consists of base sounds.
@ CONTENT_TYPE_BASE_GRAPHICS
The content consists of base graphics.
@ CONTENT_TYPE_BASE_MUSIC
The content consists of base music.
Stuff related to the text buffer GUI.
@ QSF_ENABLE_DEFAULT
enable the 'Default' button ("\0" is returned)
std::optional< std::string > GetTextfile(TextfileType type, Subdirectory dir, const std::string &filename)
Search a textfile file next to the given content.
GUI functions related to textfiles.
TextfileType
Additional text files accompanying Tar archives.
@ TFT_LICENSE
Content license.
@ TFT_README
Content readme.
@ TFT_CHANGELOG
Content changelog.
bool _video_vsync
Whether we should use vsync (only if active video driver supports HW acceleration).
bool _video_hw_accel
Whether to consider hardware accelerated video drivers on startup.
Base of all video drivers.
Functions related to (drawing on) viewports.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
void ReInitAllWindows(bool zoom_changed)
Re-initialize all windows.
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
void SetWindowClassesDirty(WindowClass cls)
Mark all windows of a particular class as dirty (in need of repainting)
Window functions not directly related to making/drawing windows.
@ WF_TIMEOUT
Window timeout counter.
@ WF_CENTERED
Window is centered and shall stay centered after ReInit.
@ FR_LOWERED
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
@ WDP_CENTER
Center the window.
@ WN_GAME_OPTIONS_GAME_OPTIONS
Game options.
@ WN_GAME_OPTIONS_GAME_SETTINGS
Game settings.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ WC_MUSIC_WINDOW
Music window; Window numbers:
@ WC_CUSTOM_CURRENCY
Custom currency; Window numbers:
@ WC_GAME_OPTIONS
Game options window; Window numbers:
@ WC_TEXTFILE
textfile; Window numbers:
@ WC_DROPDOWN_MENU
Drop down menu; Window numbers:
@ WC_QUERY_STRING
Query string window; Window numbers:
@ WC_GRF_PARAMETERS
NewGRF parameters; Window numbers:
Functions related to zooming.