From ec50f297336fb8448e2080378aeb9f14161ccf4b Mon Sep 17 00:00:00 2001 From: Jacobwasbeast Date: Sat, 18 Jan 2025 17:18:30 -0600 Subject: [PATCH] Added Cancel and Clean up --- .../PlayerSelect/PlayerSelectApplet.cs | 21 ++++++++++++++----- src/Ryujinx/UI/Applet/AvaHostUIHandler.cs | 17 ++++++--------- .../UI/Applet/UserSelectorDialog.axaml.cs | 15 ++++++------- 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/src/Ryujinx.HLE/HOS/Applets/PlayerSelect/PlayerSelectApplet.cs b/src/Ryujinx.HLE/HOS/Applets/PlayerSelect/PlayerSelectApplet.cs index e4c79e2a6..cf99b0e7a 100644 --- a/src/Ryujinx.HLE/HOS/Applets/PlayerSelect/PlayerSelectApplet.cs +++ b/src/Ryujinx.HLE/HOS/Applets/PlayerSelect/PlayerSelectApplet.cs @@ -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(); + } } } diff --git a/src/Ryujinx/UI/Applet/AvaHostUIHandler.cs b/src/Ryujinx/UI/Applet/AvaHostUIHandler.cs index f5d5111d6..0204c2259 100644 --- a/src/Ryujinx/UI/Applet/AvaHostUIHandler.cs +++ b/src/Ryujinx/UI/Applet/AvaHostUIHandler.cs @@ -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()) diff --git a/src/Ryujinx/UI/Applet/UserSelectorDialog.axaml.cs b/src/Ryujinx/UI/Applet/UserSelectorDialog.axaml.cs index e654c6b99..3df920d48 100644 --- a/src/Ryujinx/UI/Applet/UserSelectorDialog.axaml.cs +++ b/src/Ryujinx/UI/Applet/UserSelectorDialog.axaml.cs @@ -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;