2019-09-19 02:45:11 +02:00
|
|
|
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
2018-04-30 01:18:46 +02:00
|
|
|
using System;
|
|
|
|
|
2018-08-17 01:47:36 +02:00
|
|
|
namespace Ryujinx.HLE.HOS.SystemState
|
2018-04-24 22:14:26 +02:00
|
|
|
{
|
2018-04-30 01:18:46 +02:00
|
|
|
public class SystemStateMgr
|
2018-04-24 22:14:26 +02:00
|
|
|
{
|
2020-03-01 23:56:02 +01:00
|
|
|
public static readonly UserId DefaultUserId = new UserId("00000000000000010000000000000000");
|
|
|
|
|
2018-04-30 01:18:46 +02:00
|
|
|
internal static string[] LanguageCodes = new string[]
|
|
|
|
{
|
|
|
|
"ja",
|
|
|
|
"en-US",
|
|
|
|
"fr",
|
|
|
|
"de",
|
|
|
|
"it",
|
|
|
|
"es",
|
|
|
|
"zh-CN",
|
|
|
|
"ko",
|
|
|
|
"nl",
|
|
|
|
"pt",
|
|
|
|
"ru",
|
|
|
|
"zh-TW",
|
|
|
|
"en-GB",
|
|
|
|
"fr-CA",
|
|
|
|
"es-419",
|
|
|
|
"zh-Hans",
|
|
|
|
"zh-Hant"
|
|
|
|
};
|
|
|
|
|
2020-05-05 20:50:53 +02:00
|
|
|
internal long DesiredKeyboardLayout { get; private set; }
|
|
|
|
|
2020-05-27 10:40:23 +02:00
|
|
|
internal SystemLanguage DesiredSystemLanguage { get; private set; }
|
|
|
|
|
2018-04-30 01:18:46 +02:00
|
|
|
internal long DesiredLanguageCode { get; private set; }
|
|
|
|
|
2020-03-19 23:37:55 +01:00
|
|
|
internal uint DesiredRegionCode { get; private set; }
|
|
|
|
|
2018-09-19 14:09:49 +02:00
|
|
|
public TitleLanguage DesiredTitleLanguage { get; private set; }
|
|
|
|
|
2018-04-30 01:18:46 +02:00
|
|
|
internal string ActiveAudioOutput { get; private set; }
|
2018-08-15 00:02:42 +02:00
|
|
|
|
|
|
|
public bool DockedMode { get; set; }
|
|
|
|
|
|
|
|
public ColorSet ThemeColor { get; set; }
|
|
|
|
|
2018-11-18 20:37:41 +01:00
|
|
|
public bool InstallContents { get; set; }
|
|
|
|
|
2019-06-16 00:35:38 +02:00
|
|
|
public AccountUtils Account { get; private set; }
|
2018-04-24 22:14:26 +02:00
|
|
|
|
|
|
|
public SystemStateMgr()
|
|
|
|
{
|
2019-06-16 00:35:38 +02:00
|
|
|
Account = new AccountUtils();
|
2018-08-15 00:02:42 +02:00
|
|
|
|
2020-03-01 23:56:02 +01:00
|
|
|
Account.AddUser(DefaultUserId, "Player");
|
|
|
|
Account.OpenUser(DefaultUserId);
|
2020-05-05 20:50:53 +02:00
|
|
|
|
|
|
|
// TODO: Let user specify.
|
|
|
|
DesiredKeyboardLayout = (long)KeyboardLayout.Default;
|
2018-04-24 22:14:26 +02:00
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
public void SetLanguage(SystemLanguage language)
|
2018-04-30 01:18:46 +02:00
|
|
|
{
|
2020-05-27 10:40:23 +02:00
|
|
|
DesiredSystemLanguage = language;
|
|
|
|
DesiredLanguageCode = GetLanguageCode((int)DesiredSystemLanguage);
|
2018-09-19 14:09:49 +02:00
|
|
|
|
2018-12-27 16:08:34 +01:00
|
|
|
switch (language)
|
|
|
|
{
|
|
|
|
case SystemLanguage.Taiwanese:
|
|
|
|
case SystemLanguage.TraditionalChinese:
|
|
|
|
DesiredTitleLanguage = TitleLanguage.Taiwanese;
|
|
|
|
break;
|
|
|
|
case SystemLanguage.Chinese:
|
|
|
|
case SystemLanguage.SimplifiedChinese:
|
|
|
|
DesiredTitleLanguage = TitleLanguage.Chinese;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
DesiredTitleLanguage = Enum.Parse<TitleLanguage>(Enum.GetName(typeof(SystemLanguage), language));
|
|
|
|
break;
|
|
|
|
}
|
2018-04-30 01:18:46 +02:00
|
|
|
}
|
|
|
|
|
2020-05-05 20:50:53 +02:00
|
|
|
public void SetRegion(RegionCode region)
|
2020-03-19 23:37:55 +01:00
|
|
|
{
|
|
|
|
DesiredRegionCode = (uint)region;
|
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
internal static long GetLanguageCode(int index)
|
2018-04-30 01:18:46 +02:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
if ((uint)index >= LanguageCodes.Length)
|
2018-04-30 01:18:46 +02:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(index));
|
2018-04-30 01:18:46 +02:00
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
long code = 0;
|
|
|
|
int shift = 0;
|
2018-04-30 01:18:46 +02:00
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
foreach (char chr in LanguageCodes[index])
|
2018-04-30 01:18:46 +02:00
|
|
|
{
|
2018-12-06 12:16:24 +01:00
|
|
|
code |= (long)(byte)chr << shift++ * 8;
|
2018-04-30 01:18:46 +02:00
|
|
|
}
|
|
|
|
|
2018-12-06 12:16:24 +01:00
|
|
|
return code;
|
2018-04-30 01:18:46 +02:00
|
|
|
}
|
2018-04-24 22:14:26 +02:00
|
|
|
}
|
2018-08-11 14:12:28 +02:00
|
|
|
}
|