aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Ava/Ui/Windows/UserProfileWindow.axaml.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Ava/Ui/Windows/UserProfileWindow.axaml.cs')
-rw-r--r--Ryujinx.Ava/Ui/Windows/UserProfileWindow.axaml.cs102
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