2019-11-28 23:32:51 -05:00
|
|
|
using Gtk;
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
|
|
namespace Ryujinx.Ui
|
|
|
|
{
|
2020-05-02 22:00:53 -04:00
|
|
|
internal class GtkDialog : MessageDialog
|
2019-11-28 23:32:51 -05:00
|
|
|
{
|
2020-03-29 08:47:37 -04:00
|
|
|
internal static bool _isExitDialogOpen = false;
|
|
|
|
|
2020-05-02 22:00:53 -04:00
|
|
|
private GtkDialog(string title, string mainText, string secondaryText,
|
|
|
|
MessageType messageType = MessageType.Other, ButtonsType buttonsType = ButtonsType.Ok) : base(null, DialogFlags.Modal, messageType, buttonsType, null)
|
2019-11-28 23:32:51 -05:00
|
|
|
{
|
2020-05-02 22:00:53 -04:00
|
|
|
Title = title;
|
|
|
|
Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.Icon.png");
|
|
|
|
Text = mainText;
|
|
|
|
SecondaryText = secondaryText;
|
|
|
|
WindowPosition = WindowPosition.Center;
|
|
|
|
Response += GtkDialog_Response;
|
|
|
|
|
|
|
|
SetSizeRequest(100, 20);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void GtkDialog_Response(object sender, ResponseArgs args)
|
|
|
|
{
|
|
|
|
Dispose();
|
2019-11-28 23:32:51 -05:00
|
|
|
}
|
2020-02-06 06:38:24 -05:00
|
|
|
|
2020-05-02 22:00:53 -04:00
|
|
|
internal static void CreateInfoDialog(string title, string mainText, string secondaryText)
|
2020-02-06 06:38:24 -05:00
|
|
|
{
|
2020-05-02 22:00:53 -04:00
|
|
|
new GtkDialog(title, mainText, secondaryText, MessageType.Info).Run();
|
|
|
|
}
|
|
|
|
|
|
|
|
internal static void CreateWarningDialog(string mainText, string secondaryText)
|
|
|
|
{
|
|
|
|
new GtkDialog("Ryujinx - Warning", mainText, secondaryText, MessageType.Warning).Run();
|
2020-02-06 06:38:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
internal static void CreateErrorDialog(string errorMessage)
|
|
|
|
{
|
2020-05-02 22:00:53 -04:00
|
|
|
new GtkDialog("Ryujinx - Error", "Ryujinx has encountered an error", errorMessage, MessageType.Error).Run();
|
|
|
|
}
|
|
|
|
|
|
|
|
internal static MessageDialog CreateConfirmationDialog(string mainText, string secondaryText = "")
|
|
|
|
{
|
|
|
|
return new GtkDialog("Ryujinx - Confirmation", mainText, secondaryText, MessageType.Question, ButtonsType.YesNo);
|
2020-02-06 06:38:24 -05:00
|
|
|
}
|
2020-03-29 08:47:37 -04:00
|
|
|
|
|
|
|
internal static bool CreateExitDialog()
|
|
|
|
{
|
|
|
|
if (_isExitDialogOpen)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
_isExitDialogOpen = true;
|
2020-05-02 22:00:53 -04:00
|
|
|
ResponseType res = (ResponseType)new GtkDialog("Ryujinx - Exit", "Are you sure you want to stop emulation?",
|
|
|
|
"All unsaved data will be lost", MessageType.Question, ButtonsType.YesNo).Run();
|
2020-03-29 08:47:37 -04:00
|
|
|
_isExitDialogOpen = false;
|
|
|
|
|
2020-05-02 22:00:53 -04:00
|
|
|
return res == ResponseType.Yes;
|
2020-03-29 08:47:37 -04:00
|
|
|
}
|
2019-11-28 23:32:51 -05:00
|
|
|
}
|
2020-05-02 22:00:53 -04:00
|
|
|
}
|