Fix: Closing the Game Options window closes all textfile windows.

Record the parent window that opens a textfile window so only child windows are closed instead of all.
This commit is contained in:
Peter Nelson
2025-05-04 17:50:31 +01:00
committed by Peter Nelson
parent dabf2ede67
commit ac76212b80
12 changed files with 44 additions and 45 deletions
+5 -5
View File
@@ -44,7 +44,7 @@ static bool _accepted_external_search = false;
struct ContentTextfileWindow : public TextfileWindow {
const ContentInfo *ci = nullptr; ///< View the textfile of this ContentInfo.
ContentTextfileWindow(TextfileType file_type, const ContentInfo *ci) : TextfileWindow(file_type), ci(ci)
ContentTextfileWindow(Window *parent, TextfileType file_type, const ContentInfo *ci) : TextfileWindow(parent, file_type), ci(ci)
{
this->ConstructWindow();
@@ -79,10 +79,10 @@ struct ContentTextfileWindow : public TextfileWindow {
}
};
void ShowContentTextfileWindow(TextfileType file_type, const ContentInfo *ci)
static void ShowContentTextfileWindow(Window *parent, TextfileType file_type, const ContentInfo *ci)
{
CloseWindowById(WC_TEXTFILE, file_type);
new ContentTextfileWindow(file_type, ci);
parent->CloseChildWindowById(WC_TEXTFILE, file_type);
new ContentTextfileWindow(parent, file_type, ci);
}
/** Nested widgets for the download window. */
@@ -776,7 +776,7 @@ public:
if (widget >= WID_NCL_TEXTFILE && widget < WID_NCL_TEXTFILE + TFT_CONTENT_END) {
if (this->selected == nullptr || this->selected->state != ContentInfo::ALREADY_HERE) return;
ShowContentTextfileWindow((TextfileType)(widget - WID_NCL_TEXTFILE), this->selected);
ShowContentTextfileWindow(this, (TextfileType)(widget - WID_NCL_TEXTFILE), this->selected);
return;
}
+5 -5
View File
@@ -2323,7 +2323,7 @@ struct NetworkAskSurveyWindow : public Window {
{
switch (widget) {
case WID_NAS_PREVIEW:
ShowSurveyResultTextfileWindow();
ShowSurveyResultTextfileWindow(this);
break;
case WID_NAS_LINK:
@@ -2388,7 +2388,7 @@ void ShowNetworkAskSurvey()
struct SurveyResultTextfileWindow : public TextfileWindow {
const GRFConfig *grf_config; ///< View the textfile of this GRFConfig.
SurveyResultTextfileWindow(TextfileType file_type) : TextfileWindow(file_type)
SurveyResultTextfileWindow(Window *parent, TextfileType file_type) : TextfileWindow(parent, file_type)
{
this->ConstructWindow();
@@ -2398,8 +2398,8 @@ struct SurveyResultTextfileWindow : public TextfileWindow {
}
};
void ShowSurveyResultTextfileWindow()
void ShowSurveyResultTextfileWindow(Window *parent)
{
CloseWindowById(WC_TEXTFILE, TFT_SURVEY_RESULT);
new SurveyResultTextfileWindow(TFT_SURVEY_RESULT);
parent->CloseChildWindowById(WC_TEXTFILE, TFT_SURVEY_RESULT);
new SurveyResultTextfileWindow(parent, TFT_SURVEY_RESULT);
}
+1 -1
View File
@@ -24,7 +24,7 @@ void ShowNetworkGameWindow();
void ShowClientList();
void ShowNetworkAskRelay(std::string_view server_connection_string, std::string &&relay_connection_string, std::string &&token);
void ShowNetworkAskSurvey();
void ShowSurveyResultTextfileWindow();
void ShowSurveyResultTextfileWindow(Window *parent);
/** Company information stored at the client side */
struct NetworkCompanyInfo : NetworkCompanyStats {