diff options
author | frosch <frosch@openttd.org> | 2013-05-26 19:23:42 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2013-05-26 19:23:42 +0000 |
commit | 56e4a8c4d63b19cb037ac1ba64c5a4d7fde4350b (patch) | |
tree | f3e5c225182fce7a451af4e09e943920e0f1cc3c /src | |
parent | b10a4f151aa534860dcc61ecf8cba7b3589e6281 (diff) | |
download | openttd-56e4a8c4d63b19cb037ac1ba64c5a4d7fde4350b.tar.xz |
(svn r25287) -Codechange: Keep a reference to the WindowDesc in the Window after construction.
Diffstat (limited to 'src')
61 files changed, 488 insertions, 482 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index 7e569c5dc..bfa985379 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -65,7 +65,7 @@ struct AIListWindow : public Window { * @param desc The description of the window. * @param slot The company we're changing the AI for. */ - AIListWindow(const WindowDesc *desc, CompanyID slot) : Window(), + AIListWindow(WindowDesc *desc, CompanyID slot) : Window(desc), slot(slot) { if (slot == OWNER_DEITY) { @@ -74,9 +74,9 @@ struct AIListWindow : public Window { this->info_list = AI::GetUniqueInfoList(); } - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_AIL_SCROLLBAR); - this->FinishInitNested(desc); // Initializes 'this->line_height' as side effect. + this->FinishInitNested(); // Initializes 'this->line_height' as side effect. this->vscroll->SetCount((int)this->info_list->size() + 1); @@ -257,7 +257,7 @@ static const NWidgetPart _nested_ai_list_widgets[] = { }; /** Window definition for the ai list window. */ -static const WindowDesc _ai_list_desc( +static WindowDesc _ai_list_desc( WDP_CENTER, 200, 234, WC_AI_LIST, WC_NONE, 0, @@ -296,7 +296,7 @@ struct AISettingsWindow : public Window { * @param desc The description of the window. * @param slot The company we're changing the settings for. */ - AISettingsWindow(const WindowDesc *desc, CompanyID slot) : Window(), + AISettingsWindow(WindowDesc *desc, CompanyID slot) : Window(desc), slot(slot), clicked_button(-1), clicked_dropdown(false), @@ -306,9 +306,9 @@ struct AISettingsWindow : public Window { this->ai_config = GetConfig(slot); this->RebuildVisibleSettings(); - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_AIS_SCROLLBAR); - this->FinishInitNested(desc, slot); // Initializes 'this->line_height' as side effect. + this->FinishInitNested(slot); // Initializes 'this->line_height' as side effect. this->SetWidgetDisabledState(WID_AIS_RESET, _game_mode != GM_MENU && Company::IsValidID(this->slot)); @@ -603,7 +603,7 @@ static const NWidgetPart _nested_ai_settings_widgets[] = { }; /** Window definition for the AI settings window. */ -static const WindowDesc _ai_settings_desc( +static WindowDesc _ai_settings_desc( WDP_CENTER, 500, 208, WC_AI_SETTINGS, WC_NONE, 0, @@ -697,7 +697,7 @@ static const NWidgetPart _nested_ai_config_widgets[] = { }; /** Window definition for the configure AI window. */ -static const WindowDesc _ai_config_desc( +static WindowDesc _ai_config_desc( WDP_CENTER, 0, 0, WC_GAME_OPTIONS, WC_NONE, 0, @@ -712,9 +712,9 @@ struct AIConfigWindow : public Window { int line_height; ///< Height of a single AI-name line. Scrollbar *vscroll; ///< Cache of the vertical scrollbar. - AIConfigWindow() : Window() + AIConfigWindow() : Window(&_ai_config_desc) { - this->InitNested(&_ai_config_desc, WN_GAME_OPTIONS_AI); // Initializes 'this->line_height' as a side effect. + this->InitNested(WN_GAME_OPTIONS_AI); // Initializes 'this->line_height' as a side effect. this->vscroll = this->GetScrollbar(WID_AIC_SCROLLBAR); this->selected_slot = INVALID_COMPANY; NWidgetCore *nwi = this->GetWidget<NWidgetCore>(WID_AIC_LIST); @@ -1042,13 +1042,13 @@ struct AIDebugWindow : public Window { * @param desc The description of the window. * @param number The window number (actually unused). */ - AIDebugWindow(const WindowDesc *desc, WindowNumber number) : break_editbox(MAX_BREAK_STR_STRING_LENGTH) + AIDebugWindow(WindowDesc *desc, WindowNumber number) : Window(desc), break_editbox(MAX_BREAK_STR_STRING_LENGTH) { - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_AID_SCROLLBAR); this->show_break_box = _settings_client.gui.ai_developer_tools; this->GetWidget<NWidgetStacked>(WID_AID_BREAK_STRING_WIDGETS)->SetDisplayedPlane(this->show_break_box ? 0 : SZSP_HORIZONTAL); - this->FinishInitNested(desc, number); + this->FinishInitNested(number); if (!this->show_break_box) break_check_enabled = false; @@ -1486,7 +1486,7 @@ static const NWidgetPart _nested_ai_debug_widgets[] = { }; /** Window definition for the AI debug window. */ -static const WindowDesc _ai_debug_desc( +static WindowDesc _ai_debug_desc( WDP_AUTO, 600, 450, WC_AI_DEBUG, WC_NONE, 0, diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index 8d97add91..55f7e4ad9 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -67,9 +67,9 @@ static void PlaceAirport(TileIndex tile) struct BuildAirToolbarWindow : Window { int last_user_action; // Last started user action. - BuildAirToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window() + BuildAirToolbarWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { - this->InitNested(desc, window_number); + this->InitNested(window_number); if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this); this->last_user_action = WIDGET_LIST_END; } @@ -165,7 +165,7 @@ static const NWidgetPart _nested_air_toolbar_widgets[] = { EndContainer(), }; -static const WindowDesc _air_toolbar_desc( +static WindowDesc _air_toolbar_desc( WDP_ALIGN_TOOLBAR, 0, 0, WC_BUILD_TOOLBAR, WC_NONE, WDF_CONSTRUCTION, @@ -215,15 +215,15 @@ class BuildAirportWindow : public PickerWindowBase { } public: - BuildAirportWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(parent) + BuildAirportWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) { - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_AP_SCROLLBAR); this->vscroll->SetCapacity(5); this->vscroll->SetPosition(0); - this->FinishInitNested(desc, TRANSPORT_AIR); + this->FinishInitNested(TRANSPORT_AIR); this->SetWidgetLoweredState(WID_AP_BTN_DONTHILIGHT, !_settings_client.gui.station_show_coverage); this->SetWidgetLoweredState(WID_AP_BTN_DOHILIGHT, _settings_client.gui.station_show_coverage); @@ -554,7 +554,7 @@ static const NWidgetPart _nested_build_airport_widgets[] = { EndContainer(), }; -static const WindowDesc _build_airport_desc( +static WindowDesc _build_airport_desc( WDP_AUTO, 0, 0, WC_BUILD_STATION, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index ef7cbdb56..7a1b8b297 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -189,7 +189,7 @@ class ReplaceVehicleWindow : public Window { } public: - ReplaceVehicleWindow(const WindowDesc *desc, VehicleType vehicletype, GroupID id_g) : Window() + ReplaceVehicleWindow(WindowDesc *desc, VehicleType vehicletype, GroupID id_g) : Window(desc) { if (vehicletype == VEH_TRAIN) { /* For rail vehicles find the most used vehicle type, which is usually @@ -217,10 +217,10 @@ public: this->sel_engine[0] = INVALID_ENGINE; this->sel_engine[1] = INVALID_ENGINE; - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll[0] = this->GetScrollbar(WID_RV_LEFT_SCROLLBAR); this->vscroll[1] = this->GetScrollbar(WID_RV_RIGHT_SCROLLBAR); - this->FinishInitNested(desc, vehicletype); + this->FinishInitNested(vehicletype); this->owner = _local_company; this->sel_group = id_g; @@ -563,7 +563,7 @@ static const NWidgetPart _nested_replace_rail_vehicle_widgets[] = { EndContainer(), }; -static const WindowDesc _replace_rail_vehicle_desc( +static WindowDesc _replace_rail_vehicle_desc( WDP_AUTO, 500, 140, WC_REPLACE_VEHICLE, WC_NONE, WDF_CONSTRUCTION, @@ -595,7 +595,7 @@ static const NWidgetPart _nested_replace_vehicle_widgets[] = { EndContainer(), }; -static const WindowDesc _replace_vehicle_desc( +static WindowDesc _replace_vehicle_desc( WDP_AUTO, 456, 118, WC_REPLACE_VEHICLE, WC_NONE, WDF_CONSTRUCTION, diff --git a/src/bootstrap_gui.cpp b/src/bootstrap_gui.cpp index c71ef2e1c..bfcf7eead 100644 --- a/src/bootstrap_gui.cpp +++ b/src/bootstrap_gui.cpp @@ -37,7 +37,7 @@ static const struct NWidgetPart _background_widgets[] = { /** * Window description for the background window to prevent smearing. */ -static const WindowDesc _background_desc( +static WindowDesc _background_desc( WDP_MANUAL, 0, 0, WC_BOOTSTRAP, WC_NONE, 0, @@ -47,9 +47,9 @@ static const WindowDesc _background_desc( /** The background for the game. */ class BootstrapBackground : public Window { public: - BootstrapBackground() : Window() + BootstrapBackground() : Window(&_background_desc) { - this->InitNested(&_background_desc, 0); + this->InitNested(0); CLRBITS(this->flags, WF_WHITE_BORDER); ResizeWindow(this, _screen.width, _screen.height); } @@ -70,7 +70,7 @@ static const NWidgetPart _nested_boostrap_download_status_window_widgets[] = { }; /** Window description for the download window */ -static const WindowDesc _bootstrap_download_status_window_desc( +static WindowDesc _bootstrap_download_status_window_desc( WDP_CENTER, 0, 0, WC_NETWORK_STATUS_WINDOW, WC_NONE, WDF_MODAL, @@ -115,7 +115,7 @@ static const NWidgetPart _bootstrap_query_widgets[] = { }; /** The window description for the query. */ -static const WindowDesc _bootstrap_query_desc( +static WindowDesc _bootstrap_query_desc( WDP_CENTER, 0, 0, WC_CONFIRM_POPUP_QUERY, WC_NONE, 0, @@ -128,9 +128,9 @@ class BootstrapAskForDownloadWindow : public Window, ContentCallback { public: /** Start listening to the content client events. */ - BootstrapAskForDownloadWindow() : Window() + BootstrapAskForDownloadWindow() : Window(&_bootstrap_query_desc) { - this->InitNested(&_bootstrap_query_desc, WN_CONFIRM_POPUP_QUERY_BOOTSTRAP); + 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 4a349b605..e6a0812a5 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -134,17 +134,17 @@ private: } public: - BuildBridgeWindow(const WindowDesc *desc, TileIndex start, TileIndex end, uint32 br_type, GUIBridgeList *bl) : Window(), + BuildBridgeWindow(WindowDesc *desc, TileIndex start, TileIndex end, uint32 br_type, GUIBridgeList *bl) : Window(desc), start_tile(start), end_tile(end), type(br_type), bridges(bl) { - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_BBS_SCROLLBAR); /* Change the data, or the caption of the gui. Set it to road or rail, accordingly. */ this->GetWidget<NWidgetCore>(WID_BBS_CAPTION)->widget_data = (GB(this->type, 15, 2) == TRANSPORT_ROAD) ? STR_SELECT_ROAD_BRIDGE_CAPTION : STR_SELECT_RAIL_BRIDGE_CAPTION; - this->FinishInitNested(desc, GB(br_type, 15, 2)); // Initializes 'this->bridgetext_offset'. + this->FinishInitNested(GB(br_type, 15, 2)); // Initializes 'this->bridgetext_offset'. this->parent = FindWindowById(WC_BUILD_TOOLBAR, GB(this->type, 15, 2)); this->bridges->SetListing(this->last_sorting); @@ -213,7 +213,7 @@ public: } } - virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number) + virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) { /* Position the window so hopefully the first bridge from the list is under the mouse pointer. */ NWidgetBase *list = this->GetWidget<NWidgetBase>(WID_BBS_BRIDGE_LIST); @@ -351,7 +351,7 @@ static const NWidgetPart _nested_build_bridge_widgets[] = { }; /** Window definition for the rail bridge selection window. */ -static const WindowDesc _build_bridge_desc( +static WindowDesc _build_bridge_desc( WDP_AUTO, 200, 114, WC_BUILD_BRIDGE, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 56a5d6321..9698e22eb 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -938,7 +938,7 @@ struct BuildVehicleWindow : Window { int details_height; ///< Minimal needed height of the details panels (found so far). Scrollbar *vscroll; - BuildVehicleWindow(const WindowDesc *desc, TileIndex tile, VehicleType type) : Window() + BuildVehicleWindow(WindowDesc *desc, TileIndex tile, VehicleType type) : Window(desc) { this->vehicle_type = type; this->window_number = tile == INVALID_TILE ? (int)type : tile; @@ -962,7 +962,7 @@ struct BuildVehicleWindow : Window { this->listview_mode = (this->window_number <= VEH_END); - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_BV_SCROLLBAR); @@ -983,7 +983,7 @@ struct BuildVehicleWindow : Window { this->details_height = ((this->vehicle_type == VEH_TRAIN) ? 10 : 9) * FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; - this->FinishInitNested(desc, tile == INVALID_TILE ? (int)type : tile); + this->FinishInitNested(tile == INVALID_TILE ? (int)type : tile); this->owner = (tile != INVALID_TILE) ? GetTileOwner(tile) : _local_company; @@ -1404,7 +1404,7 @@ struct BuildVehicleWindow : Window { } }; -static const WindowDesc _build_vehicle_desc( +static WindowDesc _build_vehicle_desc( WDP_AUTO, 240, 268, WC_BUILD_VEHICLE, WC_NONE, WDF_CONSTRUCTION, diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp index e4c7572ce..ac42cf913 100644 --- a/src/cheat_gui.cpp +++ b/src/cheat_gui.cpp @@ -170,9 +170,9 @@ struct CheatWindow : Window { int clicked; int header_height; - CheatWindow(const WindowDesc *desc) : Window() + CheatWindow(WindowDesc *desc) : Window(desc) { - this->InitNested(desc); + this->InitNested(); } virtual void DrawWidget(const Rect &r, int widget) const @@ -348,7 +348,7 @@ struct CheatWindow : Window { }; /** Window description of the cheats GUI. */ -static const WindowDesc _cheats_desc( +static WindowDesc _cheats_desc( WDP_AUTO, 0, 0, WC_CHEATS, WC_NONE, 0, diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 7a6f93a20..8ace49875 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -273,12 +273,12 @@ 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(const WindowDesc *desc, CompanyID company) : Window() + CompanyFinancesWindow(WindowDesc *desc, CompanyID company) : Window(desc) { this->small = false; - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->SetupWidgets(); - this->FinishInitNested(desc, company); + this->FinishInitNested(company); this->owner = (Owner)this->window_number; } @@ -463,7 +463,7 @@ struct CompanyFinancesWindow : Window { /** First conservative estimate of the maximum amount of money */ Money CompanyFinancesWindow::max_money = INT32_MAX; -static const WindowDesc _company_finances_desc( +static WindowDesc _company_finances_desc( WDP_AUTO, 0, 0, WC_FINANCES, WC_NONE, 0, @@ -581,7 +581,7 @@ private: } public: - SelectCompanyLiveryWindow(const WindowDesc *desc, CompanyID company) : Window() + SelectCompanyLiveryWindow(WindowDesc *desc, CompanyID company) : Window(desc) { this->livery_class = LC_OTHER; this->sel = 1; @@ -590,7 +590,7 @@ public: this->box = maxdim(GetSpriteSize(SPR_BOX_CHECKED), GetSpriteSize(SPR_BOX_EMPTY)); this->line_height = max(max(this->square.height, this->box.height), (uint)FONT_HEIGHT_NORMAL) + 4; - this->InitNested(desc, company); + this->InitNested(company); this->owner = company; this->LowerWidget(WID_SCL_CLASS_GENERAL); this->InvalidateData(1); @@ -841,7 +841,7 @@ static const NWidgetPart _nested_select_company_livery_widgets [] = { NWidget(WWT_MATRIX, COLOUR_GREY, WID_SCL_MATRIX), SetMinimalSize(275, 15), SetFill(1, 0), SetDataTip((1 << MAT_ROW_START) | (1 << MAT_COL_START), STR_LIVERY_PANEL_TOOLTIP), }; -static const WindowDesc _select_company_livery_desc( +static WindowDesc _select_company_livery_desc( WDP_AUTO, 0, 0, WC_COMPANY_COLOUR, WC_NONE, 0, @@ -1077,12 +1077,12 @@ class SelectCompanyManagerFaceWindow : public Window } public: - SelectCompanyManagerFaceWindow(const WindowDesc *desc, Window *parent) : Window() + SelectCompanyManagerFaceWindow(WindowDesc *desc, Window *parent) : Window(desc) { this->advanced = false; - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->SelectDisplayPlanes(this->advanced); - this->FinishInitNested(desc, parent->window_number); + this->FinishInitNested(parent->window_number); this->parent = parent; this->owner = (Owner)this->window_number; this->face = Company::Get((CompanyID)this->window_number)->face; @@ -1479,7 +1479,7 @@ const StringID SelectCompanyManagerFaceWindow::PART_TEXTS[] = { }; /** Company manager face selection window description */ -static const WindowDesc _select_company_manager_face_desc( +static WindowDesc _select_company_manager_face_desc( WDP_AUTO, 0, 0, WC_COMPANY_MANAGER_FACE, WC_NONE, WDF_CONSTRUCTION, @@ -1545,11 +1545,11 @@ struct CompanyInfrastructureWindow : Window uint total_width; ///< String width of the total cost line. - CompanyInfrastructureWindow(const WindowDesc *desc, WindowNumber window_number) : Window() + CompanyInfrastructureWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { this->UpdateRailRoadTypes(); - this->InitNested(desc, window_number); + this->InitNested(window_number); this->owner = (Owner)this->window_number; } @@ -1833,7 +1833,7 @@ struct CompanyInfrastructureWindow : Window } }; -static const WindowDesc _company_infrastructure_desc( +static WindowDesc _company_infrastructure_desc( WDP_AUTO, 0, 0, WC_COMPANY_INFRASTRUCTURE, WC_NONE, 0, @@ -1983,9 +1983,9 @@ struct CompanyWindow : Window CWP_BUTTONS_OTHER, ///< Buttons of the other companies. }; - CompanyWindow(const WindowDesc *desc, WindowNumber window_number) : Window() + CompanyWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { - this->InitNested(desc, window_number); + this->InitNested(window_number); this->owner = (Owner)this->window_number; this->OnInvalidateData(); } @@ -2410,7 +2410,7 @@ struct CompanyWindow : Window } }; -static const WindowDesc _company_desc( +static WindowDesc _company_desc( WDP_AUTO, 0, 0, WC_COMPANY, WC_NONE, 0, @@ -2439,9 +2439,9 @@ void DirtyCompanyInfrastructureWindows(CompanyID company) } struct BuyCompanyWindow : Window { - BuyCompanyWindow(const WindowDesc *desc, WindowNumber window_number) : Window() + BuyCompanyWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { - this->InitNested(desc, window_number); + this->InitNested(window_number); } virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) @@ -2522,7 +2522,7 @@ static const NWidgetPart _nested_buy_company_widgets[] = { EndContainer(), }; -static const WindowDesc _buy_company_desc( +static WindowDesc _buy_company_desc( WDP_AUTO, 0, 0, WC_BUY_COMPANY, WC_NONE, WDF_CONSTRUCTION, diff --git a/src/console_gui.cpp b/src/console_gui.cpp index ca0a01853..5787a5089 100644 --- a/src/console_gui.cpp +++ b/src/console_gui.cpp @@ -158,7 +158,7 @@ static const struct NWidgetPart _nested_console_window_widgets[] = { NWidget(WWT_EMPTY, INVALID_COLOUR, WID_C_BACKGROUND), SetResize(1, 1), }; -static const WindowDesc _console_window_desc( +static WindowDesc _console_window_desc( WDP_MANUAL, 0, 0, WC_CONSOLE, WC_NONE, 0, @@ -171,13 +171,13 @@ struct IConsoleWindow : Window int line_height; ///< Height of one line of text in the console. int line_offset; - IConsoleWindow() : Window() + IConsoleWindow() : Window(&_console_window_desc) { _iconsole_mode = ICONSOLE_OPENED; this->line_height = FONT_HEIGHT_NORMAL + ICON_LINE_SPACING; this->line_offset = GetStringBoundingBox("] ").width + 5; - this->InitNested(&_console_window_desc, 0); + this->InitNested(0); ResizeWindow(this, _screen.width, _screen.height / 3); } diff --git a/src/date_gui.cpp b/src/date_gui.cpp index b2421556c..771d0e1e0 100644 --- a/src/date_gui.cpp +++ b/src/date_gui.cpp @@ -38,22 +38,22 @@ 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(const WindowDesc *desc, WindowNumber window_number, Window *parent, Date initial_date, Year min_year, Year max_year, SetDateCallback *callback) : - Window(), + SetDateWindow(WindowDesc *desc, WindowNumber window_number, Window *parent, Date initial_date, Year min_year, Year max_year, SetDateCallback *callback) : + Window(desc), callback(callback), min_year(max(MIN_YEAR, min_year)), max_year(min(MAX_YEAR, max_year)) { assert(this->min_year <= this->max_year); this->parent = parent; - this->InitNested(desc, window_number); + this->InitNested(window_number); if (initial_date == 0) initial_date = _date; ConvertDateToYMD(initial_date, &this->date); this->date.year = Clamp(this->date.year, min_year, max_year); } - virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number) + virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) { Point pt = { this->parent->left + this->parent->width / 2 - sm_width / 2, this->parent->top + this->parent->height / 2 - sm_height / 2 }; return pt; @@ -194,7 +194,7 @@ static const NWidgetPart _nested_set_date_widgets[] = { }; /** Description of the date setting window. */ -static const WindowDesc _set_date_desc( +static WindowDesc _set_date_desc( WDP_CENTER, 0, 0, WC_SET_DATE, WC_NONE, 0, diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index bfdf293fc..27280dadb 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -78,28 +78,28 @@ static const NWidgetPart _nested_train_depot_widgets[] = { EndContainer(), }; -static const WindowDesc _train_depot_desc( +static WindowDesc _train_depot_desc( WDP_AUTO, 362, 123, WC_VEHICLE_DEPOT, WC_NONE, 0, _nested_train_depot_widgets, lengthof(_nested_train_depot_widgets) ); -static const WindowDesc _road_depot_desc( +static WindowDesc _road_depot_desc( WDP_AUTO, 316, 97, WC_VEHICLE_DEPOT, WC_NONE, 0, _nested_train_depot_widgets, lengthof(_nested_train_depot_widgets) ); -static const WindowDesc _ship_depot_desc( +static WindowDesc _ship_depot_desc( WDP_AUTO, 306, 99, WC_VEHICLE_DEPOT, WC_NONE, 0, _nested_train_depot_widgets, lengthof(_nested_train_depot_widgets) ); -static const WindowDesc _aircraft_depot_desc( +static WindowDesc _aircraft_depot_desc( WDP_AUTO, 332, 99, WC_VEHICLE_DEPOT, WC_NONE, 0, @@ -229,7 +229,7 @@ struct DepotWindow : Window { Scrollbar *hscroll; ///< Only for trains. Scrollbar *vscroll; - DepotWindow(const WindowDesc *desc, TileIndex tile, VehicleType type) : Window() + DepotWindow(WindowDesc *desc, TileIndex tile, VehicleType type) : Window(desc) { assert(IsCompanyBuildableVehicleType(type)); // ensure that we make the call with a valid type @@ -239,7 +239,7 @@ struct DepotWindow : Window { this->type = type; this->num_columns = 1; // for non-trains this gets set in FinishInitNested() - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->hscroll = (this->type == VEH_TRAIN ? this->GetScrollbar(WID_D_H_SCROLL) : NULL); this->vscroll = this->GetScrollbar(WID_D_V_SCROLL); /* Don't show 'rename button' of aircraft hangar */ @@ -248,7 +248,7 @@ struct DepotWindow : Window { this->GetWidget<NWidgetStacked>(WID_D_SHOW_H_SCROLL)->SetDisplayedPlane(type == VEH_TRAIN ? 0 : SZSP_HORIZONTAL); this->GetWidget<NWidgetStacked>(WID_D_SHOW_SELL_CHAIN)->SetDisplayedPlane(type == VEH_TRAIN ? 0 : SZSP_NONE); this->SetupWidgetData(type); - this->FinishInitNested(desc, tile); + this->FinishInitNested(tile); this->owner = GetTileOwner(tile); OrderBackup::Reset(); @@ -1009,7 +1009,7 @@ void ShowDepotWindow(TileIndex tile, VehicleType type) { if (BringWindowToFrontById(WC_VEHICLE_DEPOT, tile) != NULL) return; - const WindowDesc *desc; + WindowDesc *desc; switch (type) { default: NOT_REACHED(); case VEH_TRAIN: desc = &_train_depot_desc; break; diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index d3c8a280e..d6fbd53f2 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -91,10 +91,10 @@ 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(const WindowDesc *desc, WindowNumber window_number) : Window() + BuildDocksToolbarWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { this->last_clicked_widget = WID_DT_INVALID; - this->InitNested(desc, window_number); + this->InitNested(window_number); this->OnInvalidateData(); if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this); } @@ -313,7 +313,7 @@ static const NWidgetPart _nested_build_docks_toolbar_widgets[] = { EndContainer(), }; -static const WindowDesc _build_docks_toolbar_desc( +static WindowDesc _build_docks_toolbar_desc( WDP_ALIGN_TOOLBAR, 0, 0, WC_BUILD_TOOLBAR, WC_NONE, WDF_CONSTRUCTION, @@ -365,7 +365,7 @@ static const NWidgetPart _nested_build_docks_scen_toolbar_widgets[] = { }; /** Window definition for the build docks in scenario editor window. */ -static const WindowDesc _build_docks_scen_toolbar_desc( +static WindowDesc _build_docks_scen_toolbar_desc( WDP_AUTO, 0, 0, WC_SCEN_BUILD_TOOLBAR, WC_NONE, WDF_CONSTRUCTION, @@ -392,9 +392,9 @@ enum BuildDockStationWidgets { struct BuildDocksStationWindow : public PickerWindowBase { public: - BuildDocksStationWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(parent) + BuildDocksStationWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) { - this->InitNested(desc, TRANSPORT_WATER); + this->InitNested(TRANSPORT_WATER); this->LowerWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF); } @@ -465,7 +465,7 @@ static const NWidgetPart _nested_build_dock_station_widgets[] = { EndContainer(), }; -static const WindowDesc _build_dock_station_desc( +static WindowDesc _build_dock_station_desc( WDP_AUTO, 0, 0, WC_BUILD_STATION, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, @@ -489,9 +489,9 @@ private: } public: - BuildDocksDepotWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(parent) + BuildDocksDepotWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) { - this->InitNested(desc, TRANSPORT_WATER); + this->InitNested(TRANSPORT_WATER); this->LowerWidget(_ship_depot_direction + WID_BDD_X); UpdateDocksDirection(); } @@ -542,7 +542,7 @@ static const NWidgetPart _nested_build_docks_depot_widgets[] = { EndContainer(), }; -static const WindowDesc _build_docks_depot_desc( +static WindowDesc _build_docks_depot_desc( WDP_AUTO, 0, 0, WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index a2f5b919c..8f4252f85 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -61,9 +61,9 @@ static const NWidgetPart _nested_engine_preview_widgets[] = { struct EnginePreviewWindow : Window { static const int VEHICLE_SPACE = 40; // The space to show the vehicle image - EnginePreviewWindow(const WindowDesc *desc, WindowNumber window_number) : Window() + EnginePreviewWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { - this->InitNested(desc, window_number); + this->InitNested(window_number); /* There is no way to recover the window; so disallow closure via DEL; unless SHIFT+DEL */ this->flags |= WF_STICKY; @@ -120,7 +120,7 @@ struct EnginePreviewWindow : Window { } }; -static const WindowDesc _engine_preview_desc( +static WindowDesc _engine_preview_desc( WDP_CENTER, 0, 0, WC_ENGINE_PREVIEW, WC_NONE, WDF_CONSTRUCTION, diff --git a/src/error.h b/src/error.h index 438d70d96..4a78a07aa 100644 --- a/src/error.h +++ b/src/error.h @@ -42,6 +42,9 @@ public: ~ErrorMessageData(); ErrorMessageData(StringID summary_msg, StringID detailed_msg, uint duration = 0, int x = 0, int y = 0, uint textref_stack_size = 0, const uint32 *textref_stack = NULL); + /** Check whether error window shall display a company manager face */ + bool HasFace() const { return face != INVALID_COMPANY; } + void SetDParam(uint n, uint64 v); void SetDParamStr(uint n, const char *str); diff --git a/src/error_gui.cpp b/src/error_gui.cpp index db73d31b2..df5aa7b6d 100644 --- a/src/error_gui.cpp +++ b/src/error_gui.cpp @@ -39,7 +39,7 @@ static const NWidgetPart _nested_errmsg_widgets[] = { EndContainer(), }; -static const WindowDesc _errmsg_desc( +static WindowDesc _errmsg_desc( WDP_MANUAL, 0, 0, WC_ERRMSG, WC_NONE, 0, @@ -59,7 +59,7 @@ static const NWidgetPart _nested_errmsg_face_widgets[] = { EndContainer(), }; -static const WindowDesc _errmsg_face_desc( +static WindowDesc _errmsg_face_desc( WDP_MANUAL, 0, 0, WC_ERRMSG, WC_NONE, 0, @@ -171,9 +171,9 @@ private: uint height_detailed; ///< Height of the #detailed_msg string in pixels in the #WID_EM_MESSAGE widget. public: - ErrmsgWindow(const ErrorMessageData &data) : Window(), ErrorMessageData(data) + ErrmsgWindow(const ErrorMessageData &data) : Window(data.HasFace() ? &_errmsg_face_desc : &_errmsg_desc), ErrorMessageData(data) { - this->InitNested((this->face == INVALID_COMPANY) ? &_errmsg_desc : &_errmsg_face_desc); + this->InitNested(); } virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) @@ -195,7 +195,7 @@ public: size->height = max(size->height, panel_height); } - virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number) + virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) { /* Position (0, 0) given, center the window. */ if (this->position.x == 0 && this->position.y == 0) { diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index 498798b13..e186c7e12 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -243,7 +243,7 @@ public: this->filename_editbox.text.UpdateSize(); } - SaveLoadWindow(const WindowDesc *desc, SaveLoadDialogMode mode) : filename_editbox(64) + SaveLoadWindow(WindowDesc *desc, SaveLoadDialogMode mode) : Window(desc), filename_editbox(64) { static const StringID saveload_captions[] = { STR_SAVELOAD_LOAD_CAPTION, @@ -267,12 +267,12 @@ public: this->querystrings[WID_SL_SAVE_OSK_TITLE] = &this->filename_editbox; this->filename_editbox.ok_button = WID_SL_SAVE_GAME; - this->CreateNestedTree(desc, true); + this->CreateNestedTree(true); if (mode == SLD_LOAD_GAME) this->GetWidget<NWidgetStacked>(WID_SL_CONTENT_DOWNLOAD_SEL)->SetDisplayedPlane(SZSP_HORIZONTAL); this->GetWidget<NWidgetCore>(WID_SL_CAPTION)->widget_data = saveload_captions[mode]; this->vscroll = this->GetScrollbar(WID_SL_SCROLLBAR); - this->FinishInitNested(desc, 0); + this->FinishInitNested(0); this->LowerWidget(WID_SL_DRIVES_DIRECTORIES_LIST); @@ -696,7 +696,7 @@ public: }; /** Load game/scenario */ -static const WindowDesc _load_dialog_desc( +static WindowDesc _load_dialog_desc( WDP_CENTER, 500, 294, WC_SAVELOAD, WC_NONE, 0, @@ -704,7 +704,7 @@ static const WindowDesc _load_dialog_desc( ); /** Load heightmap */ -static const WindowDesc _load_heightmap_dialog_desc( +static WindowDesc _load_heightmap_dialog_desc( WDP_CENTER, 257, 320, WC_SAVELOAD, WC_NONE, 0, @@ -712,7 +712,7 @@ static const WindowDesc _load_heightmap_dialog_desc( ); /** Save game/scenario */ -static const WindowDesc _save_dialog_desc( +static WindowDesc _save_dialog_desc( WDP_CENTER, 500, 294, WC_SAVELOAD, WC_NONE, 0, @@ -740,7 +740,7 @@ void ShowSaveLoadDialog(SaveLoadDialogMode mode) { DeleteWindowById(WC_SAVELOAD, 0); - const WindowDesc *sld; + WindowDesc *sld; switch (mode) { case SLD_SAVE_GAME: case SLD_SAVE_SCENARIO: diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index 82f285748..f5da7f950 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -311,9 +311,9 @@ struct GenerateLandscapeWindow : public Window { GenenerateLandscapeWindowMode mode; QueryString seed_editbox; - GenerateLandscapeWindow(const WindowDesc *desc, WindowNumber number = 0) : seed_editbox(11) + GenerateLandscapeWindow(WindowDesc *desc, WindowNumber number = 0) : Window(desc), seed_editbox(11) { - this->InitNested(desc, number); + this->InitNested(number); this->LowerWidget(_settings_newgame.game_creation.landscape + WID_GL_TEMPERATE); @@ -796,14 +796,14 @@ struct GenerateLandscapeWindow : public Window { } }; -static const WindowDesc _generate_landscape_desc( +static WindowDesc _generate_landscape_desc( WDP_CENTER, 0, 0, WC_GENERATE_LANDSCAPE, WC_NONE, 0, _nested_generate_landscape_widgets, lengthof(_nested_generate_landscape_widgets) ); -static const WindowDesc _heightmap_load_desc( +static WindowDesc _heightmap_load_desc( WDP_CENTER, 0, 0, WC_GENERATE_LANDSCAPE, WC_NONE, 0, @@ -870,9 +870,9 @@ struct CreateScenarioWindow : public Window { uint widget_id; - CreateScenarioWindow(const WindowDesc *desc, WindowNumber window_number) : Window() + CreateScenarioWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { - this->InitNested(desc, window_number); + this->InitNested(window_number); this->LowerWidget(_settings_newgame.game_creation.landscape + WID_CS_TEMPERATE); } @@ -1097,7 +1097,7 @@ static const NWidgetPart _nested_create_scenario_widgets[] = { EndContainer(), }; -static const WindowDesc _create_scenario_desc( +static WindowDesc _create_scenario_desc( WDP_CENTER, 0, 0, WC_GENERATE_LANDSCAPE, WC_NONE, 0, @@ -1125,7 +1125,7 @@ static const NWidgetPart _nested_generate_progress_widgets[] = { }; -static const WindowDesc _generate_progress_desc( +static WindowDesc _generate_progress_desc( WDP_CENTER, 0, 0, WC_MODAL_PROGRESS, WC_NONE, 0, @@ -1170,9 +1170,9 @@ static void AbortGeneratingWorldCallback(Window *w, bool confirmed) struct GenerateProgressWindow : public Window { - GenerateProgressWindow() : Window() + GenerateProgressWindow() : Window(&_generate_progress_desc) { - this->InitNested(&_generate_progress_desc); + this->InitNested(); } virtual void OnClick(Point pt, int widget, int click_count) diff --git a/src/goal_gui.cpp b/src/goal_gui.cpp index cf0e63398..e738617a6 100644 --- a/src/goal_gui.cpp +++ b/src/goal_gui.cpp @@ -29,11 +29,11 @@ struct GoalListWindow : Window { Scrollbar *vscroll; - GoalListWindow(const WindowDesc *desc, WindowNumber window_number) : Window() + GoalListWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_GL_SCROLLBAR); - this->FinishInitNested(desc, window_number); + this->FinishInitNested(window_number); this->OnInvalidateData(0); } @@ -230,7 +230,7 @@ static const NWidgetPart _nested_goals_list_widgets[] = { EndContainer(), }; -static const WindowDesc _goals_list_desc( +static WindowDesc _goals_list_desc( WDP_AUTO, 500, 127, WC_GOALS_LIST, WC_NONE, 0, @@ -250,7 +250,7 @@ struct GoalQuestionWindow : Window { int button[3]; byte type; - GoalQuestionWindow(const WindowDesc *desc, WindowNumber window_number, byte type, uint32 button_mask, const char *question) : Window(), type(type) + GoalQuestionWindow(WindowDesc *desc, WindowNumber window_number, byte type, uint32 button_mask, const char *question) : Window(desc), type(type) { assert(type < GOAL_QUESTION_TYPE_COUNT); this->question = strdup(question); @@ -266,9 +266,9 @@ struct GoalQuestionWindow : Window { this->buttons = n; assert(this->buttons > 0 && this->buttons < 4); - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->GetWidget<NWidgetStacked>(WID_GQ_BUTTONS)->SetDisplayedPlane(this->buttons - 1); - this->FinishInitNested(desc, window_number); + this->FinishInitNested(window_number); } ~GoalQuestionWindow() @@ -359,7 +359,7 @@ static const NWidgetPart _nested_goal_question_widgets[] = { EndContainer(), }; -static const WindowDesc _goal_question_list_desc( +static WindowDesc _goal_question_list_desc( WDP_CENTER, 0, 0, WC_GOAL_QUESTION, WC_NONE, WDF_CONSTRUCTION, diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index ab264f3a9..7a4abdeaf 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -43,9 +43,9 @@ static const uint INVALID_DATAPOINT_POS = UINT_MAX; // Used to determine if the /****************/ struct GraphLegendWindow : Window { - GraphLegendWindow(const WindowDesc *desc, WindowNumber window_number) : Window() + GraphLegendWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { - this->InitNested(desc, window_number); + this->InitNested(window_number); for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) { if (!HasBit(_legend_excluded_companies, c)) this->LowerWidget(c + WID_GL_FIRST_COMPANY); @@ -140,7 +140,7 @@ static const NWidgetPart _nested_graph_legend_widgets[] = { EndContainer(), }; -static const WindowDesc _graph_legend_desc( +static WindowDesc _graph_legend_desc( WDP_AUTO, 0, 0, WC_GRAPH_LEGEND, WC_NONE, 0, @@ -463,8 +463,8 @@ protected: } - BaseGraphWindow(int widget, StringID format_str_y_axis) : - Window(), + BaseGraphWindow(WindowDesc *desc, int widget, StringID format_str_y_axis) : + Window(desc), format_str_y_axis(format_str_y_axis) { SetWindowDirty(WC_GRAPH_LEGEND, 0); @@ -472,12 +472,12 @@ protected: this->graph_widget = widget; } - void InitializeWindow(const WindowDesc *desc, WindowNumber number) + void InitializeWindow(WindowNumber number) { /* Initialise the dataset */ this->UpdateStatistics(true); - this->InitNested(desc, number); + this->InitNested(number); } public: @@ -611,10 +611,10 @@ public: /********************/ struct OperatingProfitGraphWindow : BaseGraphWindow { - OperatingProfitGraphWindow(const WindowDesc *desc, WindowNumber window_number) : - BaseGraphWindow(WID_CV_GRAPH, STR_JUST_CURRENCY_SHORT) + OperatingProfitGraphWindow(WindowDesc *desc, WindowNumber window_number) : + BaseGraphWindow(desc, WID_CV_GRAPH, STR_JUST_CURRENCY_SHORT) { - this->InitializeWindow(desc, window_number); + this->InitializeWindow(window_number); } virtual OverflowSafeInt64 GetGraphData(const Company *c, int j) @@ -642,7 +642,7 @@ static const NWidgetPart _nested_operating_profit_widgets[] = { EndContainer(), }; -static const WindowDesc _operating_profit_desc( +static WindowDesc _operating_profit_desc( WDP_AUTO, 0, 0, WC_OPERATING_PROFIT, WC_NONE, 0, @@ -661,10 +661,10 @@ void ShowOperatingProfitGraph() /****************/ struct IncomeGraphWindow : BaseGraphWindow { - IncomeGraphWindow(const WindowDesc *desc, WindowNumber window_number) : - BaseGraphWindow(WID_CV_GRAPH, STR_JUST_CURRENCY_SHORT) + IncomeGraphWindow(WindowDesc *desc, WindowNumber window_number) : + BaseGraphWindow(desc, WID_CV_GRAPH, STR_JUST_CURRENCY_SHORT) { - this->InitializeWindow(desc, window_number); + this->InitializeWindow(window_number); } virtual OverflowSafeInt64 GetGraphData(const Company *c, int j) @@ -692,7 +692,7 @@ static const NWidgetPart _nested_income_graph_widgets[] = { EndContainer(), }; -static const WindowDesc _income_graph_desc( +static WindowDesc _income_graph_desc( WDP_AUTO, 0, 0, WC_INCOME_GRAPH, WC_NONE, 0, @@ -709,10 +709,10 @@ void ShowIncomeGraph() /*******************/ struct DeliveredCargoGraphWindow : BaseGraphWindow { - DeliveredCargoGraphWindow(const WindowDesc *desc, WindowNumber window_number) : - BaseGraphWindow(WID_CV_GRAPH, STR_JUST_COMMA) + DeliveredCargoGraphWindow(WindowDesc *desc, WindowNumber window_number) : + BaseGraphWindow(desc, WID_CV_GRAPH, STR_JUST_COMMA) { - this->InitializeWindow(desc, window_number); + this->InitializeWindow(window_number); } virtual OverflowSafeInt64 GetGraphData(const Company *c, int j) @@ -740,7 +740,7 @@ static const NWidgetPart _nested_delivered_cargo_graph_widgets[] = { EndContainer(), }; -static const WindowDesc _delivered_cargo_graph_desc( +static WindowDesc _delivered_cargo_graph_desc( WDP_AUTO, 0, 0, WC_DELIVERED_CARGO, WC_NONE, 0, @@ -757,10 +757,10 @@ void ShowDeliveredCargoGraph() /***********************/ struct PerformanceHistoryGraphWindow : BaseGraphWindow { - PerformanceHistoryGraphWindow(const WindowDesc *desc, WindowNumber window_number) : - BaseGraphWindow(WID_PHG_GRAPH, STR_JUST_COMMA) + PerformanceHistoryGraphWindow(WindowDesc *desc, WindowNumber window_number) : + BaseGraphWindow(desc, WID_PHG_GRAPH, STR_JUST_COMMA) { - this->InitializeWindow(desc, window_number); + this->InitializeWindow(window_number); } virtual OverflowSafeInt64 GetGraphData(const Company *c, int j) @@ -795,7 +795,7 @@ static const NWidgetPart _nested_performance_history_widgets[] = { EndContainer(), }; -static const WindowDesc _performance_history_desc( +static WindowDesc _performance_history_desc( WDP_AUTO, 0, 0, WC_PERFORMANCE_HISTORY, WC_NONE, 0, @@ -812,10 +812,10 @@ void ShowPerformanceHistoryGraph() /*****************/ struct CompanyValueGraphWindow : BaseGraphWindow { - CompanyValueGraphWindow(const WindowDesc *desc, WindowNumber window_number) : - BaseGraphWindow(WID_CV_GRAPH, STR_JUST_CURRENCY_SHORT) + CompanyValueGraphWindow(WindowDesc *desc, WindowNumber window_number) : + BaseGraphWindow(desc, WID_CV_GRAPH, STR_JUST_CURRENCY_SHORT) { - this->InitializeWindow(desc, window_number); + this->InitializeWindow(window_number); } virtual OverflowSafeInt64 GetGraphData(const Company *c, int j) @@ -843,7 +843,7 @@ static const NWidgetPart _nested_company_value_graph_widgets[] = { EndContainer(), }; -static const WindowDesc _company_value_graph_desc( +static WindowDesc _company_value_graph_desc( WDP_AUTO, 0, 0, WC_COMPANY_VALUE, WC_NONE, 0, @@ -861,8 +861,8 @@ void ShowCompanyValueGraph() struct PaymentRatesGraphWindow : BaseGraphWindow { bool first_init; ///< This value is true until the first initialization of the window has finished. - PaymentRatesGraphWindow(const WindowDesc *desc, WindowNumber window_number) : - BaseGraphWindow(WID_CPR_GRAPH, STR_JUST_CURRENCY_SHORT) + PaymentRatesGraphWindow(WindowDesc *desc, WindowNumber window_number) : + BaseGraphWindow(desc, WID_CPR_GRAPH, STR_JUST_CURRENCY_SHORT) { this->first_init = true; this->num_on_x_axis = 20; @@ -874,7 +874,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { /* Initialise the dataset */ this->OnHundredthTick(); - this->InitNested(desc, window_number); + this->InitNested(window_number); this->UpdateLoweredWidgets(); } @@ -1073,7 +1073,7 @@ static const NWidgetPart _nested_cargo_payment_rates_widgets[] = { EndContainer(), }; -static const WindowDesc _cargo_payment_rates_desc( +static WindowDesc _cargo_payment_rates_desc( WDP_AUTO, 0, 0, WC_PAYMENT_RATES, WC_NONE, 0, @@ -1147,9 +1147,9 @@ private: } public: - CompanyLeagueWindow(const WindowDesc *desc, WindowNumber window_number) : Window() + CompanyLeagueWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { - this->InitNested(desc, window_number); + this->InitNested(window_number); this->companies.ForceRebuild(); this->companies.NeedResort(); } @@ -1262,7 +1262,7 @@ static const NWidgetPart _nested_company_league_widgets[] = { NWidget(WWT_PANEL, COLOUR_GREY, WID_CL_BACKGROUND), SetMinimalSize(400, 0), SetMinimalTextLines(15, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM), }; -static const WindowDesc _company_league_desc( +static WindowDesc _company_league_desc( WDP_AUTO, 0, 0, WC_COMPANY_LEAGUE, WC_NONE, 0, @@ -1282,11 +1282,11 @@ struct PerformanceRatingDetailWindow : Window { static CompanyID company; int timeout; - PerformanceRatingDetailWindow(const WindowDesc *desc, WindowNumber window_number) : Window() + PerformanceRatingDetailWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { this->UpdateCompanyStats(); - this->InitNested(desc, window_number); + this->InitNested(window_number); this->OnInvalidateData(INVALID_COMPANY); } @@ -1561,7 +1561,7 @@ static const NWidgetPart _nested_performance_rating_detail_widgets[] = { NWidgetFunction(MakePerformanceDetailPanels), }; -static const WindowDesc _performance_rating_detail_desc( +static WindowDesc _performance_rating_detail_desc( WDP_AUTO, 0, 0, WC_PERFORMANCE_DETAIL, WC_NONE, 0, diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 3996ddc18..a37a056d3 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -277,9 +277,9 @@ private: } public: - VehicleGroupWindow(const WindowDesc *desc, WindowNumber window_number) : BaseVehicleListWindow(window_number) + VehicleGroupWindow(WindowDesc *desc, WindowNumber window_number) : BaseVehicleListWindow(desc, window_number) { - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_GL_LIST_VEHICLE_SCROLLBAR); this->group_sb = this->GetScrollbar(WID_GL_LIST_GROUP_SCROLLBAR); @@ -317,7 +317,7 @@ public: this->GetWidget<NWidgetCore>(WID_GL_DELETE_GROUP)->widget_data += this->vli.vtype; this->GetWidget<NWidgetCore>(WID_GL_REPLACE_PROTECTION)->widget_data += this->vli.vtype; - this->FinishInitNested(desc, window_number); + this->FinishInitNested(window_number); this->owner = vli.company; } @@ -805,7 +805,7 @@ static WindowDesc _other_group_desc( _nested_group_widgets, lengthof(_nested_group_widgets) ); -static const WindowDesc _train_group_desc( +static WindowDesc _train_group_desc( WDP_AUTO, 525, 246, WC_TRAINS_LIST, WC_NONE, 0, diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp index 768b32e49..50bb33c5e 100644 --- a/src/highscore_gui.cpp +++ b/src/highscore_gui.cpp @@ -29,9 +29,9 @@ struct EndGameHighScoreBaseWindow : Window { uint32 background_img; int8 rank; - EndGameHighScoreBaseWindow(const WindowDesc *desc) : Window() + EndGameHighScoreBaseWindow(WindowDesc *desc) : Window(desc) { - this->InitNested(desc); + this->InitNested(); CLRBITS(this->flags, WF_WHITE_BORDER); ResizeWindow(this, _screen.width - this->width, _screen.height - this->height); } @@ -89,7 +89,7 @@ struct EndGameHighScoreBaseWindow : Window { /** End game window shown at the end of the game */ struct EndGameWindow : EndGameHighScoreBaseWindow { - EndGameWindow(const 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) DoCommandP(0, PM_PAUSED_NORMAL, 1, CMD_PAUSE); @@ -150,7 +150,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(const WindowDesc *desc, int difficulty, int8 ranking) : EndGameHighScoreBaseWindow(desc) + HighScoreWindow(WindowDesc *desc, int difficulty, int8 ranking) : EndGameHighScoreBaseWindow(desc) { /* pause game to show the chart */ this->game_paused_by_player = _pause_mode == PM_PAUSED_NORMAL; @@ -203,14 +203,14 @@ static const NWidgetPart _nested_highscore_widgets[] = { NWidget(WWT_PANEL, COLOUR_BROWN, WID_H_BACKGROUND), SetMinimalSize(641, 481), SetResize(1, 1), EndContainer(), }; -static const WindowDesc _highscore_desc( +static WindowDesc _highscore_desc( WDP_MANUAL, 0, 0, WC_HIGHSCORE, WC_NONE, 0, _nested_highscore_widgets, lengthof(_nested_highscore_widgets) ); -static const WindowDesc _endgame_desc( +static WindowDesc _endgame_desc( WDP_MANUAL, 0, 0, WC_ENDSCREEN, WC_NONE, 0, diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 1b79ebbd0..356c6b77b 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -187,7 +187,7 @@ static const NWidgetPart _nested_build_industry_widgets[] = { }; /** Window definition of the dynamic place industries gui */ -static const WindowDesc _build_industry_desc( +static WindowDesc _build_industry_desc( WDP_AUTO, 170, 212, WC_BUILD_INDUSTRY, WC_NONE, WDF_CONSTRUCTION, @@ -265,7 +265,7 @@ class BuildIndustryWindow : public Window { } public: - BuildIndustryWindow() : Window() + BuildIndustryWindow() : Window(&_build_industry_desc) { this->timer_enabled = _loaded_newgrf_features.has_newindustries; @@ -274,9 +274,9 @@ public: this->callback_timer = DAY_TICKS; - this->CreateNestedTree(&_build_industry_desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_DPI_SCROLLBAR); - this->FinishInitNested(&_build_industry_desc, 0); + this->FinishInitNested(0); this->SetButtons(); } @@ -654,7 +654,7 @@ class IndustryViewWindow : public Window int info_height; ///< Height needed for the #WID_IV_INFO panel public: - IndustryViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window() + IndustryViewWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { this->flags |= WF_DISABLE_VP_SCROLL; this->editbox_line = IL_NONE; @@ -662,7 +662,7 @@ public: this->clicked_button = 0; this->info_height = WD_FRAMERECT_TOP + 2 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM + 1; // Info panel has at least two lines text. - this->InitNested(desc, window_number); + this->InitNested(window_number); NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_IV_VIEWPORT); nvp->InitializeViewport(this, Industry::Get(window_number)->location.GetCenterTile(), ZOOM_LVL_INDUSTRY); @@ -1017,7 +1017,7 @@ static const NWidgetPart _nested_industry_view_widgets[] = { }; /** Window definition of the view industry gui */ -static const WindowDesc _industry_view_desc( +static WindowDesc _industry_view_desc( WDP_AUTO, 260, 120, WC_INDUSTRY_VIEW, WC_NONE, 0, @@ -1213,9 +1213,9 @@ protected: } public: - IndustryDirectoryWindow(const WindowDesc *desc, WindowNumber number) : Window() + IndustryDirectoryWindow(WindowDesc *desc, WindowNumber number) : Window(desc) { - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_ID_SCROLLBAR); this->industries.SetListing(this->last_sorting); @@ -1223,7 +1223,7 @@ public: this->industries.ForceRebuild(); this->BuildSortIndustriesList(); - this->FinishInitNested(desc, 0); + this->FinishInitNested(0); } ~IndustryDirectoryWindow() @@ -1388,7 +1388,7 @@ const StringID IndustryDirectoryWindow::sorter_names[] = { /** Window definition of the industry directory gui */ -static const WindowDesc _industry_directory_desc( +static WindowDesc _industry_directory_desc( WDP_AUTO, 428, 190, WC_INDUSTRY_DIRECTORY, WC_NONE, 0, @@ -1429,7 +1429,7 @@ static const NWidgetPart _nested_industry_cargoes_widgets[] = { }; /** Window description for the industry cargoes window. */ -static const WindowDesc _industry_cargoes_desc( +static WindowDesc _industry_cargoes_desc( WDP_AUTO, 300, 210, WC_INDUSTRY_CARGOES, WC_NONE, 0, @@ -2036,12 +2036,12 @@ 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() + IndustryCargoesWindow(int id) : Window(&_industry_cargoes_desc) { this->OnInit(); - this->CreateNestedTree(&_industry_cargoes_desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_IC_SCROLLBAR); - this->FinishInitNested(&_industry_cargoes_desc, 0); + this->FinishInitNested(0); this->OnInvalidateData(id); } diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp index 1c4235df0..3148b6360 100644 --- a/src/intro_gui.cpp +++ b/src/intro_gui.cpp @@ -35,10 +35,10 @@ struct SelectGameWindow : public Window { - SelectGameWindow(const WindowDesc *desc) : Window() + SelectGameWindow(WindowDesc *desc) : Window(desc) { - this->CreateNestedTree(desc); - this->FinishInitNested(desc, 0); + this->CreateNestedTree(); + this->FinishInitNested(0); this->OnInvalidateData(); } @@ -246,7 +246,7 @@ static const NWidgetPart _nested_select_game_widgets[] = { EndContainer(), }; -static const WindowDesc _select_game_desc( +static WindowDesc _select_game_desc( WDP_CENTER, 0, 0, WC_SELECT_GAME, WC_NONE, 0, diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp index 736b5733e..1fd852c5e 100644 --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -380,7 +380,7 @@ static const NWidgetPart _nested_linkgraph_legend_widgets[] = { assert_compile(WID_LGL_SATURATION_LAST - WID_LGL_SATURATION_FIRST == lengthof(LinkGraphOverlay::LINK_COLOURS) - 1); -static const WindowDesc _linkgraph_legend_desc( +static WindowDesc _linkgraph_legend_desc( WDP_MANUAL, 300, 314, WC_LINKGRAPH_LEGEND, WC_NONE, 0, @@ -395,9 +395,9 @@ void ShowLinkGraphLegend() AllocateWindowDescFront<LinkGraphLegendWindow>(&_linkgraph_legend_desc, 0); } -LinkGraphLegendWindow::LinkGraphLegendWindow(const WindowDesc *desc, int window_number) +LinkGraphLegendWindow::LinkGraphLegendWindow(WindowDesc *desc, int window_number) : Window(desc) { - this->InitNested(desc, window_number); + this->InitNested(window_number); this->InvalidateData(0); this->SetOverlay(FindWindowById(WC_MAIN_WINDOW, 0)->viewport->overlay); } diff --git a/src/linkgraph/linkgraph_gui.h b/src/linkgraph/linkgraph_gui.h index c65e9a409..fe87a0464 100644 --- a/src/linkgraph/linkgraph_gui.h +++ b/src/linkgraph/linkgraph_gui.h @@ -96,7 +96,7 @@ void ShowLinkGraphLegend(); */ struct LinkGraphLegendWindow : Window { public: - LinkGraphLegendWindow(const WindowDesc *desc, int window_number); + LinkGraphLegendWindow(WindowDesc *desc, int window_number); void SetOverlay(LinkGraphOverlay *overlay); virtual void DrawWidget(const Rect &r, int widget) const; diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 235238e4b..5a1f57449 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -206,7 +206,7 @@ static const struct NWidgetPart _nested_main_window_widgets[] = { NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_M_VIEWPORT), SetResize(1, 1), }; -static const WindowDesc _main_window_desc( +static WindowDesc _main_window_desc( WDP_MANUAL, 0, 0, WC_MAIN_WINDOW, WC_NONE, 0, @@ -245,9 +245,9 @@ struct MainWindow : Window static const uint LINKGRAPH_REFRESH_PERIOD = 0xff; static const uint LINKGRAPH_DELAY = 0xf; - MainWindow() : Window() + MainWindow() : Window(&_main_window_desc) { - this->InitNested(&_main_window_desc, 0); + this->InitNested(0); CLRBITS(this->flags, WF_WHITE_BORDER); ResizeWindow(this, _screen.width, _screen.height); diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 0fa450c51..d07254975 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -48,7 +48,7 @@ static const NWidgetPart _nested_land_info_widgets[] = { NWidget(WWT_PANEL, COLOUR_GREY, WID_LI_BACKGROUND), EndContainer(), }; -static const WindowDesc _land_info_desc( +static WindowDesc _land_info_desc( WDP_AUTO, 0, 0, WC_LAND_INFO, WC_NONE, 0, @@ -110,9 +110,9 @@ public: } } - LandInfoWindow(TileIndex tile) : Window(), tile(tile) + LandInfoWindow(TileIndex tile) : Window(&_land_info_desc), tile(tile) { - this->InitNested(&_land_info_desc); + this->InitNested(); #if defined(_DEBUG) # define LANDINFOD_LEVEL 0 @@ -365,7 +365,7 @@ static const NWidgetPart _nested_about_widgets[] = { EndContainer(), }; -static const WindowDesc _about_desc( +static WindowDesc _about_desc( WDP_CENTER, 0, 0, WC_GAME_OPTIONS, WC_NONE, 0, @@ -439,9 +439,9 @@ 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() + AboutWindow() : Window(&_about_desc) { - this->InitNested(&_about_desc, WN_GAME_OPTIONS_ABOUT); + this->InitNested(WN_GAME_OPTIONS_ABOUT); this->counter = 5; this->text_position = this->GetWidget<NWidgetBase>(WID_A_SCROLLING_TEXT)->pos_y + this->GetWidget<NWidgetBase>(WID_A_SCROLLING_TEXT)->current_y; @@ -615,7 +615,7 @@ static const NWidgetPart _nested_tooltips_widgets[] = { NWidget(WWT_PANEL, COLOUR_GREY, WID_TT_BACKGROUND), SetMinimalSize(200, 32), EndContainer(), }; -static const WindowDesc _tool_tips_desc( +static WindowDesc _tool_tips_desc( WDP_MANUAL, 0, 0, // Coordinates and sizes are not used, WC_TOOLTIPS, WC_NONE, 0, @@ -630,7 +630,7 @@ struct TooltipsWindow : public Window uint64 params[5]; ///< The string parameters. TooltipCloseCondition close_cond; ///< Condition for closing the window. - TooltipsWindow(Window *parent, StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip) : Window() + TooltipsWindow(Window *parent, StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip) : Window(&_tool_tips_desc) { this->parent = parent; this->string_id = str; @@ -640,12 +640,12 @@ struct TooltipsWindow : public Window this->paramcount = paramcount; this->close_cond = close_tooltip; - this->InitNested(&_tool_tips_desc); + this->InitNested(); CLRBITS(this->flags, WF_WHITE_BORDER); } - virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number) + virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) { /* Find the free screen space between the main toolbar at the top, and the statusbar at the bottom. * Add a fixed distance 2 so the tooltip floats free from both bars. @@ -818,8 +818,8 @@ 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, const WindowDesc *desc, Window *parent, CharSetFilter afilter, QueryStringFlags flags) : - editbox(max_bytes, max_chars) + 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) { char *last_of = &this->editbox.text.buf[this->editbox.text.max_bytes - 1]; GetString(this->editbox.text.buf, str, last_of); @@ -842,7 +842,7 @@ struct QueryStringWindow : public Window this->editbox.text.afilter = afilter; this->flags = flags; - this->InitNested(desc, WN_QUERY_STRING); + this->InitNested(WN_QUERY_STRING); this->parent = parent; @@ -918,7 +918,7 @@ static const NWidgetPart _nested_query_string_widgets[] = { EndContainer(), }; -static const WindowDesc _query_string_desc( +static WindowDesc _query_string_desc( WDP_CENTER, 0, 0, WC_QUERY_STRING, WC_NONE, 0, @@ -950,7 +950,7 @@ struct QueryWindow : public Window { StringID message; ///< message shown for query window StringID caption; ///< title of window - QueryWindow(const WindowDesc *desc, StringID caption, StringID message, Window *parent, QueryCallbackProc *callback) : Window() + 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 */ @@ -959,7 +959,7 @@ struct QueryWindow : public Window { this->message = message; this->proc = callback; - this->InitNested(desc, WN_CONFIRM_POPUP_QUERY); + this->InitNested(WN_CONFIRM_POPUP_QUERY); this->parent = parent; this->left = parent->left + (parent->width / 2) - (this->width / 2); @@ -1059,7 +1059,7 @@ static const NWidgetPart _nested_query_widgets[] = { EndContainer(), }; -static const WindowDesc _query_desc( +static WindowDesc _query_desc( WDP_CENTER, 0, 0, WC_CONFIRM_POPUP_QUERY, WC_NONE, WDF_MODAL, diff --git a/src/music_gui.cpp b/src/music_gui.cpp index 72ed9f907..3f57da964 100644 --- a/src/music_gui.cpp +++ b/src/music_gui.cpp @@ -290,9 +290,9 @@ static void SelectPlaylist(byte list) } struct MusicTrackSelectionWindow : public Window { - MusicTrackSelectionWindow(const WindowDesc *desc, WindowNumber number) : Window() + MusicTrackSelectionWindow(WindowDesc *desc, WindowNumber number) : Window(desc) { - this->InitNested(desc, number); + this->InitNested(number); this->LowerWidget(WID_MTS_LIST_LEFT); this->LowerWidget(WID_MTS_LIST_RIGHT); this->SetWidgetDisabledState(WID_MTS_CLEAR, _settings_client.music.playlist <= 3); @@ -495,7 +495,7 @@ static const NWidgetPart _nested_music_track_selection_widgets[] = { EndContainer(), }; -static const WindowDesc _music_track_selection_desc( +static WindowDesc _music_track_selection_desc( WDP_AUTO, 0, 0, WC_MUSIC_TRACK_SELECTION, WC_NONE, 0, @@ -510,9 +510,9 @@ static void ShowMusicTrackSelection() struct MusicWindow : public Window { static const int slider_width = 3; - MusicWindow(const WindowDesc *desc, WindowNumber number) : Window() + MusicWindow(WindowDesc *desc, WindowNumber number) : Window(desc) { - this->InitNested(desc, number); + this->InitNested(number); this->LowerWidget(_settings_client.music.playlist + WID_M_ALL); this->SetWidgetLoweredState(WID_M_SHUFFLE, _settings_client.music.shuffle); } @@ -758,7 +758,7 @@ static const NWidgetPart _nested_music_window_widgets[] = { EndContainer(), }; -static const WindowDesc _music_window_desc( +static WindowDesc _music_window_desc( WDP_AUTO, 0, 0, WC_MUSIC_WINDOW, WC_NONE, 0, diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp index 062858e11..5e7d11821 100644 --- a/src/network/network_chat_gui.cpp +++ b/src/network/network_chat_gui.cpp @@ -296,7 +296,7 @@ struct NetworkChatWindow : public Window { * @param type The type of destination. * @param dest The actual destination index. */ - NetworkChatWindow(const WindowDesc *desc, DestType type, int dest) : message_editbox(NETWORK_CHAT_LENGTH) + NetworkChatWindow(WindowDesc *desc, DestType type, int dest) : Window(desc), message_editbox(NETWORK_CHAT_LENGTH) { this->dtype = type; this->dest = dest; @@ -312,7 +312,7 @@ struct NetworkChatWindow : public Window { assert((uint)this->dtype < lengthof(chat_captions)); this->dest_string = chat_captions[this->dtype]; - this->InitNested(desc, type); + this->InitNested(type); this->SetFocusedWidget(WID_NC_TEXTBOX); InvalidateWindowData(WC_NEWS_WINDOW, 0, this->height); @@ -459,7 +459,7 @@ struct NetworkChatWindow : public Window { free(pre_buf); } - virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number) + virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) { Point pt = { 0, _screen.height - sm_height - FindWindowById(WC_STATUS_BAR, 0)->height }; return pt; @@ -540,7 +540,7 @@ static const NWidgetPart _nested_chat_window_widgets[] = { }; /** The description of the chat window. */ -static const WindowDesc _chat_window_desc( +static WindowDesc _chat_window_desc( WDP_MANUAL, 640, 14, // x, y, width, height WC_SEND_NETWORK_MSG, WC_NONE, 0, diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index a7c503a60..ba30199ae 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -91,20 +91,20 @@ static const NWidgetPart _nested_network_content_download_status_window_widgets[ }; /** Window description for the download window */ -static const WindowDesc _network_content_download_status_window_desc( +static WindowDesc _network_content_download_status_window_desc( WDP_CENTER, 0, 0, WC_NETWORK_STATUS_WINDOW, WC_NONE, WDF_MODAL, _nested_network_content_download_status_window_widgets, lengthof(_nested_network_content_download_status_window_widgets) ); -BaseNetworkContentDownloadStatusWindow::BaseNetworkContentDownloadStatusWindow(const WindowDesc *desc) : - cur_id(UINT32_MAX) +BaseNetworkContentDownloadStatusWindow::BaseNetworkContentDownloadStatusWindow(WindowDesc *desc) : + Window(desc), cur_id(UINT32_MAX) { _network_content_client.AddCallback(this); _network_content_client.DownloadSelectedContent(this->total_files, this->total_bytes); - this->InitNested(desc, WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD); + this->InitNested(WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD); } BaseNetworkContentDownloadStatusWindow::~BaseNetworkContentDownloadStatusWindow() @@ -472,15 +472,16 @@ public: * @param desc the window description to pass to Window's constructor. * @param select_all Whether the select all button is allowed or not. */ - NetworkContentListWindow(const WindowDesc *desc, bool select_all) : + NetworkContentListWindow(WindowDesc *desc, bool select_all) : + Window(desc), auto_select(select_all), filter_editbox(EDITBOX_MAX_SIZE), selected(NULL), list_pos(0) { - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_NCL_SCROLLBAR); - this->FinishInitNested(desc, WN_NETWORK_WINDOW_CONTENT_LIST); + this->FinishInitNested(WN_NETWORK_WINDOW_CONTENT_LIST); this->GetWidget<NWidgetStacked>(WID_NCL_SEL_ALL_UPDATE)->SetDisplayedPlane(select_all); @@ -1031,7 +1032,7 @@ static const NWidgetPart _nested_network_content_list_widgets[] = { }; /** Window description of the content list */ -static const WindowDesc _network_content_list_desc( +static WindowDesc _network_content_list_desc( WDP_CENTER, 630, 460, WC_NETWORK_WINDOW, WC_NONE, 0, diff --git a/src/network/network_content_gui.h b/src/network/network_content_gui.h index 6650eb14a..212fcec04 100644 --- a/src/network/network_content_gui.h +++ b/src/network/network_content_gui.h @@ -32,7 +32,7 @@ public: * Create the window with the given description. * @param desc The description of the window. */ - BaseNetworkContentDownloadStatusWindow(const WindowDesc *desc); + BaseNetworkContentDownloadStatusWindow(WindowDesc *desc); /** * Free everything associated with this window. diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index dae8764be..80cdcda83 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -449,14 +449,14 @@ protected: } public: - NetworkGameWindow(const WindowDesc *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 = NULL; - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_NG_SCROLLBAR); - this->FinishInitNested(desc, WN_NETWORK_WINDOW_GAME); + this->FinishInitNested(WN_NETWORK_WINDOW_GAME); this->querystrings[WID_NG_CLIENT] = &this->name_editbox; this->name_editbox.text.Assign(_settings_client.network.client_name); @@ -1011,7 +1011,7 @@ static const NWidgetPart _nested_network_game_widgets[] = { EndContainer(), }; -static const WindowDesc _network_game_window_desc( +static WindowDesc _network_game_window_desc( WDP_CENTER, 1000, 730, WC_NETWORK_WINDOW, WC_NONE, 0, @@ -1040,9 +1040,9 @@ struct NetworkStartServerWindow : public Window { byte widget_id; ///< The widget that has the pop-up input menu QueryString name_editbox; ///< Server name editbox. - NetworkStartServerWindow(const WindowDesc *desc) : name_editbox(NETWORK_NAME_LENGTH) + NetworkStartServerWindow(WindowDesc *desc) : Window(desc), name_editbox(NETWORK_NAME_LENGTH) { - this->InitNested(desc, WN_NETWORK_WINDOW_START); + this->InitNested(WN_NETWORK_WINDOW_START); this->querystrings[WID_NSS_GAMENAME] = &this->name_editbox; this->name_editbox.text.Assign(_settings_client.network.server_name); @@ -1326,7 +1326,7 @@ static const NWidgetPart _nested_network_start_server_window_widgets[] = { EndContainer(), }; -static const WindowDesc _network_start_server_window_desc( +static WindowDesc _network_start_server_window_desc( WDP_CENTER, 0, 0, WC_NETWORK_WINDOW, WC_NONE, 0, @@ -1347,12 +1347,12 @@ struct NetworkLobbyWindow : public Window { NetworkCompanyInfo company_info[MAX_COMPANIES]; Scrollbar *vscroll; - NetworkLobbyWindow(const WindowDesc *desc, NetworkGameList *ngl) : - Window(), company(INVALID_COMPANY), server(ngl) + NetworkLobbyWindow(WindowDesc *desc, NetworkGameList *ngl) : + Window(desc), company(INVALID_COMPANY), server(ngl) { - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_NL_SCROLLBAR); - this->FinishInitNested(desc, WN_NETWORK_WINDOW_LOBBY); + this->FinishInitNested(WN_NETWORK_WINDOW_LOBBY); this->OnResize(); } @@ -1615,7 +1615,7 @@ static const NWidgetPart _nested_network_lobby_window_widgets[] = { EndContainer(), }; -static const WindowDesc _network_lobby_window_desc( +static WindowDesc _network_lobby_window_desc( WDP_CENTER, 0, 0, WC_NETWORK_WINDOW, WC_NONE, 0, @@ -1664,7 +1664,7 @@ static const NWidgetPart _nested_client_list_popup_widgets[] = { NWidget(WWT_PANEL, COLOUR_GREY, WID_CLP_PANEL), EndContainer(), }; -static const WindowDesc _client_list_popup_desc( +static WindowDesc _client_list_popup_desc( WDP_AUTO, 0, 0, WC_CLIENT_LIST_POPUP, WC_CLIENT_LIST, 0, @@ -1727,8 +1727,8 @@ struct NetworkClientListPopupWindow : Window { action->proc = proc; } - NetworkClientListPopupWindow(const WindowDesc *desc, int x, int y, ClientID client_id) : - Window(), + NetworkClientListPopupWindow(WindowDesc *desc, int x, int y, ClientID client_id) : + Window(desc), sel_index(0), client_id(client_id) { this->desired_location.x = x; @@ -1758,11 +1758,11 @@ struct NetworkClientListPopupWindow : Window { this->AddAction(STR_NETWORK_CLIENTLIST_BAN, &ClientList_Ban); } - this->InitNested(desc, client_id); + this->InitNested(client_id); CLRBITS(this->flags, WF_WHITE_BORDER); } - virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number) + virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) { return this->desired_location; } @@ -1840,7 +1840,7 @@ static const NWidgetPart _nested_client_list_widgets[] = { NWidget(WWT_PANEL, COLOUR_GREY, WID_CL_PANEL), SetMinimalSize(250, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM), SetResize(1, 1), EndContainer(), }; -static const WindowDesc _client_list_desc( +static WindowDesc _client_list_desc( WDP_AUTO, 0, 0, WC_CLIENT_LIST, WC_NONE, 0, @@ -1856,11 +1856,11 @@ struct NetworkClientListWindow : Window { uint server_client_width; uint company_icon_width; - NetworkClientListWindow(const WindowDesc *desc, WindowNumber window_number) : - Window(), + NetworkClientListWindow(WindowDesc *desc, WindowNumber window_number) : + Window(desc), selected_item(-1) { - this->InitNested(desc, window_number); + this->InitNested(window_number); } /** @@ -2009,10 +2009,10 @@ uint32 _network_join_bytes_total; ///< The total number of bytes to downlo struct NetworkJoinStatusWindow : Window { NetworkPasswordType password_type; - NetworkJoinStatusWindow(const WindowDesc *desc) : Window() + NetworkJoinStatusWindow(WindowDesc *desc) : Window(desc) { this->parent = FindWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_GAME); - this->InitNested(desc, WN_NETWORK_STATUS_WINDOW_JOIN); + this->InitNested(WN_NETWORK_STATUS_WINDOW_JOIN); } virtual void DrawWidget(const Rect &r, int widget) const @@ -2112,7 +2112,7 @@ static const NWidgetPart _nested_network_join_status_window_widgets[] = { EndContainer(), }; -static const WindowDesc _network_join_status_window_desc( +static WindowDesc _network_join_status_window_desc( WDP_CENTER, 0, 0, WC_NETWORK_STATUS_WINDOW, WC_NONE, WDF_MODAL, @@ -2143,9 +2143,9 @@ void ShowNetworkNeedPassword(NetworkPasswordType npt) struct NetworkCompanyPasswordWindow : public Window { QueryString password_editbox; ///< Password editbox. - NetworkCompanyPasswordWindow(const WindowDesc *desc, Window *parent) : password_editbox(lengthof(_settings_client.network.default_company_pass)) + NetworkCompanyPasswordWindow(WindowDesc *desc, Window *parent) : Window(desc), password_editbox(lengthof(_settings_client.network.default_company_pass)) { - this->InitNested(desc, 0); + this->InitNested(0); this->parent = parent; this->querystrings[WID_NCP_PASSWORD] = &this->password_editbox; @@ -2206,7 +2206,7 @@ static const NWidgetPart _nested_network_company_password_window_widgets[] = { EndContainer(), }; -static const WindowDesc _network_company_password_window_desc( +static WindowDesc _network_company_password_window_desc( WDP_AUTO, 0, 0, WC_COMPANY_PASSWORD_WINDOW, WC_NONE, 0, diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index b96001186..f4a6585a9 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -303,11 +303,11 @@ struct NewGRFInspectWindow : Window { this->SetDirty(); } - NewGRFInspectWindow(const WindowDesc *desc, WindowNumber wno) : Window() + NewGRFInspectWindow(WindowDesc *desc, WindowNumber wno) : Window(desc) { - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_NGRFI_SCROLLBAR); - this->FinishInitNested(desc, wno); + this->FinishInitNested(wno); this->vscroll->SetCount(0); this->SetWidgetDisabledState(WID_NGRFI_PARENT, GetFeatureHelper(this->window_number)->GetParent(GetFeatureIndex(this->window_number)) == UINT32_MAX); @@ -518,7 +518,7 @@ static const NWidgetPart _nested_newgrf_inspect_widgets[] = { EndContainer(), }; -static const WindowDesc _newgrf_inspect_desc( +static WindowDesc _newgrf_inspect_desc( WDP_AUTO, 400, 300, WC_NEWGRF_INSPECT, WC_NONE, 0, @@ -630,11 +630,11 @@ struct SpriteAlignerWindow : Window { SpriteID current_sprite; ///< The currently shown sprite Scrollbar *vscroll; - SpriteAlignerWindow(const WindowDesc *desc, WindowNumber wno) : Window() + SpriteAlignerWindow(WindowDesc *desc, WindowNumber wno) : Window(desc) { - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_SA_SCROLLBAR); - this->FinishInitNested(desc, wno); + this->FinishInitNested(wno); /* Oh yes, we assume there is at least one normal sprite! */ while (GetSpriteType(this->current_sprite) != ST_NORMAL) this->current_sprite++; @@ -872,7 +872,7 @@ static const NWidgetPart _nested_sprite_aligner_widgets[] = { EndContainer(), }; -static const WindowDesc _sprite_aligner_desc( +static WindowDesc _sprite_aligner_desc( WDP_AUTO, 400, 300, WC_SPRITE_ALIGNER, WC_NONE, 0, diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index 8f73ee4f3..02aca44a3 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -159,7 +159,7 @@ struct NewGRFParametersWindow : public Window { bool action14present; ///< True if action14 information is present. bool editable; ///< Allow editing parameters. - NewGRFParametersWindow(const WindowDesc *desc, GRFConfig *c, bool editable) : Window(), + NewGRFParametersWindow(WindowDesc *desc, GRFConfig *c, bool editable) : Window(desc), grf_config(c), clicked_button(UINT_MAX), clicked_dropdown(false), @@ -170,11 +170,11 @@ struct NewGRFParametersWindow : public Window { { this->action14present = (c->num_valid_params != lengthof(c->param) || c->param_info.Length() != 0); - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_NP_SCROLLBAR); this->GetWidget<NWidgetStacked>(WID_NP_SHOW_NUMPAR)->SetDisplayedPlane(this->action14present ? SZSP_HORIZONTAL : 0); this->GetWidget<NWidgetStacked>(WID_NP_SHOW_DESCRIPTION)->SetDisplayedPlane(this->action14present ? 0 : SZSP_HORIZONTAL); - this->FinishInitNested(desc); // Initializes 'this->line_height' as side effect. + this->FinishInitNested(); // Initializes 'this->line_height' as side effect. this->SetWidgetDisabledState(WID_NP_RESET, !this->editable); @@ -528,7 +528,7 @@ static const NWidgetPart _nested_newgrf_parameter_widgets[] = { }; /** Window definition for the change grf parameters window */ -static const WindowDesc _newgrf_parameters_desc( +static WindowDesc _newgrf_parameters_desc( WDP_CENTER, 500, 208, WC_GRF_PARAMETERS, WC_NONE, 0, @@ -619,7 +619,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { Scrollbar *vscroll; Scrollbar *vscroll2; - NewGRFWindow(const WindowDesc *desc, bool editable, bool show_params, bool execute, GRFConfig **orig_list) : 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 = NULL; this->avail_pos = -1; @@ -635,13 +635,13 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { CopyGRFConfigList(&this->actives, *orig_list, false); GetGRFPresetList(&_grf_preset_list); - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_NS_SCROLLBAR); this->vscroll2 = this->GetScrollbar(WID_NS_SCROLL2BAR); this->GetWidget<NWidgetStacked>(WID_NS_SHOW_REMOVE)->SetDisplayedPlane(this->editable ? 0 : 1); this->GetWidget<NWidgetStacked>(WID_NS_SHOW_APPLY)->SetDisplayedPlane(this->editable ? 0 : this->show_params ? 1 : SZSP_HORIZONTAL); - this->FinishInitNested(desc, WN_GAME_OPTIONS_NEWGRF_STATE); + this->FinishInitNested(WN_GAME_OPTIONS_NEWGRF_STATE); this->querystrings[WID_NS_FILTER] = &this->filter_editbox; this->filter_editbox.cancel_button = QueryString::ACTION_CLEAR; @@ -1877,7 +1877,7 @@ static const NWidgetPart _nested_newgrf_widgets[] = { }; /* Window definition of the manage newgrfs window */ -static const WindowDesc _newgrf_desc( +static WindowDesc _newgrf_desc( WDP_CENTER, 300, 263, WC_GAME_OPTIONS, WC_NONE, 0, @@ -1948,7 +1948,7 @@ static const NWidgetPart _nested_scan_progress_widgets[] = { }; /** Description of the widgets and other settings of the window. */ -static const WindowDesc _scan_progress_desc( +static WindowDesc _scan_progress_desc( WDP_CENTER, 0, 0, WC_MODAL_PROGRESS, WC_NONE, 0, @@ -1961,9 +1961,9 @@ struct ScanProgressWindow : public Window { int scanned; ///< The number of NewGRFs that we have seen. /** Create the window. */ - ScanProgressWindow() : Window(), last_name(NULL), scanned(0) + ScanProgressWindow() : Window(&_scan_progress_desc), last_name(NULL), scanned(0) { - this->InitNested(&_scan_progress_desc, 1); + this->InitNested(1); } /** Free the last name buffer. */ diff --git a/src/news_gui.cpp b/src/news_gui.cpp index a0c9bdbd2..67ef03678 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -89,7 +89,7 @@ static const NWidgetPart _nested_normal_news_widgets[] = { EndContainer(), }; -static const WindowDesc _normal_news_desc( +static WindowDesc _normal_news_desc( WDP_MANUAL, 0, 0, WC_NEWS_WINDOW, WC_NONE, 0, @@ -116,7 +116,7 @@ static const NWidgetPart _nested_vehicle_news_widgets[] = { EndContainer(), }; -static const WindowDesc _vehicle_news_desc( +static WindowDesc _vehicle_news_desc( WDP_MANUAL, 0, 0, WC_NEWS_WINDOW, WC_NONE, 0, @@ -147,7 +147,7 @@ static const NWidgetPart _nested_company_news_widgets[] = { EndContainer(), }; -static const WindowDesc _company_news_desc( +static WindowDesc _company_news_desc( WDP_MANUAL, 0, 0, WC_NEWS_WINDOW, WC_NONE, 0, @@ -170,7 +170,7 @@ static const NWidgetPart _nested_thin_news_widgets[] = { EndContainer(), }; -static const WindowDesc _thin_news_desc( +static WindowDesc _thin_news_desc( WDP_MANUAL, 0, 0, WC_NEWS_WINDOW, WC_NONE, 0, @@ -194,7 +194,7 @@ static const NWidgetPart _nested_small_news_widgets[] = { EndContainer(), }; -static const WindowDesc _small_news_desc( +static WindowDesc _small_news_desc( WDP_MANUAL, 0, 0, WC_NEWS_WINDOW, WC_NONE, 0, @@ -204,7 +204,7 @@ static const WindowDesc _small_news_desc( /** * Window layouts for news items. */ -static const WindowDesc* _news_window_layout[] = { +static WindowDesc* _news_window_layout[] = { &_thin_news_desc, ///< NF_THIN &_small_news_desc, ///< NF_SMALL &_normal_news_desc, ///< NF_NORMAL @@ -212,7 +212,7 @@ static const WindowDesc* _news_window_layout[] = { &_company_news_desc, ///< NF_COMPANY }; -const 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)); @@ -263,7 +263,7 @@ struct NewsWindow : Window { const NewsItem *ni; ///< News item to display. static uint duration; ///< Remaining time for showing current news message (may only be accessed while a news item is displayed). - NewsWindow(const WindowDesc *desc, const NewsItem *ni) : Window(), ni(ni) + NewsWindow(WindowDesc *desc, const NewsItem *ni) : Window(desc), ni(ni) { NewsWindow::duration = 555; const Window *w = FindWindowByClass(WC_SEND_NETWORK_MSG); @@ -272,12 +272,12 @@ struct NewsWindow : Window { this->flags |= WF_DISABLE_VP_SCROLL; - this->CreateNestedTree(desc); + this->CreateNestedTree(); /* For company news with a face we have a separate headline in param[0] */ if (desc == &_company_news_desc) this->GetWidget<NWidgetCore>(WID_N_TITLE)->widget_data = this->ni->params[0]; - this->FinishInitNested(desc, 0); + this->FinishInitNested(0); /* Initialize viewport if it exists. */ NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_N_VIEWPORT); @@ -304,7 +304,7 @@ struct NewsWindow : Window { GfxFillRect(r.left, r.bottom, r.right, r.bottom, PC_BLACK); } - virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number) + virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) { Point pt = { 0, _screen.height }; return pt; @@ -996,11 +996,11 @@ struct MessageHistoryWindow : Window { Scrollbar *vscroll; - MessageHistoryWindow(const WindowDesc *desc) : Window() + MessageHistoryWindow(WindowDesc *desc) : Window(desc) { - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_MH_SCROLLBAR); - this->FinishInitNested(desc); // Initializes 'this->line_height' and 'this->date_width'. + this->FinishInitNested(); // Initializes 'this->line_height' and 'this->date_width'. this->OnInvalidateData(0); } @@ -1109,7 +1109,7 @@ static const NWidgetPart _nested_message_history[] = { EndContainer(), }; -static const WindowDesc _message_history_desc( +static WindowDesc _message_history_desc( WDP_AUTO, 400, 140, WC_MESSAGE_HISTORY, WC_NONE, 0, diff --git a/src/object_gui.cpp b/src/object_gui.cpp index 413cb23b8..6e967a6fe 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -72,16 +72,16 @@ class BuildObjectWindow : public PickerWindowBase { } public: - BuildObjectWindow(const WindowDesc *desc, Window *w) : PickerWindowBase(w), info_height(1) + BuildObjectWindow(WindowDesc *desc, Window *w) : PickerWindowBase(desc, w), info_height(1) { - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_BO_SCROLLBAR); this->vscroll->SetCapacity(5); this->vscroll->SetPosition(0); this->vscroll->SetCount(ObjectClass::GetUIClassCount()); - this->FinishInitNested(desc, 0); + this->FinishInitNested(0); if (this->CanRestoreSelectedObject()) { this->SelectOtherObject(_selected_object_index); @@ -488,7 +488,7 @@ static const NWidgetPart _nested_build_object_widgets[] = { EndContainer(), }; -static const WindowDesc _build_object_desc( +static WindowDesc _build_object_desc( WDP_AUTO, 0, 0, WC_BUILD_OBJECT, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 2e9a7fb16..04fb155d0 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -793,13 +793,13 @@ private: } public: - OrdersWindow(const WindowDesc *desc, const Vehicle *v) : Window() + OrdersWindow(WindowDesc *desc, const Vehicle *v) : Window(desc) { this->vehicle = v; - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_O_SCROLLBAR); - this->FinishInitNested(desc, v->index); + this->FinishInitNested(v->index); if (v->owner == _local_company) { this->DisableWidget(WID_O_EMPTY); } @@ -1593,7 +1593,7 @@ static const NWidgetPart _nested_orders_train_widgets[] = { EndContainer(), }; -static const WindowDesc _orders_train_desc( +static WindowDesc _orders_train_desc( WDP_AUTO, 384, 100, WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW, WDF_CONSTRUCTION, @@ -1664,7 +1664,7 @@ static const NWidgetPart _nested_orders_widgets[] = { EndContainer(), }; -static const WindowDesc _orders_desc( +static WindowDesc _orders_desc( WDP_AUTO, 384, 100, WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW, WDF_CONSTRUCTION, @@ -1689,7 +1689,7 @@ static const NWidgetPart _nested_other_orders_widgets[] = { EndContainer(), }; -static const WindowDesc _other_orders_desc( +static WindowDesc _other_orders_desc( WDP_AUTO, 384, 86, WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW, WDF_CONSTRUCTION, diff --git a/src/osk_gui.cpp b/src/osk_gui.cpp index 015222d4d..c234192fe 100644 --- a/src/osk_gui.cpp +++ b/src/osk_gui.cpp @@ -40,7 +40,7 @@ struct OskWindow : public Window { char *orig_str_buf; ///< Original string. bool shift; ///< Is the shift effectively pressed? - OskWindow(const WindowDesc *desc, Window *parent, int button) : Window() + OskWindow(WindowDesc *desc, Window *parent, int button) : Window(desc) { this->parent = parent; assert(parent != NULL); @@ -58,7 +58,7 @@ struct OskWindow : public Window { /* make a copy in case we need to reset later */ this->orig_str_buf = strdup(this->qs->text.buf); - this->InitNested(desc, 0); + this->InitNested(0); this->SetFocusedWidget(WID_OSK_TEXT); /* Not needed by default. */ @@ -339,7 +339,7 @@ static const NWidgetPart _nested_osk_widgets[] = { EndContainer(), }; -static const WindowDesc _osk_desc( +static WindowDesc _osk_desc( WDP_CENTER, 0, 0, WC_OSK, WC_NONE, 0, diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index cee1903a0..5dd692c4e 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -415,9 +415,9 @@ struct BuildRailToolbarWindow : Window { RailType railtype; ///< Rail type to build. int last_user_action; ///< Last started user action. - BuildRailToolbarWindow(const WindowDesc *desc, RailType railtype) : Window() + BuildRailToolbarWindow(WindowDesc *desc, RailType railtype) : Window(desc) { - this->InitNested(desc, TRANSPORT_RAIL); + this->InitNested(TRANSPORT_RAIL); this->SetupRailToolbar(railtype); this->DisableWidget(WID_RAT_REMOVE); this->last_user_action = WIDGET_LIST_END; @@ -819,7 +819,7 @@ static const NWidgetPart _nested_build_rail_widgets[] = { EndContainer(), }; -static const WindowDesc _build_rail_desc( +static WindowDesc _build_rail_desc( WDP_ALIGN_TOOLBAR, 0, 0, WC_BUILD_TOOLBAR, WC_NONE, WDF_CONSTRUCTION, @@ -912,20 +912,20 @@ private: } public: - BuildRailStationWindow(const WindowDesc *desc, Window *parent, bool newstation) : PickerWindowBase(parent) + BuildRailStationWindow(WindowDesc *desc, Window *parent, bool newstation) : PickerWindowBase(desc, parent) { this->coverage_height = 2 * FONT_HEIGHT_NORMAL + 3 * WD_PAR_VSEP_NORMAL; this->vscroll = NULL; _railstation.newstations = newstation; - this->CreateNestedTree(desc); + this->CreateNestedTree(); NWidgetStacked *newst_additions = this->GetWidget<NWidgetStacked>(WID_BRAS_SHOW_NEWST_ADDITIONS); newst_additions->SetDisplayedPlane(newstation ? 0 : SZSP_NONE); newst_additions = this->GetWidget<NWidgetStacked>(WID_BRAS_SHOW_NEWST_MATRIX); newst_additions->SetDisplayedPlane(newstation ? 0 : SZSP_NONE); newst_additions = this->GetWidget<NWidgetStacked>(WID_BRAS_SHOW_NEWST_RESIZE); newst_additions->SetDisplayedPlane(newstation ? 0 : SZSP_NONE); - this->FinishInitNested(desc, TRANSPORT_RAIL); + this->FinishInitNested(TRANSPORT_RAIL); this->LowerWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X); if (_settings_client.gui.station_dragdrop) { @@ -1427,7 +1427,7 @@ static const NWidgetPart _nested_station_builder_widgets[] = { }; /** High level window description of the station-build window (default & newGRF) */ -static const WindowDesc _station_builder_desc( +static WindowDesc _station_builder_desc( WDP_AUTO, 350, 0, WC_BUILD_STATION, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, @@ -1475,9 +1475,9 @@ private: } public: - BuildSignalWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(parent) + BuildSignalWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) { - this->InitNested(desc, TRANSPORT_RAIL); + this->InitNested(TRANSPORT_RAIL); this->OnInvalidateData(); } @@ -1614,7 +1614,7 @@ static const NWidgetPart _nested_signal_builder_widgets[] = { }; /** Signal selection window description */ -static const WindowDesc _signal_builder_desc( +static WindowDesc _signal_builder_desc( WDP_AUTO, 0, 0, WC_BUILD_SIGNAL, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, @@ -1630,9 +1630,9 @@ static void ShowSignalBuilder(Window *parent) } struct BuildRailDepotWindow : public PickerWindowBase { - BuildRailDepotWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(parent) + BuildRailDepotWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) { - this->InitNested(desc, TRANSPORT_RAIL); + this->InitNested(TRANSPORT_RAIL); this->LowerWidget(_build_depot_direction + WID_BRAD_DEPOT_NE); } @@ -1691,7 +1691,7 @@ static const NWidgetPart _nested_build_depot_widgets[] = { EndContainer(), }; -static const WindowDesc _build_depot_desc( +static WindowDesc _build_depot_desc( WDP_AUTO, 0, 0, WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, @@ -1704,14 +1704,14 @@ static void ShowBuildTrainDepotPicker(Window *parent) } struct BuildRailWaypointWindow : PickerWindowBase { - BuildRailWaypointWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(parent) + BuildRailWaypointWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) { - this->CreateNestedTree(desc); + this->CreateNestedTree(); NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BRW_WAYPOINT_MATRIX); matrix->SetScrollbar(this->GetScrollbar(WID_BRW_SCROLL)); - this->FinishInitNested(desc, TRANSPORT_RAIL); + this->FinishInitNested(TRANSPORT_RAIL); matrix->SetCount(_waypoint_count); matrix->SetClicked(_cur_waypoint_type); @@ -1784,7 +1784,7 @@ static const NWidgetPart _nested_build_waypoint_widgets[] = { EndContainer(), }; -static const WindowDesc _build_waypoint_desc( +static WindowDesc _build_waypoint_desc( WDP_AUTO, 0, 0, WC_BUILD_WAYPOINT, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, diff --git a/src/road_gui.cpp b/src/road_gui.cpp index bf4ef40d1..0927c2c4a 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -308,9 +308,9 @@ static bool RoadToolbar_CtrlChanged(Window *w) struct BuildRoadToolbarWindow : Window { int last_started_action; ///< Last started user action. - BuildRoadToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window() + BuildRoadToolbarWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { - this->InitNested(desc, window_number); + this->InitNested(window_number); this->SetWidgetsDisabledState(true, WID_ROT_REMOVE, WID_ROT_ONE_WAY, @@ -713,7 +713,7 @@ static const NWidgetPart _nested_build_road_widgets[] = { EndContainer(), }; -static const WindowDesc _build_road_desc( +static WindowDesc _build_road_desc( WDP_ALIGN_TOOLBAR, 0, 0, WC_BUILD_TOOLBAR, WC_NONE, WDF_CONSTRUCTION, @@ -752,7 +752,7 @@ static const NWidgetPart _nested_build_tramway_widgets[] = { EndContainer(), }; -static const WindowDesc _build_tramway_desc( +static WindowDesc _build_tramway_desc( WDP_ALIGN_TOOLBAR, 0, 0, WC_BUILD_TOOLBAR, WC_NONE, WDF_CONSTRUCTION, @@ -812,7 +812,7 @@ static const NWidgetPart _nested_build_road_scen_widgets[] = { EndContainer(), }; -static const WindowDesc _build_road_scen_desc( +static WindowDesc _build_road_scen_desc( WDP_AUTO, 0, 0, WC_SCEN_BUILD_TOOLBAR, WC_NONE, WDF_CONSTRUCTION, @@ -839,9 +839,9 @@ EventState RoadToolbarEditorGlobalHotkeys(uint16 key, uint16 keycode) } struct BuildRoadDepotWindow : public PickerWindowBase { - BuildRoadDepotWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(parent) + BuildRoadDepotWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) { - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->LowerWidget(_road_depot_orientation + WID_BROD_DEPOT_NE); if ( _cur_roadtype == ROADTYPE_TRAM) { @@ -849,7 +849,7 @@ struct BuildRoadDepotWindow : public PickerWindowBase { for (int i = WID_BROD_DEPOT_NE; i <= WID_BROD_DEPOT_NW; i++) this->GetWidget<NWidgetCore>(i)->tool_tip = STR_BUILD_DEPOT_TRAM_ORIENTATION_SELECT_TOOLTIP; } - this->FinishInitNested(desc, TRANSPORT_ROAD); + this->FinishInitNested(TRANSPORT_ROAD); } virtual void DrawWidget(const Rect &r, int widget) const @@ -909,7 +909,7 @@ static const NWidgetPart _nested_build_road_depot_widgets[] = { EndContainer(), }; -static const WindowDesc _build_road_depot_desc( +static WindowDesc _build_road_depot_desc( WDP_AUTO, 0, 0, WC_BUILD_DEPOT, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, @@ -922,9 +922,9 @@ static void ShowRoadDepotPicker(Window *parent) } struct BuildRoadStationWindow : public PickerWindowBase { - BuildRoadStationWindow(const WindowDesc *desc, Window *parent, RoadStopType rs) : PickerWindowBase(parent) + BuildRoadStationWindow(WindowDesc *desc, Window *parent, RoadStopType rs) : PickerWindowBase(desc, parent) { - this->CreateNestedTree(desc); + this->CreateNestedTree(); /* Trams don't have non-drivethrough stations */ if (_cur_roadtype == ROADTYPE_TRAM && _road_station_picker_orientation < DIAGDIR_END) { @@ -943,7 +943,7 @@ struct BuildRoadStationWindow : public PickerWindowBase { this->LowerWidget(_road_station_picker_orientation + WID_BROS_STATION_NE); this->LowerWidget(_settings_client.gui.station_show_coverage + WID_BROS_LT_OFF); - this->FinishInitNested(desc, TRANSPORT_ROAD); + this->FinishInitNested(TRANSPORT_ROAD); this->window_class = (rs == ROADSTOP_BUS) ? WC_BUS_STATION : WC_TRUCK_STATION; } @@ -1063,7 +1063,7 @@ static const NWidgetPart _nested_rv_station_picker_widgets[] = { EndContainer(), }; -static const WindowDesc _rv_station_picker_desc( +static WindowDesc _rv_station_picker_desc( WDP_AUTO, 0, 0, WC_BUS_STATION, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 3a20f455f..96e2d0fe7 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -160,12 +160,12 @@ struct GameOptionsWindow : Window { GameSettings *opt; bool reload; - GameOptionsWindow(const WindowDesc *desc) : Window() + GameOptionsWindow(WindowDesc *desc) : Window(desc) { this->opt = &GetGameSettings(); this->reload = false; - this->InitNested(desc, WN_GAME_OPTIONS_GAME_OPTIONS); + this->InitNested(WN_GAME_OPTIONS_GAME_OPTIONS); this->OnInvalidateData(0); } @@ -662,7 +662,7 @@ static const NWidgetPart _nested_game_options_widgets[] = { EndContainer(), }; -static const WindowDesc _game_options_desc( +static WindowDesc _game_options_desc( WDP_CENTER, 0, 0, WC_GAME_OPTIONS, WC_NONE, 0, @@ -1733,7 +1733,7 @@ struct GameSettingsWindow : Window { Scrollbar *vscroll; - GameSettingsWindow(const WindowDesc *desc) : filter_editbox(50) + GameSettingsWindow(WindowDesc *desc) : Window(desc), filter_editbox(50) { static bool first_time = true; @@ -1756,9 +1756,9 @@ struct GameSettingsWindow : Window { this->closing_dropdown = false; this->manually_changed_folding = false; - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_GS_SCROLLBAR); - this->FinishInitNested(desc, WN_GAME_OPTIONS_GAME_SETTINGS); + this->FinishInitNested(WN_GAME_OPTIONS_GAME_SETTINGS); this->querystrings[WID_GS_FILTER] = &this->filter_editbox; this->filter_editbox.cancel_button = QueryString::ACTION_CLEAR; @@ -2261,7 +2261,7 @@ static const NWidgetPart _nested_settings_selection_widgets[] = { EndContainer(), }; -static const WindowDesc _settings_selection_desc( +static WindowDesc _settings_selection_desc( WDP_CENTER, 510, 450, WC_GAME_OPTIONS, WC_NONE, 0, @@ -2342,9 +2342,9 @@ void DrawBoolButton(int x, int y, bool state, bool clickable) struct CustomCurrencyWindow : Window { int query_widget; - CustomCurrencyWindow(const WindowDesc *desc) : Window() + CustomCurrencyWindow(WindowDesc *desc) : Window(desc) { - this->InitNested(desc); + this->InitNested(); SetButtonState(); } @@ -2554,7 +2554,7 @@ static const NWidgetPart _nested_cust_currency_widgets[] = { EndContainer(), }; -static const WindowDesc _cust_currency_desc( +static WindowDesc _cust_currency_desc( WDP_CENTER, 0, 0, WC_CUSTOM_CURRENCY, WC_NONE, 0, diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index cd4d7e1b8..2290f621a 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -149,11 +149,11 @@ 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(const WindowDesc *desc, WindowNumber window_number) : 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(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_SIL_SCROLLBAR); - this->FinishInitNested(desc, window_number); + this->FinishInitNested(window_number); this->SetWidgetLoweredState(WID_SIL_FILTER_MATCH_CASE_BTN, SignList::match_case); /* Initialize the text edit widget */ @@ -369,7 +369,7 @@ static const NWidgetPart _nested_sign_list_widgets[] = { EndContainer(), }; -static const WindowDesc _sign_list_desc( +static WindowDesc _sign_list_desc( WDP_AUTO, 358, 138, WC_SIGN_LIST, WC_NONE, 0, @@ -412,14 +412,14 @@ struct SignWindow : Window, SignList { QueryString name_editbox; SignID cur_sign; - SignWindow(const WindowDesc *desc, const Sign *si) : 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; this->name_editbox.cancel_button = WID_QES_CANCEL; this->name_editbox.ok_button = WID_QES_OK; - this->InitNested(desc, WN_QUERY_STRING_SIGN); + this->InitNested(WN_QUERY_STRING_SIGN); UpdateSignEditWindow(si); this->SetFocusedWidget(WID_QES_TEXT); @@ -531,7 +531,7 @@ static const NWidgetPart _nested_query_sign_edit_widgets[] = { EndContainer(), }; -static const WindowDesc _query_sign_edit_desc( +static WindowDesc _query_sign_edit_desc( WDP_AUTO, 0, 0, WC_QUERY_STRING, WC_NONE, WDF_CONSTRUCTION, diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 8001d2ed8..bc984ce63 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1045,11 +1045,11 @@ void SmallMapWindow::SetupWidgetData() this->GetWidget<NWidgetStacked>(WID_SM_SELECT_BUTTONS)->SetDisplayedPlane(plane); } -SmallMapWindow::SmallMapWindow(const WindowDesc *desc, int window_number) : Window(), refresh(FORCE_REFRESH_PERIOD) +SmallMapWindow::SmallMapWindow(WindowDesc *desc, int window_number) : Window(desc), refresh(FORCE_REFRESH_PERIOD) { _smallmap_industry_highlight = INVALID_INDUSTRYTYPE; this->overlay = new LinkGraphOverlay(this, WID_SM_MAP); - this->InitNested(desc, window_number); + this->InitNested(window_number); this->LowerWidget(this->map_type + WID_SM_CONTOUR); BuildLandLegend(); @@ -1776,7 +1776,7 @@ static const NWidgetPart _nested_smallmap_widgets[] = { EndContainer(), }; -static const WindowDesc _smallmap_desc( +static WindowDesc _smallmap_desc( WDP_AUTO, 484, 314, WC_SMALLMAP, WC_NONE, 0, diff --git a/src/smallmap_gui.h b/src/smallmap_gui.h index c54db27be..4b180f547 100644 --- a/src/smallmap_gui.h +++ b/src/smallmap_gui.h @@ -159,7 +159,7 @@ protected: public: friend class NWidgetSmallmapDisplay; - SmallMapWindow(const WindowDesc *desc, int window_number); + SmallMapWindow(WindowDesc *desc, int window_number); virtual ~SmallMapWindow() { delete this->overlay; } void SmallMapCenterOnCurrentPos(); diff --git a/src/station_gui.cpp b/src/station_gui.cpp index 5623edb32..c7c033fbf 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -282,7 +282,7 @@ protected: } public: - CompanyStationsWindow(const WindowDesc *desc, WindowNumber window_number) : Window() + CompanyStationsWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { this->stations.SetListing(this->last_sorting); this->stations.SetSortFuncs(this->sorter_funcs); @@ -290,9 +290,9 @@ public: this->stations.NeedResort(); this->SortStationsList(); - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_STL_SCROLLBAR); - this->FinishInitNested(desc, window_number); + this->FinishInitNested(window_number); this->owner = (Owner)this->window_number; const CargoSpec *cs; @@ -711,7 +711,7 @@ static const NWidgetPart _nested_company_stations_widgets[] = { EndContainer(), }; -static const WindowDesc _company_stations_desc( +static WindowDesc _company_stations_desc( WDP_AUTO, 358, 162, WC_STATION_LIST, WC_NONE, 0, @@ -816,15 +816,15 @@ struct StationViewWindow : public Window { ALH_ACCEPTS = 3, ///< Height of the accepted cargo view. }; - StationViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window() + StationViewWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { this->rating_lines = ALH_RATING; this->accepts_lines = ALH_ACCEPTS; - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_SV_SCROLLBAR); /* Nested widget tree creation is done in two steps to ensure that this->GetWidget<NWidgetCore>(WID_SV_ACCEPTS_RATINGS) exists in UpdateWidgetSize(). */ - this->FinishInitNested(desc, window_number); + this->FinishInitNested(window_number); Owner owner = Station::Get(window_number)->owner; if (owner != OWNER_NONE) this->owner = owner; @@ -1183,7 +1183,7 @@ struct StationViewWindow : public Window { }; -static const WindowDesc _station_view_desc( +static WindowDesc _station_view_desc( WDP_AUTO, 249, 110, WC_STATION_VIEW, WC_NONE, 0, @@ -1326,15 +1326,15 @@ struct SelectStationWindow : Window { TileArea area; ///< Location of new station Scrollbar *vscroll; - SelectStationWindow(const WindowDesc *desc, CommandContainer cmd, TileArea ta) : - Window(), + SelectStationWindow(WindowDesc *desc, CommandContainer cmd, TileArea ta) : + Window(desc), select_station_cmd(cmd), area(ta) { - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_JS_SCROLLBAR); this->GetWidget<NWidgetCore>(WID_JS_CAPTION)->widget_data = T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_JOIN_WAYPOINT_CAPTION : STR_JOIN_STATION_CAPTION; - this->FinishInitNested(desc, 0); + this->FinishInitNested(0); this->OnInvalidateData(0); } @@ -1427,7 +1427,7 @@ struct SelectStationWindow : Window { } }; -static const WindowDesc _select_station_desc( +static WindowDesc _select_station_desc( WDP_AUTO, 200, 180, WC_SELECT_STATION, WC_NONE, WDF_CONSTRUCTION, diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp index f8d39ceaf..67c664da8 100644 --- a/src/statusbar_gui.cpp +++ b/src/statusbar_gui.cpp @@ -83,17 +83,17 @@ struct StatusBarWindow : Window { static const int REMINDER_STOP = 0; ///< reminder disappears when counter reaches this value static const int COUNTER_STEP = 2; ///< this is subtracted from active counters every tick - StatusBarWindow(const WindowDesc *desc) : Window() + StatusBarWindow(WindowDesc *desc) : Window(desc) { this->ticker_scroll = TICKER_STOP; this->reminder_timeout = REMINDER_STOP; - this->InitNested(desc); + this->InitNested(); CLRBITS(this->flags, WF_WHITE_BORDER); PositionStatusbar(this); } - virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number) + virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) { Point pt = { 0, _screen.height - sm_height }; return pt; diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp index 80f9adbe5..a53a8b3ba 100644 --- a/src/subsidy_gui.cpp +++ b/src/subsidy_gui.cpp @@ -28,11 +28,11 @@ struct SubsidyListWindow : Window { Scrollbar *vscroll; - SubsidyListWindow(const WindowDesc *desc, WindowNumber window_number) : Window() + SubsidyListWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_SUL_SCROLLBAR); - this->FinishInitNested(desc, window_number); + this->FinishInitNested(window_number); this->OnInvalidateData(0); } @@ -238,7 +238,7 @@ static const NWidgetPart _nested_subsidies_list_widgets[] = { EndContainer(), }; -static const WindowDesc _subsidies_list_desc( +static WindowDesc _subsidies_list_desc( WDP_AUTO, 500, 127, WC_SUBSIDIES_LIST, WC_NONE, 0, diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index d3c28ef9e..22efd7a39 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -147,11 +147,11 @@ void PlaceProc_DemolishArea(TileIndex tile) struct TerraformToolbarWindow : Window { int last_user_action; ///< Last started user action. - TerraformToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window() + TerraformToolbarWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { /* This is needed as we like to have the tree available on OnInit. */ - this->CreateNestedTree(desc); - this->FinishInitNested(desc, window_number); + this->CreateNestedTree(); + this->FinishInitNested(window_number); this->last_user_action = WIDGET_LIST_END; } @@ -266,7 +266,7 @@ struct TerraformToolbarWindow : Window { VpSelectTilesWithMethod(pt.x, pt.y, select_method); } - virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number) + virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) { Point pt = GetToolbarAlignedWindowPosition(sm_width); pt.y += sm_height; @@ -341,7 +341,7 @@ static const NWidgetPart _nested_terraform_widgets[] = { EndContainer(), }; -static const WindowDesc _terraform_desc( +static WindowDesc _terraform_desc( WDP_MANUAL, 0, 0, WC_SCEN_LAND_GEN, WC_NONE, WDF_CONSTRUCTION, @@ -536,12 +536,12 @@ static void ResetLandscapeConfirmationCallback(Window *w, bool confirmed) struct ScenarioEditorLandscapeGenerationWindow : Window { int last_user_action; ///< Last started user action. - ScenarioEditorLandscapeGenerationWindow(const WindowDesc *desc, WindowNumber window_number) : Window() + ScenarioEditorLandscapeGenerationWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { - this->CreateNestedTree(desc); + this->CreateNestedTree(); NWidgetStacked *show_desert = this->GetWidget<NWidgetStacked>(WID_ETT_SHOW_PLACE_DESERT); show_desert->SetDisplayedPlane(_settings_game.game_creation.landscape == LT_TROPIC ? 0 : SZSP_NONE); - this->FinishInitNested(desc, window_number); + this->FinishInitNested(window_number); this->last_user_action = WIDGET_LIST_END; } @@ -739,7 +739,7 @@ Hotkey<ScenarioEditorLandscapeGenerationWindow> ScenarioEditorLandscapeGeneratio Hotkey<ScenarioEditorLandscapeGenerationWindow> *_terraform_editor_hotkeys = ScenarioEditorLandscapeGenerationWindow::terraform_editor_hotkeys; -static const WindowDesc _scen_edit_land_gen_desc( +static WindowDesc _scen_edit_land_gen_desc( WDP_AUTO, 0, 0, WC_SCEN_LAND_GEN, WC_NONE, WDF_CONSTRUCTION, diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp index 91adc1239..87b1add35 100644 --- a/src/textfile_gui.cpp +++ b/src/textfile_gui.cpp @@ -42,19 +42,19 @@ static const NWidgetPart _nested_textfile_widgets[] = { }; /** Window definition for the textfile window */ -static const WindowDesc _textfile_desc( +static WindowDesc _textfile_desc( WDP_CENTER, 630, 460, WC_TEXTFILE, WC_NONE, 0, _nested_textfile_widgets, lengthof(_nested_textfile_widgets) ); -TextfileWindow::TextfileWindow(TextfileType file_type) : Window(), file_type(file_type) +TextfileWindow::TextfileWindow(TextfileType file_type) : Window(&_textfile_desc), file_type(file_type) { - this->CreateNestedTree(&_textfile_desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_TF_VSCROLLBAR); this->hscroll = this->GetScrollbar(WID_TF_HSCROLLBAR); - this->FinishInitNested(&_textfile_desc); + this->FinishInitNested(); this->GetWidget<NWidgetCore>(WID_TF_CAPTION)->SetDataTip(STR_TEXTFILE_README_CAPTION + file_type, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS); } diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index 7fc8da483..7bb8ca06c 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -164,16 +164,16 @@ struct TimetableWindow : Window { Scrollbar *vscroll; bool query_is_speed_query; ///< The currently open query window is a speed query and not a time query. - TimetableWindow(const WindowDesc *desc, WindowNumber window_number) : - Window(), + TimetableWindow(WindowDesc *desc, WindowNumber window_number) : + Window(desc), sel_index(-1), vehicle(Vehicle::Get(window_number)), show_expected(true) { - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_VT_SCROLLBAR); this->UpdateSelectionStates(); - this->FinishInitNested(desc, window_number); + this->FinishInitNested(window_number); this->owner = this->vehicle->owner; } @@ -689,7 +689,7 @@ static const NWidgetPart _nested_timetable_widgets[] = { EndContainer(), }; -static const WindowDesc _timetable_desc( +static WindowDesc _timetable_desc( WDP_AUTO, 400, 130, WC_VEHICLE_TIMETABLE, WC_VEHICLE_VIEW, WDF_CONSTRUCTION, diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index f8c6691f4..0d3bffc0d 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -1552,9 +1552,9 @@ enum MainToolbarHotkeys { struct MainToolbarWindow : Window { CallBackFunction last_started_action; ///< Last started user action. - MainToolbarWindow(const WindowDesc *desc) : Window() + MainToolbarWindow(WindowDesc *desc) : Window(desc) { - this->InitNested(desc, 0); + this->InitNested(0); this->last_started_action = CBF_NONE; CLRBITS(this->flags, WF_WHITE_BORDER); @@ -1857,9 +1857,9 @@ enum MainToolbarEditorHotkeys { struct ScenarioEditorToolbarWindow : Window { CallBackFunction last_started_action; ///< Last started user action. - ScenarioEditorToolbarWindow(const WindowDesc *desc) : Window() + ScenarioEditorToolbarWindow(WindowDesc *desc) : Window(desc) { - this->InitNested(desc, 0); + this->InitNested(0); this->last_started_action = CBF_NONE; CLRBITS(this->flags, WF_WHITE_BORDER); diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 35e2e9ff7..676061594 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -88,10 +88,10 @@ private: } public: - TownAuthorityWindow(const WindowDesc *desc, WindowNumber window_number) : Window(), sel_index(-1), displayed_actions_on_previous_painting(0) + TownAuthorityWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc), sel_index(-1), displayed_actions_on_previous_painting(0) { this->town = Town::Get(window_number); - this->InitNested(desc, window_number); + this->InitNested(window_number); this->vscroll = this->GetScrollbar(WID_TA_SCROLLBAR); this->vscroll->SetCapacity((this->GetWidget<NWidgetBase>(WID_TA_COMMAND_LIST)->current_y - WD_FRAMERECT_TOP - WD_FRAMERECT_BOTTOM) / FONT_HEIGHT_NORMAL); } @@ -280,7 +280,7 @@ public: } }; -static const WindowDesc _town_authority_desc( +static WindowDesc _town_authority_desc( WDP_AUTO, 317, 222, WC_TOWN_AUTHORITY, WC_NONE, 0, @@ -301,14 +301,14 @@ private: public: static const int WID_TV_HEIGHT_NORMAL = 150; - TownViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window() + TownViewWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->town = Town::Get(window_number); if (this->town->larger_town) this->GetWidget<NWidgetCore>(WID_TV_CAPTION)->widget_data = STR_TOWN_VIEW_CITY_CAPTION; - this->FinishInitNested(desc, window_number); + this->FinishInitNested(window_number); this->flags |= WF_DISABLE_VP_SCROLL; NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_TV_VIEWPORT); @@ -550,7 +550,7 @@ static const NWidgetPart _nested_town_game_view_widgets[] = { EndContainer(), }; -static const WindowDesc _town_game_view_desc( +static WindowDesc _town_game_view_desc( WDP_AUTO, 260, TownViewWindow::WID_TV_HEIGHT_NORMAL, WC_TOWN_VIEW, WC_NONE, 0, @@ -581,7 +581,7 @@ static const NWidgetPart _nested_town_editor_view_widgets[] = { EndContainer(), }; -static const WindowDesc _town_editor_view_desc( +static WindowDesc _town_editor_view_desc( WDP_AUTO, 260, TownViewWindow::WID_TV_HEIGHT_NORMAL, WC_TOWN_VIEW, WC_NONE, 0, @@ -711,9 +711,9 @@ private: } public: - TownDirectoryWindow(const WindowDesc *desc) : Window() + TownDirectoryWindow(WindowDesc *desc) : Window(desc) { - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_TD_SCROLLBAR); @@ -722,7 +722,7 @@ public: this->towns.ForceRebuild(); this->BuildSortTownList(); - this->FinishInitNested(desc, 0); + this->FinishInitNested(0); } virtual void SetStringParameters(int widget) const @@ -937,7 +937,7 @@ GUITownList::SortFunction * const TownDirectoryWindow::sorter_funcs[] = { &TownRatingSorter, }; -static const WindowDesc _town_directory_desc( +static WindowDesc _town_directory_desc( WDP_AUTO, 208, 202, WC_TOWN_DIRECTORY, WC_NONE, 0, @@ -1041,13 +1041,14 @@ private: TownNameParams params; ///< Town name parameters public: - FoundTownWindow(const WindowDesc *desc, WindowNumber window_number) : + FoundTownWindow(WindowDesc *desc, WindowNumber window_number) : + Window(desc), town_size(TSZ_MEDIUM), town_layout(_settings_game.economy.town_layout), townname_editbox(MAX_LENGTH_TOWN_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_TOWN_NAME_CHARS), params(_settings_game.game_creation.town_name) { - this->InitNested(desc, window_number); + this->InitNested(window_number); this->querystrings[WID_TF_TOWN_NAME_EDITBOX] = &this->townname_editbox; this->RandomTownName(); this->UpdateButtons(true); @@ -1177,7 +1178,7 @@ public: } }; -static const WindowDesc _found_town_desc( +static WindowDesc _found_town_desc( WDP_AUTO, 160, 162, WC_FOUND_TOWN, WC_NONE, WDF_CONSTRUCTION, diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp index 4c9e4ed7f..449969c50 100644 --- a/src/transparency_gui.cpp +++ b/src/transparency_gui.cpp @@ -28,9 +28,9 @@ byte _display_opt; ///< What do we want to draw/do? class TransparenciesWindow : public Window { public: - TransparenciesWindow(const WindowDesc *desc, int window_number) : Window() + TransparenciesWindow(WindowDesc *desc, int window_number) : Window(desc) { - this->InitNested(desc, window_number); + this->InitNested(window_number); } virtual void OnPaint() @@ -102,7 +102,7 @@ public: } } - virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number) + virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) { Point pt = GetToolbarAlignedWindowPosition(sm_width); pt.y += 2 * (sm_height - this->GetWidget<NWidgetBase>(WID_TT_BUTTONS)->current_y); @@ -146,7 +146,7 @@ static const NWidgetPart _nested_transparency_widgets[] = { EndContainer(), }; -static const WindowDesc _transparency_desc( +static WindowDesc _transparency_desc( WDP_MANUAL, 0, 0, WC_TRANSPARENCY_TOOLBAR, WC_NONE, 0, diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp index 3a69da124..9f8d9e189 100644 --- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -52,9 +52,9 @@ class BuildTreesWindow : public Window TreeType tree_to_plant; ///< Tree number to plant, \c TREE_INVALID for a random tree. public: - BuildTreesWindow(const WindowDesc *desc, WindowNumber window_number) : Window() + BuildTreesWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { - this->InitNested(desc, window_number); + this->InitNested(window_number); ResetObjectToPlace(); } @@ -238,7 +238,7 @@ static const NWidgetPart _nested_build_trees_widgets[] = { EndContainer(), }; -static const WindowDesc _build_trees_desc( +static WindowDesc _build_trees_desc( WDP_AUTO, 0, 0, WC_BUILD_TREES, WC_NONE, WDF_CONSTRUCTION, diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index d04217d3d..3f3b736c1 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -569,13 +569,13 @@ struct RefitWindow : public Window { return &l[this->sel[1]]; } - RefitWindow(const WindowDesc *desc, const Vehicle *v, VehicleOrderID order, bool auto_refit) : Window() + RefitWindow(WindowDesc *desc, const Vehicle *v, VehicleOrderID order, bool auto_refit) : Window(desc) { this->sel[0] = -1; this->sel[1] = 0; this->auto_refit = auto_refit; this->order = order; - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_VR_SCROLLBAR); this->hscroll = (v->IsGroundVehicle() ? this->GetScrollbar(WID_VR_HSCROLLBAR) : NULL); @@ -587,7 +587,7 @@ struct RefitWindow : public Window { this->GetWidget<NWidgetStacked>(WID_VR_SHOW_HSCROLLBAR)->SetDisplayedPlane(v->IsGroundVehicle() ? 0 : SZSP_HORIZONTAL); this->GetWidget<NWidgetCore>(WID_VR_VEHICLE_PANEL_DISPLAY)->tool_tip = (v->type == VEH_TRAIN) ? STR_REFIT_SELECT_VEHICLES_TOOLTIP : STR_NULL; - this->FinishInitNested(desc, v->index); + this->FinishInitNested(v->index); this->owner = v->owner; this->SetWidgetDisabledState(WID_VR_REFIT, this->sel[0] < 0); @@ -999,7 +999,7 @@ static const NWidgetPart _nested_vehicle_refit_widgets[] = { EndContainer(), }; -static const WindowDesc _vehicle_refit_desc( +static WindowDesc _vehicle_refit_desc( WDP_AUTO, 240, 174, WC_VEHICLE_REFIT, WC_VEHICLE_VIEW, WDF_CONSTRUCTION, @@ -1421,7 +1421,7 @@ private: }; public: - VehicleListWindow(const WindowDesc *desc, WindowNumber window_number) : BaseVehicleListWindow(window_number) + VehicleListWindow(WindowDesc *desc, WindowNumber window_number) : BaseVehicleListWindow(desc, window_number) { /* Set up sorting. Make the window-specific _sorting variable * point to the correct global _sorting struct so we are freed @@ -1434,7 +1434,7 @@ public: default: NOT_REACHED(); } - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_VL_SCROLLBAR); @@ -1453,7 +1453,7 @@ public: this->GetWidget<NWidgetCore>(WID_VL_CAPTION)->widget_data = STR_VEHICLE_LIST_TRAIN_CAPTION + this->vli.vtype; } - this->FinishInitNested(desc, window_number); + this->FinishInitNested(window_number); if (this->vli.company != OWNER_NONE) this->owner = this->vli.company; if (this->vli.vtype == VEH_TRAIN) ResizeWindow(this, 65, 0); @@ -1835,13 +1835,13 @@ struct VehicleDetailsWindow : Window { Scrollbar *vscroll; /** Initialize a newly created vehicle details window */ - VehicleDetailsWindow(const WindowDesc *desc, WindowNumber window_number) : Window() + VehicleDetailsWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { const Vehicle *v = Vehicle::Get(window_number); - this->CreateNestedTree(desc); + this->CreateNestedTree(); this->vscroll = (v->type == VEH_TRAIN ? this->GetScrollbar(WID_VD_SCROLLBAR) : NULL); - this->FinishInitNested(desc, window_number); + this->FinishInitNested(window_number); this->GetWidget<NWidgetCore>(WID_VD_RENAME_VEHICLE)->tool_tip = STR_VEHICLE_DETAILS_TRAIN_RENAME + v->type; @@ -2201,7 +2201,7 @@ struct VehicleDetailsWindow : Window { }; /** Vehicle details window descriptor. */ -static const WindowDesc _train_vehicle_details_desc( +static WindowDesc _train_vehicle_details_desc( WDP_AUTO, 405, 178, WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW, 0, @@ -2209,7 +2209,7 @@ static const WindowDesc _train_vehicle_details_desc( ); /** Vehicle details window descriptor for other vehicles than a train. */ -static const WindowDesc _nontrain_vehicle_details_desc( +static WindowDesc _nontrain_vehicle_details_desc( WDP_AUTO, 405, 113, WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW, 0, @@ -2268,7 +2268,7 @@ static const NWidgetPart _nested_vehicle_view_widgets[] = { }; /** Vehicle view window descriptor for all vehicles but trains. */ -static const WindowDesc _vehicle_view_desc( +static WindowDesc _vehicle_view_desc( WDP_AUTO, 250, 116, WC_VEHICLE_VIEW, WC_NONE, 0, @@ -2279,7 +2279,7 @@ static const WindowDesc _vehicle_view_desc( * Vehicle view window descriptor for trains. Only minimum_height and * default_height are different for train view. */ -static const WindowDesc _train_view_desc( +static WindowDesc _train_view_desc( WDP_AUTO, 250, 134, WC_VEHICLE_VIEW, WC_NONE, 0, @@ -2416,9 +2416,9 @@ private: } public: - VehicleViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window() + VehicleViewWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { - this->CreateNestedTree(desc); + this->CreateNestedTree(); /* Sprites for the 'send to depot' button indexed by vehicle type. */ static const SpriteID vehicle_view_goto_depot_sprites[] = { @@ -2454,7 +2454,7 @@ public: default: NOT_REACHED(); } - this->FinishInitNested(desc, window_number); + this->FinishInitNested(window_number); this->owner = v->owner; this->GetWidget<NWidgetViewport>(WID_VV_VIEWPORT)->InitializeViewport(this, this->window_number | (1 << 31), _vehicle_view_zoom_levels[v->type]); diff --git a/src/vehicle_gui_base.h b/src/vehicle_gui_base.h index e4f6ccc76..1c03f7b34 100644 --- a/src/vehicle_gui_base.h +++ b/src/vehicle_gui_base.h @@ -38,7 +38,7 @@ struct BaseVehicleListWindow : public Window { static const StringID vehicle_sorter_names[]; static GUIVehicleList::SortFunction * const vehicle_sorter_funcs[]; - BaseVehicleListWindow(WindowNumber wno) : Window(), vli(wno) + BaseVehicleListWindow(WindowDesc *desc, WindowNumber wno) : Window(desc), vli(wno) { this->vehicles.SetSortFuncs(this->vehicle_sorter_funcs); } diff --git a/src/viewport_gui.cpp b/src/viewport_gui.cpp index 661ee0557..8330d12a1 100644 --- a/src/viewport_gui.cpp +++ b/src/viewport_gui.cpp @@ -51,9 +51,9 @@ static const NWidgetPart _nested_extra_view_port_widgets[] = { class ExtraViewportWindow : public Window { public: - ExtraViewportWindow(const WindowDesc *desc, int window_number, TileIndex tile) : Window() + ExtraViewportWindow(WindowDesc *desc, int window_number, TileIndex tile) : Window(desc) { - this->InitNested(desc, window_number); + this->InitNested(window_number); NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_EV_VIEWPORT); nvp->InitializeViewport(this, 0, ZOOM_LVL_VIEWPORT); @@ -153,7 +153,7 @@ public: } }; -static const WindowDesc _extra_view_port_desc( +static WindowDesc _extra_view_port_desc( WDP_AUTO, 300, 268, WC_EXTRA_VIEW_PORT, WC_NONE, 0, diff --git a/src/waypoint_gui.cpp b/src/waypoint_gui.cpp index cd50a9ca8..f0d6239c3 100644 --- a/src/waypoint_gui.cpp +++ b/src/waypoint_gui.cpp @@ -52,18 +52,18 @@ public: * @param desc The description of the window. * @param window_number The window number, in this case the waypoint's ID. */ - WaypointWindow(const WindowDesc *desc, WindowNumber window_number) : Window() + 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; - this->CreateNestedTree(desc); + this->CreateNestedTree(); if (this->vt == VEH_TRAIN) { this->GetWidget<NWidgetCore>(WID_W_SHOW_VEHICLES)->SetDataTip(STR_TRAIN, STR_STATION_VIEW_SCHEDULED_TRAINS_TOOLTIP); this->GetWidget<NWidgetCore>(WID_W_CENTER_VIEW)->tool_tip = STR_WAYPOINT_VIEW_CENTER_TOOLTIP; this->GetWidget<NWidgetCore>(WID_W_RENAME)->tool_tip = STR_WAYPOINT_VIEW_CHANGE_WAYPOINT_NAME; } - this->FinishInitNested(desc, window_number); + this->FinishInitNested(window_number); if (this->wp->owner != OWNER_NONE) this->owner = this->wp->owner; this->flags |= WF_DISABLE_VP_SCROLL; @@ -170,7 +170,7 @@ static const NWidgetPart _nested_waypoint_view_widgets[] = { }; /** The description of the waypoint view. */ -static const WindowDesc _waypoint_view_desc( +static WindowDesc _waypoint_view_desc( WDP_AUTO, 260, 118, WC_WAYPOINT_VIEW, WC_NONE, 0, diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index ffba1a6b6..b0beca0fe 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -90,7 +90,7 @@ static const NWidgetPart _nested_dropdown_menu_widgets[] = { EndContainer(), }; -const WindowDesc _dropdown_desc( +static WindowDesc _dropdown_desc( WDP_MANUAL, 0, 0, WC_DROPDOWN_MENU, WC_NONE, 0, @@ -124,11 +124,12 @@ struct DropdownWindow : Window { * @param scroll Dropdown menu has a scrollbar. * @param widget Widgets of the dropdown menu window. */ - DropdownWindow(Window *parent, DropDownList *list, int selected, int button, bool instant_close, const Point &position, const Dimension &size, Colours wi_colour, bool scroll) : Window() + DropdownWindow(Window *parent, DropDownList *list, int selected, int button, bool instant_close, const Point &position, const Dimension &size, Colours wi_colour, bool scroll) + : Window(&_dropdown_desc) { this->position = position; - this->CreateNestedTree(&_dropdown_desc); + this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_DM_SCROLL); @@ -142,7 +143,7 @@ struct DropdownWindow : Window { this->GetWidget<NWidgetStacked>(WID_DM_SHOW_SCROLL)->SetDisplayedPlane(scroll ? 0 : SZSP_NONE); - this->FinishInitNested(&_dropdown_desc, 0); + this->FinishInitNested(0); CLRBITS(this->flags, WF_WHITE_BORDER); /* Total length of list */ @@ -183,7 +184,7 @@ struct DropdownWindow : Window { DeleteDropDownList(this->list); } - virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number) + virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) { return this->position; } diff --git a/src/window.cpp b/src/window.cpp index d223f5cfd..718d6b03a 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1162,16 +1162,16 @@ static void BringWindowToFront(Window *w) * @pre If nested widgets are used (\a widget is \c NULL), #nested_root and #nested_array_size must be initialized. * In addition, #nested_array is either \c NULL, or already initialized. */ -void Window::InitializeData(const WindowDesc *desc, WindowNumber window_number) +void Window::InitializeData(WindowNumber window_number) { /* Set up window properties; some of them are needed to set up smallest size below */ - this->window_class = desc->cls; + this->window_class = this->window_desc->cls; this->SetWhiteBorder(); - if (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 = NULL; this->window_number = window_number; - this->desc_flags = desc->flags; + this->desc_flags = this->window_desc->flags; this->OnInit(); /* Initialize nested widget tree. */ @@ -1489,23 +1489,22 @@ static Point LocalGetWindowPlacement(const WindowDesc *desc, int16 sm_width, int return pt; } -/* virtual */ Point Window::OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number) +/* virtual */ Point Window::OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) { - return LocalGetWindowPlacement(desc, sm_width, sm_height, window_number); + return LocalGetWindowPlacement(this->window_desc, sm_width, sm_height, window_number); } /** * Perform the first part of the initialization of a nested widget tree. * Construct a nested widget tree in #nested_root, and optionally fill the #nested_array array to provide quick access to the uninitialized widgets. * This is mainly useful for setting very basic properties. - * @param desc Window description. * @param fill_nested Fill the #nested_array (enabling is expensive!). * @note Filling the nested array requires an additional traversal through the nested widget tree, and is best performed by #FinishInitNested rather than here. */ -void Window::CreateNestedTree(const WindowDesc *desc, bool fill_nested) +void Window::CreateNestedTree(bool fill_nested) { int biggest_index = -1; - this->nested_root = MakeWindowNWidgetTree(desc->nwid_parts, desc->nwid_length, &biggest_index, &this->shade_select); + this->nested_root = MakeWindowNWidgetTree(this->window_desc->nwid_parts, this->window_desc->nwid_length, &biggest_index, &this->shade_select); this->nested_array_size = (uint)(biggest_index + 1); if (fill_nested) { @@ -1516,30 +1515,31 @@ void Window::CreateNestedTree(const WindowDesc *desc, bool fill_nested) /** * Perform the second part of the initialization of a nested widget tree. - * @param desc Window description. * @param window_number Number of the new window. */ -void Window::FinishInitNested(const WindowDesc *desc, WindowNumber window_number) +void Window::FinishInitNested(WindowNumber window_number) { - this->InitializeData(desc, window_number); - Point pt = this->OnInitialPosition(desc, this->nested_root->smallest_x, this->nested_root->smallest_y, window_number); + this->InitializeData(window_number); + 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(desc->default_width, desc->default_height); + this->FindWindowPlacementAndResize(this->window_desc->default_width, this->window_desc->default_height); } /** * Perform complete initialization of the #Window with nested widgets, to allow use. - * @param desc Window description. * @param window_number Number of the new window. */ -void Window::InitNested(const WindowDesc *desc, WindowNumber window_number) +void Window::InitNested(WindowNumber window_number) { - this->CreateNestedTree(desc, false); - this->FinishInitNested(desc, window_number); + this->CreateNestedTree(false); + this->FinishInitNested(window_number); } -/** Empty constructor, initialization has been moved to #InitNested() called from the constructor of the derived class. */ -Window::Window() : scrolling_scrollbar(-1) +/** + * 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), scrolling_scrollbar(-1) { } diff --git a/src/window_gui.h b/src/window_gui.h index c0beaf323..f04c7d0a3 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -248,14 +248,14 @@ struct QueryString; */ struct Window : ZeroedMemoryAllocator { protected: - void InitializeData(const WindowDesc *desc, WindowNumber window_number); + void InitializeData(WindowNumber window_number); void InitializePositionSize(int x, int y, int min_width, int min_height); void FindWindowPlacementAndResize(int def_width, int def_height); SmallVector<int, 4> scheduled_invalidation_data; ///< Data of scheduled OnInvalidateData() calls. public: - Window(); + Window(WindowDesc *desc); virtual ~Window(); @@ -279,6 +279,7 @@ public: { } + WindowDesc *window_desc; ///< Window description WindowFlags flags; ///< Window flags WindowClass window_class; ///< Window class WindowNumber window_number; ///< Window number within the window class @@ -322,9 +323,9 @@ public: const QueryString *GetQueryString(uint widnum) const; QueryString *GetQueryString(uint widnum); - void InitNested(const WindowDesc *desc, WindowNumber number = 0); - void CreateNestedTree(const WindowDesc *desc, bool fill_nested = true); - void FinishInitNested(const WindowDesc *desc, WindowNumber window_number = 0); + void InitNested(WindowNumber number = 0); + void CreateNestedTree(bool fill_nested = true); + void FinishInitNested(WindowNumber window_number = 0); /** * Set the timeout flag of the window and initiate the timer. @@ -506,13 +507,12 @@ public: /** * Compute the initial position of the window. - * @param *desc The pointer to the WindowDesc of the window to create. * @param sm_width Smallest width of the window. * @param sm_height Smallest height of the window. * @param window_number The window number of the new window. * @return Initial position of the top-left corner of the window. */ - virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number); + virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number); /** * The window must be repainted. @@ -805,7 +805,7 @@ inline const NWID *Window::GetWidget(uint widnum) const class PickerWindowBase : public Window { public: - PickerWindowBase(Window *parent) : Window() + PickerWindowBase(WindowDesc *desc, Window *parent) : Window(desc) { this->parent = parent; } @@ -823,7 +823,7 @@ Window *FindWindowFromPt(int x, int y); * @return see Window pointer of the newly created window */ template <typename Wcls> -Wcls *AllocateWindowDescFront(const WindowDesc *desc, int window_number) +Wcls *AllocateWindowDescFront(WindowDesc *desc, int window_number) { if (BringWindowToFrontById(desc->cls, window_number)) return NULL; return new Wcls(desc, window_number); |