mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-13 20:24:17 +01:00
Make shape names editable in models.
This commit is contained in:
parent
b48c4f440a
commit
6cba63ac98
1 changed files with 54 additions and 23 deletions
|
|
@ -45,7 +45,6 @@ public partial class ModEditWindow
|
||||||
private Utf8GamePath _customGamePath = Utf8GamePath.Empty;
|
private Utf8GamePath _customGamePath = Utf8GamePath.Empty;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private LoadedData UpdateFile(MdlFile file, bool force, bool disabled)
|
private LoadedData UpdateFile(MdlFile file, bool force, bool disabled)
|
||||||
{
|
{
|
||||||
var data = disabled ? _preview : _main;
|
var data = disabled ? _preview : _main;
|
||||||
|
|
@ -89,7 +88,8 @@ public partial class ModEditWindow
|
||||||
if (disabled || tab.Mdl.Version is not MdlFile.V5)
|
if (disabled || tab.Mdl.Version is not MdlFile.V5)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!ImUtf8.ButtonEx("Update MDL Version from V5 to V6"u8, "Try using this if the bone weights of a pre-Dawntrail model seem wrong.\n\nThis is not revertible."u8,
|
if (!ImUtf8.ButtonEx("Update MDL Version from V5 to V6"u8,
|
||||||
|
"Try using this if the bone weights of a pre-Dawntrail model seem wrong.\n\nThis is not revertible."u8,
|
||||||
new Vector2(-0.1f, 0), false, 0, Colors.PressEnterWarningBg))
|
new Vector2(-0.1f, 0), false, 0, Colors.PressEnterWarningBg))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -373,6 +373,7 @@ public partial class ModEditWindow
|
||||||
tab.Mdl.Materials = materials.AddItem(_modelNewMaterial);
|
tab.Mdl.Materials = materials.AddItem(_modelNewMaterial);
|
||||||
_modelNewMaterial = string.Empty;
|
_modelNewMaterial = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
if (!validName && _modelNewMaterial.Length > 0)
|
if (!validName && _modelNewMaterial.Length > 0)
|
||||||
DrawInvalidMaterialMarker();
|
DrawInvalidMaterialMarker();
|
||||||
|
|
@ -430,7 +431,9 @@ public partial class ModEditWindow
|
||||||
private static void DrawInvalidMaterialMarker()
|
private static void DrawInvalidMaterialMarker()
|
||||||
{
|
{
|
||||||
using (ImRaii.PushFont(UiBuilder.IconFont))
|
using (ImRaii.PushFont(UiBuilder.IconFont))
|
||||||
|
{
|
||||||
ImGuiUtil.TextColored(0xFF0000FF, FontAwesomeIcon.TimesCircle.ToIconString());
|
ImGuiUtil.TextColored(0xFF0000FF, FontAwesomeIcon.TimesCircle.ToIconString());
|
||||||
|
}
|
||||||
|
|
||||||
ImGuiUtil.HoverTooltip(
|
ImGuiUtil.HoverTooltip(
|
||||||
"Materials must be either relative (e.g. \"/filename.mtrl\")\n"
|
"Materials must be either relative (e.g. \"/filename.mtrl\")\n"
|
||||||
|
|
@ -590,6 +593,7 @@ public partial class ModEditWindow
|
||||||
if (!header)
|
if (!header)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
var ret = false;
|
||||||
using (var table = ImRaii.Table("##data", 2, ImGuiTableFlags.SizingFixedFit))
|
using (var table = ImRaii.Table("##data", 2, ImGuiTableFlags.SizingFixedFit))
|
||||||
{
|
{
|
||||||
if (table)
|
if (table)
|
||||||
|
|
@ -650,22 +654,49 @@ public partial class ModEditWindow
|
||||||
using (var attributes = ImRaii.TreeNode("Attributes", ImGuiTreeNodeFlags.DefaultOpen))
|
using (var attributes = ImRaii.TreeNode("Attributes", ImGuiTreeNodeFlags.DefaultOpen))
|
||||||
{
|
{
|
||||||
if (attributes)
|
if (attributes)
|
||||||
foreach (var attribute in data.LastFile.Attributes)
|
for (var i = 0; i < data.LastFile.Attributes.Length; ++i)
|
||||||
ImRaii.TreeNode(attribute, ImGuiTreeNodeFlags.Leaf).Dispose();
|
{
|
||||||
|
using var id = ImUtf8.PushId(i);
|
||||||
|
ref var attribute = ref data.LastFile.Attributes[i];
|
||||||
|
var name = attribute;
|
||||||
|
if (ImUtf8.InputText("##attribute"u8, ref name, "Attribute Name..."u8) && name.Length > 0 && name != attribute)
|
||||||
|
{
|
||||||
|
attribute = name;
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var bones = ImRaii.TreeNode("Bones", ImGuiTreeNodeFlags.DefaultOpen))
|
using (var bones = ImRaii.TreeNode("Bones", ImGuiTreeNodeFlags.DefaultOpen))
|
||||||
{
|
{
|
||||||
if (bones)
|
if (bones)
|
||||||
foreach (var bone in data.LastFile.Bones)
|
for (var i = 0; i < data.LastFile.Bones.Length; ++i)
|
||||||
ImRaii.TreeNode(bone, ImGuiTreeNodeFlags.Leaf).Dispose();
|
{
|
||||||
|
using var id = ImUtf8.PushId(i);
|
||||||
|
ref var bone = ref data.LastFile.Bones[i];
|
||||||
|
var name = bone;
|
||||||
|
if (ImUtf8.InputText("##bone"u8, ref name, "Bone Name..."u8) && name.Length > 0 && name != bone)
|
||||||
|
{
|
||||||
|
bone = name;
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var shapes = ImRaii.TreeNode("Shapes", ImGuiTreeNodeFlags.DefaultOpen))
|
using (var shapes = ImRaii.TreeNode("Shapes", ImGuiTreeNodeFlags.DefaultOpen))
|
||||||
{
|
{
|
||||||
if (shapes)
|
if (shapes)
|
||||||
foreach (var shape in data.LastFile.Shapes)
|
for (var i = 0; i < data.LastFile.Shapes.Length; ++i)
|
||||||
ImRaii.TreeNode(shape.ShapeName, ImGuiTreeNodeFlags.Leaf).Dispose();
|
{
|
||||||
|
using var id = ImUtf8.PushId(i);
|
||||||
|
ref var shape = ref data.LastFile.Shapes[i];
|
||||||
|
var name = shape.ShapeName;
|
||||||
|
if (ImUtf8.InputText("##shape"u8, ref name, "Shape Name..."u8) && name.Length > 0 && name != shape.ShapeName)
|
||||||
|
{
|
||||||
|
shape.ShapeName = name;
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.LastFile.RemainingData.Length > 0)
|
if (data.LastFile.RemainingData.Length > 0)
|
||||||
|
|
@ -675,7 +706,7 @@ public partial class ModEditWindow
|
||||||
Widget.DrawHexViewer(data.LastFile.RemainingData);
|
Widget.DrawHexViewer(data.LastFile.RemainingData);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool GetFirstModel(IEnumerable<string> files, [NotNullWhen(true)] out string? file)
|
private static bool GetFirstModel(IEnumerable<string> files, [NotNullWhen(true)] out string? file)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue