Codechange: Use begin/end of nwidget parts of begin/length.

This simplifies processing nwidget parts as, unlike the remaining length, the pointer to the end of the list never changes. This is the same principle as we use(d) for tracking end instead of length for C-style strings.

And this removes 160~ instances of the lengthof() macro.
This commit is contained in:
Peter Nelson 2023-09-03 21:54:13 +01:00 committed by PeterN
parent e4613fc04c
commit e8015e497d
65 changed files with 231 additions and 232 deletions

View File

@ -22,7 +22,7 @@ def scan_source_files(path, ini_keys=None):
with open(new_path) as fp:
output = fp.read()
for (name, ini_key, widgets) in re.findall(r"^static WindowDesc ([a-zA-Z0-9_]*).*?, (?:\"(.*?)\")?.*?,(?:\s+(.*?),){6}", output, re.S|re.M):
for (name, ini_key, widgets) in re.findall(r"^static WindowDesc ([a-zA-Z0-9_]*).*?, (?:\"(.*?)\")?.*?,(?:\s+.*?,){6}\s+[^\s]+\((.*?)\)", output, re.S|re.M):
if ini_key:
if ini_key in ini_keys:
errors.append(f"{new_path}: {name} ini_key is a duplicate")

View File

@ -77,7 +77,7 @@ static WindowDesc _ai_config_desc(
WDP_CENTER, "settings_script_config", 0, 0,
WC_GAME_OPTIONS, WC_NONE,
0,
_nested_ai_config_widgets, lengthof(_nested_ai_config_widgets)
std::begin(_nested_ai_config_widgets), std::end(_nested_ai_config_widgets)
);
/**

View File

@ -213,7 +213,7 @@ static WindowDesc _air_toolbar_desc(
WDP_ALIGN_TOOLBAR, "toolbar_air", 0, 0,
WC_BUILD_TOOLBAR, WC_NONE,
WDF_CONSTRUCTION,
_nested_air_toolbar_widgets, lengthof(_nested_air_toolbar_widgets),
std::begin(_nested_air_toolbar_widgets), std::end(_nested_air_toolbar_widgets),
&BuildAirToolbarWindow::hotkeys
);
@ -622,7 +622,7 @@ static WindowDesc _build_airport_desc(
WDP_AUTO, nullptr, 0, 0,
WC_BUILD_STATION, WC_BUILD_TOOLBAR,
WDF_CONSTRUCTION,
_nested_build_airport_widgets, lengthof(_nested_build_airport_widgets)
std::begin(_nested_build_airport_widgets), std::end(_nested_build_airport_widgets)
);
static void ShowBuildAirportPicker(Window *parent)

View File

@ -808,7 +808,7 @@ static WindowDesc _replace_rail_vehicle_desc(
WDP_AUTO, "replace_vehicle_train", 500, 140,
WC_REPLACE_VEHICLE, WC_NONE,
WDF_CONSTRUCTION,
_nested_replace_rail_vehicle_widgets, lengthof(_nested_replace_rail_vehicle_widgets)
std::begin(_nested_replace_rail_vehicle_widgets), std::end(_nested_replace_rail_vehicle_widgets)
);
static const NWidgetPart _nested_replace_road_vehicle_widgets[] = {
@ -866,7 +866,7 @@ static WindowDesc _replace_road_vehicle_desc(
WDP_AUTO, "replace_vehicle_road", 500, 140,
WC_REPLACE_VEHICLE, WC_NONE,
WDF_CONSTRUCTION,
_nested_replace_road_vehicle_widgets, lengthof(_nested_replace_road_vehicle_widgets)
std::begin(_nested_replace_road_vehicle_widgets), std::end(_nested_replace_road_vehicle_widgets)
);
static const NWidgetPart _nested_replace_vehicle_widgets[] = {
@ -920,7 +920,7 @@ static WindowDesc _replace_vehicle_desc(
WDP_AUTO, "replace_vehicle", 456, 118,
WC_REPLACE_VEHICLE, WC_NONE,
WDF_CONSTRUCTION,
_nested_replace_vehicle_widgets, lengthof(_nested_replace_vehicle_widgets)
std::begin(_nested_replace_vehicle_widgets), std::end(_nested_replace_vehicle_widgets)
);
/**

View File

@ -43,7 +43,7 @@ static WindowDesc _background_desc(
WDP_MANUAL, nullptr, 0, 0,
WC_BOOTSTRAP, WC_NONE,
WDF_NO_CLOSE,
_background_widgets, lengthof(_background_widgets)
std::begin(_background_widgets), std::end(_background_widgets)
);
/** The background for the game. */
@ -81,7 +81,7 @@ static WindowDesc _bootstrap_errmsg_desc(
WDP_CENTER, nullptr, 0, 0,
WC_BOOTSTRAP, WC_NONE,
WDF_MODAL | WDF_NO_CLOSE,
_nested_bootstrap_errmsg_widgets, lengthof(_nested_bootstrap_errmsg_widgets)
std::begin(_nested_bootstrap_errmsg_widgets), std::end(_nested_bootstrap_errmsg_widgets)
);
/** The window for a failed bootstrap. */
@ -138,7 +138,7 @@ static WindowDesc _bootstrap_download_status_window_desc(
WDP_CENTER, nullptr, 0, 0,
WC_NETWORK_STATUS_WINDOW, WC_NONE,
WDF_MODAL | WDF_NO_CLOSE,
_nested_bootstrap_download_status_window_widgets, lengthof(_nested_bootstrap_download_status_window_widgets)
std::begin(_nested_bootstrap_download_status_window_widgets), std::end(_nested_bootstrap_download_status_window_widgets)
);
@ -192,7 +192,7 @@ static WindowDesc _bootstrap_query_desc(
WDP_CENTER, nullptr, 0, 0,
WC_CONFIRM_POPUP_QUERY, WC_NONE,
WDF_NO_CLOSE,
_bootstrap_query_widgets, lengthof(_bootstrap_query_widgets)
std::begin(_bootstrap_query_widgets), std::end(_bootstrap_query_widgets)
);
/** The window for the query. It can't use the generic query window as that uses sprites that don't exist yet. */

View File

@ -346,7 +346,7 @@ static WindowDesc _build_bridge_desc(
WDP_AUTO, "build_bridge", 200, 114,
WC_BUILD_BRIDGE, WC_BUILD_TOOLBAR,
WDF_CONSTRUCTION,
_nested_build_bridge_widgets, lengthof(_nested_build_bridge_widgets)
std::begin(_nested_build_bridge_widgets), std::end(_nested_build_bridge_widgets)
);
/**

View File

@ -1885,7 +1885,7 @@ static WindowDesc _build_vehicle_desc(
WDP_AUTO, "build_vehicle", 240, 268,
WC_BUILD_VEHICLE, WC_NONE,
WDF_CONSTRUCTION,
_nested_build_vehicle_widgets, lengthof(_nested_build_vehicle_widgets),
std::begin(_nested_build_vehicle_widgets), std::end(_nested_build_vehicle_widgets),
&BuildVehicleWindow::hotkeys
);

View File

@ -432,7 +432,7 @@ static WindowDesc _cheats_desc(
WDP_AUTO, "cheats", 0, 0,
WC_CHEATS, WC_NONE,
0,
_nested_cheat_widgets, lengthof(_nested_cheat_widgets)
std::begin(_nested_cheat_widgets), std::end(_nested_cheat_widgets)
);
/** Open cheat window. */

View File

@ -542,7 +542,7 @@ static WindowDesc _company_finances_desc(
WDP_AUTO, "company_finances", 0, 0,
WC_FINANCES, WC_NONE,
0,
_nested_company_finances_widgets, lengthof(_nested_company_finances_widgets)
std::begin(_nested_company_finances_widgets), std::end(_nested_company_finances_widgets)
);
/**
@ -1160,7 +1160,7 @@ static WindowDesc _select_company_livery_desc(
WDP_AUTO, nullptr, 0, 0,
WC_COMPANY_COLOUR, WC_NONE,
0,
_nested_select_company_livery_widgets, lengthof(_nested_select_company_livery_widgets)
std::begin(_nested_select_company_livery_widgets), std::end(_nested_select_company_livery_widgets)
);
void ShowCompanyLiveryWindow(CompanyID company, GroupID group)
@ -1777,7 +1777,7 @@ static WindowDesc _select_company_manager_face_desc(
WDP_AUTO, nullptr, 0, 0,
WC_COMPANY_MANAGER_FACE, WC_NONE,
WDF_CONSTRUCTION,
_nested_select_company_manager_face_widgets, lengthof(_nested_select_company_manager_face_widgets)
std::begin(_nested_select_company_manager_face_widgets), std::end(_nested_select_company_manager_face_widgets)
);
/**
@ -2149,7 +2149,7 @@ static WindowDesc _company_infrastructure_desc(
WDP_AUTO, "company_infrastructure", 0, 0,
WC_COMPANY_INFRASTRUCTURE, WC_NONE,
0,
_nested_company_infrastructure_widgets, lengthof(_nested_company_infrastructure_widgets)
std::begin(_nested_company_infrastructure_widgets), std::end(_nested_company_infrastructure_widgets)
);
/**
@ -2686,7 +2686,7 @@ static WindowDesc _company_desc(
WDP_AUTO, "company", 0, 0,
WC_COMPANY, WC_NONE,
0,
_nested_company_widgets, lengthof(_nested_company_widgets)
std::begin(_nested_company_widgets), std::end(_nested_company_widgets)
);
/**
@ -2820,7 +2820,7 @@ static WindowDesc _buy_company_desc(
WDP_AUTO, nullptr, 0, 0,
WC_BUY_COMPANY, WC_NONE,
WDF_CONSTRUCTION,
_nested_buy_company_widgets, lengthof(_nested_buy_company_widgets)
std::begin(_nested_buy_company_widgets), std::end(_nested_buy_company_widgets)
);
/**

View File

@ -106,7 +106,7 @@ static WindowDesc _console_window_desc(
WDP_MANUAL, nullptr, 0, 0,
WC_CONSOLE, WC_NONE,
0,
_nested_console_window_widgets, lengthof(_nested_console_window_widgets)
std::begin(_nested_console_window_widgets), std::end(_nested_console_window_widgets)
);
struct IConsoleWindow : Window

View File

@ -200,7 +200,7 @@ static WindowDesc _set_date_desc(
WDP_CENTER, nullptr, 0, 0,
WC_SET_DATE, WC_NONE,
0,
_nested_set_date_widgets, lengthof(_nested_set_date_widgets)
std::begin(_nested_set_date_widgets), std::end(_nested_set_date_widgets)
);
/**

View File

@ -89,28 +89,28 @@ static WindowDesc _train_depot_desc(
WDP_AUTO, "depot_train", 362, 123,
WC_VEHICLE_DEPOT, WC_NONE,
0,
_nested_train_depot_widgets, lengthof(_nested_train_depot_widgets)
std::begin(_nested_train_depot_widgets), std::end(_nested_train_depot_widgets)
);
static WindowDesc _road_depot_desc(
WDP_AUTO, "depot_roadveh", 316, 97,
WC_VEHICLE_DEPOT, WC_NONE,
0,
_nested_train_depot_widgets, lengthof(_nested_train_depot_widgets)
std::begin(_nested_train_depot_widgets), std::end(_nested_train_depot_widgets)
);
static WindowDesc _ship_depot_desc(
WDP_AUTO, "depot_ship", 306, 99,
WC_VEHICLE_DEPOT, WC_NONE,
0,
_nested_train_depot_widgets, lengthof(_nested_train_depot_widgets)
std::begin(_nested_train_depot_widgets), std::end(_nested_train_depot_widgets)
);
static WindowDesc _aircraft_depot_desc(
WDP_AUTO, "depot_aircraft", 332, 99,
WC_VEHICLE_DEPOT, WC_NONE,
0,
_nested_train_depot_widgets, lengthof(_nested_train_depot_widgets)
std::begin(_nested_train_depot_widgets), std::end(_nested_train_depot_widgets)
);
extern void DepotSortList(VehicleList *list);

View File

@ -349,7 +349,7 @@ static WindowDesc _build_docks_toolbar_desc(
WDP_ALIGN_TOOLBAR, "toolbar_water", 0, 0,
WC_BUILD_TOOLBAR, WC_NONE,
WDF_CONSTRUCTION,
_nested_build_docks_toolbar_widgets, lengthof(_nested_build_docks_toolbar_widgets),
std::begin(_nested_build_docks_toolbar_widgets), std::end(_nested_build_docks_toolbar_widgets),
&BuildDocksToolbarWindow::hotkeys
);
@ -393,7 +393,7 @@ static WindowDesc _build_docks_scen_toolbar_desc(
WDP_AUTO, "toolbar_water_scen", 0, 0,
WC_SCEN_BUILD_TOOLBAR, WC_NONE,
WDF_CONSTRUCTION,
_nested_build_docks_scen_toolbar_widgets, lengthof(_nested_build_docks_scen_toolbar_widgets)
std::begin(_nested_build_docks_scen_toolbar_widgets), std::end(_nested_build_docks_scen_toolbar_widgets)
);
/**
@ -499,7 +499,7 @@ static WindowDesc _build_dock_station_desc(
WDP_AUTO, nullptr, 0, 0,
WC_BUILD_STATION, WC_BUILD_TOOLBAR,
WDF_CONSTRUCTION,
_nested_build_dock_station_widgets, lengthof(_nested_build_dock_station_widgets)
std::begin(_nested_build_dock_station_widgets), std::end(_nested_build_dock_station_widgets)
);
static void ShowBuildDockStationPicker(Window *parent)
@ -597,7 +597,7 @@ static WindowDesc _build_docks_depot_desc(
WDP_AUTO, nullptr, 0, 0,
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
WDF_CONSTRUCTION,
_nested_build_docks_depot_widgets, lengthof(_nested_build_docks_depot_widgets)
std::begin(_nested_build_docks_depot_widgets), std::end(_nested_build_docks_depot_widgets)
);

View File

@ -147,7 +147,7 @@ static WindowDesc _engine_preview_desc(
WDP_CENTER, nullptr, 0, 0,
WC_ENGINE_PREVIEW, WC_NONE,
WDF_CONSTRUCTION,
_nested_engine_preview_widgets, lengthof(_nested_engine_preview_widgets)
std::begin(_nested_engine_preview_widgets), std::end(_nested_engine_preview_widgets)
);

View File

@ -46,7 +46,7 @@ static WindowDesc _errmsg_desc(
WDP_MANUAL, nullptr, 0, 0,
WC_ERRMSG, WC_NONE,
0,
_nested_errmsg_widgets, lengthof(_nested_errmsg_widgets)
std::begin(_nested_errmsg_widgets), std::end(_nested_errmsg_widgets)
);
static const NWidgetPart _nested_errmsg_face_widgets[] = {
@ -66,7 +66,7 @@ static WindowDesc _errmsg_face_desc(
WDP_MANUAL, nullptr, 0, 0,
WC_ERRMSG, WC_NONE,
0,
_nested_errmsg_face_widgets, lengthof(_nested_errmsg_face_widgets)
std::begin(_nested_errmsg_face_widgets), std::end(_nested_errmsg_face_widgets)
);
/**

View File

@ -887,7 +887,7 @@ static WindowDesc _load_dialog_desc(
WDP_CENTER, "load_game", 500, 294,
WC_SAVELOAD, WC_NONE,
0,
_nested_load_dialog_widgets, lengthof(_nested_load_dialog_widgets)
std::begin(_nested_load_dialog_widgets), std::end(_nested_load_dialog_widgets)
);
/** Load heightmap */
@ -895,7 +895,7 @@ static WindowDesc _load_heightmap_dialog_desc(
WDP_CENTER, "load_heightmap", 257, 320,
WC_SAVELOAD, WC_NONE,
0,
_nested_load_heightmap_dialog_widgets, lengthof(_nested_load_heightmap_dialog_widgets)
std::begin(_nested_load_heightmap_dialog_widgets), std::end(_nested_load_heightmap_dialog_widgets)
);
/** Save game/scenario */
@ -903,7 +903,7 @@ static WindowDesc _save_dialog_desc(
WDP_CENTER, "save_game", 500, 294,
WC_SAVELOAD, WC_NONE,
0,
_nested_save_dialog_widgets, lengthof(_nested_save_dialog_widgets)
std::begin(_nested_save_dialog_widgets), std::end(_nested_save_dialog_widgets)
);
/**

View File

@ -730,7 +730,7 @@ static WindowDesc _framerate_display_desc(
WDP_AUTO, "framerate_display", 0, 0,
WC_FRAMERATE_DISPLAY, WC_NONE,
0,
_framerate_window_widgets, lengthof(_framerate_window_widgets)
std::begin(_framerate_window_widgets), std::end(_framerate_window_widgets)
);
@ -1015,7 +1015,7 @@ static WindowDesc _frametime_graph_window_desc(
WDP_AUTO, "frametime_graph", 140, 90,
WC_FRAMETIME_GRAPH, WC_NONE,
0,
_frametime_graph_window_widgets, lengthof(_frametime_graph_window_widgets)
std::begin(_frametime_graph_window_widgets), std::end(_frametime_graph_window_widgets)
);

View File

@ -72,7 +72,7 @@ static WindowDesc _gs_config_desc(
WDP_CENTER, "settings_gs_config", 500, 350,
WC_GAME_OPTIONS, WC_NONE,
0,
_nested_gs_config_widgets, lengthof(_nested_gs_config_widgets)
std::begin(_nested_gs_config_widgets), std::end(_nested_gs_config_widgets)
);
/**

View File

@ -1025,14 +1025,14 @@ static WindowDesc _generate_landscape_desc(
WDP_CENTER, nullptr, 0, 0,
WC_GENERATE_LANDSCAPE, WC_NONE,
0,
_nested_generate_landscape_widgets, lengthof(_nested_generate_landscape_widgets)
std::begin(_nested_generate_landscape_widgets), std::end(_nested_generate_landscape_widgets)
);
static WindowDesc _heightmap_load_desc(
WDP_CENTER, nullptr, 0, 0,
WC_GENERATE_LANDSCAPE, WC_NONE,
0,
_nested_heightmap_load_widgets, lengthof(_nested_heightmap_load_widgets)
std::begin(_nested_heightmap_load_widgets), std::end(_nested_heightmap_load_widgets)
);
static void _ShowGenerateLandscape(GenerateLandscapeWindowMode mode)
@ -1328,7 +1328,7 @@ static WindowDesc _create_scenario_desc(
WDP_CENTER, nullptr, 0, 0,
WC_GENERATE_LANDSCAPE, WC_NONE,
0,
_nested_create_scenario_widgets, lengthof(_nested_create_scenario_widgets)
std::begin(_nested_create_scenario_widgets), std::end(_nested_create_scenario_widgets)
);
/** Show the window to create a scenario. */
@ -1354,7 +1354,7 @@ static WindowDesc _generate_progress_desc(
WDP_CENTER, nullptr, 0, 0,
WC_MODAL_PROGRESS, WC_NONE,
0,
_nested_generate_progress_widgets, lengthof(_nested_generate_progress_widgets)
std::begin(_nested_generate_progress_widgets), std::end(_nested_generate_progress_widgets)
);
struct GenWorldStatus {

View File

@ -306,7 +306,7 @@ static WindowDesc _goals_list_desc(
WDP_AUTO, "list_goals", 500, 127,
WC_GOALS_LIST, WC_NONE,
0,
_nested_goals_list_widgets, lengthof(_nested_goals_list_widgets)
std::begin(_nested_goals_list_widgets), std::end(_nested_goals_list_widgets)
);
/**
@ -521,25 +521,25 @@ static WindowDesc _goal_question_list_desc[] = {
WDP_CENTER, nullptr, 0, 0,
WC_GOAL_QUESTION, WC_NONE,
WDF_CONSTRUCTION,
_nested_goal_question_widgets_question, lengthof(_nested_goal_question_widgets_question),
std::begin(_nested_goal_question_widgets_question), std::end(_nested_goal_question_widgets_question),
},
{
WDP_CENTER, nullptr, 0, 0,
WC_GOAL_QUESTION, WC_NONE,
WDF_CONSTRUCTION,
_nested_goal_question_widgets_info, lengthof(_nested_goal_question_widgets_info),
std::begin(_nested_goal_question_widgets_info), std::end(_nested_goal_question_widgets_info),
},
{
WDP_CENTER, nullptr, 0, 0,
WC_GOAL_QUESTION, WC_NONE,
WDF_CONSTRUCTION,
_nested_goal_question_widgets_warning, lengthof(_nested_goal_question_widgets_warning),
std::begin(_nested_goal_question_widgets_warning), std::end(_nested_goal_question_widgets_warning),
},
{
WDP_CENTER, nullptr, 0, 0,
WC_GOAL_QUESTION, WC_NONE,
WDF_CONSTRUCTION,
_nested_goal_question_widgets_error, lengthof(_nested_goal_question_widgets_error),
std::begin(_nested_goal_question_widgets_error), std::end(_nested_goal_question_widgets_error),
},
};

View File

@ -145,7 +145,7 @@ static WindowDesc _graph_legend_desc(
WDP_AUTO, "graph_legend", 0, 0,
WC_GRAPH_LEGEND, WC_NONE,
0,
_nested_graph_legend_widgets, lengthof(_nested_graph_legend_widgets)
std::begin(_nested_graph_legend_widgets), std::end(_nested_graph_legend_widgets)
);
static void ShowGraphLegend()
@ -658,7 +658,7 @@ static WindowDesc _operating_profit_desc(
WDP_AUTO, "graph_operating_profit", 0, 0,
WC_OPERATING_PROFIT, WC_NONE,
0,
_nested_operating_profit_widgets, lengthof(_nested_operating_profit_widgets)
std::begin(_nested_operating_profit_widgets), std::end(_nested_operating_profit_widgets)
);
@ -709,7 +709,7 @@ static WindowDesc _income_graph_desc(
WDP_AUTO, "graph_income", 0, 0,
WC_INCOME_GRAPH, WC_NONE,
0,
_nested_income_graph_widgets, lengthof(_nested_income_graph_widgets)
std::begin(_nested_income_graph_widgets), std::end(_nested_income_graph_widgets)
);
void ShowIncomeGraph()
@ -758,7 +758,7 @@ static WindowDesc _delivered_cargo_graph_desc(
WDP_AUTO, "graph_delivered_cargo", 0, 0,
WC_DELIVERED_CARGO, WC_NONE,
0,
_nested_delivered_cargo_graph_widgets, lengthof(_nested_delivered_cargo_graph_widgets)
std::begin(_nested_delivered_cargo_graph_widgets), std::end(_nested_delivered_cargo_graph_widgets)
);
void ShowDeliveredCargoGraph()
@ -814,7 +814,7 @@ static WindowDesc _performance_history_desc(
WDP_AUTO, "graph_performance", 0, 0,
WC_PERFORMANCE_HISTORY, WC_NONE,
0,
_nested_performance_history_widgets, lengthof(_nested_performance_history_widgets)
std::begin(_nested_performance_history_widgets), std::end(_nested_performance_history_widgets)
);
void ShowPerformanceHistoryGraph()
@ -863,7 +863,7 @@ static WindowDesc _company_value_graph_desc(
WDP_AUTO, "graph_company_value", 0, 0,
WC_COMPANY_VALUE, WC_NONE,
0,
_nested_company_value_graph_widgets, lengthof(_nested_company_value_graph_widgets)
std::begin(_nested_company_value_graph_widgets), std::end(_nested_company_value_graph_widgets)
);
void ShowCompanyValueGraph()
@ -1097,7 +1097,7 @@ static WindowDesc _cargo_payment_rates_desc(
WDP_AUTO, "graph_cargo_payment_rates", 0, 0,
WC_PAYMENT_RATES, WC_NONE,
0,
_nested_cargo_payment_rates_widgets, lengthof(_nested_cargo_payment_rates_widgets)
std::begin(_nested_cargo_payment_rates_widgets), std::end(_nested_cargo_payment_rates_widgets)
);
@ -1393,7 +1393,7 @@ static WindowDesc _performance_rating_detail_desc(
WDP_AUTO, "league_details", 0, 0,
WC_PERFORMANCE_DETAIL, WC_NONE,
0,
_nested_performance_rating_detail_widgets, lengthof(_nested_performance_rating_detail_widgets)
std::begin(_nested_performance_rating_detail_widgets), std::end(_nested_performance_rating_detail_widgets)
);
void ShowPerformanceRatingDetail()

View File

@ -1108,14 +1108,14 @@ static WindowDesc _other_group_desc(
WDP_AUTO, "list_groups", 460, 246,
WC_INVALID, WC_NONE,
0,
_nested_group_widgets, lengthof(_nested_group_widgets)
std::begin(_nested_group_widgets), std::end(_nested_group_widgets)
);
static WindowDesc _train_group_desc(
WDP_AUTO, "list_groups_train", 525, 246,
WC_TRAINS_LIST, WC_NONE,
0,
_nested_group_widgets, lengthof(_nested_group_widgets)
std::begin(_nested_group_widgets), std::end(_nested_group_widgets)
);
/**

View File

@ -218,14 +218,14 @@ static WindowDesc _highscore_desc(
WDP_MANUAL, nullptr, 0, 0,
WC_HIGHSCORE, WC_NONE,
0,
_nested_highscore_widgets, lengthof(_nested_highscore_widgets)
std::begin(_nested_highscore_widgets), std::end(_nested_highscore_widgets)
);
static WindowDesc _endgame_desc(
WDP_MANUAL, nullptr, 0, 0,
WC_ENDSCREEN, WC_NONE,
0,
_nested_highscore_widgets, lengthof(_nested_highscore_widgets)
std::begin(_nested_highscore_widgets), std::end(_nested_highscore_widgets)
);
/**

View File

@ -296,7 +296,7 @@ static WindowDesc _build_industry_desc(
WDP_AUTO, "build_industry", 170, 212,
WC_BUILD_INDUSTRY, WC_NONE,
WDF_CONSTRUCTION,
_nested_build_industry_widgets, lengthof(_nested_build_industry_widgets)
std::begin(_nested_build_industry_widgets), std::end(_nested_build_industry_widgets)
);
/** Build (fund or prospect) a new industry, */
@ -1206,7 +1206,7 @@ static WindowDesc _industry_view_desc(
WDP_AUTO, "view_industry", 260, 120,
WC_INDUSTRY_VIEW, WC_NONE,
0,
_nested_industry_view_widgets, lengthof(_nested_industry_view_widgets)
std::begin(_nested_industry_view_widgets), std::end(_nested_industry_view_widgets)
);
void ShowIndustryViewWindow(int industry)
@ -1867,7 +1867,7 @@ static WindowDesc _industry_directory_desc(
WDP_AUTO, "list_industries", 428, 190,
WC_INDUSTRY_DIRECTORY, WC_NONE,
0,
_nested_industry_directory_widgets, lengthof(_nested_industry_directory_widgets)
std::begin(_nested_industry_directory_widgets), std::end(_nested_industry_directory_widgets)
);
void ShowIndustryDirectory()
@ -1905,7 +1905,7 @@ static WindowDesc _industry_cargoes_desc(
WDP_AUTO, "industry_cargoes", 300, 210,
WC_INDUSTRY_CARGOES, WC_NONE,
0,
_nested_industry_cargoes_widgets, lengthof(_nested_industry_cargoes_widgets)
std::begin(_nested_industry_cargoes_widgets), std::end(_nested_industry_cargoes_widgets)
);
/** Available types of field. */

View File

@ -495,7 +495,7 @@ static WindowDesc _select_game_desc(
WDP_CENTER, nullptr, 0, 0,
WC_SELECT_GAME, WC_NONE,
WDF_NO_CLOSE,
_nested_select_game_widgets, lengthof(_nested_select_game_widgets)
std::begin(_nested_select_game_widgets), std::end(_nested_select_game_widgets)
);
void ShowSelectGameWindow()

View File

@ -200,7 +200,7 @@ static WindowDesc _performance_league_desc(
WDP_AUTO, "performance_league", 0, 0,
WC_COMPANY_LEAGUE, WC_NONE,
0,
_nested_performance_league_widgets, lengthof(_nested_performance_league_widgets)
std::begin(_nested_performance_league_widgets), std::end(_nested_performance_league_widgets)
);
void ShowPerformanceLeagueTable()
@ -432,7 +432,7 @@ static WindowDesc _script_league_desc(
WDP_AUTO, "script_league", 0, 0,
WC_COMPANY_LEAGUE, WC_NONE,
0,
_nested_script_league_widgets, lengthof(_nested_script_league_widgets)
std::begin(_nested_script_league_widgets), std::end(_nested_script_league_widgets)
);
void ShowScriptLeagueTable(LeagueTableID table)

View File

@ -541,7 +541,7 @@ static WindowDesc _linkgraph_legend_desc(
WDP_AUTO, "toolbar_linkgraph", 0, 0,
WC_LINKGRAPH_LEGEND, WC_NONE,
0,
_nested_linkgraph_legend_widgets, lengthof(_nested_linkgraph_legend_widgets)
std::begin(_nested_linkgraph_legend_widgets), std::end(_nested_linkgraph_legend_widgets)
);
/**

View File

@ -511,7 +511,7 @@ static WindowDesc _main_window_desc(
WDP_MANUAL, nullptr, 0, 0,
WC_MAIN_WINDOW, WC_NONE,
WDF_NO_CLOSE,
_nested_main_window_widgets, lengthof(_nested_main_window_widgets),
std::begin(_nested_main_window_widgets), std::end(_nested_main_window_widgets),
&MainWindow::hotkeys
);

View File

@ -62,7 +62,7 @@ static WindowDesc _land_info_desc(
WDP_AUTO, nullptr, 0, 0,
WC_LAND_INFO, WC_NONE,
0,
_nested_land_info_widgets, lengthof(_nested_land_info_widgets)
std::begin(_nested_land_info_widgets), std::end(_nested_land_info_widgets)
);
class LandInfoWindow : public Window {
@ -396,7 +396,7 @@ static WindowDesc _about_desc(
WDP_CENTER, nullptr, 0, 0,
WC_GAME_OPTIONS, WC_NONE,
0,
_nested_about_widgets, lengthof(_nested_about_widgets)
std::begin(_nested_about_widgets), std::end(_nested_about_widgets)
);
static const char * const _credits[] = {
@ -654,7 +654,7 @@ static WindowDesc _tool_tips_desc(
WDP_MANUAL, nullptr, 0, 0, // Coordinates and sizes are not used,
WC_TOOLTIPS, WC_NONE,
WDF_NO_FOCUS | WDF_NO_CLOSE,
_nested_tooltips_widgets, lengthof(_nested_tooltips_widgets)
std::begin(_nested_tooltips_widgets), std::end(_nested_tooltips_widgets)
);
/** Window for displaying a tooltip. */
@ -1067,7 +1067,7 @@ static WindowDesc _query_string_desc(
WDP_CENTER, nullptr, 0, 0,
WC_QUERY_STRING, WC_NONE,
0,
_nested_query_string_widgets, lengthof(_nested_query_string_widgets)
std::begin(_nested_query_string_widgets), std::end(_nested_query_string_widgets)
);
/**
@ -1214,7 +1214,7 @@ static WindowDesc _query_desc(
WDP_CENTER, nullptr, 0, 0,
WC_CONFIRM_POPUP_QUERY, WC_NONE,
WDF_MODAL,
_nested_query_widgets, lengthof(_nested_query_widgets)
std::begin(_nested_query_widgets), std::end(_nested_query_widgets)
);
/**

View File

@ -645,7 +645,7 @@ static WindowDesc _music_track_selection_desc(
WDP_AUTO, nullptr, 0, 0,
WC_MUSIC_TRACK_SELECTION, WC_NONE,
0,
_nested_music_track_selection_widgets, lengthof(_nested_music_track_selection_widgets)
std::begin(_nested_music_track_selection_widgets), std::end(_nested_music_track_selection_widgets)
);
static void ShowMusicTrackSelection()
@ -905,7 +905,7 @@ static WindowDesc _music_window_desc(
WDP_AUTO, "music", 0, 0,
WC_MUSIC_WINDOW, WC_NONE,
0,
_nested_music_window_widgets, lengthof(_nested_music_window_widgets)
std::begin(_nested_music_window_widgets), std::end(_nested_music_window_widgets)
);
void ShowMusicWindow()

View File

@ -510,7 +510,7 @@ static WindowDesc _chat_window_desc(
WDP_MANUAL, nullptr, 0, 0,
WC_SEND_NETWORK_MSG, WC_NONE,
0,
_nested_chat_window_widgets, lengthof(_nested_chat_window_widgets)
std::begin(_nested_chat_window_widgets), std::end(_nested_chat_window_widgets)
);

View File

@ -96,7 +96,7 @@ static WindowDesc _network_content_download_status_window_desc(
WDP_CENTER, nullptr, 0, 0,
WC_NETWORK_STATUS_WINDOW, WC_NONE,
WDF_MODAL,
_nested_network_content_download_status_window_widgets, lengthof(_nested_network_content_download_status_window_widgets)
std::begin(_nested_network_content_download_status_window_widgets), std::end(_nested_network_content_download_status_window_widgets)
);
BaseNetworkContentDownloadStatusWindow::BaseNetworkContentDownloadStatusWindow(WindowDesc *desc) :
@ -1113,7 +1113,7 @@ static WindowDesc _network_content_list_desc(
WDP_CENTER, "list_content", 630, 460,
WC_NETWORK_WINDOW, WC_NONE,
0,
_nested_network_content_list_widgets, lengthof(_nested_network_content_list_widgets)
std::begin(_nested_network_content_list_widgets), std::end(_nested_network_content_list_widgets)
);
/**

View File

@ -1007,7 +1007,7 @@ static WindowDesc _network_game_window_desc(
WDP_CENTER, "list_servers", 1000, 730,
WC_NETWORK_WINDOW, WC_NONE,
0,
_nested_network_game_widgets, lengthof(_nested_network_game_widgets)
std::begin(_nested_network_game_widgets), std::end(_nested_network_game_widgets)
);
void ShowNetworkGameWindow()
@ -1280,7 +1280,7 @@ static WindowDesc _network_start_server_window_desc(
WDP_CENTER, nullptr, 0, 0,
WC_NETWORK_WINDOW, WC_NONE,
0,
_nested_network_start_server_window_widgets, lengthof(_nested_network_start_server_window_widgets)
std::begin(_nested_network_start_server_window_widgets), std::end(_nested_network_start_server_window_widgets)
);
static void ShowNetworkStartServerWindow()
@ -1359,7 +1359,7 @@ static WindowDesc _client_list_desc(
WDP_AUTO, "list_clients", 220, 300,
WC_CLIENT_LIST, WC_NONE,
0,
_nested_client_list_widgets, lengthof(_nested_client_list_widgets)
std::begin(_nested_client_list_widgets), std::end(_nested_client_list_widgets)
);
/**
@ -2274,7 +2274,7 @@ static WindowDesc _network_join_status_window_desc(
WDP_CENTER, nullptr, 0, 0,
WC_NETWORK_STATUS_WINDOW, WC_NONE,
WDF_MODAL,
_nested_network_join_status_window_widgets, lengthof(_nested_network_join_status_window_widgets)
std::begin(_nested_network_join_status_window_widgets), std::end(_nested_network_join_status_window_widgets)
);
void ShowJoinStatusWindow()
@ -2396,7 +2396,7 @@ static WindowDesc _network_company_password_window_desc(
WDP_AUTO, nullptr, 0, 0,
WC_COMPANY_PASSWORD_WINDOW, WC_NONE,
0,
_nested_network_company_password_window_widgets, lengthof(_nested_network_company_password_window_widgets)
std::begin(_nested_network_company_password_window_widgets), std::end(_nested_network_company_password_window_widgets)
);
void ShowNetworkCompanyPasswordWindow(Window *parent)
@ -2499,7 +2499,7 @@ static WindowDesc _network_ask_relay_desc(
WDP_CENTER, nullptr, 0, 0,
WC_NETWORK_ASK_RELAY, WC_NONE,
WDF_MODAL,
_nested_network_ask_relay_widgets, lengthof(_nested_network_ask_relay_widgets)
std::begin(_nested_network_ask_relay_widgets), std::end(_nested_network_ask_relay_widgets)
);
/**
@ -2597,7 +2597,7 @@ static WindowDesc _network_ask_survey_desc(
WDP_CENTER, nullptr, 0, 0,
WC_NETWORK_ASK_SURVEY, WC_NONE,
WDF_MODAL,
_nested_network_ask_survey_widgets, lengthof(_nested_network_ask_survey_widgets)
std::begin(_nested_network_ask_survey_widgets), std::end(_nested_network_ask_survey_widgets)
);
/**

View File

@ -682,14 +682,14 @@ static WindowDesc _newgrf_inspect_chain_desc(
WDP_AUTO, "newgrf_inspect_chain", 400, 300,
WC_NEWGRF_INSPECT, WC_NONE,
0,
_nested_newgrf_inspect_chain_widgets, lengthof(_nested_newgrf_inspect_chain_widgets)
std::begin(_nested_newgrf_inspect_chain_widgets), std::end(_nested_newgrf_inspect_chain_widgets)
);
static WindowDesc _newgrf_inspect_desc(
WDP_AUTO, "newgrf_inspect", 400, 300,
WC_NEWGRF_INSPECT, WC_NONE,
0,
_nested_newgrf_inspect_widgets, lengthof(_nested_newgrf_inspect_widgets)
std::begin(_nested_newgrf_inspect_widgets), std::end(_nested_newgrf_inspect_widgets)
);
/**
@ -1124,7 +1124,7 @@ static WindowDesc _sprite_aligner_desc(
WDP_AUTO, "sprite_aligner", 400, 300,
WC_SPRITE_ALIGNER, WC_NONE,
0,
_nested_sprite_aligner_widgets, lengthof(_nested_sprite_aligner_widgets)
std::begin(_nested_sprite_aligner_widgets), std::end(_nested_sprite_aligner_widgets)
);
/**

View File

@ -541,7 +541,7 @@ static WindowDesc _newgrf_parameters_desc(
WDP_CENTER, "settings_newgrf_config", 500, 208,
WC_GRF_PARAMETERS, WC_NONE,
0,
_nested_newgrf_parameter_widgets, lengthof(_nested_newgrf_parameter_widgets)
std::begin(_nested_newgrf_parameter_widgets), std::end(_nested_newgrf_parameter_widgets)
);
static void OpenGRFParameterWindow(GRFConfig *c, bool editable)
@ -1926,13 +1926,13 @@ static const NWidgetPart _nested_newgrf_infopanel_widgets[] = {
/** Construct nested container widget for managing the lists and the info panel of the NewGRF GUI. */
NWidgetBase* NewGRFDisplay(int *biggest_index)
{
NWidgetBase *avs = MakeNWidgets(_nested_newgrf_availables_widgets, lengthof(_nested_newgrf_availables_widgets), biggest_index, nullptr);
NWidgetBase *avs = MakeNWidgets(std::begin(_nested_newgrf_availables_widgets), std::end(_nested_newgrf_availables_widgets), biggest_index, nullptr);
int biggest2;
NWidgetBase *acs = MakeNWidgets(_nested_newgrf_actives_widgets, lengthof(_nested_newgrf_actives_widgets), &biggest2, nullptr);
NWidgetBase *acs = MakeNWidgets(std::begin(_nested_newgrf_actives_widgets), std::end(_nested_newgrf_actives_widgets), &biggest2, nullptr);
*biggest_index = std::max(*biggest_index, biggest2);
NWidgetBase *inf = MakeNWidgets(_nested_newgrf_infopanel_widgets, lengthof(_nested_newgrf_infopanel_widgets), &biggest2, nullptr);
NWidgetBase *inf = MakeNWidgets(std::begin(_nested_newgrf_infopanel_widgets), std::end(_nested_newgrf_infopanel_widgets), &biggest2, nullptr);
*biggest_index = std::max(*biggest_index, biggest2);
return new NWidgetNewGRFDisplay(avs, acs, inf);
@ -1960,7 +1960,7 @@ static WindowDesc _newgrf_desc(
WDP_CENTER, "settings_newgrf", 300, 263,
WC_GAME_OPTIONS, WC_NONE,
0,
_nested_newgrf_widgets, lengthof(_nested_newgrf_widgets)
std::begin(_nested_newgrf_widgets), std::end(_nested_newgrf_widgets)
);
/**
@ -2044,7 +2044,7 @@ static WindowDesc _save_preset_desc(
WDP_CENTER, "save_preset", 140, 110,
WC_SAVE_PRESET, WC_GAME_OPTIONS,
WDF_MODAL,
_nested_save_preset_widgets, lengthof(_nested_save_preset_widgets)
std::begin(_nested_save_preset_widgets), std::end(_nested_save_preset_widgets)
);
/** Class for the save preset window. */
@ -2189,7 +2189,7 @@ static WindowDesc _scan_progress_desc(
WDP_CENTER, nullptr, 0, 0,
WC_MODAL_PROGRESS, WC_NONE,
0,
_nested_scan_progress_widgets, lengthof(_nested_scan_progress_widgets)
std::begin(_nested_scan_progress_widgets), std::end(_nested_scan_progress_widgets)
);
/** Window for showing the progress of NewGRF scanning. */

View File

@ -100,7 +100,7 @@ static WindowDesc _normal_news_desc(
WDP_MANUAL, nullptr, 0, 0,
WC_NEWS_WINDOW, WC_NONE,
0,
_nested_normal_news_widgets, lengthof(_nested_normal_news_widgets)
std::begin(_nested_normal_news_widgets), std::end(_nested_normal_news_widgets)
);
/* New vehicles news items. */
@ -127,7 +127,7 @@ static WindowDesc _vehicle_news_desc(
WDP_MANUAL, nullptr, 0, 0,
WC_NEWS_WINDOW, WC_NONE,
0,
_nested_vehicle_news_widgets, lengthof(_nested_vehicle_news_widgets)
std::begin(_nested_vehicle_news_widgets), std::end(_nested_vehicle_news_widgets)
);
/* Company news items. */
@ -155,7 +155,7 @@ static WindowDesc _company_news_desc(
WDP_MANUAL, nullptr, 0, 0,
WC_NEWS_WINDOW, WC_NONE,
0,
_nested_company_news_widgets, lengthof(_nested_company_news_widgets)
std::begin(_nested_company_news_widgets), std::end(_nested_company_news_widgets)
);
/* Thin news items. */
@ -178,7 +178,7 @@ static WindowDesc _thin_news_desc(
WDP_MANUAL, nullptr, 0, 0,
WC_NEWS_WINDOW, WC_NONE,
0,
_nested_thin_news_widgets, lengthof(_nested_thin_news_widgets)
std::begin(_nested_thin_news_widgets), std::end(_nested_thin_news_widgets)
);
/* Small news items. */
@ -204,7 +204,7 @@ static WindowDesc _small_news_desc(
WDP_MANUAL, nullptr, 0, 0,
WC_NEWS_WINDOW, WC_NONE,
0,
_nested_small_news_widgets, lengthof(_nested_small_news_widgets)
std::begin(_nested_small_news_widgets), std::end(_nested_small_news_widgets)
);
/**
@ -1231,7 +1231,7 @@ static WindowDesc _message_history_desc(
WDP_AUTO, "list_news", 400, 140,
WC_MESSAGE_HISTORY, WC_NONE,
0,
_nested_message_history, lengthof(_nested_message_history)
std::begin(_nested_message_history), std::end(_nested_message_history)
);
/** Display window with news messages history */

View File

@ -720,7 +720,7 @@ static WindowDesc _build_object_desc(
WDP_AUTO, "build_object", 0, 0,
WC_BUILD_OBJECT, WC_BUILD_TOOLBAR,
WDF_CONSTRUCTION,
_nested_build_object_widgets, lengthof(_nested_build_object_widgets),
std::begin(_nested_build_object_widgets), std::end(_nested_build_object_widgets),
&BuildObjectWindow::hotkeys
);

View File

@ -1640,7 +1640,7 @@ static WindowDesc _orders_train_desc(
WDP_AUTO, "view_vehicle_orders_train", 384, 100,
WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
WDF_CONSTRUCTION,
_nested_orders_train_widgets, lengthof(_nested_orders_train_widgets),
std::begin(_nested_orders_train_widgets), std::end(_nested_orders_train_widgets),
&OrdersWindow::hotkeys
);
@ -1713,7 +1713,7 @@ static WindowDesc _orders_desc(
WDP_AUTO, "view_vehicle_orders", 384, 100,
WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
WDF_CONSTRUCTION,
_nested_orders_widgets, lengthof(_nested_orders_widgets),
std::begin(_nested_orders_widgets), std::end(_nested_orders_widgets),
&OrdersWindow::hotkeys
);
@ -1740,7 +1740,7 @@ static WindowDesc _other_orders_desc(
WDP_AUTO, "view_vehicle_orders_competitor", 384, 86,
WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
WDF_CONSTRUCTION,
_nested_other_orders_widgets, lengthof(_nested_other_orders_widgets),
std::begin(_nested_other_orders_widgets), std::end(_nested_other_orders_widgets),
&OrdersWindow::hotkeys
);

View File

@ -338,7 +338,7 @@ static WindowDesc _osk_desc(
WDP_CENTER, nullptr, 0, 0,
WC_OSK, WC_NONE,
0,
_nested_osk_widgets, lengthof(_nested_osk_widgets)
std::begin(_nested_osk_widgets), std::end(_nested_osk_widgets)
);
/**

View File

@ -841,7 +841,7 @@ static WindowDesc _build_rail_desc(
WDP_ALIGN_TOOLBAR, "toolbar_rail", 0, 0,
WC_BUILD_TOOLBAR, WC_NONE,
WDF_CONSTRUCTION,
_nested_build_rail_widgets, lengthof(_nested_build_rail_widgets),
std::begin(_nested_build_rail_widgets), std::end(_nested_build_rail_widgets),
&BuildRailToolbarWindow::hotkeys
);
@ -1631,7 +1631,7 @@ static WindowDesc _station_builder_desc(
WDP_AUTO, "build_station_rail", 350, 0,
WC_BUILD_STATION, WC_BUILD_TOOLBAR,
WDF_CONSTRUCTION,
_nested_station_builder_widgets, lengthof(_nested_station_builder_widgets),
std::begin(_nested_station_builder_widgets), std::end(_nested_station_builder_widgets),
&BuildRailStationWindow::hotkeys
);
@ -1889,7 +1889,7 @@ static WindowDesc _signal_builder_desc(
WDP_AUTO, nullptr, 0, 0,
WC_BUILD_SIGNAL, WC_BUILD_TOOLBAR,
WDF_CONSTRUCTION,
_nested_signal_builder_widgets, lengthof(_nested_signal_builder_widgets)
std::begin(_nested_signal_builder_widgets), std::end(_nested_signal_builder_widgets)
);
/**
@ -1980,7 +1980,7 @@ static WindowDesc _build_depot_desc(
WDP_AUTO, nullptr, 0, 0,
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
WDF_CONSTRUCTION,
_nested_build_depot_widgets, lengthof(_nested_build_depot_widgets)
std::begin(_nested_build_depot_widgets), std::end(_nested_build_depot_widgets)
);
static void ShowBuildTrainDepotPicker(Window *parent)
@ -2208,7 +2208,7 @@ static WindowDesc _build_waypoint_desc(
WDP_AUTO, "build_waypoint", 0, 0,
WC_BUILD_WAYPOINT, WC_BUILD_TOOLBAR,
WDF_CONSTRUCTION,
_nested_build_waypoint_widgets, lengthof(_nested_build_waypoint_widgets)
std::begin(_nested_build_waypoint_widgets), std::end(_nested_build_waypoint_widgets)
);
static void ShowBuildWaypointPicker(Window *parent)

View File

@ -858,7 +858,7 @@ static WindowDesc _build_road_desc(
WDP_ALIGN_TOOLBAR, "toolbar_road", 0, 0,
WC_BUILD_TOOLBAR, WC_NONE,
WDF_CONSTRUCTION,
_nested_build_road_widgets, lengthof(_nested_build_road_widgets),
std::begin(_nested_build_road_widgets), std::end(_nested_build_road_widgets),
&BuildRoadToolbarWindow::road_hotkeys
);
@ -899,7 +899,7 @@ static WindowDesc _build_tramway_desc(
WDP_ALIGN_TOOLBAR, "toolbar_tramway", 0, 0,
WC_BUILD_TOOLBAR, WC_NONE,
WDF_CONSTRUCTION,
_nested_build_tramway_widgets, lengthof(_nested_build_tramway_widgets),
std::begin(_nested_build_tramway_widgets), std::end(_nested_build_tramway_widgets),
&BuildRoadToolbarWindow::tram_hotkeys
);
@ -954,7 +954,7 @@ static WindowDesc _build_road_scen_desc(
WDP_AUTO, "toolbar_road_scen", 0, 0,
WC_SCEN_BUILD_TOOLBAR, WC_NONE,
WDF_CONSTRUCTION,
_nested_build_road_scen_widgets, lengthof(_nested_build_road_scen_widgets),
std::begin(_nested_build_road_scen_widgets), std::end(_nested_build_road_scen_widgets),
&BuildRoadToolbarWindow::road_hotkeys
);
@ -989,7 +989,7 @@ static WindowDesc _build_tramway_scen_desc(
WDP_AUTO, "toolbar_tram_scen", 0, 0,
WC_SCEN_BUILD_TOOLBAR, WC_NONE,
WDF_CONSTRUCTION,
_nested_build_tramway_scen_widgets, lengthof(_nested_build_tramway_scen_widgets),
std::begin(_nested_build_tramway_scen_widgets), std::end(_nested_build_tramway_scen_widgets),
&BuildRoadToolbarWindow::tram_hotkeys
);
@ -1087,7 +1087,7 @@ static WindowDesc _build_road_depot_desc(
WDP_AUTO, nullptr, 0, 0,
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
WDF_CONSTRUCTION,
_nested_build_road_depot_widgets, lengthof(_nested_build_road_depot_widgets)
std::begin(_nested_build_road_depot_widgets), std::end(_nested_build_road_depot_widgets)
);
static void ShowRoadDepotPicker(Window *parent)
@ -1684,7 +1684,7 @@ static WindowDesc _road_station_picker_desc(
WDP_AUTO, "build_station_road", 0, 0,
WC_BUS_STATION, WC_BUILD_TOOLBAR,
WDF_CONSTRUCTION,
_nested_road_station_picker_widgets, lengthof(_nested_road_station_picker_widgets)
std::begin(_nested_road_station_picker_widgets), std::end(_nested_road_station_picker_widgets)
);
/** Widget definition of the build tram station window */
@ -1769,7 +1769,7 @@ static WindowDesc _tram_station_picker_desc(
WDP_AUTO, "build_station_tram", 0, 0,
WC_BUS_STATION, WC_BUILD_TOOLBAR,
WDF_CONSTRUCTION,
_nested_tram_station_picker_widgets, lengthof(_nested_tram_station_picker_widgets)
std::begin(_nested_tram_station_picker_widgets), std::end(_nested_tram_station_picker_widgets)
);
static void ShowRVStationPicker(Window *parent, RoadStopType rs)

View File

@ -65,7 +65,7 @@ static WindowDesc _screenshot_window_desc(
WDP_AUTO, "take_a_screenshot", 200, 100,
WC_SCREENSHOT, WC_NONE,
0,
_nested_screenshot, lengthof(_nested_screenshot)
std::begin(_nested_screenshot), std::end(_nested_screenshot)
);
void ShowScreenshotWindow()

View File

@ -265,7 +265,7 @@ static WindowDesc _script_list_desc(
WDP_CENTER, "settings_script_list", 200, 234,
WC_SCRIPT_LIST, WC_NONE,
0,
_nested_script_list_widgets, lengthof(_nested_script_list_widgets)
std::begin(_nested_script_list_widgets), std::end(_nested_script_list_widgets)
);
/**
@ -608,7 +608,7 @@ static WindowDesc _script_settings_desc(
WDP_CENTER, "settings_script", 500, 208,
WC_SCRIPT_SETTINGS, WC_NONE,
0,
_nested_script_settings_widgets, lengthof(_nested_script_settings_widgets)
std::begin(_nested_script_settings_widgets), std::end(_nested_script_settings_widgets)
);
/**
@ -1195,7 +1195,7 @@ static WindowDesc _script_debug_desc(
WDP_AUTO, "script_debug", 600, 450,
WC_SCRIPT_DEBUG, WC_NONE,
0,
_nested_script_debug_widgets, lengthof(_nested_script_debug_widgets),
std::begin(_nested_script_debug_widgets), std::end(_nested_script_debug_widgets),
&ScriptDebugWindow::hotkeys
);

View File

@ -925,7 +925,7 @@ static WindowDesc _game_options_desc(
WDP_CENTER, nullptr, 0, 0,
WC_GAME_OPTIONS, WC_NONE,
0,
_nested_game_options_widgets, lengthof(_nested_game_options_widgets)
std::begin(_nested_game_options_widgets), std::end(_nested_game_options_widgets)
);
/** Open the game options window. */
@ -2657,7 +2657,7 @@ static WindowDesc _settings_selection_desc(
WDP_CENTER, "settings", 510, 450,
WC_GAME_OPTIONS, WC_NONE,
0,
_nested_settings_selection_widgets, lengthof(_nested_settings_selection_widgets)
std::begin(_nested_settings_selection_widgets), std::end(_nested_settings_selection_widgets)
);
/** Open advanced settings window. */
@ -2956,7 +2956,7 @@ static WindowDesc _cust_currency_desc(
WDP_CENTER, nullptr, 0, 0,
WC_CUSTOM_CURRENCY, WC_NONE,
0,
_nested_cust_currency_widgets, lengthof(_nested_cust_currency_widgets)
std::begin(_nested_cust_currency_widgets), std::end(_nested_cust_currency_widgets)
);
/** Open custom currency window. */

View File

@ -389,7 +389,7 @@ static WindowDesc _sign_list_desc(
WDP_AUTO, "list_signs", 358, 138,
WC_SIGN_LIST, WC_NONE,
0,
_nested_sign_list_widgets, lengthof(_nested_sign_list_widgets),
std::begin(_nested_sign_list_widgets), std::end(_nested_sign_list_widgets),
&SignListWindow::hotkeys
);
@ -555,7 +555,7 @@ static WindowDesc _query_sign_edit_desc(
WDP_CENTER, nullptr, 0, 0,
WC_QUERY_STRING, WC_NONE,
WDF_CONSTRUCTION,
_nested_query_sign_edit_widgets, lengthof(_nested_query_sign_edit_widgets)
std::begin(_nested_query_sign_edit_widgets), std::end(_nested_query_sign_edit_widgets)
);
/**

View File

@ -1833,8 +1833,8 @@ static NWidgetBase *SmallMapDisplay(int *biggest_index)
{
NWidgetContainer *map_display = new NWidgetSmallmapDisplay;
MakeNWidgets(_nested_smallmap_display, lengthof(_nested_smallmap_display), biggest_index, map_display);
MakeNWidgets(_nested_smallmap_bar, lengthof(_nested_smallmap_bar), biggest_index, map_display);
MakeNWidgets(std::begin(_nested_smallmap_display), std::end(_nested_smallmap_display), biggest_index, map_display);
MakeNWidgets(std::begin(_nested_smallmap_bar), std::end(_nested_smallmap_bar), biggest_index, map_display);
return map_display;
}
@ -1869,7 +1869,7 @@ static WindowDesc _smallmap_desc(
WDP_AUTO, "smallmap", 484, 314,
WC_SMALLMAP, WC_NONE,
0,
_nested_smallmap_widgets, lengthof(_nested_smallmap_widgets)
std::begin(_nested_smallmap_widgets), std::end(_nested_smallmap_widgets)
);
/**

View File

@ -765,7 +765,7 @@ static WindowDesc _company_stations_desc(
WDP_AUTO, "list_stations", 358, 162,
WC_STATION_LIST, WC_NONE,
0,
_nested_company_stations_widgets, lengthof(_nested_company_stations_widgets)
std::begin(_nested_company_stations_widgets), std::end(_nested_company_stations_widgets)
);
/**
@ -2121,7 +2121,7 @@ static WindowDesc _station_view_desc(
WDP_AUTO, "view_station", 249, 117,
WC_STATION_VIEW, WC_NONE,
0,
_nested_station_view_widgets, lengthof(_nested_station_view_widgets)
std::begin(_nested_station_view_widgets), std::end(_nested_station_view_widgets)
);
/**
@ -2378,7 +2378,7 @@ static WindowDesc _select_station_desc(
WDP_AUTO, "build_station_join", 200, 180,
WC_SELECT_STATION, WC_NONE,
WDF_CONSTRUCTION,
_nested_select_station_widgets, lengthof(_nested_select_station_widgets)
std::begin(_nested_select_station_widgets), std::end(_nested_select_station_widgets)
);

View File

@ -231,7 +231,7 @@ static WindowDesc _main_status_desc(
WDP_MANUAL, nullptr, 0, 0,
WC_STATUS_BAR, WC_NONE,
WDF_NO_FOCUS | WDF_NO_CLOSE,
_nested_main_status_widgets, lengthof(_nested_main_status_widgets)
std::begin(_nested_main_status_widgets), std::end(_nested_main_status_widgets)
);
/**

View File

@ -972,7 +972,7 @@ static WindowDesc _story_book_desc(
WDP_CENTER, "view_story", 400, 300,
WC_STORY_BOOK, WC_NONE,
0,
_nested_story_book_widgets, lengthof(_nested_story_book_widgets)
std::begin(_nested_story_book_widgets), std::end(_nested_story_book_widgets)
);
static CursorID TranslateStoryPageButtonCursor(StoryPageButtonCursor cursor)

View File

@ -238,7 +238,7 @@ static WindowDesc _subsidies_list_desc(
WDP_AUTO, "list_subsidies", 500, 127,
WC_SUBSIDIES_LIST, WC_NONE,
0,
_nested_subsidies_list_widgets, lengthof(_nested_subsidies_list_widgets)
std::begin(_nested_subsidies_list_widgets), std::end(_nested_subsidies_list_widgets)
);

View File

@ -355,7 +355,7 @@ static WindowDesc _terraform_desc(
WDP_MANUAL, "toolbar_landscape", 0, 0,
WC_SCEN_LAND_GEN, WC_NONE,
WDF_CONSTRUCTION,
_nested_terraform_widgets, lengthof(_nested_terraform_widgets),
std::begin(_nested_terraform_widgets), std::end(_nested_terraform_widgets),
&TerraformToolbarWindow::hotkeys
);
@ -743,7 +743,7 @@ static WindowDesc _scen_edit_land_gen_desc(
WDP_AUTO, "toolbar_landscape_scen", 0, 0,
WC_SCEN_LAND_GEN, WC_NONE,
WDF_CONSTRUCTION,
_nested_scen_edit_land_gen_widgets, lengthof(_nested_scen_edit_land_gen_widgets),
std::begin(_nested_scen_edit_land_gen_widgets), std::end(_nested_scen_edit_land_gen_widgets),
&ScenarioEditorLandscapeGenerationWindow::hotkeys
);

View File

@ -56,7 +56,7 @@ static WindowDesc _textfile_desc(
WDP_CENTER, "textfile", 630, 460,
WC_TEXTFILE, WC_NONE,
0,
_nested_textfile_widgets, lengthof(_nested_textfile_widgets)
std::begin(_nested_textfile_widgets), std::end(_nested_textfile_widgets)
);
TextfileWindow::TextfileWindow(TextfileType file_type) : Window(&_textfile_desc), file_type(file_type)

View File

@ -746,7 +746,7 @@ static WindowDesc _timetable_desc(
WDP_AUTO, "view_vehicle_timetable", 400, 130,
WC_VEHICLE_TIMETABLE, WC_VEHICLE_VIEW,
WDF_CONSTRUCTION,
_nested_timetable_widgets, lengthof(_nested_timetable_widgets)
std::begin(_nested_timetable_widgets), std::end(_nested_timetable_widgets)
);
/**

View File

@ -2254,7 +2254,7 @@ static WindowDesc _toolb_normal_desc(
WDP_MANUAL, nullptr, 0, 0,
WC_MAIN_TOOLBAR, WC_NONE,
WDF_NO_FOCUS | WDF_NO_CLOSE,
_nested_toolbar_normal_widgets, lengthof(_nested_toolbar_normal_widgets),
std::begin(_nested_toolbar_normal_widgets), std::end(_nested_toolbar_normal_widgets),
&MainToolbarWindow::hotkeys
);
@ -2583,7 +2583,7 @@ static const NWidgetPart _nested_toolb_scen_inner_widgets[] = {
static NWidgetBase *MakeScenarioToolbar(int *biggest_index)
{
return MakeNWidgets(_nested_toolb_scen_inner_widgets, lengthof(_nested_toolb_scen_inner_widgets), biggest_index, new NWidgetScenarioToolbarContainer());
return MakeNWidgets(std::begin(_nested_toolb_scen_inner_widgets), std::end(_nested_toolb_scen_inner_widgets), biggest_index, new NWidgetScenarioToolbarContainer());
}
static const NWidgetPart _nested_toolb_scen_widgets[] = {
@ -2594,7 +2594,7 @@ static WindowDesc _toolb_scen_desc(
WDP_MANUAL, nullptr, 0, 0,
WC_MAIN_TOOLBAR, WC_NONE,
WDF_NO_FOCUS | WDF_NO_CLOSE,
_nested_toolb_scen_widgets, lengthof(_nested_toolb_scen_widgets),
std::begin(_nested_toolb_scen_widgets), std::end(_nested_toolb_scen_widgets),
&ScenarioEditorToolbarWindow::hotkeys
);

View File

@ -330,7 +330,7 @@ static WindowDesc _town_authority_desc(
WDP_AUTO, "view_town_authority", 317, 222,
WC_TOWN_AUTHORITY, WC_NONE,
0,
_nested_town_authority_widgets, lengthof(_nested_town_authority_widgets)
std::begin(_nested_town_authority_widgets), std::end(_nested_town_authority_widgets)
);
static void ShowTownAuthorityWindow(uint town)
@ -631,7 +631,7 @@ static WindowDesc _town_game_view_desc(
WDP_AUTO, "view_town", 260, TownViewWindow::WID_TV_HEIGHT_NORMAL,
WC_TOWN_VIEW, WC_NONE,
0,
_nested_town_game_view_widgets, lengthof(_nested_town_game_view_widgets)
std::begin(_nested_town_game_view_widgets), std::end(_nested_town_game_view_widgets)
);
static const NWidgetPart _nested_town_editor_view_widgets[] = {
@ -662,7 +662,7 @@ static WindowDesc _town_editor_view_desc(
WDP_AUTO, "view_town_scen", 260, TownViewWindow::WID_TV_HEIGHT_NORMAL,
WC_TOWN_VIEW, WC_NONE,
0,
_nested_town_editor_view_widgets, lengthof(_nested_town_editor_view_widgets)
std::begin(_nested_town_editor_view_widgets), std::end(_nested_town_editor_view_widgets)
);
void ShowTownViewWindow(TownID town)
@ -1037,7 +1037,7 @@ static WindowDesc _town_directory_desc(
WDP_AUTO, "list_towns", 208, 202,
WC_TOWN_DIRECTORY, WC_NONE,
0,
_nested_town_directory_widgets, lengthof(_nested_town_directory_widgets)
std::begin(_nested_town_directory_widgets), std::end(_nested_town_directory_widgets)
);
void ShowTownDirectory()
@ -1287,7 +1287,7 @@ static WindowDesc _found_town_desc(
WDP_AUTO, "build_town", 160, 162,
WC_FOUND_TOWN, WC_NONE,
WDF_CONSTRUCTION,
_nested_found_town_widgets, lengthof(_nested_found_town_widgets)
std::begin(_nested_found_town_widgets), std::end(_nested_found_town_widgets)
);
void ShowFoundTownWindow()

View File

@ -152,7 +152,7 @@ static WindowDesc _transparency_desc(
WDP_MANUAL, "toolbar_transparency", 0, 0,
WC_TRANSPARENCY_TOOLBAR, WC_NONE,
0,
_nested_transparency_widgets, lengthof(_nested_transparency_widgets)
std::begin(_nested_transparency_widgets), std::end(_nested_transparency_widgets)
);
/**

View File

@ -320,7 +320,7 @@ static WindowDesc _build_trees_desc(
WDP_AUTO, "build_tree", 0, 0,
WC_BUILD_TREES, WC_NONE,
WDF_CONSTRUCTION,
_nested_build_trees_widgets, lengthof(_nested_build_trees_widgets)
std::begin(_nested_build_trees_widgets), std::end(_nested_build_trees_widgets)
);
void ShowBuildTreesToolbar()

View File

@ -1238,7 +1238,7 @@ static WindowDesc _vehicle_refit_desc(
WDP_AUTO, "view_vehicle_refit", 240, 174,
WC_VEHICLE_REFIT, WC_VEHICLE_VIEW,
WDF_CONSTRUCTION,
_nested_vehicle_refit_widgets, lengthof(_nested_vehicle_refit_widgets)
std::begin(_nested_vehicle_refit_widgets), std::end(_nested_vehicle_refit_widgets)
);
/**
@ -2171,14 +2171,14 @@ static WindowDesc _vehicle_list_other_desc(
WDP_AUTO, "list_vehicles", 260, 246,
WC_INVALID, WC_NONE,
0,
_nested_vehicle_list, lengthof(_nested_vehicle_list)
std::begin(_nested_vehicle_list), std::end(_nested_vehicle_list)
);
static WindowDesc _vehicle_list_train_desc(
WDP_AUTO, "list_vehicles_train", 325, 246,
WC_TRAINS_LIST, WC_NONE,
0,
_nested_vehicle_list, lengthof(_nested_vehicle_list)
std::begin(_nested_vehicle_list), std::end(_nested_vehicle_list)
);
static void ShowVehicleListWindowLocal(CompanyID company, VehicleListType vlt, VehicleType vehicle_type, uint32_t unique_number)
@ -2680,7 +2680,7 @@ static WindowDesc _train_vehicle_details_desc(
WDP_AUTO, "view_vehicle_details_train", 405, 178,
WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW,
0,
_nested_train_vehicle_details_widgets, lengthof(_nested_train_vehicle_details_widgets)
std::begin(_nested_train_vehicle_details_widgets), std::end(_nested_train_vehicle_details_widgets)
);
/** Vehicle details window descriptor for other vehicles than a train. */
@ -2688,7 +2688,7 @@ static WindowDesc _nontrain_vehicle_details_desc(
WDP_AUTO, "view_vehicle_details", 405, 113,
WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW,
0,
_nested_nontrain_vehicle_details_widgets, lengthof(_nested_nontrain_vehicle_details_widgets)
std::begin(_nested_nontrain_vehicle_details_widgets), std::end(_nested_nontrain_vehicle_details_widgets)
);
/** Shows the vehicle details window of the given vehicle. */
@ -3285,7 +3285,7 @@ static WindowDesc _vehicle_view_desc(
WDP_AUTO, "view_vehicle", 250, 116,
WC_VEHICLE_VIEW, WC_NONE,
0,
_nested_vehicle_view_widgets, lengthof(_nested_vehicle_view_widgets),
std::begin(_nested_vehicle_view_widgets), std::end(_nested_vehicle_view_widgets),
&VehicleViewWindow::hotkeys
);
@ -3297,7 +3297,7 @@ static WindowDesc _train_view_desc(
WDP_AUTO, "view_vehicle_train", 250, 134,
WC_VEHICLE_VIEW, WC_NONE,
0,
_nested_vehicle_view_widgets, lengthof(_nested_vehicle_view_widgets),
std::begin(_nested_vehicle_view_widgets), std::end(_nested_vehicle_view_widgets),
&VehicleViewWindow::hotkeys
);

View File

@ -163,7 +163,7 @@ static WindowDesc _extra_viewport_desc(
WDP_AUTO, "extra_viewport", 300, 268,
WC_EXTRA_VIEWPORT, WC_NONE,
0,
_nested_extra_viewport_widgets, lengthof(_nested_extra_viewport_widgets)
std::begin(_nested_extra_viewport_widgets), std::end(_nested_extra_viewport_widgets)
);
/**

View File

@ -187,7 +187,7 @@ static WindowDesc _waypoint_view_desc(
WDP_AUTO, "view_waypoint", 260, 118,
WC_WAYPOINT_VIEW, WC_NONE,
0,
_nested_waypoint_view_widgets, lengthof(_nested_waypoint_view_widgets)
std::begin(_nested_waypoint_view_widgets), std::end(_nested_waypoint_view_widgets)
);
/**

View File

@ -3008,23 +3008,23 @@ bool NWidgetLeaf::ButtonHit(const Point &pt)
* settings that follow it, until encountering a #EndContainer, another
* #NWidget, or the end of the parts array.
*
* @param parts Array with parts of the nested widget.
* @param count Length of the \a parts array.
* @param nwid_begin Pointer to beginning of nested widget parts.
* @param nwid_end Pointer to ending of nested widget parts.
* @param dest Address of pointer to use for returning the composed widget.
* @param fill_dest Fill the composed widget with child widgets.
* @param biggest_index Pointer to biggest nested widget index in the tree encountered so far.
* @return Number of widget part elements used to compose the widget.
* @pre \c biggest_index != nullptr.
*/
static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest, bool *fill_dest, int *biggest_index)
static int MakeNWidget(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, NWidgetBase **dest, bool *fill_dest, int *biggest_index)
{
int num_used = 0;
*dest = nullptr;
*fill_dest = false;
while (count > num_used) {
switch (parts->type) {
while (nwid_begin < nwid_end) {
switch (nwid_begin->type) {
case NWID_SPACER:
if (*dest != nullptr) return num_used;
*dest = new NWidgetSpacer(0, 0);
@ -3032,13 +3032,13 @@ static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest,
case NWID_HORIZONTAL:
if (*dest != nullptr) return num_used;
*dest = new NWidgetHorizontal(parts->u.cont_flags);
*dest = new NWidgetHorizontal(nwid_begin->u.cont_flags);
*fill_dest = true;
break;
case NWID_HORIZONTAL_LTR:
if (*dest != nullptr) return num_used;
*dest = new NWidgetHorizontalLTR(parts->u.cont_flags);
*dest = new NWidgetHorizontalLTR(nwid_begin->u.cont_flags);
*fill_dest = true;
break;
@ -3046,14 +3046,14 @@ static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest,
case WWT_INSET:
case WWT_FRAME:
if (*dest != nullptr) return num_used;
*dest = new NWidgetBackground(parts->type, parts->u.widget.colour, parts->u.widget.index);
*biggest_index = std::max(*biggest_index, (int)parts->u.widget.index);
*dest = new NWidgetBackground(nwid_begin->type, nwid_begin->u.widget.colour, nwid_begin->u.widget.index);
*biggest_index = std::max(*biggest_index, (int)nwid_begin->u.widget.index);
*fill_dest = true;
break;
case NWID_VERTICAL:
if (*dest != nullptr) return num_used;
*dest = new NWidgetVertical(parts->u.cont_flags);
*dest = new NWidgetVertical(nwid_begin->u.cont_flags);
*fill_dest = true;
break;
@ -3062,9 +3062,9 @@ static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest,
NWidgetMatrix *nwm = new NWidgetMatrix();
*dest = nwm;
*fill_dest = true;
nwm->SetIndex(parts->u.widget.index);
nwm->SetColour(parts->u.widget.colour);
*biggest_index = std::max(*biggest_index, (int)parts->u.widget.index);
nwm->SetIndex(nwid_begin->u.widget.index);
nwm->SetColour(nwid_begin->u.widget.colour);
*biggest_index = std::max(*biggest_index, (int)nwid_begin->u.widget.index);
break;
}
@ -3072,7 +3072,7 @@ static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest,
if (*dest != nullptr) return num_used;
/* Ensure proper functioning even when the called code simply writes its largest index. */
int biggest = -1;
*dest = parts->u.func_ptr(&biggest);
*dest = nwid_begin->u.func_ptr(&biggest);
*biggest_index = std::max(*biggest_index, biggest);
*fill_dest = false;
break;
@ -3081,8 +3081,8 @@ static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest,
case WPT_RESIZE: {
NWidgetResizeBase *nwrb = dynamic_cast<NWidgetResizeBase *>(*dest);
if (nwrb != nullptr) {
assert(parts->u.xy.x >= 0 && parts->u.xy.y >= 0);
nwrb->SetResize(parts->u.xy.x, parts->u.xy.y);
assert(nwid_begin->u.xy.x >= 0 && nwid_begin->u.xy.y >= 0);
nwrb->SetResize(nwid_begin->u.xy.x, nwid_begin->u.xy.y);
}
break;
}
@ -3090,8 +3090,8 @@ static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest,
case WPT_MINSIZE: {
NWidgetResizeBase *nwrb = dynamic_cast<NWidgetResizeBase *>(*dest);
if (nwrb != nullptr) {
assert(parts->u.xy.x >= 0 && parts->u.xy.y >= 0);
nwrb->SetMinimalSize(parts->u.xy.x, parts->u.xy.y);
assert(nwid_begin->u.xy.x >= 0 && nwid_begin->u.xy.y >= 0);
nwrb->SetMinimalSize(nwid_begin->u.xy.x, nwid_begin->u.xy.y);
}
break;
}
@ -3099,8 +3099,8 @@ static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest,
case WPT_MINTEXTLINES: {
NWidgetResizeBase *nwrb = dynamic_cast<NWidgetResizeBase *>(*dest);
if (nwrb != nullptr) {
assert(parts->u.text_lines.size >= FS_BEGIN && parts->u.text_lines.size < FS_END);
nwrb->SetMinimalTextLines(parts->u.text_lines.lines, parts->u.text_lines.spacing, parts->u.text_lines.size);
assert(nwid_begin->u.text_lines.size >= FS_BEGIN && nwid_begin->u.text_lines.size < FS_END);
nwrb->SetMinimalTextLines(nwid_begin->u.text_lines.lines, nwid_begin->u.text_lines.spacing, nwid_begin->u.text_lines.size);
}
break;
}
@ -3108,7 +3108,7 @@ static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest,
case WPT_TEXTSTYLE: {
NWidgetCore *nwc = dynamic_cast<NWidgetCore *>(*dest);
if (nwc != nullptr) {
nwc->SetTextStyle(parts->u.text_style.colour, parts->u.text_style.size);
nwc->SetTextStyle(nwid_begin->u.text_style.colour, nwid_begin->u.text_style.size);
}
break;
}
@ -3116,43 +3116,43 @@ static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest,
case WPT_ALIGNMENT: {
NWidgetCore *nwc = dynamic_cast<NWidgetCore *>(*dest);
if (nwc != nullptr) {
nwc->SetAlignment(parts->u.align.align);
nwc->SetAlignment(nwid_begin->u.align.align);
}
break;
}
case WPT_FILL: {
NWidgetResizeBase *nwrb = dynamic_cast<NWidgetResizeBase *>(*dest);
if (nwrb != nullptr) nwrb->SetFill(parts->u.xy.x, parts->u.xy.y);
if (nwrb != nullptr) nwrb->SetFill(nwid_begin->u.xy.x, nwid_begin->u.xy.y);
break;
}
case WPT_DATATIP: {
NWidgetCore *nwc = dynamic_cast<NWidgetCore *>(*dest);
if (nwc != nullptr) {
nwc->widget_data = parts->u.data_tip.data;
nwc->tool_tip = parts->u.data_tip.tooltip;
nwc->widget_data = nwid_begin->u.data_tip.data;
nwc->tool_tip = nwid_begin->u.data_tip.tooltip;
}
break;
}
case WPT_PADDING:
if (*dest != nullptr) (*dest)->SetPadding(parts->u.padding);
if (*dest != nullptr) (*dest)->SetPadding(nwid_begin->u.padding);
break;
case WPT_PIPSPACE: {
NWidgetPIPContainer *nwc = dynamic_cast<NWidgetPIPContainer *>(*dest);
if (nwc != nullptr) nwc->SetPIP(parts->u.pip.pre, parts->u.pip.inter, parts->u.pip.post);
if (nwc != nullptr) nwc->SetPIP(nwid_begin->u.pip.pre, nwid_begin->u.pip.inter, nwid_begin->u.pip.post);
NWidgetBackground *nwb = dynamic_cast<NWidgetBackground *>(*dest);
if (nwb != nullptr) nwb->SetPIP(parts->u.pip.pre, parts->u.pip.inter, parts->u.pip.post);
if (nwb != nullptr) nwb->SetPIP(nwid_begin->u.pip.pre, nwid_begin->u.pip.inter, nwid_begin->u.pip.post);
break;
}
case WPT_SCROLLBAR: {
NWidgetCore *nwc = dynamic_cast<NWidgetCore *>(*dest);
if (nwc != nullptr) {
nwc->scrollbar_index = parts->u.widget.index;
nwc->scrollbar_index = nwid_begin->u.widget.index;
}
break;
}
@ -3162,15 +3162,15 @@ static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest,
case NWID_VIEWPORT:
if (*dest != nullptr) return num_used;
*dest = new NWidgetViewport(parts->u.widget.index);
*biggest_index = std::max(*biggest_index, (int)parts->u.widget.index);
*dest = new NWidgetViewport(nwid_begin->u.widget.index);
*biggest_index = std::max(*biggest_index, (int)nwid_begin->u.widget.index);
break;
case NWID_HSCROLLBAR:
case NWID_VSCROLLBAR:
if (*dest != nullptr) return num_used;
*dest = new NWidgetScrollbar(parts->type, parts->u.widget.colour, parts->u.widget.index);
*biggest_index = std::max(*biggest_index, (int)parts->u.widget.index);
*dest = new NWidgetScrollbar(nwid_begin->type, nwid_begin->u.widget.colour, nwid_begin->u.widget.index);
*biggest_index = std::max(*biggest_index, (int)nwid_begin->u.widget.index);
break;
case NWID_SELECTION: {
@ -3178,20 +3178,20 @@ static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest,
NWidgetStacked *nws = new NWidgetStacked();
*dest = nws;
*fill_dest = true;
nws->SetIndex(parts->u.widget.index);
*biggest_index = std::max(*biggest_index, (int)parts->u.widget.index);
nws->SetIndex(nwid_begin->u.widget.index);
*biggest_index = std::max(*biggest_index, (int)nwid_begin->u.widget.index);
break;
}
default:
if (*dest != nullptr) return num_used;
assert((parts->type & WWT_MASK) < WWT_LAST || (parts->type & WWT_MASK) == NWID_BUTTON_DROPDOWN);
*dest = new NWidgetLeaf(parts->type, parts->u.widget.colour, parts->u.widget.index, 0x0, STR_NULL);
*biggest_index = std::max(*biggest_index, (int)parts->u.widget.index);
assert((nwid_begin->type & WWT_MASK) < WWT_LAST || (nwid_begin->type & WWT_MASK) == NWID_BUTTON_DROPDOWN);
*dest = new NWidgetLeaf(nwid_begin->type, nwid_begin->u.widget.colour, nwid_begin->u.widget.index, 0x0, STR_NULL);
*biggest_index = std::max(*biggest_index, (int)nwid_begin->u.widget.index);
break;
}
num_used++;
parts++;
nwid_begin++;
}
return num_used;
@ -3199,14 +3199,14 @@ static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest,
/**
* Build a nested widget tree by recursively filling containers with nested widgets read from their parts.
* @param parts Array with parts of the nested widgets.
* @param count Length of the \a parts array.
* @param nwid_begin Pointer to beginning of nested widget parts.
* @param nwid_end Pointer to ending of nested widget parts.
* @param parent Pointer or container to use for storing the child widgets (*parent == nullptr or *parent == container or background widget).
* @param biggest_index Pointer to biggest nested widget index in the tree.
* @return Number of widget part elements used to fill the container.
* @post \c *biggest_index contains the largest widget index of the tree and \c -1 if no index is used.
*/
static int MakeWidgetTree(const NWidgetPart *parts, int count, NWidgetBase **parent, int *biggest_index)
static int MakeWidgetTree(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, NWidgetBase **parent, int *biggest_index)
{
/* If *parent == nullptr, only the first widget is read and returned. Otherwise, *parent must point to either
* a #NWidgetContainer or a #NWidgetBackground object, and parts are added as much as possible. */
@ -3218,8 +3218,8 @@ static int MakeWidgetTree(const NWidgetPart *parts, int count, NWidgetBase **par
for (;;) {
NWidgetBase *sub_widget = nullptr;
bool fill_sub = false;
int num_used = MakeNWidget(parts, count - total_used, &sub_widget, &fill_sub, biggest_index);
parts += num_used;
int num_used = MakeNWidget(nwid_begin, nwid_end, &sub_widget, &fill_sub, biggest_index);
nwid_begin += num_used;
total_used += num_used;
/* Break out of loop when end reached */
@ -3230,8 +3230,8 @@ static int MakeWidgetTree(const NWidgetPart *parts, int count, NWidgetBase **par
if (fill_sub && (tp == NWID_HORIZONTAL || tp == NWID_HORIZONTAL_LTR || tp == NWID_VERTICAL || tp == NWID_MATRIX
|| tp == WWT_PANEL || tp == WWT_FRAME || tp == WWT_INSET || tp == NWID_SELECTION)) {
NWidgetBase *sub_ptr = sub_widget;
num_used = MakeWidgetTree(parts, count - total_used, &sub_ptr, biggest_index);
parts += num_used;
num_used = MakeWidgetTree(nwid_begin, nwid_end, &sub_ptr, biggest_index);
nwid_begin += num_used;
total_used += num_used;
}
@ -3244,17 +3244,17 @@ static int MakeWidgetTree(const NWidgetPart *parts, int count, NWidgetBase **par
}
}
if (count == total_used) return total_used; // Reached the end of the array of parts?
if (nwid_begin == nwid_end) return total_used; // Reached the end of the array of parts?
assert(total_used < count);
assert(parts->type == WPT_ENDCONTAINER);
return total_used + 1; // *parts is also 'used'
assert(nwid_begin < nwid_end);
assert(nwid_begin->type == WPT_ENDCONTAINER);
return total_used + 1; // *nwid_begin is also 'used'
}
/**
* Construct a nested widget tree from an array of parts.
* @param parts Array with parts of the widgets.
* @param count Length of the \a parts array.
* @param nwid_begin Pointer to beginning of nested widget parts.
* @param nwid_end Pointer to ending of nested widget parts.
* @param biggest_index Pointer to biggest nested widget index collected in the tree.
* @param container Container to add the nested widgets to. In case it is nullptr a vertical container is used.
* @return Root of the nested widget tree, a vertical container containing the entire GUI.
@ -3262,12 +3262,12 @@ static int MakeWidgetTree(const NWidgetPart *parts, int count, NWidgetBase **par
* @pre \c biggest_index != nullptr
* @post \c *biggest_index contains the largest widget index of the tree and \c -1 if no index is used.
*/
NWidgetContainer *MakeNWidgets(const NWidgetPart *parts, int count, int *biggest_index, NWidgetContainer *container)
NWidgetContainer *MakeNWidgets(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, int *biggest_index, NWidgetContainer *container)
{
*biggest_index = -1;
if (container == nullptr) container = new NWidgetVertical();
NWidgetBase *cont_ptr = container;
MakeWidgetTree(parts, count, &cont_ptr, biggest_index);
MakeWidgetTree(nwid_begin, nwid_end, &cont_ptr, biggest_index);
return container;
}
@ -3275,8 +3275,8 @@ NWidgetContainer *MakeNWidgets(const NWidgetPart *parts, int count, int *biggest
* Make a nested widget tree for a window from a parts array. Besides loading, it inserts a shading selection widget
* between the title bar and the window body if the first widget in the parts array looks like a title bar (it is a horizontal
* container with a caption widget) and has a shade box widget.
* @param parts Array with parts of the widgets.
* @param count Length of the \a parts array.
* @param nwid_begin Pointer to beginning of nested widget parts.
* @param nwid_end Pointer to ending of nested widget parts.
* @param biggest_index Pointer to biggest nested widget index collected in the tree.
* @param[out] shade_select Pointer to the inserted shade selection widget (\c nullptr if not unserted).
* @return Root of the nested widget tree, a vertical container containing the entire GUI.
@ -3284,20 +3284,19 @@ NWidgetContainer *MakeNWidgets(const NWidgetPart *parts, int count, int *biggest
* @pre \c biggest_index != nullptr
* @post \c *biggest_index contains the largest widget index of the tree and \c -1 if no index is used.
*/
NWidgetContainer *MakeWindowNWidgetTree(const NWidgetPart *parts, int count, int *biggest_index, NWidgetStacked **shade_select)
NWidgetContainer *MakeWindowNWidgetTree(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, int *biggest_index, NWidgetStacked **shade_select)
{
*biggest_index = -1;
/* Read the first widget recursively from the array. */
NWidgetBase *nwid = nullptr;
int num_used = MakeWidgetTree(parts, count, &nwid, biggest_index);
int num_used = MakeWidgetTree(nwid_begin, nwid_end, &nwid, biggest_index);
assert(nwid != nullptr);
parts += num_used;
count -= num_used;
nwid_begin += num_used;
NWidgetContainer *root = new NWidgetVertical;
root->Add(nwid);
if (count == 0) { // There is no body at all.
if (nwid_begin == nwid_end) { // There is no body at all.
*shade_select = nullptr;
return root;
}
@ -3318,7 +3317,7 @@ NWidgetContainer *MakeWindowNWidgetTree(const NWidgetPart *parts, int count, int
/* Load the remaining parts into 'body'. */
int biggest2 = -1;
MakeNWidgets(parts, count, &biggest2, body);
MakeNWidgets(nwid_begin, nwid_end, &biggest2, body);
*biggest_index = std::max(*biggest_index, biggest2);
return root;

View File

@ -1296,8 +1296,8 @@ static inline NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
return part;
}
NWidgetContainer *MakeNWidgets(const NWidgetPart *parts, int count, int *biggest_index, NWidgetContainer *container);
NWidgetContainer *MakeWindowNWidgetTree(const NWidgetPart *parts, int count, int *biggest_index, NWidgetStacked **shade_select);
NWidgetContainer *MakeNWidgets(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, int *biggest_index, NWidgetContainer *container);
NWidgetContainer *MakeWindowNWidgetTree(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, int *biggest_index, NWidgetStacked **shade_select);
NWidgetBase *MakeCompanyButtonRows(int *biggest_index, int widget_first, int widget_last, Colours button_colour, int max_length, StringID button_tooltip);

View File

@ -104,7 +104,7 @@ static WindowDesc _dropdown_desc(
WDP_MANUAL, nullptr, 0, 0,
WC_DROPDOWN_MENU, WC_NONE,
WDF_NO_FOCUS,
_nested_dropdown_menu_widgets, lengthof(_nested_dropdown_menu_widgets)
std::begin(_nested_dropdown_menu_widgets), std::end(_nested_dropdown_menu_widgets)
);
/** Drop-down menu window */

View File

@ -104,14 +104,14 @@ std::string _windows_file;
/** Window description constructor. */
WindowDesc::WindowDesc(WindowPosition def_pos, const char *ini_key, int16_t def_width_trad, int16_t def_height_trad,
WindowClass window_class, WindowClass parent_class, uint32_t flags,
const NWidgetPart *nwid_parts, int16_t nwid_length, HotkeyList *hotkeys) :
const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, HotkeyList *hotkeys) :
default_pos(def_pos),
cls(window_class),
parent_cls(parent_class),
ini_key(ini_key),
flags(flags),
nwid_parts(nwid_parts),
nwid_length(nwid_length),
nwid_begin(nwid_begin),
nwid_end(nwid_end),
hotkeys(hotkeys),
pref_sticky(false),
pref_width(0),
@ -1798,7 +1798,7 @@ static Point LocalGetWindowPlacement(const WindowDesc *desc, int16_t sm_width, i
void Window::CreateNestedTree(bool fill_nested)
{
int biggest_index = -1;
this->nested_root = MakeWindowNWidgetTree(this->window_desc->nwid_parts, this->window_desc->nwid_length, &biggest_index, &this->shade_select);
this->nested_root = MakeWindowNWidgetTree(this->window_desc->nwid_begin, this->window_desc->nwid_end, &biggest_index, &this->shade_select);
this->nested_array_size = (uint)(biggest_index + 1);
if (fill_nested) {

View File

@ -97,7 +97,7 @@ struct WindowDesc : ZeroedMemoryAllocator {
WindowDesc(WindowPosition default_pos, const char *ini_key, int16_t def_width_trad, int16_t def_height_trad,
WindowClass window_class, WindowClass parent_class, uint32_t flags,
const NWidgetPart *nwid_parts, int16_t nwid_length, HotkeyList *hotkeys = nullptr);
const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, HotkeyList *hotkeys = nullptr);
~WindowDesc();
@ -106,8 +106,8 @@ struct WindowDesc : ZeroedMemoryAllocator {
WindowClass parent_cls; ///< Class of the parent window. @see WindowClass
const char *ini_key; ///< Key to store window defaults in openttd.cfg. \c nullptr if nothing shall be stored.
uint32_t flags; ///< Flags. @see WindowDefaultFlag
const NWidgetPart *nwid_parts; ///< Nested widget parts describing the window.
int16_t nwid_length; ///< Length of the #nwid_parts array.
const NWidgetPart *nwid_begin; ///< Beginning of nested widget parts describing the window.
const NWidgetPart *nwid_end; ///< Ending of nested widget parts describing the window.
HotkeyList *hotkeys; ///< Hotkeys for the window.
bool pref_sticky; ///< Preferred stickyness.