Change window close/deallocation to match upstream
This commit is contained in:
@@ -98,10 +98,11 @@ struct AIConfigWindow : public Window {
|
|||||||
this->OnInvalidateData(0);
|
this->OnInvalidateData(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
~AIConfigWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
CloseWindowByClass(WC_SCRIPT_LIST);
|
CloseWindowByClass(WC_SCRIPT_LIST);
|
||||||
CloseWindowByClass(WC_SCRIPT_SETTINGS);
|
CloseWindowByClass(WC_SCRIPT_SETTINGS);
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetStringParameters(int widget) const override
|
void SetStringParameters(int widget) const override
|
||||||
@@ -247,7 +248,7 @@ struct AIConfigWindow : public Window {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_AIC_CLOSE:
|
case WID_AIC_CLOSE:
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_AIC_CONTENT_DOWNLOAD:
|
case WID_AIC_CONTENT_DOWNLOAD:
|
||||||
|
@@ -78,10 +78,11 @@ struct BuildAirToolbarWindow : Window {
|
|||||||
this->last_user_action = WIDGET_LIST_END;
|
this->last_user_action = WIDGET_LIST_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
~BuildAirToolbarWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
if (this->IsWidgetLowered(WID_AT_AIRPORT)) SetViewportCatchmentStation(nullptr, true);
|
if (this->IsWidgetLowered(WID_AT_AIRPORT)) SetViewportCatchmentStation(nullptr, true);
|
||||||
if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false);
|
if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false);
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -278,9 +279,10 @@ public:
|
|||||||
if (selectFirstAirport) this->SelectFirstAvailableAirport(true);
|
if (selectFirstAirport) this->SelectFirstAvailableAirport(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~BuildAirportWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
CloseWindowById(WC_SELECT_STATION, 0);
|
CloseWindowById(WC_SELECT_STATION, 0);
|
||||||
|
this->PickerWindowBase::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetStringParameters(int widget) const override
|
void SetStringParameters(int widget) const override
|
||||||
|
@@ -91,9 +91,10 @@ public:
|
|||||||
this->InitNested(1);
|
this->InitNested(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
~BootstrapErrorWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
_exit_game = true;
|
_exit_game = true;
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||||
@@ -148,12 +149,13 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~BootstrapContentDownloadStatusWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
/* If we are not set to exit the game, it means the bootstrap failed. */
|
/* If we are not set to exit the game, it means the bootstrap failed. */
|
||||||
if (!_exit_game) {
|
if (!_exit_game) {
|
||||||
new BootstrapErrorWindow();
|
new BootstrapErrorWindow();
|
||||||
}
|
}
|
||||||
|
this->BaseNetworkContentDownloadStatusWindow::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDownloadComplete(ContentID cid) override
|
void OnDownloadComplete(ContentID cid) override
|
||||||
@@ -166,7 +168,7 @@ public:
|
|||||||
|
|
||||||
/* _exit_game is used to break out of the outer video driver's MainLoop. */
|
/* _exit_game is used to break out of the outer video driver's MainLoop. */
|
||||||
_exit_game = true;
|
_exit_game = true;
|
||||||
delete this;
|
this->Close();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -205,9 +207,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Stop listening to the content client events. */
|
/** Stop listening to the content client events. */
|
||||||
~BootstrapAskForDownloadWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
_network_content_client.RemoveCallback(this);
|
_network_content_client.RemoveCallback(this);
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||||
@@ -268,7 +271,7 @@ public:
|
|||||||
/* And once the meta data is received, start downloading it. */
|
/* And once the meta data is received, start downloading it. */
|
||||||
_network_content_client.Select(ci->id);
|
_network_content_client.Select(ci->id);
|
||||||
new BootstrapContentDownloadStatusWindow();
|
new BootstrapContentDownloadStatusWindow();
|
||||||
delete this;
|
this->Close();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -185,11 +185,15 @@ public:
|
|||||||
|
|
||||||
~BuildBridgeWindow()
|
~BuildBridgeWindow()
|
||||||
{
|
{
|
||||||
this->last_sorting = this->bridges->GetListing();
|
|
||||||
|
|
||||||
delete bridges;
|
delete bridges;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Close() override
|
||||||
|
{
|
||||||
|
this->last_sorting = this->bridges->GetListing();
|
||||||
|
this->Window::Close();
|
||||||
|
}
|
||||||
|
|
||||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||||
{
|
{
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
@@ -266,7 +270,7 @@ public:
|
|||||||
if (i < 9 && i < this->bridges->size()) {
|
if (i < 9 && i < this->bridges->size()) {
|
||||||
/* Build the requested bridge */
|
/* Build the requested bridge */
|
||||||
this->BuildBridge(i);
|
this->BuildBridge(i);
|
||||||
delete this;
|
this->Close();
|
||||||
return ES_HANDLED;
|
return ES_HANDLED;
|
||||||
}
|
}
|
||||||
return ES_NOT_HANDLED;
|
return ES_NOT_HANDLED;
|
||||||
@@ -280,7 +284,7 @@ public:
|
|||||||
auto it = this->vscroll->GetScrolledItemFromWidget(*this->bridges, pt.y, this, WID_BBS_BRIDGE_LIST);
|
auto it = this->vscroll->GetScrolledItemFromWidget(*this->bridges, pt.y, this, WID_BBS_BRIDGE_LIST);
|
||||||
if (it != this->bridges->end()) {
|
if (it != this->bridges->end()) {
|
||||||
this->BuildBridge(it - this->bridges->begin());
|
this->BuildBridge(it - this->bridges->begin());
|
||||||
delete this;
|
this->Close();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -1689,7 +1689,7 @@ public:
|
|||||||
|
|
||||||
/* Cancel button */
|
/* Cancel button */
|
||||||
case WID_SCMF_CANCEL:
|
case WID_SCMF_CANCEL:
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Load button */
|
/* Load button */
|
||||||
@@ -2895,12 +2895,13 @@ struct BuyCompanyWindow : Window {
|
|||||||
this->company_value = hostile_takeover ? CalculateHostileTakeoverValue(c) : c->bankrupt_value;
|
this->company_value = hostile_takeover ? CalculateHostileTakeoverValue(c) : c->bankrupt_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
~BuyCompanyWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
const Company *c = Company::GetIfValid((CompanyID)this->window_number);
|
const Company *c = Company::GetIfValid((CompanyID)this->window_number);
|
||||||
if (!this->hostile_takeover && c != nullptr && HasBit(c->bankrupt_asked, this->owner) && _current_company == this->owner) {
|
if (!this->hostile_takeover && c != nullptr && HasBit(c->bankrupt_asked, this->owner) && _current_company == this->owner) {
|
||||||
EnqueueDoCommandP(NewCommandContainerBasic(0, this->window_number, 0, CMD_DECLINE_BUY_COMPANY | CMD_NO_SHIFT_ESTIMATE));
|
EnqueueDoCommandP(NewCommandContainerBasic(0, this->window_number, 0, CMD_DECLINE_BUY_COMPANY | CMD_NO_SHIFT_ESTIMATE));
|
||||||
}
|
}
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||||
@@ -2952,7 +2953,7 @@ struct BuyCompanyWindow : Window {
|
|||||||
{
|
{
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
case WID_BC_NO:
|
case WID_BC_NO:
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_BC_YES:
|
case WID_BC_YES:
|
||||||
|
@@ -133,10 +133,11 @@ struct IConsoleWindow : Window
|
|||||||
this->line_offset = GetStringBoundingBox("] ").width + WidgetDimensions::scaled.frametext.left;
|
this->line_offset = GetStringBoundingBox("] ").width + WidgetDimensions::scaled.frametext.left;
|
||||||
}
|
}
|
||||||
|
|
||||||
~IConsoleWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
_iconsole_mode = ICONSOLE_CLOSED;
|
_iconsole_mode = ICONSOLE_CLOSED;
|
||||||
VideoDriver::GetInstance()->EditBoxLostFocus();
|
VideoDriver::GetInstance()->EditBoxLostFocus();
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -345,7 +346,7 @@ struct IConsoleWindow : Window
|
|||||||
VideoDriver::GetInstance()->EditBoxGainedFocus();
|
VideoDriver::GetInstance()->EditBoxGainedFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnFocusLost(Window *newly_focused_window) override
|
void OnFocusLost(bool closing, Window *newly_focused_window) override
|
||||||
{
|
{
|
||||||
VideoDriver::GetInstance()->EditBoxLostFocus();
|
VideoDriver::GetInstance()->EditBoxLostFocus();
|
||||||
}
|
}
|
||||||
|
@@ -155,7 +155,7 @@ struct SetDateWindow : Window {
|
|||||||
if (this->callback != nullptr) {
|
if (this->callback != nullptr) {
|
||||||
this->callback(this, DateToScaledDateTicks(ConvertYMDToDate(this->date.year, this->date.month, this->date.day)));
|
this->callback(this, DateToScaledDateTicks(ConvertYMDToDate(this->date.year, this->date.month, this->date.day)));
|
||||||
}
|
}
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -271,7 +271,7 @@ struct SetMinutesWindow : SetDateWindow
|
|||||||
if (this->callback != nullptr) {
|
if (this->callback != nullptr) {
|
||||||
this->callback(this, ((DateTicks)minutes - _settings_time.clock_offset) * (DateTicksScaled)_settings_time.ticks_per_minute);
|
this->callback(this, ((DateTicks)minutes - _settings_time.clock_offset) * (DateTicksScaled)_settings_time.ticks_per_minute);
|
||||||
}
|
}
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -289,7 +289,7 @@ public:
|
|||||||
|
|
||||||
virtual ~DeparturesWindow()
|
virtual ~DeparturesWindow()
|
||||||
{
|
{
|
||||||
this->DeleteDeparturesList(departures);
|
this->DeleteDeparturesList(this->departures);
|
||||||
this->DeleteDeparturesList(this->arrivals);
|
this->DeleteDeparturesList(this->arrivals);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -296,11 +296,12 @@ struct DepotWindow : Window {
|
|||||||
OrderBackup::Reset();
|
OrderBackup::Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
~DepotWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
CloseWindowById(WC_BUILD_VEHICLE, this->window_number);
|
CloseWindowById(WC_BUILD_VEHICLE, this->window_number);
|
||||||
CloseWindowById(GetWindowClassForVehicleType(this->type), VehicleListIdentifier(VL_DEPOT_LIST, this->type, this->owner, this->GetDepotIndex()).Pack(), false);
|
CloseWindowById(GetWindowClassForVehicleType(this->type), VehicleListIdentifier(VL_DEPOT_LIST, this->type, this->owner, this->GetDepotIndex()).Pack(), false);
|
||||||
OrderBackup::Reset(this->window_number);
|
OrderBackup::Reset(this->window_number);
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -106,10 +106,11 @@ struct BuildDocksToolbarWindow : Window {
|
|||||||
if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
|
if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
~BuildDocksToolbarWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
if (_game_mode == GM_NORMAL && this->IsWidgetLowered(WID_DT_STATION)) SetViewportCatchmentStation(nullptr, true);
|
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);
|
if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false);
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -425,9 +426,10 @@ public:
|
|||||||
this->LowerWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF);
|
this->LowerWidget(_settings_client.gui.station_show_coverage + BDSW_LT_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~BuildDocksStationWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
CloseWindowById(WC_SELECT_STATION, 0);
|
CloseWindowById(WC_SELECT_STATION, 0);
|
||||||
|
this->PickerWindowBase::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnPaint() override
|
void OnPaint() override
|
||||||
|
@@ -128,7 +128,7 @@ struct EnginePreviewWindow : Window {
|
|||||||
DoCommandP(0, this->window_number, 0, CMD_WANT_ENGINE_PREVIEW);
|
DoCommandP(0, this->window_number, 0, CMD_WANT_ENGINE_PREVIEW);
|
||||||
FALLTHROUGH;
|
FALLTHROUGH;
|
||||||
case WID_EP_NO:
|
case WID_EP_NO:
|
||||||
if (!_shift_pressed) delete this;
|
if (!_shift_pressed) this->Close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -138,7 +138,7 @@ struct EnginePreviewWindow : Window {
|
|||||||
if (!gui_scope) return;
|
if (!gui_scope) return;
|
||||||
|
|
||||||
EngineID engine = this->window_number;
|
EngineID engine = this->window_number;
|
||||||
if (Engine::Get(engine)->preview_company != _local_company) delete this;
|
if (Engine::Get(engine)->preview_company != _local_company) this->Close();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -262,7 +262,7 @@ public:
|
|||||||
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
||||||
{
|
{
|
||||||
/* If company gets shut down, while displaying an error about it, remove the error message. */
|
/* If company gets shut down, while displaying an error about it, remove the error message. */
|
||||||
if (this->face != INVALID_COMPANY && !Company::IsValidID(this->face)) delete this;
|
if (this->face != INVALID_COMPANY && !Company::IsValidID(this->face)) this->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetStringParameters(int widget) const override
|
void SetStringParameters(int widget) const override
|
||||||
@@ -316,20 +316,21 @@ public:
|
|||||||
void OnMouseLoop() override
|
void OnMouseLoop() override
|
||||||
{
|
{
|
||||||
/* Disallow closing the window too easily, if timeout is disabled */
|
/* Disallow closing the window too easily, if timeout is disabled */
|
||||||
if (_right_button_down && !this->display_timer.HasElapsed()) delete this;
|
if (_right_button_down && !this->display_timer.HasElapsed()) this->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnRealtimeTick(uint delta_ms) override
|
void OnRealtimeTick(uint delta_ms) override
|
||||||
{
|
{
|
||||||
if (this->display_timer.CountElapsed(delta_ms) == 0) return;
|
if (this->display_timer.CountElapsed(delta_ms) == 0) return;
|
||||||
|
|
||||||
delete this;
|
this->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
~ErrmsgWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
SetRedErrorSquare(INVALID_TILE);
|
SetRedErrorSquare(INVALID_TILE);
|
||||||
if (_window_system_initialized) ShowFirstError();
|
if (_window_system_initialized) ShowFirstError();
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -372,7 +373,7 @@ void UnshowCriticalError()
|
|||||||
if (_window_system_initialized && w != nullptr) {
|
if (_window_system_initialized && w != nullptr) {
|
||||||
if (w->IsCritical()) _error_list.push_front(*w);
|
if (w->IsCritical()) _error_list.push_front(*w);
|
||||||
_window_system_initialized = false;
|
_window_system_initialized = false;
|
||||||
delete w;
|
w->Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,18 +427,20 @@ void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel
|
|||||||
data.CopyOutDParams();
|
data.CopyOutDParams();
|
||||||
|
|
||||||
ErrmsgWindow *w = (ErrmsgWindow*)FindWindowById(WC_ERRMSG, 0);
|
ErrmsgWindow *w = (ErrmsgWindow*)FindWindowById(WC_ERRMSG, 0);
|
||||||
if (w != nullptr && w->IsCritical()) {
|
if (w != nullptr) {
|
||||||
/* A critical error is currently shown. */
|
if (w->IsCritical()) {
|
||||||
if (wl == WL_CRITICAL) {
|
/* A critical error is currently shown. */
|
||||||
/* Push another critical error in the queue of errors,
|
if (wl == WL_CRITICAL) {
|
||||||
* but do not put other errors in the queue. */
|
/* Push another critical error in the queue of errors,
|
||||||
_error_list.push_back(data);
|
* but do not put other errors in the queue. */
|
||||||
|
_error_list.push_back(data);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
/* A non-critical error was shown. */
|
||||||
/* Nothing or a non-critical error was shown. */
|
w->Close();
|
||||||
delete w;
|
|
||||||
new ErrmsgWindow(data);
|
|
||||||
}
|
}
|
||||||
|
new ErrmsgWindow(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -448,7 +451,7 @@ void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel
|
|||||||
bool HideActiveErrorMessage() {
|
bool HideActiveErrorMessage() {
|
||||||
ErrmsgWindow *w = (ErrmsgWindow*)FindWindowById(WC_ERRMSG, 0);
|
ErrmsgWindow *w = (ErrmsgWindow*)FindWindowById(WC_ERRMSG, 0);
|
||||||
if (w == nullptr) return false;
|
if (w == nullptr) return false;
|
||||||
delete w;
|
w->Close();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -408,12 +408,13 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~SaveLoadWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
/* pause is only used in single-player, non-editor mode, non menu mode */
|
/* pause is only used in single-player, non-editor mode, non menu mode */
|
||||||
if (!_networking && _game_mode != GM_EDITOR && _game_mode != GM_MENU) {
|
if (!_networking && _game_mode != GM_EDITOR && _game_mode != GM_MENU) {
|
||||||
DoCommandP(0, PM_PAUSED_SAVELOAD, 0, CMD_PAUSE);
|
DoCommandP(0, PM_PAUSED_SAVELOAD, 0, CMD_PAUSE);
|
||||||
}
|
}
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawWidget(const Rect &r, int widget) const override
|
void DrawWidget(const Rect &r, int widget) const override
|
||||||
@@ -641,12 +642,12 @@ public:
|
|||||||
_file_to_saveload.Set(*this->selected);
|
_file_to_saveload.Set(*this->selected);
|
||||||
|
|
||||||
if (this->abstract_filetype == FT_HEIGHTMAP) {
|
if (this->abstract_filetype == FT_HEIGHTMAP) {
|
||||||
delete this;
|
this->Close();
|
||||||
ShowHeightmapLoad();
|
ShowHeightmapLoad();
|
||||||
} else if (!_load_check_data.HasNewGrfs() || _load_check_data.grf_compatibility != GLC_NOT_FOUND || _settings_client.gui.UserIsAllowedToChangeNewGRFs()) {
|
} else if (!_load_check_data.HasNewGrfs() || _load_check_data.grf_compatibility != GLC_NOT_FOUND || _settings_client.gui.UserIsAllowedToChangeNewGRFs()) {
|
||||||
_switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD_GAME;
|
_switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD_GAME;
|
||||||
ClearErrorMessages();
|
ClearErrorMessages();
|
||||||
delete this;
|
this->Close();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -704,7 +705,7 @@ public:
|
|||||||
assert(this->abstract_filetype == FT_HEIGHTMAP);
|
assert(this->abstract_filetype == FT_HEIGHTMAP);
|
||||||
_file_to_saveload.Set(*file);
|
_file_to_saveload.Set(*file);
|
||||||
|
|
||||||
delete this;
|
this->Close();
|
||||||
ShowHeightmapLoad();
|
ShowHeightmapLoad();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -757,7 +758,7 @@ public:
|
|||||||
EventState OnKeyPress(WChar key, uint16 keycode) override
|
EventState OnKeyPress(WChar key, uint16 keycode) override
|
||||||
{
|
{
|
||||||
if (keycode == WKC_ESC) {
|
if (keycode == WKC_ESC) {
|
||||||
delete this;
|
this->Close();
|
||||||
return ES_HANDLED;
|
return ES_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -111,10 +111,11 @@ struct GSConfigWindow : public Window {
|
|||||||
this->RebuildVisibleSettings();
|
this->RebuildVisibleSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
~GSConfigWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
HideDropDownMenu(this);
|
HideDropDownMenu(this);
|
||||||
CloseWindowByClass(WC_SCRIPT_LIST);
|
CloseWindowByClass(WC_SCRIPT_LIST);
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -354,7 +355,7 @@ struct GSConfigWindow : public Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case WID_GSC_ACCEPT:
|
case WID_GSC_ACCEPT:
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_GSC_RESET:
|
case WID_GSC_RESET:
|
||||||
|
@@ -375,17 +375,17 @@ struct GoalQuestionWindow : public Window {
|
|||||||
switch (widget) {
|
switch (widget) {
|
||||||
case WID_GQ_BUTTON_1:
|
case WID_GQ_BUTTON_1:
|
||||||
DoCommandP(0, this->window_number, this->button[0], CMD_GOAL_QUESTION_ANSWER);
|
DoCommandP(0, this->window_number, this->button[0], CMD_GOAL_QUESTION_ANSWER);
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_GQ_BUTTON_2:
|
case WID_GQ_BUTTON_2:
|
||||||
DoCommandP(0, this->window_number, this->button[1], CMD_GOAL_QUESTION_ANSWER);
|
DoCommandP(0, this->window_number, this->button[1], CMD_GOAL_QUESTION_ANSWER);
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_GQ_BUTTON_3:
|
case WID_GQ_BUTTON_3:
|
||||||
DoCommandP(0, this->window_number, this->button[2], CMD_GOAL_QUESTION_ANSWER);
|
DoCommandP(0, this->window_number, this->button[2], CMD_GOAL_QUESTION_ANSWER);
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -447,9 +447,10 @@ public:
|
|||||||
this->owner = vli.company;
|
this->owner = vli.company;
|
||||||
}
|
}
|
||||||
|
|
||||||
~VehicleGroupWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
*this->sorting = this->vehgroups.GetListing();
|
*this->sorting = this->vehgroups.GetListing();
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||||
|
@@ -64,7 +64,7 @@ struct EndGameHighScoreBaseWindow : Window {
|
|||||||
|
|
||||||
void OnClick(Point pt, int widget, int click_count) override
|
void OnClick(Point pt, int widget, int click_count) override
|
||||||
{
|
{
|
||||||
delete this;
|
this->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
EventState OnKeyPress(WChar key, uint16 keycode) override
|
EventState OnKeyPress(WChar key, uint16 keycode) override
|
||||||
@@ -79,7 +79,7 @@ struct EndGameHighScoreBaseWindow : Window {
|
|||||||
case WKC_RETURN:
|
case WKC_RETURN:
|
||||||
case WKC_ESC:
|
case WKC_ESC:
|
||||||
case WKC_SPACE:
|
case WKC_SPACE:
|
||||||
delete this;
|
this->Close();
|
||||||
return ES_HANDLED;
|
return ES_HANDLED;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -122,10 +122,11 @@ struct EndGameWindow : EndGameHighScoreBaseWindow {
|
|||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
~EndGameWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
if (!_networking) DoCommandP(0, PM_PAUSED_NORMAL, 0, CMD_PAUSE); // unpause
|
if (!_networking) DoCommandP(0, PM_PAUSED_NORMAL, 0, CMD_PAUSE); // unpause
|
||||||
if (_game_mode != GM_MENU) ShowHighscoreTable(this->window_number, this->rank);
|
if (_game_mode != GM_MENU) ShowHighscoreTable(this->window_number, this->rank);
|
||||||
|
this->EndGameHighScoreBaseWindow::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnPaint() override
|
void OnPaint() override
|
||||||
@@ -169,11 +170,13 @@ struct HighScoreWindow : EndGameHighScoreBaseWindow {
|
|||||||
this->rank = ranking;
|
this->rank = ranking;
|
||||||
}
|
}
|
||||||
|
|
||||||
~HighScoreWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
if (_game_mode != GM_MENU) ShowVitalWindows();
|
if (_game_mode != GM_MENU) ShowVitalWindows();
|
||||||
|
|
||||||
if (!_networking && !this->game_paused_by_player) DoCommandP(0, PM_PAUSED_NORMAL, 0, CMD_PAUSE); // unpause
|
if (!_networking && !this->game_paused_by_player) DoCommandP(0, PM_PAUSED_NORMAL, 0, CMD_PAUSE); // unpause
|
||||||
|
|
||||||
|
this->EndGameHighScoreBaseWindow::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnPaint() override
|
void OnPaint() override
|
||||||
|
@@ -1638,9 +1638,10 @@ public:
|
|||||||
this->industry_editbox.cancel_button = QueryString::ACTION_CLEAR;
|
this->industry_editbox.cancel_button = QueryString::ACTION_CLEAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
~IndustryDirectoryWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
this->last_sorting = this->industries.GetListing();
|
this->last_sorting = this->industries.GetListing();
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnInit() override
|
void OnInit() override
|
||||||
|
@@ -903,7 +903,7 @@ void LinkGraphLegendWindow::OnClick(Point pt, int widget, int click_count)
|
|||||||
void LinkGraphLegendWindow::OnInvalidateData(int data, bool gui_scope)
|
void LinkGraphLegendWindow::OnInvalidateData(int data, bool gui_scope)
|
||||||
{
|
{
|
||||||
if (this->num_cargo != _sorted_cargo_specs.size()) {
|
if (this->num_cargo != _sorted_cargo_specs.size()) {
|
||||||
delete this;
|
this->Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -799,15 +799,15 @@ struct TooltipsWindow : public Window
|
|||||||
{
|
{
|
||||||
/* Always close tooltips when the cursor is not in our window. */
|
/* Always close tooltips when the cursor is not in our window. */
|
||||||
if (!_cursor.in_window || this->delete_next_mouse_loop) {
|
if (!_cursor.in_window || this->delete_next_mouse_loop) {
|
||||||
delete this;
|
this->Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We can show tooltips while dragging tools. These are shown as long as
|
/* We can show tooltips while dragging tools. These are shown as long as
|
||||||
* we are dragging the tool. Normal tooltips work with hover or rmb. */
|
* we are dragging the tool. Normal tooltips work with hover or rmb. */
|
||||||
switch (this->close_cond) {
|
switch (this->close_cond) {
|
||||||
case TCC_RIGHT_CLICK: if (!_right_button_down) delete this; break;
|
case TCC_RIGHT_CLICK: if (!_right_button_down) this->Close();; break;
|
||||||
case TCC_HOVER: if (!_mouse_hovering) delete this; break;
|
case TCC_HOVER: if (!_mouse_hovering) this->Close();; break;
|
||||||
case TCC_NONE: break;
|
case TCC_NONE: break;
|
||||||
case TCC_NEXT_LOOP: this->delete_next_mouse_loop = true; break;
|
case TCC_NEXT_LOOP: this->delete_next_mouse_loop = true; break;
|
||||||
|
|
||||||
@@ -815,7 +815,7 @@ struct TooltipsWindow : public Window
|
|||||||
if (_settings_client.gui.hover_delay_ms == 0) {
|
if (_settings_client.gui.hover_delay_ms == 0) {
|
||||||
if (!_right_button_down) this->delete_next_mouse_loop = true;
|
if (!_right_button_down) this->delete_next_mouse_loop = true;
|
||||||
} else if (!_mouse_hovering) {
|
} else if (!_mouse_hovering) {
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (this->viewport_virtual_left != this->parent->viewport->virtual_left ||
|
if (this->viewport_virtual_left != this->parent->viewport->virtual_left ||
|
||||||
@@ -826,7 +826,7 @@ struct TooltipsWindow : public Window
|
|||||||
|
|
||||||
case TCC_EXIT_VIEWPORT: {
|
case TCC_EXIT_VIEWPORT: {
|
||||||
Window *w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y);
|
Window *w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y);
|
||||||
if (w == nullptr || IsPtInWindowViewport(w, _cursor.pos.x, _cursor.pos.y) == nullptr) delete this;
|
if (w == nullptr || IsPtInWindowViewport(w, _cursor.pos.x, _cursor.pos.y) == nullptr) this->Close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1134,18 +1134,19 @@ struct QueryStringWindow : public Window
|
|||||||
FALLTHROUGH;
|
FALLTHROUGH;
|
||||||
|
|
||||||
case WID_QS_CANCEL:
|
case WID_QS_CANCEL:
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~QueryStringWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
if (!this->editbox.handled && this->parent != nullptr) {
|
if (!this->editbox.handled && this->parent != nullptr) {
|
||||||
Window *parent = this->parent;
|
Window *parent = this->parent;
|
||||||
this->parent = nullptr; // so parent doesn't try to delete us again
|
this->parent = nullptr; // so parent doesn't try to close us again
|
||||||
parent->OnQueryTextFinished(nullptr);
|
parent->OnQueryTextFinished(nullptr);
|
||||||
}
|
}
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1227,9 +1228,10 @@ struct QueryWindow : public Window {
|
|||||||
this->InitNested(WN_CONFIRM_POPUP_QUERY);
|
this->InitNested(WN_CONFIRM_POPUP_QUERY);
|
||||||
}
|
}
|
||||||
|
|
||||||
~QueryWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
if (this->proc != nullptr) this->proc(this->parent, false);
|
if (this->proc != nullptr) this->proc(this->parent, false);
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindWindowPlacementAndResize(int def_width, int def_height) override
|
void FindWindowPlacementAndResize(int def_width, int def_height) override
|
||||||
@@ -1292,7 +1294,7 @@ struct QueryWindow : public Window {
|
|||||||
Window *parent = this->parent;
|
Window *parent = this->parent;
|
||||||
/* Prevent the destructor calling the callback function */
|
/* Prevent the destructor calling the callback function */
|
||||||
this->proc = nullptr;
|
this->proc = nullptr;
|
||||||
delete this;
|
this->Close();
|
||||||
if (proc != nullptr) {
|
if (proc != nullptr) {
|
||||||
proc(parent, true);
|
proc(parent, true);
|
||||||
proc = nullptr;
|
proc = nullptr;
|
||||||
@@ -1300,7 +1302,7 @@ struct QueryWindow : public Window {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WID_Q_NO:
|
case WID_Q_NO:
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1318,7 +1320,7 @@ struct QueryWindow : public Window {
|
|||||||
FALLTHROUGH;
|
FALLTHROUGH;
|
||||||
|
|
||||||
case WKC_ESC:
|
case WKC_ESC:
|
||||||
delete this;
|
this->Close();
|
||||||
return ES_HANDLED;
|
return ES_HANDLED;
|
||||||
}
|
}
|
||||||
return ES_NOT_HANDLED;
|
return ES_NOT_HANDLED;
|
||||||
@@ -1350,13 +1352,13 @@ static WindowDesc _query_desc(
|
|||||||
|
|
||||||
static void RemoveExistingQueryWindow(Window *parent, QueryCallbackProc *callback)
|
static void RemoveExistingQueryWindow(Window *parent, QueryCallbackProc *callback)
|
||||||
{
|
{
|
||||||
for (const Window *w : Window::IterateFromBack()) {
|
for (Window *w : Window::IterateFromBack()) {
|
||||||
if (w->window_class != WC_CONFIRM_POPUP_QUERY) continue;
|
if (w->window_class != WC_CONFIRM_POPUP_QUERY) continue;
|
||||||
|
|
||||||
const QueryWindow *qw = (const QueryWindow *)w;
|
QueryWindow *qw = (QueryWindow *)w;
|
||||||
if (qw->parent != parent || qw->proc != callback) continue;
|
if (qw->parent != parent || qw->proc != callback) continue;
|
||||||
|
|
||||||
delete qw;
|
qw->Close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1424,10 +1426,11 @@ struct ModifierKeyToggleWindow : Window {
|
|||||||
this->UpdateButtons();
|
this->UpdateButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
~ModifierKeyToggleWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
_invert_shift = false;
|
_invert_shift = false;
|
||||||
_invert_ctrl = false;
|
_invert_ctrl = false;
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateButtons()
|
void UpdateButtons()
|
||||||
|
@@ -314,9 +314,10 @@ struct NetworkChatWindow : public Window {
|
|||||||
PositionNetworkChatWindow(this);
|
PositionNetworkChatWindow(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
~NetworkChatWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
InvalidateWindowData(WC_NEWS_WINDOW, 0, 0);
|
InvalidateWindowData(WC_NEWS_WINDOW, 0, 0);
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindWindowPlacementAndResize(int def_width, int def_height) override
|
void FindWindowPlacementAndResize(int def_width, int def_height) override
|
||||||
@@ -470,7 +471,7 @@ struct NetworkChatWindow : public Window {
|
|||||||
FALLTHROUGH;
|
FALLTHROUGH;
|
||||||
|
|
||||||
case WID_NC_CLOSE: /* Cancel */
|
case WID_NC_CLOSE: /* Cancel */
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -497,7 +498,7 @@ struct NetworkChatWindow : public Window {
|
|||||||
*/
|
*/
|
||||||
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
||||||
{
|
{
|
||||||
if (data == this->dest) delete this;
|
if (data == this->dest) this->Close();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -109,9 +109,10 @@ BaseNetworkContentDownloadStatusWindow::BaseNetworkContentDownloadStatusWindow(W
|
|||||||
this->InitNested(WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD);
|
this->InitNested(WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseNetworkContentDownloadStatusWindow::~BaseNetworkContentDownloadStatusWindow()
|
void BaseNetworkContentDownloadStatusWindow::Close()
|
||||||
{
|
{
|
||||||
_network_content_client.RemoveCallback(this);
|
_network_content_client.RemoveCallback(this);
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseNetworkContentDownloadStatusWindow::UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
void BaseNetworkContentDownloadStatusWindow::UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
||||||
@@ -200,8 +201,7 @@ public:
|
|||||||
this->parent = FindWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_CONTENT_LIST);
|
this->parent = FindWindowById(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_CONTENT_LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Free whatever we've allocated */
|
void Close() override
|
||||||
~NetworkContentDownloadStatusWindow()
|
|
||||||
{
|
{
|
||||||
TarScanner::Mode mode = TarScanner::NONE;
|
TarScanner::Mode mode = TarScanner::NONE;
|
||||||
for (auto ctype : this->receivedTypes) {
|
for (auto ctype : this->receivedTypes) {
|
||||||
@@ -282,6 +282,8 @@ public:
|
|||||||
|
|
||||||
/* Always invalidate the download window; tell it we are going to be gone */
|
/* Always invalidate the download window; tell it we are going to be gone */
|
||||||
InvalidateWindowData(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_CONTENT_LIST, 2);
|
InvalidateWindowData(WC_NETWORK_WINDOW, WN_NETWORK_WINDOW_CONTENT_LIST, 2);
|
||||||
|
|
||||||
|
this->BaseNetworkContentDownloadStatusWindow::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnClick(Point pt, int widget, int click_count) override
|
void OnClick(Point pt, int widget, int click_count) override
|
||||||
@@ -289,7 +291,7 @@ public:
|
|||||||
if (widget == WID_NCDS_CANCELOK) {
|
if (widget == WID_NCDS_CANCELOK) {
|
||||||
if (this->downloaded_bytes != this->total_bytes) {
|
if (this->downloaded_bytes != this->total_bytes) {
|
||||||
_network_content_client.CloseConnection();
|
_network_content_client.CloseConnection();
|
||||||
delete this;
|
this->Close();
|
||||||
} else {
|
} else {
|
||||||
/* If downloading succeeded, close the online content window. This will close
|
/* If downloading succeeded, close the online content window. This will close
|
||||||
* the current window as well. */
|
* the current window as well. */
|
||||||
@@ -572,10 +574,10 @@ public:
|
|||||||
this->InvalidateData();
|
this->InvalidateData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Free everything we allocated */
|
void Close() override
|
||||||
~NetworkContentListWindow()
|
|
||||||
{
|
{
|
||||||
_network_content_client.RemoveCallback(this);
|
_network_content_client.RemoveCallback(this);
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnInit() override
|
void OnInit() override
|
||||||
@@ -852,7 +854,7 @@ public:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_NCL_CANCEL:
|
case WID_NCL_CANCEL:
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_NCL_OPEN_URL:
|
case WID_NCL_OPEN_URL:
|
||||||
@@ -955,7 +957,7 @@ public:
|
|||||||
{
|
{
|
||||||
if (!success) {
|
if (!success) {
|
||||||
ShowErrorMessage(STR_CONTENT_ERROR_COULD_NOT_CONNECT, INVALID_STRING_ID, WL_ERROR);
|
ShowErrorMessage(STR_CONTENT_ERROR_COULD_NOT_CONNECT, INVALID_STRING_ID, WL_ERROR);
|
||||||
delete this;
|
this->Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -32,11 +32,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
BaseNetworkContentDownloadStatusWindow(WindowDesc *desc);
|
BaseNetworkContentDownloadStatusWindow(WindowDesc *desc);
|
||||||
|
|
||||||
/**
|
void Close() override;
|
||||||
* Free everything associated with this window.
|
|
||||||
*/
|
|
||||||
~BaseNetworkContentDownloadStatusWindow();
|
|
||||||
|
|
||||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override;
|
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override;
|
||||||
void DrawWidget(const Rect &r, int widget) const override;
|
void DrawWidget(const Rect &r, int widget) const override;
|
||||||
void OnDownloadProgress(const ContentInfo *ci, int bytes) override;
|
void OnDownloadProgress(const ContentInfo *ci, int bytes) override;
|
||||||
|
@@ -523,9 +523,10 @@ public:
|
|||||||
this->servers.ForceRebuild();
|
this->servers.ForceRebuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
~NetworkGameWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
this->last_sorting = this->servers.GetListing();
|
this->last_sorting = this->servers.GetListing();
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnInit() override
|
void OnInit() override
|
||||||
@@ -2378,7 +2379,7 @@ struct NetworkCompanyPasswordWindow : public Window {
|
|||||||
FALLTHROUGH;
|
FALLTHROUGH;
|
||||||
|
|
||||||
case WID_NCP_CANCEL:
|
case WID_NCP_CANCEL:
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_NCP_SAVE_AS_DEFAULT_PASSWORD:
|
case WID_NCP_SAVE_AS_DEFAULT_PASSWORD:
|
||||||
@@ -2485,18 +2486,18 @@ struct NetworkAskRelayWindow : public Window {
|
|||||||
switch (widget) {
|
switch (widget) {
|
||||||
case WID_NAR_NO:
|
case WID_NAR_NO:
|
||||||
_network_coordinator_client.ConnectFailure(this->token, 0);
|
_network_coordinator_client.ConnectFailure(this->token, 0);
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_NAR_YES_ONCE:
|
case WID_NAR_YES_ONCE:
|
||||||
_network_coordinator_client.StartTurnConnection(this->token);
|
_network_coordinator_client.StartTurnConnection(this->token);
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_NAR_YES_ALWAYS:
|
case WID_NAR_YES_ALWAYS:
|
||||||
_settings_client.network.use_relay_service = URS_ALLOW;
|
_settings_client.network.use_relay_service = URS_ALLOW;
|
||||||
_network_coordinator_client.StartTurnConnection(this->token);
|
_network_coordinator_client.StartTurnConnection(this->token);
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -184,9 +184,10 @@ struct NewGRFParametersWindow : public Window {
|
|||||||
this->InvalidateData();
|
this->InvalidateData();
|
||||||
}
|
}
|
||||||
|
|
||||||
~NewGRFParametersWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
HideDropDownMenu(this);
|
HideDropDownMenu(this);
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -449,7 +450,7 @@ struct NewGRFParametersWindow : public Window {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_NP_ACCEPT:
|
case WID_NP_ACCEPT:
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -686,7 +687,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
|||||||
this->OnInvalidateData(GOID_NEWGRF_CURRENT_LOADED);
|
this->OnInvalidateData(GOID_NEWGRF_CURRENT_LOADED);
|
||||||
}
|
}
|
||||||
|
|
||||||
~NewGRFWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
CloseWindowByClass(WC_GRF_PARAMETERS);
|
CloseWindowByClass(WC_GRF_PARAMETERS);
|
||||||
CloseWindowByClass(WC_TEXTFILE);
|
CloseWindowByClass(WC_TEXTFILE);
|
||||||
@@ -699,6 +700,11 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
|
|||||||
PostCheckNewGRFLoadWarnings();
|
PostCheckNewGRFLoadWarnings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->Window::Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
~NewGRFWindow()
|
||||||
|
{
|
||||||
/* Remove the temporary copy of grf-list used in window */
|
/* Remove the temporary copy of grf-list used in window */
|
||||||
ClearGRFConfigList(&this->actives);
|
ClearGRFConfigList(&this->actives);
|
||||||
}
|
}
|
||||||
@@ -2121,10 +2127,6 @@ struct SavePresetWindow : public Window {
|
|||||||
if (initial_text != nullptr) this->presetname_editbox.text.Assign(initial_text);
|
if (initial_text != nullptr) this->presetname_editbox.text.Assign(initial_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
~SavePresetWindow()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||||
{
|
{
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
@@ -2181,13 +2183,13 @@ struct SavePresetWindow : public Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case WID_SVP_CANCEL:
|
case WID_SVP_CANCEL:
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_SVP_SAVE: {
|
case WID_SVP_SAVE: {
|
||||||
Window *w = FindWindowById(WC_GAME_OPTIONS, WN_GAME_OPTIONS_NEWGRF_STATE);
|
Window *w = FindWindowById(WC_GAME_OPTIONS, WN_GAME_OPTIONS_NEWGRF_STATE);
|
||||||
if (w != nullptr && !StrEmpty(this->presetname_editbox.text.buf)) w->OnQueryTextFinished(this->presetname_editbox.text.buf);
|
if (w != nullptr && !StrEmpty(this->presetname_editbox.text.buf)) w->OnQueryTextFinished(this->presetname_editbox.text.buf);
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -485,7 +485,7 @@ struct NewsWindow : Window {
|
|||||||
switch (widget) {
|
switch (widget) {
|
||||||
case WID_N_CLOSEBOX:
|
case WID_N_CLOSEBOX:
|
||||||
NewsWindow::duration = 0;
|
NewsWindow::duration = 0;
|
||||||
delete this;
|
this->Close();
|
||||||
_forced_news = nullptr;
|
_forced_news = nullptr;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1054,7 +1054,7 @@ static void ShowNewsMessage(const NewsItem *ni)
|
|||||||
bool HideActiveNewsMessage() {
|
bool HideActiveNewsMessage() {
|
||||||
NewsWindow *w = (NewsWindow*)FindWindowById(WC_NEWS_WINDOW, 0);
|
NewsWindow *w = (NewsWindow*)FindWindowById(WC_NEWS_WINDOW, 0);
|
||||||
if (w == nullptr) return false;
|
if (w == nullptr) return false;
|
||||||
delete w;
|
w->Close();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -528,7 +528,7 @@ static void LoadIntroGame(bool load_newgrfs = true)
|
|||||||
{
|
{
|
||||||
UnshowCriticalError();
|
UnshowCriticalError();
|
||||||
for (Window *w : Window::IterateFromFront()) {
|
for (Window *w : Window::IterateFromFront()) {
|
||||||
delete w;
|
w->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
_game_mode = GM_MENU;
|
_game_mode = GM_MENU;
|
||||||
|
@@ -179,11 +179,12 @@ public:
|
|||||||
this->owner = v->owner;
|
this->owner = v->owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
~CargoTypeOrdersWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
if (!FocusWindowById(WC_VEHICLE_ORDERS, this->window_number)) {
|
if (!FocusWindowById(WC_VEHICLE_ORDERS, this->window_number)) {
|
||||||
MarkDirtyFocusedRoutePaths(this->vehicle);
|
MarkDirtyFocusedRoutePaths(this->vehicle);
|
||||||
}
|
}
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||||
@@ -229,11 +230,11 @@ public:
|
|||||||
virtual void OnClick(Point pt, int widget, int click_count) override
|
virtual void OnClick(Point pt, int widget, int click_count) override
|
||||||
{
|
{
|
||||||
if (!this->CheckOrderStillValid()) {
|
if (!this->CheckOrderStillValid()) {
|
||||||
delete this;
|
this->Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (widget == WID_CTO_CLOSEBTN) {
|
if (widget == WID_CTO_CLOSEBTN) {
|
||||||
delete this;
|
this->Close();
|
||||||
} else if (WID_CTO_CARGO_DROPDOWN_FIRST <= widget && widget <= WID_CTO_CARGO_DROPDOWN_LAST) {
|
} else if (WID_CTO_CARGO_DROPDOWN_FIRST <= widget && widget <= WID_CTO_CARGO_DROPDOWN_LAST) {
|
||||||
const CargoSpec *cs = _sorted_cargo_specs[widget - WID_CTO_CARGO_DROPDOWN_FIRST];
|
const CargoSpec *cs = _sorted_cargo_specs[widget - WID_CTO_CARGO_DROPDOWN_FIRST];
|
||||||
const CargoID cargo_id = cs->Index();
|
const CargoID cargo_id = cs->Index();
|
||||||
@@ -247,7 +248,7 @@ public:
|
|||||||
virtual void OnDropdownSelect(int widget, int action_type) override
|
virtual void OnDropdownSelect(int widget, int action_type) override
|
||||||
{
|
{
|
||||||
if (!this->CheckOrderStillValid()) {
|
if (!this->CheckOrderStillValid()) {
|
||||||
delete this;
|
this->Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ModifyOrderFlags mof = (this->variant == CTOWV_LOAD) ? MOF_CARGO_TYPE_LOAD : MOF_CARGO_TYPE_UNLOAD;
|
ModifyOrderFlags mof = (this->variant == CTOWV_LOAD) ? MOF_CARGO_TYPE_LOAD : MOF_CARGO_TYPE_UNLOAD;
|
||||||
@@ -301,7 +302,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnFocusLost(Window *newly_focused_window) override
|
virtual void OnFocusLost(bool closing, Window *newly_focused_window) override
|
||||||
{
|
{
|
||||||
if (HasFocusedVehicleChanged(this->window_number, newly_focused_window)) {
|
if (HasFocusedVehicleChanged(this->window_number, newly_focused_window)) {
|
||||||
MarkDirtyFocusedRoutePaths(this->vehicle);
|
MarkDirtyFocusedRoutePaths(this->vehicle);
|
||||||
@@ -316,7 +317,7 @@ public:
|
|||||||
virtual void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
virtual void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
||||||
{
|
{
|
||||||
if (!this->CheckOrderStillValid()) {
|
if (!this->CheckOrderStillValid()) {
|
||||||
delete this;
|
this->Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (gui_scope) {
|
if (gui_scope) {
|
||||||
@@ -1900,13 +1901,14 @@ public:
|
|||||||
this->OnInvalidateData(VIWD_MODIFY_ORDERS);
|
this->OnInvalidateData(VIWD_MODIFY_ORDERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
~OrdersWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
CloseWindowById(WC_VEHICLE_CARGO_TYPE_LOAD_ORDERS, this->window_number, false);
|
CloseWindowById(WC_VEHICLE_CARGO_TYPE_LOAD_ORDERS, this->window_number, false);
|
||||||
CloseWindowById(WC_VEHICLE_CARGO_TYPE_UNLOAD_ORDERS, this->window_number, false);
|
CloseWindowById(WC_VEHICLE_CARGO_TYPE_UNLOAD_ORDERS, this->window_number, false);
|
||||||
if (!FocusWindowById(WC_VEHICLE_VIEW, this->window_number)) {
|
if (!FocusWindowById(WC_VEHICLE_VIEW, this->window_number)) {
|
||||||
MarkDirtyFocusedRoutePaths(this->vehicle);
|
MarkDirtyFocusedRoutePaths(this->vehicle);
|
||||||
}
|
}
|
||||||
|
this->GeneralVehicleWindow::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||||
@@ -3575,7 +3577,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnFocusLost(Window *newly_focused_window) override
|
virtual void OnFocusLost(bool closing, Window *newly_focused_window) override
|
||||||
{
|
{
|
||||||
if (HasFocusedVehicleChanged(this->window_number, newly_focused_window)) {
|
if (HasFocusedVehicleChanged(this->window_number, newly_focused_window)) {
|
||||||
MarkDirtyFocusedRoutePaths(this->vehicle);
|
MarkDirtyFocusedRoutePaths(this->vehicle);
|
||||||
|
@@ -165,7 +165,7 @@ struct OskWindow : public Window {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_OSK_CANCEL:
|
case WID_OSK_CANCEL:
|
||||||
@@ -177,7 +177,7 @@ struct OskWindow : public Window {
|
|||||||
qs->text.Assign(this->orig_str.c_str());
|
qs->text.Assign(this->orig_str.c_str());
|
||||||
qs->text.MovePos(WKC_END);
|
qs->text.MovePos(WKC_END);
|
||||||
this->OnEditboxChanged(WID_OSK_TEXT);
|
this->OnEditboxChanged(WID_OSK_TEXT);
|
||||||
delete this;
|
this->Close();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -197,10 +197,10 @@ struct OskWindow : public Window {
|
|||||||
this->parent->SetWidgetDirty(this->text_btn);
|
this->parent->SetWidgetDirty(this->text_btn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnFocusLost(Window *newly_focused_window) override
|
void OnFocusLost(bool closing, Window *newly_focused_window) override
|
||||||
{
|
{
|
||||||
VideoDriver::GetInstance()->EditBoxLostFocus();
|
VideoDriver::GetInstance()->EditBoxLostFocus();
|
||||||
delete this;
|
if (!closing) this->Close();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -98,13 +98,14 @@ struct PlansWindow : Window {
|
|||||||
RebuildList();
|
RebuildList();
|
||||||
}
|
}
|
||||||
|
|
||||||
~PlansWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
this->list.clear();
|
this->list.clear();
|
||||||
if (_current_plan) {
|
if (_current_plan) {
|
||||||
_current_plan->SetFocus(false);
|
_current_plan->SetFocus(false);
|
||||||
_current_plan = nullptr;
|
_current_plan = nullptr;
|
||||||
}
|
}
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnClick(Point pt, int widget, int click_count) override
|
virtual void OnClick(Point pt, int widget, int click_count) override
|
||||||
|
@@ -515,12 +515,13 @@ struct BuildRailToolbarWindow : Window {
|
|||||||
if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
|
if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
~BuildRailToolbarWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
if (this->IsWidgetLowered(WID_RAT_BUILD_STATION)) SetViewportCatchmentStation(nullptr, true);
|
if (this->IsWidgetLowered(WID_RAT_BUILD_STATION)) SetViewportCatchmentStation(nullptr, true);
|
||||||
if (this->IsWidgetLowered(WID_RAT_BUILD_WAYPOINT)) SetViewportCatchmentWaypoint(nullptr, true);
|
if (this->IsWidgetLowered(WID_RAT_BUILD_WAYPOINT)) SetViewportCatchmentWaypoint(nullptr, true);
|
||||||
if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false);
|
if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false);
|
||||||
CloseWindowById(WC_SELECT_STATION, 0);
|
CloseWindowById(WC_SELECT_STATION, 0);
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1249,9 +1250,10 @@ public:
|
|||||||
this->InvalidateData();
|
this->InvalidateData();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~BuildRailStationWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
CloseWindowById(WC_SELECT_STATION, 0);
|
CloseWindowById(WC_SELECT_STATION, 0);
|
||||||
|
this->PickerWindowBase::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sort station classes by StationClassID. */
|
/** Sort station classes by StationClassID. */
|
||||||
@@ -1979,11 +1981,12 @@ public:
|
|||||||
this->OnInvalidateData();
|
this->OnInvalidateData();
|
||||||
}
|
}
|
||||||
|
|
||||||
~BuildSignalWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
_convert_signal_button = false;
|
_convert_signal_button = false;
|
||||||
_trace_restrict_button = false;
|
_trace_restrict_button = false;
|
||||||
_program_signal_button = false;
|
_program_signal_button = false;
|
||||||
|
this->PickerWindowBase::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnInit() override
|
void OnInit() override
|
||||||
@@ -2516,9 +2519,10 @@ struct BuildRailWaypointWindow : PickerWindowBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~BuildRailWaypointWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
CloseWindowById(WC_SELECT_STATION, 0);
|
CloseWindowById(WC_SELECT_STATION, 0);
|
||||||
|
this->PickerWindowBase::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||||
|
@@ -377,12 +377,13 @@ struct BuildRoadToolbarWindow : Window {
|
|||||||
if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
|
if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
~BuildRoadToolbarWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
if (_game_mode == GM_NORMAL && (this->IsWidgetLowered(WID_ROT_BUS_STATION) || this->IsWidgetLowered(WID_ROT_TRUCK_STATION))) SetViewportCatchmentStation(nullptr, true);
|
if (_game_mode == GM_NORMAL && (this->IsWidgetLowered(WID_ROT_BUS_STATION) || this->IsWidgetLowered(WID_ROT_TRUCK_STATION))) SetViewportCatchmentStation(nullptr, true);
|
||||||
if (_game_mode == GM_NORMAL && this->IsWidgetLowered(WID_ROT_BUILD_WAYPOINT)) SetViewportCatchmentWaypoint(nullptr, true);
|
if (_game_mode == GM_NORMAL && this->IsWidgetLowered(WID_ROT_BUILD_WAYPOINT)) SetViewportCatchmentWaypoint(nullptr, true);
|
||||||
if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false);
|
if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false);
|
||||||
CloseWindowById(WC_SELECT_STATION, 0);
|
CloseWindowById(WC_SELECT_STATION, 0);
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1377,9 +1378,10 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~BuildRoadStationWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
CloseWindowById(WC_SELECT_STATION, 0);
|
CloseWindowById(WC_SELECT_STATION, 0);
|
||||||
|
this->PickerWindowBase::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sort classes by RoadStopClassID. */
|
/** Sort classes by RoadStopClassID. */
|
||||||
@@ -2035,9 +2037,10 @@ struct BuildRoadWaypointWindow : PickerWindowBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~BuildRoadWaypointWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
CloseWindowById(WC_SELECT_STATION, 0);
|
CloseWindowById(WC_SELECT_STATION, 0);
|
||||||
|
this->PickerWindowBase::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||||
@@ -2395,7 +2398,7 @@ static BuildRoadToolbarWindow *GetRoadToolbarWindowForRoadStop(const RoadStopSpe
|
|||||||
if (w != nullptr) {
|
if (w != nullptr) {
|
||||||
if (spec != nullptr && ((HasBit(spec->flags, RSF_BUILD_MENU_ROAD_ONLY) && !RoadTypeIsRoad(_cur_roadtype)) ||
|
if (spec != nullptr && ((HasBit(spec->flags, RSF_BUILD_MENU_ROAD_ONLY) && !RoadTypeIsRoad(_cur_roadtype)) ||
|
||||||
(HasBit(spec->flags, RSF_BUILD_MENU_TRAM_ONLY) && !RoadTypeIsTram(_cur_roadtype)))) {
|
(HasBit(spec->flags, RSF_BUILD_MENU_TRAM_ONLY) && !RoadTypeIsTram(_cur_roadtype)))) {
|
||||||
delete w;
|
w->Close();
|
||||||
} else {
|
} else {
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
@@ -210,11 +210,12 @@ struct SchdispatchWindow : GeneralVehicleWindow {
|
|||||||
this->AutoSelectSchedule();
|
this->AutoSelectSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
~SchdispatchWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
if (!FocusWindowById(WC_VEHICLE_VIEW, this->window_number)) {
|
if (!FocusWindowById(WC_VEHICLE_VIEW, this->window_number)) {
|
||||||
MarkDirtyFocusedRoutePaths(this->vehicle);
|
MarkDirtyFocusedRoutePaths(this->vehicle);
|
||||||
}
|
}
|
||||||
|
this->GeneralVehicleWindow::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint base_width;
|
uint base_width;
|
||||||
@@ -1169,7 +1170,7 @@ struct ScheduledDispatchAddSlotsWindow : Window {
|
|||||||
|
|
||||||
case WID_SCHDISPATCH_ADD_SLOT_ADD_BUTTON:
|
case WID_SCHDISPATCH_ADD_SLOT_ADD_BUTTON:
|
||||||
static_cast<SchdispatchWindow *>(this->parent)->AddMultipleDepartureSlots(this->start, this->step, this->end);
|
static_cast<SchdispatchWindow *>(this->parent)->AddMultipleDepartureSlots(this->start, this->step, this->end);
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -201,7 +201,7 @@ struct ScriptListWindow : public Window {
|
|||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
if (click_count > 1) {
|
if (click_count > 1) {
|
||||||
this->ChangeScript();
|
this->ChangeScript();
|
||||||
delete this;
|
this->Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -209,12 +209,12 @@ struct ScriptListWindow : public Window {
|
|||||||
|
|
||||||
case WID_SCRL_ACCEPT: {
|
case WID_SCRL_ACCEPT: {
|
||||||
this->ChangeScript();
|
this->ChangeScript();
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WID_SCRL_CANCEL:
|
case WID_SCRL_CANCEL:
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -232,7 +232,7 @@ struct ScriptListWindow : public Window {
|
|||||||
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
||||||
{
|
{
|
||||||
if (_game_mode == GM_NORMAL && Company::IsValidID(this->slot)) {
|
if (_game_mode == GM_NORMAL && Company::IsValidID(this->slot)) {
|
||||||
delete this;
|
this->Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,9 +325,10 @@ struct ScriptSettingsWindow : public Window {
|
|||||||
this->RebuildVisibleSettings();
|
this->RebuildVisibleSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
~ScriptSettingsWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
HideDropDownMenu(this);
|
HideDropDownMenu(this);
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -520,7 +521,7 @@ struct ScriptSettingsWindow : public Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case WID_SCRS_ACCEPT:
|
case WID_SCRS_ACCEPT:
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_SCRS_RESET:
|
case WID_SCRS_RESET:
|
||||||
@@ -660,7 +661,7 @@ struct ScriptTextfileWindow : public TextfileWindow {
|
|||||||
{
|
{
|
||||||
const char *textfile = GetConfig(slot)->GetTextfile(file_type, slot);
|
const char *textfile = GetConfig(slot)->GetTextfile(file_type, slot);
|
||||||
if (textfile == nullptr) {
|
if (textfile == nullptr) {
|
||||||
delete this;
|
this->Close();
|
||||||
} else {
|
} else {
|
||||||
this->LoadTextfile(textfile, (slot == OWNER_DEITY) ? GAME_DIR : AI_DIR);
|
this->LoadTextfile(textfile, (slot == OWNER_DEITY) ? GAME_DIR : AI_DIR);
|
||||||
}
|
}
|
||||||
|
@@ -197,11 +197,12 @@ struct GameOptionsWindow : Window {
|
|||||||
if constexpr (!NetworkSurveyHandler::IsSurveyPossible()) this->GetWidget<NWidgetStacked>(WID_GO_SURVEY_SEL)->SetDisplayedPlane(SZSP_NONE);
|
if constexpr (!NetworkSurveyHandler::IsSurveyPossible()) this->GetWidget<NWidgetStacked>(WID_GO_SURVEY_SEL)->SetDisplayedPlane(SZSP_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
~GameOptionsWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
CloseWindowById(WC_CUSTOM_CURRENCY, 0);
|
CloseWindowById(WC_CUSTOM_CURRENCY, 0);
|
||||||
CloseWindowByClass(WC_TEXTFILE);
|
CloseWindowByClass(WC_TEXTFILE);
|
||||||
if (this->reload) _switch_mode = SM_MENU;
|
if (this->reload) _switch_mode = SM_MENU;
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -527,7 +527,7 @@ struct SignWindow : Window, SignList {
|
|||||||
FALLTHROUGH;
|
FALLTHROUGH;
|
||||||
|
|
||||||
case WID_QES_CANCEL:
|
case WID_QES_CANCEL:
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -596,5 +596,5 @@ void DeleteRenameSignWindow(SignID sign)
|
|||||||
{
|
{
|
||||||
SignWindow *w = dynamic_cast<SignWindow *>(FindWindowById(WC_QUERY_STRING, WN_QUERY_STRING_SIGN));
|
SignWindow *w = dynamic_cast<SignWindow *>(FindWindowById(WC_QUERY_STRING, WN_QUERY_STRING_SIGN));
|
||||||
|
|
||||||
if (w != nullptr && w->cur_sign == sign) delete w;
|
if (w != nullptr && w->cur_sign == sign) w->Close();
|
||||||
}
|
}
|
||||||
|
@@ -1086,7 +1086,12 @@ SmallMapWindow::SmallMapWindow(WindowDesc *desc, int window_number) : Window(des
|
|||||||
SmallMapWindow::~SmallMapWindow()
|
SmallMapWindow::~SmallMapWindow()
|
||||||
{
|
{
|
||||||
delete this->overlay;
|
delete this->overlay;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* virtual */ void SmallMapWindow::Close()
|
||||||
|
{
|
||||||
this->BreakIndustryChainLink();
|
this->BreakIndustryChainLink();
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -207,6 +207,7 @@ public:
|
|||||||
void SmallMapCenterOnCurrentPos();
|
void SmallMapCenterOnCurrentPos();
|
||||||
Point GetStationMiddle(const Station *st) const;
|
Point GetStationMiddle(const Station *st) const;
|
||||||
|
|
||||||
|
void Close() override;
|
||||||
void SetStringParameters(int widget) const override;
|
void SetStringParameters(int widget) const override;
|
||||||
void OnInit() override;
|
void OnInit() override;
|
||||||
void OnPaint() override;
|
void OnPaint() override;
|
||||||
|
@@ -480,9 +480,10 @@ public:
|
|||||||
this->GetWidget<NWidgetCore>(WID_STL_SORTDROPBTN)->widget_data = this->sorter_names[this->stations.SortType()];
|
this->GetWidget<NWidgetCore>(WID_STL_SORTDROPBTN)->widget_data = this->sorter_names[this->stations.SortType()];
|
||||||
}
|
}
|
||||||
|
|
||||||
~CompanyStationsWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
this->last_sorting = this->stations.GetListing();
|
this->last_sorting = this->stations.GetListing();
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||||
@@ -1435,7 +1436,7 @@ struct StationViewWindow : public Window {
|
|||||||
ZoningStationWindowOpenClose(Station::Get(window_number));
|
ZoningStationWindowOpenClose(Station::Get(window_number));
|
||||||
}
|
}
|
||||||
|
|
||||||
~StationViewWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
ZoningStationWindowOpenClose(Station::Get(window_number));
|
ZoningStationWindowOpenClose(Station::Get(window_number));
|
||||||
CloseWindowById(WC_TRAINS_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_TRAIN, this->owner, this->window_number).Pack(), false);
|
CloseWindowById(WC_TRAINS_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_TRAIN, this->owner, this->window_number).Pack(), false);
|
||||||
@@ -1444,6 +1445,7 @@ struct StationViewWindow : public Window {
|
|||||||
CloseWindowById(WC_AIRCRAFT_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_AIRCRAFT, this->owner, this->window_number).Pack(), false);
|
CloseWindowById(WC_AIRCRAFT_LIST, VehicleListIdentifier(VL_STATION_LIST, VEH_AIRCRAFT, this->owner, this->window_number).Pack(), false);
|
||||||
|
|
||||||
SetViewportCatchmentStation(Station::Get(this->window_number), false);
|
SetViewportCatchmentStation(Station::Get(this->window_number), false);
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnInit() override
|
void OnInit() override
|
||||||
@@ -2545,11 +2547,12 @@ struct SelectStationWindow : Window {
|
|||||||
_thd.freeze = true;
|
_thd.freeze = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
~SelectStationWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
SetViewportCatchmentStation(nullptr, true);
|
SetViewportCatchmentStation(nullptr, true);
|
||||||
|
|
||||||
_thd.freeze = false;
|
_thd.freeze = false;
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||||
@@ -2684,7 +2687,7 @@ static bool StationJoinerNeeded(const CommandContainer &cmd, TileArea ta)
|
|||||||
Window *selection_window = FindWindowById(WC_SELECT_STATION, 0);
|
Window *selection_window = FindWindowById(WC_SELECT_STATION, 0);
|
||||||
if (selection_window != nullptr) {
|
if (selection_window != nullptr) {
|
||||||
/* Abort current distant-join and start new one */
|
/* Abort current distant-join and start new one */
|
||||||
delete selection_window;
|
selection_window->Close();
|
||||||
UpdateTileSelection();
|
UpdateTileSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3097,7 +3100,7 @@ public:
|
|||||||
void OnMouseLoop() override
|
void OnMouseLoop() override
|
||||||
{
|
{
|
||||||
if (!_cursor.in_window || !(_settings_client.gui.hover_delay_ms == 0 ? _right_button_down : _mouse_hovering)) {
|
if (!_cursor.in_window || !(_settings_client.gui.hover_delay_ms == 0 ? _right_button_down : _mouse_hovering)) {
|
||||||
delete this;
|
this->Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -166,7 +166,7 @@ public:
|
|||||||
UpdateButtonState();
|
UpdateButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
~TemplateCreateWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
if (virtual_train != nullptr) {
|
if (virtual_train != nullptr) {
|
||||||
DoCommandP(0, virtual_train->index, 0, CMD_DELETE_VIRTUAL_TRAIN);
|
DoCommandP(0, virtual_train->index, 0, CMD_DELETE_VIRTUAL_TRAIN);
|
||||||
@@ -177,6 +177,7 @@ public:
|
|||||||
*create_window_open = false;
|
*create_window_open = false;
|
||||||
CloseWindowById(WC_BUILD_VIRTUAL_TRAIN, this->window_number);
|
CloseWindowById(WC_BUILD_VIRTUAL_TRAIN, this->window_number);
|
||||||
InvalidateWindowClassesData(WC_TEMPLATEGUI_MAIN);
|
InvalidateWindowClassesData(WC_TEMPLATEGUI_MAIN);
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetVirtualTrain(Train* const train)
|
void SetVirtualTrain(Train* const train)
|
||||||
@@ -208,7 +209,7 @@ public:
|
|||||||
|
|
||||||
if (this->template_index != INVALID_VEHICLE) {
|
if (this->template_index != INVALID_VEHICLE) {
|
||||||
if (TemplateVehicle::GetIfValid(this->template_index) == nullptr) {
|
if (TemplateVehicle::GetIfValid(this->template_index) == nullptr) {
|
||||||
delete this;
|
this->Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -244,11 +245,11 @@ public:
|
|||||||
} else if (this->template_index != INVALID_VEHICLE) {
|
} else if (this->template_index != INVALID_VEHICLE) {
|
||||||
DoCommandP(0, this->template_index, 0, CMD_DELETE_TEMPLATE_VEHICLE);
|
DoCommandP(0, this->template_index, 0, CMD_DELETE_TEMPLATE_VEHICLE);
|
||||||
}
|
}
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TCW_CANCEL: {
|
case TCW_CANCEL: {
|
||||||
delete this;
|
this->Close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TCW_REFIT: {
|
case TCW_REFIT: {
|
||||||
|
@@ -255,8 +255,9 @@ public:
|
|||||||
this->BuildTemplateGuiList();
|
this->BuildTemplateGuiList();
|
||||||
}
|
}
|
||||||
|
|
||||||
~TemplateReplaceWindow() {
|
void Close() override {
|
||||||
CloseWindowById(WC_CREATE_TEMPLATE, this->window_number);
|
CloseWindowById(WC_CREATE_TEMPLATE, this->window_number);
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||||
|
@@ -213,10 +213,6 @@ struct TerraformToolbarWindow : Window {
|
|||||||
this->last_user_action = WIDGET_LIST_END;
|
this->last_user_action = WIDGET_LIST_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
~TerraformToolbarWindow()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnInit() override
|
void OnInit() override
|
||||||
{
|
{
|
||||||
/* Don't show the place object button when there are no objects to place. */
|
/* Don't show the place object button when there are no objects to place. */
|
||||||
|
@@ -370,11 +370,12 @@ struct TimetableWindow : GeneralVehicleWindow {
|
|||||||
this->owner = this->vehicle->owner;
|
this->owner = this->vehicle->owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
~TimetableWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
if (!FocusWindowById(WC_VEHICLE_VIEW, this->window_number)) {
|
if (!FocusWindowById(WC_VEHICLE_VIEW, this->window_number)) {
|
||||||
MarkDirtyFocusedRoutePaths(this->vehicle);
|
MarkDirtyFocusedRoutePaths(this->vehicle);
|
||||||
}
|
}
|
||||||
|
this->GeneralVehicleWindow::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1165,7 +1166,7 @@ struct TimetableWindow : GeneralVehicleWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnFocusLost(Window *newly_focused_window) override
|
virtual void OnFocusLost(bool closing, Window *newly_focused_window) override
|
||||||
{
|
{
|
||||||
if (HasFocusedVehicleChanged(this->window_number, newly_focused_window)) {
|
if (HasFocusedVehicleChanged(this->window_number, newly_focused_window)) {
|
||||||
MarkDirtyFocusedRoutePaths(this->vehicle);
|
MarkDirtyFocusedRoutePaths(this->vehicle);
|
||||||
|
@@ -534,9 +534,10 @@ public:
|
|||||||
nvp->InitializeViewport(this, this->town->xy, ScaleZoomGUI(ZOOM_LVL_TOWN));
|
nvp->InitializeViewport(this, this->town->xy, ScaleZoomGUI(ZOOM_LVL_TOWN));
|
||||||
}
|
}
|
||||||
|
|
||||||
~TownViewWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
SetViewportCatchmentTown(Town::Get(this->window_number), false);
|
SetViewportCatchmentTown(Town::Get(this->window_number), false);
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetStringParameters(int widget) const override
|
void SetStringParameters(int widget) const override
|
||||||
@@ -2116,7 +2117,7 @@ struct SelectTownWindow : Window {
|
|||||||
DoCommandP(&this->cmd);
|
DoCommandP(&this->cmd);
|
||||||
|
|
||||||
/* Close the window */
|
/* Close the window */
|
||||||
delete this;
|
this->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnResize()
|
virtual void OnResize()
|
||||||
|
@@ -1780,7 +1780,7 @@ public:
|
|||||||
this->ReloadProgramme();
|
this->ReloadProgramme();
|
||||||
}
|
}
|
||||||
|
|
||||||
~TraceRestrictWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
extern const TraceRestrictProgram *_viewport_highlight_tracerestrict_program;
|
extern const TraceRestrictProgram *_viewport_highlight_tracerestrict_program;
|
||||||
if (_viewport_highlight_tracerestrict_program != nullptr) {
|
if (_viewport_highlight_tracerestrict_program != nullptr) {
|
||||||
@@ -1789,6 +1789,7 @@ public:
|
|||||||
SetViewportCatchmentTraceRestrictProgram(prog, false);
|
SetViewportCatchmentTraceRestrictProgram(prog, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnClick(Point pt, int widget, int click_count) override
|
virtual void OnClick(Point pt, int widget, int click_count) override
|
||||||
@@ -3844,9 +3845,10 @@ public:
|
|||||||
this->owner = vli.company;
|
this->owner = vli.company;
|
||||||
}
|
}
|
||||||
|
|
||||||
~TraceRestrictSlotWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
*this->sorting = this->vehgroups.GetListing();
|
*this->sorting = this->vehgroups.GetListing();
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||||
|
@@ -906,7 +906,7 @@ struct RefitWindow : public Window {
|
|||||||
this->SetWidgetDisabledState(WID_VR_REFIT, this->sel[0] < 0);
|
this->SetWidgetDisabledState(WID_VR_REFIT, this->sel[0] < 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
~RefitWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
if (this->window_number != INVALID_VEHICLE) {
|
if (this->window_number != INVALID_VEHICLE) {
|
||||||
if (!FocusWindowById(WC_VEHICLE_VIEW, this->window_number)) {
|
if (!FocusWindowById(WC_VEHICLE_VIEW, this->window_number)) {
|
||||||
@@ -916,6 +916,7 @@ struct RefitWindow : public Window {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnFocus(Window *previously_focused_window) override
|
void OnFocus(Window *previously_focused_window) override
|
||||||
@@ -928,7 +929,7 @@ struct RefitWindow : public Window {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnFocusLost(Window *newly_focused_window) override
|
void OnFocusLost(bool closing, Window *newly_focused_window) override
|
||||||
{
|
{
|
||||||
if (HasFocusedVehicleChanged(this->window_number, newly_focused_window)) {
|
if (HasFocusedVehicleChanged(this->window_number, newly_focused_window)) {
|
||||||
if (this->window_number != INVALID_VEHICLE) {
|
if (this->window_number != INVALID_VEHICLE) {
|
||||||
@@ -1350,10 +1351,10 @@ struct RefitWindow : public Window {
|
|||||||
bool delete_window = this->selected_vehicle == v->index && this->num_vehicles == UINT8_MAX;
|
bool delete_window = this->selected_vehicle == v->index && this->num_vehicles == UINT8_MAX;
|
||||||
if (DoCommandP(v->tile, this->selected_vehicle, this->cargo->cargo | this->cargo->subtype << 8 | this->num_vehicles << 16 | this->is_virtual_train << 31,
|
if (DoCommandP(v->tile, this->selected_vehicle, this->cargo->cargo | this->cargo->subtype << 8 | this->num_vehicles << 16 | this->is_virtual_train << 31,
|
||||||
GetCmdRefitVeh(v)) && delete_window) {
|
GetCmdRefitVeh(v)) && delete_window) {
|
||||||
delete this;
|
this->Close();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (DoCommandP(v->tile, v->index, this->cargo->cargo | this->cargo->subtype << 8 | this->order << 16, CMD_ORDER_REFIT)) delete this;
|
if (DoCommandP(v->tile, v->index, this->cargo->cargo | this->cargo->subtype << 8 | this->order << 16, CMD_ORDER_REFIT)) this->Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -2262,10 +2263,11 @@ public:
|
|||||||
if (this->vli.company != OWNER_NONE) this->owner = this->vli.company;
|
if (this->vli.company != OWNER_NONE) this->owner = this->vli.company;
|
||||||
}
|
}
|
||||||
|
|
||||||
~VehicleListWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
*this->sorting = this->vehgroups.GetListing();
|
*this->sorting = this->vehgroups.GetListing();
|
||||||
this->RefreshRouteOverlay();
|
this->RefreshRouteOverlay();
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnFocus(Window *previously_focused_window) override
|
virtual void OnFocus(Window *previously_focused_window) override
|
||||||
@@ -2273,7 +2275,7 @@ public:
|
|||||||
this->RefreshRouteOverlay();
|
this->RefreshRouteOverlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnFocusLost(Window *newly_focused_window) override
|
virtual void OnFocusLost(bool closing, Window *newly_focused_window) override
|
||||||
{
|
{
|
||||||
this->RefreshRouteOverlay();
|
this->RefreshRouteOverlay();
|
||||||
}
|
}
|
||||||
@@ -2671,7 +2673,7 @@ public:
|
|||||||
/* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
|
/* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
|
||||||
this->vehgroups.ForceRebuild();
|
this->vehgroups.ForceRebuild();
|
||||||
if (this->vli.type == VL_SHARED_ORDERS && !_settings_client.gui.enable_single_veh_shared_order_gui && this->vehicles.size() == 1) {
|
if (this->vli.type == VL_SHARED_ORDERS && !_settings_client.gui.enable_single_veh_shared_order_gui && this->vehicles.size() == 1) {
|
||||||
delete this;
|
this->Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -2885,7 +2887,7 @@ struct VehicleDetailsWindow : Window {
|
|||||||
if (v->type == VEH_TRAIN && _shift_pressed) this->tab = TDW_TAB_TOTALS;
|
if (v->type == VEH_TRAIN && _shift_pressed) this->tab = TDW_TAB_TOTALS;
|
||||||
}
|
}
|
||||||
|
|
||||||
~VehicleDetailsWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
if (this->window_number != INVALID_VEHICLE) {
|
if (this->window_number != INVALID_VEHICLE) {
|
||||||
if (!FocusWindowById(WC_VEHICLE_VIEW, this->window_number)) {
|
if (!FocusWindowById(WC_VEHICLE_VIEW, this->window_number)) {
|
||||||
@@ -2895,6 +2897,7 @@ struct VehicleDetailsWindow : Window {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3401,7 +3404,7 @@ struct VehicleDetailsWindow : Window {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnFocusLost(Window *newly_focused_window) override
|
virtual void OnFocusLost(bool closing, Window *newly_focused_window) override
|
||||||
{
|
{
|
||||||
if (HasFocusedVehicleChanged(this->window_number, newly_focused_window)) {
|
if (HasFocusedVehicleChanged(this->window_number, newly_focused_window)) {
|
||||||
if (this->window_number != INVALID_VEHICLE) {
|
if (this->window_number != INVALID_VEHICLE) {
|
||||||
@@ -3676,7 +3679,7 @@ public:
|
|||||||
this->UpdateButtonStatus();
|
this->UpdateButtonStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
~VehicleViewWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
if (this->window_number != INVALID_VEHICLE) {
|
if (this->window_number != INVALID_VEHICLE) {
|
||||||
const Vehicle *v = Vehicle::Get(this->window_number);
|
const Vehicle *v = Vehicle::Get(this->window_number);
|
||||||
@@ -3690,6 +3693,8 @@ public:
|
|||||||
if (this->fixed_route_overlay_active) {
|
if (this->fixed_route_overlay_active) {
|
||||||
RemoveFixedViewportRoutePath(this->window_number);
|
RemoveFixedViewportRoutePath(this->window_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnFocus(Window *previously_focused_window) override
|
virtual void OnFocus(Window *previously_focused_window) override
|
||||||
@@ -3702,7 +3707,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnFocusLost(Window *newly_focused_window) override
|
virtual void OnFocusLost(bool closing, Window *newly_focused_window) override
|
||||||
{
|
{
|
||||||
if (HasFocusedVehicleChanged(this->window_number, newly_focused_window)) {
|
if (HasFocusedVehicleChanged(this->window_number, newly_focused_window)) {
|
||||||
if (this->window_number != INVALID_VEHICLE) {
|
if (this->window_number != INVALID_VEHICLE) {
|
||||||
|
@@ -106,11 +106,11 @@ public:
|
|||||||
this->OnInvalidateData(0);
|
this->OnInvalidateData(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
~WaypointWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
CloseWindowById(GetWindowClassForVehicleType(this->vt), VehicleListIdentifier(VL_STATION_LIST, this->vt, this->owner, this->window_number).Pack(), false);
|
CloseWindowById(GetWindowClassForVehicleType(this->vt), VehicleListIdentifier(VL_STATION_LIST, this->vt, this->owner, this->window_number).Pack(), false);
|
||||||
|
|
||||||
SetViewportCatchmentWaypoint(Waypoint::Get(this->window_number), false);
|
SetViewportCatchmentWaypoint(Waypoint::Get(this->window_number), false);
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetStringParameters(int widget) const override
|
void SetStringParameters(int widget) const override
|
||||||
|
@@ -179,12 +179,12 @@ struct DropdownWindow : Window {
|
|||||||
this->scrolling_timer = GUITimer(MILLISECONDS_PER_TICK);
|
this->scrolling_timer = GUITimer(MILLISECONDS_PER_TICK);
|
||||||
}
|
}
|
||||||
|
|
||||||
~DropdownWindow()
|
void Close() override
|
||||||
{
|
{
|
||||||
/* Make the dropdown "invisible", so it doesn't affect new window placement.
|
/* Make the dropdown "invisible", so it doesn't affect new window placement.
|
||||||
* Also mark it dirty in case the callback deals with the screen. (e.g. screenshots). */
|
* Also mark it dirty in case the callback deals with the screen. (e.g. screenshots). */
|
||||||
this->window_class = WC_INVALID;
|
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
|
this->Window::Close();
|
||||||
|
|
||||||
Window *w2 = FindWindowById(this->parent_wnd_class, this->parent_wnd_num);
|
Window *w2 = FindWindowById(this->parent_wnd_class, this->parent_wnd_num);
|
||||||
if (w2 != nullptr) {
|
if (w2 != nullptr) {
|
||||||
@@ -291,7 +291,7 @@ struct DropdownWindow : Window {
|
|||||||
{
|
{
|
||||||
Window *w2 = FindWindowById(this->parent_wnd_class, this->parent_wnd_num);
|
Window *w2 = FindWindowById(this->parent_wnd_class, this->parent_wnd_num);
|
||||||
if (w2 == nullptr) {
|
if (w2 == nullptr) {
|
||||||
delete this;
|
this->Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,7 +302,7 @@ struct DropdownWindow : Window {
|
|||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
|
|
||||||
w2->OnDropdownSelect(this->parent_button, this->selected_index);
|
w2->OnDropdownSelect(this->parent_button, this->selected_index);
|
||||||
delete this;
|
this->Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,7 +312,7 @@ struct DropdownWindow : Window {
|
|||||||
if (!_left_button_clicked) {
|
if (!_left_button_clicked) {
|
||||||
this->drag_mode = false;
|
this->drag_mode = false;
|
||||||
if (!this->GetDropDownItem(item)) {
|
if (!this->GetDropDownItem(item)) {
|
||||||
if (this->instant_close) delete this;
|
if (this->instant_close) this->Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->click_delay = 2;
|
this->click_delay = 2;
|
||||||
@@ -345,11 +345,11 @@ struct DropdownWindow : Window {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnFocusLost(Window *newly_focused_window)
|
virtual void OnFocusLost(bool closing, Window *newly_focused_window)
|
||||||
{
|
{
|
||||||
if (this->sync_parent_focus & DDSF_LOST_FOCUS) {
|
if (this->sync_parent_focus & DDSF_LOST_FOCUS) {
|
||||||
Window *parent = FindWindowById(this->parent_wnd_class, this->parent_wnd_num);
|
Window *parent = FindWindowById(this->parent_wnd_class, this->parent_wnd_num);
|
||||||
if (parent) parent->OnFocusLost(newly_focused_window);
|
if (parent) parent->OnFocusLost(false, newly_focused_window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
161
src/window.cpp
161
src/window.cpp
@@ -58,11 +58,11 @@ static Window *_mouseover_last_w = nullptr; ///< Window of the last OnMouseOver
|
|||||||
static Window *_last_scroll_window = nullptr; ///< Window of the last scroll event.
|
static Window *_last_scroll_window = nullptr; ///< Window of the last scroll event.
|
||||||
|
|
||||||
/** List of windows opened at the screen sorted from the front. */
|
/** List of windows opened at the screen sorted from the front. */
|
||||||
WindowBase *_z_front_window = nullptr;
|
Window *_z_front_window = nullptr;
|
||||||
/** List of windows opened at the screen sorted from the back. */
|
/** List of windows opened at the screen sorted from the back. */
|
||||||
WindowBase *_z_back_window = nullptr;
|
Window *_z_back_window = nullptr;
|
||||||
/** List of windows in an arbitrary order, that is not instantaneously changed by bringing windows to the front. */
|
/** List of windows in an arbitrary order, that is not instantaneously changed by bringing windows to the front. */
|
||||||
WindowBase *_first_window = nullptr;
|
Window *_first_window = nullptr;
|
||||||
|
|
||||||
/** If false, highlight is white, otherwise the by the widget defined colour. */
|
/** If false, highlight is white, otherwise the by the widget defined colour. */
|
||||||
bool _window_highlight_colour = false;
|
bool _window_highlight_colour = false;
|
||||||
@@ -470,7 +470,7 @@ void SetFocusedWindow(Window *w)
|
|||||||
_focused_window = w;
|
_focused_window = w;
|
||||||
|
|
||||||
/* So we can inform it that it lost focus */
|
/* So we can inform it that it lost focus */
|
||||||
if (old_focused != nullptr) old_focused->OnFocusLost(w);
|
if (old_focused != nullptr) old_focused->OnFocusLost(false, w);
|
||||||
if (_focused_window != nullptr) _focused_window->OnFocus(old_focused);
|
if (_focused_window != nullptr) _focused_window->OnFocus(old_focused);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,7 +561,7 @@ void Window::OnFocus(Window *previously_focused_window)
|
|||||||
/**
|
/**
|
||||||
* Called when window loses focus
|
* Called when window loses focus
|
||||||
*/
|
*/
|
||||||
void Window::OnFocusLost(Window *newly_focused_window)
|
void Window::OnFocusLost(bool closing, Window *newly_focused_window)
|
||||||
{
|
{
|
||||||
if (this->nested_focus != nullptr && this->nested_focus->type == WWT_EDITBOX) VideoDriver::GetInstance()->EditBoxLostFocus();
|
if (this->nested_focus != nullptr && this->nested_focus->type == WWT_EDITBOX) VideoDriver::GetInstance()->EditBoxLostFocus();
|
||||||
}
|
}
|
||||||
@@ -747,7 +747,7 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, int click_count)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case WWT_CLOSEBOX: // 'X'
|
case WWT_CLOSEBOX: // 'X'
|
||||||
delete w;
|
w->Close();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case WWT_CAPTION: // 'Title bar'
|
case WWT_CAPTION: // 'Title bar'
|
||||||
@@ -835,7 +835,7 @@ static void DispatchRightClickEvent(Window *w, int x, int y)
|
|||||||
|
|
||||||
/* Right-click close is enabled and there is a closebox */
|
/* Right-click close is enabled and there is a closebox */
|
||||||
if (_settings_client.gui.right_mouse_wnd_close && (w->window_desc->flags & WDF_NO_CLOSE) == 0) {
|
if (_settings_client.gui.right_mouse_wnd_close && (w->window_desc->flags & WDF_NO_CLOSE) == 0) {
|
||||||
delete w;
|
w->Close();
|
||||||
} else if (_settings_client.gui.hover_delay_ms == 0 && !w->OnTooltip(pt, wid->index, TCC_RIGHT_CLICK) && wid->tool_tip != 0) {
|
} else if (_settings_client.gui.hover_delay_ms == 0 && !w->OnTooltip(pt, wid->index, TCC_RIGHT_CLICK) && wid->tool_tip != 0) {
|
||||||
GuiShowTooltips(w, wid->tool_tip, 0, nullptr, TCC_RIGHT_CLICK);
|
GuiShowTooltips(w, wid->tool_tip, 0, nullptr, TCC_RIGHT_CLICK);
|
||||||
}
|
}
|
||||||
@@ -1120,15 +1120,15 @@ void Window::CloseChildWindows(WindowClass wc) const
|
|||||||
{
|
{
|
||||||
Window *child = FindChildWindow(this, wc);
|
Window *child = FindChildWindow(this, wc);
|
||||||
while (child != nullptr) {
|
while (child != nullptr) {
|
||||||
delete child;
|
child->Close();
|
||||||
child = FindChildWindow(this, wc);
|
child = FindChildWindow(this, wc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove window and all its child windows from the window stack.
|
* Hide the window and all its child windows, and mark them for a later deletion.
|
||||||
*/
|
*/
|
||||||
Window::~Window()
|
void Window::Close()
|
||||||
{
|
{
|
||||||
if (_thd.window_class == this->window_class &&
|
if (_thd.window_class == this->window_class &&
|
||||||
_thd.window_number == this->window_number) {
|
_thd.window_number == this->window_number) {
|
||||||
@@ -1147,33 +1147,27 @@ Window::~Window()
|
|||||||
/* Make sure we don't try to access this window as the focused window when it doesn't exist anymore. */
|
/* Make sure we don't try to access this window as the focused window when it doesn't exist anymore. */
|
||||||
if (_focused_window == this) {
|
if (_focused_window == this) {
|
||||||
_focused_window = nullptr;
|
_focused_window = nullptr;
|
||||||
this->OnFocusLost(nullptr);
|
this->OnFocusLost(true, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->CloseChildWindows();
|
this->CloseChildWindows();
|
||||||
|
|
||||||
if (this->viewport != nullptr) DeleteWindowViewport(this);
|
|
||||||
|
|
||||||
this->SetDirtyAsBlocks();
|
this->SetDirtyAsBlocks();
|
||||||
|
|
||||||
|
this->window_class = WC_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove window and all its child windows from the window stack.
|
||||||
|
*/
|
||||||
|
Window::~Window()
|
||||||
|
{
|
||||||
|
assert(this->window_class == WC_INVALID);
|
||||||
|
|
||||||
|
if (this->viewport != nullptr) DeleteWindowViewport(this);
|
||||||
|
|
||||||
free(this->nested_array); // Contents is released through deletion of #nested_root.
|
free(this->nested_array); // Contents is released through deletion of #nested_root.
|
||||||
delete this->nested_root;
|
delete this->nested_root;
|
||||||
|
|
||||||
/*
|
|
||||||
* Make fairly sure that this is written, and not "optimized" away.
|
|
||||||
* The delete operator is overwritten to not delete it; the deletion
|
|
||||||
* happens at a later moment in time after the window has been
|
|
||||||
* removed from the list of windows to prevent issues with items
|
|
||||||
* being removed during the iteration as not one but more windows
|
|
||||||
* may be removed by a single call to ~Window by means of the
|
|
||||||
* CloseChildWindows function.
|
|
||||||
*/
|
|
||||||
const_cast<volatile WindowClass &>(this->window_class) = WC_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Window::Close()
|
|
||||||
{
|
|
||||||
if (this->window_class != WC_INVALID) delete this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1232,7 +1226,7 @@ void CloseWindowById(WindowClass cls, WindowNumber number, bool force)
|
|||||||
{
|
{
|
||||||
Window *w = FindWindowById(cls, number);
|
Window *w = FindWindowById(cls, number);
|
||||||
if (w != nullptr && (force || (w->flags & WF_STICKY) == 0)) {
|
if (w != nullptr && (force || (w->flags & WF_STICKY) == 0)) {
|
||||||
delete w;
|
w->Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1247,9 +1241,9 @@ void CloseAllWindowsById(WindowClass cls, WindowNumber number, bool force)
|
|||||||
if (cls < WC_END && !_present_window_types[cls]) return;
|
if (cls < WC_END && !_present_window_types[cls]) return;
|
||||||
|
|
||||||
/* Note: the container remains stable, even when deleting windows. */
|
/* Note: the container remains stable, even when deleting windows. */
|
||||||
for (Window *w : Window::IterateUnordered()) {
|
for (Window *w : Window::Iterate()) {
|
||||||
if (w->window_class == cls && w->window_number == number && (force || (w->flags & WF_STICKY) == 0)) {
|
if (w->window_class == cls && w->window_number == number && (force || (w->flags & WF_STICKY) == 0)) {
|
||||||
delete w;
|
w->Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1263,9 +1257,9 @@ void CloseWindowByClass(WindowClass cls)
|
|||||||
if (cls < WC_END && !_present_window_types[cls]) return;
|
if (cls < WC_END && !_present_window_types[cls]) return;
|
||||||
|
|
||||||
/* Note: the container remains stable, even when deleting windows. */
|
/* Note: the container remains stable, even when deleting windows. */
|
||||||
for (Window *w : Window::IterateUnordered()) {
|
for (Window *w : Window::Iterate()) {
|
||||||
if (w->window_class == cls) {
|
if (w->window_class == cls) {
|
||||||
delete w;
|
w->Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1279,9 +1273,9 @@ void CloseWindowByClass(WindowClass cls)
|
|||||||
void DeleteCompanyWindows(CompanyID id)
|
void DeleteCompanyWindows(CompanyID id)
|
||||||
{
|
{
|
||||||
/* Note: the container remains stable, even when deleting windows. */
|
/* Note: the container remains stable, even when deleting windows. */
|
||||||
for (Window *w : Window::IterateUnordered()) {
|
for (Window *w : Window::Iterate()) {
|
||||||
if (w->owner == id) {
|
if (w->owner == id) {
|
||||||
delete w;
|
w->Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1458,7 +1452,7 @@ static void AddWindowToZOrdering(Window *w)
|
|||||||
w->z_front = w->z_back = nullptr;
|
w->z_front = w->z_back = nullptr;
|
||||||
} else {
|
} else {
|
||||||
/* Search down the z-ordering for its location. */
|
/* Search down the z-ordering for its location. */
|
||||||
WindowBase *v = _z_front_window;
|
Window *v = _z_front_window;
|
||||||
uint last_z_priority = UINT_MAX;
|
uint last_z_priority = UINT_MAX;
|
||||||
(void)last_z_priority; // Unused without asserts
|
(void)last_z_priority; // Unused without asserts
|
||||||
while (v != nullptr && (v->window_class == WC_INVALID || GetWindowZPriority(v->window_class) > GetWindowZPriority(w->window_class))) {
|
while (v != nullptr && (v->window_class == WC_INVALID || GetWindowZPriority(v->window_class) > GetWindowZPriority(w->window_class))) {
|
||||||
@@ -1498,7 +1492,7 @@ static void AddWindowToZOrdering(Window *w)
|
|||||||
* Removes a window from the z-ordering.
|
* Removes a window from the z-ordering.
|
||||||
* @param w Window to remove
|
* @param w Window to remove
|
||||||
*/
|
*/
|
||||||
static void RemoveWindowFromZOrdering(WindowBase *w)
|
static void RemoveWindowFromZOrdering(Window *w)
|
||||||
{
|
{
|
||||||
if (w->z_front == nullptr) {
|
if (w->z_front == nullptr) {
|
||||||
dbg_assert(_z_front_window == w);
|
dbg_assert(_z_front_window == w);
|
||||||
@@ -2003,13 +1997,8 @@ void UnInitWindowSystem()
|
|||||||
{
|
{
|
||||||
UnshowCriticalError();
|
UnshowCriticalError();
|
||||||
|
|
||||||
for (Window *w : Window::IterateUnordered()) delete w;
|
for (Window *w : Window::Iterate()) w->Close();
|
||||||
|
Window::DeleteClosedWindows();
|
||||||
for (WindowBase *w = _z_front_window; w != nullptr; /* nothing */) {
|
|
||||||
WindowBase *to_del = w;
|
|
||||||
w = w->z_back;
|
|
||||||
free(to_del);
|
|
||||||
}
|
|
||||||
|
|
||||||
_z_front_window = nullptr;
|
_z_front_window = nullptr;
|
||||||
_z_back_window = nullptr;
|
_z_back_window = nullptr;
|
||||||
@@ -3237,7 +3226,37 @@ static void CheckSoftLimit()
|
|||||||
if (deletable_count <= _settings_client.gui.window_soft_limit) break;
|
if (deletable_count <= _settings_client.gui.window_soft_limit) break;
|
||||||
|
|
||||||
assert(last_deletable != nullptr);
|
assert(last_deletable != nullptr);
|
||||||
delete last_deletable;
|
last_deletable->Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all closed windows.
|
||||||
|
*/
|
||||||
|
/* static */ void Window::DeleteClosedWindows()
|
||||||
|
{
|
||||||
|
bool reset_window_nexts = false;
|
||||||
|
_present_window_types.reset();
|
||||||
|
|
||||||
|
/* Do the actual free of the deleted windows. */
|
||||||
|
for (Window *v = _z_front_window; v != nullptr; /* nothing */) {
|
||||||
|
Window *w = v;
|
||||||
|
v = v->z_back;
|
||||||
|
|
||||||
|
if (w->window_class < WC_END) _present_window_types.set(w->window_class);
|
||||||
|
|
||||||
|
if (w->window_class != WC_INVALID) continue;
|
||||||
|
|
||||||
|
RemoveWindowFromZOrdering(w);
|
||||||
|
delete w;
|
||||||
|
reset_window_nexts = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reset_window_nexts) {
|
||||||
|
_first_window = _z_front_window;
|
||||||
|
for (Window *w = _z_front_window; w != nullptr; w = w->z_back) {
|
||||||
|
w->next_window = w->z_back;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3252,30 +3271,7 @@ void InputLoop()
|
|||||||
|
|
||||||
CheckSoftLimit();
|
CheckSoftLimit();
|
||||||
|
|
||||||
bool reset_window_nexts = false;
|
Window::DeleteClosedWindows();
|
||||||
|
|
||||||
_present_window_types.reset();
|
|
||||||
|
|
||||||
/* Do the actual free of the deleted windows. */
|
|
||||||
for (WindowBase *v = _z_front_window; v != nullptr; /* nothing */) {
|
|
||||||
WindowBase *w = v;
|
|
||||||
v = v->z_back;
|
|
||||||
|
|
||||||
if (w->window_class < WC_END) _present_window_types.set(w->window_class);
|
|
||||||
|
|
||||||
if (w->window_class != WC_INVALID) continue;
|
|
||||||
|
|
||||||
RemoveWindowFromZOrdering(w);
|
|
||||||
free(w);
|
|
||||||
reset_window_nexts = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reset_window_nexts) {
|
|
||||||
_first_window = _z_front_window;
|
|
||||||
for (WindowBase *w = _z_front_window; w != nullptr; w = w->z_back) {
|
|
||||||
w->next_window = w->z_back;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_input_events_this_tick != 0) {
|
if (_input_events_this_tick != 0) {
|
||||||
/* The input loop is called only once per GameLoop() - so we can clear the counter here */
|
/* The input loop is called only once per GameLoop() - so we can clear the counter here */
|
||||||
@@ -3541,11 +3537,11 @@ void CallWindowGameTickEvent()
|
|||||||
void CloseNonVitalWindows()
|
void CloseNonVitalWindows()
|
||||||
{
|
{
|
||||||
/* Note: the container remains stable, even when deleting windows. */
|
/* Note: the container remains stable, even when deleting windows. */
|
||||||
for (Window *w : Window::IterateUnordered()) {
|
for (Window *w : Window::Iterate()) {
|
||||||
if ((w->window_desc->flags & WDF_NO_CLOSE) == 0 &&
|
if ((w->window_desc->flags & WDF_NO_CLOSE) == 0 &&
|
||||||
(w->flags & WF_STICKY) == 0) { // do not delete windows which are 'pinned'
|
(w->flags & WF_STICKY) == 0) { // do not delete windows which are 'pinned'
|
||||||
|
|
||||||
delete w;
|
w->Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3560,9 +3556,9 @@ void CloseNonVitalWindows()
|
|||||||
void CloseAllNonVitalWindows()
|
void CloseAllNonVitalWindows()
|
||||||
{
|
{
|
||||||
/* Note: the container remains stable, even when closing windows. */
|
/* Note: the container remains stable, even when closing windows. */
|
||||||
for (Window *w : Window::IterateUnordered()) {
|
for (Window *w : Window::Iterate()) {
|
||||||
if ((w->window_desc->flags & WDF_NO_CLOSE) == 0) {
|
if ((w->window_desc->flags & WDF_NO_CLOSE) == 0) {
|
||||||
delete w;
|
w->Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3585,9 +3581,9 @@ void DeleteAllMessages()
|
|||||||
void CloseConstructionWindows()
|
void CloseConstructionWindows()
|
||||||
{
|
{
|
||||||
/* Note: the container remains stable, even when deleting windows. */
|
/* Note: the container remains stable, even when deleting windows. */
|
||||||
for (const Window *w : Window::IterateUnordered()) {
|
for (Window *w : Window::Iterate()) {
|
||||||
if (w->window_desc->flags & WDF_CONSTRUCTION) {
|
if (w->window_desc->flags & WDF_CONSTRUCTION) {
|
||||||
delete w;
|
w->Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3598,9 +3594,9 @@ void CloseConstructionWindows()
|
|||||||
void CloseNetworkClientWindows()
|
void CloseNetworkClientWindows()
|
||||||
{
|
{
|
||||||
/* Note: the container remains stable, even when deleting windows. */
|
/* Note: the container remains stable, even when deleting windows. */
|
||||||
for (const Window *w : Window::IterateUnordered()) {
|
for (Window *w : Window::Iterate()) {
|
||||||
if (w->window_desc->flags & WDF_NETWORK) {
|
if (w->window_desc->flags & WDF_NETWORK) {
|
||||||
delete w;
|
w->Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3807,14 +3803,13 @@ void RelocateAllWindows(int neww, int newh)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor of the base class PickerWindowBase
|
* Hide the window and all its child windows, and mark them for a later deletion.
|
||||||
* Main utility is to stop the base Window destructor from triggering
|
* Always call ResetObjectToPlace() when closing a PickerWindow.
|
||||||
* a free while the child will already be free, in this case by the ResetObjectToPlace().
|
|
||||||
*/
|
*/
|
||||||
PickerWindowBase::~PickerWindowBase()
|
void PickerWindowBase::Close()
|
||||||
{
|
{
|
||||||
this->window_class = WC_INVALID; // stop the ancestor from freeing the already (to be) child
|
|
||||||
ResetObjectToPlace();
|
ResetObjectToPlace();
|
||||||
|
this->Window::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
char *DumpWindowInfo(char *b, const char *last, const Window *w)
|
char *DumpWindowInfo(char *b, const char *last, const Window *w)
|
||||||
|
111
src/window_gui.h
111
src/window_gui.h
@@ -77,9 +77,9 @@ static inline void DrawFrameRect(const Rect &r, Colours colour, FrameFlags flags
|
|||||||
void DrawCaption(const Rect &r, Colours colour, Owner owner, TextColour text_colour, StringID str, StringAlignment align, FontSize fs);
|
void DrawCaption(const Rect &r, Colours colour, Owner owner, TextColour text_colour, StringID str, StringAlignment align, FontSize fs);
|
||||||
|
|
||||||
/* window.cpp */
|
/* window.cpp */
|
||||||
extern WindowBase *_z_front_window;
|
extern Window *_z_front_window;
|
||||||
extern WindowBase *_z_back_window;
|
extern Window *_z_back_window;
|
||||||
extern WindowBase *_first_window;
|
extern Window *_first_window;
|
||||||
extern Window *_focused_window;
|
extern Window *_focused_window;
|
||||||
|
|
||||||
inline uint64 GetWindowUpdateNumber()
|
inline uint64 GetWindowUpdateNumber()
|
||||||
@@ -233,51 +233,27 @@ enum TooltipCloseCondition {
|
|||||||
TCC_EXIT_VIEWPORT,
|
TCC_EXIT_VIEWPORT,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct WindowBase {
|
|
||||||
WindowBase *z_front; ///< The window in front of us in z-order.
|
|
||||||
WindowBase *z_back; ///< The window behind us in z-order.
|
|
||||||
WindowBase *next_window; ///< The next window in arbitrary iteration order.
|
|
||||||
WindowClass window_class; ///< Window class
|
|
||||||
|
|
||||||
virtual ~WindowBase() {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Memory allocator for a single class instance.
|
|
||||||
* @param size the amount of bytes to allocate.
|
|
||||||
* @return the given amounts of bytes zeroed.
|
|
||||||
*/
|
|
||||||
inline void *operator new(size_t size) { return CallocT<byte>(size); }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
WindowBase() {}
|
|
||||||
|
|
||||||
private:
|
|
||||||
/**
|
|
||||||
* Memory allocator for an array of class instances.
|
|
||||||
* @param size the amount of bytes to allocate.
|
|
||||||
* @return the given amounts of bytes zeroed.
|
|
||||||
*/
|
|
||||||
inline void *operator new[](size_t size) { NOT_REACHED(); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Memory release for a single class instance.
|
|
||||||
* @param ptr the memory to free.
|
|
||||||
*/
|
|
||||||
inline void operator delete(void *ptr) { NOT_REACHED(); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Memory release for an array of class instances.
|
|
||||||
* @param ptr the memory to free.
|
|
||||||
*/
|
|
||||||
inline void operator delete[](void *ptr) { NOT_REACHED(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::vector<const Vehicle *> VehicleList;
|
typedef std::vector<const Vehicle *> VehicleList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data structure for an opened window
|
* Data structure for an opened window
|
||||||
*/
|
*/
|
||||||
struct Window : WindowBase {
|
struct Window : ZeroedMemoryAllocator {
|
||||||
|
Window *z_front; ///< The window in front of us in z-order.
|
||||||
|
Window *z_back; ///< The window behind us in z-order.
|
||||||
|
Window *next_window; ///< The next window in arbitrary iteration order.
|
||||||
|
WindowClass window_class; ///< Window class
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* Helper allocation function to disallow something.
|
||||||
|
* Don't allow arrays; arrays of Windows are pointless as you need
|
||||||
|
* to destruct them all at the same time too, which is kinda hard.
|
||||||
|
* @param size the amount of space not to allocate
|
||||||
|
*/
|
||||||
|
inline void *operator new[](size_t size) { NOT_REACHED(); }
|
||||||
|
inline void operator delete[](void *ptr) { NOT_REACHED(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void InitializeData(WindowNumber window_number);
|
void InitializeData(WindowNumber window_number);
|
||||||
void InitializePositionSize(int x, int y, int min_width, int min_height);
|
void InitializePositionSize(int x, int y, int min_width, int min_height);
|
||||||
@@ -285,32 +261,13 @@ protected:
|
|||||||
|
|
||||||
std::vector<int> scheduled_invalidation_data; ///< Data of scheduled OnInvalidateData() calls.
|
std::vector<int> scheduled_invalidation_data; ///< Data of scheduled OnInvalidateData() calls.
|
||||||
|
|
||||||
|
virtual ~Window();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Window(WindowDesc *desc);
|
Window(WindowDesc *desc);
|
||||||
|
|
||||||
virtual ~Window();
|
|
||||||
|
|
||||||
virtual void Close();
|
virtual void Close();
|
||||||
|
static void DeleteClosedWindows();
|
||||||
/**
|
|
||||||
* Helper allocation function to disallow something.
|
|
||||||
* Don't allow arrays; arrays of Windows are pointless as you need
|
|
||||||
* to destruct them all at the same time too, which is kinda hard.
|
|
||||||
* @param size the amount of space not to allocate
|
|
||||||
*/
|
|
||||||
inline void *operator new[](size_t size)
|
|
||||||
{
|
|
||||||
NOT_REACHED();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper allocation function to disallow something.
|
|
||||||
* Don't free the window directly; it corrupts the linked list when iterating
|
|
||||||
* @param ptr the pointer not to free
|
|
||||||
*/
|
|
||||||
inline void operator delete(void *ptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowDesc *window_desc; ///< Window description
|
WindowDesc *window_desc; ///< Window description
|
||||||
WindowFlags flags; ///< Window flags
|
WindowFlags flags; ///< Window flags
|
||||||
@@ -601,7 +558,7 @@ public:
|
|||||||
|
|
||||||
virtual void OnFocus(Window *previously_focused_window);
|
virtual void OnFocus(Window *previously_focused_window);
|
||||||
|
|
||||||
virtual void OnFocusLost(Window *newly_focused_window);
|
virtual void OnFocusLost(bool closing, Window *newly_focused_window);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A key has been pressed.
|
* A key has been pressed.
|
||||||
@@ -845,7 +802,7 @@ public:
|
|||||||
virtual void ShowNewGRFInspectWindow() const { NOT_REACHED(); }
|
virtual void ShowNewGRFInspectWindow() const { NOT_REACHED(); }
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
using window_base_t = std::conditional_t<std::is_const<T>{}, WindowBase const, WindowBase>;
|
using window_type = std::conditional_t<std::is_const<T>{}, Window const, Window>;
|
||||||
|
|
||||||
enum IterationMode {
|
enum IterationMode {
|
||||||
IM_FROM_FRONT,
|
IM_FROM_FRONT,
|
||||||
@@ -866,7 +823,7 @@ public:
|
|||||||
typedef size_t difference_type;
|
typedef size_t difference_type;
|
||||||
typedef std::forward_iterator_tag iterator_category;
|
typedef std::forward_iterator_tag iterator_category;
|
||||||
|
|
||||||
explicit WindowIterator(window_base_t<T> *start) : w(start)
|
explicit WindowIterator(window_type<T> *start) : w(start)
|
||||||
{
|
{
|
||||||
this->Validate();
|
this->Validate();
|
||||||
}
|
}
|
||||||
@@ -877,7 +834,7 @@ public:
|
|||||||
WindowIterator & operator++() { this->Next(); this->Validate(); return *this; }
|
WindowIterator & operator++() { this->Next(); this->Validate(); return *this; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
window_base_t<T> *w;
|
window_type<T> *w;
|
||||||
void Validate() { while (this->w != nullptr && this->w->window_class == WC_INVALID) this->Next(); }
|
void Validate() { while (this->w != nullptr && this->w->window_class == WC_INVALID) this->Next(); }
|
||||||
|
|
||||||
void Next()
|
void Next()
|
||||||
@@ -901,16 +858,16 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Iterable ensemble of all valid Windows
|
* Iterable ensemble of all valid Windows
|
||||||
* @tparam T Type of the class/struct that is going to be iterated
|
* @tparam T Type of the class/struct that is going to be iterated
|
||||||
* @tparam Tfront Wether we iterate from front
|
* @tparam Tmode Iteration mode
|
||||||
*/
|
*/
|
||||||
template <class T, IterationMode Tmode>
|
template <class T, IterationMode Tmode>
|
||||||
struct Iterate {
|
struct IterateCommon {
|
||||||
Iterate(window_base_t<T> *from) : from(from) {}
|
IterateCommon(window_type<T> *from) : from(from) {}
|
||||||
WindowIterator<T, Tmode> begin() { return WindowIterator<T, Tmode>(this->from); }
|
WindowIterator<T, Tmode> begin() { return WindowIterator<T, Tmode>(this->from); }
|
||||||
WindowIterator<T, Tmode> end() { return WindowIterator<T, Tmode>(nullptr); }
|
WindowIterator<T, Tmode> end() { return WindowIterator<T, Tmode>(nullptr); }
|
||||||
bool empty() { return this->begin() == this->end(); }
|
bool empty() { return this->begin() == this->end(); }
|
||||||
private:
|
private:
|
||||||
window_base_t<T> *from;
|
window_type<T> *from;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -920,7 +877,7 @@ public:
|
|||||||
* @return an iterable ensemble of all valid Window
|
* @return an iterable ensemble of all valid Window
|
||||||
*/
|
*/
|
||||||
template <class T = Window>
|
template <class T = Window>
|
||||||
static Iterate<T, IM_FROM_BACK> IterateFromBack(window_base_t<T> *from = _z_back_window) { return Iterate<T, IM_FROM_BACK>(from); }
|
static IterateCommon<T, IM_FROM_BACK> IterateFromBack(window_type<T> *from = _z_back_window) { return IterateCommon<T, IM_FROM_BACK>(from); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an iterable ensemble of all valid Window from front to back
|
* Returns an iterable ensemble of all valid Window from front to back
|
||||||
@@ -929,7 +886,7 @@ public:
|
|||||||
* @return an iterable ensemble of all valid Window
|
* @return an iterable ensemble of all valid Window
|
||||||
*/
|
*/
|
||||||
template <class T = Window>
|
template <class T = Window>
|
||||||
static Iterate<T, IM_FROM_FRONT> IterateFromFront(window_base_t<T> *from = _z_front_window) { return Iterate<T, IM_FROM_FRONT>(from); }
|
static IterateCommon<T, IM_FROM_FRONT> IterateFromFront(window_type<T> *from = _z_front_window) { return IterateCommon<T, IM_FROM_FRONT>(from); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an iterable ensemble of all valid Window in an arbitrary order which is safe to use when deleting
|
* Returns an iterable ensemble of all valid Window in an arbitrary order which is safe to use when deleting
|
||||||
@@ -938,7 +895,7 @@ public:
|
|||||||
* @return an iterable ensemble of all valid Window
|
* @return an iterable ensemble of all valid Window
|
||||||
*/
|
*/
|
||||||
template <class T = Window>
|
template <class T = Window>
|
||||||
static Iterate<T, IM_ARBITRARY> IterateUnordered(window_base_t<T> *from = _first_window) { return Iterate<T, IM_ARBITRARY>(from); }
|
static IterateCommon<T, IM_ARBITRARY> Iterate(window_type<T> *from = _first_window) { return IterateCommon<T, IM_ARBITRARY>(from); }
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1001,7 +958,7 @@ public:
|
|||||||
this->parent = parent;
|
this->parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~PickerWindowBase();
|
void Close() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
Window *BringWindowToFrontById(WindowClass cls, WindowNumber number);
|
Window *BringWindowToFrontById(WindowClass cls, WindowNumber number);
|
||||||
|
Reference in New Issue
Block a user