Added Cancel and Clean up

This commit is contained in:
Jacobwasbeast 2025-01-18 17:18:30 -06:00
parent d0b45244d3
commit ec50f29733
3 changed files with 30 additions and 23 deletions

View File

@ -1,5 +1,3 @@
using Ryujinx.Common;
using Ryujinx.Common.Logging;
using Ryujinx.Common.Memory;
using Ryujinx.HLE.HOS.Services.Account.Acc;
using Ryujinx.HLE.HOS.Services.Am.AppletAE;
@ -30,10 +28,13 @@ namespace Ryujinx.HLE.HOS.Applets
_interactiveSession = interactiveSession;
UserProfile selected = _system.Device.UIHandler.ShowPlayerSelectDialog();
if (selected.UserId == new UserId("00000000000000000000000000000080"))
if (selected == null)
{
_normalSession.Push(BuildResponse());
}
else if (selected.UserId == new UserId("00000000000000000000000000000080"))
{
_normalSession.Push(BuildGuestResponse());
Logger.Info?.Print(LogClass.Service,$"[Player Select] Guest Selected");
}
else
{
@ -62,10 +63,20 @@ namespace Ryujinx.HLE.HOS.Applets
{
using MemoryStream stream = MemoryStreamManager.Shared.GetStream();
using BinaryWriter writer = new(stream);
writer.Write(new byte());
return stream.ToArray();
}
private byte[] BuildResponse()
{
using MemoryStream stream = MemoryStreamManager.Shared.GetStream();
using BinaryWriter writer = new(stream);
writer.Write((ulong)PlayerSelectResult.Failure);
return stream.ToArray();
}
}
}

View File

@ -1,6 +1,4 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Media.Imaging;
using Avalonia.Threading;
using FluentAvalonia.UI.Controls;
using Gommon;
@ -282,16 +280,9 @@ namespace Ryujinx.Ava.UI.Applet
Profiles.Add(new Models.UserProfile(guest, nav));
var content = new UserSelectorDialog(Profiles);
(UserId id, _) = await UserSelectorDialog.ShowInputDialog(content);
(UserId id, _) = await UserSelectorDialog.ShowInputDialog(content, _parent.AccountManager.LastOpenedUser);
if (id != UserId.Null)
{
selected = id;
}
else
{
selected = _parent.AccountManager.LastOpenedUser.UserId;
}
selected = id;
dialogCloseEvent.Set();
});
@ -303,6 +294,10 @@ namespace Ryujinx.Ava.UI.Applet
{
profile = guest;
}
else if (selected == UserId.Null)
{
profile = null;
}
else
{
foreach (UserProfile p in _parent.AccountManager.GetAllUsers())

View File

@ -1,22 +1,17 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using FluentAvalonia.UI.Controls;
using FluentAvalonia.UI.Navigation;
using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.UI.Controls;
using Ryujinx.Ava.UI.Helpers;
using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Applets;
using Ryujinx.HLE.HOS.Services.Account.Acc;
using shaderc;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Button = Avalonia.Controls.Button;
using UserProfile = Ryujinx.Ava.UI.Models.UserProfile;
using UserProfileSft = Ryujinx.HLE.HOS.Services.Account.Acc.UserProfile;
@ -91,14 +86,15 @@ namespace Ryujinx.Ava.UI.Applet
}
}
public static async Task<(UserId id, bool result)> ShowInputDialog(UserSelectorDialog content)
public static async Task<(UserId id, bool result)> ShowInputDialog(UserSelectorDialog content, UserProfileSft accountManagerLastOpenedUser)
{
content._selectedUserId = accountManagerLastOpenedUser.UserId;
ContentDialog contentDialog = new()
{
Title = LocaleManager.Instance[LocaleKeys.UserProfileWindowTitle],
PrimaryButtonText = LocaleManager.Instance[LocaleKeys.Continue],
SecondaryButtonText = string.Empty,
CloseButtonText = string.Empty,
CloseButtonText = LocaleManager.Instance[LocaleKeys.Cancel],
Content = content,
Padding = new Thickness(0)
};
@ -114,6 +110,11 @@ namespace Ryujinx.Ava.UI.Applet
result = view?._selectedUserId ?? UserId.Null;
input = true;
}
else
{
result = UserId.Null;
input = false;
}
}
contentDialog.Closed += Handler;