diff --git a/CodeWalker.Core/GameFiles/FileTypes/YptFile.cs b/CodeWalker.Core/GameFiles/FileTypes/YptFile.cs index 35a28e8..884a1fa 100644 --- a/CodeWalker.Core/GameFiles/FileTypes/YptFile.cs +++ b/CodeWalker.Core/GameFiles/FileTypes/YptFile.cs @@ -12,7 +12,7 @@ namespace CodeWalker.GameFiles { public ParticleEffectsList PtfxList { get; set; } - public Dictionary DrawableDict { get; set; } + public Dictionary DrawableDict { get; set; } public string ErrorMessage { get; set; } @@ -76,7 +76,7 @@ namespace CodeWalker.GameFiles if ((dDict?.Drawables?.data_items != null) && (dDict?.Hashes != null)) { - DrawableDict = new Dictionary(); + DrawableDict = new Dictionary(); var drawables = dDict.Drawables.data_items; var hashes = dDict.Hashes; for (int i = 0; (i < drawables.Length) && (i < hashes.Length); i++) @@ -87,23 +87,23 @@ namespace CodeWalker.GameFiles drawable.Owner = this; } - for (int i = 0; (i < drawables.Length) && (i < hashes.Length); i++) - { - var drawable = drawables[i]; - var hash = hashes[i]; - if ((drawable.Name == null) || (drawable.Name.EndsWith("#dd"))) - { - string hstr = JenkIndex.TryGetString(hash); - if (!string.IsNullOrEmpty(hstr)) - { - drawable.Name = hstr; - } - else - { - drawable.Name = "0x" + hash.ToString("X").PadLeft(8, '0'); - } - } - } + //for (int i = 0; (i < drawables.Length) && (i < hashes.Length); i++) + //{ + // var drawable = drawables[i]; + // var hash = hashes[i]; + // if ((drawable.Name == null) || (drawable.Name.EndsWith("#dd"))) + // { + // string hstr = JenkIndex.TryGetString(hash); + // if (!string.IsNullOrEmpty(hstr)) + // { + // drawable.Name = hstr; + // } + // else + // { + // drawable.Name = "0x" + hash.ToString("X").PadLeft(8, '0'); + // } + // } + //} } } diff --git a/CodeWalker.Core/GameFiles/Resources/Drawable.cs b/CodeWalker.Core/GameFiles/Resources/Drawable.cs index 64cc615..2140630 100644 --- a/CodeWalker.Core/GameFiles/Resources/Drawable.cs +++ b/CodeWalker.Core/GameFiles/Resources/Drawable.cs @@ -4582,10 +4582,8 @@ namespace CodeWalker.GameFiles } // structure data - public uint Unknown_10h { get; set; } - public uint Unknown_14h { get; set; } - public uint Unknown_18h { get; set; } - public uint Unknown_1Ch { get; set; } + public ulong Unknown_10h; // 0x0000000000000000 + public ulong Unknown_18h = 1; // 0x0000000000000001 public ulong HashesPointer { get; set; } public ushort HashesCount1 { get; set; } public ushort HashesCount2 { get; set; } @@ -4604,18 +4602,13 @@ namespace CodeWalker.GameFiles private ResourceSystemStructBlock HashesBlock = null;//only used for saving - /// - /// Reads the data-block from a stream. - /// public override void Read(ResourceDataReader reader, params object[] parameters) { base.Read(reader, parameters); // read structure data - this.Unknown_10h = reader.ReadUInt32(); - this.Unknown_14h = reader.ReadUInt32(); - this.Unknown_18h = reader.ReadUInt32(); - this.Unknown_1Ch = reader.ReadUInt32(); + this.Unknown_10h = reader.ReadUInt64(); + this.Unknown_18h = reader.ReadUInt64(); this.HashesPointer = reader.ReadUInt64(); this.HashesCount1 = reader.ReadUInt16(); this.HashesCount2 = reader.ReadUInt16(); @@ -4626,21 +4619,18 @@ namespace CodeWalker.GameFiles this.Unknown_3Ch = reader.ReadUInt32(); // read reference data - //this.Hashes = reader.ReadBlockAt>( - // this.HashesPointer, // offset - // this.HashesCount1 - //); this.Hashes = reader.ReadUintsAt(this.HashesPointer, this.HashesCount1); + this.Drawables = reader.ReadBlockAt>(this.DrawablesPointer, this.DrawablesCount1); - this.Drawables = reader.ReadBlockAt>( - this.DrawablesPointer, // offset - this.DrawablesCount1 - ); + //if (Unknown_10h != 0) + //{ } + //if (Unknown_18h != 1) + //{ } + //if (Unknown_2Ch != 0) + //{ } + //if (Unknown_3Ch != 0) + //{ } } - - /// - /// Writes the data-block to a stream. - /// public override void Write(ResourceDataWriter writer, params object[] parameters) { base.Write(writer, parameters); @@ -4655,9 +4645,7 @@ namespace CodeWalker.GameFiles // write structure data writer.Write(this.Unknown_10h); - writer.Write(this.Unknown_14h); writer.Write(this.Unknown_18h); - writer.Write(this.Unknown_1Ch); writer.Write(this.HashesPointer); writer.Write(this.HashesCount1); writer.Write(this.HashesCount2); @@ -4668,9 +4656,6 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_3Ch); } - /// - /// Returns a list of data blocks which are referenced by this block. - /// public override IResourceBlock[] GetReferences() { var list = new List(base.GetReferences()); diff --git a/CodeWalker.Core/GameFiles/Resources/Particle.cs b/CodeWalker.Core/GameFiles/Resources/Particle.cs index f73bbb5..c2ec3a5 100644 --- a/CodeWalker.Core/GameFiles/Resources/Particle.cs +++ b/CodeWalker.Core/GameFiles/Resources/Particle.cs @@ -61,7 +61,7 @@ namespace CodeWalker.GameFiles // reference data public string_r Name { get; set; } public TextureDictionary TextureDictionary { get; set; } - public DrawableDictionary DrawableDictionary { get; set; } + public DrawableBaseDictionary DrawableDictionary { get; set; } public ParticleRuleDictionary ParticleRuleDictionary { get; set; } public ParticleEffectRuleDictionary EffectRuleDictionary { get; set; } public ParticleEmitterRuleDictionary EmitterRuleDictionary { get; set; } @@ -86,7 +86,7 @@ namespace CodeWalker.GameFiles // read reference data this.Name = reader.ReadBlockAt(this.NamePointer); this.TextureDictionary = reader.ReadBlockAt(this.TextureDictionaryPointer); - this.DrawableDictionary = reader.ReadBlockAt(this.DrawableDictionaryPointer); + this.DrawableDictionary = reader.ReadBlockAt(this.DrawableDictionaryPointer); this.ParticleRuleDictionary = reader.ReadBlockAt(this.ParticleRuleDictionaryPointer); this.EffectRuleDictionary = reader.ReadBlockAt(this.EmitterRuleDictionaryPointer); this.EmitterRuleDictionary = reader.ReadBlockAt(this.EffectRuleDictionaryPointer); @@ -866,6 +866,11 @@ namespace CodeWalker.GameFiles new Tuple(0x210, UnknownList2) }; } + + public override string ToString() + { + return Name?.ToString() ?? base.ToString(); + } } @@ -957,6 +962,12 @@ namespace CodeWalker.GameFiles new Tuple(0x40, Unknown_40h) }; } + + public override string ToString() + { + var n = Name.ToString(); + return (!string.IsNullOrEmpty(n)) ? n : base.ToString(); + } } @@ -977,7 +988,7 @@ namespace CodeWalker.GameFiles // reference data public string_r String1 { get; set; } - public Drawable Drawable { get; set; } + public DrawableBase Drawable { get; set; } public override void Read(ResourceDataReader reader, params object[] parameters) { @@ -994,7 +1005,7 @@ namespace CodeWalker.GameFiles // read reference data this.String1 = reader.ReadBlockAt(this.String1Pointer); - this.Drawable = reader.ReadBlockAt(this.DrawablePointer); + this.Drawable = reader.ReadBlockAt(this.DrawablePointer); switch (Unknown_0h) @@ -1073,7 +1084,7 @@ namespace CodeWalker.GameFiles case 0xb1178b81: // break; default: - break;//no hit + break; } //if (Unknown_24h != 0) //{ }//no hit @@ -1105,6 +1116,13 @@ namespace CodeWalker.GameFiles if (Drawable != null) list.Add(Drawable); return list.ToArray(); } + + public override string ToString() + { + if (!string.IsNullOrEmpty(String1?.Value)) return String1.Value; + if (Unknown_20h != 0) return Unknown_20h.ToString(); + return base.ToString(); + } } @@ -1378,6 +1396,12 @@ namespace CodeWalker.GameFiles if (String1 != null) list.Add(String1); return list.ToArray(); } + + public override string ToString() + { + var str = String1?.ToString(); + return (!string.IsNullOrEmpty(str)) ? str : base.ToString(); + } } @@ -1906,6 +1930,11 @@ namespace CodeWalker.GameFiles new Tuple(768, KeyframeProp4) }; } + + public override string ToString() + { + return Name?.ToString() ?? base.ToString(); + } } @@ -2110,6 +2139,11 @@ namespace CodeWalker.GameFiles new Tuple(0x70, Items) }; } + + public override string ToString() + { + return Unknown_68h.ToString(); + } } @@ -2235,6 +2269,11 @@ namespace CodeWalker.GameFiles writer.Write(this.Unknown_18h); writer.Write(this.Unknown_1Ch); } + + public override string ToString() + { + return string.Format("{0}, {1}, {2}, {3}, {4}, {5}", Unknown_0h, Unknown_4h, Unknown_10h, Unknown_14h, Unknown_18h, Unknown_1Ch); + } } @@ -2467,6 +2506,11 @@ namespace CodeWalker.GameFiles if (ParticleRule != null) list.Add(ParticleRule); return list.ToArray(); } + + public override string ToString() + { + return String1?.ToString() ?? String2?.ToString() ?? base.ToString(); + } } @@ -2672,6 +2716,11 @@ namespace CodeWalker.GameFiles new Tuple(1416, KeyframeProps1[9]), }; } + + public override string ToString() + { + return Name?.ToString() ?? base.ToString(); + } } @@ -2731,6 +2780,11 @@ namespace CodeWalker.GameFiles new Tuple(0x28, Unknown_28h) }; } + + public override string ToString() + { + return base.ToString(); + } } @@ -2762,7 +2816,6 @@ namespace CodeWalker.GameFiles //if (Unknown_10h != 0) //{ }//no hit } - public override void Write(ResourceDataWriter writer, params object[] parameters) { // update structure data @@ -2780,6 +2833,11 @@ namespace CodeWalker.GameFiles if (String1 != null) list.Add(String1); return list.ToArray(); } + + public override string ToString() + { + return String1?.ToString() ?? base.ToString(); + } } @@ -2858,13 +2916,12 @@ namespace CodeWalker.GameFiles case 0xff864d6c: // break; default: - break;//no hit + break; } //if (Unknown_4h != 0) //{ }//no hit } - public override void Write(ResourceDataWriter writer, params object[] parameters) { // update structure data @@ -2882,6 +2939,11 @@ namespace CodeWalker.GameFiles if (Item != null) list.Add(Item); return list.ToArray(); } + + public override string ToString() + { + return Unknown_0h.ToString(); + } } @@ -2951,7 +3013,7 @@ namespace CodeWalker.GameFiles case 0xff864d6c: // break; default: - break;//no hit + break; } //switch (Unknown_14h) //{ @@ -2962,7 +3024,6 @@ namespace CodeWalker.GameFiles // break;//no hit //} } - public override void Write(ResourceDataWriter writer, params object[] parameters) { // write structure data @@ -2977,6 +3038,11 @@ namespace CodeWalker.GameFiles new Tuple(0, Unknown_0h) }; } + + public override string ToString() + { + return Unknown_10h.ToString(); + } } @@ -3028,7 +3094,6 @@ namespace CodeWalker.GameFiles //if (Unknown_28h != 0) //{ }//no hit } - public override void Write(ResourceDataWriter writer, params object[] parameters) { // write structure data @@ -3046,6 +3111,11 @@ namespace CodeWalker.GameFiles new Tuple(0, Unknown_0h) }; } + + public override string ToString() + { + return Unknown_20h.ToString() + ", " + Unknown_24h.ToString(); + } } @@ -3215,6 +3285,10 @@ namespace CodeWalker.GameFiles } } + public override string ToString() + { + return "Domain: " + DomainType.ToString(); + } } [TC(typeof(EXP))] public class ParticleDomainBox : ParticleDomain @@ -3345,6 +3419,11 @@ namespace CodeWalker.GameFiles default: return null;// throw new Exception("Unknown behaviour type"); } } + + public override string ToString() + { + return "Behaviour: " + Type.ToString(); + } } [TC(typeof(EXP))] public class ParticleBehaviourAge : ParticleBehaviour @@ -5857,6 +5936,11 @@ namespace CodeWalker.GameFiles default: return null;// throw new Exception("Unknown shader var type"); } } + + public override string ToString() + { + return Unknown_10h.ToString() + ": " + Type.ToString(); + } } [TC(typeof(EXP))] public class ParticleShaderVarVector : ParticleShaderVar @@ -5987,7 +6071,7 @@ namespace CodeWalker.GameFiles public override long BlockLength => 0x40; // structure data - public uint Unknown_18h { get; set; } // 3, 4, 6, 7 + public uint Unknown_18h { get; set; } // 3, 4, 6, 7 //shader var index..? public uint Unknown_1Ch; // 0x00000000 public uint Unknown_20h; // 0x00000000 public uint Unknown_24h; // 0x00000000 @@ -6089,7 +6173,7 @@ namespace CodeWalker.GameFiles public override long BlockLength => 0x50; // structure data - public uint Unknown_18h { get; set; } // 9, 14, 15, 16, 17, 20, 23, 31 + public uint Unknown_18h { get; set; } // 9, 14, 15, 16, 17, 20, 23, 31 //shader var index..? public uint Unknown_1Ch = 1; // 0x00000001 public ulong Unknown_20h; // 0x0000000000000000 public ResourceSimpleList64 Items { get; set; } diff --git a/Forms/ModelForm.cs b/Forms/ModelForm.cs index c4c0cdf..c593353 100644 --- a/Forms/ModelForm.cs +++ b/Forms/ModelForm.cs @@ -1023,6 +1023,35 @@ namespace CodeWalker.Forms ToolsPanel.Visible = true; //show the panel by default for dictionaries... } + private void UpdateModelsUI(Dictionary dict) + { + //DetailsPropertyGrid.SelectedObject = dict; //this won't look good... + + DrawableDrawFlags.Clear(); + Renderer.SelectionModelDrawFlags.Clear(); + Renderer.SelectionGeometryDrawFlags.Clear(); + ModelsTreeView.Nodes.Clear(); + ModelsTreeView.ShowRootLines = true; + TexturesTreeView.Nodes.Clear(); + + bool check = true; + if (dict != null) + { + List> items = new List>(); + foreach (var kvp in dict) + { + items.Add(kvp); + } + //items.Sort((a, b) => { return a.Value?.Name?.CompareTo(b.Value?.Name ?? "") ?? 0; }); + foreach (var kvp in items) + { + AddDrawableTreeNode(kvp.Value, kvp.Key, check); + check = false; + } + } + + ToolsPanel.Visible = true; //show the panel by default for dictionaries... + } private void UpdateBoundsUI(YbnFile bounds) { DetailsPropertyGrid.SelectedObject = bounds; @@ -1878,7 +1907,7 @@ namespace CodeWalker.Forms } else if ((Ypt != null) && (Ypt.Loaded)) { - dict = Ypt.DrawableDict; + //dict = Ypt.DrawableDict; } else {