mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 10:17:23 +01:00
Use new functionality.
This commit is contained in:
parent
a4de13f228
commit
2219d9293f
9 changed files with 163 additions and 136 deletions
|
|
@ -2,6 +2,7 @@ using Glamourer.Designs.Links;
|
|||
using Glamourer.Events;
|
||||
using Glamourer.GameData;
|
||||
using Glamourer.Services;
|
||||
using Glamourer.State;
|
||||
using Penumbra.GameData.Enums;
|
||||
using Penumbra.GameData.Structs;
|
||||
|
||||
|
|
@ -22,7 +23,7 @@ public class DesignEditor(
|
|||
protected readonly Configuration Config = config;
|
||||
protected readonly Dictionary<Guid, DesignData> UndoStore = [];
|
||||
|
||||
private bool _forceFullItemOff = false;
|
||||
private bool _forceFullItemOff;
|
||||
|
||||
/// <summary> Whether an Undo for the given design is possible. </summary>
|
||||
public bool CanUndo(Design? design)
|
||||
|
|
@ -31,11 +32,8 @@ public class DesignEditor(
|
|||
/// <inheritdoc/>
|
||||
public void ChangeCustomize(object data, CustomizeIndex idx, CustomizeValue value, ApplySettings _ = default)
|
||||
{
|
||||
if (data is not Design design)
|
||||
return;
|
||||
|
||||
var design = (Design)data;
|
||||
var oldValue = design.DesignData.Customize[idx];
|
||||
|
||||
switch (idx)
|
||||
{
|
||||
case CustomizeIndex.Race:
|
||||
|
|
@ -80,9 +78,7 @@ public class DesignEditor(
|
|||
/// <inheritdoc/>
|
||||
public void ChangeEntireCustomize(object data, in CustomizeArray customize, CustomizeFlag apply, ApplySettings _ = default)
|
||||
{
|
||||
if (data is not Design design)
|
||||
return;
|
||||
|
||||
var design = (Design)data;
|
||||
var (newCustomize, applied, changed) = Customizations.Combine(design.DesignData.Customize, customize, apply, true);
|
||||
if (changed == 0)
|
||||
return;
|
||||
|
|
@ -98,9 +94,7 @@ public class DesignEditor(
|
|||
/// <inheritdoc/>
|
||||
public void ChangeCustomizeParameter(object data, CustomizeParameterFlag flag, CustomizeParameterValue value, ApplySettings _ = default)
|
||||
{
|
||||
if (data is not Design design)
|
||||
return;
|
||||
|
||||
var design = (Design)data;
|
||||
var old = design.DesignData.Parameters[flag];
|
||||
if (!design.GetDesignDataRef().Parameters.Set(flag, value))
|
||||
return;
|
||||
|
|
@ -115,9 +109,7 @@ public class DesignEditor(
|
|||
/// <inheritdoc/>
|
||||
public void ChangeItem(object data, EquipSlot slot, EquipItem item, ApplySettings _ = default)
|
||||
{
|
||||
if (data is not Design design)
|
||||
return;
|
||||
|
||||
var design = (Design)data;
|
||||
switch (slot)
|
||||
{
|
||||
case EquipSlot.MainHand:
|
||||
|
|
@ -176,9 +168,7 @@ public class DesignEditor(
|
|||
/// <inheritdoc/>
|
||||
public void ChangeStain(object data, EquipSlot slot, StainId stain, ApplySettings _ = default)
|
||||
{
|
||||
if (data is not Design design)
|
||||
return;
|
||||
|
||||
var design = (Design)data;
|
||||
if (Items.ValidateStain(stain, out var _, false).Length > 0)
|
||||
return;
|
||||
|
||||
|
|
@ -204,9 +194,7 @@ public class DesignEditor(
|
|||
/// <inheritdoc/>
|
||||
public void ChangeCrest(object data, CrestFlag slot, bool crest, ApplySettings _ = default)
|
||||
{
|
||||
if (data is not Design design)
|
||||
return;
|
||||
|
||||
var design = (Design)data;
|
||||
var oldCrest = design.DesignData.Crest(slot);
|
||||
if (!design.GetDesignDataRef().SetCrest(slot, crest))
|
||||
return;
|
||||
|
|
@ -220,9 +208,7 @@ public class DesignEditor(
|
|||
/// <inheritdoc/>
|
||||
public void ChangeMetaState(object data, MetaIndex metaIndex, bool value, ApplySettings _ = default)
|
||||
{
|
||||
if (data is not Design design)
|
||||
return;
|
||||
|
||||
var design = (Design)data;
|
||||
if (!design.GetDesignDataRef().SetMeta(metaIndex, value))
|
||||
return;
|
||||
|
||||
|
|
@ -239,9 +225,7 @@ public class DesignEditor(
|
|||
/// <inheritdoc/>
|
||||
public void ApplyDesign(object data, DesignBase other, ApplySettings _ = default)
|
||||
{
|
||||
if (data is not Design design)
|
||||
return;
|
||||
|
||||
var design = (Design)data;
|
||||
UndoStore[design.Identifier] = design.DesignData;
|
||||
foreach (var index in MetaExtensions.AllRelevant.Where(other.DoApplyMeta))
|
||||
design.GetDesignDataRef().SetMeta(index, other.DesignData.GetMeta(index));
|
||||
|
|
@ -269,7 +253,7 @@ public class DesignEditor(
|
|||
}
|
||||
|
||||
/// <summary> Change a mainhand weapon and either fix or apply appropriate offhand and potentially gauntlets. </summary>
|
||||
private bool ChangeMainhandPeriphery(Design design, EquipItem currentMain, EquipItem currentOff, EquipItem newMain, out EquipItem? newOff,
|
||||
private bool ChangeMainhandPeriphery(DesignBase design, EquipItem currentMain, EquipItem currentOff, EquipItem newMain, out EquipItem? newOff,
|
||||
out EquipItem? newGauntlets)
|
||||
{
|
||||
newOff = null;
|
||||
|
|
|
|||
|
|
@ -301,7 +301,7 @@ public sealed class DesignManager : DesignEditor
|
|||
}
|
||||
|
||||
/// <summary> Change whether to apply a specific equipment piece. </summary>
|
||||
public void ChangeApplyEquip(Design design, EquipSlot slot, bool value)
|
||||
public void ChangeApplyItem(Design design, EquipSlot slot, bool value)
|
||||
{
|
||||
if (!design.SetApplyEquip(slot, value))
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,19 +1,28 @@
|
|||
using Glamourer.Designs;
|
||||
using Glamourer.Events;
|
||||
using Glamourer.GameData;
|
||||
using Glamourer.State;
|
||||
|
||||
namespace Glamourer.Gui.Customization;
|
||||
|
||||
public ref struct CustomizeParameterDrawData(CustomizeParameterFlag flag, in DesignData data)
|
||||
public struct CustomizeParameterDrawData(CustomizeParameterFlag flag, in DesignData data)
|
||||
{
|
||||
private IDesignEditor _editor;
|
||||
private object _object;
|
||||
public readonly CustomizeParameterFlag Flag = flag;
|
||||
public bool Locked;
|
||||
public bool DisplayApplication;
|
||||
public bool AllowRevert;
|
||||
|
||||
public Action<CustomizeParameterValue> ValueSetter = null!;
|
||||
public Action<bool> ApplySetter = null!;
|
||||
public readonly void ChangeParameter(CustomizeParameterValue value)
|
||||
=> _editor.ChangeCustomizeParameter(_object, Flag, value, ApplySettings.Manual);
|
||||
|
||||
public readonly void ChangeApplyParameter(bool value)
|
||||
{
|
||||
var manager = (DesignManager)_editor;
|
||||
var design = (Design)_object;
|
||||
manager.ChangeApplyParameter(design, Flag, value);
|
||||
}
|
||||
|
||||
public CustomizeParameterValue CurrentValue = data.Parameters[flag];
|
||||
public CustomizeParameterValue GameValue;
|
||||
public bool CurrentApply;
|
||||
|
|
@ -21,19 +30,20 @@ public ref struct CustomizeParameterDrawData(CustomizeParameterFlag flag, in Des
|
|||
public static CustomizeParameterDrawData FromDesign(DesignManager manager, Design design, CustomizeParameterFlag flag)
|
||||
=> new(flag, design.DesignData)
|
||||
{
|
||||
_editor = manager,
|
||||
_object = design,
|
||||
Locked = design.WriteProtected(),
|
||||
DisplayApplication = true,
|
||||
CurrentApply = design.DoApplyParameter(flag),
|
||||
ValueSetter = v => manager.ChangeCustomizeParameter(design, flag, v),
|
||||
ApplySetter = v => manager.ChangeApplyParameter(design, flag, v),
|
||||
};
|
||||
|
||||
public static CustomizeParameterDrawData FromState(StateManager manager, ActorState state, CustomizeParameterFlag flag)
|
||||
=> new(flag, state.ModelData)
|
||||
{
|
||||
_editor = manager,
|
||||
_object = state,
|
||||
Locked = state.IsLocked,
|
||||
DisplayApplication = false,
|
||||
ValueSetter = v => manager.ChangeCustomizeParameter(state, flag, v, ApplySettings.Manual),
|
||||
GameValue = state.BaseData.Parameters[flag],
|
||||
AllowRevert = true,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ public class CustomizeParameterDrawer(Configuration config, PaletteImport import
|
|||
using (_ = ImRaii.Disabled(data.Locked || noHighlights))
|
||||
{
|
||||
if (ImGui.ColorEdit3("##value", ref value, GetFlags()))
|
||||
data.ValueSetter(new CustomizeParameterValue(value));
|
||||
data.ChangeParameter(new CustomizeParameterValue(value));
|
||||
}
|
||||
|
||||
if (noHighlights)
|
||||
|
|
@ -215,7 +215,7 @@ public class CustomizeParameterDrawer(Configuration config, PaletteImport import
|
|||
using (_ = ImRaii.Disabled(data.Locked))
|
||||
{
|
||||
if (ImGui.ColorEdit4("##value", ref value, GetFlags() | ImGuiColorEditFlags.AlphaPreviewHalf))
|
||||
data.ValueSetter(new CustomizeParameterValue(value));
|
||||
data.ChangeParameter(new CustomizeParameterValue(value));
|
||||
}
|
||||
|
||||
DrawRevert(data);
|
||||
|
|
@ -231,7 +231,7 @@ public class CustomizeParameterDrawer(Configuration config, PaletteImport import
|
|||
using (_ = ImRaii.Disabled(data.Locked))
|
||||
{
|
||||
if (ImGui.InputFloat("##value", ref value, 0.1f, 0.5f))
|
||||
data.ValueSetter(new CustomizeParameterValue(value));
|
||||
data.ChangeParameter(new CustomizeParameterValue(value));
|
||||
}
|
||||
|
||||
DrawRevert(data);
|
||||
|
|
@ -247,7 +247,7 @@ public class CustomizeParameterDrawer(Configuration config, PaletteImport import
|
|||
using (_ = ImRaii.Disabled(data.Locked))
|
||||
{
|
||||
if (ImGui.SliderFloat("##value", ref value, -100f, 300, "%.2f"))
|
||||
data.ValueSetter(new CustomizeParameterValue(value / 100f));
|
||||
data.ChangeParameter(new CustomizeParameterValue(value / 100f));
|
||||
ImGuiUtil.HoverTooltip("You can control-click this to enter arbitrary values by hand instead of dragging.");
|
||||
}
|
||||
|
||||
|
|
@ -262,7 +262,7 @@ public class CustomizeParameterDrawer(Configuration config, PaletteImport import
|
|||
return;
|
||||
|
||||
if (ImGui.IsItemClicked(ImGuiMouseButton.Right) && ImGui.GetIO().KeyCtrl)
|
||||
data.ValueSetter(data.GameValue);
|
||||
data.ChangeParameter(data.GameValue);
|
||||
|
||||
ImGuiUtil.HoverTooltip("Hold Control and Right-click to revert to game values.");
|
||||
}
|
||||
|
|
@ -271,7 +271,7 @@ public class CustomizeParameterDrawer(Configuration config, PaletteImport import
|
|||
{
|
||||
if (UiHelpers.DrawCheckbox("##apply", "Apply this custom parameter when applying the Design.", data.CurrentApply, out var enabled,
|
||||
data.Locked))
|
||||
data.ApplySetter(enabled);
|
||||
data.ChangeApplyParameter(enabled);
|
||||
}
|
||||
|
||||
private void DrawApplyAndLabel(in CustomizeParameterDrawData data)
|
||||
|
|
@ -310,6 +310,6 @@ public class CustomizeParameterDrawer(Configuration config, PaletteImport import
|
|||
ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.X);
|
||||
if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Paste.ToIconString(), new Vector2(ImGui.GetFrameHeight()),
|
||||
_copy.HasValue ? "Paste the currently copied value." : "No value copied yet.", locked || !_copy.HasValue, true))
|
||||
data.ValueSetter(_copy!.Value);
|
||||
data.ChangeParameter(_copy!.Value);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +1,45 @@
|
|||
using Dalamud.Game.Inventory;
|
||||
using Glamourer.Designs;
|
||||
using Glamourer.Events;
|
||||
using Glamourer.Designs;
|
||||
using Glamourer.State;
|
||||
using Penumbra.GameData.Enums;
|
||||
using Penumbra.GameData.Structs;
|
||||
|
||||
namespace Glamourer.Gui.Equipment;
|
||||
|
||||
public ref struct EquipDrawData(EquipSlot slot, in DesignData designData)
|
||||
public struct EquipDrawData(EquipSlot slot, in DesignData designData)
|
||||
{
|
||||
public readonly EquipSlot Slot = slot;
|
||||
public bool Locked;
|
||||
public bool DisplayApplication;
|
||||
public bool AllowRevert;
|
||||
private IDesignEditor _editor;
|
||||
private object _object;
|
||||
public readonly EquipSlot Slot = slot;
|
||||
public bool Locked;
|
||||
public bool DisplayApplication;
|
||||
public bool AllowRevert;
|
||||
|
||||
public Action<EquipItem> ItemSetter = null!;
|
||||
public Action<StainId> StainSetter = null!;
|
||||
public Action<bool> ApplySetter = null!;
|
||||
public Action<bool> ApplyStainSetter = null!;
|
||||
public EquipItem CurrentItem = designData.Item(slot);
|
||||
public StainId CurrentStain = designData.Stain(slot);
|
||||
public EquipItem GameItem = default;
|
||||
public StainId GameStain = default;
|
||||
public bool CurrentApply;
|
||||
public bool CurrentApplyStain;
|
||||
public readonly void SetItem(EquipItem item)
|
||||
=> _editor.ChangeItem(_object, Slot, item, ApplySettings.Manual);
|
||||
|
||||
public readonly void SetStain(StainId stain)
|
||||
=> _editor.ChangeStain(_object, Slot, stain, ApplySettings.Manual);
|
||||
|
||||
public readonly void SetApplyItem(bool value)
|
||||
{
|
||||
var manager = (DesignManager)_editor;
|
||||
var design = (Design)_object;
|
||||
manager.ChangeApplyItem(design, Slot, value);
|
||||
}
|
||||
|
||||
public readonly void SetApplyStain(bool value)
|
||||
{
|
||||
var manager = (DesignManager)_editor;
|
||||
var design = (Design)_object;
|
||||
manager.ChangeApplyStain(design, Slot, value);
|
||||
}
|
||||
|
||||
public EquipItem CurrentItem = designData.Item(slot);
|
||||
public StainId CurrentStain = designData.Stain(slot);
|
||||
public EquipItem GameItem = default;
|
||||
public StainId GameStain = default;
|
||||
public bool CurrentApply;
|
||||
public bool CurrentApplyStain;
|
||||
|
||||
public readonly Gender CurrentGender = designData.Customize.Gender;
|
||||
public readonly Race CurrentRace = designData.Customize.Race;
|
||||
|
|
@ -31,10 +47,8 @@ public ref struct EquipDrawData(EquipSlot slot, in DesignData designData)
|
|||
public static EquipDrawData FromDesign(DesignManager manager, Design design, EquipSlot slot)
|
||||
=> new(slot, design.DesignData)
|
||||
{
|
||||
ItemSetter = i => manager.ChangeItem(design, slot, i),
|
||||
StainSetter = i => manager.ChangeStain(design, slot, i),
|
||||
ApplySetter = b => manager.ChangeApplyEquip(design, slot, b),
|
||||
ApplyStainSetter = b => manager.ChangeApplyStain(design, slot, b),
|
||||
_editor = manager,
|
||||
_object = design,
|
||||
CurrentApply = design.DoApplyEquip(slot),
|
||||
CurrentApplyStain = design.DoApplyStain(slot),
|
||||
Locked = design.WriteProtected(),
|
||||
|
|
@ -44,8 +58,8 @@ public ref struct EquipDrawData(EquipSlot slot, in DesignData designData)
|
|||
public static EquipDrawData FromState(StateManager manager, ActorState state, EquipSlot slot)
|
||||
=> new(slot, state.ModelData)
|
||||
{
|
||||
ItemSetter = i => manager.ChangeItem(state, slot, i, ApplySettings.Manual),
|
||||
StainSetter = i => manager.ChangeStain(state, slot, i, ApplySettings.Manual),
|
||||
_editor = manager,
|
||||
_object = state,
|
||||
Locked = state.IsLocked,
|
||||
DisplayApplication = false,
|
||||
GameItem = state.BaseData.Item(slot),
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ public class EquipmentDrawer
|
|||
{
|
||||
var newSetId = (PrimaryId)Math.Clamp(setId, 0, ushort.MaxValue);
|
||||
if (newSetId.Id != current.CurrentItem.PrimaryId.Id)
|
||||
current.ItemSetter(_items.Identify(current.Slot, newSetId, current.CurrentItem.SecondaryId, current.CurrentItem.Variant));
|
||||
current.SetItem(_items.Identify(current.Slot, newSetId, current.CurrentItem.SecondaryId, current.CurrentItem.Variant));
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
|
|
@ -214,7 +214,7 @@ public class EquipmentDrawer
|
|||
{
|
||||
var newType = (SecondaryId)Math.Clamp(type, 0, ushort.MaxValue);
|
||||
if (newType.Id != current.CurrentItem.SecondaryId.Id)
|
||||
current.ItemSetter(_items.Identify(current.Slot, current.CurrentItem.PrimaryId, newType, current.CurrentItem.Variant));
|
||||
current.SetItem(_items.Identify(current.Slot, current.CurrentItem.PrimaryId, newType, current.CurrentItem.Variant));
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
|
|
@ -223,7 +223,7 @@ public class EquipmentDrawer
|
|||
{
|
||||
var newVariant = (Variant)Math.Clamp(variant, 0, byte.MaxValue);
|
||||
if (newVariant.Id != current.CurrentItem.Variant.Id)
|
||||
current.ItemSetter(_items.Identify(current.Slot, current.CurrentItem.PrimaryId, current.CurrentItem.SecondaryId,
|
||||
current.SetItem(_items.Identify(current.Slot, current.CurrentItem.PrimaryId, current.CurrentItem.SecondaryId,
|
||||
newVariant));
|
||||
}
|
||||
}
|
||||
|
|
@ -239,7 +239,7 @@ public class EquipmentDrawer
|
|||
|
||||
var newStainId = (StainId)Math.Clamp(stainId, 0, byte.MaxValue);
|
||||
if (newStainId != data.CurrentStain.Id)
|
||||
data.StainSetter(newStainId);
|
||||
data.SetStain(newStainId);
|
||||
}
|
||||
|
||||
/// <summary> Draw an input for armor that can set arbitrary values instead of choosing items. </summary>
|
||||
|
|
@ -252,7 +252,7 @@ public class EquipmentDrawer
|
|||
{
|
||||
var newSetId = (PrimaryId)Math.Clamp(setId, 0, ushort.MaxValue);
|
||||
if (newSetId.Id != data.CurrentItem.PrimaryId.Id)
|
||||
data.ItemSetter(_items.Identify(data.Slot, newSetId, data.CurrentItem.Variant));
|
||||
data.SetItem(_items.Identify(data.Slot, newSetId, data.CurrentItem.Variant));
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
|
|
@ -261,7 +261,7 @@ public class EquipmentDrawer
|
|||
{
|
||||
var newVariant = (byte)Math.Clamp(variant, 0, byte.MaxValue);
|
||||
if (newVariant != data.CurrentItem.Variant)
|
||||
data.ItemSetter(_items.Identify(data.Slot, data.CurrentItem.PrimaryId, newVariant));
|
||||
data.SetItem(_items.Identify(data.Slot, data.CurrentItem.PrimaryId, newVariant));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -365,7 +365,7 @@ public class EquipmentDrawer
|
|||
mainhand.CurrentItem.DrawIcon(_textures, _iconSize, EquipSlot.MainHand);
|
||||
var left = ImGui.IsItemClicked(ImGuiMouseButton.Left);
|
||||
ImGui.SameLine();
|
||||
using (var group = ImRaii.Group())
|
||||
using (ImRaii.Group())
|
||||
{
|
||||
DrawMainhand(ref mainhand, ref offhand, out var mainhandLabel, allWeapons, false, left);
|
||||
if (mainhand.DisplayApplication)
|
||||
|
|
@ -391,7 +391,7 @@ public class EquipmentDrawer
|
|||
var right = ImGui.IsItemClicked(ImGuiMouseButton.Right);
|
||||
left = ImGui.IsItemClicked(ImGuiMouseButton.Left);
|
||||
ImGui.SameLine();
|
||||
using (var group = ImRaii.Group())
|
||||
using (ImRaii.Group())
|
||||
{
|
||||
DrawOffhand(mainhand, offhand, out var offhandLabel, false, right, left);
|
||||
if (offhand.DisplayApplication)
|
||||
|
|
@ -420,12 +420,12 @@ public class EquipmentDrawer
|
|||
: _stainCombo.Draw($"##stain{data.Slot}", stain.RgbaColor, stain.Name, found, stain.Gloss, _comboLength);
|
||||
if (change)
|
||||
if (_stainData.TryGetValue(_stainCombo.CurrentSelection.Key, out stain))
|
||||
data.StainSetter(stain.RowIndex);
|
||||
data.SetStain(stain.RowIndex);
|
||||
else if (_stainCombo.CurrentSelection.Key == Stain.None.RowIndex)
|
||||
data.StainSetter(Stain.None.RowIndex);
|
||||
data.SetStain(Stain.None.RowIndex);
|
||||
|
||||
if (ResetOrClear(data.Locked, false, data.AllowRevert, true, data.CurrentStain, data.GameStain, Stain.None.RowIndex, out var id))
|
||||
data.StainSetter(Stain.None.RowIndex);
|
||||
if (ResetOrClear(data.Locked, false, data.AllowRevert, true, data.CurrentStain, data.GameStain, Stain.None.RowIndex, out _))
|
||||
data.SetStain(Stain.None.RowIndex);
|
||||
}
|
||||
|
||||
private void DrawItem(in EquipDrawData data, out string label, bool small, bool clear, bool open)
|
||||
|
|
@ -441,13 +441,13 @@ public class EquipmentDrawer
|
|||
var change = combo.Draw(data.CurrentItem.Name, data.CurrentItem.ItemId, small ? _comboLength - ImGui.GetFrameHeight() : _comboLength,
|
||||
_requiredComboWidth);
|
||||
if (change)
|
||||
data.ItemSetter(combo.CurrentSelection);
|
||||
data.SetItem(combo.CurrentSelection);
|
||||
else if (combo.CustomVariant.Id > 0)
|
||||
data.ItemSetter(_items.Identify(data.Slot, combo.CustomSetId, combo.CustomVariant));
|
||||
data.SetItem(_items.Identify(data.Slot, combo.CustomSetId, combo.CustomVariant));
|
||||
|
||||
if (ResetOrClear(data.Locked, clear, data.AllowRevert, true, data.CurrentItem, data.GameItem, ItemManager.NothingItem(data.Slot),
|
||||
out var item))
|
||||
data.ItemSetter(item);
|
||||
data.SetItem(item);
|
||||
}
|
||||
|
||||
private static bool ResetOrClear<T>(bool locked, bool clicked, bool allowRevert, bool allowClear,
|
||||
|
|
@ -467,9 +467,9 @@ public class EquipmentDrawer
|
|||
(true, true, true) => ("Right-click to clear. Control and Right-Click to revert to game.", revertItem, true),
|
||||
(true, true, false) => ("Right-click to clear. Control and Right-Click to revert to game.", clearItem, true),
|
||||
(true, false, true) => ("Control and Right-Click to revert to game.", revertItem, true),
|
||||
(true, false, false) => ("Control and Right-Click to revert to game.", (T?)default, false),
|
||||
(true, false, false) => ("Control and Right-Click to revert to game.", default, false),
|
||||
(false, true, _) => ("Right-click to clear.", clearItem, true),
|
||||
(false, false, _) => (string.Empty, (T?)default, false),
|
||||
(false, false, _) => (string.Empty, default, false),
|
||||
};
|
||||
ImGuiUtil.HoverTooltip(tt);
|
||||
|
||||
|
|
@ -502,11 +502,11 @@ public class EquipmentDrawer
|
|||
|
||||
if (changedItem != null)
|
||||
{
|
||||
mainhand.ItemSetter(changedItem.Value);
|
||||
mainhand.SetItem(changedItem.Value);
|
||||
if (changedItem.Value.Type.ValidOffhand() != mainhand.CurrentItem.Type.ValidOffhand())
|
||||
{
|
||||
offhand.CurrentItem = _items.GetDefaultOffhand(changedItem.Value);
|
||||
offhand.ItemSetter(offhand.CurrentItem);
|
||||
offhand.SetItem(offhand.CurrentItem);
|
||||
}
|
||||
|
||||
mainhand.CurrentItem = changedItem.Value;
|
||||
|
|
@ -533,18 +533,18 @@ public class EquipmentDrawer
|
|||
UiHelpers.OpenCombo($"##{combo.Label}");
|
||||
if (combo.Draw(offhand.CurrentItem.Name, offhand.CurrentItem.ItemId, small ? _comboLength - ImGui.GetFrameHeight() : _comboLength,
|
||||
_requiredComboWidth))
|
||||
offhand.ItemSetter(combo.CurrentSelection);
|
||||
offhand.SetItem(combo.CurrentSelection);
|
||||
|
||||
var defaultOffhand = _items.GetDefaultOffhand(mainhand.CurrentItem);
|
||||
if (ResetOrClear(locked, open, offhand.AllowRevert, true, offhand.CurrentItem, offhand.GameItem, defaultOffhand, out var item))
|
||||
offhand.ItemSetter(item);
|
||||
if (ResetOrClear(locked, clear, offhand.AllowRevert, true, offhand.CurrentItem, offhand.GameItem, defaultOffhand, out var item))
|
||||
offhand.SetItem(item);
|
||||
}
|
||||
|
||||
private static void DrawApply(in EquipDrawData data)
|
||||
{
|
||||
if (UiHelpers.DrawCheckbox($"##apply{data.Slot}", "Apply this item when applying the Design.", data.CurrentApply, out var enabled,
|
||||
data.Locked))
|
||||
data.ApplySetter(enabled);
|
||||
data.SetApplyItem(enabled);
|
||||
}
|
||||
|
||||
private static void DrawApplyStain(in EquipDrawData data)
|
||||
|
|
@ -552,7 +552,7 @@ public class EquipmentDrawer
|
|||
if (UiHelpers.DrawCheckbox($"##applyStain{data.Slot}", "Apply this item when applying the Design.", data.CurrentApplyStain,
|
||||
out var enabled,
|
||||
data.Locked))
|
||||
data.ApplyStainSetter(enabled);
|
||||
data.SetApplyStain(enabled);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ public class DesignPanel(
|
|||
{
|
||||
var apply = bigChange ? ((EquipFlag)flags).HasFlag(slot.ToFlag()) : _selector.Selected!.DoApplyEquip(slot);
|
||||
if (ImGui.Checkbox($"Apply {slot.ToName()}", ref apply) || bigChange)
|
||||
_manager.ChangeApplyEquip(_selector.Selected!, slot, apply);
|
||||
_manager.ChangeApplyItem(_selector.Selected!, slot, apply);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,74 +4,109 @@ using Penumbra.GameData.Enums;
|
|||
|
||||
namespace Glamourer.Gui;
|
||||
|
||||
public ref struct ToggleDrawData
|
||||
public struct ToggleDrawData
|
||||
{
|
||||
private IDesignEditor _editor = null!;
|
||||
private object _data = null!;
|
||||
private StateIndex _index;
|
||||
|
||||
public bool Locked;
|
||||
public bool DisplayApplication;
|
||||
|
||||
public bool CurrentValue;
|
||||
public bool CurrentApply;
|
||||
|
||||
public Action<bool> SetValue = null!;
|
||||
public Action<bool> SetApply = null!;
|
||||
|
||||
public string Label = string.Empty;
|
||||
public string Tooltip = string.Empty;
|
||||
|
||||
|
||||
public ToggleDrawData()
|
||||
{ }
|
||||
|
||||
public readonly void SetValue(bool value)
|
||||
{
|
||||
switch (_index.GetFlag())
|
||||
{
|
||||
case MetaIndex index:
|
||||
_editor.ChangeMetaState(_data, index, value, ApplySettings.Manual);
|
||||
break;
|
||||
case CrestFlag flag:
|
||||
_editor.ChangeCrest(_data, flag, value, ApplySettings.Manual);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public readonly void SetApply(bool value)
|
||||
{
|
||||
var manager = (DesignManager)_editor;
|
||||
var design = (Design)_data;
|
||||
switch (_index.GetFlag())
|
||||
{
|
||||
case MetaIndex index:
|
||||
manager.ChangeApplyMeta(design, index, value);
|
||||
break;
|
||||
case CrestFlag flag:
|
||||
manager.ChangeApplyCrest(design, flag, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static ToggleDrawData FromDesign(MetaIndex index, DesignManager manager, Design design)
|
||||
=> new()
|
||||
{
|
||||
_index = index,
|
||||
_editor = manager,
|
||||
_data = design,
|
||||
Label = index.ToName(),
|
||||
Tooltip = string.Empty,
|
||||
Locked = design.WriteProtected(),
|
||||
DisplayApplication = true,
|
||||
CurrentValue = design.DesignData.GetMeta(index),
|
||||
CurrentApply = design.DoApplyMeta(index),
|
||||
SetValue = b => manager.ChangeMetaState(design, index, b),
|
||||
SetApply = b => manager.ChangeApplyMeta(design, index, b),
|
||||
};
|
||||
|
||||
public static ToggleDrawData FromState(MetaIndex index, StateManager manager, ActorState state)
|
||||
=> new()
|
||||
{
|
||||
_index = index,
|
||||
_editor = manager,
|
||||
_data = state,
|
||||
Label = index.ToName(),
|
||||
Tooltip = index.ToTooltip(),
|
||||
Locked = state.IsLocked,
|
||||
CurrentValue = state.ModelData.GetMeta(index),
|
||||
};
|
||||
|
||||
public static ToggleDrawData CrestFromDesign(CrestFlag slot, DesignManager manager, Design design)
|
||||
=> new()
|
||||
{
|
||||
_index = slot,
|
||||
_editor = manager,
|
||||
_data = design,
|
||||
Label = $"{slot.ToLabel()} Crest",
|
||||
Tooltip = string.Empty,
|
||||
Locked = design.WriteProtected(),
|
||||
DisplayApplication = true,
|
||||
CurrentValue = design.DesignData.Crest(slot),
|
||||
CurrentApply = design.DoApplyCrest(slot),
|
||||
SetValue = v => manager.ChangeCrest(design, slot, v),
|
||||
SetApply = v => manager.ChangeApplyCrest(design, slot, v),
|
||||
};
|
||||
|
||||
public static ToggleDrawData CrestFromState(CrestFlag slot, StateManager manager, ActorState state)
|
||||
=> new()
|
||||
{
|
||||
_index = slot,
|
||||
_editor = manager,
|
||||
_data = state,
|
||||
Label = $"{slot.ToLabel()} Crest",
|
||||
Tooltip = "Hide or show your free company crest on this piece of gear.",
|
||||
Locked = state.IsLocked,
|
||||
CurrentValue = state.ModelData.Crest(slot),
|
||||
SetValue = v => manager.ChangeCrest(state, slot, v, ApplySettings.Manual),
|
||||
};
|
||||
|
||||
public static ToggleDrawData FromState(MetaIndex index, StateManager manager, ActorState state)
|
||||
{
|
||||
return new ToggleDrawData
|
||||
{
|
||||
Label = index.ToName(),
|
||||
Tooltip = index.ToTooltip(),
|
||||
Locked = state.IsLocked,
|
||||
CurrentValue = state.ModelData.GetMeta(index),
|
||||
SetValue = b => manager.ChangeMetaState(state, index, b, ApplySettings.Manual),
|
||||
};
|
||||
}
|
||||
|
||||
public static ToggleDrawData FromValue(MetaIndex index, bool value)
|
||||
=> new()
|
||||
{
|
||||
_index = index,
|
||||
Label = index.ToName(),
|
||||
Tooltip = index.ToTooltip(),
|
||||
Locked = true,
|
||||
|
|
|
|||
|
|
@ -39,9 +39,7 @@ public class StateEditor(
|
|||
/// <inheritdoc/>
|
||||
public void ChangeCustomize(object data, CustomizeIndex idx, CustomizeValue value, ApplySettings settings)
|
||||
{
|
||||
if (data is not ActorState state)
|
||||
return;
|
||||
|
||||
var state = (ActorState)data;
|
||||
if (!Editor.ChangeCustomize(state, idx, value, settings.Source, out var old, settings.Key))
|
||||
return;
|
||||
|
||||
|
|
@ -54,9 +52,7 @@ public class StateEditor(
|
|||
/// <inheritdoc/>
|
||||
public void ChangeEntireCustomize(object data, in CustomizeArray customizeInput, CustomizeFlag apply, ApplySettings settings)
|
||||
{
|
||||
if (data is not ActorState state)
|
||||
return;
|
||||
|
||||
var state = (ActorState)data;
|
||||
if (!Editor.ChangeHumanCustomize(state, customizeInput, apply, _ => settings.Source, out var old, out var applied, settings.Key))
|
||||
return;
|
||||
|
||||
|
|
@ -69,9 +65,7 @@ public class StateEditor(
|
|||
/// <inheritdoc/>
|
||||
public void ChangeItem(object data, EquipSlot slot, EquipItem item, ApplySettings settings = default)
|
||||
{
|
||||
if (data is not ActorState state)
|
||||
return;
|
||||
|
||||
var state = (ActorState)data;
|
||||
if (!Editor.ChangeItem(state, slot, item, settings.Source, out var old, settings.Key))
|
||||
return;
|
||||
|
||||
|
|
@ -103,9 +97,7 @@ public class StateEditor(
|
|||
return;
|
||||
}
|
||||
|
||||
if (data is not ActorState state)
|
||||
return;
|
||||
|
||||
var state = (ActorState)data;
|
||||
if (!Editor.ChangeEquip(state, slot, item ?? state.ModelData.Item(slot), stain ?? state.ModelData.Stain(slot), settings.Source,
|
||||
out var old, out var oldStain, settings.Key))
|
||||
return;
|
||||
|
|
@ -128,9 +120,7 @@ public class StateEditor(
|
|||
/// <inheritdoc/>
|
||||
public void ChangeStain(object data, EquipSlot slot, StainId stain, ApplySettings settings)
|
||||
{
|
||||
if (data is not ActorState state)
|
||||
return;
|
||||
|
||||
var state = (ActorState)data;
|
||||
if (!Editor.ChangeStain(state, slot, stain, settings.Source, out var old, settings.Key))
|
||||
return;
|
||||
|
||||
|
|
@ -143,9 +133,7 @@ public class StateEditor(
|
|||
/// <inheritdoc/>
|
||||
public void ChangeCrest(object data, CrestFlag slot, bool crest, ApplySettings settings)
|
||||
{
|
||||
if (data is not ActorState state)
|
||||
return;
|
||||
|
||||
var state = (ActorState)data;
|
||||
if (!Editor.ChangeCrest(state, slot, crest, settings.Source, out var old, settings.Key))
|
||||
return;
|
||||
|
||||
|
|
@ -178,9 +166,7 @@ public class StateEditor(
|
|||
/// <inheritdoc/>
|
||||
public void ChangeMetaState(object data, MetaIndex index, bool value, ApplySettings settings)
|
||||
{
|
||||
if (data is not ActorState state)
|
||||
return;
|
||||
|
||||
var state = (ActorState)data;
|
||||
if (!Editor.ChangeMetaState(state, index, value, settings.Source, out var old, settings.Key))
|
||||
return;
|
||||
|
||||
|
|
@ -193,9 +179,7 @@ public class StateEditor(
|
|||
/// <inheritdoc/>
|
||||
public void ApplyDesign(object data, MergedDesign mergedDesign, ApplySettings settings)
|
||||
{
|
||||
if (data is not ActorState state)
|
||||
return;
|
||||
|
||||
var state = (ActorState)data;
|
||||
if (!Editor.ChangeModelId(state, mergedDesign.Design.DesignData.ModelId, mergedDesign.Design.DesignData.Customize,
|
||||
mergedDesign.Design.GetDesignDataRef().GetEquipmentPtr(), settings.Source, out var oldModelId, settings.Key))
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue