aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx
diff options
context:
space:
mode:
authorAc_K <Acoustik666@gmail.com>2020-09-28 00:00:38 +0200
committerGitHub <noreply@github.com>2020-09-28 00:00:38 +0200
commit4f65043ad77dcc37d9195b2a5e976d102421b82a (patch)
treead9ff1ed1a672263a419843371e732b01fa3a811 /Ryujinx
parentf89b754abb3d721c09ba6ab00f7906d2d5ccb02b (diff)
Basic impl of Error Applet (#1551)
Diffstat (limited to 'Ryujinx')
-rw-r--r--Ryujinx/Ui/ErrorAppletDialog.cs32
-rw-r--r--Ryujinx/Ui/GtkHostUiHandler.cs51
2 files changed, 83 insertions, 0 deletions
diff --git a/Ryujinx/Ui/ErrorAppletDialog.cs b/Ryujinx/Ui/ErrorAppletDialog.cs
new file mode 100644
index 00000000..f7a548b3
--- /dev/null
+++ b/Ryujinx/Ui/ErrorAppletDialog.cs
@@ -0,0 +1,32 @@
+using Gtk;
+using System.Reflection;
+
+namespace Ryujinx.Ui
+{
+ internal class ErrorAppletDialog : MessageDialog
+ {
+ internal static bool _isExitDialogOpen = false;
+
+ public ErrorAppletDialog(Window parentWindow, DialogFlags dialogFlags, MessageType messageType, string[] buttons) : base(parentWindow, dialogFlags, messageType, ButtonsType.None, null)
+ {
+ Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.Icon.png");
+
+ int responseId = 0;
+
+ if (buttons != null)
+ {
+ foreach (string buttonText in buttons)
+ {
+ AddButton(buttonText, responseId);
+ responseId++;
+ }
+ }
+ else
+ {
+ AddButton("OK", 0);
+ }
+
+ ShowAll();
+ }
+ }
+} \ No newline at end of file
diff --git a/Ryujinx/Ui/GtkHostUiHandler.cs b/Ryujinx/Ui/GtkHostUiHandler.cs
index fd193dd7..12ba81c4 100644
--- a/Ryujinx/Ui/GtkHostUiHandler.cs
+++ b/Ryujinx/Ui/GtkHostUiHandler.cs
@@ -128,5 +128,56 @@ namespace Ryujinx.Ui
device.UserChannelPersistence.ExecuteProgram(kind, value);
MainWindow.GlWidget?.Exit();
}
+
+ public bool DisplayErrorAppletDialog(string title, string message, string[] buttons)
+ {
+ ManualResetEvent dialogCloseEvent = new ManualResetEvent(false);
+ bool showDetails = false;
+
+ Application.Invoke(delegate
+ {
+ try
+ {
+ ErrorAppletDialog msgDialog = new ErrorAppletDialog(_parent, DialogFlags.DestroyWithParent, MessageType.Error, buttons)
+ {
+ Title = title,
+ Text = message,
+ UseMarkup = true,
+ WindowPosition = WindowPosition.CenterAlways
+ };
+
+ msgDialog.SetDefaultSize(400, 0);
+
+ msgDialog.Response += (object o, ResponseArgs args) =>
+ {
+ if (buttons != null)
+ {
+ if (buttons.Length > 1)
+ {
+ if (args.ResponseId != (ResponseType)(buttons.Length - 1))
+ {
+ showDetails = true;
+ }
+ }
+ }
+
+ dialogCloseEvent.Set();
+ msgDialog?.Dispose();
+ };
+
+ msgDialog.Show();
+ }
+ catch (Exception e)
+ {
+ Logger.Error?.Print(LogClass.Application, $"Error displaying ErrorApplet Dialog: {e}");
+
+ dialogCloseEvent.Set();
+ }
+ });
+
+ dialogCloseEvent.WaitOne();
+
+ return showDetails;
+ }
}
}