1
0
mirror of synced 2024-12-01 02:27:22 +01:00

Auto calculate hashed texture names for layouts in sarcs

This commit is contained in:
KillzXGaming 2019-10-18 18:59:04 -04:00
parent b0b1355887
commit 098c8fb842
2 changed files with 30 additions and 1 deletions

View File

@ -293,6 +293,23 @@ namespace FirstPlugin
}
}
public string TryGetHash(List<string> names, string folder)
{
//Name is not hashed so return
if (!FileName.Contains(HashName))
return FileName;
for (int i = 0; i < names?.Count; i++)
{
uint hash = StringHashToUint(hashName);
Console.WriteLine($"{FileName} {hash} {names[i]} {NameHash(names[i])}");
if (hash == NameHash($"{folder}/{names[i]}"))
return names[i];
}
return FileName;
}
public bool IsHashMatch(string fileName)
{
uint hash = StringHashToUint(hashName);

View File

@ -256,9 +256,21 @@ namespace LayoutBXLYT.Cafe
if (Utils.GetExtension(file.FileName) == ".bflim")
{
BFLIM bflim = (BFLIM)file.OpenFile();
string name = bflim.FileName;
if (archive is SARC)
{
if (((SARC)archive).sarcData.HashOnly)
{
var sarcEntry = file as SARC.SarcEntry;
//Look through all textures and find a hash match
name = sarcEntry.TryGetHash(header.Textures, "timg");
}
}
file.FileFormat = bflim;
if (!textures.ContainsKey(bflim.FileName))
textures.Add(bflim.FileName, bflim);
textures.Add(name, bflim);
}
}
catch (Exception ex)