Finish up mesh material combos

This commit is contained in:
ackwell 2023-12-23 00:12:59 +11:00
parent a581495c7e
commit b22470ac79
2 changed files with 21 additions and 19 deletions

View file

@ -1,4 +1,3 @@
using System.Collections.ObjectModel;
using OtterGui;
using Penumbra.GameData;
using Penumbra.GameData.Files;
@ -24,11 +23,13 @@ public partial class ModEditWindow
// Meshes using the removed material are redirected to material 0, and those after the index are corrected.
for (var meshIndex = 0; meshIndex < Mdl.Meshes.Length; meshIndex++)
{
var mesh = Mdl.Meshes[meshIndex];
if (mesh.MaterialIndex == materialIndex)
mesh.MaterialIndex = 0;
else if (mesh.MaterialIndex > materialIndex)
mesh.MaterialIndex -= 1;
var newIndex = Mdl.Meshes[meshIndex].MaterialIndex;
if (newIndex == materialIndex)
newIndex = 0;
else if (newIndex > materialIndex)
newIndex -= 1;
Mdl.Meshes[meshIndex].MaterialIndex = newIndex;
}
Mdl.Materials = Mdl.Materials.RemoveItems(materialIndex);

View file

@ -158,27 +158,28 @@ public partial class ModEditWindow
var ret = false;
// Mesh material.
// var temp = tab.GetMeshMaterial(meshIndex);
// if (
// ImGui.InputText("Material", ref temp, Utf8GamePath.MaxGamePathLength, disabled ? ImGuiInputTextFlags.ReadOnly : ImGuiInputTextFlags.None)
// && temp.Length > 0
// && temp != tab.GetMeshMaterial(meshIndex)
// ) {
// tab.SetMeshMaterial(meshIndex, temp);
// ret = true;
// }
// Mesh material
ImGui.TableNextColumn();
ImGui.Text("Material");
ImGui.TableNextColumn();
ImGui.SetNextItemWidth(-1);
using (var materialCombo = ImRaii.Combo("##material", "TODO material"))
using (var materialCombo = ImRaii.Combo("##material", tab.Mdl.Materials[mesh.MaterialIndex]))
{
// todo
if (materialCombo)
{
foreach (var (material, materialIndex) in tab.Mdl.Materials.WithIndex())
{
if (ImGui.Selectable(material, mesh.MaterialIndex == materialIndex))
{
file.Meshes[meshIndex].MaterialIndex = (ushort)materialIndex;
ret = true;
}
}
}
}
// Submeshes.
// Submeshes
for (var submeshOffset = 0; submeshOffset < mesh.SubMeshCount; submeshOffset++)
{
using var submeshId = ImRaii.PushId(submeshOffset);