47 static const StringID _driveside_dropdown[] = {
48 STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_LEFT,
49 STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_RIGHT,
53 static const StringID _autosave_dropdown[] = {
54 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_OFF,
55 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_1_MONTH,
56 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_3_MONTHS,
57 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_6_MONTHS,
58 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_12_MONTHS,
62 static const StringID _gui_zoom_dropdown[] = {
63 STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_NORMAL,
64 STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_2X_ZOOM,
65 STR_GAME_OPTIONS_GUI_ZOOM_DROPDOWN_4X_ZOOM,
69 static const StringID _font_zoom_dropdown[] = {
70 STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_NORMAL,
71 STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_2X_ZOOM,
72 STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_4X_ZOOM,
100 if (town_name <
_nb_orig_names)
return STR_GAME_OPTIONS_TOWN_NAME_ORIGINAL_ENGLISH + town_name;
103 return STR_UNDEFINED;
126 static DropDownList *BuildSetDropDownList(
int *selected_index,
bool allow_selection)
128 int n = T::GetNumSets();
129 *selected_index = T::GetIndexOfUsedSet();
132 for (
int i = 0; i < n; i++) {
139 DropDownList *BuildMusicSetDropDownList(
int *selected_index)
141 return BuildSetDropDownList<BaseMusic>(selected_index,
true);
145 template <
class TBaseSet>
152 const char *textfile = this->baseset->GetTextfile(file_type);
171 template <
class TBaseSet>
185 this->reload =
false;
230 const StringID *items = _driveside_dropdown;
250 int enabled_item = (_game_mode == GM_MENU ||
Town::GetNumItems() == 0) ? -1 : *selected_index;
259 int newgrf_size = list->
Length();
261 if (newgrf_size > 0) {
268 *list->
Append() =
new DropDownListStringItem(STR_GAME_OPTIONS_TOWN_NAME_ORIGINAL_ENGLISH + i, i, enabled_item != i && enabled_item >= 0);
277 const StringID *items = _autosave_dropdown;
307 const StringID *items = _gui_zoom_dropdown;
317 const StringID *items = _font_zoom_dropdown;
325 list = BuildSetDropDownList<BaseGraphics>(selected_index, (_game_mode == GM_MENU));
329 list = BuildSetDropDownList<BaseSounds>(selected_index, (_game_mode == GM_MENU));
333 list = BuildMusicSetDropDownList(selected_index);
389 size->height =
max(size->height, (uint)
GetStringHeight(STR_BLACK_RAW_STRING, size->width));
397 if (invalid_files == 0)
continue;
408 size->height =
max(size->height, (uint)
GetStringHeight(STR_BLACK_RAW_STRING, size->width));
416 size->height =
max(size->height, (uint)
GetStringHeight(STR_BLACK_RAW_STRING, size->width));
424 if (invalid_files == 0)
continue;
433 DropDownList *list = this->BuildDropDownList(widget, &selected);
438 int width = (*it)->Width();
439 string_dim.width = width + padding.width;
440 string_dim.height = (*it)->Height(width) + padding.height;
441 *size =
maxdim(*size, string_dim);
472 if (!ToggleFullScreen(!_fullscreen)) {
481 DropDownList *list = this->BuildDropDownList(widget, &selected);
500 if (_game_mode == GM_MENU) {
501 const char *name = T::GetSet(index)->name;
574 this->SetMediaSet<BaseGraphics>(index);
578 this->SetMediaSet<BaseSounds>(index);
594 if (!gui_scope)
return;
600 for (
TextfileType tft = TFT_BEGIN; tft < TFT_END; tft++) {
611 static const NWidgetPart _nested_game_options_widgets[] = {
626 NWidget(
WWT_DROPDOWN, COLOUR_GREY,
WID_GO_RESOLUTION_DROPDOWN),
SetMinimalSize(150, 12),
SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_RESOLUTION_TOOLTIP),
SetFill(1, 0),
SetPadding(0, 0, 3, 0),
659 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),
672 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),
685 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),
699 _nested_game_options_widgets,
lengthof(_nested_game_options_widgets)
753 virtual void Init(byte level = 0);
754 virtual void FoldAll() {}
755 virtual void UnFoldAll() {}
763 virtual uint Length()
const = 0;
764 virtual void GetFoldingState(
bool &all_folded,
bool &all_unfolded)
const {}
767 virtual uint GetMaxHelpHeight(
int maxw) {
return 0; }
775 virtual bool UpdateFilterState(
SettingFilter &filter,
bool force_visible) = 0;
777 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;
780 virtual void DrawSetting(
GameSettings *settings_ptr,
int left,
int right,
int y,
bool highlight)
const = 0;
791 virtual void Init(byte level = 0);
792 virtual uint Length()
const;
793 virtual uint GetMaxHelpHeight(
int maxw);
794 virtual bool UpdateFilterState(
SettingFilter &filter,
bool force_visible);
796 void SetButtons(byte new_val);
807 void SetValueDParams(uint first_param, int32 value)
const;
810 virtual void DrawSetting(
GameSettings *settings_ptr,
int left,
int right,
int y,
bool highlight)
const;
818 typedef std::vector<BaseSettingEntry*> EntryVector;
824 this->entries.push_back(item);
828 void Init(byte level = 0);
833 void GetFoldingState(
bool &all_folded,
bool &all_unfolded)
const;
836 uint GetMaxHelpHeight(
int maxw);
838 bool UpdateFilterState(
SettingFilter &filter,
bool force_visible);
840 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;
850 virtual void Init(byte level = 0);
851 virtual void FoldAll();
852 virtual void UnFoldAll();
854 virtual uint Length()
const;
855 virtual void GetFoldingState(
bool &all_folded,
bool &all_unfolded)
const;
860 virtual bool UpdateFilterState(
SettingFilter &filter,
bool force_visible);
862 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;
865 virtual void DrawSetting(
GameSettings *settings_ptr,
int left,
int right,
int y,
bool highlight)
const;
887 if (this->IsFiltered())
return false;
888 if (
this == item)
return true;
900 if (this->IsFiltered())
return NULL;
901 if (row_num == *cur_row)
return this;
937 if (this->IsFiltered())
return cur_row;
938 if (cur_row >= max_row)
return cur_row;
941 int offset = rtl ? -4 : 4;
944 int x = rtl ? right :
left;
945 if (cur_row >= first_row) {
950 for (uint lvl = 0; lvl < this->level; lvl++) {
951 if (!
HasBit(parent_last, lvl)) GfxDrawLine(x + offset, y, x + offset, y +
SETTING_HEIGHT - 1, colour);
957 GfxDrawLine(x + offset, y, x + offset, bottom_y, colour);
959 GfxDrawLine(x + offset, halfway_y, x + level_width - offset, halfway_y, colour);
962 this->DrawSetting(settings_ptr, rtl ? left : x, rtl ? x : right, y,
this == selected);
978 this->setting = NULL;
990 assert(this->setting != NULL);
1007 return this->IsFiltered() ? 0 : 1;
1028 if (mode ==
RM_ALL)
return true;
1037 const void *var = ResolveVariableAddress(settings_ptr, sd);
1060 return current_value != filter_value;
1073 bool visible =
true;
1094 if (!this->IsVisibleByRestrictionMode(filter.
mode)) {
1127 SetDParam(first_param++, value != 0 ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
1153 const void *var = ResolveVariableAddress(settings_ptr, sd);
1165 SetDParam(0, highlight ? STR_ORANGE_STRING1_WHITE : STR_ORANGE_STRING1_LTBLUE);
1178 this->SetValueDParams(1, value);
1190 for (EntryVector::iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1198 for (EntryVector::iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1206 for (EntryVector::iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1218 for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1219 (*it)->GetFoldingState(all_folded, all_unfolded);
1231 bool visible =
false;
1232 bool first_visible =
true;
1233 for (EntryVector::reverse_iterator it = this->entries.rbegin(); it != this->entries.rend(); ++it) {
1234 visible |= (*it)->UpdateFilterState(filter, force_visible);
1235 (*it)->SetLastField(first_visible);
1236 if (visible && first_visible) first_visible =
false;
1250 for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1251 if ((*it)->IsVisible(item))
return true;
1260 for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1261 length += (*it)->Length();
1275 for (EntryVector::iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1276 pe = (*it)->
FindEntry(row_num, cur_row);
1292 for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1293 biggest =
max(biggest, (*it)->GetMaxHelpHeight(maxw));
1315 for (EntryVector::const_iterator it = this->entries.begin(); it != this->entries.end(); ++it) {
1316 cur_row = (*it)->Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1317 if (cur_row >= max_row) {
1332 this->title = title;
1333 this->folded =
true;
1349 if (this->IsFiltered())
return;
1350 this->folded =
true;
1358 if (this->IsFiltered())
return;
1359 this->folded =
false;
1371 if (this->IsFiltered())
return;
1374 all_unfolded =
false;
1413 if (this->IsFiltered())
return false;
1414 if (
this == item)
return true;
1415 if (this->folded)
return false;
1423 if (this->IsFiltered())
return 0;
1424 if (this->folded)
return 1;
1437 if (this->IsFiltered())
return NULL;
1438 if (row_num == *cur_row)
return this;
1440 if (this->folded)
return NULL;
1461 if (this->IsFiltered())
return cur_row;
1462 if (cur_row >= max_row)
return cur_row;
1464 cur_row =
BaseSettingEntry::Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1466 if (!this->folded) {
1468 assert(this->level < 8 *
sizeof(parent_last));
1469 SetBit(parent_last, this->level);
1472 cur_row =
SettingsContainer::Draw(settings_ptr, left, right, y, first_row, max_row, selected, cur_row, parent_last);
1489 DrawSprite((this->folded ? SPR_CIRCLE_FOLDED : SPR_CIRCLE_UNFOLDED), PAL_NONE, rtl ? right - _circle_size.width : left, y + (
SETTING_HEIGHT - _circle_size.height) / 2);
1505 localisation->Add(
new SettingEntry(
"locale.units_velocity"));
1506 localisation->Add(
new SettingEntry(
"locale.units_power"));
1507 localisation->Add(
new SettingEntry(
"locale.units_weight"));
1508 localisation->Add(
new SettingEntry(
"locale.units_volume"));
1509 localisation->Add(
new SettingEntry(
"locale.units_force"));
1510 localisation->Add(
new SettingEntry(
"locale.units_height"));
1511 localisation->Add(
new SettingEntry(
"gui.date_format_in_default_names"));
1518 graphics->Add(
new SettingEntry(
"gui.smallmap_land_colour"));
1519 graphics->Add(
new SettingEntry(
"gui.graph_line_thickness"));
1534 SettingsPage *
interface = main->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE));
1536 SettingsPage *general = interface->Add(
new SettingsPage(STR_CONFIG_SETTING_INTERFACE_GENERAL));
1541 general->Add(
new SettingEntry(
"gui.window_snap_radius"));
1542 general->Add(
new SettingEntry(
"gui.window_soft_limit"));
1543 general->Add(
new SettingEntry(
"gui.right_mouse_wnd_close"));
1546 SettingsPage *viewports = interface->Add(
new SettingsPage(STR_CONFIG_SETTING_INTERFACE_VIEWPORTS));
1548 viewports->Add(
new SettingEntry(
"gui.auto_scrolling"));
1554 viewports->Add(
new SettingEntry(
"gui.scrollwheel_scrolling"));
1555 viewports->Add(
new SettingEntry(
"gui.scrollwheel_multiplier"));
1558 viewports->Add(
new SettingEntry(
"gui.right_mouse_btn_emulation"));
1560 viewports->Add(
new SettingEntry(
"gui.population_in_label"));
1562 viewports->Add(
new SettingEntry(
"construction.train_signal_side"));
1563 viewports->Add(
new SettingEntry(
"gui.measure_tooltip"));
1564 viewports->Add(
new SettingEntry(
"gui.loading_indicators"));
1565 viewports->Add(
new SettingEntry(
"gui.show_track_reservation"));
1568 SettingsPage *construction = interface->Add(
new SettingsPage(STR_CONFIG_SETTING_INTERFACE_CONSTRUCTION));
1570 construction->Add(
new SettingEntry(
"gui.link_terraform_toolbar"));
1571 construction->Add(
new SettingEntry(
"gui.enable_signal_gui"));
1572 construction->Add(
new SettingEntry(
"gui.persistent_buildingtools"));
1574 construction->Add(
new SettingEntry(
"gui.default_rail_type"));
1575 construction->Add(
new SettingEntry(
"gui.disable_unsuitable_building"));
1581 interface->Add(
new SettingEntry(
"gui.prefer_teamchat"));
1582 interface->Add(
new SettingEntry(
"gui.advanced_vehicle_list"));
1583 interface->Add(
new SettingEntry(
"gui.timetable_in_ticks"));
1584 interface->Add(
new SettingEntry(
"gui.timetable_arrival_departure"));
1585 interface->Add(
new SettingEntry(
"gui.expenses_layout"));
1588 SettingsPage *advisors = main->Add(
new SettingsPage(STR_CONFIG_SETTING_ADVISORS));
1590 advisors->Add(
new SettingEntry(
"gui.coloured_news_year"));
1591 advisors->Add(
new SettingEntry(
"news_display.general"));
1592 advisors->Add(
new SettingEntry(
"news_display.new_vehicles"));
1593 advisors->Add(
new SettingEntry(
"news_display.accident"));
1594 advisors->Add(
new SettingEntry(
"news_display.company_info"));
1595 advisors->Add(
new SettingEntry(
"news_display.acceptance"));
1596 advisors->Add(
new SettingEntry(
"news_display.arrival_player"));
1597 advisors->Add(
new SettingEntry(
"news_display.arrival_other"));
1598 advisors->Add(
new SettingEntry(
"news_display.advice"));
1599 advisors->Add(
new SettingEntry(
"gui.order_review_system"));
1600 advisors->Add(
new SettingEntry(
"gui.vehicle_income_warn"));
1601 advisors->Add(
new SettingEntry(
"gui.lost_vehicle_warn"));
1603 advisors->Add(
new SettingEntry(
"news_display.economy"));
1604 advisors->Add(
new SettingEntry(
"news_display.subsidies"));
1607 advisors->Add(
new SettingEntry(
"news_display.production_player"));
1608 advisors->Add(
new SettingEntry(
"news_display.production_other"));
1609 advisors->Add(
new SettingEntry(
"news_display.production_nobody"));
1612 SettingsPage *company = main->Add(
new SettingsPage(STR_CONFIG_SETTING_COMPANY));
1614 company->Add(
new SettingEntry(
"gui.semaphore_build_before"));
1615 company->Add(
new SettingEntry(
"gui.default_signal_type"));
1616 company->Add(
new SettingEntry(
"gui.cycle_signal_types"));
1617 company->Add(
new SettingEntry(
"gui.drag_signals_fixed_distance"));
1621 company->Add(
new SettingEntry(
"company.engine_renew"));
1622 company->Add(
new SettingEntry(
"company.engine_renew_months"));
1623 company->Add(
new SettingEntry(
"company.engine_renew_money"));
1624 company->Add(
new SettingEntry(
"vehicle.servint_ispercent"));
1625 company->Add(
new SettingEntry(
"vehicle.servint_trains"));
1626 company->Add(
new SettingEntry(
"vehicle.servint_roadveh"));
1627 company->Add(
new SettingEntry(
"vehicle.servint_ships"));
1628 company->Add(
new SettingEntry(
"vehicle.servint_aircraft"));
1631 SettingsPage *accounting = main->Add(
new SettingsPage(STR_CONFIG_SETTING_ACCOUNTING));
1633 accounting->Add(
new SettingEntry(
"economy.inflation"));
1634 accounting->Add(
new SettingEntry(
"difficulty.initial_interest"));
1635 accounting->Add(
new SettingEntry(
"difficulty.max_loan"));
1636 accounting->Add(
new SettingEntry(
"difficulty.subsidy_multiplier"));
1637 accounting->Add(
new SettingEntry(
"economy.feeder_payment_share"));
1638 accounting->Add(
new SettingEntry(
"economy.infrastructure_maintenance"));
1639 accounting->Add(
new SettingEntry(
"difficulty.vehicle_costs"));
1640 accounting->Add(
new SettingEntry(
"difficulty.construction_cost"));
1643 SettingsPage *vehicles = main->Add(
new SettingsPage(STR_CONFIG_SETTING_VEHICLES));
1645 SettingsPage *physics = vehicles->Add(
new SettingsPage(STR_CONFIG_SETTING_VEHICLES_PHYSICS));
1647 physics->Add(
new SettingEntry(
"vehicle.train_acceleration_model"));
1648 physics->Add(
new SettingEntry(
"vehicle.train_slope_steepness"));
1649 physics->Add(
new SettingEntry(
"vehicle.wagon_speed_limits"));
1650 physics->Add(
new SettingEntry(
"vehicle.freight_trains"));
1651 physics->Add(
new SettingEntry(
"vehicle.roadveh_acceleration_model"));
1652 physics->Add(
new SettingEntry(
"vehicle.roadveh_slope_steepness"));
1653 physics->Add(
new SettingEntry(
"vehicle.smoke_amount"));
1657 SettingsPage *routing = vehicles->Add(
new SettingsPage(STR_CONFIG_SETTING_VEHICLES_ROUTING));
1659 routing->Add(
new SettingEntry(
"pf.pathfinder_for_trains"));
1660 routing->Add(
new SettingEntry(
"difficulty.line_reverse_mode"));
1661 routing->Add(
new SettingEntry(
"pf.reverse_at_signals"));
1663 routing->Add(
new SettingEntry(
"pf.pathfinder_for_roadvehs"));
1664 routing->Add(
new SettingEntry(
"pf.pathfinder_for_ships"));
1667 vehicles->Add(
new SettingEntry(
"order.no_servicing_if_no_breakdowns"));
1668 vehicles->Add(
new SettingEntry(
"order.serviceathelipad"));
1671 SettingsPage *limitations = main->Add(
new SettingsPage(STR_CONFIG_SETTING_LIMITATIONS));
1673 limitations->Add(
new SettingEntry(
"construction.command_pause_level"));
1674 limitations->Add(
new SettingEntry(
"construction.autoslope"));
1675 limitations->Add(
new SettingEntry(
"construction.extra_dynamite"));
1676 limitations->Add(
new SettingEntry(
"construction.max_heightlevel"));
1677 limitations->Add(
new SettingEntry(
"construction.max_bridge_length"));
1678 limitations->Add(
new SettingEntry(
"construction.max_bridge_height"));
1679 limitations->Add(
new SettingEntry(
"construction.max_tunnel_length"));
1680 limitations->Add(
new SettingEntry(
"station.never_expire_airports"));
1681 limitations->Add(
new SettingEntry(
"vehicle.never_expire_vehicles"));
1682 limitations->Add(
new SettingEntry(
"vehicle.max_trains"));
1683 limitations->Add(
new SettingEntry(
"vehicle.max_roadveh"));
1684 limitations->Add(
new SettingEntry(
"vehicle.max_aircraft"));
1685 limitations->Add(
new SettingEntry(
"vehicle.max_ships"));
1686 limitations->Add(
new SettingEntry(
"vehicle.max_train_length"));
1687 limitations->Add(
new SettingEntry(
"station.station_spread"));
1688 limitations->Add(
new SettingEntry(
"station.distant_join_stations"));
1689 limitations->Add(
new SettingEntry(
"construction.road_stop_on_town_road"));
1690 limitations->Add(
new SettingEntry(
"construction.road_stop_on_competitor_road"));
1691 limitations->Add(
new SettingEntry(
"vehicle.disable_elrails"));
1694 SettingsPage *disasters = main->Add(
new SettingsPage(STR_CONFIG_SETTING_ACCIDENTS));
1696 disasters->Add(
new SettingEntry(
"difficulty.disasters"));
1697 disasters->Add(
new SettingEntry(
"difficulty.economy"));
1698 disasters->Add(
new SettingEntry(
"difficulty.vehicle_breakdowns"));
1699 disasters->Add(
new SettingEntry(
"vehicle.plane_crashes"));
1702 SettingsPage *genworld = main->Add(
new SettingsPage(STR_CONFIG_SETTING_GENWORLD));
1704 genworld->Add(
new SettingEntry(
"game_creation.landscape"));
1705 genworld->Add(
new SettingEntry(
"game_creation.land_generator"));
1706 genworld->Add(
new SettingEntry(
"difficulty.terrain_type"));
1707 genworld->Add(
new SettingEntry(
"game_creation.tgen_smoothness"));
1708 genworld->Add(
new SettingEntry(
"game_creation.variety"));
1709 genworld->Add(
new SettingEntry(
"game_creation.snow_line_height"));
1710 genworld->Add(
new SettingEntry(
"game_creation.amount_of_rivers"));
1711 genworld->Add(
new SettingEntry(
"game_creation.tree_placer"));
1713 genworld->Add(
new SettingEntry(
"economy.larger_towns"));
1714 genworld->Add(
new SettingEntry(
"economy.initial_city_size"));
1715 genworld->Add(
new SettingEntry(
"economy.town_layout"));
1716 genworld->Add(
new SettingEntry(
"difficulty.industry_density"));
1717 genworld->Add(
new SettingEntry(
"gui.pause_on_newgame"));
1720 SettingsPage *environment = main->Add(
new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT));
1722 SettingsPage *authorities = environment->Add(
new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_AUTHORITIES));
1724 authorities->Add(
new SettingEntry(
"difficulty.town_council_tolerance"));
1726 authorities->Add(
new SettingEntry(
"economy.exclusive_rights"));
1727 authorities->Add(
new SettingEntry(
"economy.fund_roads"));
1728 authorities->Add(
new SettingEntry(
"economy.fund_buildings"));
1729 authorities->Add(
new SettingEntry(
"economy.station_noise_level"));
1732 SettingsPage *towns = environment->Add(
new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_TOWNS));
1734 towns->Add(
new SettingEntry(
"economy.town_growth_rate"));
1735 towns->Add(
new SettingEntry(
"economy.allow_town_roads"));
1736 towns->Add(
new SettingEntry(
"economy.allow_town_level_crossings"));
1740 SettingsPage *industries = environment->Add(
new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_INDUSTRIES));
1742 industries->Add(
new SettingEntry(
"construction.raw_industry_construction"));
1743 industries->Add(
new SettingEntry(
"construction.industry_platform"));
1744 industries->Add(
new SettingEntry(
"economy.multiple_industry_per_town"));
1745 industries->Add(
new SettingEntry(
"game_creation.oil_refinery_limit"));
1746 industries->Add(
new SettingEntry(
"economy.smooth_economy"));
1749 SettingsPage *cdist = environment->Add(
new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_CARGODIST));
1752 cdist->Add(
new SettingEntry(
"linkgraph.recalc_interval"));
1753 cdist->Add(
new SettingEntry(
"linkgraph.distribution_pax"));
1754 cdist->Add(
new SettingEntry(
"linkgraph.distribution_mail"));
1755 cdist->Add(
new SettingEntry(
"linkgraph.distribution_armoured"));
1756 cdist->Add(
new SettingEntry(
"linkgraph.distribution_default"));
1758 cdist->Add(
new SettingEntry(
"linkgraph.demand_distance"));
1760 cdist->Add(
new SettingEntry(
"linkgraph.short_path_saturation"));
1763 environment->Add(
new SettingEntry(
"station.modified_catchment"));
1764 environment->Add(
new SettingEntry(
"construction.extra_tree_placement"));
1767 SettingsPage *ai = main->Add(
new SettingsPage(STR_CONFIG_SETTING_AI));
1769 SettingsPage *npc = ai->Add(
new SettingsPage(STR_CONFIG_SETTING_AI_NPC));
1772 npc->Add(
new SettingEntry(
"script.script_max_opcode_till_suspend"));
1773 npc->Add(
new SettingEntry(
"difficulty.competitor_speed"));
1776 npc->Add(
new SettingEntry(
"ai.ai_disable_veh_roadveh"));
1777 npc->Add(
new SettingEntry(
"ai.ai_disable_veh_aircraft"));
1790 static const StringID _game_settings_restrict_dropdown[] = {
1791 STR_CONFIG_SETTING_RESTRICT_BASIC,
1792 STR_CONFIG_SETTING_RESTRICT_ADVANCED,
1793 STR_CONFIG_SETTING_RESTRICT_ALL,
1794 STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_DEFAULT,
1795 STR_CONFIG_SETTING_RESTRICT_CHANGED_AGAINST_NEW,
1797 assert_compile(
lengthof(_game_settings_restrict_dropdown) ==
RM_END);
1809 static const int SETTINGTREE_LEFT_OFFSET = 5;
1810 static const int SETTINGTREE_RIGHT_OFFSET = 5;
1811 static const int SETTINGTREE_TOP_OFFSET = 5;
1812 static const int SETTINGTREE_BOTTOM_OFFSET = 5;
1833 this->warn_lines = 0;
1835 this->filter.min_cat =
RM_ALL;
1836 this->filter.type =
ST_ALL;
1837 this->filter.type_hides =
false;
1843 this->valuewindow_entry = NULL;
1844 this->clicked_entry = NULL;
1845 this->last_clicked = NULL;
1846 this->valuedropdown_entry = NULL;
1847 this->closing_dropdown =
false;
1848 this->manually_changed_folding =
false;
1868 size->height = 5 * resize->height + SETTINGTREE_TOP_OFFSET + SETTINGTREE_BOTTOM_OFFSET;
1872 static const StringID setting_types[] = {
1873 STR_CONFIG_SETTING_TYPE_CLIENT,
1874 STR_CONFIG_SETTING_TYPE_COMPANY_MENU, STR_CONFIG_SETTING_TYPE_COMPANY_INGAME,
1875 STR_CONFIG_SETTING_TYPE_GAME_MENU, STR_CONFIG_SETTING_TYPE_GAME_INGAME,
1877 for (uint i = 0; i <
lengthof(setting_types); i++) {
1898 if (this->closing_dropdown) {
1899 this->closing_dropdown =
false;
1900 assert(this->valuedropdown_entry != NULL);
1902 this->valuedropdown_entry = NULL;
1907 StringID warn_str = STR_CONFIG_SETTING_CATEGORY_HIDES - 1 + this->warn_missing;
1909 if (this->warn_missing ==
WHR_NONE) {
1915 if (this->warn_lines != new_warn_lines) {
1916 this->vscroll->
SetCount(this->vscroll->
GetCount() - this->warn_lines + new_warn_lines);
1917 this->warn_lines = new_warn_lines;
1923 if (this->warn_missing !=
WHR_NONE) {
1925 const int right = left + panel->
current_x - 1;
1928 if (this->warn_lines == 1) {
1941 SetDParam(0, _game_settings_restrict_dropdown[this->filter.
mode]);
1945 switch (this->filter.
type) {
1946 case ST_GAME:
SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME);
break;
1947 case ST_COMPANY:
SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME);
break;
1949 default:
SetDParam(0, STR_CONFIG_SETTING_TYPE_DROPDOWN_ALL);
break;
1962 for (
int mode = 0; mode !=
RM_END; mode++) {
1974 *list->
Append() =
new DropDownListStringItem(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_GAME_INGAME,
ST_GAME,
false);
1975 *list->
Append() =
new DropDownListStringItem(_game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_DROPDOWN_COMPANY_INGAME,
ST_COMPANY,
false);
1986 int top_pos = r.top + SETTINGTREE_TOP_OFFSET + 1 + this->warn_lines *
SETTING_HEIGHT;
1988 int next_row =
GetSettingsTree().
Draw(settings_ptr, r.left + SETTINGTREE_LEFT_OFFSET, r.right - SETTINGTREE_RIGHT_OFFSET, top_pos,
1989 this->vscroll->GetPosition(), last_row, this->last_clicked);
1990 if (next_row == 0)
DrawString(r.left + SETTINGTREE_LEFT_OFFSET, r.right - SETTINGTREE_RIGHT_OFFSET, top_pos, STR_CONFIG_SETTINGS_NONE);
1995 if (this->last_clicked != NULL) {
2000 case ST_COMPANY:
SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_COMPANY_MENU : STR_CONFIG_SETTING_TYPE_COMPANY_INGAME);
break;
2002 case ST_GAME:
SetDParam(0, _game_mode == GM_MENU ? STR_CONFIG_SETTING_TYPE_GAME_MENU : STR_CONFIG_SETTING_TYPE_GAME_INGAME);
break;
2003 default: NOT_REACHED();
2005 DrawString(r.left, r.right, y, STR_CONFIG_SETTING_TYPE);
2010 DrawString(r.left, r.right, y, STR_CONFIG_SETTING_DEFAULT_VALUE);
2013 DrawStringMultiLine(r.left, r.right, y, r.bottom, this->last_clicked->GetHelpText(), TC_WHITE);
2028 if (this->last_clicked != pe) this->
SetDirty();
2029 this->last_clicked = pe;
2036 this->manually_changed_folding =
true;
2042 this->manually_changed_folding =
true;
2067 if (btn == INT_MAX || (
int)btn < this->warn_lines)
return;
2068 btn -= this->warn_lines;
2073 if (clicked_entry == NULL)
return;
2079 if (clicked_page != NULL) {
2080 this->SetDisplayedHelpText(NULL);
2083 this->manually_changed_folding =
true;
2095 this->SetDisplayedHelpText(pe);
2099 const void *var = ResolveVariableAddress(settings_ptr, sd);
2105 this->SetDisplayedHelpText(pe);
2107 if (this->valuedropdown_entry == pe) {
2110 this->closing_dropdown =
false;
2112 this->valuedropdown_entry = NULL;
2114 if (this->valuedropdown_entry != NULL) this->valuedropdown_entry->
SetButtons(0);
2115 this->closing_dropdown =
false;
2118 int rel_y = (pt.y - (int)wid->
pos_y - SETTINGTREE_TOP_OFFSET) % wid->
resize_y;
2127 if (pt.y >= wi_rect.top && pt.y <= wi_rect.bottom) {
2128 this->valuedropdown_entry = pe;
2132 for (
int i = sdb->
min; i <= (
int)sdb->
max; i++) {
2141 this->SetDisplayedHelpText(pe);
2143 int32 oldvalue = value;
2154 if (step == 0) step = 1;
2166 assert((int32)sdb->
max >= 0);
2167 if (value > (int32)sdb->
max) value = (int32)sdb->
max;
2169 if ((uint32)value > sdb->
max) value = (int32)sdb->
max;
2171 if (value < sdb->
min) value = sdb->
min;
2178 if (value != oldvalue) {
2179 if (this->clicked_entry != NULL) {
2180 this->clicked_entry->SetButtons(0);
2182 this->clicked_entry = pe;
2190 default: NOT_REACHED();
2193 if (value != oldvalue) {
2207 this->valuewindow_entry = pe;
2211 this->SetDisplayedHelpText(pe);
2217 if (this->clicked_entry != NULL) {
2219 this->clicked_entry = NULL;
2227 if (str == NULL)
return;
2229 assert(this->valuewindow_entry != NULL);
2239 value = (int32)(
size_t)sd->
desc.
def;
2258 if (!this->manually_changed_folding) {
2278 assert(this->valuedropdown_entry != NULL);
2307 assert(this->valuedropdown_entry != NULL);
2308 this->closing_dropdown =
true;
2315 if (!gui_scope)
return;
2319 this->filter.min_cat = min_level;
2320 this->filter.type_hides =
false;
2325 }
else if (min_level < this->filter.
min_cat) {
2332 if (this->last_clicked != NULL && !
GetSettingsTree().IsVisible(this->last_clicked)) {
2333 this->SetDisplayedHelpText(NULL);
2336 bool all_folded =
true;
2337 bool all_unfolded =
true;
2347 if (!this->filter.
string.
IsEmpty() && !this->manually_changed_folding) {
2364 static const NWidgetPart _nested_settings_selection_widgets[] = {
2374 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),
2378 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),
2385 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
2409 _nested_settings_selection_widgets,
lengthof(_nested_settings_selection_widgets)
2429 void DrawArrowButtons(
int x,
int y, Colours button_colour, byte state,
bool clickable_left,
bool clickable_right)
2432 Dimension dim = NWidgetScrollbar::GetHorizontalDimension();
2434 DrawFrameRect(x, y, x + dim.width - 1, y + dim.height - 1, button_colour, (state == 1) ?
FR_LOWERED : FR_NONE);
2435 DrawFrameRect(x + dim.width, y, x + dim.width + dim.width - 1, y + dim.height - 1, button_colour, (state == 2) ?
FR_LOWERED : FR_NONE);
2441 if (rtl ? !clickable_right : !clickable_left) {
2444 if (rtl ? !clickable_left : !clickable_right) {
2478 static const Colours _bool_ctabs[2][2] = {{COLOUR_CREAM, COLOUR_RED}, {COLOUR_DARK_GREEN, COLOUR_GREEN}};
2492 void SetButtonState()
2508 SetDParam(0, (_custom_currency.to_euro !=
CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER);
2546 if (_custom_currency.rate > 1) _custom_currency.rate--;
2552 if (_custom_currency.rate < UINT16_MAX) _custom_currency.rate++;
2568 str = STR_JUST_RAW_STRING;
2576 str = STR_JUST_RAW_STRING;
2584 str = STR_JUST_RAW_STRING;
2590 _custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ?
CF_NOEURO : _custom_currency.to_euro - 1;
2596 _custom_currency.to_euro =
Clamp(_custom_currency.to_euro + 1, 2000,
MAX_YEAR);
2611 this->query_widget = line;
2612 ShowQueryString(str, STR_CURRENCY_CHANGE_PARAMETER, len + 1,
this, afilter, QSF_NONE);
2621 if (str == NULL)
return;
2623 switch (this->query_widget) {
2625 _custom_currency.rate =
Clamp(atoi(str), 1, UINT16_MAX);
2629 strecpy(_custom_currency.separator, str,
lastof(_custom_currency.separator));
2633 strecpy(_custom_currency.prefix, str,
lastof(_custom_currency.prefix));
2637 strecpy(_custom_currency.suffix, str,
lastof(_custom_currency.suffix));
2641 int val = atoi(str);
2657 static const NWidgetPart _nested_cust_currency_widgets[] = {
2693 SetDataTip(STR_CURRENCY_PREVIEW, STR_CURRENCY_CUSTOM_CURRENCY_PREVIEW_TOOLTIP),
SetPadding(15, 1, 18, 2),
2701 _nested_cust_currency_widgets,
lengthof(_nested_cust_currency_widgets)
RestrictionMode mode
Filter based on category.
Functions related to OTTD's strings.
VehicleSettings vehicle
options for vehicles
virtual void OnTimeout()
Called when this window's timeout has been reached.
Definition of stuff that is very close to a company, like the company struct itself.
void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher)
Check whether the currently loaded language pack uses characters that the currently loaded font does ...
bool _networking
are we in networking mode?
const void * def
default value given when none is present
virtual bool IsVisible(const BaseSettingEntry *item) const
Check whether an entry is visible and not folded or filtered away.
bool IsFiltered() const
Check whether an entry is hidden due to filters.
Horizontally center the text.
ResizeInfo resize
Resize information.
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
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 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 SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
int warn_lines
Number of lines used for warning about missing search results.
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
uint GetMaxHelpHeight(int maxw)
Get the biggest height of the help texts, if the width is at least maxw.
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
this setting can be different for each company (saved in company struct)
High level window description.
WindowFlags flags
Window flags.
int left
x position of left edge of the window
All settings together for the game.
void DrawWidgets() const
Paint all widgets of a window.
void ChangeMusicSet(int index)
Change the configured music set and reset playback.
static Titem * Get(size_t index)
Returns Titem with given index.
Switch to game intro menu.
virtual void UnFoldAll()
Recursively open all (filtered) folds of sub-pages.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
SettingsPage(StringID title)
Constructor for a sub-page in the 'advanced settings' window.
CurrencySpec _currency_specs[CURRENCY_END]
Array of currencies used by the system.
Functions to handle different currencies.
virtual void Init(byte level=0)
Initialization of a setting entry.
int GetNumInvalid() const
Get the number of invalid files.
Data structure describing a single setting in a tab.
Of a numeric setting entry, the right button is depressed.
Normal amount of vertical space between two paragraphs of text.
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
textfile; Window numbers:
void ResetState()
Reset the matching state to process a new item.
void UnFoldAll()
Recursively open all folds of sub-pages.
void SetMediaSet(int index)
Set the base media set.
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
SettingGuiFlag flags
handles how a setting would show up in the GUI (text/currency, etc.)
bool GetState() const
Get the matching state of the current item.
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
void ShowDropDownList(Window *w, const DropDownList *list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
fluid_settings_t * settings
FluidSynth settings handle.
Show only settings which are different compared to the user's new game setting values.
#define SETBITS(x, y)
Sets several bits in a variable.
const LanguageMetadata * _current_language
The currently loaded language.
bool closing_dropdown
True, if the dropdown list is currently closing.
static Dimension _circle_size
Dimension of the circle +/- icon. This is here as not all users are within the class of the settings ...
the number represents money, so when reading value multiply by exchange rate
DropDownList * BuildDropDownList(int widget, int *selected_index) const
Build the dropdown list for a specific widget.
static const int ACTION_CLEAR
Clear editbox.
Filter for settings list.
int top
y position of top edge of the window
Header of Action 0F "universal holder" structure and functions.
Type setting filtered matches away.
int64 ReadValue(const void *ptr, VarType conv)
Return a signed-long version of the value of a setting.
const T * Begin() const
Get the pointer to the first item (const)
virtual void OnDropdownClose(Point pt, int widget, int index, bool instant_close)
A dropdown window associated to this window has been closed.
WarnHiddenResult
Warnings about hidden search results.
void SetButtons(byte new_val)
Set the button-depressed flags (SEF_LEFT_DEPRESSED and SEF_RIGHT_DEPRESSED) to a specified value...
WarnHiddenResult warn_missing
Whether and how to warn about missing search results.
int GetStringHeight(const char *str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
LanguageList _languages
The actual list of language meta data.
Window to edit settings of the game.
Properties of config file settings.
uint Length() const
Return number of rows needed to display the whole page.
int _num_resolutions
The number of resolutions.
Settings displayed in the list of basic settings.
void SetLastField(bool last_field)
Set whether this is the last visible entry of the parent node.
#define lastof(x)
Get the last element of an fixed size array.
ZoomLevelByte _gui_zoom
GUI Zoom level.
Settings displayed in the list of advanced settings.
Show only settings which are different compared to default values.
Stuff related to the text buffer GUI.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
const SettingDesc * setting
Setting description of the setting.
void DisableWidget(byte widget_index)
Sets a widget to disabled.
#define CLRBITS(x, y)
Clears several bits in a variable.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
Subdirectory for all base data (base sets, intro game)
static T max(const T a, const T b)
Returns the maximum of two values.
static StringID TownName(int town_name)
Get a town name.
virtual uint GetMaxHelpHeight(int maxw)
Get the biggest height of the help text(s), if the width is at least maxw.
the value represents a limited number of string-options (internally integer)
int GetNumMissing() const
Get the number of missing files.
const T * End() const
Get the pointer behind the last valid item (const)
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
virtual void Init(byte level=0)
Initialization of an entire setting page.
int HideDropDownMenu(Window *pw)
Delete the drop-down menu from window pw.
virtual void OnQueryTextFinished(char *str)
The query window opened from this window has closed.
static const int LEVEL_WIDTH
Indenting width of a sub-page in pixels.
bool _left_button_clicked
Is left mouse button clicked?
T * Append(uint to_add=1)
Append an item and return it.
CompanyByte _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Functions related to (drawing on) viewports.
static int GetCurRes()
Get index of the current screen resolution.
Base for the GUIs that have an edit box in them.
Data structure for an opened window.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
void SetFilterTerm(const char *str)
Set the term to filter on.
Functions to read fonts from files and cache them.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
SettingEntry * last_clicked
If non-NULL, pointer to the last clicked setting.
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=NULL, uint textref_stack_size=0, const uint32 *textref_stack=NULL)
Display an error message in a window.
Bottom offset of the text of the frame.
SaveLoad save
Internal structure (going to savegame, parts to config)
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
enable the 'Default' button ("\0" is returned)
bool ReadLanguagePack(const LanguageMetadata *lang)
Read a particular language.
Functions related to low-level strings.
bool type_hides
Whether the type hides filtered strings.
bool UpdateFilterState(SettingFilter &filter, bool force_visible)
Update the filter state.
VarType conv
type of the variable to be saved, int
Functions related to errors.
Used in setting filter to match all types.
uint Length() const
Get the number of items in the list.
display absolute value of the setting
Of a numeric setting entry, the left button is depressed.
bool manually_changed_folding
Whether the user expanded/collapsed something manually.
CompanySettings company
default values for per-company settings
static GameSettings * settings_ptr
Pointer to the game settings being displayed and modified.
StringID str_help
(Translated) string with help text; gui only.
int main(int argc, char *argv[])
Entry point.
SettingEntry(const char *name)
Constructor for a single setting in the 'advanced settings' window.
virtual uint Length() const
Return number of rows needed to display the (filtered) entry.
byte road_side
the side of the road vehicles drive on
void SetDisplayedHelpText(SettingEntry *pe)
Set the entry that should have its help text displayed, and mark the window dirty so it gets repainte...
SmallMap< int, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
void UpdateAllVirtCoords()
Update the viewport coordinates of all signs.
const char * name
Name of the setting.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Simple vector template class, with automatic delete.
virtual void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const
Function to draw setting value (button + text + current value)
Data stored about a string that can be modified in the GUI.
ClientSettings _settings_client
The current settings for this game.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
Definition of base types and functions in a cross-platform compatible way.
void LoadStringWidthTable(bool monospace)
Initialize _stringwidth_table cache.
static const int CF_NOEURO
Currency never switches to the Euro (as far as known).
A number of safeguards to prevent using unsafe methods.
static int SETTING_HEIGHT
Height of a single setting in the tree view in pixels.
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
byte level
Nesting level of this setting entry.
StringID GetHelpText() const
Get the help text of a single setting.
Display settings associated to the "basic" list.
virtual void OnQueryTextFinished(char *str)
The query window opened from this window has closed.
bool IsVisibleByRestrictionMode(RestrictionMode mode) const
Checks whether an entry shall be made visible based on the restriction mode.
Offset at bottom to draw below the text.
Custom currency; Window numbers:
const SettingDesc * GetSettingFromName(const char *name, uint *i)
Given a name of setting, return a setting description of it.
StringID title
Title of the sub-page.
StringID * BuildCurrencyDropdown()
Build a list of currency names StringIDs to use in a dropdown list.
Information about languages and their files.
SettingFilter filter
Filter for the list.
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
char * stredup(const char *s, const char *last)
Create a duplicate of the given string.
Window for displaying the textfile of a BaseSet.
virtual void OnDropdownSelect(int widget, int index)
A dropdown option associated to this window has been selected.
Display settings associated to the "advanced" list.
virtual BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find setting entry at row row_num.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
void Init(byte level=0)
Initialization of an entire setting page.
virtual void LoadTextfile(const char *textfile, Subdirectory dir)
Loads the textfile text from file and setup lines.
SettingType type
Filter based on type.
Containers for BaseSettingEntry.
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.
Entry is hidden by the string filter.
Basic functions/variables used all over the place.
void SetValueDParams(uint first_param, int32 value) const
Set the DParams for drawing the value of a setting.
uint index
Index of the setting in the settings table.
RestrictionMode
How the list of advanced settings is filtered.
SettingEntryFlags
Flags for SettingEntry.
Right offset of the text of the frame.
#define lengthof(x)
Return the length of an fixed size array.
bool RoadVehiclesAreBuilt()
Verify whether a road vehicle is available.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
void GfxClearSpriteCache()
Remove all encoded sprites from the sprite cache without discarding sprite location information...
TextfileType
Additional text files accompanying Tar archives.
static T min(const T a, const T b)
Returns the minimum of two values.
bool folded
Sub-page is folded (not visible except for its title)
static StringID * _grf_names
Pointer to town names defined by NewGRFs.
virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible)
Update the filter state.
Top offset of the text of the frame.
StringFilter string
Filter string.
Left offset of the text of the frame.
Types related to the drop down widget.
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right)
Draw [<][>] boxes.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
void DeleteWindowByClass(WindowClass cls)
Delete all windows of a given class.
virtual uint Length() const
Return number of rows needed to display the (filtered) entry.
Data structure describing one page of settings in the settings window.
#define SETTING_BUTTON_WIDTH
Width of setting buttons.
CharSetFilter
Valid filter types for IsValidChar.
This entry is the last one in a (sub-)page.
void SetCompanySetting(uint index, int32 value)
Top function to save the new value of an element of the Settings struct.
Offset at top to draw above the text.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
virtual void GetFoldingState(bool &all_folded, bool &all_unfolded) const
Recursively accumulate the folding state of the (filtered) tree.
bool IsVisible(const BaseSettingEntry *item) const
Check whether an entry is visible and not folded or filtered away.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
RestrictionMode min_cat
Minimum category needed to display all filtered strings (RM_BASIC, RM_ADVANCED, or RM_ALL)...
void FoldAll()
Recursively close all folds of sub-pages.
virtual void FoldAll()
Recursively close all (filtered) folds of sub-pages.
Dimension _resolutions[32]
List of resolutions.
uint8 settings_restriction_mode
selected restriction mode in adv. settings GUI.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
SettingEntry * valuedropdown_entry
If non-NULL, pointer to the value for which a dropdown window is currently opened.
void AddLine(const char *str)
Pass another text line from the current item to the filter.
const TBaseSet * baseset
View the textfile of this BaseSet.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Draw only every second pixel, used for greying-out.
No window, redirects to WC_MAIN_WINDOW.
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
bool IsEditable(bool do_command=false) const
Check whether the setting is editable in the current gamemode.
ZoomLevelByte zoom_min
minimum zoom out level
void InitGRFTownGeneratorNames()
Allocate memory for the NewGRF town names.
EntryVector entries
Settings on this page.
static void * GetVariableAddress(const void *object, const SaveLoad *sld)
Get the address of the variable.
StringID str_val
(Translated) first string describing the value.
ZoomLevel
All zoom levels we know.
Functions related to companies.
char *const buf
buffer in which text is saved
const char * GetCurrentLanguageIsoCode()
Get the ISO language code of the currently loaded language.
void ReInitAllWindows()
Re-initialize all windows.
Both numeric and alphabetic and spaces and stuff.
Category setting filtered matches away.
Declaration of functions and types defined in highscore.h and highscore_gui.h.
GUISettings gui
settings related to the GUI
Bit-mask for button flags.
void ShowBaseSetTextfileWindow(TextfileType file_type, const TBaseSet *baseset, StringID content_type)
Open the BaseSet version of the textfile window.
Window for displaying a textfile.
If set the frame is lowered and the background colour brighter (ie. buttons when pressed) ...
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
a value of zero means the feature is disabled
void UpdateCursorSize()
Update cursor dimension.
int GetStringLineCount(StringID str, int maxw)
Calculates number of lines of string.
static size_t GetNumItems()
Returns number of valid items in the pool.
TextDirection _current_text_dir
Text direction of the currently selected language.
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.
static GameSettings & GetGameSettings()
Get the settings-object applicable for the current situation: the newgame settings when we're in the ...
Searching and filtering using a stringterm.
TextfileType file_type
Type of textfile to view.
Top offset of image in the button.
bitmasked number where only ONE bit may be set
bool SetSettingValue(uint index, int32 value, bool force_newgame)
Top function to save the new value of an element of the Settings struct.
void ShowGameOptions()
Open the game options window.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
static T abs(const T a)
Returns the absolute value of (scalar) variable.
Functions for setting GUIs.
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.
Functions related to zooming.
Scrollbar * vscroll
Vertical scrollbar.
Functions and types used internally for the settings configurations.
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
virtual void SetStringParameters(int widget) const
Initialize string parameters for a widget.
virtual void OnResize()
Called after the window got resized.
virtual void SetStringParameters(int widget) const
Initialize string parameters for a widget.
bool SetFocusedWidget(int widget_index)
Set focus within this window to the given widget.
Functions related to the drop down widget.
SwitchMode _switch_mode
The next mainloop command.
void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
Draw a dropdown button.
SettingType GetType() const
Return the type of the setting.
SettingDescType cmd
various flags for the variable
LocaleSettings locale
settings related to used currency/unit system in the current game
virtual void Init(byte level=0)
Initialization of a setting entry.
static SettingsContainer & GetSettingsTree()
Construct settings tree.
void ShowGameSettings()
Open advanced settings window.
byte town_name
the town name generator used for town names
GRFTextWrapper * name
NOSAVE: GRF name (Action 0x08)
virtual BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find setting entry at row row_num.
static int _nb_grf_names
Number of town names defined by NewGRFs.
Functions related to commands.
bool _network_server
network-server is active
Coordinates of a point in 2D.
byte flags
Flags of the setting entry.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
List item containing a C char string.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-NULL) Titem.
virtual void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const
Function to draw setting value (button + text + current value)
virtual void OnEditboxChanged(int wid)
The text in an editbox has been edited.
SettingEntry * clicked_entry
If non-NULL, pointer to a clicked numeric setting (with a depressed left or right button)...
StringID str
(translated) string with descriptive text; gui and console
virtual void SetStringParameters(int widget) const
Initialize string parameters for a widget.
StringID content_type
STR_CONTENT_TYPE_xxx for title.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
ZoomLevelByte _font_zoom
Font Zoom level.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
uint64 GetMaskOfAllowedCurrencies()
get a mask of the allowed currencies depending on the year
Offset at right to draw the frame rectangular area.
int width
width of the window (number of pixels to the right in x direction)
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Base functions for all AIs.
static void ShowCustCurrency()
Open custom currency window.
#define DECLARE_POSTFIX_INCREMENT(enum_type)
Some enums need to have allowed incrementing (i.e.
GameCreationSettings game_creation
settings used during the creation of a game (map)
QueryString filter_editbox
Filter editbox;.
void DrawBoolButton(int x, int y, bool state, bool clickable)
Draw a toggle button.
Specification of a rectangle with absolute coordinates of all edges.
int _nb_orig_names
Number of original town names.
Both category and type settings filtered matches away.
Text is written right-to-left by default.
SettingEntry * valuewindow_entry
If non-NULL, pointer to setting for which a value-entering window has been opened.
Window functions not directly related to making/drawing windows.
SettingType
Type of settings for filtering.
const char * GetTextfile(TextfileType type, Subdirectory dir, const char *filename)
Search a textfile file next to the given content.
virtual void OnDropdownClose(Point pt, int widget, int index, bool instant_close)
A dropdown window associated to this window has been closed.
Nothing was filtering matches away.
virtual void OnDropdownSelect(int widget, int index)
A dropdown option associated to this window has been selected.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
void SetStringParameters(int widget) const
Initialize string parameters for a widget.
#define SETTING_BUTTON_HEIGHT
Height of setting buttons.
uint8 timeout_timer
Timer value of the WF_TIMEOUT for flags.
Errors (eg. saving/loading failed)
void GetFoldingState(bool &all_folded, bool &all_unfolded) const
Recursively accumulate the folding state of the tree.
static void QSortT(T *base, uint num, int(CDECL *comparator)(const T *, const T *), bool desc=false)
Type safe qsort()
BaseSettingEntry * FindEntry(uint row, uint *cur_row)
Find the setting entry at row number row_num.
Left offset of the image in the button.
int32 interval
the interval to use between settings in the 'settings' window. If interval is '0' the interval is dyn...
Base list item class from which others are derived.
byte autosave
how often should we do autosaves?
SettingDescBase desc
Settings structure (going to configuration file)
Dimensions (a width and height) of a rectangle in 2D.
Query string window; Window numbers:
bool IsEmpty() const
Check whether any filter words were entered.
Offset at left to draw the frame rectangular area.
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...
Factory to 'query' all available blitters.
Game options window; Window numbers:
void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int button, Rect wi_rect, Colours wi_colour, bool auto_width, bool instant_close)
Show a drop down list.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
virtual void OnPaint()
The window must be repainted.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
virtual bool IsVisible(const BaseSettingEntry *item) const
Check whether an entry is visible and not folded or filtered away.
int height
Height of the window (number of pixels down in y direction)
virtual bool UpdateFilterState(SettingFilter &filter, bool force_visible)
Update the filter state.
void EnableWidget(byte widget_index)
Sets a widget to Enabled.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
GUI functions related to textfiles.
AutoDeleteSmallVector< const DropDownListItem *, 4 > DropDownList
A drop down list is a collection of drop down list items.
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.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
List all settings regardless of the default/newgame/... values.
virtual void OnTimeout()
Called when this window's timeout has been reached.
byte currency
currency we currently use
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
static int CDECL NatSortFunc(const DropDownListItem *const *first, const DropDownListItem *const *second)
Natural sorting comparator function for DropDownList::sort().