Auto calculate hashed texture names for layouts in sarcs
This commit is contained in:
parent
b0b1355887
commit
098c8fb842
@ -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);
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user