Adds language info to Switch title data (#311)

Shows supported languages in title list
This commit is contained in:
shloop 2024-08-27 18:19:49 -07:00 committed by GitHub
parent 559b8c89f9
commit fefa38ff22
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 34 additions and 4 deletions

View file

@ -133,6 +133,26 @@ public struct ApplicationControlProperty
BrazilianPortuguese = 15 BrazilianPortuguese = 15
} }
public static readonly string[] LanguageCodes =
[
"en-US",
"en-GB",
"ja",
"fr",
"de",
"es-419",
"es",
"it",
"nl",
"fr-CA",
"pt",
"ru",
"ko",
"zh-Hans",
"zh-Hant",
"pt-BR"
];
[SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("ReSharper", "InconsistentNaming")]
public enum Organization public enum Organization
{ {

View file

@ -232,13 +232,20 @@ public class SwitchFs : IDisposable
control.Get.Read(out _, 0, title.Control.ByteSpan).ThrowIfFailure(); control.Get.Read(out _, 0, title.Control.ByteSpan).ThrowIfFailure();
} }
int i = 0;
bool nameSet = false;
foreach (ref readonly ApplicationControlProperty.ApplicationTitle desc in title.Control.Value.Title) foreach (ref readonly ApplicationControlProperty.ApplicationTitle desc in title.Control.Value.Title)
{ {
if (!desc.NameString.IsEmpty()) if (!desc.NameString.IsEmpty())
{ {
title.Name = desc.NameString.ToString(); if (!nameSet)
break; {
title.Name = desc.NameString.ToString();
nameSet = true;
}
title.Languages.Add((ApplicationControlProperty.Language)i);
} }
i++;
} }
} }
} }
@ -360,6 +367,8 @@ public class Title
public SwitchFsNca MainNca { get; internal set; } public SwitchFsNca MainNca { get; internal set; }
public SwitchFsNca ControlNca { get; internal set; } public SwitchFsNca ControlNca { get; internal set; }
public List<ApplicationControlProperty.Language> Languages { get; internal set; } = [];
public long GetSize() public long GetSize()
{ {
return Ncas.Sum(x => x.Nca.Header.NcaSize); return Ncas.Sum(x => x.Nca.Header.NcaSize);

View file

@ -237,7 +237,7 @@ internal static class ProcessSwitchFs
public static string ListTitles(SwitchFs sdfs) public static string ListTitles(SwitchFs sdfs)
{ {
var table = new TableBuilder("Title ID", "Version", "", "Type", "Size", "Display Version", "Name"); var table = new TableBuilder("Title ID", "Version", "", "Type", "Size", "Display Version", "Name", "Languages");
foreach (Title title in sdfs.Titles.Values.OrderBy(x => x.Id)) foreach (Title title in sdfs.Titles.Values.OrderBy(x => x.Id))
{ {
@ -247,7 +247,8 @@ internal static class ProcessSwitchFs
title.Metadata?.Type.Print(), title.Metadata?.Type.Print(),
Utilities.GetBytesReadable(title.GetSize()), Utilities.GetBytesReadable(title.GetSize()),
title.Control.Value.DisplayVersionString.ToString(), title.Control.Value.DisplayVersionString.ToString(),
title.Name); title.Name,
string.Join(',', title.Languages.Select(x => ApplicationControlProperty.LanguageCodes[(int)x])));
} }
return table.Print(); return table.Print();