forked from MeloNX/MeloNX
* dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Address dotnet format CA1816 warnings * Address or silence dotnet format CA2208 warnings * Address or silence dotnet format CA1806 and a few CA1854 warnings * Address dotnet format CA1822 warnings * Make dotnet format succeed in style mode * Address dotnet format CA2208 warnings properly * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Format if-blocks correctly * Another rebase, another dotnet format run * Run dotnet format whitespace after rebase * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Add comments to disabled warnings * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * First dotnet format pass * Fix build issues * Apply suggestions from code review Co-authored-by: Ac_K <Acoustik666@gmail.com> * Second dotnet format pass * Update src/Ryujinx/Modules/Updater/Updater.cs Co-authored-by: Ac_K <Acoustik666@gmail.com> * Add trailing commas and improve formatting * Fix formatting and naming issues * Rename nvStutterWorkaround to nvidiaStutterWorkaround * Use using declarations and extend resource lifetimes * Fix GTK issues * Add formatting for generated files * Add trailing commas --------- Co-authored-by: Ac_K <Acoustik666@gmail.com>
115 lines
4.1 KiB
C#
115 lines
4.1 KiB
C#
using Gtk;
|
|
using Ryujinx.Common.Logging;
|
|
using Ryujinx.Ui.Common.Configuration;
|
|
using System.Collections.Generic;
|
|
using System.Reflection;
|
|
|
|
namespace Ryujinx.Ui.Widgets
|
|
{
|
|
internal class GtkDialog : MessageDialog
|
|
{
|
|
private static bool _isChoiceDialogOpen;
|
|
|
|
private GtkDialog(string title, string mainText, string secondaryText, MessageType messageType = MessageType.Other, ButtonsType buttonsType = ButtonsType.Ok)
|
|
: base(null, DialogFlags.Modal, messageType, buttonsType, null)
|
|
{
|
|
Title = title;
|
|
Icon = new Gdk.Pixbuf(Assembly.GetAssembly(typeof(ConfigurationState)), "Ryujinx.Ui.Common.Resources.Logo_Ryujinx.png");
|
|
Text = mainText;
|
|
SecondaryText = secondaryText;
|
|
WindowPosition = WindowPosition.Center;
|
|
SecondaryUseMarkup = true;
|
|
|
|
Response += GtkDialog_Response;
|
|
|
|
SetSizeRequest(200, 20);
|
|
}
|
|
|
|
private void GtkDialog_Response(object sender, ResponseArgs args)
|
|
{
|
|
Dispose();
|
|
}
|
|
|
|
internal static void CreateInfoDialog(string mainText, string secondaryText)
|
|
{
|
|
new GtkDialog("Ryujinx - Info", mainText, secondaryText, MessageType.Info).Run();
|
|
}
|
|
|
|
internal static void CreateUpdaterInfoDialog(string mainText, string secondaryText)
|
|
{
|
|
new GtkDialog("Ryujinx - Updater", mainText, secondaryText, MessageType.Info).Run();
|
|
}
|
|
|
|
internal static MessageDialog CreateWaitingDialog(string mainText, string secondaryText)
|
|
{
|
|
return new GtkDialog("Ryujinx - Waiting", mainText, secondaryText, MessageType.Info, ButtonsType.None);
|
|
}
|
|
|
|
internal static void CreateWarningDialog(string mainText, string secondaryText)
|
|
{
|
|
new GtkDialog("Ryujinx - Warning", mainText, secondaryText, MessageType.Warning).Run();
|
|
}
|
|
|
|
internal static void CreateErrorDialog(string errorMessage)
|
|
{
|
|
Logger.Error?.Print(LogClass.Application, errorMessage);
|
|
|
|
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);
|
|
}
|
|
|
|
internal static bool CreateChoiceDialog(string title, string mainText, string secondaryText)
|
|
{
|
|
if (_isChoiceDialogOpen)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
_isChoiceDialogOpen = true;
|
|
|
|
ResponseType response = (ResponseType)new GtkDialog(title, mainText, secondaryText, MessageType.Question, ButtonsType.YesNo).Run();
|
|
|
|
_isChoiceDialogOpen = false;
|
|
|
|
return response == ResponseType.Yes;
|
|
}
|
|
|
|
internal static ResponseType CreateCustomDialog(string title, string mainText, string secondaryText, Dictionary<int, string> buttons, MessageType messageType = MessageType.Other)
|
|
{
|
|
GtkDialog gtkDialog = new(title, mainText, secondaryText, messageType, ButtonsType.None);
|
|
|
|
foreach (var button in buttons)
|
|
{
|
|
gtkDialog.AddButton(button.Value, button.Key);
|
|
}
|
|
|
|
return (ResponseType)gtkDialog.Run();
|
|
}
|
|
|
|
internal static string CreateInputDialog(Window parent, string title, string mainText, uint inputMax)
|
|
{
|
|
GtkInputDialog gtkDialog = new(parent, title, mainText, inputMax);
|
|
ResponseType response = (ResponseType)gtkDialog.Run();
|
|
string responseText = gtkDialog.InputEntry.Text.TrimEnd();
|
|
|
|
gtkDialog.Dispose();
|
|
|
|
if (response == ResponseType.Ok)
|
|
{
|
|
return responseText;
|
|
}
|
|
|
|
return "";
|
|
}
|
|
|
|
internal static bool CreateExitDialog()
|
|
{
|
|
return CreateChoiceDialog("Ryujinx - Exit", "Are you sure you want to close Ryujinx?", "All unsaved data will be lost!");
|
|
}
|
|
}
|
|
}
|