mirror of
https://github.com/ryujinx-mirror/ryujinx.git
synced 2024-12-28 18:41:10 +00:00
Escape key now brings up a dialog to confirm you want to stop emulation (#1044)
* Add a dialog to make sure user wants to stop emulation when esc is pressed * Remove unneccesary space * Fix formatting * Remove unnessecary spaces * Fix formatting for member of GtkDialog
This commit is contained in:
parent
7ad8b3ef75
commit
5c1757f7c2
2 changed files with 37 additions and 1 deletions
|
@ -138,7 +138,10 @@ namespace Ryujinx.Ui
|
||||||
{
|
{
|
||||||
if (keyboard.IsKeyDown(OpenTK.Input.Key.Escape))
|
if (keyboard.IsKeyDown(OpenTK.Input.Key.Escape))
|
||||||
{
|
{
|
||||||
Exit();
|
if (GtkDialog.CreateExitDialog())
|
||||||
|
{
|
||||||
|
Exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,6 +5,8 @@ namespace Ryujinx.Ui
|
||||||
{
|
{
|
||||||
internal class GtkDialog
|
internal class GtkDialog
|
||||||
{
|
{
|
||||||
|
internal static bool _isExitDialogOpen = false;
|
||||||
|
|
||||||
internal static void CreateDialog(string title, string text, string secondaryText)
|
internal static void CreateDialog(string title, string text, string secondaryText)
|
||||||
{
|
{
|
||||||
MessageDialog errorDialog = new MessageDialog(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, null)
|
MessageDialog errorDialog = new MessageDialog(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, null)
|
||||||
|
@ -29,5 +31,36 @@ namespace Ryujinx.Ui
|
||||||
{
|
{
|
||||||
CreateDialog("Ryujinx - Error", "Ryujinx has encountered an error", errorMessage);
|
CreateDialog("Ryujinx - Error", "Ryujinx has encountered an error", errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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…
Reference in a new issue