2022-07-24 13:38:38 -04:00
|
|
|
using Avalonia;
|
|
|
|
using Avalonia.Controls;
|
|
|
|
using FluentAvalonia.UI.Controls;
|
2022-12-02 08:16:43 -05:00
|
|
|
using LibHac;
|
2022-07-24 13:38:38 -04:00
|
|
|
using Ryujinx.Ava.Common.Locale;
|
2022-12-29 09:24:05 -05:00
|
|
|
using Ryujinx.Ava.UI.ViewModels;
|
2022-07-24 13:38:38 -04:00
|
|
|
using Ryujinx.HLE.FileSystem;
|
|
|
|
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
|
|
|
using System;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
2022-12-29 09:24:05 -05:00
|
|
|
namespace Ryujinx.Ava.UI.Controls
|
2022-07-24 13:38:38 -04:00
|
|
|
{
|
|
|
|
public partial class NavigationDialogHost : UserControl
|
|
|
|
{
|
|
|
|
public AccountManager AccountManager { get; }
|
|
|
|
public ContentManager ContentManager { get; }
|
2022-12-02 08:16:43 -05:00
|
|
|
public VirtualFileSystem VirtualFileSystem { get; }
|
|
|
|
public HorizonClient HorizonClient { get; }
|
2022-07-24 13:38:38 -04:00
|
|
|
public UserProfileViewModel ViewModel { get; set; }
|
|
|
|
|
|
|
|
public NavigationDialogHost()
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
}
|
|
|
|
|
|
|
|
public NavigationDialogHost(AccountManager accountManager, ContentManager contentManager,
|
2022-12-02 08:16:43 -05:00
|
|
|
VirtualFileSystem virtualFileSystem, HorizonClient horizonClient)
|
2022-07-24 13:38:38 -04:00
|
|
|
{
|
|
|
|
AccountManager = accountManager;
|
|
|
|
ContentManager = contentManager;
|
2022-12-02 08:16:43 -05:00
|
|
|
VirtualFileSystem = virtualFileSystem;
|
|
|
|
HorizonClient = horizonClient;
|
2022-07-24 13:38:38 -04:00
|
|
|
ViewModel = new UserProfileViewModel(this);
|
|
|
|
|
|
|
|
|
|
|
|
if (contentManager.GetCurrentFirmwareVersion() != null)
|
|
|
|
{
|
|
|
|
Task.Run(() =>
|
|
|
|
{
|
|
|
|
AvatarProfileViewModel.PreloadAvatars(contentManager, virtualFileSystem);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
InitializeComponent();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void GoBack(object parameter = null)
|
|
|
|
{
|
|
|
|
if (ContentFrame.BackStack.Count > 0)
|
|
|
|
{
|
|
|
|
ContentFrame.GoBack();
|
|
|
|
}
|
|
|
|
|
|
|
|
ViewModel.LoadProfiles();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Navigate(Type sourcePageType, object parameter)
|
|
|
|
{
|
|
|
|
ContentFrame.Navigate(sourcePageType, parameter);
|
|
|
|
}
|
|
|
|
|
2022-12-02 08:16:43 -05:00
|
|
|
public static async Task Show(AccountManager ownerAccountManager, ContentManager ownerContentManager,
|
|
|
|
VirtualFileSystem ownerVirtualFileSystem, HorizonClient ownerHorizonClient)
|
2022-07-24 13:38:38 -04:00
|
|
|
{
|
2022-12-02 08:16:43 -05:00
|
|
|
var content = new NavigationDialogHost(ownerAccountManager, ownerContentManager, ownerVirtualFileSystem, ownerHorizonClient);
|
2022-07-24 13:38:38 -04:00
|
|
|
ContentDialog contentDialog = new ContentDialog
|
|
|
|
{
|
|
|
|
Title = LocaleManager.Instance["UserProfileWindowTitle"],
|
|
|
|
PrimaryButtonText = "",
|
|
|
|
SecondaryButtonText = "",
|
|
|
|
CloseButtonText = LocaleManager.Instance["UserProfilesClose"],
|
|
|
|
Content = content,
|
|
|
|
Padding = new Thickness(0)
|
|
|
|
};
|
|
|
|
|
|
|
|
contentDialog.Closed += (sender, args) =>
|
|
|
|
{
|
|
|
|
content.ViewModel.Dispose();
|
|
|
|
};
|
|
|
|
|
|
|
|
await contentDialog.ShowAsync();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
|
|
|
{
|
|
|
|
base.OnAttachedToVisualTree(e);
|
|
|
|
|
|
|
|
Navigate(typeof(UserSelector), this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|