|
OpenTTD Source
13.0-beta1
|
Go to the documentation of this file.
24 #include "widgets/slider_func.h"
50 static const StringID _autosave_dropdown[] = {
51 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_OFF,
52 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_1_MONTH,
53 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_3_MONTHS,
54 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_6_MONTHS,
55 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_12_MONTHS,
59 static const StringID _gui_zoom_dropdown[] = {
60 STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_AUTO,
61 STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_NORMAL,
62 STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_2X_ZOOM,
63 STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_4X_ZOOM,
67 static const StringID _font_zoom_dropdown[] = {
68 STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_AUTO,
69 STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_NORMAL,
70 STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_2X_ZOOM,
71 STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_4X_ZOOM,
92 static DropDownList BuildSetDropDownList(
int *selected_index,
bool allow_selection)
94 int n = T::GetNumSets();
95 *selected_index = T::GetIndexOfUsedSet();
98 for (
int i = 0; i < n; i++) {
105 DropDownList BuildMusicSetDropDownList(
int *selected_index)
107 return BuildSetDropDownList<BaseMusic>(selected_index,
true);
111 template <
class TBaseSet>
118 const char *textfile = this->baseset->GetTextfile(
file_type);
137 template <
class TBaseSet>
144 std::set<int> _refresh_rates = { 30, 60, 75, 90, 100, 120, 144, 240 };
157 std::copy(monitorRates.begin(), monitorRates.end(), std::inserter(_refresh_rates, _refresh_rates.end()));
167 this->reload =
false;
213 const StringID *items = _autosave_dropdown;
221 for (uint i = 0; i <
_languages.size(); i++) {
222 bool hide_language = IsReleasedVersion() && !
_languages[i].IsReasonablyFinished();
223 if (hide_language)
continue;
225 auto item =
new DropDownListParamStringItem(hide_percentage ? STR_JUST_RAW_STRING : STR_GAME_OPTIONS_LANGUAGE_PERCENTAGE, i,
false);
237 item->SetParam(1, (LANGUAGE_TOTAL_STRINGS -
_languages[i].missing) * 100 / LANGUAGE_TOTAL_STRINGS);
238 list.emplace_back(item);
252 list.emplace_back(item);
257 for (
auto it = _refresh_rates.begin(); it != _refresh_rates.end(); it++) {
258 auto i = std::distance(_refresh_rates.begin(), it);
261 item->SetParam(0, *it);
262 list.emplace_back(item);
268 const StringID *items = _gui_zoom_dropdown;
277 const StringID *items = _font_zoom_dropdown;
285 list = BuildSetDropDownList<BaseGraphics>(selected_index, (_game_mode == GM_MENU));
289 list = BuildSetDropDownList<BaseSounds>(selected_index, (_game_mode == GM_MENU));
293 list = BuildMusicSetDropDownList(selected_index);
319 SetDParam(0, STR_GAME_OPTIONS_RESOLUTION_OTHER);
321 SetDParam(0, STR_GAME_OPTIONS_RESOLUTION_ITEM);
365 size->height = std::max(size->height, (uint)
GetStringHeight(STR_BLACK_RAW_STRING, size->width));
373 if (invalid_files == 0)
continue;
384 size->height = std::max(size->height, (uint)
GetStringHeight(STR_BLACK_RAW_STRING, size->width));
392 size->height = std::max(size->height, (uint)
GetStringHeight(STR_BLACK_RAW_STRING, size->width));
400 if (invalid_files == 0)
continue;
412 for (
const auto &ddli : list) {
414 int width = ddli->Width();
415 string_dim.width =
width + padding.width;
416 string_dim.height = ddli->Height(
width) + padding.height;
417 *size =
maxdim(*size, string_dim);
447 if (!ToggleFullScreen(!_fullscreen)) {
511 if (_game_mode == GM_MENU) {
512 auto name = T::GetSet(index)->name;
540 ClearAllCachedNames();
563 int8 new_zoom = index > 0 ?
ZOOM_LVL_OUT_4X - index + 1 : ZOOM_LVL_CFG_AUTO;
577 int8 new_zoom = index > 0 ?
ZOOM_LVL_OUT_4X - index + 1 : ZOOM_LVL_CFG_AUTO;
591 this->SetMediaSet<BaseGraphics>(index);
595 this->SetMediaSet<BaseSounds>(index);
611 if (!gui_scope)
return;
622 this->GetWidget<NWidgetCore>(
WID_GO_BASE_GRF_STATUS)->SetDataTip(missing_files ? STR_EMPTY : STR_GAME_OPTIONS_BASE_GRF_STATUS, STR_NULL);
624 for (
TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) {
631 this->GetWidget<NWidgetCore>(
WID_GO_BASE_MUSIC_STATUS)->SetDataTip(missing_files ? STR_EMPTY : STR_GAME_OPTIONS_BASE_MUSIC_STATUS, STR_NULL);
635 static const NWidgetPart _nested_game_options_widgets[] = {
706 NWidget(
WWT_TEXT, COLOUR_GREY,
WID_GO_BASE_GRF_DESCRIPTION),
SetMinimalSize(330, 0),
SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_BASE_GRF_DESCRIPTION_TOOLTIP),
SetFill(1, 0),
SetPadding(6, 0, 6, 0),
720 NWidget(
WWT_TEXT, COLOUR_GREY,
WID_GO_BASE_SFX_DESCRIPTION),
SetMinimalSize(330, 0),
SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_BASE_SFX_DESCRIPTION_TOOLTIP),
SetFill(1, 0),
SetPadding(6, 0, 6, 0),
734 NWidget(
WWT_TEXT, COLOUR_GREY,
WID_GO_BASE_MUSIC_DESCRIPTION),
SetMinimalSize(330, 0),
SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_BASE_MUSIC_DESCRIPTION_TOOLTIP),
SetFill(1, 0),
SetPadding(6, 0, 6, 0),
748 _nested_game_options_widgets,
lengthof(_nested_game_options_widgets)
803 virtual void FoldAll() {}
804 virtual void UnFoldAll() {}
805 virtual void ResetAll() = 0;
813 virtual uint Length()
const = 0;
814 virtual void GetFoldingState(
bool &all_folded,
bool &all_unfolded)
const {}
817 virtual uint GetMaxHelpHeight(
int maxw) {
return 0; }
825 virtual bool UpdateFilterState(
SettingFilter &filter,
bool force_visible) = 0;
827 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;
830 virtual void DrawSetting(
GameSettings *settings_ptr,
int left,
int right,
int y,
bool highlight)
const = 0;
841 virtual void ResetAll();
842 virtual uint
Length()
const;
868 typedef std::vector<BaseSettingEntry*> EntryVector;
874 this->entries.push_back(item);
878 void Init(
byte level = 0);
891 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;
906 virtual uint
Length()
const;
907 virtual void GetFoldingState(
bool &all_folded,
bool &all_unfolded)
const;
914 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;
952 if (row_num == *cur_row)
return this;
989 if (cur_row >= max_row)
return cur_row;
992 int offset = rtl ? -4 : 4;
995 int x = rtl ? right : left;
996 if (cur_row >= first_row) {
1001 for (uint lvl = 0; lvl < this->
level; lvl++) {
1002 if (!
HasBit(parent_last, lvl)) GfxDrawLine(x + offset, y, x + offset, y +
SETTING_HEIGHT - 1, colour);
1008 GfxDrawLine(x + offset, y, x + offset, bottom_y, colour);
1010 GfxDrawLine(x + offset, halfway_y, x + level_width - offset, halfway_y, colour);
1013 this->DrawSetting(settings_ptr, rtl ? left : x, rtl ? x : right, y,
this == selected);
1043 void SettingEntry::ResetAll()
1083 if (mode ==
RM_ALL)
return true;
1092 int64 current_value = sd->
Read(
object);
1099 filter_value = sd->
def;
1112 return current_value != filter_value;
1125 bool visible =
true;
1162 return settings_ptr;
1173 SetDParam(first_param++, value != 0 ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
1209 SetDParam(0, highlight ? STR_ORANGE_STRING1_WHITE : STR_ORANGE_STRING1_LTBLUE);
1210 int32 value = sd->
Read(ResolveObject(settings_ptr, sd));
1234 for (EntryVector::iterator it = this->
entries.begin(); it != this->entries.end(); ++it) {
1242 for (
auto settings_entry : this->
entries) {
1243 settings_entry->ResetAll();
1250 for (EntryVector::iterator it = this->
entries.begin(); it != this->entries.end(); ++it) {
1258 for (EntryVector::iterator it = this->
entries.begin(); it != this->entries.end(); ++it) {
1270 for (EntryVector::const_iterator it = this->
entries.begin(); it != this->entries.end(); ++it) {
1271 (*it)->GetFoldingState(all_folded, all_unfolded);
1283 bool visible =
false;
1284 bool first_visible =
true;
1285 for (EntryVector::reverse_iterator it = this->
entries.rbegin(); it != this->entries.rend(); ++it) {
1286 visible |= (*it)->UpdateFilterState(filter, force_visible);
1287 (*it)->SetLastField(first_visible);
1288 if (visible && first_visible) first_visible =
false;
1302 for (EntryVector::const_iterator it = this->
entries.begin(); it != this->entries.end(); ++it) {
1303 if ((*it)->IsVisible(item))
return true;
1312 for (EntryVector::const_iterator it = this->
entries.begin(); it != this->entries.end(); ++it) {
1313 length += (*it)->Length();
1327 for (EntryVector::iterator it = this->
entries.begin(); it != this->entries.end(); ++it) {
1328 pe = (*it)->
FindEntry(row_num, cur_row);
1329 if (pe !=
nullptr) {
1344 for (EntryVector::const_iterator it = this->
entries.begin(); it != this->entries.end(); ++it) {
1345 biggest = std::max(biggest, (*it)->GetMaxHelpHeight(maxw));
1367 for (EntryVector::const_iterator it = this->
entries.begin(); it != this->entries.end(); ++it) {
1368 cur_row = (*it)->Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1369 if (cur_row >= max_row) {
1384 this->title =
title;
1401 for (
auto settings_entry : this->
entries) {
1402 settings_entry->ResetAll();
1434 all_unfolded =
false;
1474 if (
this == item)
return true;
1475 if (this->
folded)
return false;
1484 if (this->
folded)
return 1;
1498 if (row_num == *cur_row)
return this;
1500 if (this->
folded)
return nullptr;
1522 if (cur_row >= max_row)
return cur_row;
1524 cur_row =
BaseSettingEntry::Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1528 assert(this->
level < 8 *
sizeof(parent_last));
1532 cur_row =
SettingsContainer::Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1558 if (
main ==
nullptr)
1565 localisation->Add(
new SettingEntry(
"locale.units_velocity"));
1566 localisation->Add(
new SettingEntry(
"locale.units_power"));
1567 localisation->Add(
new SettingEntry(
"locale.units_weight"));
1568 localisation->Add(
new SettingEntry(
"locale.units_volume"));
1569 localisation->Add(
new SettingEntry(
"locale.units_force"));
1570 localisation->Add(
new SettingEntry(
"locale.units_height"));
1571 localisation->Add(
new SettingEntry(
"gui.date_format_in_default_names"));
1578 graphics->Add(
new SettingEntry(
"gui.sprite_zoom_min"));
1579 graphics->Add(
new SettingEntry(
"gui.smallmap_land_colour"));
1580 graphics->Add(
new SettingEntry(
"gui.linkgraph_colours"));
1581 graphics->Add(
new SettingEntry(
"gui.graph_line_thickness"));
1603 general->Add(
new SettingEntry(
"gui.window_snap_radius"));
1604 general->Add(
new SettingEntry(
"gui.window_soft_limit"));
1605 general->Add(
new SettingEntry(
"gui.right_mouse_wnd_close"));
1610 viewports->Add(
new SettingEntry(
"gui.auto_scrolling"));
1616 viewports->Add(
new SettingEntry(
"gui.scrollwheel_scrolling"));
1617 viewports->Add(
new SettingEntry(
"gui.scrollwheel_multiplier"));
1620 viewports->Add(
new SettingEntry(
"gui.right_mouse_btn_emulation"));
1622 viewports->Add(
new SettingEntry(
"gui.population_in_label"));
1624 viewports->Add(
new SettingEntry(
"construction.train_signal_side"));
1625 viewports->Add(
new SettingEntry(
"gui.measure_tooltip"));
1626 viewports->Add(
new SettingEntry(
"gui.loading_indicators"));
1627 viewports->Add(
new SettingEntry(
"gui.show_track_reservation"));
1632 construction->Add(
new SettingEntry(
"gui.link_terraform_toolbar"));
1633 construction->Add(
new SettingEntry(
"gui.persistent_buildingtools"));
1635 construction->Add(
new SettingEntry(
"gui.default_rail_type"));
1638 interface->Add(
new SettingEntry(
"gui.fast_forward_speed_limit"));
1642 interface->Add(
new SettingEntry(
"gui.prefer_teamchat"));
1643 interface->Add(
new SettingEntry(
"gui.advanced_vehicle_list"));
1644 interface->Add(
new SettingEntry(
"gui.timetable_in_ticks"));
1645 interface->Add(
new SettingEntry(
"gui.timetable_arrival_departure"));
1646 interface->Add(
new SettingEntry(
"gui.show_newgrf_name"));
1651 advisors->Add(
new SettingEntry(
"gui.coloured_news_year"));
1652 advisors->Add(
new SettingEntry(
"news_display.general"));
1653 advisors->Add(
new SettingEntry(
"news_display.new_vehicles"));
1654 advisors->Add(
new SettingEntry(
"news_display.accident"));
1655 advisors->Add(
new SettingEntry(
"news_display.accident_other"));
1656 advisors->Add(
new SettingEntry(
"news_display.company_info"));
1657 advisors->Add(
new SettingEntry(
"news_display.acceptance"));
1658 advisors->Add(
new SettingEntry(
"news_display.arrival_player"));
1659 advisors->Add(
new SettingEntry(
"news_display.arrival_other"));
1660 advisors->Add(
new SettingEntry(
"news_display.advice"));
1661 advisors->Add(
new SettingEntry(
"gui.order_review_system"));
1662 advisors->Add(
new SettingEntry(
"gui.vehicle_income_warn"));
1663 advisors->Add(
new SettingEntry(
"gui.lost_vehicle_warn"));
1665 advisors->Add(
new SettingEntry(
"news_display.economy"));
1666 advisors->Add(
new SettingEntry(
"news_display.subsidies"));
1669 advisors->Add(
new SettingEntry(
"news_display.production_player"));
1670 advisors->Add(
new SettingEntry(
"news_display.production_other"));
1671 advisors->Add(
new SettingEntry(
"news_display.production_nobody"));
1676 company->Add(
new SettingEntry(
"gui.semaphore_build_before"));
1677 company->Add(
new SettingEntry(
"gui.cycle_signal_types"));
1679 company->Add(
new SettingEntry(
"gui.drag_signals_fixed_distance"));
1680 company->Add(
new SettingEntry(
"gui.auto_remove_signals"));
1684 company->Add(
new SettingEntry(
"company.engine_renew"));
1685 company->Add(
new SettingEntry(
"company.engine_renew_months"));
1686 company->Add(
new SettingEntry(
"company.engine_renew_money"));
1687 company->Add(
new SettingEntry(
"vehicle.servint_ispercent"));
1688 company->Add(
new SettingEntry(
"vehicle.servint_trains"));
1689 company->Add(
new SettingEntry(
"vehicle.servint_roadveh"));
1690 company->Add(
new SettingEntry(
"vehicle.servint_ships"));
1691 company->Add(
new SettingEntry(
"vehicle.servint_aircraft"));
1696 accounting->Add(
new SettingEntry(
"economy.inflation"));
1697 accounting->Add(
new SettingEntry(
"difficulty.initial_interest"));
1698 accounting->Add(
new SettingEntry(
"difficulty.max_loan"));
1699 accounting->Add(
new SettingEntry(
"difficulty.subsidy_multiplier"));
1700 accounting->Add(
new SettingEntry(
"difficulty.subsidy_duration"));
1701 accounting->Add(
new SettingEntry(
"economy.feeder_payment_share"));
1702 accounting->Add(
new SettingEntry(
"economy.infrastructure_maintenance"));
1703 accounting->Add(
new SettingEntry(
"difficulty.vehicle_costs"));
1704 accounting->Add(
new SettingEntry(
"difficulty.construction_cost"));
1711 physics->Add(
new SettingEntry(
"vehicle.train_acceleration_model"));
1712 physics->Add(
new SettingEntry(
"vehicle.train_slope_steepness"));
1713 physics->Add(
new SettingEntry(
"vehicle.wagon_speed_limits"));
1714 physics->Add(
new SettingEntry(
"vehicle.freight_trains"));
1715 physics->Add(
new SettingEntry(
"vehicle.roadveh_acceleration_model"));
1716 physics->Add(
new SettingEntry(
"vehicle.roadveh_slope_steepness"));
1717 physics->Add(
new SettingEntry(
"vehicle.smoke_amount"));
1723 routing->Add(
new SettingEntry(
"pf.pathfinder_for_trains"));
1724 routing->Add(
new SettingEntry(
"difficulty.line_reverse_mode"));
1725 routing->Add(
new SettingEntry(
"pf.reverse_at_signals"));
1727 routing->Add(
new SettingEntry(
"pf.pathfinder_for_roadvehs"));
1728 routing->Add(
new SettingEntry(
"pf.pathfinder_for_ships"));
1731 vehicles->Add(
new SettingEntry(
"order.no_servicing_if_no_breakdowns"));
1732 vehicles->Add(
new SettingEntry(
"order.serviceathelipad"));
1737 limitations->Add(
new SettingEntry(
"construction.command_pause_level"));
1738 limitations->Add(
new SettingEntry(
"construction.autoslope"));
1739 limitations->Add(
new SettingEntry(
"construction.extra_dynamite"));
1740 limitations->Add(
new SettingEntry(
"construction.map_height_limit"));
1741 limitations->Add(
new SettingEntry(
"construction.max_bridge_length"));
1742 limitations->Add(
new SettingEntry(
"construction.max_bridge_height"));
1743 limitations->Add(
new SettingEntry(
"construction.max_tunnel_length"));
1744 limitations->Add(
new SettingEntry(
"station.never_expire_airports"));
1745 limitations->Add(
new SettingEntry(
"vehicle.never_expire_vehicles"));
1746 limitations->Add(
new SettingEntry(
"vehicle.max_trains"));
1747 limitations->Add(
new SettingEntry(
"vehicle.max_roadveh"));
1748 limitations->Add(
new SettingEntry(
"vehicle.max_aircraft"));
1749 limitations->Add(
new SettingEntry(
"vehicle.max_ships"));
1750 limitations->Add(
new SettingEntry(
"vehicle.max_train_length"));
1751 limitations->Add(
new SettingEntry(
"station.station_spread"));
1752 limitations->Add(
new SettingEntry(
"station.distant_join_stations"));
1753 limitations->Add(
new SettingEntry(
"construction.road_stop_on_town_road"));
1754 limitations->Add(
new SettingEntry(
"construction.road_stop_on_competitor_road"));
1755 limitations->Add(
new SettingEntry(
"vehicle.disable_elrails"));
1760 disasters->Add(
new SettingEntry(
"difficulty.disasters"));
1761 disasters->Add(
new SettingEntry(
"difficulty.economy"));
1762 disasters->Add(
new SettingEntry(
"difficulty.vehicle_breakdowns"));
1763 disasters->Add(
new SettingEntry(
"vehicle.plane_crashes"));
1768 genworld->Add(
new SettingEntry(
"game_creation.landscape"));
1769 genworld->Add(
new SettingEntry(
"game_creation.land_generator"));
1770 genworld->Add(
new SettingEntry(
"difficulty.terrain_type"));
1771 genworld->Add(
new SettingEntry(
"game_creation.tgen_smoothness"));
1772 genworld->Add(
new SettingEntry(
"game_creation.variety"));
1773 genworld->Add(
new SettingEntry(
"game_creation.snow_coverage"));
1774 genworld->Add(
new SettingEntry(
"game_creation.snow_line_height"));
1775 genworld->Add(
new SettingEntry(
"game_creation.desert_coverage"));
1776 genworld->Add(
new SettingEntry(
"game_creation.amount_of_rivers"));
1777 genworld->Add(
new SettingEntry(
"game_creation.tree_placer"));
1779 genworld->Add(
new SettingEntry(
"economy.larger_towns"));
1780 genworld->Add(
new SettingEntry(
"economy.initial_city_size"));
1781 genworld->Add(
new SettingEntry(
"economy.town_layout"));
1782 genworld->Add(
new SettingEntry(
"difficulty.industry_density"));
1783 genworld->Add(
new SettingEntry(
"gui.pause_on_newgame"));
1784 genworld->Add(
new SettingEntry(
"game_creation.ending_year"));
1791 authorities->Add(
new SettingEntry(
"difficulty.town_council_tolerance"));
1793 authorities->Add(
new SettingEntry(
"economy.exclusive_rights"));
1794 authorities->Add(
new SettingEntry(
"economy.fund_roads"));
1795 authorities->Add(
new SettingEntry(
"economy.fund_buildings"));
1796 authorities->Add(
new SettingEntry(
"economy.station_noise_level"));
1801 towns->Add(
new SettingEntry(
"economy.town_growth_rate"));
1802 towns->Add(
new SettingEntry(
"economy.allow_town_roads"));
1803 towns->Add(
new SettingEntry(
"economy.allow_town_level_crossings"));
1805 towns->Add(
new SettingEntry(
"economy.town_cargogen_mode"));
1810 industries->Add(
new SettingEntry(
"construction.raw_industry_construction"));
1811 industries->Add(
new SettingEntry(
"construction.industry_platform"));
1812 industries->Add(
new SettingEntry(
"economy.multiple_industry_per_town"));
1813 industries->Add(
new SettingEntry(
"game_creation.oil_refinery_limit"));
1815 industries->Add(
new SettingEntry(
"station.serve_neutral_industries"));
1821 cdist->Add(
new SettingEntry(
"linkgraph.recalc_interval"));
1822 cdist->Add(
new SettingEntry(
"linkgraph.distribution_pax"));
1823 cdist->Add(
new SettingEntry(
"linkgraph.distribution_mail"));
1824 cdist->Add(
new SettingEntry(
"linkgraph.distribution_armoured"));
1825 cdist->Add(
new SettingEntry(
"linkgraph.distribution_default"));
1827 cdist->Add(
new SettingEntry(
"linkgraph.demand_distance"));
1829 cdist->Add(
new SettingEntry(
"linkgraph.short_path_saturation"));
1832 environment->Add(
new SettingEntry(
"station.modified_catchment"));
1833 environment->Add(
new SettingEntry(
"construction.extra_tree_placement"));
1841 npc->Add(
new SettingEntry(
"script.script_max_opcode_till_suspend"));
1842 npc->Add(
new SettingEntry(
"script.script_max_memory_megabytes"));
1843 npc->Add(
new SettingEntry(
"difficulty.competitor_speed"));
1846 npc->Add(
new SettingEntry(
"ai.ai_disable_veh_roadveh"));
1847 npc->Add(
new SettingEntry(
"ai.ai_disable_veh_aircraft"));
1853 ai->Add(
new SettingEntry(
"economy.min_years_for_shares"));
1858 network->Add(
new SettingEntry(
"network.use_relay_service"));
1866 static const StringID _game_settings_restrict_dropdown[] = {
1867 STR_CONFIG_SETTING_RESTRICT_BASIC,
1868 STR_CONFIG_SETTING_RESTRICT_ADVANCED,
1869 STR_CONFIG_SETTING_RESTRICT_ALL,
1870 STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_DEFAULT,
1871 STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_NEW,
1873 static_assert(
lengthof(_game_settings_restrict_dropdown) ==
RM_END);
1923 this->warn_lines = 0;
1925 this->filter.min_cat =
RM_ALL;
1926 this->filter.type =
ST_ALL;
1927 this->filter.type_hides =
false;
1933 this->valuewindow_entry =
nullptr;
1934 this->clicked_entry =
nullptr;
1935 this->last_clicked =
nullptr;
1936 this->valuedropdown_entry =
nullptr;
1937 this->closing_dropdown =
false;
1938 this->manually_changed_folding =
false;
1962 static const StringID setting_types[] = {
1963 STR_CONFIG_SETTING_TYPE_CLIENT,
1964 STR_CONFIG_SETTING_TYPE_COMPANY_MENU, STR_CONFIG_SETTING_TYPE_COMPANY_INGAME,
1965 STR_CONFIG_SETTING_TYPE_GAME_MENU, STR_CONFIG_SETTING_TYPE_GAME_INGAME,
1967 for (uint i = 0; i <
lengthof(setting_types); i++) {
1972 std::max(size->height,
GetSettingsTree().GetMaxHelpHeight(size->width));
1988 if (this->closing_dropdown) {
1989 this->closing_dropdown =
false;
1990 assert(this->valuedropdown_entry !=
nullptr);
1992 this->valuedropdown_entry =
nullptr;
1999 if (this->warn_missing ==
WHR_NONE) {
2005 if (this->warn_lines != new_warn_lines) {
2006 this->vscroll->
SetCount(this->vscroll->
GetCount() - this->warn_lines + new_warn_lines);
2007 this->warn_lines = new_warn_lines;
2013 if (this->warn_missing !=
WHR_NONE) {
2018 if (this->warn_lines == 1) {
2031 SetDParam(0, _game_settings_restrict_dropdown[this->filter.
mode]);
2035 switch (this->filter.
type) {
2036 case ST_GAME:
SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME);
break;
2037 case ST_COMPANY:
SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME);
break;
2039 default:
SetDParam(0, STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL);
break;
2050 for (
int mode = 0; mode !=
RM_END; mode++) {
2061 list.emplace_back(
new DropDownListStringItem(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME,
ST_GAME,
false));
2062 list.emplace_back(
new DropDownListStringItem(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME,
ST_COMPANY,
false));
2076 this->vscroll->GetPosition(), last_row, this->last_clicked);
2082 if (this->last_clicked !=
nullptr) {
2087 case ST_COMPANY:
SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_COMPANY_INGAME);
break;
2089 case ST_GAME:
SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_GAME_MENU : STR_CONFIG_SETTING_TYPE_GAME_INGAME);
break;
2090 default: NOT_REACHED();
2092 DrawString(r.left, r.right, y, STR_CONFIG_SETTING_TYPE);
2096 DrawString(r.left, r.right, y, STR_CONFIG_SETTING_DEFAULT_VALUE);
2099 DrawStringMultiLine(r.left, r.right, y, r.bottom, this->last_clicked->GetHelpText(), TC_WHITE);
2114 if (this->last_clicked != pe) this->
SetDirty();
2115 this->last_clicked = pe;
2122 this->manually_changed_folding =
true;
2128 this->manually_changed_folding =
true;
2135 STR_CONFIG_SETTING_RESET_ALL_CONFIRMATION_DIALOG_CAPTION,
2136 STR_CONFIG_SETTING_RESET_ALL_CONFIRMATION_DIALOG_TEXT,
2144 if (!list.empty()) {
2152 if (!list.empty()) {
2162 if (btn == INT_MAX || (
int)btn < this->
warn_lines)
return;
2174 if (clicked_page !=
nullptr) {
2178 this->manually_changed_folding =
true;
2185 assert(pe !=
nullptr);
2200 if (this->valuedropdown_entry == pe) {
2203 this->closing_dropdown =
false;
2205 this->valuedropdown_entry =
nullptr;
2207 if (this->valuedropdown_entry !=
nullptr) this->valuedropdown_entry->
SetButtons(0);
2208 this->closing_dropdown =
false;
2220 if (pt.y >= wi_rect.top && pt.y <= wi_rect.bottom) {
2221 this->valuedropdown_entry = pe;
2225 for (
int i = sd->
min; i <= (
int)sd->
max; i++) {
2235 int32 oldvalue = value;
2245 if (step == 0) step = 1;
2257 assert((int32)sd->
max >= 0);
2258 if (value > (int32)sd->
max) value = (int32)sd->
max;
2260 if ((uint32)value > sd->
max) value = (int32)sd->
max;
2262 if (value < sd->min) value = sd->
min;
2269 if (value != oldvalue) {
2270 if (this->clicked_entry !=
nullptr) {
2271 this->clicked_entry->SetButtons(0);
2273 this->clicked_entry = pe;
2280 if (value != oldvalue) {
2287 int64 value64 = value;
2291 this->valuewindow_entry = pe;
2302 if (this->clicked_entry !=
nullptr) {
2304 this->clicked_entry =
nullptr;
2312 if (str ==
nullptr)
return;
2314 assert(this->valuewindow_entry !=
nullptr);
2319 long long llvalue = atoll(str);
2341 if (!this->manually_changed_folding) {
2361 assert(this->valuedropdown_entry !=
nullptr);
2385 assert(this->valuedropdown_entry !=
nullptr);
2386 this->closing_dropdown =
true;
2393 if (!gui_scope)
return;
2397 this->filter.min_cat = min_level;
2398 this->filter.type_hides =
false;
2414 bool all_folded =
true;
2415 bool all_unfolded =
true;
2425 if (!this->filter.
string.
IsEmpty() && !this->manually_changed_folding) {
2442 static const NWidgetPart _nested_settings_selection_widgets[] = {
2452 NWidget(
WWT_DROPDOWN, COLOUR_MAUVE,
WID_GS_RESTRICT_DROPDOWN),
SetMinimalSize(100, 12),
SetDataTip(STR_BLACK_STRING, STR_CONFIG_SETTING_RESTRICT_DROPDOWN_HELPTEXT),
SetFill(1, 0),
SetResize(1, 0),
2456 NWidget(
WWT_DROPDOWN, COLOUR_MAUVE,
WID_GS_TYPE_DROPDOWN),
SetMinimalSize(100, 12),
SetDataTip(STR_BLACK_STRING, STR_CONFIG_SETTING_TYPE_DROPDOWN_HELPTEXT),
SetFill(1, 0),
SetResize(1, 0),
2460 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),
2486 _nested_settings_selection_widgets,
lengthof(_nested_settings_selection_widgets)
2506 void DrawArrowButtons(
int x,
int y, Colours button_colour,
byte state,
bool clickable_left,
bool clickable_right)
2509 Dimension dim = NWidgetScrollbar::GetHorizontalDimension();
2511 DrawFrameRect(x, y, x + dim.width - 1, y + dim.height - 1, button_colour, (state == 1) ?
FR_LOWERED : FR_NONE);
2512 DrawFrameRect(x + dim.width, y, x + dim.width + dim.width - 1, y + dim.height - 1, button_colour, (state == 2) ?
FR_LOWERED : FR_NONE);
2518 if (rtl ? !clickable_right : !clickable_left) {
2521 if (rtl ? !clickable_left : !clickable_right) {
2555 static const Colours _bool_ctabs[2][2] = {{COLOUR_CREAM, COLOUR_RED}, {COLOUR_DARK_GREEN, COLOUR_GREEN}};
2569 void SetButtonState()
2585 SetDParam(0, (_custom_currency.to_euro !=
CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER);
2623 if (_custom_currency.rate > 1) _custom_currency.rate--;
2629 if (_custom_currency.rate < UINT16_MAX) _custom_currency.rate++;
2645 str = STR_JUST_RAW_STRING;
2653 str = STR_JUST_RAW_STRING;
2661 str = STR_JUST_RAW_STRING;
2667 _custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ?
CF_NOEURO : _custom_currency.to_euro - 1;
2673 _custom_currency.to_euro =
Clamp(_custom_currency.to_euro + 1, 2000,
MAX_YEAR);
2688 this->query_widget = line;
2689 ShowQueryString(str, STR_CURRENCY_CHANGE_PARAMETER, len + 1,
this, afilter, QSF_NONE);
2698 if (str ==
nullptr)
return;
2700 switch (this->query_widget) {
2702 _custom_currency.rate =
Clamp(atoi(str), 1, UINT16_MAX);
2706 _custom_currency.separator = str;
2710 _custom_currency.prefix = str;
2714 _custom_currency.suffix = str;
2718 int val = atoi(str);
2734 static const NWidgetPart _nested_cust_currency_widgets[] = {
2770 SetDataTip(STR_CURRENCY_PREVIEW, STR_CURRENCY_CUSTOM_CURRENCY_PREVIEW_TOOLTIP),
SetPadding(15, 1, 18, 2),
2778 _nested_cust_currency_widgets,
lengthof(_nested_cust_currency_widgets)
void LoadStringWidthTable(bool monospace)
Initialize _stringwidth_table cache.
virtual uint Length() const
Return number of rows needed to display the (filtered) entry.
@ WC_CUSTOM_CURRENCY
Custom currency; Window numbers:
@ SEF_RIGHT_DEPRESSED
Of a numeric setting entry, the right button is depressed.
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible)
Update the filter state.
void OnTimeout() override
Called when this window's timeout has been reached.
static const int CF_NOEURO
Currency never switches to the Euro (as far as known).
@ SF_PER_COMPANY
This setting can be different for each company (saved in company struct).
static int32 ClampToI32(const int64 a)
Reduce a signed 64-bit int to a signed 32-bit one.
uint16 refresh_rate
How often we refresh the screen (time between draw-ticks).
@ SF_GUI_0_IS_SPECIAL
A value of zero is possible and has a custom string (the one after "strval").
virtual void LoadTextfile(const char *textfile, Subdirectory dir)
Loads the textfile text from file and setup lines.
static Titem * Get(size_t index)
Returns Titem with given index.
@ SEF_LEFT_DEPRESSED
Of a numeric setting entry, the left button is depressed.
uint8 timeout_timer
Timer value of the WF_TIMEOUT for flags.
String list item with parameters.
const char * GetCurrentLanguageIsoCode()
Get the ISO language code of the currently loaded language.
@ SEF_BUTTONS_MASK
Bit-mask for button flags.
Dimensions (a width and height) of a rectangle in 2D.
const TBaseSet * baseset
View the textfile of this BaseSet.
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
StringID content_type
STR_CONTENT_TYPE_xxx for title.
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.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
virtual void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const
Function to draw setting value (button + text + current value)
static GameSettings * settings_ptr
Pointer to the game settings being displayed and modified.
SettingCategory cat
assigned categories of the setting
void SetFilterTerm(const char *str)
Set the term to filter on.
void DrawVolumeSliderWidget(Rect r, byte value)
Draw a volume slider widget with know at given value.
SettingType type
Filter based on type.
@ BASESET_DIR
Subdirectory for all base data (base sets, intro game)
virtual void SetVolume(byte vol)=0
Set the volume, if possible.
const IntSettingDesc * setting
Setting description of the setting.
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 Init(byte level=0)
Initialization of an entire setting page.
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
virtual uint Length() const
Return number of rows needed to display the (filtered) entry.
bool IsEditable(bool do_command=false) const
Check whether the setting is editable in the current gamemode.
void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override
A dropdown window associated to this window has been closed.
List item containing a C char string.
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.
void SetLastField(bool last_field)
Set whether this is the last visible entry of the parent node.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Window for displaying the textfile of a BaseSet.
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
StringFilter string
Filter string.
int8 _font_zoom_cfg
Font zoom level in config.
virtual void Init(byte level=0)
Initialization of a setting entry.
@ ST_COMPANY
Company setting.
@ WD_FRAMETEXT_TOP
Top offset of the text of the frame.
Base list item class from which others are derived.
EntryVector entries
Settings on this page.
ClientSettings _settings_client
The current settings for this game.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
SettingEntry * last_clicked
If non-nullptr, pointer to the last clicked setting.
byte autosave
how often should we do autosaves?
void AddLine(const char *str)
Pass another text line from the current item to the filter.
static const int SETTINGTREE_TOP_OFFSET
Position of top edge of setting values.
virtual void OnDropdownClose(Point pt, int widget, int index, bool instant_close)
A dropdown window associated to this window has been closed.
@ 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.).
@ SEF_FILTERED
Entry is hidden by the string filter.
@ WC_MUSIC_WINDOW
Music window; Window numbers:
static const int SETTINGTREE_LEFT_OFFSET
Position of left edge of setting values.
ZoomLevel _gui_zoom
GUI Zoom level.
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.
Data structure describing one page of settings in the settings window.
@ WD_FRAMETEXT_LEFT
Left offset of the text of the frame.
TextfileType file_type
Type of textfile to view.
@ TFT_CHANGELOG
NewGRF changelog.
bool UpdateFilterState(SettingFilter &filter, bool force_visible)
Update the filter state.
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Data stored about a string that can be modified in the GUI.
#define SETBITS(x, y)
Sets several bits in a variable.
void OnTimeout() override
Called when this window's timeout has been reached.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
int GetStringLineCount(StringID str, int maxw)
Calculates number of lines of string.
char *const buf
buffer in which text is saved
SmallMap< int, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=nullptr, uint textref_stack_size=0, const uint32 *textref_stack=nullptr)
Display an error message in a window.
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
virtual uint GetMaxHelpHeight(int maxw)
Get the biggest height of the help text(s), if the width is at least maxw.
StringID * BuildCurrencyDropdown()
Build a list of currency names StringIDs to use in a dropdown list.
void UpdateCursorSize()
Update cursor dimension.
static GameSettings & GetGameSettings()
Get the settings-object applicable for the current situation: the newgame settings when we're in the ...
@ WN_GAME_OPTIONS_GAME_OPTIONS
Game options.
High level window description.
WarnHiddenResult warn_missing
Whether and how to warn about missing search results.
byte level
Nesting level of this setting entry.
SettingType
Type of settings for filtering.
#define DECLARE_POSTFIX_INCREMENT(enum_type)
Some enums need to have allowed incrementing (i.e.
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).
@ WC_QUERY_STRING
Query string window; Window numbers:
DropDownList BuildDropDownList(int widget, int *selected_index) const
Build the dropdown list for a specific widget.
void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
Draw a dropdown button.
StringID str_val
(Translated) first string describing the value.
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.
void EnableWidget(byte widget_index)
Sets a widget to Enabled.
static MusicDriver * GetInstance()
Get the currently active instance of the music driver.
RestrictionMode
How the list of advanced settings is filtered.
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.
void GfxClearSpriteCache()
Remove all encoded sprites from the sprite cache without discarding sprite location information.
virtual void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const
Function to draw setting value (button + text + current value)
@ WHR_TYPE
Type setting filtered matches away.
int height
Height of the window (number of pixels down in y direction)
Base integer type, including boolean, settings.
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
static const int SETTINGTREE_BOTTOM_OFFSET
Position of bottom edge of setting values.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
void ResetAll()
Resets all settings to their default values.
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
byte missing_strings_threshold
the number of missing strings before showing the warning
virtual void ToggleVsync(bool vsync)
Change the vsync setting.
Data structure describing a single setting in a tab.
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
@ WD_PAR_VSEP_NORMAL
Normal amount of vertical space between two paragraphs of text.
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
@ WD_FRAMETEXT_BOTTOM
Bottom offset of the text of the frame.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
@ RM_END
End for iteration.
RestrictionMode mode
Filter based on category.
const char * name
Name of the setting.
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
@ WL_INFO
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
virtual void FoldAll()
Recursively close all (filtered) folds of sub-pages.
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.
@ SEF_LAST_FIELD
This entry is the last one in a (sub-)page.
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.
int left
x position of left edge of the window
WindowFlags flags
Window flags.
std::vector< Dimension > _resolutions
List of resolutions.
@ WF_TIMEOUT
Window timeout counter.
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
All settings together for the game.
bool folded
Sub-page is folded (not visible except for its title)
@ SF_GUI_NEGATIVE_IS_SPECIAL
A negative value has another string (the one after "strval").
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
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.
@ SF_GUI_CURRENCY
The number represents money, so when reading value multiply by exchange rate.
void CheckBlitter()
Check whether we still use the right blitter, or use another (better) one.
@ 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.
virtual BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find setting entry at row row_num.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
#define SETTING_BUTTON_WIDTH
Width of setting buttons.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
@ WD_FRAMETEXT_RIGHT
Right offset of the text of the frame.
bool SetFocusedWidget(int widget_index)
Set focus within this window to the given widget.
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.
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.
@ TFT_README
NewGRF 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.
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.
int mouse_capture_widget
Widgetindex of current mouse capture widget (e.g. dragged scrollbar). -1 if no widget has mouse captu...
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ SA_HOR_CENTER
Horizontally center the text.
@ WHR_CATEGORY_TYPE
Both category and type settings filtered matches away.
void ShowBaseSetTextfileWindow(TextfileType file_type, const TBaseSet *baseset, StringID content_type)
Open the BaseSet version of the textfile window.
int GetNumMissing() const
Get the number of missing files.
bool ClickVolumeSliderWidget(Rect r, Point pt, byte &value)
Handle click on a volume slider widget to change the value.
int GetStringHeight(const char *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.
ZoomLevel zoom_min
minimum zoom out level
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
int8 _gui_zoom_cfg
GUI zoom level in config.
void SetButtons(byte new_val)
Set the button-depressed flags (SEF_LEFT_DEPRESSED and SEF_RIGHT_DEPRESSED) to a specified value.
@ TFT_LICENSE
NewGRF license.
SwitchMode _switch_mode
The next mainloop command.
ZoomLevel _font_zoom
Font Zoom level.
void OnResize() override
Called after the window got resized.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback)
Show a modal confirmation window with standard 'yes' and 'no' buttons The window is aligned to the ce...
StringID str_help
(Translated) string with help text; gui only.
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
@ WC_GAME_OPTIONS
Game options window; Window numbers:
@ CURRENCY_END
always the last item
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
int CDECL main(int argc, char *argv[])
And the main program (what else?)
const char * GetTextfile(TextfileType type, Subdirectory dir, const char *filename)
Search a textfile file next to the given content.
byte currency
currency we currently use
GRFTextWrapper name
NOSAVE: GRF name (Action 0x08)
virtual BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find setting entry at row row_num.
int HideDropDownMenu(Window *pw)
Delete the drop-down menu from window pw.
int32 interval
the interval to use between settings in the 'settings' window. If interval is '0' the interval is dyn...
void UnFoldAll()
Recursively open all folds of sub-pages.
bool IsVisible(const BaseSettingEntry *item) const
Check whether an entry is visible and not folded or filtered away.
virtual void GetFoldingState(bool &all_folded, bool &all_unfolded) const
Recursively accumulate the folding state of the (filtered) tree.
uint Length() const
Return number of rows needed to display the whole page.
bool SetSettingValue(const IntSettingDesc *sd, int32 value, bool force_newgame)
Top function to save the new value of an element of the Settings struct.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
@ 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.
void CloseWindowByClass(WindowClass cls)
Close all windows of a given class.
StringID str
(translated) string with descriptive text; gui and console
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.
virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible)
Update the filter state.
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.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
bool GetState() const
Get the matching state of the current item.
@ WD_IMGBTN_TOP
Top offset of image in the button.
@ SF_GUI_DROPDOWN
The value represents a limited number of string-options (internally integer) presented as dropdown.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
int32 Read(const void *object) const
Read the integer from the the actual setting.
@ WL_ERROR
Errors (eg. saving/loading failed)
@ SM_MENU
Switch to game intro menu.
static uint GetCurrentResolutionIndex()
Get index of the current screen resolution.
static const int ACTION_CLEAR
Clear editbox.
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.
int top
y position of top edge of the window
static T abs(const T a)
Returns the absolute value of (scalar) variable.
static const int LEVEL_WIDTH
Indenting width of a sub-page in pixels.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
void SetValueDParams(uint first_param, int32 value) const
Set the DParams for drawing the value of a setting.
virtual 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 ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button, Rect wi_rect, Colours wi_colour, bool auto_width, bool instant_close)
Show a drop down list.
bool _video_vsync
Whether we should use vsync (only if _video_hw_accel is enabled).
uint8 settings_restriction_mode
selected restriction mode in adv. settings GUI.
void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher)
Check whether the currently loaded language pack uses characters that the currently loaded font does ...
SettingFilter filter
Filter for the list.
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
#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.
LocaleSettings locale
settings related to used currency/unit system in the current game
void CloseWindowById(WindowClass cls, WindowNumber number, bool force)
Close a window by its class and window number (if it is open).
virtual bool IsVisible(const BaseSettingEntry *item) const
Check whether an entry is visible and not folded or filtered away.
SettingEntry(const char *name)
Constructor for a single setting in the 'advanced settings' window.
static const int SETTINGTREE_RIGHT_OFFSET
Position of right edge of setting values.
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.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
static SettingsContainer & GetSettingsTree()
Construct settings tree.
@ ST_ALL
Used in setting filter to match all types.
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.
@ SC_ADVANCED_LIST
Settings displayed in the list of advanced settings.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
virtual void ResetAll()
Resets all settings to their default values.
void DrawWidgets() const
Paint all widgets of a window.
@ ZOOM_LVL_OUT_4X
Zoomed 4 times out.
void ShowGameSettings()
Open advanced settings window.
void DrawBoolButton(int x, int y, bool state, bool clickable)
Draw a toggle button.
@ WD_IMGBTN_LEFT
Left offset of the image in the button.
StringID GetHelpText() const
Get the help text of a single setting.
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
LanguageList _languages
The actual list of language meta data.
uint64 GetMaskOfAllowedCurrencies()
get a mask of the allowed currencies depending on the year
int GetNumInvalid() const
Get the number of invalid files.
Specification of a rectangle with absolute coordinates of all edges.
bool manually_changed_folding
Whether the user expanded/collapsed something manually.
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...
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
void DisableWidget(byte widget_index)
Sets a widget to disabled.
#define CLRBITS(x, y)
Clears several bits in a variable.
@ WC_TEXTFILE
textfile; Window numbers:
@ WHR_NONE
Nothing was filtering matches away.
void UpdateGUIZoom()
Resolve GUI zoom level, if auto-suggestion is requested.
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.
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
#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.
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
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.
void OnEditboxChanged(int wid) override
The text in an editbox has been edited.
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.
virtual void UnFoldAll()
Recursively open all (filtered) folds of sub-pages.
CharSetFilter
Valid filter types for IsValidChar.
CurrencySpec _currency_specs[CURRENCY_END]
Array of currencies used by the system.
int32 def
default value given when none is present
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
@ WD_TEXTPANEL_BOTTOM
Offset at bottom to draw below the text.
void SetMediaSet(int index)
Set the base media set.
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
@ 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 UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
const struct IntSettingDesc * AsIntSetting() const
Get the setting description of this setting as an integer setting.
@ WD_TEXTPANEL_TOP
Offset at top to draw above the text.
bool IsFiltered() const
Check whether an entry is hidden due to filters.
static const Year MAX_YEAR
MAX_YEAR, nicely rounded value of the number of years that can be encoded in a single 32 bits date,...
@ RM_ADVANCED
Display settings associated to the "advanced" list.
@ WN_GAME_OPTIONS_GAME_SETTINGS
Game settings.
virtual void Close()
Hide the window and all its child windows, and mark them for a later deletion.
void ShowGameOptions()
Open the game options window.
SettingEntryFlags
Flags for SettingEntry.
static bool NatSortFunc(std::unique_ptr< const DropDownListItem > const &first, std::unique_ptr< const DropDownListItem > const &second)
Natural sorting comparator function for DropDownList::sort().