diff --git a/tools/LayoutDump/Program.cs b/tools/LayoutDump/Program.cs index 255917ff..38b8a2b0 100644 --- a/tools/LayoutDump/Program.cs +++ b/tools/LayoutDump/Program.cs @@ -46,6 +46,55 @@ if (root is null) Console.WriteLine($"layout 0x{ids[0]:X8}"); Print(root, 0); +int mediaAt = Array.IndexOf(args, "--media"); +if (mediaAt >= 0) +{ + // The RAW media sequence per state, straight off the LayoutDesc. ElementInfo + // keeps only the first image, so an animation is invisible above that level. + uint wanted = mediaAt + 1 < args.Length + ? Convert.ToUInt32(args[mediaAt + 1], 16) + : 0u; + // Layouts are not necessarily in Portal — go through the adapter, the same + // way LayoutImporter does. + var ld = adapter.Get(ids[0]); + if (ld is null) + { + Console.WriteLine($"layout 0x{ids[0]:X8} not found"); + return 2; + } + + foreach (var top in ld.Elements) + Walk(top.Value); + return 0; + + void Walk(DatReaderWriter.Types.ElementDesc d) + { + if (wanted == 0 || d.ElementId == wanted) + { + Console.WriteLine($"element 0x{d.ElementId:X8}"); + if (d.States.Count == 0) + { + // Raw descriptors only carry what THIS element overrides; states + // and their media usually come from the base element, and + // LayoutDesc::InqFullDesc @0x0069A520 resolves that chain. + // Following it here would mean reimplementing LayoutImporter's + // Resolve, so say so rather than imply the element has none. + Console.WriteLine( + $" (no states of its own — inherited from base 0x{d.BaseElement:X8};" + + " raw media not resolved here)"); + } + foreach (var st in d.States) + { + Console.WriteLine($" state {st.Key}: {st.Value.Media.Count} media"); + foreach (var m in st.Value.Media) + Console.WriteLine($" {m.GetType().Name}"); + } + } + foreach (var child in d.Children) + Walk(child.Value); + } +} + int resizeAt = Array.IndexOf(args, "--resize"); if (resizeAt >= 0 && resizeAt + 2 < args.Length) {