diff options
author | Emmanuel Hansen <emmausssss@gmail.com> | 2022-07-08 18:47:11 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-08 15:47:11 -0300 |
commit | 3af42d6c7e9e71c504b87a7b0f7f960fe83418fb (patch) | |
tree | 2b27f12ee0273d5316229d31383619d915c3210d /Ryujinx.Ava/Ui/Windows/UserProfileWindow.axaml.cs | |
parent | bccf5e8b5a8f3870dbf03bedb0eb46b85b78d5f4 (diff) |
UI - Avalonia Part 3 (#3441)1.1.171
* Add all other windows
* addreesed review
* Prevent "No Update" option from being deleted
* Select no update is the current update is removed from the title update window
* fix amiibo crash
Diffstat (limited to 'Ryujinx.Ava/Ui/Windows/UserProfileWindow.axaml.cs')
-rw-r--r-- | Ryujinx.Ava/Ui/Windows/UserProfileWindow.axaml.cs | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/Ryujinx.Ava/Ui/Windows/UserProfileWindow.axaml.cs b/Ryujinx.Ava/Ui/Windows/UserProfileWindow.axaml.cs new file mode 100644 index 00000000..e78e0384 --- /dev/null +++ b/Ryujinx.Ava/Ui/Windows/UserProfileWindow.axaml.cs @@ -0,0 +1,102 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Interactivity; +using Avalonia.Markup.Xaml; +using Ryujinx.Ava.Common.Locale; +using Ryujinx.Ava.Ui.ViewModels; +using Ryujinx.HLE.FileSystem; +using Ryujinx.HLE.HOS.Services.Account.Acc; +using System.Threading.Tasks; +using UserProfile = Ryujinx.Ava.Ui.Models.UserProfile; + +namespace Ryujinx.Ava.Ui.Windows +{ + public class UserProfileWindow : StyleableWindow + { + private TextBox _nameBox; + + public UserProfileWindow(AccountManager accountManager, ContentManager contentManager, + VirtualFileSystem virtualFileSystem) + { + AccountManager = accountManager; + ContentManager = contentManager; + ViewModel = new UserProfileViewModel(this); + + DataContext = ViewModel; + + InitializeComponent(); +#if DEBUG + this.AttachDevTools(); +#endif + if (contentManager.GetCurrentFirmwareVersion() != null) + { + Task.Run(() => + { + AvatarProfileViewModel.PreloadAvatars(contentManager, virtualFileSystem); + }); + } + + Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance["UserProfileWindowTitle"]; + } + + public UserProfileWindow() + { + ViewModel = new UserProfileViewModel(); + + DataContext = ViewModel; + + InitializeComponent(); +#if DEBUG + this.AttachDevTools(); +#endif + Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance["UserProfileWindowTitle"]; + } + + public AccountManager AccountManager { get; } + public ContentManager ContentManager { get; } + + public UserProfileViewModel ViewModel { get; set; } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + _nameBox = this.FindControl<TextBox>("NameBox"); + } + + private void ProfilesList_DoubleTapped(object sender, RoutedEventArgs e) + { + if (sender is ListBox listBox) + { + int selectedIndex = listBox.SelectedIndex; + + if (selectedIndex >= 0 && selectedIndex < ViewModel.Profiles.Count) + { + ViewModel.SelectedProfile = ViewModel.Profiles[selectedIndex]; + + AccountManager.OpenUser(ViewModel.SelectedProfile.UserId); + + ViewModel.LoadProfiles(); + + foreach (UserProfile profile in ViewModel.Profiles) + { + profile.UpdateState(); + } + } + } + } + + private void CloseButton_OnClick(object sender, RoutedEventArgs e) + { + Close(); + } + + private void SetNameButton_OnClick(object sender, RoutedEventArgs e) + { + if (!string.IsNullOrWhiteSpace(_nameBox.Text)) + { + ViewModel.SelectedProfile.Name = _nameBox.Text; + AccountManager.SetUserName(ViewModel.SelectedProfile.UserId, _nameBox.Text); + } + } + } +}
\ No newline at end of file |