mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Read nacp display name and version
This commit is contained in:
parent
1df1ce7bcc
commit
d5ddde4909
3 changed files with 55 additions and 2 deletions
|
@ -129,7 +129,7 @@ namespace hactoolnet
|
|||
{
|
||||
foreach (var title in sdfs.Titles.Values.OrderBy(x => x.Id))
|
||||
{
|
||||
Console.WriteLine(title.Name);
|
||||
Console.WriteLine($"{title.Name} {title.Control?.Version}");
|
||||
Console.WriteLine($"{title.Id:X16} v{title.Version.Version} ({title.Version}) {title.Metadata.Type}");
|
||||
|
||||
foreach (var content in title.Metadata.ContentEntries)
|
||||
|
|
41
libhac/Nacp.cs
Normal file
41
libhac/Nacp.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace libhac
|
||||
{
|
||||
public class Nacp
|
||||
{
|
||||
public NacpLang[] Languages { get; } = new NacpLang[0x10];
|
||||
public string Version { get; }
|
||||
|
||||
public Nacp(BinaryReader reader)
|
||||
{
|
||||
var start = reader.BaseStream.Position;
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
Languages[i] = new NacpLang(reader);
|
||||
}
|
||||
|
||||
reader.BaseStream.Position = start + 0x3060;
|
||||
Version = reader.ReadUtf8Z();
|
||||
}
|
||||
}
|
||||
|
||||
public class NacpLang
|
||||
{
|
||||
public string Title { get; }
|
||||
public string Developer { get; }
|
||||
|
||||
public NacpLang(BinaryReader reader)
|
||||
{
|
||||
var start = reader.BaseStream.Position;
|
||||
Title = reader.ReadUtf8Z();
|
||||
reader.BaseStream.Position = start + 0x200;
|
||||
Developer = reader.ReadUtf8Z();
|
||||
reader.BaseStream.Position = start + 0x300;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
|
@ -108,7 +109,16 @@ namespace libhac
|
|||
File.WriteAllBytes($"control/{title.Id:X16}.nacp", control);
|
||||
|
||||
var reader = new BinaryReader(new MemoryStream(control));
|
||||
title.Name = reader.ReadUtf8Z();
|
||||
title.Control = new Nacp(reader);
|
||||
|
||||
foreach (var lang in title.Control.Languages)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(lang.Title))
|
||||
{
|
||||
title.Name = lang.Title;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,6 +141,7 @@ namespace libhac
|
|||
}
|
||||
}
|
||||
|
||||
[DebuggerDisplay("{" + nameof(Name) + "}")]
|
||||
public class Title
|
||||
{
|
||||
public ulong Id { get; internal set; }
|
||||
|
@ -139,6 +150,7 @@ namespace libhac
|
|||
public Cnmt Metadata { get; internal set; }
|
||||
|
||||
public string Name { get; internal set; }
|
||||
public Nacp Control { get; internal set; }
|
||||
public Nca MetaNca { get; internal set; }
|
||||
public Nca ProgramNca { get; internal set; }
|
||||
public Nca ControlNca { get; internal set; }
|
||||
|
|
Loading…
Reference in a new issue