Store Model ID for NPCs, fix issue with applying NPC data setting extended colors.

This commit is contained in:
Ottermandias 2024-01-12 23:35:41 +01:00
parent a50b63f67e
commit c87885bd3b
4 changed files with 20 additions and 4 deletions

View file

@ -72,6 +72,7 @@ public class NpcCustomizeSet : IAsyncDataContainer, IReadOnlyList<NpcData>
{
Name = name,
Customize = customize,
ModelId = row.ModelChara.Row,
Id = id,
Kind = ObjectKind.EventNpc,
};
@ -132,6 +133,7 @@ public class NpcCustomizeSet : IAsyncDataContainer, IReadOnlyList<NpcData>
var ret = new NpcData
{
Customize = customize,
ModelId = baseRow.ModelChara.Row,
Id = baseRow.RowId,
Kind = ObjectKind.BattleNpc,
};

View file

@ -24,6 +24,9 @@ public unsafe struct NpcData
/// <summary> The data ID of the NPC, either event NPC or battle NPC name. </summary>
public NpcId Id;
/// <summary> The Model ID of the NPC. </summary>
public uint ModelId;
/// <summary> Whether the NPCs visor is toggled. </summary>
public bool VisorToggled;
@ -87,6 +90,9 @@ public unsafe struct NpcData
/// <summary> Check if the appearance data, excluding ID and Name, of two NpcData is equal. </summary>
public bool DataEquals(in NpcData other)
{
if (ModelId != other.ModelId)
return false;
if (VisorToggled != other.VisorToggled)
return false;

View file

@ -33,7 +33,7 @@ public class NpcAppearancePanel(NpcCombo _npcCombo, StateManager _state, ObjectM
ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X);
var resetScroll = ImGui.InputTextWithHint("##npcFilter", "Filter...", ref _npcFilter, 64);
using var table = ImRaii.Table("npcs", 6, ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollY | ImGuiTableFlags.SizingFixedFit,
using var table = ImRaii.Table("npcs", 7, ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollY | ImGuiTableFlags.SizingFixedFit,
new Vector2(-1, 400 * ImGuiHelpers.GlobalScale));
if (!table)
return;
@ -45,6 +45,7 @@ public class NpcAppearancePanel(NpcCombo _npcCombo, StateManager _state, ObjectM
ImGui.TableSetupColumn("Name", ImGuiTableColumnFlags.WidthFixed, ImGuiHelpers.GlobalScale * 300);
ImGui.TableSetupColumn("Kind", ImGuiTableColumnFlags.WidthFixed);
ImGui.TableSetupColumn("Id", ImGuiTableColumnFlags.WidthFixed);
ImGui.TableSetupColumn("Model", ImGuiTableColumnFlags.WidthFixed);
ImGui.TableSetupColumn("Visor", ImGuiTableColumnFlags.WidthFixed);
ImGui.TableSetupColumn("Compare", ImGuiTableColumnFlags.WidthStretch);
@ -83,6 +84,10 @@ public class NpcAppearancePanel(NpcCombo _npcCombo, StateManager _state, ObjectM
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted(data.Id.Id.ToString());
ImGui.TableNextColumn();
ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted(data.ModelId.ToString());
using (_ = ImRaii.PushFont(UiBuilder.IconFont))
{
ImGui.TableNextColumn();

View file

@ -141,7 +141,10 @@ public class NpcPanel(
private void DrawCustomization()
{
using var h = ImRaii.CollapsingHeader("Customization");
var header = _selector.Selection.ModelId == 0
? "Customization"
: $"Customization (Model Id #{_selector.Selection.ModelId})###Customization";
using var h = ImRaii.CollapsingHeader(header);
if (!h)
return;
@ -197,8 +200,8 @@ public class NpcPanel(
if (_state.GetOrCreate(id, data.Objects[0], out var state))
{
var (applyGear, applyCustomize, applyCrest, applyParameters) = UiHelpers.ConvertKeysToFlags();
var design = _converter.Convert(ToDesignData(), applyGear, applyCustomize, applyCrest, applyParameters);
var (applyGear, applyCustomize, _, _) = UiHelpers.ConvertKeysToFlags();
var design = _converter.Convert(ToDesignData(), applyGear, applyCustomize, 0, 0);
_state.ApplyDesign(design, state, StateChanged.Source.Manual);
}
}