mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-15 05:04:15 +01:00
Resolve mdl game paths
This commit is contained in:
parent
d7cac3e09a
commit
71fc901798
3 changed files with 21 additions and 2 deletions
|
|
@ -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<Utf8GamePath> GamePaths;
|
||||
|
||||
private readonly List<string>[] _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<Utf8GamePath> 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();
|
||||
}
|
||||
|
||||
/// <summary> Remove the material given by the index. </summary>
|
||||
/// <remarks> Meshes using the removed material are redirected to material 0, and those after the index are corrected. </remarks>
|
||||
public void RemoveMaterial(int materialIndex)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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<MdlTab>(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<ShpkTab>(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));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue