Refactoring of acc:u0 (#701)

* Refactoring of acc:u0

- Move all account things to the account service
- More accurate IAccountServiceForApplication
- Add helper to UInt128

* FIx my engrish

* FIx my engrish #2
This commit is contained in:
Ac_K 2019-06-16 00:35:38 +02:00 committed by Thomas Guillemard
parent d8d5f2cbe7
commit 5c1bc52409
11 changed files with 335 additions and 118 deletions

View file

@ -1,8 +1,6 @@
using Ryujinx.HLE.HOS.Services.Acc;
using Ryujinx.HLE.Utilities;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
namespace Ryujinx.HLE.HOS.SystemState
{
@ -50,21 +48,18 @@ namespace Ryujinx.HLE.HOS.SystemState
public bool InstallContents { get; set; }
private ConcurrentDictionary<string, UserProfile> _profiles;
internal UserProfile LastOpenUser { get; private set; }
public AccountUtils Account { get; private set; }
public SystemStateMgr()
{
SetAudioOutputAsBuiltInSpeaker();
_profiles = new ConcurrentDictionary<string, UserProfile>();
Account = new AccountUtils();
UInt128 defaultUuid = new UInt128("00000000000000000000000000000001");
UInt128 defaultUid = new UInt128("00000000000000000000000000000001");
AddUser(defaultUuid, "Player");
OpenUser(defaultUuid);
Account.AddUser(defaultUid, "Player");
Account.OpenUser(defaultUid);
}
public void SetLanguage(SystemLanguage language)
@ -102,49 +97,6 @@ namespace Ryujinx.HLE.HOS.SystemState
ActiveAudioOutput = AudioOutputs[2];
}
public void AddUser(UInt128 uuid, string name)
{
UserProfile profile = new UserProfile(uuid, name);
_profiles.AddOrUpdate(uuid.ToString(), profile, (key, old) => profile);
}
public void OpenUser(UInt128 uuid)
{
if (_profiles.TryGetValue(uuid.ToString(), out UserProfile profile))
{
(LastOpenUser = profile).AccountState = OpenCloseState.Open;
}
}
public void CloseUser(UInt128 uuid)
{
if (_profiles.TryGetValue(uuid.ToString(), out UserProfile profile))
{
profile.AccountState = OpenCloseState.Closed;
}
}
public int GetUserCount()
{
return _profiles.Count;
}
internal bool TryGetUser(UInt128 uuid, out UserProfile profile)
{
return _profiles.TryGetValue(uuid.ToString(), out profile);
}
internal IEnumerable<UserProfile> GetAllUsers()
{
return _profiles.Values;
}
internal IEnumerable<UserProfile> GetOpenUsers()
{
return _profiles.Values.Where(x => x.AccountState == OpenCloseState.Open);
}
internal static long GetLanguageCode(int index)
{
if ((uint)index >= LanguageCodes.Length)