-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathDebug.cs
55 lines (48 loc) · 1.84 KB
/
Debug.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using GBFRDataTools.Files.UI.Types;
using GBFRDataTools.Hashing;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GBFRDataTools.Files.UI;
public class UIDebugUtilities
{
// Dumps "sprite_names.txt"
public static void GetAllSpriteNames(string pathToUiDirectory)
{
Dictionary<uint, string> _spriteNames = [];
using (var tx = new StreamWriter("sprite_names.txt"))
{
foreach (var file in Directory.GetFiles(pathToUiDirectory, "*.texb", SearchOption.AllDirectories))
{
var fs = File.OpenRead(file);
var bulk = new BulkReader(fs);
var root = bulk.ReadObject(KnownProperties.List);
bulk.ResolveHashReferencesRecursive(root);
int count = 0;
foreach (var sub in root.Children)
{
UIObjectArray sprites = root["Sprites"] as UIObjectArray;
foreach (UIObject sprite in sprites.Array)
{
var name = sprite["Name"] as UIString;
if (_spriteNames.TryAdd(XXHash32Custom.Hash(name.Value), name.Value))
{
if (count == 0)
{
string normalized = file.Replace('\\', '/');
int idx = normalized.IndexOf("ui/");
tx.WriteLine($"// {normalized.Substring(idx, file.Length - idx)}");
}
tx.WriteLine(name.Value);
count++;
}
}
}
if (count > 0)
tx.WriteLine();
}
}
}
}