YTD and embedded texture editing in YtdForm, Fixed texture sorting by hash when importing XML

This commit is contained in:
dexy
2021-12-28 23:26:35 +11:00
Unverified
parent a4998e36c8
commit 7f0bb17e68
6 changed files with 523 additions and 93 deletions
@@ -26,6 +26,7 @@ namespace CodeWalker.GameFiles
public void Load(byte[] data, RpfFileEntry entry)
{
Name = entry.Name;
RpfFileEntry = entry;
RpfResourceFileEntry resentry = entry as RpfResourceFileEntry;
+18 -7
View File
@@ -99,7 +99,6 @@ namespace CodeWalker.GameFiles
public void ReadXml(XmlNode node, string ddsfolder)
{
var textures = new List<Texture>();
var texturehashes = new List<uint>();
var inodes = node.SelectNodes("Item");
if (inodes != null)
@@ -109,15 +108,10 @@ namespace CodeWalker.GameFiles
var tex = new Texture();
tex.ReadXml(inode, ddsfolder);
textures.Add(tex);
texturehashes.Add(tex.NameHash);
}
}
TextureNameHashes = new ResourceSimpleList64_uint();
TextureNameHashes.data_items = texturehashes.ToArray();
Textures = new ResourcePointerList64<Texture>();
Textures.data_items = textures.ToArray();
BuildDict();
BuildFromTextureList(textures);
}
public static void WriteXmlNode(TextureDictionary d, StringBuilder sb, int indent, string ddsfolder, string name = "TextureDictionary")
{
@@ -175,6 +169,23 @@ namespace CodeWalker.GameFiles
Dict = dict;
}
public void BuildFromTextureList(List<Texture> textures)
{
textures.Sort((a, b) => a.NameHash.CompareTo(b.NameHash));
var texturehashes = new List<uint>();
foreach (var tex in textures)
{
texturehashes.Add(tex.NameHash);
}
TextureNameHashes = new ResourceSimpleList64_uint();
TextureNameHashes.data_items = texturehashes.ToArray();
Textures = new ResourcePointerList64<Texture>();
Textures.data_items = textures.ToArray();
BuildDict();
}
}
[TypeConverter(typeof(ExpandableObjectConverter))] public class TextureBase : ResourceSystemBlock