2020-05-03 02:00:53 +00:00
|
|
|
using Gtk;
|
2023-03-04 13:43:08 +00:00
|
|
|
using Ryujinx.Ui.Common.Configuration;
|
2020-05-03 02:00:53 +00:00
|
|
|
using System;
|
2021-01-18 20:33:58 +00:00
|
|
|
using System.Reflection;
|
2020-05-03 02:00:53 +00:00
|
|
|
using GUI = Gtk.Builder.ObjectAttribute;
|
|
|
|
|
2021-01-08 08:14:13 +00:00
|
|
|
namespace Ryujinx.Ui.Widgets
|
2020-05-03 02:00:53 +00:00
|
|
|
{
|
|
|
|
public class ProfileDialog : Dialog
|
|
|
|
{
|
|
|
|
public string FileName { get; private set; }
|
|
|
|
|
|
|
|
#pragma warning disable CS0649, IDE0044
|
|
|
|
[GUI] Entry _profileEntry;
|
|
|
|
[GUI] Label _errorMessage;
|
|
|
|
#pragma warning restore CS0649, IDE0044
|
|
|
|
|
2021-01-08 08:14:13 +00:00
|
|
|
public ProfileDialog() : this(new Builder("Ryujinx.Ui.Widgets.ProfileDialog.glade")) { }
|
2020-05-03 02:00:53 +00:00
|
|
|
|
2022-12-06 22:00:25 +00:00
|
|
|
private ProfileDialog(Builder builder) : base(builder.GetRawOwnedObject("_profileDialog"))
|
2020-05-03 02:00:53 +00:00
|
|
|
{
|
|
|
|
builder.Autoconnect(this);
|
2022-05-15 11:30:15 +00:00
|
|
|
Icon = new Gdk.Pixbuf(Assembly.GetAssembly(typeof(ConfigurationState)), "Ryujinx.Ui.Common.Resources.Logo_Ryujinx.png");
|
2020-05-03 02:00:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void OkToggle_Activated(object sender, EventArgs args)
|
|
|
|
{
|
2021-01-08 08:14:13 +00:00
|
|
|
((ToggleButton)sender).SetStateFlags(StateFlags.Normal, true);
|
2020-05-03 02:00:53 +00:00
|
|
|
|
|
|
|
bool validFileName = true;
|
|
|
|
|
|
|
|
foreach (char invalidChar in System.IO.Path.GetInvalidFileNameChars())
|
|
|
|
{
|
|
|
|
if (_profileEntry.Text.Contains(invalidChar))
|
|
|
|
{
|
|
|
|
validFileName = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (validFileName && !string.IsNullOrEmpty(_profileEntry.Text))
|
|
|
|
{
|
|
|
|
FileName = $"{_profileEntry.Text}.json";
|
|
|
|
|
|
|
|
Respond(ResponseType.Ok);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_errorMessage.Text = "The file name contains invalid characters. Please try again.";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void CancelToggle_Activated(object sender, EventArgs args)
|
|
|
|
{
|
|
|
|
Respond(ResponseType.Cancel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|