1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-20 10:52:41 +01:00

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

View File

@@ -609,7 +609,7 @@ void ShowScriptSettingsWindow(CompanyID slot)
struct ScriptTextfileWindow : public TextfileWindow {
CompanyID slot{}; ///< View the textfile of this CompanyID slot.
ScriptTextfileWindow(TextfileType file_type, CompanyID slot) : TextfileWindow(file_type), slot(slot)
ScriptTextfileWindow(Window *parent, TextfileType file_type, CompanyID slot) : TextfileWindow(parent, file_type), slot(slot)
{
this->ConstructWindow();
this->OnInvalidateData();
@@ -640,10 +640,10 @@ struct ScriptTextfileWindow : public TextfileWindow {
* @param file_type The type of textfile to display.
* @param slot The slot the Script is using.
*/
void ShowScriptTextfileWindow(TextfileType file_type, CompanyID slot)
void ShowScriptTextfileWindow(Window *parent, TextfileType file_type, CompanyID slot)
{
CloseWindowById(WC_TEXTFILE, file_type);
new ScriptTextfileWindow(file_type, slot);
parent->CloseChildWindowById(WC_TEXTFILE, file_type);
new ScriptTextfileWindow(parent, file_type, slot);
}

View File

@@ -18,7 +18,7 @@ struct Window;
void ShowScriptListWindow(CompanyID slot, bool show_all);
Window *ShowScriptDebugWindow(CompanyID show_company = CompanyID::Invalid(), bool new_window = false);
void ShowScriptSettingsWindow(CompanyID slot);
void ShowScriptTextfileWindow(TextfileType file_type, CompanyID slot);
void ShowScriptTextfileWindow(Window *parent, TextfileType file_type, CompanyID slot);
void ShowScriptDebugWindowIfScriptError();
void InitializeScriptGui();