2018-04-29 20:18:46 -03:00
|
|
|
using System;
|
|
|
|
|
2018-08-16 20:47:36 -03:00
|
|
|
namespace Ryujinx.HLE.HOS.SystemState
|
2018-04-24 17:14:26 -03:00
|
|
|
{
|
2018-04-29 20:18:46 -03:00
|
|
|
public class SystemStateMgr
|
2018-04-24 17:14:26 -03:00
|
|
|
{
|
2018-04-29 20:18:46 -03: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",
|
2021-10-28 18:06:45 -03:00
|
|
|
"zh-Hant",
|
|
|
|
"pt-BR"
|
2018-04-29 20:18:46 -03:00
|
|
|
};
|
|
|
|
|
2020-05-05 11:50:53 -07:00
|
|
|
internal long DesiredKeyboardLayout { get; private set; }
|
|
|
|
|
2020-05-27 14:10:23 +05:30
|
|
|
internal SystemLanguage DesiredSystemLanguage { get; private set; }
|
|
|
|
|
2018-04-29 20:18:46 -03:00
|
|
|
internal long DesiredLanguageCode { get; private set; }
|
|
|
|
|
2020-03-19 23:37:55 +01:00
|
|
|
internal uint DesiredRegionCode { get; private set; }
|
|
|
|
|
2018-09-19 15:09:49 +03:00
|
|
|
public TitleLanguage DesiredTitleLanguage { get; private set; }
|
|
|
|
|
2018-08-14 19:02:42 -03:00
|
|
|
public bool DockedMode { get; set; }
|
|
|
|
|
|
|
|
public ColorSet ThemeColor { get; set; }
|
|
|
|
|
2021-06-24 01:18:36 +02:00
|
|
|
public string DeviceNickName { get; set; }
|
2018-11-18 21:37:41 +02:00
|
|
|
|
2018-04-24 17:14:26 -03:00
|
|
|
public SystemStateMgr()
|
|
|
|
{
|
2021-06-24 01:18:36 +02:00
|
|
|
// TODO: Let user specify fields.
|
2020-05-05 11:50:53 -07:00
|
|
|
DesiredKeyboardLayout = (long)KeyboardLayout.Default;
|
2021-06-24 01:18:36 +02:00
|
|
|
DeviceNickName = "Ryujinx's Switch";
|
2018-04-24 17:14:26 -03:00
|
|
|
}
|
|
|
|
|
2018-12-06 05:16:24 -06:00
|
|
|
public void SetLanguage(SystemLanguage language)
|
2018-04-29 20:18:46 -03:00
|
|
|
{
|
2020-05-27 14:10:23 +05:30
|
|
|
DesiredSystemLanguage = language;
|
2021-06-24 01:18:36 +02:00
|
|
|
DesiredLanguageCode = GetLanguageCode((int)DesiredSystemLanguage);
|
2018-09-19 15:09:49 +03:00
|
|
|
|
2021-06-24 01:18:36 +02:00
|
|
|
DesiredTitleLanguage = language switch
|
2018-12-27 23:08:34 +08:00
|
|
|
{
|
2021-07-06 20:17:06 +02:00
|
|
|
SystemLanguage.Taiwanese or
|
2022-12-22 04:20:37 +08:00
|
|
|
SystemLanguage.TraditionalChinese => TitleLanguage.TraditionalChinese,
|
2021-06-24 01:18:36 +02:00
|
|
|
SystemLanguage.Chinese or
|
2022-12-22 04:20:37 +08:00
|
|
|
SystemLanguage.SimplifiedChinese => TitleLanguage.SimplifiedChinese,
|
2022-02-13 14:50:07 +01:00
|
|
|
_ => Enum.Parse<TitleLanguage>(Enum.GetName<SystemLanguage>(language)),
|
2021-06-24 01:18:36 +02:00
|
|
|
};
|
2018-04-29 20:18:46 -03:00
|
|
|
}
|
|
|
|
|
2020-05-05 11:50:53 -07:00
|
|
|
public void SetRegion(RegionCode region)
|
2020-03-19 23:37:55 +01:00
|
|
|
{
|
|
|
|
DesiredRegionCode = (uint)region;
|
|
|
|
}
|
|
|
|
|
2018-12-06 05:16:24 -06:00
|
|
|
internal static long GetLanguageCode(int index)
|
2018-04-29 20:18:46 -03:00
|
|
|
{
|
2018-12-06 05:16:24 -06:00
|
|
|
if ((uint)index >= LanguageCodes.Length)
|
2018-04-29 20:18:46 -03:00
|
|
|
{
|
2018-12-06 05:16:24 -06:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(index));
|
2018-04-29 20:18:46 -03:00
|
|
|
}
|
|
|
|
|
2018-12-06 05:16:24 -06:00
|
|
|
long code = 0;
|
|
|
|
int shift = 0;
|
2018-04-29 20:18:46 -03:00
|
|
|
|
2018-12-06 05:16:24 -06:00
|
|
|
foreach (char chr in LanguageCodes[index])
|
2018-04-29 20:18:46 -03:00
|
|
|
{
|
2018-12-06 05:16:24 -06:00
|
|
|
code |= (long)(byte)chr << shift++ * 8;
|
2018-04-29 20:18:46 -03:00
|
|
|
}
|
|
|
|
|
2018-12-06 05:16:24 -06:00
|
|
|
return code;
|
2018-04-29 20:18:46 -03:00
|
|
|
}
|
2018-04-24 17:14:26 -03:00
|
|
|
}
|
2021-06-24 01:18:36 +02:00
|
|
|
}
|