mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 18:27:24 +01:00
Refactor drawing of equipment to be more sane.
This commit is contained in:
parent
eed11bb67f
commit
60a53d4bff
9 changed files with 536 additions and 763 deletions
|
|
@ -194,14 +194,14 @@ public partial class CustomizationDrawer
|
|||
{
|
||||
switch (UiHelpers.DrawMetaToggle(_currentIndex.ToDefaultName(), tmp, _currentApply, out var newValue, out var newApply, _locked))
|
||||
{
|
||||
case DataChange.Item:
|
||||
case (true, false):
|
||||
_customize.Set(idx, newValue ? CustomizeValue.Max : CustomizeValue.Zero);
|
||||
Changed |= _currentFlag;
|
||||
break;
|
||||
case DataChange.ApplyItem:
|
||||
case (false, true):
|
||||
ChangeApply = newApply ? ChangeApply | _currentFlag : ChangeApply & ~_currentFlag;
|
||||
break;
|
||||
case DataChange.Item | DataChange.ApplyItem:
|
||||
case (true, true):
|
||||
ChangeApply = newApply ? ChangeApply | _currentFlag : ChangeApply & ~_currentFlag;
|
||||
_customize.Set(idx, newValue ? CustomizeValue.Max : CustomizeValue.Zero);
|
||||
Changed |= _currentFlag;
|
||||
|
|
|
|||
|
|
@ -14,18 +14,16 @@ using CustomizeData = Penumbra.GameData.Structs.CustomizeData;
|
|||
|
||||
namespace Glamourer.Gui.Customization;
|
||||
|
||||
public partial class CustomizationDrawer : IDisposable
|
||||
public partial class CustomizationDrawer(DalamudPluginInterface pi, CustomizationService _service, CodeService _codes, Configuration _config)
|
||||
: IDisposable
|
||||
{
|
||||
private readonly CodeService _codes;
|
||||
private readonly Configuration _config;
|
||||
|
||||
private readonly Vector4 _redTint = new(0.6f, 0.3f, 0.3f, 1f);
|
||||
private readonly IDalamudTextureWrap? _legacyTattoo;
|
||||
private readonly Vector4 _redTint = new(0.6f, 0.3f, 0.3f, 1f);
|
||||
private readonly IDalamudTextureWrap? _legacyTattoo = GetLegacyTattooIcon(pi);
|
||||
|
||||
private Exception? _terminate;
|
||||
|
||||
private Customize _customize;
|
||||
private CustomizationSet _set = null!;
|
||||
private Customize _customize = Customize.Default;
|
||||
private CustomizationSet _set = null!;
|
||||
|
||||
public Customize Customize
|
||||
=> _customize;
|
||||
|
|
@ -46,21 +44,8 @@ public partial class CustomizationDrawer : IDisposable
|
|||
private float _raceSelectorWidth;
|
||||
private bool _withApply;
|
||||
|
||||
private readonly CustomizationService _service;
|
||||
|
||||
public CustomizationDrawer(DalamudPluginInterface pi, CustomizationService service, CodeService codes, Configuration config)
|
||||
{
|
||||
_service = service;
|
||||
_codes = codes;
|
||||
_config = config;
|
||||
_legacyTattoo = GetLegacyTattooIcon(pi);
|
||||
_customize = Customize.Default;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_legacyTattoo?.Dispose();
|
||||
}
|
||||
=> _legacyTattoo?.Dispose();
|
||||
|
||||
public bool Draw(Customize current, bool locked, bool lockedRedraw)
|
||||
{
|
||||
|
|
@ -125,12 +110,6 @@ public partial class CustomizationDrawer : IDisposable
|
|||
Changed |= _currentFlag;
|
||||
}
|
||||
|
||||
public bool DrawWetnessState(bool currentValue, out bool newValue, bool locked)
|
||||
=> UiHelpers.DrawCheckbox("Force Wetness", "Force the character to be wet or not.", currentValue, out newValue, locked);
|
||||
|
||||
public DataChange DrawWetnessState(bool currentValue, bool currentApply, out bool newValue, out bool newApply, bool locked)
|
||||
=> UiHelpers.DrawMetaToggle("Force Wetness", currentValue, currentApply, out newValue, out newApply, locked);
|
||||
|
||||
private bool DrawInternal()
|
||||
{
|
||||
using var spacing = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, _spacing);
|
||||
|
|
@ -199,13 +178,13 @@ public partial class CustomizationDrawer : IDisposable
|
|||
|
||||
private void UpdateSizes()
|
||||
{
|
||||
_spacing = ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemInnerSpacing.X };
|
||||
_iconSize = new Vector2(ImGui.GetTextLineHeight() * 2 + _spacing.Y + 2 * ImGui.GetStyle().FramePadding.Y);
|
||||
_framedIconSize = _iconSize + 2 * ImGui.GetStyle().FramePadding;
|
||||
_inputIntSize = 2 * _framedIconSize.X + 1 * _spacing.X;
|
||||
_spacing = ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemInnerSpacing.X };
|
||||
_iconSize = new Vector2(ImGui.GetTextLineHeight() * 2 + _spacing.Y + 2 * ImGui.GetStyle().FramePadding.Y);
|
||||
_framedIconSize = _iconSize + 2 * ImGui.GetStyle().FramePadding;
|
||||
_inputIntSize = 2 * _framedIconSize.X + 1 * _spacing.X;
|
||||
_inputIntSizeNoButtons = _inputIntSize - 2 * _spacing.X - 2 * ImGui.GetFrameHeight();
|
||||
_comboSelectorSize = 4 * _framedIconSize.X + 3 * _spacing.X;
|
||||
_raceSelectorWidth = _inputIntSize + _comboSelectorSize - _framedIconSize.X;
|
||||
_comboSelectorSize = 4 * _framedIconSize.X + 3 * _spacing.X;
|
||||
_raceSelectorWidth = _inputIntSize + _comboSelectorSize - _framedIconSize.X;
|
||||
}
|
||||
|
||||
private static IDalamudTextureWrap? GetLegacyTattooIcon(DalamudPluginInterface pi)
|
||||
|
|
|
|||
49
Glamourer/Gui/Equipment/EquipDrawData.cs
Normal file
49
Glamourer/Gui/Equipment/EquipDrawData.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
using System;
|
||||
using Glamourer.Designs;
|
||||
using Glamourer.Events;
|
||||
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 readonly EquipSlot Slot = slot;
|
||||
public bool Locked;
|
||||
public bool DisplayApplication;
|
||||
|
||||
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 bool CurrentApply;
|
||||
public bool CurrentApplyStain;
|
||||
|
||||
public readonly Gender CurrentGender = designData.Customize.Gender;
|
||||
public readonly Race CurrentRace = designData.Customize.Race;
|
||||
|
||||
public static EquipDrawData FromDesign(DesignManager manager, Design design, EquipSlot slot)
|
||||
=> new(slot, design.DesignData)
|
||||
{
|
||||
ItemSetter = i => manager.ChangeEquip(design, slot, i),
|
||||
StainSetter = i => manager.ChangeStain(design, slot, i),
|
||||
ApplySetter = b => manager.ChangeApplyEquip(design, slot, b),
|
||||
ApplyStainSetter = b => manager.ChangeApplyStain(design, slot, b),
|
||||
CurrentApply = design.DoApplyEquip(slot),
|
||||
CurrentApplyStain = design.DoApplyStain(slot),
|
||||
Locked = design.WriteProtected(),
|
||||
DisplayApplication = true,
|
||||
};
|
||||
|
||||
public static EquipDrawData FromState(StateManager manager, ActorState state, EquipSlot slot)
|
||||
=> new(slot, state.ModelData)
|
||||
{
|
||||
ItemSetter = i => manager.ChangeItem(state, slot, i, StateChanged.Source.Manual),
|
||||
StainSetter = i => manager.ChangeStain(state, slot, i, StateChanged.Source.Manual),
|
||||
Locked = state.IsLocked,
|
||||
DisplayApplication = false,
|
||||
};
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -24,21 +24,11 @@ using Penumbra.GameData.Enums;
|
|||
|
||||
namespace Glamourer.Gui.Tabs.ActorTab;
|
||||
|
||||
public class ActorPanel
|
||||
public class ActorPanel(ActorSelector _selector, StateManager _stateManager, CustomizationDrawer _customizationDrawer,
|
||||
EquipmentDrawer _equipmentDrawer, IdentifierService _identification, AutoDesignApplier _autoDesignApplier,
|
||||
Configuration _config, DesignConverter _converter, ObjectManager _objects, DesignManager _designManager, ImportService _importService,
|
||||
ICondition _conditions)
|
||||
{
|
||||
private readonly ActorSelector _selector;
|
||||
private readonly StateManager _stateManager;
|
||||
private readonly CustomizationDrawer _customizationDrawer;
|
||||
private readonly EquipmentDrawer _equipmentDrawer;
|
||||
private readonly IdentifierService _identification;
|
||||
private readonly AutoDesignApplier _autoDesignApplier;
|
||||
private readonly Configuration _config;
|
||||
private readonly DesignConverter _converter;
|
||||
private readonly ObjectManager _objects;
|
||||
private readonly DesignManager _designManager;
|
||||
private readonly ImportService _importService;
|
||||
private readonly ICondition _conditions;
|
||||
|
||||
private ActorIdentifier _identifier;
|
||||
private string _actorName = string.Empty;
|
||||
private Actor _actor = Actor.Null;
|
||||
|
|
@ -46,29 +36,10 @@ public class ActorPanel
|
|||
private ActorState? _state;
|
||||
private bool _lockedRedraw;
|
||||
|
||||
public ActorPanel(ActorSelector selector, StateManager stateManager, CustomizationDrawer customizationDrawer,
|
||||
EquipmentDrawer equipmentDrawer, IdentifierService identification, AutoDesignApplier autoDesignApplier,
|
||||
Configuration config, DesignConverter converter, ObjectManager objects, DesignManager designManager, ImportService importService,
|
||||
ICondition conditions)
|
||||
{
|
||||
_selector = selector;
|
||||
_stateManager = stateManager;
|
||||
_customizationDrawer = customizationDrawer;
|
||||
_equipmentDrawer = equipmentDrawer;
|
||||
_identification = identification;
|
||||
_autoDesignApplier = autoDesignApplier;
|
||||
_config = config;
|
||||
_converter = converter;
|
||||
_objects = objects;
|
||||
_designManager = designManager;
|
||||
_importService = importService;
|
||||
_conditions = conditions;
|
||||
}
|
||||
|
||||
private CustomizeFlag CustomizeApplicationFlags
|
||||
=> _lockedRedraw ? CustomizeFlagExtensions.AllRelevant & ~CustomizeFlagExtensions.RedrawRequired : CustomizeFlagExtensions.AllRelevant;
|
||||
|
||||
public unsafe void Draw()
|
||||
public void Draw()
|
||||
{
|
||||
using var group = ImRaii.Group();
|
||||
(_identifier, _data) = _selector.Selection;
|
||||
|
|
@ -161,8 +132,7 @@ public class ActorPanel
|
|||
if (_customizationDrawer.Draw(_state!.ModelData.Customize, _state.IsLocked, _lockedRedraw))
|
||||
_stateManager.ChangeCustomize(_state, _customizationDrawer.Customize, _customizationDrawer.Changed, StateChanged.Source.Manual);
|
||||
|
||||
if (_customizationDrawer.DrawWetnessState(_state!.ModelData.IsWet(), out var newWetness, _state.IsLocked))
|
||||
_stateManager.ChangeWetness(_state, newWetness, StateChanged.Source.Manual);
|
||||
EquipmentDrawer.DrawMetaToggle(ToggleDrawData.FromState(ActorState.MetaIndex.Wetness, _stateManager, _state));
|
||||
ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2));
|
||||
}
|
||||
|
||||
|
|
@ -176,62 +146,22 @@ public class ActorPanel
|
|||
var usedAllStain = _equipmentDrawer.DrawAllStain(out var newAllStain, _state!.IsLocked);
|
||||
foreach (var slot in EquipSlotExtensions.EqdpSlots)
|
||||
{
|
||||
var changes = _equipmentDrawer.DrawEquip(slot, _state!.ModelData, out var newArmor, out var newStain, null, out _, out _,
|
||||
_state.IsLocked);
|
||||
var data = EquipDrawData.FromState(_stateManager, _state!, slot);
|
||||
_equipmentDrawer.DrawEquip(data);
|
||||
if (usedAllStain)
|
||||
{
|
||||
changes |= DataChange.Stain;
|
||||
newStain = newAllStain;
|
||||
}
|
||||
|
||||
switch (changes)
|
||||
{
|
||||
case DataChange.Item:
|
||||
_stateManager.ChangeItem(_state, slot, newArmor, StateChanged.Source.Manual);
|
||||
break;
|
||||
case DataChange.Stain:
|
||||
_stateManager.ChangeStain(_state, slot, newStain, StateChanged.Source.Manual);
|
||||
break;
|
||||
case DataChange.Item | DataChange.Stain:
|
||||
_stateManager.ChangeEquip(_state, slot, newArmor, newStain, StateChanged.Source.Manual);
|
||||
break;
|
||||
}
|
||||
_stateManager.ChangeStain(_state, slot, newAllStain, StateChanged.Source.Manual);
|
||||
}
|
||||
|
||||
var weaponChanges = _equipmentDrawer.DrawWeapons(_state!.ModelData, out var newMainhand, out var newOffhand, out var newMainhandStain,
|
||||
out var newOffhandStain, null, GameMain.IsInGPose(), out _, out _, out _, out _, _state.IsLocked);
|
||||
if (usedAllStain)
|
||||
{
|
||||
weaponChanges |= DataChange.Stain | DataChange.Stain2;
|
||||
newMainhandStain = newAllStain;
|
||||
newOffhandStain = newAllStain;
|
||||
}
|
||||
|
||||
if (weaponChanges.HasFlag(DataChange.Item))
|
||||
if (weaponChanges.HasFlag(DataChange.Stain))
|
||||
_stateManager.ChangeEquip(_state, EquipSlot.MainHand, newMainhand, newMainhandStain, StateChanged.Source.Manual);
|
||||
else
|
||||
_stateManager.ChangeItem(_state, EquipSlot.MainHand, newMainhand, StateChanged.Source.Manual);
|
||||
else if (weaponChanges.HasFlag(DataChange.Stain))
|
||||
_stateManager.ChangeStain(_state, EquipSlot.MainHand, newMainhandStain, StateChanged.Source.Manual);
|
||||
|
||||
if (weaponChanges.HasFlag(DataChange.Item2))
|
||||
if (weaponChanges.HasFlag(DataChange.Stain2))
|
||||
_stateManager.ChangeEquip(_state, EquipSlot.OffHand, newOffhand, newOffhandStain, StateChanged.Source.Manual);
|
||||
else
|
||||
_stateManager.ChangeItem(_state, EquipSlot.OffHand, newOffhand, StateChanged.Source.Manual);
|
||||
else if (weaponChanges.HasFlag(DataChange.Stain2))
|
||||
_stateManager.ChangeStain(_state, EquipSlot.OffHand, newOffhandStain, StateChanged.Source.Manual);
|
||||
var mainhand = EquipDrawData.FromState(_stateManager, _state, EquipSlot.MainHand);
|
||||
var offhand = EquipDrawData.FromState(_stateManager, _state, EquipSlot.OffHand);
|
||||
_equipmentDrawer.DrawWeapons(mainhand, offhand, GameMain.IsInGPose());
|
||||
|
||||
ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2));
|
||||
if (EquipmentDrawer.DrawHatState(_state!.ModelData.IsHatVisible(), out var newHatState, _state!.IsLocked))
|
||||
_stateManager.ChangeHatState(_state, newHatState, StateChanged.Source.Manual);
|
||||
EquipmentDrawer.DrawMetaToggle(ToggleDrawData.FromState(ActorState.MetaIndex.HatState, _stateManager, _state));
|
||||
ImGui.SameLine();
|
||||
if (EquipmentDrawer.DrawVisorState(_state!.ModelData.IsVisorToggled(), out var newVisorState, _state!.IsLocked))
|
||||
_stateManager.ChangeVisorState(_state, newVisorState, StateChanged.Source.Manual);
|
||||
EquipmentDrawer.DrawMetaToggle(ToggleDrawData.FromState(ActorState.MetaIndex.VisorState, _stateManager, _state));
|
||||
ImGui.SameLine();
|
||||
if (EquipmentDrawer.DrawWeaponState(_state!.ModelData.IsWeaponVisible(), out var newWeaponState, _state!.IsLocked))
|
||||
_stateManager.ChangeWeaponState(_state, newWeaponState, StateChanged.Source.Manual);
|
||||
EquipmentDrawer.DrawMetaToggle(ToggleDrawData.FromState(ActorState.MetaIndex.WeaponState, _stateManager, _state));
|
||||
ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Xml.Linq;
|
||||
using Dalamud.Interface;
|
||||
using Dalamud.Interface.ImGuiFileDialog;
|
||||
using Dalamud.Interface.Internal.Notifications;
|
||||
|
|
@ -95,45 +94,15 @@ public class DesignPanel(DesignFileSystemSelector _selector, CustomizationDrawer
|
|||
var usedAllStain = _equipmentDrawer.DrawAllStain(out var newAllStain, _selector.Selected!.WriteProtected());
|
||||
foreach (var slot in EquipSlotExtensions.EqdpSlots)
|
||||
{
|
||||
var changes = _equipmentDrawer.DrawEquip(slot, _selector.Selected!.DesignData, out var newArmor, out var newStain,
|
||||
_selector.Selected.ApplyEquip, out var newApply, out var newApplyStain, _selector.Selected!.WriteProtected());
|
||||
if (changes.HasFlag(DataChange.Item))
|
||||
_manager.ChangeEquip(_selector.Selected, slot, newArmor);
|
||||
if (changes.HasFlag(DataChange.Stain))
|
||||
_manager.ChangeStain(_selector.Selected, slot, newStain);
|
||||
else if (usedAllStain)
|
||||
var data = EquipDrawData.FromDesign(_manager, _selector.Selected!, slot);
|
||||
_equipmentDrawer.DrawEquip(data);
|
||||
if (usedAllStain)
|
||||
_manager.ChangeStain(_selector.Selected, slot, newAllStain);
|
||||
if (changes.HasFlag(DataChange.ApplyItem))
|
||||
_manager.ChangeApplyEquip(_selector.Selected, slot, newApply);
|
||||
if (changes.HasFlag(DataChange.ApplyStain))
|
||||
_manager.ChangeApplyStain(_selector.Selected, slot, newApplyStain);
|
||||
}
|
||||
|
||||
var weaponChanges = _equipmentDrawer.DrawWeapons(_selector.Selected!.DesignData, out var newMainhand, out var newOffhand,
|
||||
out var newMainhandStain, out var newOffhandStain, _selector.Selected.ApplyEquip, true, out var applyMain, out var applyMainStain,
|
||||
out var applyOff, out var applyOffStain, _selector.Selected!.WriteProtected());
|
||||
|
||||
if (weaponChanges.HasFlag(DataChange.Item))
|
||||
_manager.ChangeWeapon(_selector.Selected, EquipSlot.MainHand, newMainhand);
|
||||
if (weaponChanges.HasFlag(DataChange.Stain))
|
||||
_manager.ChangeStain(_selector.Selected, EquipSlot.MainHand, newMainhandStain);
|
||||
else if (usedAllStain)
|
||||
_manager.ChangeStain(_selector.Selected, EquipSlot.MainHand, newAllStain);
|
||||
if (weaponChanges.HasFlag(DataChange.ApplyItem))
|
||||
_manager.ChangeApplyEquip(_selector.Selected, EquipSlot.MainHand, applyMain);
|
||||
if (weaponChanges.HasFlag(DataChange.ApplyStain))
|
||||
_manager.ChangeApplyStain(_selector.Selected, EquipSlot.MainHand, applyMainStain);
|
||||
if (weaponChanges.HasFlag(DataChange.Item2))
|
||||
_manager.ChangeWeapon(_selector.Selected, EquipSlot.OffHand, newOffhand);
|
||||
if (weaponChanges.HasFlag(DataChange.Stain2))
|
||||
_manager.ChangeStain(_selector.Selected, EquipSlot.OffHand, newOffhandStain);
|
||||
else if (usedAllStain)
|
||||
_manager.ChangeStain(_selector.Selected, EquipSlot.OffHand, newAllStain);
|
||||
if (weaponChanges.HasFlag(DataChange.ApplyItem2))
|
||||
_manager.ChangeApplyEquip(_selector.Selected, EquipSlot.OffHand, applyOff);
|
||||
if (weaponChanges.HasFlag(DataChange.ApplyStain2))
|
||||
_manager.ChangeApplyStain(_selector.Selected, EquipSlot.OffHand, applyOffStain);
|
||||
|
||||
var mainhand = EquipDrawData.FromDesign(_manager, _selector.Selected!, EquipSlot.MainHand);
|
||||
var offhand = EquipDrawData.FromDesign(_manager, _selector.Selected!, EquipSlot.OffHand);
|
||||
_equipmentDrawer.DrawWeapons(mainhand, offhand, true);
|
||||
ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2));
|
||||
DrawEquipmentMetaToggles();
|
||||
ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2));
|
||||
|
|
@ -141,22 +110,11 @@ public class DesignPanel(DesignFileSystemSelector _selector, CustomizationDrawer
|
|||
|
||||
private void DrawEquipmentMetaToggles()
|
||||
{
|
||||
var hatChanges = EquipmentDrawer.DrawHatState(_selector.Selected!.DesignData.IsHatVisible(),
|
||||
_selector.Selected.DoApplyHatVisible(),
|
||||
out var newHatState, out var newHatApply, _selector.Selected.WriteProtected());
|
||||
ApplyChanges(ActorState.MetaIndex.HatState, hatChanges, newHatState, newHatApply);
|
||||
|
||||
EquipmentDrawer.DrawMetaToggle(ToggleDrawData.FromDesign(ActorState.MetaIndex.HatState, _manager, _selector.Selected!));
|
||||
ImGui.SameLine();
|
||||
var visorChanges = EquipmentDrawer.DrawVisorState(_selector.Selected!.DesignData.IsVisorToggled(),
|
||||
_selector.Selected.DoApplyVisorToggle(),
|
||||
out var newVisorState, out var newVisorApply, _selector.Selected.WriteProtected());
|
||||
ApplyChanges(ActorState.MetaIndex.VisorState, visorChanges, newVisorState, newVisorApply);
|
||||
|
||||
EquipmentDrawer.DrawMetaToggle(ToggleDrawData.FromDesign(ActorState.MetaIndex.VisorState, _manager, _selector.Selected!));
|
||||
ImGui.SameLine();
|
||||
var weaponChanges = EquipmentDrawer.DrawWeaponState(_selector.Selected!.DesignData.IsWeaponVisible(),
|
||||
_selector.Selected.DoApplyWeaponVisible(),
|
||||
out var newWeaponState, out var newWeaponApply, _selector.Selected.WriteProtected());
|
||||
ApplyChanges(ActorState.MetaIndex.WeaponState, weaponChanges, newWeaponState, newWeaponApply);
|
||||
EquipmentDrawer.DrawMetaToggle(ToggleDrawData.FromDesign(ActorState.MetaIndex.WeaponState, _manager, _selector.Selected!));
|
||||
}
|
||||
|
||||
private void DrawCustomize()
|
||||
|
|
@ -178,9 +136,7 @@ public class DesignPanel(DesignFileSystemSelector _selector, CustomizationDrawer
|
|||
_manager.ChangeCustomize(_selector.Selected, idx, _customizationDrawer.Customize[idx]);
|
||||
}
|
||||
|
||||
var wetnessChanges = _customizationDrawer.DrawWetnessState(_selector.Selected!.DesignData.IsWet(),
|
||||
_selector.Selected!.DoApplyWetness(), out var newWetnessState, out var newWetnessApply, _selector.Selected!.WriteProtected());
|
||||
ApplyChanges(ActorState.MetaIndex.Wetness, wetnessChanges, newWetnessState, newWetnessApply);
|
||||
EquipmentDrawer.DrawMetaToggle(ToggleDrawData.FromDesign(ActorState.MetaIndex.Wetness, _manager, _selector.Selected!));
|
||||
ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2));
|
||||
}
|
||||
|
||||
|
|
@ -306,12 +262,14 @@ public class DesignPanel(DesignFileSystemSelector _selector, CustomizationDrawer
|
|||
_manager.ChangeCustomize(_selector.Selected!, CustomizeIndex.Gender, dat.Customize[CustomizeIndex.Gender]);
|
||||
foreach (var idx in CustomizationExtensions.AllBasic)
|
||||
_manager.ChangeCustomize(_selector.Selected!, idx, dat.Customize[idx]);
|
||||
Glamourer.Messager.NotificationMessage($"Applied games .dat file {dat.Description} customizations to {_selector.Selected.Name}.", NotificationType.Success, false);
|
||||
Glamourer.Messager.NotificationMessage(
|
||||
$"Applied games .dat file {dat.Description} customizations to {_selector.Selected.Name}.", NotificationType.Success, false);
|
||||
}
|
||||
else if (_importService.CreateCharaTarget(out var designBase, out var name))
|
||||
{
|
||||
_manager.ApplyDesign(_selector.Selected!, designBase);
|
||||
Glamourer.Messager.NotificationMessage($"Applied Anamnesis .chara file {name} to {_selector.Selected.Name}.", NotificationType.Success, false);
|
||||
Glamourer.Messager.NotificationMessage($"Applied Anamnesis .chara file {name} to {_selector.Selected.Name}.",
|
||||
NotificationType.Success, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -441,23 +399,6 @@ public class DesignPanel(DesignFileSystemSelector _selector, CustomizationDrawer
|
|||
_fileDialog.Draw();
|
||||
}
|
||||
|
||||
private void ApplyChanges(ActorState.MetaIndex index, DataChange change, bool value, bool apply)
|
||||
{
|
||||
switch (change)
|
||||
{
|
||||
case DataChange.Item:
|
||||
_manager.ChangeMeta(_selector.Selected!, index, value);
|
||||
break;
|
||||
case DataChange.ApplyItem:
|
||||
_manager.ChangeApplyMeta(_selector.Selected!, index, apply);
|
||||
break;
|
||||
case DataChange.Item | DataChange.ApplyItem:
|
||||
_manager.ChangeApplyMeta(_selector.Selected!, index, apply);
|
||||
_manager.ChangeMeta(_selector.Selected!, index, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static unsafe string GetUserPath()
|
||||
=> Framework.Instance()->UserPath;
|
||||
}
|
||||
|
|
|
|||
79
Glamourer/Gui/ToggleDrawData.cs
Normal file
79
Glamourer/Gui/ToggleDrawData.cs
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
using System;
|
||||
using Glamourer.Designs;
|
||||
using Glamourer.Events;
|
||||
using Glamourer.State;
|
||||
|
||||
namespace Glamourer.Gui;
|
||||
|
||||
public ref struct ToggleDrawData
|
||||
{
|
||||
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 static ToggleDrawData FromDesign(ActorState.MetaIndex index, DesignManager manager, Design design)
|
||||
{
|
||||
var (label, value, apply, setValue, setApply) = index switch
|
||||
{
|
||||
ActorState.MetaIndex.HatState => ("Hat Visible", design.DesignData.IsHatVisible(), design.DoApplyHatVisible(),
|
||||
(Action<bool>)(b => manager.ChangeMeta(design, index, b)), (Action<bool>)(b => manager.ChangeApplyMeta(design, index, b))),
|
||||
ActorState.MetaIndex.VisorState => ("Visor Toggled", design.DesignData.IsVisorToggled(), design.DoApplyVisorToggle(),
|
||||
b => manager.ChangeMeta(design, index, b), b => manager.ChangeApplyMeta(design, index, b)),
|
||||
ActorState.MetaIndex.WeaponState => ("Weapon Visible", design.DesignData.IsWeaponVisible(), design.DoApplyWeaponVisible(),
|
||||
b => manager.ChangeMeta(design, index, b), b => manager.ChangeApplyMeta(design, index, b)),
|
||||
ActorState.MetaIndex.Wetness => ("Force Wetness", design.DesignData.IsWet(), design.DoApplyWetness(),
|
||||
b => manager.ChangeMeta(design, index, b), b => manager.ChangeApplyMeta(design, index, b)),
|
||||
_ => throw new Exception("Unsupported meta index."),
|
||||
};
|
||||
|
||||
return new ToggleDrawData
|
||||
{
|
||||
Label = label,
|
||||
Tooltip = string.Empty,
|
||||
Locked = design.WriteProtected(),
|
||||
DisplayApplication = true,
|
||||
CurrentValue = value,
|
||||
CurrentApply = apply,
|
||||
SetValue = setValue,
|
||||
SetApply = setApply,
|
||||
};
|
||||
}
|
||||
|
||||
public static ToggleDrawData FromState(ActorState.MetaIndex index, StateManager manager, ActorState state)
|
||||
{
|
||||
var (label, tooltip, value, setValue) = index switch
|
||||
{
|
||||
ActorState.MetaIndex.HatState => ("Hat Visible", "Hide or show the characters head gear.", state.ModelData.IsHatVisible(),
|
||||
(Action<bool>)(b => manager.ChangeHatState(state, b, StateChanged.Source.Manual))),
|
||||
ActorState.MetaIndex.VisorState => ("Visor Toggled", "Toggle the visor state of the characters head gear.",
|
||||
state.ModelData.IsVisorToggled(),
|
||||
b => manager.ChangeVisorState(state, b, StateChanged.Source.Manual)),
|
||||
ActorState.MetaIndex.WeaponState => ("Weapon Visible", "Hide or show the characters weapons when not drawn.",
|
||||
state.ModelData.IsWeaponVisible(),
|
||||
b => manager.ChangeWeaponState(state, b, StateChanged.Source.Manual)),
|
||||
ActorState.MetaIndex.Wetness => ("Force Wetness", "Force the character to be wet or not.", state.ModelData.IsWet(),
|
||||
b => manager.ChangeWetness(state, b, StateChanged.Source.Manual)),
|
||||
_ => throw new Exception("Unsupported meta index."),
|
||||
};
|
||||
|
||||
return new ToggleDrawData
|
||||
{
|
||||
Label = label,
|
||||
Tooltip = tooltip,
|
||||
Locked = state.IsLocked,
|
||||
CurrentValue = value,
|
||||
SetValue = setValue,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -71,14 +71,15 @@ public static class UiHelpers
|
|||
return ret;
|
||||
}
|
||||
|
||||
public static DataChange DrawMetaToggle(string label, bool currentValue, bool currentApply, out bool newValue,
|
||||
public static (bool, bool) DrawMetaToggle(string label, bool currentValue, bool currentApply, out bool newValue,
|
||||
out bool newApply, bool locked)
|
||||
{
|
||||
var flags = (sbyte)(currentApply ? currentValue ? 1 : -1 : 0);
|
||||
using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemInnerSpacing);
|
||||
using (var disabled = ImRaii.Disabled(locked))
|
||||
{
|
||||
if (new TristateCheckbox(ColorId.TriStateCross.Value(), ColorId.TriStateCheck.Value(), ColorId.TriStateNeutral.Value()).Draw("##" + label, flags, out flags))
|
||||
if (new TristateCheckbox(ColorId.TriStateCross.Value(), ColorId.TriStateCheck.Value(), ColorId.TriStateNeutral.Value()).Draw(
|
||||
"##" + label, flags, out flags))
|
||||
{
|
||||
(newValue, newApply) = flags switch
|
||||
{
|
||||
|
|
@ -99,13 +100,7 @@ public static class UiHelpers
|
|||
ImGui.SameLine();
|
||||
ImGui.TextUnformatted(label);
|
||||
|
||||
return (currentApply != newApply, currentValue != newValue) switch
|
||||
{
|
||||
(true, true) => DataChange.ApplyItem | DataChange.Item,
|
||||
(true, false) => DataChange.ApplyItem,
|
||||
(false, true) => DataChange.Item,
|
||||
_ => DataChange.None,
|
||||
};
|
||||
return (currentValue != newValue, currentApply != newApply);
|
||||
}
|
||||
|
||||
public static (EquipFlag, CustomizeFlag) ConvertKeysToFlags()
|
||||
|
|
|
|||
2
OtterGui
2
OtterGui
|
|
@ -1 +1 @@
|
|||
Subproject commit 858b610a194ee52b4e8e89c0c64d9f2653025524
|
||||
Subproject commit 2a7908493ab0fd0e576d5fa37a3acbd920be6233
|
||||
Loading…
Add table
Add a link
Reference in a new issue