Refactor `MainForm`'s `Closing` handler

This commit is contained in:
YoshiRulz 2024-08-31 11:37:55 +10:00
parent aeda8f1659
commit 31b0a29d2d
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 17 additions and 15 deletions

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
@ -523,21 +524,7 @@ namespace BizHawk.Client.EmuHawk
DragDrop += FormDragDrop;
};
Closing += (o, e) =>
{
if (Tools.AskSave())
{
// zero 03-nov-2015 - close game after other steps. tools might need to unhook themselves from a core.
MovieSession.StopMovie();
Tools.Close();
CloseGame();
SaveConfig();
}
else
{
e.Cancel = true;
}
};
Closing += CheckMayCloseAndCleanup;
ResizeBegin += (o, e) =>
{
@ -794,6 +781,21 @@ namespace BizHawk.Client.EmuHawk
}
}
private void CheckMayCloseAndCleanup(object/*?*/ closingSender, CancelEventArgs closingArgs)
{
if (!Tools.AskSave())
{
closingArgs.Cancel = true;
return;
}
MovieSession.StopMovie();
Tools.Close();
// zero 03-nov-2015 - close game after other steps. tools might need to unhook themselves from a core.
CloseGame();
SaveConfig();
}
private readonly bool _suppressSyncSettingsWarning;
public override bool BlocksInputWhenFocused { get; } = false;