Skip to content

Commit f4f01d1

Browse files
committed
fix: duplicated exit confirmation
- fix: AlertWindow's handleCancel - panda's review (I) - squashed to sign commits Signed-off-by: Arufonsu <17498701+Arufonsu@users.noreply.github.com>
1 parent 4891f3c commit f4f01d1

4 files changed

Lines changed: 50 additions & 4 deletions

File tree

Intersect.Client.Core/Interface/Game/SimplifiedEscapeMenu.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
using Intersect.Client.General;
77
using Intersect.Client.Interface.Shared;
88
using Intersect.Client.Localization;
9+
using Intersect.Client.MonoGame;
910
using Intersect.Framework.Core;
10-
using Intersect.Utilities;
1111

1212
namespace Intersect.Client.Interface.Game;
1313

@@ -114,6 +114,11 @@ private void LogoutToMainToMainMenuClicked(Base sender, MouseButtonState argumen
114114

115115
private void ExitToDesktopClicked(Base sender, MouseButtonState arguments)
116116
{
117+
if (IntersectGame._isShowingExitConfirmation)
118+
{
119+
return;
120+
}
121+
117122
if (Globals.Me?.CombatTimer > Timing.Global?.Milliseconds)
118123
{
119124
AlertWindow.Open(
@@ -123,8 +128,13 @@ private void ExitToDesktopClicked(Base sender, MouseButtonState arguments)
123128
inputType: InputType.YesNo,
124129
handleSubmit: (_, _) =>
125130
{
131+
IntersectGame._isShowingExitConfirmation = false;
126132
Globals.Me.CombatTimer = 0;
127133
Globals.IsRunning = false;
134+
},
135+
handleCancel: (_, _) =>
136+
{
137+
IntersectGame._isShowingExitConfirmation = false;
128138
}
129139
);
130140
}
@@ -137,10 +147,17 @@ private void ExitToDesktopClicked(Base sender, MouseButtonState arguments)
137147
inputType: InputType.YesNo,
138148
handleSubmit: (_, _) =>
139149
{
150+
IntersectGame._isShowingExitConfirmation = false;
140151
Globals.IsRunning = false;
152+
},
153+
handleCancel: (_, _) =>
154+
{
155+
IntersectGame._isShowingExitConfirmation = false;
141156
}
142157
);
143158
}
159+
160+
IntersectGame._isShowingExitConfirmation = true;
144161
}
145162

146163
private void OpenSettingsWindow(object? sender, EventArgs? e)

Intersect.Client.Core/Interface/Menu/EscapeMenuWindow.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
using Intersect.Client.General;
66
using Intersect.Client.Interface.Shared;
77
using Intersect.Client.Localization;
8+
using Intersect.Client.MonoGame;
89
using Intersect.Framework.Core;
9-
using Intersect.Utilities;
1010

1111
namespace Intersect.Client.Interface.Menu;
1212

@@ -217,6 +217,11 @@ private void ShowCombatWarning()
217217

218218
private void ExitToDesktop(object? sender, EventArgs? e)
219219
{
220+
if (IntersectGame._isShowingExitConfirmation)
221+
{
222+
return;
223+
}
224+
220225
AlertWindow.Open(
221226
Strings.General.QuitPrompt,
222227
Strings.General.QuitTitle,
@@ -229,8 +234,15 @@ private void ExitToDesktop(object? sender, EventArgs? e)
229234
Globals.Me.CombatTimer = 0;
230235
}
231236

237+
IntersectGame._isShowingExitConfirmation = false;
232238
Globals.IsRunning = false;
239+
},
240+
handleCancel: (_, _) =>
241+
{
242+
IntersectGame._isShowingExitConfirmation = false;
233243
}
234244
);
245+
246+
IntersectGame._isShowingExitConfirmation = true;
235247
}
236248
}

Intersect.Client.Core/Interface/Shared/InputBox.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@ protected InputBox(
580580

581581
Submitted += onSubmit;
582582
Canceled += onCancel;
583+
Closed += onCancel;
583584
}
584585

585586
private void YesButtonOnClicked(Base sender, MouseButtonState arguments)

Intersect.Client.Core/MonoGame/IntersectGame.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
using Intersect.Configuration;
1212
using Microsoft.Xna.Framework;
1313
using Microsoft.Xna.Framework.Graphics;
14-
using System.Diagnostics;
15-
using System.Reflection;
1614
using Intersect.Client.Framework.Database;
1715
using Intersect.Client.Framework.Graphics;
1816
using Intersect.Client.ThirdParty;
@@ -58,6 +56,8 @@ internal partial class IntersectGame : Game
5856
private SpriteBatch? updateBatch;
5957

6058
private bool updaterGraphicsReset;
59+
60+
public static bool _isShowingExitConfirmation;
6161

6262
#endregion
6363

@@ -355,6 +355,11 @@ protected override void OnExiting(object sender, ExitingEventArgs args)
355355
Globals.Me.CombatTimer > Timing.Global?.Milliseconds &&
356356
Globals.GameState == GameStates.InGame;
357357

358+
if (_isShowingExitConfirmation)
359+
{
360+
return;
361+
}
362+
358363
if (inCombat)
359364
{
360365
AlertWindow.Open(
@@ -369,7 +374,12 @@ protected override void OnExiting(object sender, ExitingEventArgs args)
369374
Globals.Me.CombatTimer = 0;
370375
}
371376

377+
_isShowingExitConfirmation = false;
372378
Globals.IsRunning = false;
379+
},
380+
handleCancel: (_, _) =>
381+
{
382+
_isShowingExitConfirmation = false;
373383
}
374384
);
375385
}
@@ -382,10 +392,16 @@ protected override void OnExiting(object sender, ExitingEventArgs args)
382392
inputType: InputType.YesNo,
383393
handleSubmit: (_, _) =>
384394
{
395+
_isShowingExitConfirmation = false;
385396
Globals.IsRunning = false;
397+
},
398+
handleCancel: (_, _) =>
399+
{
400+
_isShowingExitConfirmation = false;
386401
}
387402
);
388403
}
404+
_isShowingExitConfirmation = true;
389405
}
390406

391407
private void TryExit(object sender, ExitingEventArgs args)

0 commit comments

Comments
 (0)