2019-09-18 17:45:11 -07:00
|
|
|
using Ryujinx.HLE.HOS.Services.Account.Acc;
|
2018-10-07 06:13:46 -07:00
|
|
|
using Ryujinx.HLE.Utilities;
|
2018-04-29 16:18:46 -07:00
|
|
|
using System;
|
|
|
|
|
2018-08-16 16:47:36 -07:00
|
|
|
namespace Ryujinx.HLE.HOS.SystemState
|
2018-04-24 13:14:26 -07:00
|
|
|
{
|
2018-04-29 16:18:46 -07:00
|
|
|
public class SystemStateMgr
|
2018-04-24 13:14:26 -07:00
|
|
|
{
|
2018-04-29 16:18:46 -07: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"
|
|
|
|
};
|
|
|
|
|
2018-04-24 13:14:26 -07:00
|
|
|
internal static string[] AudioOutputs = new string[]
|
|
|
|
{
|
|
|
|
"AudioTvOutput",
|
|
|
|
"AudioStereoJackOutput",
|
|
|
|
"AudioBuiltInSpeakerOutput"
|
|
|
|
};
|
|
|
|
|
2018-04-29 16:18:46 -07:00
|
|
|
internal long DesiredLanguageCode { get; private set; }
|
|
|
|
|
2018-09-19 05:09:49 -07:00
|
|
|
public TitleLanguage DesiredTitleLanguage { get; private set; }
|
|
|
|
|
2018-04-29 16:18:46 -07:00
|
|
|
internal string ActiveAudioOutput { get; private set; }
|
2018-08-14 15:02:42 -07:00
|
|
|
|
|
|
|
public bool DockedMode { get; set; }
|
|
|
|
|
|
|
|
public ColorSet ThemeColor { get; set; }
|
|
|
|
|
2018-11-18 11:37:41 -08:00
|
|
|
public bool InstallContents { get; set; }
|
|
|
|
|
2019-06-15 15:35:38 -07:00
|
|
|
public AccountUtils Account { get; private set; }
|
2018-04-24 13:14:26 -07:00
|
|
|
|
|
|
|
public SystemStateMgr()
|
|
|
|
{
|
|
|
|
SetAudioOutputAsBuiltInSpeaker();
|
2018-08-14 15:02:42 -07:00
|
|
|
|
2019-06-15 15:35:38 -07:00
|
|
|
Account = new AccountUtils();
|
2018-08-14 15:02:42 -07:00
|
|
|
|
2019-06-15 15:35:38 -07:00
|
|
|
UInt128 defaultUid = new UInt128("00000000000000000000000000000001");
|
2018-10-07 06:13:46 -07:00
|
|
|
|
2019-06-15 15:35:38 -07:00
|
|
|
Account.AddUser(defaultUid, "Player");
|
|
|
|
Account.OpenUser(defaultUid);
|
2018-04-24 13:14:26 -07:00
|
|
|
}
|
|
|
|
|
2018-12-06 03:16:24 -08:00
|
|
|
public void SetLanguage(SystemLanguage language)
|
2018-04-29 16:18:46 -07:00
|
|
|
{
|
2018-12-06 03:16:24 -08:00
|
|
|
DesiredLanguageCode = GetLanguageCode((int)language);
|
2018-09-19 05:09:49 -07:00
|
|
|
|
2018-12-27 07:08:34 -08: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-29 16:18:46 -07:00
|
|
|
}
|
|
|
|
|
2018-04-24 13:14:26 -07:00
|
|
|
public void SetAudioOutputAsTv()
|
|
|
|
{
|
|
|
|
ActiveAudioOutput = AudioOutputs[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetAudioOutputAsStereoJack()
|
|
|
|
{
|
|
|
|
ActiveAudioOutput = AudioOutputs[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetAudioOutputAsBuiltInSpeaker()
|
|
|
|
{
|
|
|
|
ActiveAudioOutput = AudioOutputs[2];
|
|
|
|
}
|
2018-04-29 16:18:46 -07:00
|
|
|
|
2018-12-06 03:16:24 -08:00
|
|
|
internal static long GetLanguageCode(int index)
|
2018-04-29 16:18:46 -07:00
|
|
|
{
|
2018-12-06 03:16:24 -08:00
|
|
|
if ((uint)index >= LanguageCodes.Length)
|
2018-04-29 16:18:46 -07:00
|
|
|
{
|
2018-12-06 03:16:24 -08:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(index));
|
2018-04-29 16:18:46 -07:00
|
|
|
}
|
|
|
|
|
2018-12-06 03:16:24 -08:00
|
|
|
long code = 0;
|
|
|
|
int shift = 0;
|
2018-04-29 16:18:46 -07:00
|
|
|
|
2018-12-06 03:16:24 -08:00
|
|
|
foreach (char chr in LanguageCodes[index])
|
2018-04-29 16:18:46 -07:00
|
|
|
{
|
2018-12-06 03:16:24 -08:00
|
|
|
code |= (long)(byte)chr << shift++ * 8;
|
2018-04-29 16:18:46 -07:00
|
|
|
}
|
|
|
|
|
2018-12-06 03:16:24 -08:00
|
|
|
return code;
|
2018-04-29 16:18:46 -07:00
|
|
|
}
|
2018-04-24 13:14:26 -07:00
|
|
|
}
|
2018-08-11 05:12:28 -07:00
|
|
|
}
|