Archived
1
0
Fork 0
forked from Mirror/Ryujinx
This repository has been archived on 2024-10-11. You can view files and clone it, but cannot push or open issues or pull requests.
jinx/Ryujinx/Ui/Widgets/ProfileDialog.cs
riperiperi e211c3f00a
UI: Add Metal surface creation for MoltenVK (#3980)
* Initial implementation of metal surface across UIs

* Fix SDL2 on windows

* Update Ryujinx/Ryujinx.csproj

Co-authored-by: Mary-nyan <thog@protonmail.com>

* Address Feedback

Co-authored-by: Mary-nyan <thog@protonmail.com>
2022-12-06 19:00:25 -03:00

58 lines
No EOL
1.7 KiB
C#

using Gtk;
using System;
using System.Reflection;
using Ryujinx.Ui.Common.Configuration;
using GUI = Gtk.Builder.ObjectAttribute;
namespace Ryujinx.Ui.Widgets
{
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
public ProfileDialog() : this(new Builder("Ryujinx.Ui.Widgets.ProfileDialog.glade")) { }
private ProfileDialog(Builder builder) : base(builder.GetRawOwnedObject("_profileDialog"))
{
builder.Autoconnect(this);
Icon = new Gdk.Pixbuf(Assembly.GetAssembly(typeof(ConfigurationState)), "Ryujinx.Ui.Common.Resources.Logo_Ryujinx.png");
}
private void OkToggle_Activated(object sender, EventArgs args)
{
((ToggleButton)sender).SetStateFlags(StateFlags.Normal, true);
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);
}
}
}