diff --git a/Penumbra/UI/AdvancedWindow/ModEditWindow.Models.MdlTab.cs b/Penumbra/UI/AdvancedWindow/ModEditWindow.Models.MdlTab.cs index 4986963f..254db841 100644 --- a/Penumbra/UI/AdvancedWindow/ModEditWindow.Models.MdlTab.cs +++ b/Penumbra/UI/AdvancedWindow/ModEditWindow.Models.MdlTab.cs @@ -1,6 +1,8 @@ using OtterGui; using Penumbra.GameData; using Penumbra.GameData.Files; +using Penumbra.Mods; +using Penumbra.String.Classes; namespace Penumbra.UI.AdvancedWindow; @@ -9,12 +11,14 @@ public partial class ModEditWindow private class MdlTab : IWritable { public readonly MdlFile Mdl; + public readonly List GamePaths; private readonly List[] _attributes; - public MdlTab(byte[] bytes) + public MdlTab(byte[] bytes, string path, Mod? mod) { Mdl = new MdlFile(bytes); + GamePaths = mod == null ? new() : FindGamePaths(path, mod); _attributes = CreateAttributes(Mdl); } @@ -26,6 +30,18 @@ public partial class ModEditWindow public byte[] Write() => Mdl.Write(); + // TODO: this _needs_ to be done asynchronously, kart mods hang for a good second or so + private List FindGamePaths(string path, Mod mod) + { + // todo: might be worth ordering based on prio + selection for disambiguating between multiple matches? not sure. same for the multi group case + return mod.AllSubMods + .SelectMany(submod => submod.Files.Concat(submod.FileSwaps)) + // todo: using ordinal ignore case because the option group paths in mods being lowerecased somewhere, but the mod editor using fs paths, which may be uppercase. i'd say this will blow up on linux, but it's already the case so can't be too much worse than present right + .Where(kv => kv.Value.FullName.Equals(path, StringComparison.OrdinalIgnoreCase)) + .Select(kv => kv.Key) + .ToList(); + } + /// Remove the material given by the index. /// Meshes using the removed material are redirected to material 0, and those after the index are corrected. public void RemoveMaterial(int materialIndex) diff --git a/Penumbra/UI/AdvancedWindow/ModEditWindow.Models.cs b/Penumbra/UI/AdvancedWindow/ModEditWindow.Models.cs index f0cc34a6..d5ca6fa5 100644 --- a/Penumbra/UI/AdvancedWindow/ModEditWindow.Models.cs +++ b/Penumbra/UI/AdvancedWindow/ModEditWindow.Models.cs @@ -45,6 +45,9 @@ public partial class ModEditWindow { _models.SkeletonTest(); } + ImGui.TextUnformatted("blippity blap"); + foreach (var gamePath in tab.GamePaths) + ImGui.TextUnformatted(gamePath.ToString()); var ret = false; diff --git a/Penumbra/UI/AdvancedWindow/ModEditWindow.cs b/Penumbra/UI/AdvancedWindow/ModEditWindow.cs index 1a3d9182..181538ec 100644 --- a/Penumbra/UI/AdvancedWindow/ModEditWindow.cs +++ b/Penumbra/UI/AdvancedWindow/ModEditWindow.cs @@ -587,7 +587,7 @@ public partial class ModEditWindow : Window, IDisposable () => PopulateIsOnPlayer(_editor.Files.Mtrl, ResourceType.Mtrl), DrawMaterialPanel, () => _mod?.ModPath.FullName ?? string.Empty, (bytes, path, writable) => new MtrlTab(this, new MtrlFile(bytes), path, writable)); _modelTab = new FileEditor(this, gameData, config, _editor.Compactor, _fileDialog, "Models", ".mdl", - () => PopulateIsOnPlayer(_editor.Files.Mdl, ResourceType.Mdl), DrawModelPanel, () => _mod?.ModPath.FullName ?? string.Empty, (bytes, _, _) => new MdlTab(bytes)); + () => PopulateIsOnPlayer(_editor.Files.Mdl, ResourceType.Mdl), DrawModelPanel, () => _mod?.ModPath.FullName ?? string.Empty, (bytes, path, _) => new MdlTab(bytes, path, _mod)); _shaderPackageTab = new FileEditor(this, gameData, config, _editor.Compactor, _fileDialog, "Shaders", ".shpk", () => PopulateIsOnPlayer(_editor.Files.Shpk, ResourceType.Shpk), DrawShaderPackagePanel, () => _mod?.ModPath.FullName ?? string.Empty, (bytes, _, _) => new ShpkTab(_fileDialog, bytes));