Introduce Identifiers and strong entry types for each meta manipulation and use them in the manipulations.

This commit is contained in:
Ottermandias 2024-06-06 17:26:25 +02:00
parent ceed8531af
commit 2e9f184454
27 changed files with 533 additions and 163 deletions

View file

@ -453,7 +453,7 @@ public partial class ModEditWindow
private static class EstRow
{
private static EstManipulation _new = new(Gender.Male, ModelRace.Midlander, EstManipulation.EstType.Body, 1, 0);
private static EstManipulation _new = new(Gender.Male, ModelRace.Midlander, EstType.Body, 1, EstEntry.Zero);
private static float IdWidth
=> 100 * UiHelpers.Scale;
@ -510,7 +510,7 @@ public partial class ModEditWindow
// Values
using var disabled = ImRaii.Disabled();
ImGui.TableNextColumn();
IntDragInput("##estSkeleton", "Skeleton Index", IdWidth, _new.Entry, defaultEntry, out _, 0, ushort.MaxValue, 0.05f);
IntDragInput("##estSkeleton", "Skeleton Index", IdWidth, _new.Entry.Value, defaultEntry.Value, out _, 0, ushort.MaxValue, 0.05f);
}
public static void Draw(MetaFileManager metaFileManager, EstManipulation meta, ModEditor editor, Vector2 iconSize)
@ -538,9 +538,9 @@ public partial class ModEditWindow
// Values
var defaultEntry = EstFile.GetDefault(metaFileManager, meta.Slot, Names.CombinedRace(meta.Gender, meta.Race), meta.SetId);
ImGui.TableNextColumn();
if (IntDragInput("##estSkeleton", $"Skeleton Index\nDefault Value: {defaultEntry}", IdWidth, meta.Entry, defaultEntry,
if (IntDragInput("##estSkeleton", $"Skeleton Index\nDefault Value: {defaultEntry}", IdWidth, meta.Entry.Value, defaultEntry.Value,
out var entry, 0, ushort.MaxValue, 0.05f))
editor.MetaEditor.Change(meta.Copy((ushort)entry));
editor.MetaEditor.Change(meta.Copy(new EstEntry((ushort)entry)));
}
}
@ -646,7 +646,7 @@ public partial class ModEditWindow
private static class RspRow
{
private static RspManipulation _new = new(SubRace.Midlander, RspAttribute.MaleMinSize, 1f);
private static RspManipulation _new = new(SubRace.Midlander, RspAttribute.MaleMinSize, RspEntry.One);
private static float FloatWidth
=> 150 * UiHelpers.Scale;
@ -680,7 +680,8 @@ public partial class ModEditWindow
using var disabled = ImRaii.Disabled();
ImGui.TableNextColumn();
ImGui.SetNextItemWidth(FloatWidth);
ImGui.DragFloat("##rspValue", ref defaultEntry, 0f);
var value = defaultEntry.Value;
ImGui.DragFloat("##rspValue", ref value, 0f);
}
public static void Draw(MetaFileManager metaFileManager, RspManipulation meta, ModEditor editor, Vector2 iconSize)
@ -699,15 +700,15 @@ public partial class ModEditWindow
ImGui.TableNextColumn();
// Values
var def = CmpFile.GetDefault(metaFileManager, meta.SubRace, meta.Attribute);
var value = meta.Entry;
var def = CmpFile.GetDefault(metaFileManager, meta.SubRace, meta.Attribute).Value;
var value = meta.Entry.Value;
ImGui.SetNextItemWidth(FloatWidth);
using var color = ImRaii.PushColor(ImGuiCol.FrameBg,
def < value ? ColorId.IncreasedMetaValue.Value() : ColorId.DecreasedMetaValue.Value(),
def != value);
if (ImGui.DragFloat("##rspValue", ref value, 0.001f, RspManipulation.MinValue, RspManipulation.MaxValue)
&& value is >= RspManipulation.MinValue and <= RspManipulation.MaxValue)
editor.MetaEditor.Change(meta.Copy(value));
if (ImGui.DragFloat("##rspValue", ref value, 0.001f, RspEntry.MinValue, RspEntry.MaxValue)
&& value is >= RspEntry.MinValue and <= RspEntry.MaxValue)
editor.MetaEditor.Change(meta.Copy(new RspEntry(value)));
ImGuiUtil.HoverTooltip($"Default Value: {def:0.###}");
}

View file

@ -33,7 +33,7 @@ public static class Combos
=> ImGuiUtil.GenericEnumCombo(label, unscaledWidth * UiHelpers.Scale, current, out attribute,
RspAttributeExtensions.ToFullString, 0, 1);
public static bool EstSlot(string label, EstManipulation.EstType current, out EstManipulation.EstType attribute, float unscaledWidth = 200)
public static bool EstSlot(string label, EstType current, out EstType attribute, float unscaledWidth = 200)
=> ImGuiUtil.GenericEnumCombo(label, unscaledWidth * UiHelpers.Scale, current, out attribute);
public static bool ImcType(string label, ObjectType current, out ObjectType type, float unscaledWidth = 110)