diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index de8a5fa0b4..5afbbc45f4 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -99,7 +99,7 @@ struct AIConfigWindow : public Window { this->OnInvalidateData(0); } - void Close() override + void Close([[maybe_unused]] int data = 0) override { CloseWindowByClass(WC_SCRIPT_LIST); CloseWindowByClass(WC_SCRIPT_SETTINGS); diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index aa53eed6b9..5407a84165 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -90,7 +90,7 @@ struct BuildAirToolbarWindow : Window { this->last_user_action = INVALID_WID_AT; } - void Close() override + void Close([[maybe_unused]] int data = 0) override { if (this->IsWidgetLowered(WID_AT_AIRPORT)) SetViewportCatchmentStation(nullptr, true); if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false); @@ -285,7 +285,7 @@ public: if (selectFirstAirport) this->SelectFirstAvailableAirport(true); } - void Close() override + void Close([[maybe_unused]] int data = 0) override { CloseWindowById(WC_SELECT_STATION, 0); this->PickerWindowBase::Close(); diff --git a/src/bootstrap_gui.cpp b/src/bootstrap_gui.cpp index 7933c60b1f..eba6b55623 100644 --- a/src/bootstrap_gui.cpp +++ b/src/bootstrap_gui.cpp @@ -92,7 +92,7 @@ public: this->InitNested(1); } - void Close() override + void Close([[maybe_unused]] int data = 0) override { _exit_game = true; this->Window::Close(); @@ -150,7 +150,7 @@ public: { } - void Close() override + void Close([[maybe_unused]] int data = 0) override { /* If we are not set to exit the game, it means the bootstrap failed. */ if (!_exit_game) { @@ -208,7 +208,7 @@ public: } /** Stop listening to the content client events. */ - void Close() override + void Close([[maybe_unused]] int data = 0) override { _network_content_client.RemoveCallback(this); this->Window::Close(); diff --git a/src/console_gui.cpp b/src/console_gui.cpp index 82f70210a4..d507c3b660 100644 --- a/src/console_gui.cpp +++ b/src/console_gui.cpp @@ -129,7 +129,7 @@ struct IConsoleWindow : Window this->line_offset = GetStringBoundingBox("] ").width + WidgetDimensions::scaled.frametext.left; } - void Close() override + void Close([[maybe_unused]] int data = 0) override { _iconsole_mode = ICONSOLE_CLOSED; VideoDriver::GetInstance()->EditBoxLostFocus(); diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 4ed3df4bde..97f34fba0b 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -294,7 +294,7 @@ struct DepotWindow : Window { OrderBackup::Reset(); } - void Close() override + void Close([[maybe_unused]] int data = 0) override { CloseWindowById(WC_BUILD_VEHICLE, this->window_number); CloseWindowById(GetWindowClassForVehicleType(this->type), VehicleListIdentifier(VL_DEPOT_LIST, this->type, this->owner, this->GetDepotIndex()).Pack(), false); diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index 9c0d9b61d9..18c4aa501d 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -108,7 +108,7 @@ struct BuildDocksToolbarWindow : Window { if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this); } - void Close() override + void Close([[maybe_unused]] int data = 0) override { if (_game_mode == GM_NORMAL && this->IsWidgetLowered(WID_DT_STATION)) SetViewportCatchmentStation(nullptr, true); if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false); @@ -422,7 +422,7 @@ public: this->LowerWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF); } - void Close() override + void Close([[maybe_unused]] int data = 0) override { CloseWindowById(WC_SELECT_STATION, 0); this->PickerWindowBase::Close(); diff --git a/src/error_gui.cpp b/src/error_gui.cpp index 94ac9c7461..f573574dfd 100644 --- a/src/error_gui.cpp +++ b/src/error_gui.cpp @@ -313,7 +313,7 @@ public: if (_right_button_down && !this->is_critical) this->Close(); } - void Close() override + void Close([[maybe_unused]] int data = 0) override { SetRedErrorSquare(INVALID_TILE); if (_window_system_initialized) ShowFirstError(); diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index 9b7820edcf..93555e7c5d 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -399,7 +399,7 @@ public: } } - void Close() override + void Close([[maybe_unused]] int data = 0) override { /* pause is only used in single-player, non-editor mode, non menu mode */ if (!_networking && _game_mode != GM_EDITOR && _game_mode != GM_MENU) { diff --git a/src/game/game_gui.cpp b/src/game/game_gui.cpp index faca456f13..b4c2d1d632 100644 --- a/src/game/game_gui.cpp +++ b/src/game/game_gui.cpp @@ -105,7 +105,7 @@ struct GSConfigWindow : public Window { this->RebuildVisibleSettings(); } - void Close() override + void Close([[maybe_unused]] int data = 0) override { CloseWindowByClass(WC_SCRIPT_LIST); this->Window::Close(); diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp index 7989b6071f..1deb60281c 100644 --- a/src/highscore_gui.cpp +++ b/src/highscore_gui.cpp @@ -125,7 +125,7 @@ struct EndGameWindow : EndGameHighScoreBaseWindow { MarkWholeScreenDirty(); } - void Close() override + void Close([[maybe_unused]] int data = 0) override { if (!_networking) Command::Post(PM_PAUSED_NORMAL, false); // unpause if (_game_mode != GM_MENU) ShowHighscoreTable(this->window_number, this->rank); @@ -173,7 +173,7 @@ struct HighScoreWindow : EndGameHighScoreBaseWindow { this->rank = ranking; } - void Close() override + void Close([[maybe_unused]] int data = 0) override { if (_game_mode != GM_MENU) ShowVitalWindows(); diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 1e2474782f..ad129cee8c 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -1036,7 +1036,7 @@ struct QueryStringWindow : public Window } } - void Close() override + void Close([[maybe_unused]] int data = 0) override { if (!this->editbox.handled && this->parent != nullptr) { Window *parent = this->parent; @@ -1109,7 +1109,7 @@ struct QueryWindow : public Window { this->FinishInitNested(WN_CONFIRM_POPUP_QUERY); } - void Close() override + void Close([[maybe_unused]] int data = 0) override { if (this->proc != nullptr) this->proc(this->parent, false); this->Window::Close(); diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp index 3ccfb42f38..a13236c8a0 100644 --- a/src/network/network_chat_gui.cpp +++ b/src/network/network_chat_gui.cpp @@ -302,7 +302,7 @@ struct NetworkChatWindow : public Window { PositionNetworkChatWindow(this); } - void Close() override + void Close([[maybe_unused]] int data = 0) override { InvalidateWindowData(WC_NEWS_WINDOW, 0, 0); this->Window::Close(); diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index fb1f435473..f7b9a9a40a 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -108,7 +108,7 @@ BaseNetworkContentDownloadStatusWindow::BaseNetworkContentDownloadStatusWindow(W this->InitNested(WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD); } -void BaseNetworkContentDownloadStatusWindow::Close() +void BaseNetworkContentDownloadStatusWindow::Close([[maybe_unused]] int data) { _network_content_client.RemoveCallback(this); this->Window::Close(); @@ -200,7 +200,7 @@ public: this->parent = FindWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_CONTENT_LIST); } - void Close() override + void Close([[maybe_unused]] int data = 0) override { TarScanner::Mode mode = TarScanner::NONE; for (auto ctype : this->receivedTypes) { @@ -570,7 +570,7 @@ public: this->InvalidateData(); } - void Close() override + void Close([[maybe_unused]] int data = 0) override { _network_content_client.RemoveCallback(this); this->Window::Close(); diff --git a/src/network/network_content_gui.h b/src/network/network_content_gui.h index 300095fe7e..75d9b21d4f 100644 --- a/src/network/network_content_gui.h +++ b/src/network/network_content_gui.h @@ -32,7 +32,7 @@ public: */ BaseNetworkContentDownloadStatusWindow(WindowDesc *desc); - void Close() override; + void Close([[maybe_unused]] int data = 0) override; void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override; void DrawWidget(const Rect &r, int widget) const override; void OnDownloadProgress(const ContentInfo *ci, int bytes) override; diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index f1ec5e3f7f..3298e4cb03 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -672,7 +672,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { this->OnInvalidateData(GOID_NEWGRF_CURRENT_LOADED); } - void Close() override + void Close([[maybe_unused]] int data = 0) override { CloseWindowByClass(WC_GRF_PARAMETERS); CloseWindowByClass(WC_TEXTFILE); diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 4125156878..36792c7c53 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -419,7 +419,7 @@ struct BuildRailToolbarWindow : Window { if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this); } - void Close() override + void Close([[maybe_unused]] int data = 0) override { if (this->IsWidgetLowered(WID_RAT_BUILD_STATION)) SetViewportCatchmentStation(nullptr, true); if (this->IsWidgetLowered(WID_RAT_BUILD_WAYPOINT)) SetViewportCatchmentWaypoint(nullptr, true); @@ -1031,7 +1031,7 @@ public: this->InvalidateData(); } - void Close() override + void Close([[maybe_unused]] int data = 0) override { CloseWindowById(WC_SELECT_STATION, 0); this->PickerWindowBase::Close(); @@ -1694,7 +1694,7 @@ public: this->OnInvalidateData(); } - void Close() override + void Close([[maybe_unused]] int data = 0) override { _convert_signal_button = false; this->PickerWindowBase::Close(); @@ -2018,7 +2018,7 @@ struct BuildRailWaypointWindow : PickerWindowBase { this->BuildPickerList(); } - void Close() override + void Close([[maybe_unused]] int data = 0) override { CloseWindowById(WC_SELECT_STATION, 0); this->PickerWindowBase::Close(); diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 333730c4c0..7784a7a5c7 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -327,7 +327,7 @@ struct BuildRoadToolbarWindow : Window { if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this); } - void Close() override + void Close([[maybe_unused]] int data = 0) override { if (_game_mode == GM_NORMAL && (this->IsWidgetLowered(WID_ROT_BUS_STATION) || this->IsWidgetLowered(WID_ROT_TRUCK_STATION))) SetViewportCatchmentStation(nullptr, true); if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false); @@ -1223,7 +1223,7 @@ public: } } - void Close() override + void Close([[maybe_unused]] int data = 0) override { CloseWindowById(WC_SELECT_STATION, 0); this->PickerWindowBase::Close(); diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 176203b4ff..e6f32b6f30 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -186,7 +186,7 @@ struct GameOptionsWindow : Window { if constexpr (!NetworkSurveyHandler::IsSurveyPossible()) this->GetWidget(WID_GO_SURVEY_SEL)->SetDisplayedPlane(SZSP_NONE); } - void Close() override + void Close([[maybe_unused]] int data = 0) override { CloseWindowById(WC_CUSTOM_CURRENCY, 0); CloseWindowByClass(WC_TEXTFILE); diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index aed4abd03e..9ce1a8a339 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1096,7 +1096,7 @@ SmallMapWindow::~SmallMapWindow() delete this->overlay; } -/* virtual */ void SmallMapWindow::Close() +/* virtual */ void SmallMapWindow::Close([[maybe_unused]] int data) { this->BreakIndustryChainLink(); this->Window::Close(); diff --git a/src/smallmap_gui.h b/src/smallmap_gui.h index 5aa8cb34eb..570a256f98 100644 --- a/src/smallmap_gui.h +++ b/src/smallmap_gui.h @@ -199,7 +199,7 @@ public: void SmallMapCenterOnCurrentPos(); Point GetStationMiddle(const Station *st) const; - void Close() override; + void Close([[maybe_unused]] int data = 0) override; void SetStringParameters(int widget) const override; void OnInit() override; void OnPaint() override; diff --git a/src/station_gui.cpp b/src/station_gui.cpp index befcdbc221..b73ca59c41 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -1325,7 +1325,7 @@ struct StationViewWindow : public Window { this->owner = Station::Get(window_number)->owner; } - void Close() override + void Close([[maybe_unused]] int data = 0) override { CloseWindowById(WC_TRAINS_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_TRAIN, this->owner, this->window_number).Pack(), false); CloseWindowById(WC_ROADVEH_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_ROAD, this->owner, this->window_number).Pack(), false); @@ -2287,7 +2287,7 @@ struct SelectStationWindow : Window { _thd.freeze = true; } - void Close() override + void Close([[maybe_unused]] int data = 0) override { SetViewportCatchmentSpecializedStation(nullptr, true); diff --git a/src/town_gui.cpp b/src/town_gui.cpp index e2e76204d2..4e6dfb3c68 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -364,7 +364,7 @@ public: this->SetWidgetDisabledState(WID_TV_CHANGE_NAME, _networking && !_network_server); } - void Close() override + void Close([[maybe_unused]] int data = 0) override { SetViewportCatchmentTown(Town::Get(this->window_number), false); this->Window::Close(); diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index d5f602de91..86c63dac2b 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -2935,7 +2935,7 @@ public: this->UpdateButtonStatus(); } - void Close() override + void Close([[maybe_unused]] int data = 0) override { CloseWindowById(WC_VEHICLE_ORDERS, this->window_number, false); CloseWindowById(WC_VEHICLE_REFIT, this->window_number, false); diff --git a/src/waypoint_gui.cpp b/src/waypoint_gui.cpp index 4a296d9087..3ef1fa1f48 100644 --- a/src/waypoint_gui.cpp +++ b/src/waypoint_gui.cpp @@ -76,7 +76,7 @@ public: this->OnInvalidateData(0); } - void Close() override + void Close([[maybe_unused]] int data = 0) override { CloseWindowById(GetWindowClassForVehicleType(this->vt), VehicleListIdentifier(VL_STATION_LIST, this->vt, this->owner, this->window_number).Pack(), false); SetViewportCatchmentWaypoint(Waypoint::Get(this->window_number), false); diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index af1c4e2f19..14551f01c5 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -173,7 +173,7 @@ struct DropdownWindow : Window { this->instant_close = instant_close; } - void Close() override + void Close([[maybe_unused]] int data = 0) override { /* Finish closing the dropdown, so it doesn't affect new window placement. * Also mark it dirty in case the callback deals with the screen. (e.g. screenshots). */ diff --git a/src/window.cpp b/src/window.cpp index bcc86c661e..8782b49056 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1045,7 +1045,7 @@ void Window::CloseChildWindows(WindowClass wc) const /** * Hide the window and all its child windows, and mark them for a later deletion. */ -void Window::Close() +void Window::Close([[maybe_unused]] int data) { /* Don't close twice. */ if (*this->z_position == nullptr) return; @@ -1141,11 +1141,11 @@ Window *GetMainWindow() * @param number Number of the window within the window class * @param force force closing; if false don't close when stickied */ -void CloseWindowById(WindowClass cls, WindowNumber number, bool force) +void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data) { Window *w = FindWindowById(cls, number); if (w != nullptr && (force || (w->flags & WF_STICKY) == 0)) { - w->Close(); + w->Close(data); } } @@ -1153,12 +1153,12 @@ void CloseWindowById(WindowClass cls, WindowNumber number, bool force) * Close all windows of a given class * @param cls Window class of windows to delete */ -void CloseWindowByClass(WindowClass cls) +void CloseWindowByClass(WindowClass cls, int data) { /* Note: the container remains stable, even when deleting windows. */ for (Window *w : Window::Iterate()) { if (w->window_class == cls) { - w->Close(); + w->Close(data); } } } @@ -3486,7 +3486,7 @@ void RelocateAllWindows(int neww, int newh) * Hide the window and all its child windows, and mark them for a later deletion. * Always call ResetObjectToPlace() when closing a PickerWindow. */ -void PickerWindowBase::Close() +void PickerWindowBase::Close([[maybe_unused]] int data) { ResetObjectToPlace(); this->Window::Close(); diff --git a/src/window_func.h b/src/window_func.h index 11037db891..c99ef98616 100644 --- a/src/window_func.h +++ b/src/window_func.h @@ -73,13 +73,13 @@ void SetWindowDirty(WindowClass cls, T number) SetWindowDirty(cls, static_cast(number)); } -void CloseWindowById(WindowClass cls, WindowNumber number, bool force = true); -void CloseWindowByClass(WindowClass cls); +void CloseWindowById(WindowClass cls, WindowNumber number, bool force = true, int data = 0); +void CloseWindowByClass(WindowClass cls, int data = 0); template::value, int> = 0> -void CloseWindowById(WindowClass cls, T number, bool force = true) +void CloseWindowById(WindowClass cls, T number, bool force = true, int data = 0) { - CloseWindowById(cls, static_cast(number), force); + CloseWindowById(cls, static_cast(number), force, data); } bool EditBoxInGlobalFocus(); diff --git a/src/window_gui.h b/src/window_gui.h index 26b8dfb2c4..53257ca00b 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -488,7 +488,7 @@ public: static int SortButtonWidth(); void CloseChildWindows(WindowClass wc = WC_INVALID) const; - virtual void Close(); + virtual void Close(int data = 0); static void DeleteClosedWindows(); void SetDirty() const; @@ -922,7 +922,7 @@ public: this->parent = parent; } - void Close() override; + void Close([[maybe_unused]] int data = 0) override; }; Window *BringWindowToFrontById(WindowClass cls, WindowNumber number);