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