Changeset - r27991:0d8a4a945cd0
[Not reviewed]
master
0 28 0
Peter Nelson - 14 months ago 2023-10-13 11:59:15
peter1138@openttd.org
Add: data parameter in Window::Close method.

This allows passing data when closing a window, e.g. to indicate how it was closed.
28 files changed with 50 insertions and 50 deletions:
0 comments (0 inline, 0 general)
src/ai/ai_gui.cpp
Show inline comments
 
@@ -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);
src/airport_gui.cpp
Show inline comments
 
@@ -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();
src/bootstrap_gui.cpp
Show inline comments
 
@@ -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();
src/console_gui.cpp
Show inline comments
 
@@ -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();
src/depot_gui.cpp
Show inline comments
 
@@ -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);
src/dock_gui.cpp
Show inline comments
 
@@ -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();
src/error_gui.cpp
Show inline comments
 
@@ -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();
src/fios_gui.cpp
Show inline comments
 
@@ -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) {
src/game/game_gui.cpp
Show inline comments
 
@@ -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();
src/highscore_gui.cpp
Show inline comments
 
@@ -125,7 +125,7 @@ struct EndGameWindow : EndGameHighScoreB
 
		MarkWholeScreenDirty();
 
	}
 

	
 
	void Close() override
 
	void Close([[maybe_unused]] int data = 0) override
 
	{
 
		if (!_networking) Command<CMD_PAUSE>::Post(PM_PAUSED_NORMAL, false); // unpause
 
		if (_game_mode != GM_MENU) ShowHighscoreTable(this->window_number, this->rank);
 
@@ -173,7 +173,7 @@ struct HighScoreWindow : EndGameHighScor
 
		this->rank = ranking;
 
	}
 

	
 
	void Close() override
 
	void Close([[maybe_unused]] int data = 0) override
 
	{
 
		if (_game_mode != GM_MENU) ShowVitalWindows();
 

	
src/misc_gui.cpp
Show inline comments
 
@@ -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();
src/network/network_chat_gui.cpp
Show inline comments
 
@@ -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();
src/network/network_content_gui.cpp
Show inline comments
 
@@ -108,7 +108,7 @@ BaseNetworkContentDownloadStatusWindow::
 
	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();
src/network/network_content_gui.h
Show inline comments
 
@@ -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;
src/newgrf_gui.cpp
Show inline comments
 
@@ -672,7 +672,7 @@ struct NewGRFWindow : public Window, New
 
		this->OnInvalidateData(GOID_NEWGRF_CURRENT_LOADED);
 
	}
 

	
 
	void Close() override
 
	void Close([[maybe_unused]] int data = 0) override
 
	{
 
		CloseWindowByClass(WC_GRF_PARAMETERS);
 
		CloseWindowByClass(WC_TEXTFILE);
src/rail_gui.cpp
Show inline comments
 
@@ -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 : PickerW
 
		this->BuildPickerList();
 
	}
 

	
 
	void Close() override
 
	void Close([[maybe_unused]] int data = 0) override
 
	{
 
		CloseWindowById(WC_SELECT_STATION, 0);
 
		this->PickerWindowBase::Close();
src/road_gui.cpp
Show inline comments
 
@@ -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();
src/settings_gui.cpp
Show inline comments
 
@@ -186,7 +186,7 @@ struct GameOptionsWindow : Window {
 
		if constexpr (!NetworkSurveyHandler::IsSurveyPossible()) this->GetWidget<NWidgetStacked>(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);
src/smallmap_gui.cpp
Show inline comments
 
@@ -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();
src/smallmap_gui.h
Show inline comments
 
@@ -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;
src/station_gui.cpp
Show inline comments
 
@@ -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<T>(nullptr, true);
 

	
src/town_gui.cpp
Show inline comments
 
@@ -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();
src/vehicle_gui.cpp
Show inline comments
 
@@ -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);
src/waypoint_gui.cpp
Show inline comments
 
@@ -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);
src/widgets/dropdown.cpp
Show inline comments
 
@@ -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). */
src/window.cpp
Show inline comments
 
@@ -1045,7 +1045,7 @@ void Window::CloseChildWindows(WindowCla
 
/**
 
 * 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, Wi
 
 * 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 ne
 
 * 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();
src/window_func.h
Show inline comments
 
@@ -73,13 +73,13 @@ void SetWindowDirty(WindowClass cls, T n
 
	SetWindowDirty(cls, static_cast<typename T::BaseType>(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<typename T, std::enable_if_t<std::is_base_of<StrongTypedefBase, T>::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<typename T::BaseType>(number), force);
 
	CloseWindowById(cls, static_cast<typename T::BaseType>(number), force, data);
 
}
 

	
 
bool EditBoxInGlobalFocus();
src/window_gui.h
Show inline comments
 
@@ -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);
0 comments (0 inline, 0 general)