Fix GetDesiredLanguage and expose a way to set the desired language, default to english

This commit is contained in:
gdkchan 2018-04-29 20:18:46 -03:00
parent f73a182b20
commit 071754aaeb
5 changed files with 83 additions and 63 deletions

View file

@ -1,7 +1,30 @@
using System;
namespace Ryujinx.Core.OsHle
{
class SystemStateMgr
public class SystemStateMgr
{
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"
};
internal static string[] AudioOutputs = new string[]
{
"AudioTvOutput",
@ -9,13 +32,22 @@ namespace Ryujinx.Core.OsHle
"AudioBuiltInSpeakerOutput"
};
public string ActiveAudioOutput { get; private set; }
internal long DesiredLanguageCode { get; private set; }
internal string ActiveAudioOutput { get; private set; }
public SystemStateMgr()
{
SetLanguage(SystemLanguage.AmericanEnglish);
SetAudioOutputAsBuiltInSpeaker();
}
public void SetLanguage(SystemLanguage Language)
{
DesiredLanguageCode = GetLanguageCode((int)Language);
}
public void SetAudioOutputAsTv()
{
ActiveAudioOutput = AudioOutputs[0];
@ -30,5 +62,23 @@ namespace Ryujinx.Core.OsHle
{
ActiveAudioOutput = AudioOutputs[2];
}
internal static long GetLanguageCode(int Index)
{
if ((uint)Index >= LanguageCodes.Length)
{
throw new ArgumentOutOfRangeException(nameof(Index));
}
long Code = 0;
int Shift = 0;
foreach (char Chr in LanguageCodes[Index])
{
Code |= (long)(byte)Chr << Shift++ * 8;
}
return Code;
}
}
}