Improve bodytype stuff.

This commit is contained in:
Ottermandias 2023-12-24 16:17:44 +01:00
parent a900219ede
commit 1fa9afb9c6
7 changed files with 40 additions and 88 deletions

View file

@ -33,26 +33,26 @@ public class DesignBase
internal DesignBase(CustomizeService customize, in DesignData designData, EquipFlag equipFlags, CustomizeFlag customizeFlags) internal DesignBase(CustomizeService customize, in DesignData designData, EquipFlag equipFlags, CustomizeFlag customizeFlags)
{ {
_designData = designData; _designData = designData;
ApplyCustomize = customizeFlags & CustomizeFlagExtensions.AllRelevant; ApplyCustomize = customizeFlags & CustomizeFlagExtensions.AllRelevant;
ApplyEquip = equipFlags & EquipFlagExtensions.All; ApplyEquip = equipFlags & EquipFlagExtensions.All;
_designFlags = 0; _designFlags = 0;
CustomizeSet = SetCustomizationSet(customize); CustomizeSet = SetCustomizationSet(customize);
} }
internal DesignBase(DesignBase clone) internal DesignBase(DesignBase clone)
{ {
_designData = clone._designData; _designData = clone._designData;
CustomizeSet = clone.CustomizeSet; CustomizeSet = clone.CustomizeSet;
ApplyCustomize = clone.ApplyCustomizeRaw; ApplyCustomize = clone.ApplyCustomizeRaw;
ApplyEquip = clone.ApplyEquip & EquipFlagExtensions.All; ApplyEquip = clone.ApplyEquip & EquipFlagExtensions.All;
_designFlags = clone._designFlags & (DesignFlags)0x0F; _designFlags = clone._designFlags & (DesignFlags)0x0F;
} }
/// <summary> Ensure that the customization set is updated when the design data changes. </summary> /// <summary> Ensure that the customization set is updated when the design data changes. </summary>
internal void SetDesignData(CustomizeService customize, in DesignData other) internal void SetDesignData(CustomizeService customize, in DesignData other)
{ {
_designData = other; _designData = other;
CustomizeSet = SetCustomizationSet(customize); CustomizeSet = SetCustomizationSet(customize);
} }
@ -68,8 +68,8 @@ public class DesignBase
WriteProtected = 0x10, WriteProtected = 0x10,
} }
private CustomizeFlag _applyCustomize = CustomizeFlagExtensions.AllRelevant; private CustomizeFlag _applyCustomize = CustomizeFlagExtensions.AllRelevant;
public CustomizeSet CustomizeSet { get; private set; } public CustomizeSet CustomizeSet { get; private set; }
internal CustomizeFlag ApplyCustomize internal CustomizeFlag ApplyCustomize
{ {
@ -90,7 +90,7 @@ public class DesignBase
return false; return false;
_designData.Customize = customize; _designData.Customize = customize;
CustomizeSet = customizeService.Manager.GetSet(customize.Clan, customize.Gender); CustomizeSet = customizeService.Manager.GetSet(customize.Clan, customize.Gender);
return true; return true;
} }
@ -485,7 +485,7 @@ public class DesignBase
design._designData.Customize.Race = race; design._designData.Customize.Race = race;
design._designData.Customize.Clan = clan; design._designData.Customize.Clan = clan;
design._designData.Customize.Gender = gender; design._designData.Customize.Gender = gender;
design.CustomizeSet = design.SetCustomizationSet(customizations); design.CustomizeSet = design.SetCustomizationSet(customizations);
design.SetApplyCustomize(CustomizeIndex.Race, json[CustomizeIndex.Race.ToString()]?["Apply"]?.ToObject<bool>() ?? false); design.SetApplyCustomize(CustomizeIndex.Race, json[CustomizeIndex.Race.ToString()]?["Apply"]?.ToObject<bool>() ?? false);
design.SetApplyCustomize(CustomizeIndex.Clan, json[CustomizeIndex.Clan.ToString()]?["Apply"]?.ToObject<bool>() ?? false); design.SetApplyCustomize(CustomizeIndex.Clan, json[CustomizeIndex.Clan.ToString()]?["Apply"]?.ToObject<bool>() ?? false);
design.SetApplyCustomize(CustomizeIndex.Gender, json[CustomizeIndex.Gender.ToString()]?["Apply"]?.ToObject<bool>() ?? false); design.SetApplyCustomize(CustomizeIndex.Gender, json[CustomizeIndex.Gender.ToString()]?["Apply"]?.ToObject<bool>() ?? false);
@ -495,7 +495,7 @@ public class DesignBase
{ {
var tok = json[idx.ToString()]; var tok = json[idx.ToString()];
var data = (CustomizeValue)(tok?["Value"]?.ToObject<byte>() ?? 0); var data = (CustomizeValue)(tok?["Value"]?.ToObject<byte>() ?? 0);
if (set.IsAvailable(idx)) if (set.IsAvailable(idx) && design._designData.Customize.BodyType == 1)
PrintWarning(CustomizeService.ValidateCustomizeValue(set, design._designData.Customize.Face, idx, data, out data, PrintWarning(CustomizeService.ValidateCustomizeValue(set, design._designData.Customize.Face, idx, data, out data,
allowUnknown)); allowUnknown));
var apply = tok?["Apply"]?.ToObject<bool>() ?? false; var apply = tok?["Apply"]?.ToObject<bool>() ?? false;

View file

@ -297,5 +297,5 @@ public static class CustomizationSetExtensions
{ {
/// <summary> Return only the available customizations in this set and Clan or Gender. </summary> /// <summary> Return only the available customizations in this set and Clan or Gender. </summary>
public static CustomizeFlag FixApplication(this CustomizeFlag flag, CustomizeSet set) public static CustomizeFlag FixApplication(this CustomizeFlag flag, CustomizeSet set)
=> flag & (set.SettingAvailable | CustomizeFlag.Clan | CustomizeFlag.Gender); => flag & (set.SettingAvailable | CustomizeFlag.Clan | CustomizeFlag.Gender | CustomizeFlag.BodyType);
} }

View file

@ -91,7 +91,7 @@ internal class CustomizeSetFactory(
var npcCustomizations = new HashSet<(CustomizeIndex, CustomizeValue)>(); var npcCustomizations = new HashSet<(CustomizeIndex, CustomizeValue)>();
_npcCustomizeSet.Awaiter.Wait(); _npcCustomizeSet.Awaiter.Wait();
foreach (var customize in _npcCustomizeSet.Select(s => s.Customize).Where(c => c.Clan == race && c.Gender == gender)) foreach (var customize in _npcCustomizeSet.Select(s => s.Customize).Where(c => c.Clan == race && c.Gender == gender && c.BodyType.Value == 1))
{ {
foreach (var customizeIndex in customizeIndices) foreach (var customizeIndex in customizeIndices)
{ {

View file

@ -256,8 +256,7 @@ public class NpcCustomizeSet : IAsyncDataContainer, IReadOnlyList<NpcData>
customize.SetByIndex(24, (CustomizeValue)bnpcCustomize.FacePaint); customize.SetByIndex(24, (CustomizeValue)bnpcCustomize.FacePaint);
customize.SetByIndex(25, (CustomizeValue)bnpcCustomize.FacePaintColor); customize.SetByIndex(25, (CustomizeValue)bnpcCustomize.FacePaintColor);
if (customize.BodyType.Value != 1 if (!CustomizeManager.Races.Contains(customize.Race)
|| !CustomizeManager.Races.Contains(customize.Race)
|| !CustomizeManager.Clans.Contains(customize.Clan) || !CustomizeManager.Clans.Contains(customize.Clan)
|| !CustomizeManager.Genders.Contains(customize.Gender)) || !CustomizeManager.Genders.Contains(customize.Gender))
return (false, CustomizeArray.Default); return (false, CustomizeArray.Default);
@ -299,8 +298,7 @@ public class NpcCustomizeSet : IAsyncDataContainer, IReadOnlyList<NpcData>
customize.SetByIndex(24, (CustomizeValue)enpcBase.FacePaint); customize.SetByIndex(24, (CustomizeValue)enpcBase.FacePaint);
customize.SetByIndex(25, (CustomizeValue)enpcBase.FacePaintColor); customize.SetByIndex(25, (CustomizeValue)enpcBase.FacePaintColor);
if (customize.BodyType.Value != 1 if (!CustomizeManager.Races.Contains(customize.Race)
|| !CustomizeManager.Races.Contains(customize.Race)
|| !CustomizeManager.Clans.Contains(customize.Clan) || !CustomizeManager.Clans.Contains(customize.Clan)
|| !CustomizeManager.Genders.Contains(customize.Gender)) || !CustomizeManager.Genders.Contains(customize.Gender))
return (false, CustomizeArray.Default); return (false, CustomizeArray.Default);

View file

@ -1,20 +1,14 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using Dalamud.Interface.Utility;
using ImGuiNET; using ImGuiNET;
using Microsoft.Extensions.DependencyInjection;
using OtterGui;
using OtterGui.Raii; using OtterGui.Raii;
using OtterGui.Services;
using OtterGui.Widgets; using OtterGui.Widgets;
using ImGuiClip = Dalamud.Interface.Utility.ImGuiClip;
namespace Glamourer.Gui.Tabs.DebugTab; namespace Glamourer.Gui.Tabs.DebugTab;
public unsafe class DebugTab(IServiceProvider _provider) : ITab public unsafe class DebugTab(ServiceManager manager) : ITab
{ {
private readonly Configuration _config = _provider.GetRequiredService<Configuration>(); private readonly Configuration _config = manager.GetService<Configuration>();
public bool IsVisible public bool IsVisible
=> _config.DebugMode; => _config.DebugMode;
@ -24,11 +18,11 @@ public unsafe class DebugTab(IServiceProvider _provider) : ITab
private readonly DebugTabHeader[] _headers = private readonly DebugTabHeader[] _headers =
[ [
DebugTabHeader.CreateInterop(_provider), DebugTabHeader.CreateInterop(manager.Provider!),
DebugTabHeader.CreateGameData(_provider), DebugTabHeader.CreateGameData(manager.Provider!),
DebugTabHeader.CreateDesigns(_provider), DebugTabHeader.CreateDesigns(manager.Provider!),
DebugTabHeader.CreateState(_provider), DebugTabHeader.CreateState(manager.Provider!),
DebugTabHeader.CreateUnlocks(_provider), DebugTabHeader.CreateUnlocks(manager.Provider!),
]; ];
public void DrawContent() public void DrawContent()
@ -37,55 +31,12 @@ public unsafe class DebugTab(IServiceProvider _provider) : ITab
if (!child) if (!child)
return; return;
if (ImGui.CollapsingHeader("General"))
{
manager.Timers.Draw("Timers");
}
foreach (var header in _headers) foreach (var header in _headers)
header.Draw(); header.Draw();
} }
public static void DrawInputModelSet(bool withWeapon, ref int setId, ref int secondaryId, ref int variant)
{
ImGui.SetNextItemWidth(100 * ImGuiHelpers.GlobalScale);
ImGui.InputInt("##SetId", ref setId, 0, 0);
if (withWeapon)
{
ImGui.SameLine();
ImGui.SetNextItemWidth(100 * ImGuiHelpers.GlobalScale);
ImGui.InputInt("##TypeId", ref secondaryId, 0, 0);
}
ImGui.SameLine();
ImGui.SetNextItemWidth(100 * ImGuiHelpers.GlobalScale);
ImGui.InputInt("##Variant", ref variant, 0, 0);
}
public static void DrawNameTable(string label, ref string filter, IEnumerable<(uint, string)> names)
{
using var _ = ImRaii.PushId(label);
using var tree = ImRaii.TreeNode(label);
if (!tree)
return;
var resetScroll = ImGui.InputTextWithHint("##filter", "Filter...", ref filter, 256);
var height = ImGui.GetTextLineHeightWithSpacing() + 2 * ImGui.GetStyle().CellPadding.Y;
using var table = ImRaii.Table("##table", 2, ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollY | ImGuiTableFlags.BordersOuter,
new Vector2(-1, 10 * height));
if (!table)
return;
if (resetScroll)
ImGui.SetScrollY(0);
ImGui.TableSetupColumn("1", ImGuiTableColumnFlags.WidthFixed, 50 * ImGuiHelpers.GlobalScale);
ImGui.TableSetupColumn("2", ImGuiTableColumnFlags.WidthStretch);
ImGui.TableNextColumn();
var skips = ImGuiClip.GetNecessarySkips(height);
ImGui.TableNextColumn();
var f = filter;
var remainder = ImGuiClip.FilteredClippedDraw(names.Select(p => (p.Item1.ToString("D5"), p.Item2)), skips,
p => p.Item1.Contains(f) || p.Item2.Contains(f, StringComparison.OrdinalIgnoreCase),
p =>
{
ImGuiUtil.DrawTableColumn(p.Item1);
ImGuiUtil.DrawTableColumn(p.Item2);
});
ImGuiClip.DrawEndDummy(remainder, height);
}
} }

View file

@ -3,7 +3,6 @@ using System.Collections.Generic;
using ImGuiNET; using ImGuiNET;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using OtterGui.Raii; using OtterGui.Raii;
using OtterGui.Services;
using Penumbra.GameData.Gui.Debug; using Penumbra.GameData.Gui.Debug;
namespace Glamourer.Gui.Tabs.DebugTab; namespace Glamourer.Gui.Tabs.DebugTab;

View file

@ -17,7 +17,8 @@ using ImGuiClip = OtterGui.ImGuiClip;
namespace Glamourer.Gui.Tabs.DebugTab; namespace Glamourer.Gui.Tabs.DebugTab;
public class NpcAppearancePanel(NpcCombo _npcCombo, StateManager _state, ObjectManager _objectManager, DesignConverter _designConverter) : IGameDataDrawer public class NpcAppearancePanel(NpcCombo _npcCombo, StateManager _state, ObjectManager _objectManager, DesignConverter _designConverter)
: IGameDataDrawer
{ {
public string Label public string Label
=> "NPC Appearance"; => "NPC Appearance";
@ -25,20 +26,23 @@ public class NpcAppearancePanel(NpcCombo _npcCombo, StateManager _state, ObjectM
public bool Disabled public bool Disabled
=> false; => false;
private string _npcFilter = string.Empty; private string _npcFilter = string.Empty;
private bool _customizeOrGear; private bool _customizeOrGear;
public void Draw() public void Draw()
{ {
ImGui.Checkbox("Compare Customize (or Gear)", ref _customizeOrGear); ImGui.Checkbox("Compare Customize (or Gear)", ref _customizeOrGear);
ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X); ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X);
ImGui.InputTextWithHint("##npcFilter", "Filter...", ref _npcFilter, 64); var resetScroll = ImGui.InputTextWithHint("##npcFilter", "Filter...", ref _npcFilter, 64);
using var table = ImRaii.Table("npcs", 5, ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollY | ImGuiTableFlags.SizingFixedFit, using var table = ImRaii.Table("npcs", 5, ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollY | ImGuiTableFlags.SizingFixedFit,
new Vector2(-1, 400 * ImGuiHelpers.GlobalScale)); new Vector2(-1, 400 * ImGuiHelpers.GlobalScale));
if (!table) if (!table)
return; return;
if (resetScroll)
ImGui.SetScrollY(0);
ImGui.TableSetupColumn("Button", ImGuiTableColumnFlags.WidthFixed); ImGui.TableSetupColumn("Button", ImGuiTableColumnFlags.WidthFixed);
ImGui.TableSetupColumn("Name", ImGuiTableColumnFlags.WidthFixed, ImGuiHelpers.GlobalScale * 300); ImGui.TableSetupColumn("Name", ImGuiTableColumnFlags.WidthFixed, ImGuiHelpers.GlobalScale * 300);
ImGui.TableSetupColumn("Kind", ImGuiTableColumnFlags.WidthFixed); ImGui.TableSetupColumn("Kind", ImGuiTableColumnFlags.WidthFixed);