Add a dialog to make sure user wants to stop emulation when esc is pressed
This commit is contained in:
parent
0dd38028cb
commit
658d7c40e7
2 changed files with 31 additions and 2 deletions
|
@ -138,7 +138,8 @@ namespace Ryujinx.Ui
|
||||||
{
|
{
|
||||||
if (keyboard.IsKeyDown(OpenTK.Input.Key.Escape))
|
if (keyboard.IsKeyDown(OpenTK.Input.Key.Escape))
|
||||||
{
|
{
|
||||||
Exit();
|
if (GtkDialog.CreateExitDialog())
|
||||||
|
Exit();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,5 +29,33 @@ namespace Ryujinx.Ui
|
||||||
{
|
{
|
||||||
CreateDialog("Ryujinx - Error", "Ryujinx has encountered an error", errorMessage);
|
CreateDialog("Ryujinx - Error", "Ryujinx has encountered an error", errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static bool isExitDialogOpen = false;
|
||||||
|
internal static bool CreateExitDialog()
|
||||||
|
{
|
||||||
|
if (isExitDialogOpen)
|
||||||
|
return false;
|
||||||
|
isExitDialogOpen = true;
|
||||||
|
|
||||||
|
MessageDialog messageDialog = new MessageDialog(null, DialogFlags.Modal, MessageType.Question, ButtonsType.OkCancel, null)
|
||||||
|
{
|
||||||
|
Title = "Ryujinx - Exit",
|
||||||
|
Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.Icon.png"),
|
||||||
|
Text = "Are you sure you want to stop emulation?",
|
||||||
|
SecondaryText = "All unsaved data will be lost",
|
||||||
|
WindowPosition = WindowPosition.Center
|
||||||
|
};
|
||||||
|
messageDialog.SetSizeRequest(100, 20);
|
||||||
|
ResponseType res = (ResponseType)messageDialog.Run();
|
||||||
|
messageDialog.Dispose();
|
||||||
|
isExitDialogOpen = false;
|
||||||
|
|
||||||
|
if (res == ResponseType.Ok)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue