Skip to content

Commit

Permalink
Fix customize check to use correct gender/clan.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ottermandias committed Feb 12, 2024
1 parent 488bea0 commit c40853e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Glamourer/Automation/AutoDesignApplier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ private unsafe void Reduce(Actor actor, ActorState state, AutoDesignSet set, boo

var mergedDesign = _designMerger.Merge(
set.Designs.Where(d => d.IsActive(actor)).SelectMany(d => d.Design?.AllLinks.Select(l => (l.Design, l.Flags & d.Type)) ?? [(d.Design, d.Type)]),
state.BaseData, true, _config.AlwaysApplyAssociatedMods);
state.ModelData.Customize, state.BaseData, true, _config.AlwaysApplyAssociatedMods);
_state.ApplyDesign(state, mergedDesign, new ApplySettings(0, StateSource.Fixed, respectManual, fromJobChange, false));
}

Expand Down
8 changes: 3 additions & 5 deletions Glamourer/Designs/DesignBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,13 @@ internal CustomizeFlag ApplyCustomizeRaw
internal MetaFlag ApplyMeta = MetaFlag.HatState | MetaFlag.VisorState | MetaFlag.WeaponState;
private bool _writeProtected;

public bool SetCustomize(CustomizeService customizeService, CustomizeArray customize, CustomizeSet? set = null)
public bool SetCustomize(CustomizeService customizeService, CustomizeArray customize)
{
if (customize.Equals(_designData.Customize))
return false;

set ??= customizeService.Manager.GetSet(customize.Clan, customize.Gender);
Debug.Assert(set.Clan == customize.Clan && set.Gender == customize.Gender, "Invalid CustomizeSet provided.");
_designData.Customize = customize;
CustomizeSet = set;
_designData.Customize = customize;
CustomizeSet = customizeService.Manager.GetSet(customize.Clan, customize.Gender);
return true;
}

Expand Down
14 changes: 9 additions & 5 deletions Glamourer/Designs/Links/DesignMerger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Glamourer.Unlocks;
using OtterGui.Services;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;

namespace Glamourer.Designs.Links;

Expand All @@ -15,13 +16,14 @@ public class DesignMerger(
ItemUnlockManager _itemUnlocks,
CustomizeUnlockManager _customizeUnlocks) : IService
{
public MergedDesign Merge(LinkContainer designs, in DesignData baseRef, bool respectOwnership, bool modAssociations)
=> Merge(designs.Select(d => ((DesignBase?) d.Link, d.Type)), baseRef, respectOwnership, modAssociations);
public MergedDesign Merge(LinkContainer designs, in CustomizeArray currentCustomize, in DesignData baseRef, bool respectOwnership, bool modAssociations)
=> Merge(designs.Select(d => ((DesignBase?) d.Link, d.Type)), currentCustomize, baseRef, respectOwnership, modAssociations);

public MergedDesign Merge(IEnumerable<(DesignBase?, ApplicationType)> designs, in DesignData baseRef, bool respectOwnership,
public MergedDesign Merge(IEnumerable<(DesignBase?, ApplicationType)> designs, in CustomizeArray currentCustomize, in DesignData baseRef, bool respectOwnership,
bool modAssociations)
{
var ret = new MergedDesign(designManager);
ret.Design.SetCustomize(_customize, currentCustomize);
CustomizeFlag fixFlags = 0;
respectOwnership &= _config.UnlockedItemMode;
foreach (var (design, type) in designs)
Expand Down Expand Up @@ -63,6 +65,8 @@ private static void ReduceMods(Design? design, MergedDesign ret, bool modAssocia
private static void ReduceMeta(in DesignData design, MetaFlag applyMeta, MergedDesign ret, StateSource source)
{
applyMeta &= ~ret.Design.ApplyMeta;
if (applyMeta == 0)
return;

foreach (var index in MetaExtensions.AllRelevant)
{
Expand Down Expand Up @@ -227,7 +231,7 @@ private void ReduceCustomize(in DesignData design, CustomizeFlag customizeFlags,
ret.Sources[CustomizeIndex.Face] = source;
}

var set = _customize.Manager.GetSet(ret.Design.DesignData.Customize.Clan, ret.Design.DesignData.Customize.Gender);
var set = _customize.Manager.GetSet(customize.Clan, customize.Gender);
var face = customize.Face;
foreach (var index in Enum.GetValues<CustomizeIndex>())
{
Expand All @@ -248,7 +252,7 @@ private void ReduceCustomize(in DesignData design, CustomizeFlag customizeFlags,
fixFlags &= ~flag;
}

ret.Design.SetCustomize(_customize, customize, set);
ret.Design.SetCustomize(_customize, customize);
}

private static void ApplyFixFlags(MergedDesign ret, CustomizeFlag fixFlags)
Expand Down
2 changes: 2 additions & 0 deletions Glamourer/Gui/Tabs/DebugTab/DesignConverterPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public void Draw()
{
using var f = ImRaii.PushFont(UiBuilder.MonoFont);
ImGuiUtil.TextWrapped(_textUncompressed);
if (ImGui.IsItemClicked())
ImGui.SetClipboardText(_textUncompressed);
}

if (_json != null)
Expand Down
2 changes: 1 addition & 1 deletion Glamourer/State/StateEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ StateSource Source(StateIndex index)
public void ApplyDesign(object data, DesignBase design, ApplySettings settings)
{
var merged = settings.MergeLinks && design is Design d
? merger.Merge(d.AllLinks, ((ActorState)data).BaseData, false, Config.AlwaysApplyAssociatedMods)
? merger.Merge(d.AllLinks, ((ActorState)data).ModelData.Customize, ((ActorState)data).BaseData, false, Config.AlwaysApplyAssociatedMods)
: new MergedDesign(design);

ApplyDesign(data, merged, settings with
Expand Down

0 comments on commit c40853e

Please sign in to comment.