account: Adds AccountManager (#2184)

* account: Adds Account Manager

In a way to have Custom User Profiles merged in master faster, this PR adds a `AccountManager` class (based on `AccountUtils` class) and the following changes have been made:
- Adds a "default profile values" which were the old hardcoded ones.
- The image profile is moved to the Account service folder.
- The hardcoded UserId for the savedata is now using the `AccountManager` last opened one.
- The DeviceId in Mii service is changed to the right value (checked by REd sys:set call).

* Fix csproj

* Addresses gdkchan's comments

* Fix UserProfile fields

* Fix mii GetDeviceId()

* Update Ryujinx.HLE.csproj
This commit is contained in:
Ac_K 2021-04-13 03:16:43 +02:00 committed by GitHub
parent 3876f21d40
commit ec72355555
19 changed files with 89 additions and 81 deletions

View file

@ -3,7 +3,6 @@ using ARMeilleure.Translation.PTC;
using Gtk;
using LibHac.Common;
using LibHac.Ns;
using Ryujinx.Audio;
using Ryujinx.Audio.Backends.Dummy;
using Ryujinx.Audio.Backends.OpenAL;
using Ryujinx.Audio.Backends.SoundIo;
@ -17,6 +16,7 @@ using Ryujinx.Graphics.OpenGL;
using Ryujinx.HLE.FileSystem;
using Ryujinx.HLE.FileSystem.Content;
using Ryujinx.HLE.HOS;
using Ryujinx.HLE.HOS.Services.Account.Acc;
using Ryujinx.Modules;
using Ryujinx.Ui.App;
using Ryujinx.Ui.Applet;
@ -42,6 +42,7 @@ namespace Ryujinx.Ui
{
private readonly VirtualFileSystem _virtualFileSystem;
private readonly ContentManager _contentManager;
private readonly AccountManager _accountManager;
private UserChannelPersistence _userChannelPersistence;
@ -135,6 +136,7 @@ namespace Ryujinx.Ui
// Instanciate HLE objects.
_virtualFileSystem = VirtualFileSystem.CreateInstance();
_contentManager = new ContentManager(_virtualFileSystem);
_accountManager = new AccountManager();
_userChannelPersistence = new UserChannelPersistence();
// Instanciate GUI objects.
@ -344,6 +346,7 @@ namespace Ryujinx.Ui
_emulationContext = new HLE.Switch(
_virtualFileSystem,
_contentManager,
_accountManager,
_userChannelPersistence,
renderer,
deviceDriver,
@ -942,7 +945,7 @@ namespace Ryujinx.Ui
BlitStruct<ApplicationControlProperty> controlData = (BlitStruct<ApplicationControlProperty>)_tableStore.GetValue(treeIter, 10);
_ = new GameTableContextMenu(this, _virtualFileSystem, titleFilePath, titleName, titleId, controlData);
_ = new GameTableContextMenu(this, _virtualFileSystem, _accountManager, titleFilePath, titleName, titleId, controlData);
}
private void Load_Application_File(object sender, EventArgs args)

View file

@ -13,6 +13,7 @@ using Ryujinx.Common.Configuration;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.FileSystem;
using Ryujinx.HLE.HOS;
using Ryujinx.HLE.HOS.Services.Account.Acc;
using Ryujinx.Ui.Helper;
using Ryujinx.Ui.Windows;
using System;
@ -31,6 +32,7 @@ namespace Ryujinx.Ui.Widgets
{
private readonly MainWindow _parent;
private readonly VirtualFileSystem _virtualFileSystem;
private readonly AccountManager _accountManager;
private readonly BlitStruct<ApplicationControlProperty> _controlData;
private readonly string _titleFilePath;
@ -41,13 +43,14 @@ namespace Ryujinx.Ui.Widgets
private MessageDialog _dialog;
private bool _cancel;
public GameTableContextMenu(MainWindow parent, VirtualFileSystem virtualFileSystem, string titleFilePath, string titleName, string titleId, BlitStruct<ApplicationControlProperty> controlData)
public GameTableContextMenu(MainWindow parent, VirtualFileSystem virtualFileSystem, AccountManager accountManager, string titleFilePath, string titleName, string titleId, BlitStruct<ApplicationControlProperty> controlData)
{
_parent = parent;
InitializeComponent();
_virtualFileSystem = virtualFileSystem;
_accountManager = accountManager;
_titleFilePath = titleFilePath;
_titleName = titleName;
_titleIdText = titleId;
@ -429,7 +432,7 @@ namespace Ryujinx.Ui.Widgets
private void OpenSaveUserDir_Clicked(object sender, EventArgs args)
{
SaveDataFilter saveDataFilter = new SaveDataFilter();
saveDataFilter.SetUserId(new UserId(1, 0)); // TODO: Remove Hardcoded value.
saveDataFilter.SetUserId(new LibHac.Fs.UserId((ulong)_accountManager.LastOpenedUser.UserId.High, (ulong)_accountManager.LastOpenedUser.UserId.Low));
OpenSaveDir(saveDataFilter);
}