From 4cf6d1dd796499d3b7afaf25c970f8943aa25c77 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Tue, 11 Jun 2024 08:58:03 +0100 Subject: [PATCH] Codechange: Pass WindowDesc by reference instead of pointer. (#12771) WindowDesc as passed to Windows is not optional so don't allow to it to be nullptr. --- src/ai/ai_gui.cpp | 2 +- src/airport_gui.cpp | 8 ++-- src/autoreplace_gui.cpp | 10 ++--- src/bootstrap_gui.cpp | 8 ++-- src/bridge_gui.cpp | 4 +- src/build_vehicle_gui.cpp | 4 +- src/cheat_gui.cpp | 4 +- src/company_gui.cpp | 24 +++++------ src/console_gui.cpp | 2 +- src/date_gui.cpp | 4 +- src/depot_gui.cpp | 13 +++--- src/dock_gui.cpp | 14 +++---- src/dropdown.cpp | 2 +- src/engine_gui.cpp | 4 +- src/error_gui.cpp | 2 +- src/fios_gui.cpp | 9 ++--- src/framerate_gui.cpp | 8 ++-- src/game/game_gui.cpp | 2 +- src/genworld_gui.cpp | 10 ++--- src/goal_gui.cpp | 8 ++-- src/graph_gui.cpp | 34 ++++++++-------- src/group_gui.cpp | 6 +-- src/help_gui.cpp | 4 +- src/highscore_gui.cpp | 10 ++--- src/industry_gui.cpp | 12 +++--- src/intro_gui.cpp | 4 +- src/league_gui.cpp | 8 ++-- src/linkgraph/linkgraph_gui.cpp | 4 +- src/linkgraph/linkgraph_gui.h | 2 +- src/main_gui.cpp | 4 +- src/misc_gui.cpp | 14 +++---- src/music_gui.cpp | 8 ++-- src/network/network_chat_gui.cpp | 4 +- src/network/network_content_gui.cpp | 8 ++-- src/network/network_content_gui.h | 2 +- src/network/network_gui.cpp | 24 +++++------ src/newgrf_debug_gui.cpp | 8 ++-- src/newgrf_gui.cpp | 12 +++--- src/news_gui.cpp | 12 +++--- src/object_gui.cpp | 4 +- src/order_gui.cpp | 6 +-- src/osk_gui.cpp | 4 +- src/picker_gui.cpp | 2 +- src/picker_gui.h | 2 +- src/rail_gui.cpp | 20 +++++----- src/road_gui.cpp | 14 +++---- src/screenshot_gui.cpp | 4 +- src/script/script_gui.cpp | 12 +++--- src/settings_gui.cpp | 12 +++--- src/signs_gui.cpp | 8 ++-- src/smallmap_gui.cpp | 4 +- src/station_gui.cpp | 12 +++--- src/statusbar_gui.cpp | 4 +- src/story_gui.cpp | 4 +- src/subsidy_gui.cpp | 4 +- src/terraform_gui.cpp | 10 ++--- src/textfile_gui.cpp | 2 +- src/timetable_gui.cpp | 4 +- src/toolbar_gui.cpp | 8 ++-- src/town_gui.cpp | 22 +++++----- src/transparency_gui.cpp | 4 +- src/tree_gui.cpp | 4 +- src/vehicle_gui.cpp | 20 +++++----- src/vehicle_gui_base.h | 2 +- src/viewport_gui.cpp | 4 +- src/waypoint_gui.cpp | 4 +- src/window.cpp | 62 ++++++++++++++--------------- src/window_gui.h | 10 ++--- 68 files changed, 293 insertions(+), 301 deletions(-) diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index 9bdf53a1de7f7..3568f704103e4 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -97,7 +97,7 @@ struct AIConfigWindow : public Window { int line_height; ///< Height of a single AI-name line. Scrollbar *vscroll; ///< Cache of the vertical scrollbar. - AIConfigWindow() : Window(&_ai_config_desc) + AIConfigWindow() : Window(_ai_config_desc) { this->InitNested(WN_GAME_OPTIONS_AI); // Initializes 'this->line_height' as a side effect. this->vscroll = this->GetScrollbar(WID_AIC_SCROLLBAR); diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index c592d8c9cf649..83ed73ee3e085 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -83,7 +83,7 @@ static void PlaceAirport(TileIndex tile) struct BuildAirToolbarWindow : Window { int last_user_action; // Last started user action. - BuildAirToolbarWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) + BuildAirToolbarWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc) { this->InitNested(window_number); this->OnInvalidateData(); @@ -228,7 +228,7 @@ Window *ShowBuildAirToolbar() if (!Company::IsValidID(_local_company)) return nullptr; CloseWindowByClass(WC_BUILD_TOOLBAR); - return AllocateWindowDescFront(&_air_toolbar_desc, TRANSPORT_AIR); + return AllocateWindowDescFront(_air_toolbar_desc, TRANSPORT_AIR); } class BuildAirportWindow : public PickerWindowBase { @@ -249,7 +249,7 @@ class BuildAirportWindow : public PickerWindowBase { } public: - BuildAirportWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) + BuildAirportWindow(WindowDesc &desc, Window *parent) : PickerWindowBase(desc, parent) { this->CreateNestedTree(); @@ -626,7 +626,7 @@ static WindowDesc _build_airport_desc( static void ShowBuildAirportPicker(Window *parent) { - new BuildAirportWindow(&_build_airport_desc, parent); + new BuildAirportWindow(_build_airport_desc, parent); } void InitializeAirportGui() diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index eab2b141176a9..eba70f9449756 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -263,7 +263,7 @@ class ReplaceVehicleWindow : public Window { } public: - ReplaceVehicleWindow(WindowDesc *desc, VehicleType vehicletype, GroupID id_g) : Window(desc) + ReplaceVehicleWindow(WindowDesc &desc, VehicleType vehicletype, GroupID id_g) : Window(desc) { this->sel_railtype = INVALID_RAILTYPE; this->sel_roadtype = INVALID_ROADTYPE; @@ -889,11 +889,9 @@ static WindowDesc _replace_vehicle_desc( void ShowReplaceGroupVehicleWindow(GroupID id_g, VehicleType vehicletype) { CloseWindowById(WC_REPLACE_VEHICLE, vehicletype); - WindowDesc *desc; switch (vehicletype) { - case VEH_TRAIN: desc = &_replace_rail_vehicle_desc; break; - case VEH_ROAD: desc = &_replace_road_vehicle_desc; break; - default: desc = &_replace_vehicle_desc; break; + case VEH_TRAIN: new ReplaceVehicleWindow(_replace_rail_vehicle_desc, vehicletype, id_g); break; + case VEH_ROAD: new ReplaceVehicleWindow(_replace_road_vehicle_desc, vehicletype, id_g); break; + default: new ReplaceVehicleWindow(_replace_vehicle_desc, vehicletype, id_g); break; } - new ReplaceVehicleWindow(desc, vehicletype, id_g); } diff --git a/src/bootstrap_gui.cpp b/src/bootstrap_gui.cpp index 3f19c7fae0a83..18a3ebb7f45cc 100644 --- a/src/bootstrap_gui.cpp +++ b/src/bootstrap_gui.cpp @@ -50,7 +50,7 @@ static WindowDesc _background_desc( /** The background for the game. */ class BootstrapBackground : public Window { public: - BootstrapBackground() : Window(&_background_desc) + BootstrapBackground() : Window(_background_desc) { this->InitNested(0); CLRBITS(this->flags, WF_WHITE_BORDER); @@ -86,7 +86,7 @@ static WindowDesc _bootstrap_errmsg_desc( /** The window for a failed bootstrap. */ class BootstrapErrorWindow : public Window { public: - BootstrapErrorWindow() : Window(&_bootstrap_errmsg_desc) + BootstrapErrorWindow() : Window(_bootstrap_errmsg_desc) { this->InitNested(1); } @@ -145,7 +145,7 @@ static WindowDesc _bootstrap_download_status_window_desc( struct BootstrapContentDownloadStatusWindow : public BaseNetworkContentDownloadStatusWindow { public: /** Simple call the constructor of the superclass. */ - BootstrapContentDownloadStatusWindow() : BaseNetworkContentDownloadStatusWindow(&_bootstrap_download_status_window_desc) + BootstrapContentDownloadStatusWindow() : BaseNetworkContentDownloadStatusWindow(_bootstrap_download_status_window_desc) { } @@ -198,7 +198,7 @@ class BootstrapAskForDownloadWindow : public Window, ContentCallback { public: /** Start listening to the content client events. */ - BootstrapAskForDownloadWindow() : Window(&_bootstrap_query_desc) + BootstrapAskForDownloadWindow() : Window(_bootstrap_query_desc) { this->InitNested(WN_CONFIRM_POPUP_QUERY_BOOTSTRAP); _network_content_client.AddCallback(this); diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index 023411b115752..b6decec50b9ce 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -151,7 +151,7 @@ class BuildBridgeWindow : public Window { } public: - BuildBridgeWindow(WindowDesc *desc, TileIndex start, TileIndex end, TransportType transport_type, uint8_t road_rail_type, GUIBridgeList &&bl) : Window(desc), + BuildBridgeWindow(WindowDesc &desc, TileIndex start, TileIndex end, TransportType transport_type, uint8_t road_rail_type, GUIBridgeList &&bl) : Window(desc), start_tile(start), end_tile(end), transport_type(transport_type), @@ -435,7 +435,7 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo } if (!bl.empty()) { - new BuildBridgeWindow(&_build_bridge_desc, start, end, transport_type, road_rail_type, std::move(bl)); + new BuildBridgeWindow(_build_bridge_desc, start, end, transport_type, road_rail_type, std::move(bl)); } else { ShowErrorMessage(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE, errmsg, WL_INFO, TileX(end) * TILE_SIZE, TileY(end) * TILE_SIZE); } diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 12934979ef9be..9040a3cfd6acf 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -1201,7 +1201,7 @@ struct BuildVehicleWindow : Window { } } - BuildVehicleWindow(WindowDesc *desc, TileIndex tile, VehicleType type) : Window(desc), vehicle_editbox(MAX_LENGTH_VEHICLE_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_VEHICLE_NAME_CHARS) + BuildVehicleWindow(WindowDesc &desc, TileIndex tile, VehicleType type) : Window(desc), vehicle_editbox(MAX_LENGTH_VEHICLE_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_VEHICLE_NAME_CHARS) { this->vehicle_type = type; this->listview_mode = tile == INVALID_TILE; @@ -1938,5 +1938,5 @@ void ShowBuildVehicleWindow(TileIndex tile, VehicleType type) CloseWindowById(WC_BUILD_VEHICLE, num); - new BuildVehicleWindow(&_build_vehicle_desc, tile, type); + new BuildVehicleWindow(_build_vehicle_desc, tile, type); } diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp index 1e7dbaa3d2dca..e7fb3caa04a2f 100644 --- a/src/cheat_gui.cpp +++ b/src/cheat_gui.cpp @@ -230,7 +230,7 @@ struct CheatWindow : Window { uint line_height; Dimension icon; ///< Dimension of company icon sprite - CheatWindow(WindowDesc *desc) : Window(desc) + CheatWindow(WindowDesc &desc) : Window(desc) { this->InitNested(); } @@ -436,5 +436,5 @@ static WindowDesc _cheats_desc( void ShowCheatWindow() { CloseWindowById(WC_CHEATS, 0); - new CheatWindow(&_cheats_desc); + new CheatWindow(_cheats_desc); } diff --git a/src/company_gui.cpp b/src/company_gui.cpp index c68e9d26e06d1..47d49385f4bb6 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -336,7 +336,7 @@ struct CompanyFinancesWindow : Window { static Money max_money; ///< The maximum amount of money a company has had this 'run' bool small; ///< Window is toggled to 'small'. - CompanyFinancesWindow(WindowDesc *desc, CompanyID company) : Window(desc) + CompanyFinancesWindow(WindowDesc &desc, CompanyID company) : Window(desc) { this->small = false; this->CreateNestedTree(); @@ -548,7 +548,7 @@ void ShowCompanyFinances(CompanyID company) if (!Company::IsValidID(company)) return; if (BringWindowToFrontById(WC_FINANCES, company)) return; - new CompanyFinancesWindow(&_company_finances_desc, company); + new CompanyFinancesWindow(_company_finances_desc, company); } /* Association of liveries to livery classes */ @@ -670,7 +670,7 @@ struct SelectCompanyLiveryWindow : public Window { } public: - SelectCompanyLiveryWindow(WindowDesc *desc, CompanyID company, GroupID group) : Window(desc) + SelectCompanyLiveryWindow(WindowDesc &desc, CompanyID company, GroupID group) : Window(desc) { this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_SCL_MATRIX_SCROLLBAR); @@ -1089,7 +1089,7 @@ void ShowCompanyLiveryWindow(CompanyID company, GroupID group) { SelectCompanyLiveryWindow *w = (SelectCompanyLiveryWindow *)BringWindowToFrontById(WC_COMPANY_COLOUR, company); if (w == nullptr) { - new SelectCompanyLiveryWindow(&_select_company_livery_desc, company, group); + new SelectCompanyLiveryWindow(_select_company_livery_desc, company, group); } else if (group != INVALID_GROUP) { w->SetSelectedGroup(company, group); } @@ -1349,7 +1349,7 @@ class SelectCompanyManagerFaceWindow : public Window } public: - SelectCompanyManagerFaceWindow(WindowDesc *desc, Window *parent) : Window(desc) + SelectCompanyManagerFaceWindow(WindowDesc &desc, Window *parent) : Window(desc) { this->advanced = false; this->CreateNestedTree(); @@ -1720,7 +1720,7 @@ static void DoSelectCompanyManagerFace(Window *parent) if (!Company::IsValidID((CompanyID)parent->window_number)) return; if (BringWindowToFrontById(WC_COMPANY_MANAGER_FACE, parent->window_number)) return; - new SelectCompanyManagerFaceWindow(&_select_company_manager_face_desc, parent); + new SelectCompanyManagerFaceWindow(_select_company_manager_face_desc, parent); } static constexpr NWidgetPart _nested_company_infrastructure_widgets[] = { @@ -1770,7 +1770,7 @@ struct CompanyInfrastructureWindow : Window uint total_width; ///< String width of the total cost line. - CompanyInfrastructureWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) + CompanyInfrastructureWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc) { this->UpdateRailRoadTypes(); @@ -2094,7 +2094,7 @@ static WindowDesc _company_infrastructure_desc( static void ShowCompanyInfrastructure(CompanyID company) { if (!Company::IsValidID(company)) return; - AllocateWindowDescFront(&_company_infrastructure_desc, company); + AllocateWindowDescFront(_company_infrastructure_desc, company); } static constexpr NWidgetPart _nested_company_widgets[] = { @@ -2196,7 +2196,7 @@ struct CompanyWindow : Window CWP_RELOCATE_HIDE, ///< Hide the relocate HQ button. }; - CompanyWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) + CompanyWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc) { this->InitNested(window_number); this->owner = (Owner)this->window_number; @@ -2567,7 +2567,7 @@ void ShowCompany(CompanyID company) { if (!Company::IsValidID(company)) return; - AllocateWindowDescFront(&_company_desc, company); + AllocateWindowDescFront(_company_desc, company); } /** @@ -2581,7 +2581,7 @@ void DirtyCompanyInfrastructureWindows(CompanyID company) } struct BuyCompanyWindow : Window { - BuyCompanyWindow(WindowDesc *desc, WindowNumber window_number, bool hostile_takeover) : Window(desc), hostile_takeover(hostile_takeover) + BuyCompanyWindow(WindowDesc &desc, WindowNumber window_number, bool hostile_takeover) : Window(desc), hostile_takeover(hostile_takeover) { this->InitNested(window_number); @@ -2702,6 +2702,6 @@ void ShowBuyCompanyDialog(CompanyID company, bool hostile_takeover) { auto window = BringWindowToFrontById(WC_BUY_COMPANY, company); if (window == nullptr) { - new BuyCompanyWindow(&_buy_company_desc, company, hostile_takeover); + new BuyCompanyWindow(_buy_company_desc, company, hostile_takeover); } } diff --git a/src/console_gui.cpp b/src/console_gui.cpp index 14f8ac7ec2b89..0f496dac1ab1d 100644 --- a/src/console_gui.cpp +++ b/src/console_gui.cpp @@ -154,7 +154,7 @@ struct IConsoleWindow : Window int line_offset; int cursor_width; - IConsoleWindow() : Window(&_console_window_desc) + IConsoleWindow() : Window(_console_window_desc) { _iconsole_mode = ICONSOLE_OPENED; diff --git a/src/date_gui.cpp b/src/date_gui.cpp index 7faad2acf2897..2a7c568e1bd40 100644 --- a/src/date_gui.cpp +++ b/src/date_gui.cpp @@ -40,7 +40,7 @@ struct SetDateWindow : Window { * @param max_year the maximum year (inclusive) to show in the year dropdown * @param callback the callback to call once a date has been selected */ - SetDateWindow(WindowDesc *desc, WindowNumber window_number, Window *parent, TimerGameEconomy::Date initial_date, TimerGameEconomy::Year min_year, TimerGameEconomy::Year max_year, SetDateCallback *callback, void *callback_data) : + SetDateWindow(WindowDesc &desc, WindowNumber window_number, Window *parent, TimerGameEconomy::Date initial_date, TimerGameEconomy::Year min_year, TimerGameEconomy::Year max_year, SetDateCallback *callback, void *callback_data) : Window(desc), callback(callback), callback_data(callback_data), @@ -216,5 +216,5 @@ static WindowDesc _set_date_desc( void ShowSetDateWindow(Window *parent, int window_number, TimerGameEconomy::Date initial_date, TimerGameEconomy::Year min_year, TimerGameEconomy::Year max_year, SetDateCallback *callback, void *callback_data) { CloseWindowByClass(WC_SET_DATE); - new SetDateWindow(&_set_date_desc, window_number, parent, initial_date, min_year, max_year, callback, callback_data); + new SetDateWindow(_set_date_desc, window_number, parent, initial_date, min_year, max_year, callback, callback_data); } diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index dd9def04432c4..de5107cec0b4b 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -266,7 +266,7 @@ struct DepotWindow : Window { Scrollbar *hscroll; ///< Only for trains. Scrollbar *vscroll; - DepotWindow(WindowDesc *desc, TileIndex tile, VehicleType type) : Window(desc) + DepotWindow(WindowDesc &desc, TileIndex tile, VehicleType type) : Window(desc) { assert(IsCompanyBuildableVehicleType(type)); // ensure that we make the call with a valid type @@ -1142,16 +1142,13 @@ void ShowDepotWindow(TileIndex tile, VehicleType type) { if (BringWindowToFrontById(WC_VEHICLE_DEPOT, tile) != nullptr) return; - WindowDesc *desc; switch (type) { default: NOT_REACHED(); - case VEH_TRAIN: desc = &_train_depot_desc; break; - case VEH_ROAD: desc = &_road_depot_desc; break; - case VEH_SHIP: desc = &_ship_depot_desc; break; - case VEH_AIRCRAFT: desc = &_aircraft_depot_desc; break; + case VEH_TRAIN: new DepotWindow(_train_depot_desc, tile, type); break; + case VEH_ROAD: new DepotWindow(_road_depot_desc, tile, type); break; + case VEH_SHIP: new DepotWindow(_ship_depot_desc, tile, type); break; + case VEH_AIRCRAFT: new DepotWindow(_aircraft_depot_desc, tile, type); break; } - - new DepotWindow(desc, tile, type); } /** diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index 8772a0baa5ba9..673762dd4e33e 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -100,7 +100,7 @@ static TileIndex GetOtherAqueductEnd(TileIndex tile_from, TileIndex *tile_to = n struct BuildDocksToolbarWindow : Window { DockToolbarWidgets last_clicked_widget; ///< Contains the last widget that has been clicked on this toolbar. - BuildDocksToolbarWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) + BuildDocksToolbarWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc) { this->last_clicked_widget = WID_DT_INVALID; this->InitNested(window_number); @@ -364,7 +364,7 @@ Window *ShowBuildDocksToolbar() if (!Company::IsValidID(_local_company)) return nullptr; CloseWindowByClass(WC_BUILD_TOOLBAR); - return AllocateWindowDescFront(&_build_docks_toolbar_desc, TRANSPORT_WATER); + return AllocateWindowDescFront(_build_docks_toolbar_desc, TRANSPORT_WATER); } /** @@ -402,7 +402,7 @@ static WindowDesc _build_docks_scen_toolbar_desc( */ Window *ShowBuildDocksScenToolbar() { - return AllocateWindowDescFront(&_build_docks_scen_toolbar_desc, TRANSPORT_WATER); + return AllocateWindowDescFront(_build_docks_scen_toolbar_desc, TRANSPORT_WATER); } /** Widget numbers of the build-dock GUI. */ @@ -416,7 +416,7 @@ enum BuildDockStationWidgets { struct BuildDocksStationWindow : public PickerWindowBase { public: - BuildDocksStationWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) + BuildDocksStationWindow(WindowDesc &desc, Window *parent) : PickerWindowBase(desc, parent) { this->InitNested(TRANSPORT_WATER); this->LowerWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF); @@ -507,7 +507,7 @@ static WindowDesc _build_dock_station_desc( static void ShowBuildDockStationPicker(Window *parent) { - new BuildDocksStationWindow(&_build_dock_station_desc, parent); + new BuildDocksStationWindow(_build_dock_station_desc, parent); } struct BuildDocksDepotWindow : public PickerWindowBase { @@ -522,7 +522,7 @@ struct BuildDocksDepotWindow : public PickerWindowBase { } public: - BuildDocksDepotWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) + BuildDocksDepotWindow(WindowDesc &desc, Window *parent) : PickerWindowBase(desc, parent) { this->InitNested(TRANSPORT_WATER); this->LowerWidget(WID_BDD_X + _ship_depot_direction); @@ -603,7 +603,7 @@ static WindowDesc _build_docks_depot_desc( static void ShowBuildDocksDepotPicker(Window *parent) { - new BuildDocksDepotWindow(&_build_docks_depot_desc, parent); + new BuildDocksDepotWindow(_build_docks_depot_desc, parent); } diff --git a/src/dropdown.cpp b/src/dropdown.cpp index 2e1cd43452f90..3eba2fb835f4c 100644 --- a/src/dropdown.cpp +++ b/src/dropdown.cpp @@ -96,7 +96,7 @@ struct DropdownWindow : Window { * @param persist Dropdown menu will persist. */ DropdownWindow(Window *parent, DropDownList &&list, int selected, WidgetID button, const Rect wi_rect, bool instant_close, Colours wi_colour, bool persist) - : Window(&_dropdown_desc) + : Window(_dropdown_desc) , parent_button(button) , wi_rect(wi_rect) , list(std::move(list)) diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index 172b22f507cf4..31e5f68fac9ce 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -70,7 +70,7 @@ static constexpr NWidgetPart _nested_engine_preview_widgets[] = { struct EnginePreviewWindow : Window { int vehicle_space; // The space to show the vehicle image - EnginePreviewWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) + EnginePreviewWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc) { this->InitNested(window_number); @@ -154,7 +154,7 @@ static WindowDesc _engine_preview_desc( void ShowEnginePreviewWindow(EngineID engine) { - AllocateWindowDescFront(&_engine_preview_desc, engine); + AllocateWindowDescFront(_engine_preview_desc, engine); } /** diff --git a/src/error_gui.cpp b/src/error_gui.cpp index e702cdf13327e..982101fc50ef5 100644 --- a/src/error_gui.cpp +++ b/src/error_gui.cpp @@ -175,7 +175,7 @@ struct ErrmsgWindow : public Window, ErrorMessageData { public: ErrmsgWindow(const ErrorMessageData &data) : - Window(data.HasFace() ? &_errmsg_face_desc : &_errmsg_desc), + Window(data.HasFace() ? _errmsg_face_desc : _errmsg_desc), ErrorMessageData(data), display_timeout(std::chrono::seconds(3 * _settings_client.gui.errmsg_duration), [this]() { this->Close(); diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index 311f095703fc3..2db7745c65075 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -302,7 +302,7 @@ struct SaveLoadWindow : public Window { this->filename_editbox.text.Assign(GenerateDefaultSaveName()); } - SaveLoadWindow(WindowDesc *desc, AbstractFileType abstract_filetype, SaveLoadOperation fop) + SaveLoadWindow(WindowDesc &desc, AbstractFileType abstract_filetype, SaveLoadOperation fop) : Window(desc), filename_editbox(64), abstract_filetype(abstract_filetype), fop(fop), filter_editbox(EDITBOX_MAX_SIZE) { assert(this->fop == SLO_SAVE || this->fop == SLO_LOAD); @@ -915,13 +915,10 @@ void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fo { CloseWindowById(WC_SAVELOAD, 0); - WindowDesc *sld; if (fop == SLO_SAVE) { - sld = &_save_dialog_desc; + new SaveLoadWindow(_save_dialog_desc, abstract_filetype, fop); } else { /* Dialogue for loading a file. */ - sld = (abstract_filetype == FT_HEIGHTMAP) ? &_load_heightmap_dialog_desc : &_load_dialog_desc; + new SaveLoadWindow((abstract_filetype == FT_HEIGHTMAP) ? _load_heightmap_dialog_desc : _load_dialog_desc, abstract_filetype, fop); } - - new SaveLoadWindow(sld, abstract_filetype, fop); } diff --git a/src/framerate_gui.cpp b/src/framerate_gui.cpp index 56848b060a604..a2c1a47049461 100644 --- a/src/framerate_gui.cpp +++ b/src/framerate_gui.cpp @@ -448,7 +448,7 @@ struct FramerateWindow : Window { static constexpr int MIN_ELEMENTS = 5; ///< smallest number of elements to display - FramerateWindow(WindowDesc *desc, WindowNumber number) : Window(desc) + FramerateWindow(WindowDesc &desc, WindowNumber number) : Window(desc) { this->InitNested(number); this->small = this->IsShaded(); @@ -755,7 +755,7 @@ struct FrametimeGraphWindow : Window { PerformanceElement element; ///< what element this window renders graph for Dimension graph_size; ///< size of the main graph area (excluding axis labels) - FrametimeGraphWindow(WindowDesc *desc, WindowNumber number) : Window(desc) + FrametimeGraphWindow(WindowDesc &desc, WindowNumber number) : Window(desc) { this->element = (PerformanceElement)number; this->horizontal_scale = 4; @@ -1029,14 +1029,14 @@ static WindowDesc _frametime_graph_window_desc( /** Open the general framerate window */ void ShowFramerateWindow() { - AllocateWindowDescFront(&_framerate_display_desc, 0); + AllocateWindowDescFront(_framerate_display_desc, 0); } /** Open a graph window for a performance element */ void ShowFrametimeGraphWindow(PerformanceElement elem) { if (elem < PFE_FIRST || elem >= PFE_MAX) return; // maybe warn? - AllocateWindowDescFront(&_frametime_graph_window_desc, elem, true); + AllocateWindowDescFront(_frametime_graph_window_desc, elem, true); } /** Print performance statistics to game console */ diff --git a/src/game/game_gui.cpp b/src/game/game_gui.cpp index 7ad4cd7b420be..8f0c1dde2c7f4 100644 --- a/src/game/game_gui.cpp +++ b/src/game/game_gui.cpp @@ -96,7 +96,7 @@ struct GSConfigWindow : public Window { typedef std::vector VisibleSettingsList; ///< typdef for a vector of script settings VisibleSettingsList visible_settings; ///< List of visible GS settings - GSConfigWindow() : Window(&_gs_config_desc), + GSConfigWindow() : Window(_gs_config_desc), clicked_button(-1), clicked_dropdown(false), closing_dropdown(false) diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index e8dfa4b999722..a9da133279cec 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -391,7 +391,7 @@ struct GenerateLandscapeWindow : public Window { std::string name; GenerateLandscapeWindowMode mode; - GenerateLandscapeWindow(WindowDesc *desc, WindowNumber number = 0) : Window(desc) + GenerateLandscapeWindow(WindowDesc &desc, WindowNumber number = 0) : Window(desc) { this->InitNested(number); @@ -1029,7 +1029,7 @@ static void _ShowGenerateLandscape(GenerateLandscapeWindowMode mode) if (!GetHeightmapDimensions(_file_to_saveload.detail_ftype, _file_to_saveload.name.c_str(), &x, &y)) return; } - WindowDesc *desc = (mode == GLWM_HEIGHTMAP) ? &_heightmap_load_desc : &_generate_landscape_desc; + WindowDesc &desc = (mode == GLWM_HEIGHTMAP) ? _heightmap_load_desc : _generate_landscape_desc; GenerateLandscapeWindow *w = AllocateWindowDescFront(desc, mode, true); if (mode == GLWM_HEIGHTMAP) { @@ -1075,7 +1075,7 @@ struct CreateScenarioWindow : public Window { WidgetID widget_id; - CreateScenarioWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) + CreateScenarioWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc) { this->InitNested(window_number); this->LowerWidget(_settings_newgame.game_creation.landscape + WID_CS_TEMPERATE); @@ -1321,7 +1321,7 @@ static WindowDesc _create_scenario_desc( void ShowCreateScenario() { CloseWindowByClass(WC_GENERATE_LANDSCAPE); - new CreateScenarioWindow(&_create_scenario_desc, GLWM_SCENARIO); + new CreateScenarioWindow(_create_scenario_desc, GLWM_SCENARIO); } static constexpr NWidgetPart _nested_generate_progress_widgets[] = { @@ -1381,7 +1381,7 @@ static void AbortGeneratingWorldCallback(Window *, bool confirmed) struct GenerateProgressWindow : public Window { - GenerateProgressWindow() : Window(&_generate_progress_desc) + GenerateProgressWindow() : Window(_generate_progress_desc) { this->InitNested(); } diff --git a/src/goal_gui.cpp b/src/goal_gui.cpp index afbbd953d5eda..9104abfad34c0 100644 --- a/src/goal_gui.cpp +++ b/src/goal_gui.cpp @@ -40,7 +40,7 @@ enum GoalColumn { struct GoalListWindow : public Window { Scrollbar *vscroll; ///< Reference to the scrollbar widget. - GoalListWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) + GoalListWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc) { this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_GOAL_SCROLLBAR); @@ -317,7 +317,7 @@ void ShowGoalsList(CompanyID company) { if (!Company::IsValidID(company)) company = (CompanyID)INVALID_COMPANY; - AllocateWindowDescFront(&_goals_list_desc, company); + AllocateWindowDescFront(_goals_list_desc, company); } /** Ask a question about a goal. */ @@ -327,7 +327,7 @@ struct GoalQuestionWindow : public Window { int button[3]; ///< Buttons to display. TextColour colour; ///< Colour of the question text. - GoalQuestionWindow(WindowDesc *desc, WindowNumber window_number, TextColour colour, uint32_t button_mask, const std::string &question) : Window(desc), colour(colour) + GoalQuestionWindow(WindowDesc &desc, WindowNumber window_number, TextColour colour, uint32_t button_mask, const std::string &question) : Window(desc), colour(colour) { this->question = question; @@ -482,5 +482,5 @@ static WindowDesc _goal_question_list_desc[] = { void ShowGoalQuestion(uint16_t id, uint8_t type, uint32_t button_mask, const std::string &question) { assert(type < GQT_END); - new GoalQuestionWindow(&_goal_question_list_desc[type], id, type == 3 ? TC_WHITE : TC_BLACK, button_mask, question); + new GoalQuestionWindow(_goal_question_list_desc[type], id, type == 3 ? TC_WHITE : TC_BLACK, button_mask, question); } diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index e705e3749a5e6..2ec9547f6e265 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -49,7 +49,7 @@ static_assert(static_cast(INT64_MAX_IN_DOUBLE) < INT64_MAX); /****************/ struct GraphLegendWindow : Window { - GraphLegendWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) + GraphLegendWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc) { this->InitNested(window_number); @@ -151,7 +151,7 @@ static WindowDesc _graph_legend_desc( static void ShowGraphLegend() { - AllocateWindowDescFront(&_graph_legend_desc, 0); + AllocateWindowDescFront(_graph_legend_desc, 0); } /** Contains the interval of a graph's data. */ @@ -493,7 +493,7 @@ struct BaseGraphWindow : Window { } - BaseGraphWindow(WindowDesc *desc, StringID format_str_y_axis) : + BaseGraphWindow(WindowDesc &desc, StringID format_str_y_axis) : Window(desc), format_str_y_axis(format_str_y_axis) { @@ -652,7 +652,7 @@ struct BaseGraphWindow : Window { /********************/ struct OperatingProfitGraphWindow : BaseGraphWindow { - OperatingProfitGraphWindow(WindowDesc *desc, WindowNumber window_number) : + OperatingProfitGraphWindow(WindowDesc &desc, WindowNumber window_number) : BaseGraphWindow(desc, STR_JUST_CURRENCY_SHORT) { this->num_on_x_axis = GRAPH_NUM_MONTHS; @@ -702,7 +702,7 @@ static WindowDesc _operating_profit_desc( void ShowOperatingProfitGraph() { - AllocateWindowDescFront(&_operating_profit_desc, 0); + AllocateWindowDescFront(_operating_profit_desc, 0); } @@ -711,7 +711,7 @@ void ShowOperatingProfitGraph() /****************/ struct IncomeGraphWindow : BaseGraphWindow { - IncomeGraphWindow(WindowDesc *desc, WindowNumber window_number) : + IncomeGraphWindow(WindowDesc &desc, WindowNumber window_number) : BaseGraphWindow(desc, STR_JUST_CURRENCY_SHORT) { this->num_on_x_axis = GRAPH_NUM_MONTHS; @@ -760,7 +760,7 @@ static WindowDesc _income_graph_desc( void ShowIncomeGraph() { - AllocateWindowDescFront(&_income_graph_desc, 0); + AllocateWindowDescFront(_income_graph_desc, 0); } /*******************/ @@ -768,7 +768,7 @@ void ShowIncomeGraph() /*******************/ struct DeliveredCargoGraphWindow : BaseGraphWindow { - DeliveredCargoGraphWindow(WindowDesc *desc, WindowNumber window_number) : + DeliveredCargoGraphWindow(WindowDesc &desc, WindowNumber window_number) : BaseGraphWindow(desc, STR_JUST_COMMA) { this->num_on_x_axis = GRAPH_NUM_MONTHS; @@ -817,7 +817,7 @@ static WindowDesc _delivered_cargo_graph_desc( void ShowDeliveredCargoGraph() { - AllocateWindowDescFront(&_delivered_cargo_graph_desc, 0); + AllocateWindowDescFront(_delivered_cargo_graph_desc, 0); } /***********************/ @@ -825,7 +825,7 @@ void ShowDeliveredCargoGraph() /***********************/ struct PerformanceHistoryGraphWindow : BaseGraphWindow { - PerformanceHistoryGraphWindow(WindowDesc *desc, WindowNumber window_number) : + PerformanceHistoryGraphWindow(WindowDesc &desc, WindowNumber window_number) : BaseGraphWindow(desc, STR_JUST_COMMA) { this->num_on_x_axis = GRAPH_NUM_MONTHS; @@ -881,7 +881,7 @@ static WindowDesc _performance_history_desc( void ShowPerformanceHistoryGraph() { - AllocateWindowDescFront(&_performance_history_desc, 0); + AllocateWindowDescFront(_performance_history_desc, 0); } /*****************/ @@ -889,7 +889,7 @@ void ShowPerformanceHistoryGraph() /*****************/ struct CompanyValueGraphWindow : BaseGraphWindow { - CompanyValueGraphWindow(WindowDesc *desc, WindowNumber window_number) : + CompanyValueGraphWindow(WindowDesc &desc, WindowNumber window_number) : BaseGraphWindow(desc, STR_JUST_CURRENCY_SHORT) { this->num_on_x_axis = GRAPH_NUM_MONTHS; @@ -938,7 +938,7 @@ static WindowDesc _company_value_graph_desc( void ShowCompanyValueGraph() { - AllocateWindowDescFront(&_company_value_graph_desc, 0); + AllocateWindowDescFront(_company_value_graph_desc, 0); } /*****************/ @@ -950,7 +950,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { Scrollbar *vscroll; ///< Cargo list scrollbar. uint legend_width; ///< Width of legend 'blob'. - PaymentRatesGraphWindow(WindowDesc *desc, WindowNumber window_number) : + PaymentRatesGraphWindow(WindowDesc &desc, WindowNumber window_number) : BaseGraphWindow(desc, STR_JUST_CURRENCY_SHORT) { this->num_on_x_axis = 20; @@ -1176,7 +1176,7 @@ static WindowDesc _cargo_payment_rates_desc( void ShowCargoPaymentRates() { - AllocateWindowDescFront(&_cargo_payment_rates_desc, 0); + AllocateWindowDescFront(_cargo_payment_rates_desc, 0); } /*****************************/ @@ -1187,7 +1187,7 @@ struct PerformanceRatingDetailWindow : Window { static CompanyID company; int timeout; - PerformanceRatingDetailWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) + PerformanceRatingDetailWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc) { this->UpdateCompanyStats(); @@ -1470,7 +1470,7 @@ static WindowDesc _performance_rating_detail_desc( void ShowPerformanceRatingDetail() { - AllocateWindowDescFront(&_performance_rating_detail_desc, 0); + AllocateWindowDescFront(_performance_rating_detail_desc, 0); } void InitializeGraphGui() diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 7e68691306b75..089a529203739 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -388,7 +388,7 @@ class VehicleGroupWindow : public BaseVehicleListWindow { } public: - VehicleGroupWindow(WindowDesc *desc, WindowNumber window_number) : BaseVehicleListWindow(desc, window_number) + VehicleGroupWindow(WindowDesc &desc, WindowNumber window_number) : BaseVehicleListWindow(desc, window_number) { this->CreateNestedTree(); @@ -1170,10 +1170,10 @@ void ShowCompanyGroup(CompanyID company, VehicleType vehicle_type, GroupID group const WindowNumber num = VehicleListIdentifier(VL_GROUP_LIST, vehicle_type, company).Pack(); VehicleGroupWindow *w; if (vehicle_type == VEH_TRAIN) { - w = AllocateWindowDescFront(&_train_group_desc, num, need_existing_window); + w = AllocateWindowDescFront(_train_group_desc, num, need_existing_window); } else { _other_group_desc.cls = GetWindowClassForVehicleType(vehicle_type); - w = AllocateWindowDescFront(&_other_group_desc, num, need_existing_window); + w = AllocateWindowDescFront(_other_group_desc, num, need_existing_window); } if (w != nullptr) w->SelectGroup(group); } diff --git a/src/help_gui.cpp b/src/help_gui.cpp index fdf2975393f42..1c6f7fb167a66 100644 --- a/src/help_gui.cpp +++ b/src/help_gui.cpp @@ -121,7 +121,7 @@ struct GameManualTextfileWindow : public TextfileWindow { /** Window class displaying the help window. */ struct HelpWindow : public Window { - HelpWindow(WindowDesc *desc, WindowNumber number) : Window(desc) + HelpWindow(WindowDesc &desc, WindowNumber number) : Window(desc) { this->InitNested(number); @@ -202,5 +202,5 @@ static WindowDesc _helpwin_desc( void ShowHelpWindow() { - AllocateWindowDescFront(&_helpwin_desc, 0); + AllocateWindowDescFront(_helpwin_desc, 0); } diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp index 3cd70d171204b..a8b83774630b9 100644 --- a/src/highscore_gui.cpp +++ b/src/highscore_gui.cpp @@ -33,7 +33,7 @@ struct EndGameHighScoreBaseWindow : Window { uint32_t background_img; int8_t rank; - EndGameHighScoreBaseWindow(WindowDesc *desc) : Window(desc) + EndGameHighScoreBaseWindow(WindowDesc &desc) : Window(desc) { this->InitNested(); CLRBITS(this->flags, WF_WHITE_BORDER); @@ -96,7 +96,7 @@ struct EndGameHighScoreBaseWindow : Window { /** End game window shown at the end of the game */ struct EndGameWindow : EndGameHighScoreBaseWindow { - EndGameWindow(WindowDesc *desc) : EndGameHighScoreBaseWindow(desc) + EndGameWindow(WindowDesc &desc) : EndGameHighScoreBaseWindow(desc) { /* Pause in single-player to have a look at the highscore at your own leisure */ if (!_networking) Command::Post(PM_PAUSED_NORMAL, true); @@ -158,7 +158,7 @@ struct EndGameWindow : EndGameHighScoreBaseWindow { struct HighScoreWindow : EndGameHighScoreBaseWindow { bool game_paused_by_player; ///< True if the game was paused by the player when the highscore window was opened. - HighScoreWindow(WindowDesc *desc, int difficulty, int8_t ranking) : EndGameHighScoreBaseWindow(desc) + HighScoreWindow(WindowDesc &desc, int difficulty, int8_t ranking) : EndGameHighScoreBaseWindow(desc) { /* pause game to show the chart */ this->game_paused_by_player = _pause_mode == PM_PAUSED_NORMAL; @@ -236,7 +236,7 @@ static WindowDesc _endgame_desc( void ShowHighscoreTable(int difficulty, int8_t ranking) { CloseWindowByClass(WC_HIGHSCORE); - new HighScoreWindow(&_highscore_desc, difficulty, ranking); + new HighScoreWindow(_highscore_desc, difficulty, ranking); } /** @@ -250,7 +250,7 @@ void ShowEndGameChart() HideVitalWindows(); CloseWindowByClass(WC_ENDSCREEN); - new EndGameWindow(&_endgame_desc); + new EndGameWindow(_endgame_desc); } static IntervalTimer _check_end_game({TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE}, [](auto) diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 35cc27d837aed..633d0eb118cc5 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -403,7 +403,7 @@ class BuildIndustryWindow : public Window { } public: - BuildIndustryWindow() : Window(&_build_industry_desc) + BuildIndustryWindow() : Window(_build_industry_desc) { this->selected_type = INVALID_INDUSTRYTYPE; @@ -812,7 +812,7 @@ class IndustryViewWindow : public Window int cheat_line_height; ///< Height of each line for the #WID_IV_INFO panel public: - IndustryViewWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) + IndustryViewWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc) { this->flags |= WF_DISABLE_VP_SCROLL; this->editbox_line = IL_NONE; @@ -1226,7 +1226,7 @@ static WindowDesc _industry_view_desc( void ShowIndustryViewWindow(int industry) { - AllocateWindowDescFront(&_industry_view_desc, industry); + AllocateWindowDescFront(_industry_view_desc, industry); } /** Widget definition of the industry directory gui */ @@ -1636,7 +1636,7 @@ class IndustryDirectoryWindow : public Window { } public: - IndustryDirectoryWindow(WindowDesc *desc, WindowNumber) : Window(desc), industry_editbox(MAX_FILTER_LENGTH * MAX_CHAR_LENGTH, MAX_FILTER_LENGTH) + IndustryDirectoryWindow(WindowDesc &desc, WindowNumber) : Window(desc), industry_editbox(MAX_FILTER_LENGTH * MAX_CHAR_LENGTH, MAX_FILTER_LENGTH) { this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_ID_VSCROLLBAR); @@ -1925,7 +1925,7 @@ static WindowDesc _industry_directory_desc( void ShowIndustryDirectory() { - AllocateWindowDescFront(&_industry_directory_desc, 0); + AllocateWindowDescFront(_industry_directory_desc, 0); } /** Widgets of the industry cargoes window. */ @@ -2542,7 +2542,7 @@ struct IndustryCargoesWindow : public Window { Dimension ind_textsize; ///< Size to hold any industry type text, as well as STR_INDUSTRY_CARGOES_SELECT_INDUSTRY. Scrollbar *vscroll; - IndustryCargoesWindow(int id) : Window(&_industry_cargoes_desc) + IndustryCargoesWindow(int id) : Window(_industry_cargoes_desc) { this->OnInit(); this->CreateNestedTree(); diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp index 092c5964aee83..713031e5dab14 100644 --- a/src/intro_gui.cpp +++ b/src/intro_gui.cpp @@ -176,7 +176,7 @@ struct SelectGameWindow : public Window { } } - SelectGameWindow(WindowDesc *desc) : Window(desc) + SelectGameWindow(WindowDesc &desc) : Window(desc) { this->CreateNestedTree(); this->FinishInitNested(0); @@ -465,7 +465,7 @@ static WindowDesc _select_game_desc( void ShowSelectGameWindow() { - new SelectGameWindow(&_select_game_desc); + new SelectGameWindow(_select_game_desc); } static void AskExitGameCallback(Window *, bool confirmed) diff --git a/src/league_gui.cpp b/src/league_gui.cpp index 8b52359c92339..70f23142579c1 100644 --- a/src/league_gui.cpp +++ b/src/league_gui.cpp @@ -86,7 +86,7 @@ class PerformanceLeagueWindow : public Window { } public: - PerformanceLeagueWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) + PerformanceLeagueWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc) { this->InitNested(window_number); this->companies.ForceRebuild(); @@ -209,7 +209,7 @@ static WindowDesc _performance_league_desc( void ShowPerformanceLeagueTable() { - AllocateWindowDescFront(&_performance_league_desc, 0); + AllocateWindowDescFront(_performance_league_desc, 0); } static void HandleLinkClick(Link link) @@ -298,7 +298,7 @@ class ScriptLeagueWindow : public Window { } public: - ScriptLeagueWindow(WindowDesc *desc, LeagueTableID table) : Window(desc) + ScriptLeagueWindow(WindowDesc &desc, LeagueTableID table) : Window(desc) { this->table = table; this->BuildTable(); @@ -445,7 +445,7 @@ static WindowDesc _script_league_desc( void ShowScriptLeagueTable(LeagueTableID table) { if (!LeagueTable::IsValidID(table)) return; - AllocateWindowDescFront(&_script_league_desc, table); + AllocateWindowDescFront(_script_league_desc, table); } void ShowFirstLeagueTable() diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp index 937f24509c9f8..f59797a812128 100644 --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -548,10 +548,10 @@ static WindowDesc _linkgraph_legend_desc( */ void ShowLinkGraphLegend() { - AllocateWindowDescFront(&_linkgraph_legend_desc, 0); + AllocateWindowDescFront(_linkgraph_legend_desc, 0); } -LinkGraphLegendWindow::LinkGraphLegendWindow(WindowDesc *desc, int window_number) : Window(desc) +LinkGraphLegendWindow::LinkGraphLegendWindow(WindowDesc &desc, int window_number) : Window(desc) { this->num_cargo = _sorted_cargo_specs.size(); diff --git a/src/linkgraph/linkgraph_gui.h b/src/linkgraph/linkgraph_gui.h index a8dc91c822e3e..ce7219fe43797 100644 --- a/src/linkgraph/linkgraph_gui.h +++ b/src/linkgraph/linkgraph_gui.h @@ -105,7 +105,7 @@ void ShowLinkGraphLegend(); */ struct LinkGraphLegendWindow : Window { public: - LinkGraphLegendWindow(WindowDesc *desc, int window_number); + LinkGraphLegendWindow(WindowDesc &desc, int window_number); void SetOverlay(std::shared_ptr overlay); void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override; diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 52e5a5491a39a..8a6b7132c9c6e 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -211,7 +211,7 @@ enum { struct MainWindow : Window { - MainWindow(WindowDesc *desc) : Window(desc) + MainWindow(WindowDesc &desc) : Window(desc) { this->InitNested(0); CLRBITS(this->flags, WF_WHITE_BORDER); @@ -548,7 +548,7 @@ void SetupColoursAndInitialWindow() } } - new MainWindow(&_main_window_desc); + new MainWindow(_main_window_desc); /* XXX: these are not done */ switch (_game_mode) { diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index f0de0d1cf4ec2..6c53b5f499096 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -110,7 +110,7 @@ class LandInfoWindow : public Window { } } - LandInfoWindow(Tile tile) : Window(&_land_info_desc), tile(tile) + LandInfoWindow(Tile tile) : Window(_land_info_desc), tile(tile) { this->InitNested(); @@ -477,7 +477,7 @@ struct AboutWindow : public Window { int line_height; ///< The height of a single line static const int num_visible_lines = 19; ///< The number of lines visible simultaneously - AboutWindow() : Window(&_about_desc) + AboutWindow() : Window(_about_desc) { this->InitNested(WN_GAME_OPTIONS_ABOUT); @@ -671,7 +671,7 @@ struct TooltipsWindow : public Window std::vector params; ///< The string parameters. TooltipCloseCondition close_cond; ///< Condition for closing the window. - TooltipsWindow(Window *parent, StringID str, uint paramcount, TooltipCloseCondition close_tooltip) : Window(&_tool_tips_desc) + TooltipsWindow(Window *parent, StringID str, uint paramcount, TooltipCloseCondition close_tooltip) : Window(_tool_tips_desc) { this->parent = parent; this->string_id = str; @@ -971,7 +971,7 @@ struct QueryStringWindow : public Window QueryString editbox; ///< Editbox. QueryStringFlags flags; ///< Flags controlling behaviour of the window. - QueryStringWindow(StringID str, StringID caption, uint max_bytes, uint max_chars, WindowDesc *desc, Window *parent, CharSetFilter afilter, QueryStringFlags flags) : + QueryStringWindow(StringID str, StringID caption, uint max_bytes, uint max_chars, WindowDesc &desc, Window *parent, CharSetFilter afilter, QueryStringFlags flags) : Window(desc), editbox(max_bytes, max_chars) { this->editbox.text.Assign(str); @@ -1081,7 +1081,7 @@ void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *paren assert(parent != nullptr); CloseWindowByClass(WC_QUERY_STRING); - new QueryStringWindow(str, caption, ((flags & QSF_LEN_IN_CHARS) ? MAX_CHAR_LENGTH : 1) * maxsize, maxsize, &_query_string_desc, parent, afilter, flags); + new QueryStringWindow(str, caption, ((flags & QSF_LEN_IN_CHARS) ? MAX_CHAR_LENGTH : 1) * maxsize, maxsize, _query_string_desc, parent, afilter, flags); } /** @@ -1092,7 +1092,7 @@ struct QueryWindow : public Window { std::vector params; ///< local copy of #_global_string_params StringID message; ///< message shown for query window - QueryWindow(WindowDesc *desc, StringID caption, StringID message, Window *parent, QueryCallbackProc *callback) : Window(desc) + QueryWindow(WindowDesc &desc, StringID caption, StringID message, Window *parent, QueryCallbackProc *callback) : Window(desc) { /* Create a backup of the variadic arguments to strings because it will be * overridden pretty often. We will copy these back for drawing */ @@ -1234,6 +1234,6 @@ void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallback break; } - QueryWindow *q = new QueryWindow(&_query_desc, caption, message, parent, callback); + QueryWindow *q = new QueryWindow(_query_desc, caption, message, parent, callback); if (focus) SetFocusedWindow(q); } diff --git a/src/music_gui.cpp b/src/music_gui.cpp index 4f9e5b978d13c..bfac1656ef92d 100644 --- a/src/music_gui.cpp +++ b/src/music_gui.cpp @@ -477,7 +477,7 @@ void InitializeMusic() struct MusicTrackSelectionWindow : public Window { - MusicTrackSelectionWindow(WindowDesc *desc, WindowNumber number) : Window(desc) + MusicTrackSelectionWindow(WindowDesc &desc, WindowNumber number) : Window(desc) { this->InitNested(number); this->LowerWidget(WID_MTS_LIST_LEFT); @@ -676,11 +676,11 @@ static WindowDesc _music_track_selection_desc( static void ShowMusicTrackSelection() { - AllocateWindowDescFront(&_music_track_selection_desc, 0); + AllocateWindowDescFront(_music_track_selection_desc, 0); } struct MusicWindow : public Window { - MusicWindow(WindowDesc *desc, WindowNumber number) : Window(desc) + MusicWindow(WindowDesc &desc, WindowNumber number) : Window(desc) { this->InitNested(number); this->LowerWidget(_settings_client.music.playlist + WID_M_ALL); @@ -935,5 +935,5 @@ static WindowDesc _music_window_desc( void ShowMusicWindow() { - AllocateWindowDescFront(&_music_window_desc, 0); + AllocateWindowDescFront(_music_window_desc, 0); } diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp index 25ab13d932403..c10cf969edd7b 100644 --- a/src/network/network_chat_gui.cpp +++ b/src/network/network_chat_gui.cpp @@ -310,7 +310,7 @@ struct NetworkChatWindow : public Window { * @param type The type of destination. * @param dest The actual destination index. */ - NetworkChatWindow(WindowDesc *desc, DestType type, int dest) + NetworkChatWindow(WindowDesc &desc, DestType type, int dest) : Window(desc), message_editbox(NETWORK_CHAT_LENGTH), chat_tab_completion(&message_editbox.text) { this->dtype = type; @@ -445,5 +445,5 @@ static WindowDesc _chat_window_desc( void ShowNetworkChatQueryWindow(DestType type, int dest) { CloseWindowByClass(WC_SEND_NETWORK_MSG); - new NetworkChatWindow(&_chat_window_desc, type, dest); + new NetworkChatWindow(_chat_window_desc, type, dest); } diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index 8facf62fe4b7d..f20d47090311a 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -101,7 +101,7 @@ static WindowDesc _network_content_download_status_window_desc( std::begin(_nested_network_content_download_status_window_widgets), std::end(_nested_network_content_download_status_window_widgets) ); -BaseNetworkContentDownloadStatusWindow::BaseNetworkContentDownloadStatusWindow(WindowDesc *desc) : +BaseNetworkContentDownloadStatusWindow::BaseNetworkContentDownloadStatusWindow(WindowDesc &desc) : Window(desc), downloaded_bytes(0), downloaded_files(0), cur_id(UINT32_MAX) { _network_content_client.AddCallback(this); @@ -197,7 +197,7 @@ struct NetworkContentDownloadStatusWindow : public BaseNetworkContentDownloadSta * Create a new download window based on a list of content information * with flags whether to download them or not. */ - NetworkContentDownloadStatusWindow() : BaseNetworkContentDownloadStatusWindow(&_network_content_download_status_window_desc) + NetworkContentDownloadStatusWindow() : BaseNetworkContentDownloadStatusWindow(_network_content_download_status_window_desc) { this->parent = FindWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_CONTENT_LIST); } @@ -542,7 +542,7 @@ class NetworkContentListWindow : public Window, ContentCallback { * other types are only shown when content that depend on them are * selected. */ - NetworkContentListWindow(WindowDesc *desc, bool select_all, const std::bitset &types) : + NetworkContentListWindow(WindowDesc &desc, bool select_all, const std::bitset &types) : Window(desc), auto_select(select_all), filter_editbox(EDITBOX_MAX_SIZE), @@ -1144,7 +1144,7 @@ void ShowNetworkContentListWindow(ContentVector *cv, ContentType type1, ContentT } CloseWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_CONTENT_LIST); - new NetworkContentListWindow(&_network_content_list_desc, cv != nullptr, types); + new NetworkContentListWindow(_network_content_list_desc, cv != nullptr, types); #else ShowErrorMessage(STR_CONTENT_NO_ZLIB, STR_CONTENT_NO_ZLIB_SUB, WL_ERROR); /* Connection failed... clean up the mess */ diff --git a/src/network/network_content_gui.h b/src/network/network_content_gui.h index a0f014e239a5a..b32022ec693af 100644 --- a/src/network/network_content_gui.h +++ b/src/network/network_content_gui.h @@ -30,7 +30,7 @@ class BaseNetworkContentDownloadStatusWindow : public Window, ContentCallback { * Create the window with the given description. * @param desc The description of the window. */ - BaseNetworkContentDownloadStatusWindow(WindowDesc *desc); + BaseNetworkContentDownloadStatusWindow(WindowDesc &desc); void Close([[maybe_unused]] int data = 0) override; void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override; diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 7f279f90045d0..13a8ae5d69145 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -430,7 +430,7 @@ class NetworkGameWindow : public Window { } public: - NetworkGameWindow(WindowDesc *desc) : Window(desc), name_editbox(NETWORK_CLIENT_NAME_LENGTH), filter_editbox(120) + NetworkGameWindow(WindowDesc &desc) : Window(desc), name_editbox(NETWORK_CLIENT_NAME_LENGTH), filter_editbox(120) { this->list_pos = SLP_INVALID; this->server = nullptr; @@ -976,14 +976,14 @@ void ShowNetworkGameWindow() } } - new NetworkGameWindow(&_network_game_window_desc); + new NetworkGameWindow(_network_game_window_desc); } struct NetworkStartServerWindow : public Window { WidgetID widget_id; ///< The widget that has the pop-up input menu QueryString name_editbox; ///< Server name editbox. - NetworkStartServerWindow(WindowDesc *desc) : Window(desc), name_editbox(NETWORK_NAME_LENGTH) + NetworkStartServerWindow(WindowDesc &desc) : Window(desc), name_editbox(NETWORK_NAME_LENGTH) { this->InitNested(WN_NETWORK_WINDOW_START); @@ -1235,7 +1235,7 @@ static void ShowNetworkStartServerWindow() CloseWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME); - new NetworkStartServerWindow(&_network_start_server_window_desc); + new NetworkStartServerWindow(_network_start_server_window_desc); } /* The window below gives information about the connected clients @@ -1630,7 +1630,7 @@ struct NetworkClientListWindow : Window { } public: - NetworkClientListWindow(WindowDesc *desc, WindowNumber window_number) : + NetworkClientListWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc), hover_index(-1), player_self_index(-1), @@ -2066,7 +2066,7 @@ struct NetworkClientListWindow : Window { void ShowClientList() { - AllocateWindowDescFront(&_client_list_desc, 0); + AllocateWindowDescFront(_client_list_desc, 0); } NetworkJoinStatus _network_join_status; ///< The status of joining. @@ -2077,7 +2077,7 @@ uint32_t _network_join_bytes_total; ///< The total number of bytes to down struct NetworkJoinStatusWindow : Window { std::shared_ptr request; - NetworkJoinStatusWindow(WindowDesc *desc) : Window(desc) + NetworkJoinStatusWindow(WindowDesc &desc) : Window(desc) { this->parent = FindWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME); this->InitNested(WN_NETWORK_STATUS_WINDOW_JOIN); @@ -2201,7 +2201,7 @@ static WindowDesc _network_join_status_window_desc( void ShowJoinStatusWindow() { CloseWindowById(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN); - new NetworkJoinStatusWindow(&_network_join_status_window_desc); + new NetworkJoinStatusWindow(_network_join_status_window_desc); } void ShowNetworkNeedPassword(std::shared_ptr request) @@ -2221,7 +2221,7 @@ struct NetworkAskRelayWindow : public Window { std::string relay_connection_string; ///< The relay server we want to connect to. std::string token; ///< The token for this connection. - NetworkAskRelayWindow(WindowDesc *desc, Window *parent, const std::string &server_connection_string, const std::string &relay_connection_string, const std::string &token) : + NetworkAskRelayWindow(WindowDesc &desc, Window *parent, const std::string &server_connection_string, const std::string &relay_connection_string, const std::string &token) : Window(desc), server_connection_string(server_connection_string), relay_connection_string(relay_connection_string), @@ -2326,14 +2326,14 @@ void ShowNetworkAskRelay(const std::string &server_connection_string, const std: CloseWindowByClass(WC_NETWORK_ASK_RELAY, NRWCD_HANDLED); Window *parent = GetMainWindow(); - new NetworkAskRelayWindow(&_network_ask_relay_desc, parent, server_connection_string, relay_connection_string, token); + new NetworkAskRelayWindow(_network_ask_relay_desc, parent, server_connection_string, relay_connection_string, token); } /** * Window used for asking if the user wants to participate in the automated survey. */ struct NetworkAskSurveyWindow : public Window { - NetworkAskSurveyWindow(WindowDesc *desc, Window *parent) : + NetworkAskSurveyWindow(WindowDesc &desc, Window *parent) : Window(desc) { this->parent = parent; @@ -2424,7 +2424,7 @@ void ShowNetworkAskSurvey() CloseWindowByClass(WC_NETWORK_ASK_SURVEY); Window *parent = GetMainWindow(); - new NetworkAskSurveyWindow(&_network_ask_survey_desc, parent); + new NetworkAskSurveyWindow(_network_ask_survey_desc, parent); } /** Window for displaying the textfile of a survey result. */ diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index 18ce09797202b..d0f16329e00fb 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -338,7 +338,7 @@ struct NewGRFInspectWindow : Window { if (v == nullptr) this->chain_index = 0; } - NewGRFInspectWindow(WindowDesc *desc, WindowNumber wno) : Window(desc) + NewGRFInspectWindow(WindowDesc &desc, WindowNumber wno) : Window(desc) { this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_NGRFI_SCROLLBAR); @@ -697,7 +697,7 @@ void ShowNewGRFInspectWindow(GrfSpecFeature feature, uint index, const uint32_t if (!IsNewGRFInspectable(feature, index)) return; WindowNumber wno = GetInspectWindowNumber(feature, index); - WindowDesc *desc = (feature == GSF_TRAINS || feature == GSF_ROADVEHICLES) ? &_newgrf_inspect_chain_desc : &_newgrf_inspect_desc; + WindowDesc &desc = (feature == GSF_TRAINS || feature == GSF_ROADVEHICLES) ? _newgrf_inspect_chain_desc : _newgrf_inspect_desc; NewGRFInspectWindow *w = AllocateWindowDescFront(desc, wno, true); w->SetCallerGRFID(grfid); } @@ -813,7 +813,7 @@ struct SpriteAlignerWindow : Window { static bool crosshair; const Action5Type *act5_type = nullptr; ///< Sprite Area of current selected sprite. - SpriteAlignerWindow(WindowDesc *desc, WindowNumber wno) : Window(desc) + SpriteAlignerWindow(WindowDesc &desc, WindowNumber wno) : Window(desc) { /* On first opening, set initial zoom to current zoom level. */ if (SpriteAlignerWindow::zoom == ZOOM_LVL_END) SpriteAlignerWindow::zoom = _gui_zoom; @@ -1212,5 +1212,5 @@ static WindowDesc _sprite_aligner_desc( */ void ShowSpriteAlignerWindow() { - AllocateWindowDescFront(&_sprite_aligner_desc, 0); + AllocateWindowDescFront(_sprite_aligner_desc, 0); } diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index c9c11151fc6c4..c530ed26e5b82 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -156,7 +156,7 @@ struct NewGRFParametersWindow : public Window { bool action14present; ///< True if action14 information is present. bool editable; ///< Allow editing parameters. - NewGRFParametersWindow(WindowDesc *desc, bool is_baseset, GRFConfig *c, bool editable) : Window(desc), + NewGRFParametersWindow(WindowDesc &desc, bool is_baseset, GRFConfig *c, bool editable) : Window(desc), grf_config(c), clicked_button(INT32_MAX), clicked_dropdown(false), @@ -551,7 +551,7 @@ static WindowDesc _newgrf_parameters_desc( void OpenGRFParameterWindow(bool is_baseset, GRFConfig *c, bool editable) { CloseWindowByClass(WC_GRF_PARAMETERS); - new NewGRFParametersWindow(&_newgrf_parameters_desc, is_baseset, c, editable); + new NewGRFParametersWindow(_newgrf_parameters_desc, is_baseset, c, editable); } /** Window for displaying the textfile of a NewGRF. */ @@ -634,7 +634,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { Scrollbar *vscroll; Scrollbar *vscroll2; - NewGRFWindow(WindowDesc *desc, bool editable, bool show_params, bool execute, GRFConfig **orig_list) : Window(desc), filter_editbox(EDITBOX_MAX_SIZE) + NewGRFWindow(WindowDesc &desc, bool editable, bool show_params, bool execute, GRFConfig **orig_list) : Window(desc), filter_editbox(EDITBOX_MAX_SIZE) { this->avail_sel = nullptr; this->avail_pos = -1; @@ -2020,7 +2020,7 @@ static void NewGRFConfirmationCallback(Window *w, bool confirmed) void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config) { CloseWindowByClass(WC_GAME_OPTIONS); - new NewGRFWindow(&_newgrf_desc, editable, show_params, exec_changes, config); + new NewGRFWindow(_newgrf_desc, editable, show_params, exec_changes, config); } /** Widget parts of the save preset window. */ @@ -2067,7 +2067,7 @@ struct SavePresetWindow : public Window { * Constructor of the save preset window. * @param initial_text Initial text to display in the edit box, or \c nullptr. */ - SavePresetWindow(const char *initial_text) : Window(&_save_preset_desc), presetname_editbox(32) + SavePresetWindow(const char *initial_text) : Window(_save_preset_desc), presetname_editbox(32) { this->presets = GetGRFPresetList(); this->selected = -1; @@ -2207,7 +2207,7 @@ struct ScanProgressWindow : public Window { int scanned; ///< The number of NewGRFs that we have seen. /** Create the window. */ - ScanProgressWindow() : Window(&_scan_progress_desc), scanned(0) + ScanProgressWindow() : Window(_scan_progress_desc), scanned(0) { this->InitNested(1); } diff --git a/src/news_gui.cpp b/src/news_gui.cpp index b7b16dc7185dc..cf5550b700d87 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -234,11 +234,11 @@ static WindowDesc *_news_window_layout[] = { &_company_news_desc, ///< NF_COMPANY }; -WindowDesc *GetNewsWindowLayout(NewsFlag flags) +WindowDesc &GetNewsWindowLayout(NewsFlag flags) { uint layout = GB(flags, NFB_WINDOW_LAYOUT, NFB_WINDOW_LAYOUT_COUNT); assert(layout < lengthof(_news_window_layout)); - return _news_window_layout[layout]; + return *_news_window_layout[layout]; } /** @@ -284,7 +284,7 @@ struct NewsWindow : Window { const NewsItem *ni; ///< News item to display. static int duration; ///< Remaining time for showing the current news message (may only be access while a news item is displayed). - NewsWindow(WindowDesc *desc, const NewsItem *ni) : Window(desc), ni(ni) + NewsWindow(WindowDesc &desc, const NewsItem *ni) : Window(desc), ni(ni) { NewsWindow::duration = 16650; const Window *w = FindWindowByClass(WC_SEND_NETWORK_MSG); @@ -296,7 +296,7 @@ struct NewsWindow : Window { this->CreateNestedTree(); /* For company news with a face we have a separate headline in param[0] */ - if (desc == &_company_news_desc) this->GetWidget(WID_N_TITLE)->widget_data = this->ni->params[0].data; + if (&desc == &_company_news_desc) this->GetWidget(WID_N_TITLE)->widget_data = this->ni->params[0].data; NWidgetCore *nwid = this->GetWidget(WID_N_SHOW_GROUP); if (ni->reftype1 == NR_VEHICLE && nwid != nullptr) { @@ -1103,7 +1103,7 @@ struct MessageHistoryWindow : Window { Scrollbar *vscroll; - MessageHistoryWindow(WindowDesc *desc) : Window(desc) + MessageHistoryWindow(WindowDesc &desc) : Window(desc) { this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_MH_SCROLLBAR); @@ -1208,5 +1208,5 @@ static WindowDesc _message_history_desc( void ShowMessageHistory() { CloseWindowById(WC_MESSAGE_HISTORY, 0); - new MessageHistoryWindow(&_message_history_desc); + new MessageHistoryWindow(_message_history_desc); } diff --git a/src/object_gui.cpp b/src/object_gui.cpp index bc8a9f6b5e0df..494d1445d9101 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -114,7 +114,7 @@ class BuildObjectWindow : public PickerWindow { int info_height; ///< The height of the info box. public: - BuildObjectWindow(WindowDesc *desc, WindowNumber) : PickerWindow(desc, nullptr, 0, ObjectPickerCallbacks::instance), info_height(1) + BuildObjectWindow(WindowDesc &desc, WindowNumber) : PickerWindow(desc, nullptr, 0, ObjectPickerCallbacks::instance), info_height(1) { ResetObjectToPlace(); this->ConstructWindow(); @@ -410,7 +410,7 @@ Window *ShowBuildObjectPicker() { /* Don't show the place object button when there are no objects to place. */ if (ObjectPickerCallbacks::instance.IsActive()) { - return AllocateWindowDescFront(&_build_object_desc, 0); + return AllocateWindowDescFront(_build_object_desc, 0); } return nullptr; } diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 43101d1cd17c4..762ab62e46fec 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -796,7 +796,7 @@ struct OrdersWindow : public Window { } public: - OrdersWindow(WindowDesc *desc, const Vehicle *v) : Window(desc) + OrdersWindow(WindowDesc &desc, const Vehicle *v) : Window(desc) { this->vehicle = v; @@ -1794,8 +1794,8 @@ void ShowOrdersWindow(const Vehicle *v) * TODO Rewrite the order GUI to not use different WindowDescs. */ if (v->owner != _local_company) { - new OrdersWindow(&_other_orders_desc, v); + new OrdersWindow(_other_orders_desc, v); } else { - new OrdersWindow(v->IsGroundVehicle() ? &_orders_train_desc : &_orders_desc, v); + new OrdersWindow(v->IsGroundVehicle() ? _orders_train_desc : _orders_desc, v); } } diff --git a/src/osk_gui.cpp b/src/osk_gui.cpp index 1949b8008e76c..f3ae270576669 100644 --- a/src/osk_gui.cpp +++ b/src/osk_gui.cpp @@ -42,7 +42,7 @@ struct OskWindow : public Window { std::string orig_str; ///< Original string. bool shift; ///< Is the shift effectively pressed? - OskWindow(WindowDesc *desc, Window *parent, WidgetID button) : Window(desc) + OskWindow(WindowDesc &desc, Window *parent, WidgetID button) : Window(desc) { this->parent = parent; assert(parent != nullptr); @@ -397,7 +397,7 @@ void ShowOnScreenKeyboard(Window *parent, WidgetID button) CloseWindowById(WC_OSK, 0); GetKeyboardLayout(); - new OskWindow(&_osk_desc, parent, button); + new OskWindow(_osk_desc, parent, button); } /** diff --git a/src/picker_gui.cpp b/src/picker_gui.cpp index ba221d22f4e31..4edde5ed2380d 100644 --- a/src/picker_gui.cpp +++ b/src/picker_gui.cpp @@ -155,7 +155,7 @@ static const std::initializer_list _cla static const std::initializer_list _type_sorter_funcs = { TypeIDSorter }; ///< Sort functions of the #PickerTypeList. static const std::initializer_list _type_filter_funcs = { TypeTagNameFilter }; ///< Filter functions of the #PickerTypeList. -PickerWindow::PickerWindow(WindowDesc *desc, Window *parent, int window_number, PickerCallbacks &callbacks) : PickerWindowBase(desc, parent), callbacks(callbacks), +PickerWindow::PickerWindow(WindowDesc &desc, Window *parent, int window_number, PickerCallbacks &callbacks) : PickerWindowBase(desc, parent), callbacks(callbacks), class_editbox(EDITBOX_MAX_SIZE * MAX_CHAR_LENGTH, EDITBOX_MAX_SIZE), type_editbox(EDITBOX_MAX_SIZE * MAX_CHAR_LENGTH, EDITBOX_MAX_SIZE) { diff --git a/src/picker_gui.h b/src/picker_gui.h index 78403be18740b..3ff9e2f314704 100644 --- a/src/picker_gui.h +++ b/src/picker_gui.h @@ -170,7 +170,7 @@ class PickerWindow : public PickerWindowBase { bool has_class_picker = false; ///< Set if this window has a class picker 'component'. bool has_type_picker = false; ///< Set if this window has a type picker 'component'. - PickerWindow(WindowDesc *desc, Window *parent, int window_number, PickerCallbacks &callbacks); + PickerWindow(WindowDesc &desc, Window *parent, int window_number, PickerCallbacks &callbacks); void Close(int data = 0) override; void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override; void DrawWidget(const Rect &r, WidgetID widget) const override; diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 6646441ac9a64..3b0a0c928f81c 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -436,7 +436,7 @@ struct BuildRailToolbarWindow : Window { RailType railtype; ///< Rail type to build. int last_user_action; ///< Last started user action. - BuildRailToolbarWindow(WindowDesc *desc, RailType railtype) : Window(desc) + BuildRailToolbarWindow(WindowDesc &desc, RailType railtype) : Window(desc) { this->InitNested(TRANSPORT_RAIL); this->SetupRailToolbar(railtype); @@ -922,7 +922,7 @@ Window *ShowBuildRailToolbar(RailType railtype) CloseWindowByClass(WC_BUILD_TOOLBAR); _cur_railtype = railtype; _remove_button_clicked = false; - return new BuildRailToolbarWindow(&_build_rail_desc, railtype); + return new BuildRailToolbarWindow(_build_rail_desc, railtype); } /* TODO: For custom stations, respect their allowed platforms/lengths bitmasks! @@ -1076,7 +1076,7 @@ struct BuildRailStationWindow : public PickerWindow { } public: - BuildRailStationWindow(WindowDesc *desc, Window *parent) : PickerWindow(desc, parent, TRANSPORT_RAIL, StationPickerCallbacks::instance) + BuildRailStationWindow(WindowDesc &desc, Window *parent) : PickerWindow(desc, parent, TRANSPORT_RAIL, StationPickerCallbacks::instance) { this->coverage_height = 2 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; this->ConstructWindow(); @@ -1437,7 +1437,7 @@ static WindowDesc _station_builder_desc( /** Open station build window */ static Window *ShowStationBuilder(Window *parent) { - return new BuildRailStationWindow(&_station_builder_desc, parent); + return new BuildRailStationWindow(_station_builder_desc, parent); } struct BuildSignalWindow : public PickerWindowBase { @@ -1471,7 +1471,7 @@ struct BuildSignalWindow : public PickerWindowBase { } public: - BuildSignalWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) + BuildSignalWindow(WindowDesc &desc, Window *parent) : PickerWindowBase(desc, parent) { this->CreateNestedTree(); this->SetSignalUIMode(); @@ -1694,11 +1694,11 @@ static WindowDesc _signal_builder_desc( */ static void ShowSignalBuilder(Window *parent) { - new BuildSignalWindow(&_signal_builder_desc, parent); + new BuildSignalWindow(_signal_builder_desc, parent); } struct BuildRailDepotWindow : public PickerWindowBase { - BuildRailDepotWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) + BuildRailDepotWindow(WindowDesc &desc, Window *parent) : PickerWindowBase(desc, parent) { this->InitNested(TRANSPORT_RAIL); this->LowerWidget(WID_BRAD_DEPOT_NE + _build_depot_direction); @@ -1772,7 +1772,7 @@ static WindowDesc _build_depot_desc( static void ShowBuildTrainDepotPicker(Window *parent) { - new BuildRailDepotWindow(&_build_depot_desc, parent); + new BuildRailDepotWindow(_build_depot_desc, parent); } class WaypointPickerCallbacks : public PickerCallbacksNewGRFClass { @@ -1849,7 +1849,7 @@ class WaypointPickerCallbacks : public PickerCallbacksNewGRFClass /* static */ WaypointPickerCallbacks WaypointPickerCallbacks::instance; struct BuildRailWaypointWindow : public PickerWindow { - BuildRailWaypointWindow(WindowDesc *desc, Window *parent) : PickerWindow(desc, parent, TRANSPORT_RAIL, WaypointPickerCallbacks::instance) + BuildRailWaypointWindow(WindowDesc &desc, Window *parent) : PickerWindow(desc, parent, TRANSPORT_RAIL, WaypointPickerCallbacks::instance) { this->ConstructWindow(); this->InvalidateData(); @@ -1885,7 +1885,7 @@ static WindowDesc _build_waypoint_desc( static void ShowBuildWaypointPicker(Window *parent) { if (!WaypointPickerCallbacks::instance.IsActive()) return; - new BuildRailWaypointWindow(&_build_waypoint_desc, parent); + new BuildRailWaypointWindow(_build_waypoint_desc, parent); } /** diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 6cb897e20ecd8..fb546b2a18063 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -313,7 +313,7 @@ struct BuildRoadToolbarWindow : Window { const RoadTypeInfo *rti; ///< Information about current road type int last_started_action; ///< Last started user action. - BuildRoadToolbarWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) + BuildRoadToolbarWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc) { this->Initialize(_cur_roadtype); this->InitNested(window_number); @@ -918,7 +918,7 @@ Window *ShowBuildRoadToolbar(RoadType roadtype) CloseWindowByClass(WC_BUILD_TOOLBAR); _cur_roadtype = roadtype; - return AllocateWindowDescFront(RoadTypeIsRoad(_cur_roadtype) ? &_build_road_desc : &_build_tramway_desc, TRANSPORT_ROAD); + return AllocateWindowDescFront(RoadTypeIsRoad(_cur_roadtype) ? _build_road_desc : _build_tramway_desc, TRANSPORT_ROAD); } static constexpr NWidgetPart _nested_build_road_scen_widgets[] = { @@ -1002,11 +1002,11 @@ Window *ShowBuildRoadScenToolbar(RoadType roadtype) CloseWindowById(WC_SCEN_BUILD_TOOLBAR, TRANSPORT_ROAD); _cur_roadtype = roadtype; - return AllocateWindowDescFront(RoadTypeIsRoad(_cur_roadtype) ? &_build_road_scen_desc : &_build_tramway_scen_desc, TRANSPORT_ROAD); + return AllocateWindowDescFront(RoadTypeIsRoad(_cur_roadtype) ? _build_road_scen_desc : _build_tramway_scen_desc, TRANSPORT_ROAD); } struct BuildRoadDepotWindow : public PickerWindowBase { - BuildRoadDepotWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) + BuildRoadDepotWindow(WindowDesc &desc, Window *parent) : PickerWindowBase(desc, parent) { this->CreateNestedTree(); @@ -1091,7 +1091,7 @@ static WindowDesc _build_road_depot_desc( static void ShowRoadDepotPicker(Window *parent) { - new BuildRoadDepotWindow(&_build_road_depot_desc, parent); + new BuildRoadDepotWindow(_build_road_depot_desc, parent); } template @@ -1222,7 +1222,7 @@ struct BuildRoadStationWindow : public PickerWindow { } public: - BuildRoadStationWindow(WindowDesc *desc, Window *parent, RoadStopType rs) : PickerWindow(desc, parent, TRANSPORT_ROAD, GetRoadStopPickerCallbacks(rs)) + BuildRoadStationWindow(WindowDesc &desc, Window *parent, RoadStopType rs) : PickerWindow(desc, parent, TRANSPORT_ROAD, GetRoadStopPickerCallbacks(rs)) { this->coverage_height = 2 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; @@ -1510,7 +1510,7 @@ static WindowDesc _tram_station_picker_desc( static void ShowRVStationPicker(Window *parent, RoadStopType rs) { - new BuildRoadStationWindow(RoadTypeIsRoad(_cur_roadtype) ? &_road_station_picker_desc : &_tram_station_picker_desc, parent, rs); + new BuildRoadStationWindow(RoadTypeIsRoad(_cur_roadtype) ? _road_station_picker_desc : _tram_station_picker_desc, parent, rs); } void InitializeRoadGui() diff --git a/src/screenshot_gui.cpp b/src/screenshot_gui.cpp index 2bfde67e898ac..237a0a4bfe893 100644 --- a/src/screenshot_gui.cpp +++ b/src/screenshot_gui.cpp @@ -20,7 +20,7 @@ #include "safeguards.h" struct ScreenshotWindow : Window { - ScreenshotWindow(WindowDesc *desc) : Window(desc) + ScreenshotWindow(WindowDesc &desc) : Window(desc) { this->CreateNestedTree(); this->FinishInitNested(); @@ -74,7 +74,7 @@ static WindowDesc _screenshot_window_desc( void ShowScreenshotWindow() { CloseWindowById(WC_SCREENSHOT, 0); - new ScreenshotWindow(&_screenshot_window_desc); + new ScreenshotWindow(_screenshot_window_desc); } /** diff --git a/src/script/script_gui.cpp b/src/script/script_gui.cpp index 24f71564ba5d3..28ad6378797bf 100644 --- a/src/script/script_gui.cpp +++ b/src/script/script_gui.cpp @@ -65,7 +65,7 @@ struct ScriptListWindow : public Window { * @param slot The company we're changing the Script for. * @param show_all Whether to show all available versions. */ - ScriptListWindow(WindowDesc *desc, CompanyID slot, bool show_all) : Window(desc), + ScriptListWindow(WindowDesc &desc, CompanyID slot, bool show_all) : Window(desc), slot(slot), show_all(show_all) { if (slot == OWNER_DEITY) { @@ -277,7 +277,7 @@ static WindowDesc _script_list_desc( void ShowScriptListWindow(CompanyID slot, bool show_all) { CloseWindowByClass(WC_SCRIPT_LIST); - new ScriptListWindow(&_script_list_desc, slot, show_all); + new ScriptListWindow(_script_list_desc, slot, show_all); } @@ -302,7 +302,7 @@ struct ScriptSettingsWindow : public Window { * @param desc The description of the window. * @param slot The company we're changing the settings for. */ - ScriptSettingsWindow(WindowDesc *desc, CompanyID slot) : Window(desc), + ScriptSettingsWindow(WindowDesc &desc, CompanyID slot) : Window(desc), slot(slot), clicked_button(-1), clicked_dropdown(false), @@ -622,7 +622,7 @@ void ShowScriptSettingsWindow(CompanyID slot) { CloseWindowByClass(WC_SCRIPT_LIST); CloseWindowByClass(WC_SCRIPT_SETTINGS); - new ScriptSettingsWindow(&_script_settings_desc, slot); + new ScriptSettingsWindow(_script_settings_desc, slot); } @@ -779,7 +779,7 @@ struct ScriptDebugWindow : public Window { * @param desc The description of the window. * @param number The window number (actually unused). */ - ScriptDebugWindow(WindowDesc *desc, WindowNumber number, Owner show_company) : Window(desc), break_editbox(MAX_BREAK_STR_STRING_LENGTH) + ScriptDebugWindow(WindowDesc &desc, WindowNumber number, Owner show_company) : Window(desc), break_editbox(MAX_BREAK_STR_STRING_LENGTH) { this->filter = ScriptDebugWindow::initial_state; this->break_string_filter = {&this->filter.case_sensitive_break_check, false}; @@ -1325,7 +1325,7 @@ Window *ShowScriptDebugWindow(CompanyID show_company, bool new_window) return w; } } - return new ScriptDebugWindow(&_script_debug_desc, i, show_company); + return new ScriptDebugWindow(_script_debug_desc, i, show_company); } else { ShowErrorMessage(STR_ERROR_AI_DEBUG_SERVER_ONLY, INVALID_STRING_ID, WL_INFO); } diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 6da28e6db5e2f..34a5bd60df097 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -359,7 +359,7 @@ struct GameOptionsWindow : Window { int gui_scale; static inline WidgetID active_tab = WID_GO_TAB_GENERAL; - GameOptionsWindow(WindowDesc *desc) : Window(desc) + GameOptionsWindow(WindowDesc &desc) : Window(desc) { this->opt = &GetGameSettings(); this->reload = false; @@ -1199,7 +1199,7 @@ static WindowDesc _game_options_desc( void ShowGameOptions() { CloseWindowByClass(WC_GAME_OPTIONS); - new GameOptionsWindow(&_game_options_desc); + new GameOptionsWindow(_game_options_desc); } static int SETTING_HEIGHT = 11; ///< Height of a single setting in the tree view in pixels @@ -2334,7 +2334,7 @@ struct GameSettingsWindow : Window { Scrollbar *vscroll; - GameSettingsWindow(WindowDesc *desc) : Window(desc), filter_editbox(50) + GameSettingsWindow(WindowDesc &desc) : Window(desc), filter_editbox(50) { this->warn_missing = WHR_NONE; this->warn_lines = 0; @@ -2909,7 +2909,7 @@ static WindowDesc _settings_selection_desc( void ShowGameSettings() { CloseWindowByClass(WC_GAME_OPTIONS); - new GameSettingsWindow(&_settings_selection_desc); + new GameSettingsWindow(_settings_selection_desc); } @@ -2985,7 +2985,7 @@ void DrawBoolButton(int x, int y, bool state, bool clickable) struct CustomCurrencyWindow : Window { int query_widget; - CustomCurrencyWindow(WindowDesc *desc) : Window(desc) + CustomCurrencyWindow(WindowDesc &desc) : Window(desc) { this->InitNested(); @@ -3217,5 +3217,5 @@ static WindowDesc _cust_currency_desc( static void ShowCustCurrency() { CloseWindowById(WC_CUSTOM_CURRENCY, 0); - new CustomCurrencyWindow(&_cust_currency_desc); + new CustomCurrencyWindow(_cust_currency_desc); } diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index abdd0b0b14617..f4d7438ef3e3c 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -142,7 +142,7 @@ struct SignListWindow : Window, SignList { int text_offset; ///< Offset of the sign text relative to the left edge of the WID_SIL_LIST widget. Scrollbar *vscroll; - SignListWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc), filter_editbox(MAX_LENGTH_SIGN_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_SIGN_NAME_CHARS) + SignListWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc), filter_editbox(MAX_LENGTH_SIGN_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_SIGN_NAME_CHARS) { this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_SIL_SCROLLBAR); @@ -398,7 +398,7 @@ static WindowDesc _sign_list_desc( */ Window *ShowSignList() { - return AllocateWindowDescFront(&_sign_list_desc, 0); + return AllocateWindowDescFront(_sign_list_desc, 0); } /** @@ -418,7 +418,7 @@ struct SignWindow : Window, SignList { QueryString name_editbox; SignID cur_sign; - SignWindow(WindowDesc *desc, const Sign *si) : Window(desc), name_editbox(MAX_LENGTH_SIGN_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_SIGN_NAME_CHARS) + SignWindow(WindowDesc &desc, const Sign *si) : Window(desc), name_editbox(MAX_LENGTH_SIGN_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_SIGN_NAME_CHARS) { this->querystrings[WID_QES_TEXT] = &this->name_editbox; this->name_editbox.caption = STR_EDIT_SIGN_CAPTION; @@ -582,7 +582,7 @@ void ShowRenameSignWindow(const Sign *si) /* Delete all other edit windows */ CloseWindowByClass(WC_QUERY_STRING); - new SignWindow(&_query_sign_edit_desc, si); + new SignWindow(_query_sign_edit_desc, si); } /** diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 81350a5f43fed..ca138823d6231 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1400,7 +1400,7 @@ class SmallMapWindow : public Window { public: friend class NWidgetSmallmapDisplay; - SmallMapWindow(WindowDesc *desc, int window_number) : Window(desc) + SmallMapWindow(WindowDesc &desc, int window_number) : Window(desc) { _smallmap_industry_highlight = INVALID_INDUSTRYTYPE; this->overlay = std::make_unique(this, WID_SM_MAP, 0, this->GetOverlayCompanyMask(), 1); @@ -1994,7 +1994,7 @@ static WindowDesc _smallmap_desc( */ void ShowSmallMap() { - AllocateWindowDescFront(&_smallmap_desc, 0); + AllocateWindowDescFront(_smallmap_desc, 0); } /** diff --git a/src/station_gui.cpp b/src/station_gui.cpp index c5de52e2e9fae..ecf33815ac551 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -384,7 +384,7 @@ class CompanyStationsWindow : public Window } public: - CompanyStationsWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) + CompanyStationsWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc) { /* Load initial filter state. */ this->filter = CompanyStationsWindow::initial_state; @@ -781,7 +781,7 @@ void ShowCompanyStations(CompanyID company) { if (!Company::IsValidID(company)) return; - AllocateWindowDescFront(&_company_stations_desc, company); + AllocateWindowDescFront(_company_stations_desc, company); } static constexpr NWidgetPart _nested_station_view_widgets[] = { @@ -1321,7 +1321,7 @@ struct StationViewWindow : public Window { CargoDataEntry cached_destinations; ///< Cache for the flows passing through this station. CargoDataVector displayed_rows; ///< Parent entry of currently displayed rows (including collapsed ones). - StationViewWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc), + StationViewWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc), scroll_to_row(INT_MAX), grouping_index(0) { this->rating_lines = ALH_RATING; @@ -2143,7 +2143,7 @@ static WindowDesc _station_view_desc( */ void ShowStationViewWindow(StationID station) { - AllocateWindowDescFront(&_station_view_desc, station); + AllocateWindowDescFront(_station_view_desc, station); } /** Struct containing TileIndex and StationID */ @@ -2271,7 +2271,7 @@ struct SelectStationWindow : Window { TileArea area; ///< Location of new station Scrollbar *vscroll; - SelectStationWindow(WindowDesc *desc, TileArea ta, StationPickerCmdProc&& proc) : + SelectStationWindow(WindowDesc &desc, TileArea ta, StationPickerCmdProc&& proc) : Window(desc), select_station_proc(std::move(proc)), area(ta) @@ -2441,7 +2441,7 @@ void ShowSelectBaseStationIfNeeded(TileArea ta, StationPickerCmdProc&& proc) { if (StationJoinerNeeded(ta, proc)) { if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); - new SelectStationWindow(&_select_station_desc, ta, std::move(proc)); + new SelectStationWindow(_select_station_desc, ta, std::move(proc)); } else { proc(false, INVALID_STATION); } diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp index dd6e33da34e5d..f7ed7b2a68241 100644 --- a/src/statusbar_gui.cpp +++ b/src/statusbar_gui.cpp @@ -63,7 +63,7 @@ struct StatusBarWindow : Window { static const int COUNTER_STEP = 2; ///< this is subtracted from active counters every tick static constexpr auto REMINDER_START = std::chrono::milliseconds(1350); ///< time in ms for reminder notification (red dot on the right) to stay - StatusBarWindow(WindowDesc *desc) : Window(desc) + StatusBarWindow(WindowDesc &desc) : Window(desc) { this->ticker_scroll = TICKER_STOP; @@ -249,5 +249,5 @@ bool IsNewsTickerShown() */ void ShowStatusBar() { - new StatusBarWindow(&_main_status_desc); + new StatusBarWindow(_main_status_desc); } diff --git a/src/story_gui.cpp b/src/story_gui.cpp index 838bee7f35ce1..c50caedf37c49 100644 --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -590,7 +590,7 @@ struct StoryBookWindow : Window { } public: - StoryBookWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) + StoryBookWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc) { this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_SB_SCROLLBAR); @@ -1052,6 +1052,6 @@ void ShowStoryBook(CompanyID company, uint16_t page_id, bool centered) { if (!Company::IsValidID(company)) company = (CompanyID)INVALID_COMPANY; - StoryBookWindow *w = AllocateWindowDescFront(centered ? &_story_book_gs_desc : &_story_book_desc, company, true); + StoryBookWindow *w = AllocateWindowDescFront(centered ? _story_book_gs_desc : _story_book_desc, company, true); if (page_id != INVALID_STORY_PAGE) w->SetSelectedPage(page_id); } diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp index 98c218e3b6f0b..df24ba84d9041 100644 --- a/src/subsidy_gui.cpp +++ b/src/subsidy_gui.cpp @@ -29,7 +29,7 @@ struct SubsidyListWindow : Window { Scrollbar *vscroll; Dimension cargo_icon_size; - SubsidyListWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) + SubsidyListWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc) { this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_SUL_SCROLLBAR); @@ -277,5 +277,5 @@ static WindowDesc _subsidies_list_desc( void ShowSubsidiesList() { - AllocateWindowDescFront(&_subsidies_list_desc, 0); + AllocateWindowDescFront(_subsidies_list_desc, 0); } diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index df1d442742a68..f9859efd37d6c 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -157,7 +157,7 @@ void PlaceProc_DemolishArea(TileIndex tile) struct TerraformToolbarWindow : Window { int last_user_action; ///< Last started user action. - TerraformToolbarWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) + TerraformToolbarWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc) { /* This is needed as we like to have the tree available on OnInit. */ this->CreateNestedTree(); @@ -371,13 +371,13 @@ Window *ShowTerraformToolbar(Window *link) Window *w; if (link == nullptr) { - w = AllocateWindowDescFront(&_terraform_desc, 0); + w = AllocateWindowDescFront(_terraform_desc, 0); return w; } /* Delete the terraform toolbar to place it again. */ CloseWindowById(WC_SCEN_LAND_GEN, 0, true); - w = AllocateWindowDescFront(&_terraform_desc, 0); + w = AllocateWindowDescFront(_terraform_desc, 0); /* Align the terraform toolbar under the main toolbar. */ w->top -= w->height; w->SetDirty(); @@ -536,7 +536,7 @@ static void ResetLandscapeConfirmationCallback(Window *, bool confirmed) struct ScenarioEditorLandscapeGenerationWindow : Window { int last_user_action; ///< Last started user action. - ScenarioEditorLandscapeGenerationWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) + ScenarioEditorLandscapeGenerationWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc) { this->CreateNestedTree(); NWidgetStacked *show_desert = this->GetWidget(WID_ETT_SHOW_PLACE_DESERT); @@ -750,5 +750,5 @@ static WindowDesc _scen_edit_land_gen_desc( */ Window *ShowEditorTerraformToolbar() { - return AllocateWindowDescFront(&_scen_edit_land_gen_desc, 0); + return AllocateWindowDescFront(_scen_edit_land_gen_desc, 0); } diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp index 1ae7673715304..9cfe0220faff0 100644 --- a/src/textfile_gui.cpp +++ b/src/textfile_gui.cpp @@ -82,7 +82,7 @@ static WindowDesc _textfile_desc( std::begin(_nested_textfile_widgets), std::end(_nested_textfile_widgets) ); -TextfileWindow::TextfileWindow(TextfileType file_type) : Window(&_textfile_desc), file_type(file_type) +TextfileWindow::TextfileWindow(TextfileType file_type) : Window(_textfile_desc), file_type(file_type) { /* Init of nested tree is deferred. * TextfileWindow::ConstructWindow must be called by the inheriting window. */ diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index a8bd962001960..7591e7da20159 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -207,7 +207,7 @@ struct TimetableWindow : Window { bool set_start_date_all; ///< Set start date using minutes text entry for all timetable entries (ctrl-click) action. bool change_timetable_all; ///< Set wait time or speed for all timetable entries (ctrl-click) action. - TimetableWindow(WindowDesc *desc, WindowNumber window_number) : + TimetableWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc), sel_index(-1), vehicle(Vehicle::Get(window_number)), @@ -867,5 +867,5 @@ void ShowTimetableWindow(const Vehicle *v) { CloseWindowById(WC_VEHICLE_DETAILS, v->index, false); CloseWindowById(WC_VEHICLE_ORDERS, v->index, false); - AllocateWindowDescFront(&_timetable_desc, v->index); + AllocateWindowDescFront(_timetable_desc, v->index); } diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 77a5b265b9d77..3c06ca1a9e490 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -1955,7 +1955,7 @@ static ToolbarButtonProc * const _toolbar_button_procs[] = { /** Main toolbar. */ struct MainToolbarWindow : Window { - MainToolbarWindow(WindowDesc *desc) : Window(desc) + MainToolbarWindow(WindowDesc &desc) : Window(desc) { this->InitNested(0); @@ -2296,7 +2296,7 @@ enum MainToolbarEditorHotkeys { }; struct ScenarioEditorToolbarWindow : Window { - ScenarioEditorToolbarWindow(WindowDesc *desc) : Window(desc) + ScenarioEditorToolbarWindow(WindowDesc &desc) : Window(desc) { this->InitNested(0); @@ -2562,8 +2562,8 @@ void AllocateToolbar() _last_built_tramtype = ROADTYPE_TRAM; if (_game_mode == GM_EDITOR) { - new ScenarioEditorToolbarWindow(&_toolb_scen_desc); + new ScenarioEditorToolbarWindow(_toolb_scen_desc); } else { - new MainToolbarWindow(&_toolb_normal_desc); + new MainToolbarWindow(_toolb_normal_desc); } } diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 4a9c536301689..27c10d220fe65 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -121,7 +121,7 @@ struct TownAuthorityWindow : Window { } public: - TownAuthorityWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc), sel_index(-1), displayed_actions_on_previous_painting(0), available_actions(TACT_NONE) + TownAuthorityWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc), sel_index(-1), displayed_actions_on_previous_painting(0), available_actions(TACT_NONE) { this->town = Town::Get(window_number); this->enabled_actions = GetEnabledActions(); @@ -351,7 +351,7 @@ static WindowDesc _town_authority_desc( static void ShowTownAuthorityWindow(uint town) { - AllocateWindowDescFront(&_town_authority_desc, town); + AllocateWindowDescFront(_town_authority_desc, town); } @@ -363,7 +363,7 @@ struct TownViewWindow : Window { public: static const int WID_TV_HEIGHT_NORMAL = 150; - TownViewWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) + TownViewWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc) { this->CreateNestedTree(); @@ -677,9 +677,9 @@ static WindowDesc _town_editor_view_desc( void ShowTownViewWindow(TownID town) { if (_game_mode == GM_EDITOR) { - AllocateWindowDescFront(&_town_editor_view_desc, town); + AllocateWindowDescFront(_town_editor_view_desc, town); } else { - AllocateWindowDescFront(&_town_game_view_desc, town); + AllocateWindowDescFront(_town_game_view_desc, town); } } @@ -799,7 +799,7 @@ struct TownDirectoryWindow : public Window { } public: - TownDirectoryWindow(WindowDesc *desc) : Window(desc), townname_editbox(MAX_LENGTH_TOWN_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_TOWN_NAME_CHARS) + TownDirectoryWindow(WindowDesc &desc) : Window(desc), townname_editbox(MAX_LENGTH_TOWN_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_TOWN_NAME_CHARS) { this->CreateNestedTree(); @@ -1067,7 +1067,7 @@ static WindowDesc _town_directory_desc( void ShowTownDirectory() { if (BringWindowToFrontById(WC_TOWN_DIRECTORY, 0)) return; - new TownDirectoryWindow(&_town_directory_desc); + new TownDirectoryWindow(_town_directory_desc); } void CcFoundTown(Commands, const CommandCost &result, TileIndex tile) @@ -1146,7 +1146,7 @@ struct FoundTownWindow : Window { TownNameParams params; ///< Town name parameters public: - FoundTownWindow(WindowDesc *desc, WindowNumber window_number) : + FoundTownWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc), town_size(TSZ_MEDIUM), town_layout(_settings_game.economy.town_layout), @@ -1300,7 +1300,7 @@ static WindowDesc _found_town_desc( void ShowFoundTownWindow() { if (_game_mode != GM_EDITOR && !Company::IsValidID(_local_company)) return; - AllocateWindowDescFront(&_found_town_desc, 0); + AllocateWindowDescFront(_found_town_desc, 0); } void InitializeTownGui() @@ -1558,7 +1558,7 @@ class HousePickerCallbacks : public PickerCallbacks { /* static */ HousePickerCallbacks HousePickerCallbacks::instance; struct BuildHouseWindow : public PickerWindow { - BuildHouseWindow(WindowDesc *desc, Window *parent) : PickerWindow(desc, parent, 0, HousePickerCallbacks::instance) + BuildHouseWindow(WindowDesc &desc, Window *parent) : PickerWindow(desc, parent, 0, HousePickerCallbacks::instance) { HousePickerCallbacks::instance.SetClimateMask(); this->ConstructWindow(); @@ -1639,5 +1639,5 @@ static WindowDesc _build_house_desc( void ShowBuildHousePicker(Window *parent) { if (BringWindowToFrontById(WC_BUILD_HOUSE, 0)) return; - new BuildHouseWindow(&_build_house_desc, parent); + new BuildHouseWindow(_build_house_desc, parent); } diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp index 1a0c3a713fe34..0648f1e4c80fb 100644 --- a/src/transparency_gui.cpp +++ b/src/transparency_gui.cpp @@ -28,7 +28,7 @@ uint8_t _display_opt; ///< What do we want to draw/do? class TransparenciesWindow : public Window { public: - TransparenciesWindow(WindowDesc *desc, int window_number) : Window(desc) + TransparenciesWindow(WindowDesc &desc, int window_number) : Window(desc) { this->InitNested(window_number); } @@ -160,5 +160,5 @@ static WindowDesc _transparency_desc( */ void ShowTransparencyToolbar() { - AllocateWindowDescFront(&_transparency_desc, 0); + AllocateWindowDescFront(_transparency_desc, 0); } diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp index be32a3e07cbae..5288b2c96b48b 100644 --- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -139,7 +139,7 @@ class BuildTreesWindow : public Window } public: - BuildTreesWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc), tree_to_plant(-1), mode(PM_NORMAL) + BuildTreesWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc), tree_to_plant(-1), mode(PM_NORMAL) { this->CreateNestedTree(); ResetObjectToPlace(); @@ -320,5 +320,5 @@ static WindowDesc _build_trees_desc( void ShowBuildTreesToolbar() { if (_game_mode != GM_EDITOR && !Company::IsValidID(_local_company)) return; - AllocateWindowDescFront(&_build_trees_desc, 0); + AllocateWindowDescFront(_build_trees_desc, 0); } diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index e4bcdb93fdaad..dcfd4a80e57dc 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -162,7 +162,7 @@ const StringID BaseVehicleListWindow::vehicle_depot_name[] = { STR_VEHICLE_LIST_SEND_AIRCRAFT_TO_HANGAR }; -BaseVehicleListWindow::BaseVehicleListWindow(WindowDesc *desc, WindowNumber wno) : Window(desc), vli(VehicleListIdentifier::UnPack(wno)) +BaseVehicleListWindow::BaseVehicleListWindow(WindowDesc &desc, WindowNumber wno) : Window(desc), vli(VehicleListIdentifier::UnPack(wno)) { this->vehicle_sel = INVALID_VEHICLE; this->grouping = _grouping[vli.type][vli.vtype]; @@ -862,7 +862,7 @@ struct RefitWindow : public Window { this->selected_refit = nullptr; } - RefitWindow(WindowDesc *desc, const Vehicle *v, VehicleOrderID order, bool auto_refit) : Window(desc) + RefitWindow(WindowDesc &desc, const Vehicle *v, VehicleOrderID order, bool auto_refit) : Window(desc) { this->auto_refit = auto_refit; this->order = order; @@ -1293,7 +1293,7 @@ static WindowDesc _vehicle_refit_desc( void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit) { CloseWindowById(WC_VEHICLE_REFIT, v->index); - RefitWindow *w = new RefitWindow(&_vehicle_refit_desc, v, order, auto_refit); + RefitWindow *w = new RefitWindow(_vehicle_refit_desc, v, order, auto_refit); w->parent = parent; } @@ -1871,7 +1871,7 @@ struct VehicleListWindow : public BaseVehicleListWindow { }; public: - VehicleListWindow(WindowDesc *desc, WindowNumber window_number) : BaseVehicleListWindow(desc, window_number) + VehicleListWindow(WindowDesc &desc, WindowNumber window_number) : BaseVehicleListWindow(desc, window_number) { this->CreateNestedTree(); @@ -2236,10 +2236,10 @@ static void ShowVehicleListWindowLocal(CompanyID company, VehicleListType vlt, V WindowNumber num = VehicleListIdentifier(vlt, vehicle_type, company, unique_number).Pack(); if (vehicle_type == VEH_TRAIN) { - AllocateWindowDescFront(&_vehicle_list_train_desc, num); + AllocateWindowDescFront(_vehicle_list_train_desc, num); } else { _vehicle_list_other_desc.cls = GetWindowClassForVehicleType(vehicle_type); - AllocateWindowDescFront(&_vehicle_list_other_desc, num); + AllocateWindowDescFront(_vehicle_list_other_desc, num); } } @@ -2371,7 +2371,7 @@ struct VehicleDetailsWindow : Window { Scrollbar *vscroll; /** Initialize a newly created vehicle details window */ - VehicleDetailsWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) + VehicleDetailsWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc) { const Vehicle *v = Vehicle::Get(window_number); @@ -2795,7 +2795,7 @@ static void ShowVehicleDetailsWindow(const Vehicle *v) { CloseWindowById(WC_VEHICLE_ORDERS, v->index, false); CloseWindowById(WC_VEHICLE_TIMETABLE, v->index, false); - AllocateWindowDescFront((v->type == VEH_TRAIN) ? &_train_vehicle_details_desc : &_nontrain_vehicle_details_desc, v->index); + AllocateWindowDescFront((v->type == VEH_TRAIN) ? _train_vehicle_details_desc : _nontrain_vehicle_details_desc, v->index); } @@ -2972,7 +2972,7 @@ struct VehicleViewWindow : Window { } public: - VehicleViewWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) + VehicleViewWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc) { this->flags |= WF_DISABLE_VP_SCROLL; this->CreateNestedTree(); @@ -3405,7 +3405,7 @@ static WindowDesc _train_view_desc( /** Shows the vehicle view window of the given vehicle. */ void ShowVehicleViewWindow(const Vehicle *v) { - AllocateWindowDescFront((v->type == VEH_TRAIN) ? &_train_view_desc : &_vehicle_view_desc, v->index); + AllocateWindowDescFront((v->type == VEH_TRAIN) ? _train_view_desc : _vehicle_view_desc, v->index); } /** diff --git a/src/vehicle_gui_base.h b/src/vehicle_gui_base.h index 73036fefe3e46..21053c492175c 100644 --- a/src/vehicle_gui_base.h +++ b/src/vehicle_gui_base.h @@ -106,7 +106,7 @@ struct BaseVehicleListWindow : public Window { static const std::initializer_list vehicle_group_none_sorter_funcs; static const std::initializer_list vehicle_group_shared_orders_sorter_funcs; - BaseVehicleListWindow(WindowDesc *desc, WindowNumber wno); + BaseVehicleListWindow(WindowDesc &desc, WindowNumber wno); void OnInit() override; diff --git a/src/viewport_gui.cpp b/src/viewport_gui.cpp index e872191975988..f20c10f30368e 100644 --- a/src/viewport_gui.cpp +++ b/src/viewport_gui.cpp @@ -52,7 +52,7 @@ static constexpr NWidgetPart _nested_extra_viewport_widgets[] = { class ExtraViewportWindow : public Window { public: - ExtraViewportWindow(WindowDesc *desc, int window_number, TileIndex tile) : Window(desc) + ExtraViewportWindow(WindowDesc &desc, int window_number, TileIndex tile) : Window(desc) { this->InitNested(window_number); @@ -160,7 +160,7 @@ void ShowExtraViewportWindow(TileIndex tile) /* find next free window number for extra viewport */ while (FindWindowById(WC_EXTRA_VIEWPORT, i) != nullptr) i++; - new ExtraViewportWindow(&_extra_viewport_desc, i, tile); + new ExtraViewportWindow(_extra_viewport_desc, i, tile); } /** diff --git a/src/waypoint_gui.cpp b/src/waypoint_gui.cpp index 2259b8b74cf11..985718849c16e 100644 --- a/src/waypoint_gui.cpp +++ b/src/waypoint_gui.cpp @@ -54,7 +54,7 @@ struct WaypointWindow : Window { * @param desc The description of the window. * @param window_number The window number, in this case the waypoint's ID. */ - WaypointWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) + WaypointWindow(WindowDesc &desc, WindowNumber window_number) : Window(desc) { this->wp = Waypoint::Get(window_number); this->vt = (wp->string_id == STR_SV_STNAME_WAYPOINT) ? VEH_TRAIN : VEH_SHIP; @@ -196,5 +196,5 @@ static WindowDesc _waypoint_view_desc( */ void ShowWaypointWindow(const Waypoint *wp) { - AllocateWindowDescFront(&_waypoint_view_desc, wp->index); + AllocateWindowDescFront(_waypoint_view_desc, wp->index); } diff --git a/src/window.cpp b/src/window.cpp index 6a5a2eee34097..012bab7537340 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -195,10 +195,10 @@ void WindowDesc::SaveToConfig() void Window::ApplyDefaults() { if (this->nested_root != nullptr && this->nested_root->GetWidgetOfType(WWT_STICKYBOX) != nullptr) { - if (this->window_desc->pref_sticky) this->flags |= WF_STICKY; + if (this->window_desc.pref_sticky) this->flags |= WF_STICKY; } else { /* There is no stickybox; clear the preference in case someone tried to be funny */ - this->window_desc->pref_sticky = false; + this->window_desc.pref_sticky = false; } } @@ -616,7 +616,7 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, int click_count) bool focused_widget_changed = false; /* If clicked on a window that previously did not have focus */ if (_focused_window != w && // We already have focus, right? - (w->window_desc->flags & WDF_NO_FOCUS) == 0 && // Don't lose focus to toolbars + (w->window_desc.flags & WDF_NO_FOCUS) == 0 && // Don't lose focus to toolbars widget_type != WWT_CLOSEBOX) { // Don't change focused window if 'X' (close button) was clicked focused_widget_changed = true; SetFocusedWindow(w); @@ -681,11 +681,11 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, int click_count) case WWT_DEFSIZEBOX: { if (_ctrl_pressed) { - w->window_desc->pref_width = w->width; - w->window_desc->pref_height = w->height; + w->window_desc.pref_width = w->width; + w->window_desc.pref_height = w->height; } else { - int16_t def_width = std::max(std::min(w->window_desc->GetDefaultWidth(), _screen.width), w->nested_root->smallest_x); - int16_t def_height = std::max(std::min(w->window_desc->GetDefaultHeight(), _screen.height - 50), w->nested_root->smallest_y); + int16_t def_width = std::max(std::min(w->window_desc.GetDefaultWidth(), _screen.width), w->nested_root->smallest_x); + int16_t def_height = std::max(std::min(w->window_desc.GetDefaultHeight(), _screen.height - 50), w->nested_root->smallest_y); int dx = (w->resize.step_width == 0) ? 0 : def_width - w->width; int dy = (w->resize.step_height == 0) ? 0 : def_height - w->height; @@ -714,7 +714,7 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, int click_count) case WWT_STICKYBOX: w->flags ^= WF_STICKY; nw->SetDirty(w); - if (_ctrl_pressed) w->window_desc->pref_sticky = (w->flags & WF_STICKY) != 0; + if (_ctrl_pressed) w->window_desc.pref_sticky = (w->flags & WF_STICKY) != 0; return; default: @@ -752,9 +752,9 @@ static void DispatchRightClickEvent(Window *w, int x, int y) } /* Right-click close is enabled and there is a closebox. */ - if (_settings_client.gui.right_click_wnd_close == RCC_YES && (w->window_desc->flags & WDF_NO_CLOSE) == 0) { + if (_settings_client.gui.right_click_wnd_close == RCC_YES && (w->window_desc.flags & WDF_NO_CLOSE) == 0) { w->Close(); - } else if (_settings_client.gui.right_click_wnd_close == RCC_YES_EXCEPT_STICKY && (w->flags & WF_STICKY) == 0 && (w->window_desc->flags & WDF_NO_CLOSE) == 0) { + } else if (_settings_client.gui.right_click_wnd_close == RCC_YES_EXCEPT_STICKY && (w->flags & WF_STICKY) == 0 && (w->window_desc.flags & WDF_NO_CLOSE) == 0) { /* Right-click close is enabled, but excluding sticky windows. */ w->Close(); } else if (_settings_client.gui.hover_delay_ms == 0 && !w->OnTooltip(pt, wid->index, TCC_RIGHT_CLICK) && wid->tool_tip != 0) { @@ -981,7 +981,7 @@ void Window::ReInit(int rx, int ry, bool reposition) if (reposition) { Point pt = this->OnInitialPosition(this->nested_root->smallest_x, this->nested_root->smallest_y, window_number); this->InitializePositionSize(pt.x, pt.y, this->nested_root->smallest_x, this->nested_root->smallest_y); - this->FindWindowPlacementAndResize(this->window_desc->GetDefaultWidth(), this->window_desc->GetDefaultHeight()); + this->FindWindowPlacementAndResize(this->window_desc.GetDefaultWidth(), this->window_desc.GetDefaultHeight()); } ResizeWindow(this, dx, dy, true, false); @@ -1365,9 +1365,9 @@ static void BringWindowToFront(Window *w, bool dirty) void Window::InitializeData(WindowNumber window_number) { /* Set up window properties; some of them are needed to set up smallest size below */ - this->window_class = this->window_desc->cls; + this->window_class = this->window_desc.cls; this->SetWhiteBorder(); - if (this->window_desc->default_pos == WDP_CENTER) this->flags |= WF_CENTERED; + if (this->window_desc.default_pos == WDP_CENTER) this->flags |= WF_CENTERED; this->owner = INVALID_OWNER; this->nested_focus = nullptr; this->window_number = window_number; @@ -1650,17 +1650,17 @@ Point GetToolbarAlignedWindowPosition(int window_width) * * @return Coordinate of the top-left corner of the new window. */ -static Point LocalGetWindowPlacement(const WindowDesc *desc, int16_t sm_width, int16_t sm_height, int window_number) +static Point LocalGetWindowPlacement(const WindowDesc &desc, int16_t sm_width, int16_t sm_height, int window_number) { Point pt; const Window *w; - int16_t default_width = std::max(desc->GetDefaultWidth(), sm_width); - int16_t default_height = std::max(desc->GetDefaultHeight(), sm_height); + int16_t default_width = std::max(desc.GetDefaultWidth(), sm_width); + int16_t default_height = std::max(desc.GetDefaultHeight(), sm_height); - if (desc->parent_cls != WC_NONE && (w = FindWindowById(desc->parent_cls, window_number)) != nullptr) { + if (desc.parent_cls != WC_NONE && (w = FindWindowById(desc.parent_cls, window_number)) != nullptr) { bool rtl = _current_text_dir == TD_RTL; - if (desc->parent_cls == WC_BUILD_TOOLBAR || desc->parent_cls == WC_SCEN_LAND_GEN) { + if (desc.parent_cls == WC_BUILD_TOOLBAR || desc.parent_cls == WC_SCEN_LAND_GEN) { pt.x = w->left + (rtl ? w->width - default_width : 0); pt.y = w->top + w->height; return pt; @@ -1685,7 +1685,7 @@ static Point LocalGetWindowPlacement(const WindowDesc *desc, int16_t sm_width, i } } - switch (desc->default_pos) { + switch (desc.default_pos) { case WDP_ALIGN_TOOLBAR: // Align to the toolbar return GetToolbarAlignedWindowPosition(default_width); @@ -1723,7 +1723,7 @@ static Point LocalGetWindowPlacement(const WindowDesc *desc, int16_t sm_width, i */ void Window::CreateNestedTree() { - this->nested_root = MakeWindowNWidgetTree(this->window_desc->nwid_begin, this->window_desc->nwid_end, &this->shade_select); + this->nested_root = MakeWindowNWidgetTree(this->window_desc.nwid_begin, this->window_desc.nwid_end, &this->shade_select); this->nested_root->FillWidgetLookup(this->widget_lookup); } @@ -1737,7 +1737,7 @@ void Window::FinishInitNested(WindowNumber window_number) this->ApplyDefaults(); Point pt = this->OnInitialPosition(this->nested_root->smallest_x, this->nested_root->smallest_y, window_number); this->InitializePositionSize(pt.x, pt.y, this->nested_root->smallest_x, this->nested_root->smallest_y); - this->FindWindowPlacementAndResize(this->window_desc->GetDefaultWidth(), this->window_desc->GetDefaultHeight()); + this->FindWindowPlacementAndResize(this->window_desc.GetDefaultWidth(), this->window_desc.GetDefaultHeight()); } /** @@ -1754,7 +1754,7 @@ void Window::InitNested(WindowNumber window_number) * Empty constructor, initialization has been moved to #InitNested() called from the constructor of the derived class. * @param desc The description of the window. */ -Window::Window(WindowDesc *desc) : window_desc(desc), scale(_gui_scale), mouse_capture_widget(-1) +Window::Window(WindowDesc &desc) : window_desc(desc), scale(_gui_scale), mouse_capture_widget(-1) { this->z_position = _z_windows.insert(_z_windows.end(), this); } @@ -2435,7 +2435,7 @@ static bool MaybeBringWindowToFront(Window *w) for (; !it.IsEnd(); ++it) { Window *u = *it; /* A modal child will prevent the activation of the parent window */ - if (u->parent == w && (u->window_desc->flags & WDF_MODAL)) { + if (u->parent == w && (u->window_desc.flags & WDF_MODAL)) { u->SetWhiteBorder(); u->SetDirty(); return false; @@ -2549,7 +2549,7 @@ void HandleToolbarHotkey(int hotkey) Window *w = FindWindowById(WC_MAIN_TOOLBAR, 0); if (w != nullptr) { - if (w->window_desc->hotkeys != nullptr) { + if (w->window_desc.hotkeys != nullptr) { if (hotkey >= 0 && w->OnHotkey(hotkey) == ES_HANDLED) return; } } @@ -2593,8 +2593,8 @@ void HandleKeypress(uint keycode, char32_t key) /* Call the event, start with the uppermost window, but ignore the toolbar. */ for (Window *w : Window::IterateFromFront()) { if (w->window_class == WC_MAIN_TOOLBAR) continue; - if (w->window_desc->hotkeys != nullptr) { - int hotkey = w->window_desc->hotkeys->CheckMatch(keycode); + if (w->window_desc.hotkeys != nullptr) { + int hotkey = w->window_desc.hotkeys->CheckMatch(keycode); if (hotkey >= 0 && w->OnHotkey(hotkey) == ES_HANDLED) return; } if (w->OnKeyPress(key, keycode) == ES_HANDLED) return; @@ -2603,8 +2603,8 @@ void HandleKeypress(uint keycode, char32_t key) Window *w = FindWindowById(WC_MAIN_TOOLBAR, 0); /* When there is no toolbar w is null, check for that */ if (w != nullptr) { - if (w->window_desc->hotkeys != nullptr) { - int hotkey = w->window_desc->hotkeys->CheckMatch(keycode); + if (w->window_desc.hotkeys != nullptr) { + int hotkey = w->window_desc.hotkeys->CheckMatch(keycode); if (hotkey >= 0 && w->OnHotkey(hotkey) == ES_HANDLED) return; } if (w->OnKeyPress(key, keycode) == ES_HANDLED) return; @@ -3243,7 +3243,7 @@ void CloseNonVitalWindows() { /* Note: the container remains stable, even when deleting windows. */ for (Window *w : Window::Iterate()) { - if ((w->window_desc->flags & WDF_NO_CLOSE) == 0 && + if ((w->window_desc.flags & WDF_NO_CLOSE) == 0 && (w->flags & WF_STICKY) == 0) { // do not delete windows which are 'pinned' w->Close(); @@ -3262,7 +3262,7 @@ void CloseAllNonVitalWindows() { /* Note: the container remains stable, even when closing windows. */ for (Window *w : Window::Iterate()) { - if ((w->window_desc->flags & WDF_NO_CLOSE) == 0) { + if ((w->window_desc.flags & WDF_NO_CLOSE) == 0) { w->Close(); } } @@ -3287,7 +3287,7 @@ void CloseConstructionWindows() { /* Note: the container remains stable, even when deleting windows. */ for (Window *w : Window::Iterate()) { - if (w->window_desc->flags & WDF_CONSTRUCTION) { + if (w->window_desc.flags & WDF_CONSTRUCTION) { w->Close(); } } diff --git a/src/window_gui.h b/src/window_gui.h index a18b9f85fbe10..30e1d6fd90f01 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -290,7 +290,7 @@ struct Window : ZeroedMemoryAllocator { virtual ~Window(); public: - Window(WindowDesc *desc); + Window(WindowDesc &desc); /** * Helper allocation function to disallow something. @@ -300,7 +300,7 @@ struct Window : ZeroedMemoryAllocator { */ inline void *operator new[](size_t size) = delete; - WindowDesc *window_desc; ///< Window description + WindowDesc &window_desc; ///< Window description WindowFlags flags; ///< Window flags WindowClass window_class; ///< Window class WindowNumber window_number; ///< Window number within the window class @@ -990,7 +990,7 @@ inline const NWID *Window::GetWidget(WidgetID widnum) const class PickerWindowBase : public Window { public: - PickerWindowBase(WindowDesc *desc, Window *parent) : Window(desc) + PickerWindowBase(WindowDesc &desc, Window *parent) : Window(desc) { this->parent = parent; } @@ -1016,9 +1016,9 @@ Window *BringWindowToFrontById(WindowClass cls, T number) * @return %Window pointer of the newly created window, or the existing one if \a return_existing is set, or \c nullptr. */ template -Wcls *AllocateWindowDescFront(WindowDesc *desc, int window_number, bool return_existing = false) +Wcls *AllocateWindowDescFront(WindowDesc &desc, int window_number, bool return_existing = false) { - Wcls *w = static_cast(BringWindowToFrontById(desc->cls, window_number)); + Wcls *w = static_cast(BringWindowToFrontById(desc.cls, window_number)); if (w != nullptr) return return_existing ? w : nullptr; return new Wcls(desc, window_number); }