Add parameter handling.

This commit is contained in:
Ottermandias 2024-01-08 23:00:02 +01:00
parent 9361560350
commit 1a0a0f681f
27 changed files with 633 additions and 155 deletions

View file

@ -159,8 +159,8 @@ public class DesignQuickBar : Window, IDisposable
return;
}
var (applyGear, applyCustomize, applyCrest) = UiHelpers.ConvertKeysToFlags();
using var _ = design!.TemporarilyRestrictApplication(applyGear, applyCustomize, applyCrest);
var (applyGear, applyCustomize, applyCrest, applyParameters) = UiHelpers.ConvertKeysToFlags();
using var _ = design!.TemporarilyRestrictApplication(applyGear, applyCustomize, applyCrest, applyParameters);
_stateManager.ApplyDesign(design, state, StateChanged.Source.Manual);
}

View file

@ -35,7 +35,8 @@ public class ActorPanel(
DesignManager _designManager,
ImportService _importService,
ICondition _conditions,
DictModelChara _modelChara)
DictModelChara _modelChara,
CustomizeParameterDrawer _parameterDrawer)
{
private ActorIdentifier _identifier;
private string _actorName = string.Empty;
@ -127,6 +128,7 @@ public class ActorPanel(
{
DrawCustomizationsHeader();
DrawEquipmentHeader();
DrawParameterHeader();
}
private void DrawCustomizationsHeader()
@ -169,6 +171,14 @@ public class ActorPanel(
ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2));
}
private void DrawParameterHeader()
{
if (!_config.UseAdvancedParameters || !ImGui.CollapsingHeader("Advanced Customizations"))
return;
_parameterDrawer.Draw(_stateManager, _state!);
}
private void DrawEquipmentMetaToggles()
{
using (_ = ImRaii.Group())
@ -302,9 +312,9 @@ public class ActorPanel(
private void SaveDesignOpen()
{
ImGui.OpenPopup("Save as Design");
_newName = _state!.Identifier.ToName();
var (applyGear, applyCustomize, applyCrest) = UiHelpers.ConvertKeysToFlags();
_newDesign = _converter.Convert(_state, applyGear, applyCustomize, applyCrest);
_newName = _state!.Identifier.ToName();
var (applyGear, applyCustomize, applyCrest, applyParameters) = UiHelpers.ConvertKeysToFlags();
_newDesign = _converter.Convert(_state, applyGear, applyCustomize, applyCrest, applyParameters);
}
private void SaveDesignDrawPopup()
@ -339,8 +349,8 @@ public class ActorPanel(
{
try
{
var (applyGear, applyCustomize, applyCrest) = UiHelpers.ConvertKeysToFlags();
var text = _converter.ShareBase64(_state!, applyGear, applyCustomize, applyCrest);
var (applyGear, applyCustomize, applyCrest, applyParameters) = UiHelpers.ConvertKeysToFlags();
var text = _converter.ShareBase64(_state!, applyGear, applyCustomize, applyCrest, applyParameters);
ImGui.SetClipboardText(text);
}
catch (Exception ex)
@ -379,9 +389,9 @@ public class ActorPanel(
!data.Valid || id == _identifier || _state!.ModelData.ModelId != 0))
return;
var (applyGear, applyCustomize, applyCrest) = UiHelpers.ConvertKeysToFlags();
var (applyGear, applyCustomize, applyCrest, applyParameters) = UiHelpers.ConvertKeysToFlags();
if (_stateManager.GetOrCreate(id, data.Objects[0], out var state))
_stateManager.ApplyDesign(_converter.Convert(_state!, applyGear, applyCustomize, applyCrest), state,
_stateManager.ApplyDesign(_converter.Convert(_state!, applyGear, applyCustomize, applyCrest, applyParameters), state,
StateChanged.Source.Manual);
}
@ -397,9 +407,9 @@ public class ActorPanel(
!data.Valid || id == _identifier || _state!.ModelData.ModelId != 0))
return;
var (applyGear, applyCustomize, applyCrest) = UiHelpers.ConvertKeysToFlags();
var (applyGear, applyCustomize, applyCrest, applyParameters) = UiHelpers.ConvertKeysToFlags();
if (_stateManager.GetOrCreate(id, data.Objects[0], out var state))
_stateManager.ApplyDesign(_converter.Convert(_state!, applyGear, applyCustomize, applyCrest), state,
_stateManager.ApplyDesign(_converter.Convert(_state!, applyGear, applyCustomize, applyCrest, applyParameters), state,
StateChanged.Source.Manual);
}
}

View file

@ -269,7 +269,7 @@ public class SetPanel(
var size = new Vector2(ImGui.GetFrameHeight());
size.X += ImGuiHelpers.GlobalScale;
var (equipFlags, customizeFlags, _, _, _, _, _) = design.ApplyWhat();
var (equipFlags, customizeFlags, _, _, _, _, _, _) = design.ApplyWhat();
var sb = new StringBuilder();
foreach (var slot in EquipSlotExtensions.EqdpSlots.Append(EquipSlot.MainHand).Append(EquipSlot.OffHand))
{

View file

@ -101,6 +101,18 @@ public class ActiveStatePanel(StateManager _stateManager, ObjectManager _objectM
PrintRow(type.ToDefaultName(), state.BaseData.Customize[type].Value, state.ModelData.Customize[type].Value, state[type]);
ImGui.TableNextRow();
}
foreach (var crest in CrestExtensions.AllRelevantSet)
{
PrintRow(crest.ToLabel(), state.BaseData.Crest(crest), state.ModelData.Crest(crest), state[crest]);
ImGui.TableNextRow();
}
foreach (var flag in CustomizeParameterExtensions.AllFlags)
{
PrintRow(flag.ToString(), state.BaseData.Parameters[flag], state.ModelData.Parameters[flag], state[flag]);
ImGui.TableNextRow();
}
}
else
{

View file

@ -1,6 +1,8 @@
using System;
using System.Numerics;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
using FFXIVClientStructs.FFXIV.Shader;
using Glamourer.GameData;
using Glamourer.Interop;
using Glamourer.Interop.Structs;
using ImGuiNET;
@ -78,6 +80,28 @@ public unsafe class ModelEvaluationPanel(
DrawEquip(actor, model);
DrawCustomize(actor, model);
DrawCrests(actor, model);
DrawParameters(actor, model);
}
private void DrawParameters(Actor actor, Model model)
{
if (!model.IsHuman)
return;
if (model.AsHuman->CustomizeParameterCBuffer == null)
return;
var ptr = (CustomizeParameter*)model.AsHuman->CustomizeParameterCBuffer->UnsafeSourcePointer;
if (ptr == null)
return;
var convert = CustomizeParameterData.FromParameters(*ptr);
foreach (var flag in CustomizeParameterExtensions.AllFlags)
{
ImGuiUtil.DrawTableColumn(flag.ToString());
ImGuiUtil.DrawTableColumn(string.Empty);
ImGuiUtil.DrawTableColumn(convert[flag].ToString());
ImGui.TableNextColumn();
}
}
private void DrawVisor(Actor actor, Model model)

View file

@ -9,6 +9,7 @@ using FFXIVClientStructs.FFXIV.Client.System.Framework;
using Glamourer.Automation;
using Glamourer.Designs;
using Glamourer.Events;
using Glamourer.GameData;
using Glamourer.Gui.Customization;
using Glamourer.Gui.Equipment;
using Glamourer.Interop;
@ -21,9 +22,20 @@ using Penumbra.GameData.Enums;
namespace Glamourer.Gui.Tabs.DesignTab;
public class DesignPanel(DesignFileSystemSelector _selector, CustomizationDrawer _customizationDrawer, DesignManager _manager,
ObjectManager _objects, StateManager _state, EquipmentDrawer _equipmentDrawer, ModAssociationsTab _modAssociations,
DesignDetailTab _designDetails, DesignConverter _converter, ImportService _importService, MultiDesignPanel _multiDesignPanel)
public class DesignPanel(
DesignFileSystemSelector _selector,
CustomizationDrawer _customizationDrawer,
DesignManager _manager,
ObjectManager _objects,
StateManager _state,
EquipmentDrawer _equipmentDrawer,
ModAssociationsTab _modAssociations,
Configuration _config,
DesignDetailTab _designDetails,
DesignConverter _converter,
ImportService _importService,
MultiDesignPanel _multiDesignPanel,
CustomizeParameterDrawer _parameterDrawer)
{
private readonly FileDialogManager _fileDialog = new();
@ -152,11 +164,20 @@ public class DesignPanel(DesignFileSystemSelector _selector, CustomizationDrawer
ImGui.Dummy(new Vector2(ImGui.GetTextLineHeight() / 2));
}
private void DrawCustomizeParameters()
{
if (!_config.UseAdvancedParameters || !ImGui.CollapsingHeader("Advanced Customization"))
return;
_parameterDrawer.Draw(_manager, _selector.Selected!);
}
private void DrawCustomizeApplication()
{
var set = _selector.Selected!.CustomizeSet;
var available = set.SettingAvailable | CustomizeFlag.Clan | CustomizeFlag.Gender | CustomizeFlag.BodyType;
var flags = _selector.Selected!.ApplyCustomizeExcludingBodyType == 0 ? 0 : (_selector.Selected!.ApplyCustomize & available) == available ? 3 : 1;
var set = _selector.Selected!.CustomizeSet;
var available = set.SettingAvailable | CustomizeFlag.Clan | CustomizeFlag.Gender | CustomizeFlag.BodyType;
var flags = _selector.Selected!.ApplyCustomizeExcludingBodyType == 0 ? 0 :
(_selector.Selected!.ApplyCustomize & available) == available ? 3 : 1;
if (ImGui.CheckboxFlags("Apply All Customizations", ref flags, 3))
{
var newFlags = flags == 3;
@ -205,6 +226,9 @@ public class DesignPanel(DesignFileSystemSelector _selector, CustomizationDrawer
DrawCustomizeApplication();
ImGui.NewLine();
DrawCrestApplication();
ImGui.NewLine();
if (_config.UseAdvancedParameters)
DrawMetaApplication();
}
ImGui.SameLine(ImGui.GetContentRegionAvail().X / 2);
@ -248,27 +272,47 @@ public class DesignPanel(DesignFileSystemSelector _selector, CustomizationDrawer
EquipSlotExtensions.FullSlots);
ImGui.NewLine();
const uint all = 0x0Fu;
var flags = (_selector.Selected!.DoApplyHatVisible() ? 0x01u : 0x00)
| (_selector.Selected!.DoApplyVisorToggle() ? 0x02u : 0x00)
| (_selector.Selected!.DoApplyWeaponVisible() ? 0x04u : 0x00)
| (_selector.Selected!.DoApplyWetness() ? 0x08u : 0x00);
var bigChange = ImGui.CheckboxFlags("Apply All Meta Changes", ref flags, all);
var apply = bigChange ? (flags & 0x01) == 0x01 : _selector.Selected!.DoApplyHatVisible();
if (ImGui.Checkbox("Apply Hat Visibility", ref apply) || bigChange)
_manager.ChangeApplyMeta(_selector.Selected!, ActorState.MetaIndex.HatState, apply);
if (_config.UseAdvancedParameters)
DrawParameterApplication();
else
DrawMetaApplication();
}
}
apply = bigChange ? (flags & 0x02) == 0x02 : _selector.Selected!.DoApplyVisorToggle();
if (ImGui.Checkbox("Apply Visor State", ref apply) || bigChange)
_manager.ChangeApplyMeta(_selector.Selected!, ActorState.MetaIndex.VisorState, apply);
private void DrawMetaApplication()
{
const uint all = 0x0Fu;
var flags = (_selector.Selected!.DoApplyHatVisible() ? 0x01u : 0x00)
| (_selector.Selected!.DoApplyVisorToggle() ? 0x02u : 0x00)
| (_selector.Selected!.DoApplyWeaponVisible() ? 0x04u : 0x00)
| (_selector.Selected!.DoApplyWetness() ? 0x08u : 0x00);
var bigChange = ImGui.CheckboxFlags("Apply All Meta Changes", ref flags, all);
var apply = bigChange ? (flags & 0x01) == 0x01 : _selector.Selected!.DoApplyHatVisible();
if (ImGui.Checkbox("Apply Hat Visibility", ref apply) || bigChange)
_manager.ChangeApplyMeta(_selector.Selected!, ActorState.MetaIndex.HatState, apply);
apply = bigChange ? (flags & 0x04) == 0x04 : _selector.Selected!.DoApplyWeaponVisible();
if (ImGui.Checkbox("Apply Weapon Visibility", ref apply) || bigChange)
_manager.ChangeApplyMeta(_selector.Selected!, ActorState.MetaIndex.WeaponState, apply);
apply = bigChange ? (flags & 0x02) == 0x02 : _selector.Selected!.DoApplyVisorToggle();
if (ImGui.Checkbox("Apply Visor State", ref apply) || bigChange)
_manager.ChangeApplyMeta(_selector.Selected!, ActorState.MetaIndex.VisorState, apply);
apply = bigChange ? (flags & 0x08) == 0x08 : _selector.Selected!.DoApplyWetness();
if (ImGui.Checkbox("Apply Wetness", ref apply) || bigChange)
_manager.ChangeApplyMeta(_selector.Selected!, ActorState.MetaIndex.Wetness, apply);
apply = bigChange ? (flags & 0x04) == 0x04 : _selector.Selected!.DoApplyWeaponVisible();
if (ImGui.Checkbox("Apply Weapon Visibility", ref apply) || bigChange)
_manager.ChangeApplyMeta(_selector.Selected!, ActorState.MetaIndex.WeaponState, apply);
apply = bigChange ? (flags & 0x08) == 0x08 : _selector.Selected!.DoApplyWetness();
if (ImGui.Checkbox("Apply Wetness", ref apply) || bigChange)
_manager.ChangeApplyMeta(_selector.Selected!, ActorState.MetaIndex.Wetness, apply);
}
private void DrawParameterApplication()
{
var flags = (uint)_selector.Selected!.ApplyParameters;
var bigChange = ImGui.CheckboxFlags("Apply All Customize Parameters", ref flags, (uint)CustomizeParameterExtensions.All);
foreach (var flag in CustomizeParameterExtensions.AllFlags)
{
var apply = bigChange ? ((CustomizeParameterFlag)flags).HasFlag(flag) : _selector.Selected!.DoApplyParameter(flag);
if (ImGui.Checkbox($"Apply {flag}", ref apply) || bigChange)
_manager.ChangeApplyParameter(_selector.Selected!, flag, apply);
}
}
@ -316,6 +360,7 @@ public class DesignPanel(DesignFileSystemSelector _selector, CustomizationDrawer
DrawButtonRow();
DrawCustomize();
DrawEquipment();
DrawCustomizeParameters();
_designDetails.Draw();
DrawApplicationRules();
_modAssociations.Draw();
@ -386,8 +431,8 @@ public class DesignPanel(DesignFileSystemSelector _selector, CustomizationDrawer
if (_state.GetOrCreate(id, data.Objects[0], out var state))
{
var (applyGear, applyCustomize, applyCrest) = UiHelpers.ConvertKeysToFlags();
using var _ = _selector.Selected!.TemporarilyRestrictApplication(applyGear, applyCustomize, applyCrest);
var (applyGear, applyCustomize, applyCrest, applyParameters) = UiHelpers.ConvertKeysToFlags();
using var _ = _selector.Selected!.TemporarilyRestrictApplication(applyGear, applyCustomize, applyCrest, applyParameters);
_state.ApplyDesign(_selector.Selected!, state, StateChanged.Source.Manual);
}
}
@ -405,8 +450,8 @@ public class DesignPanel(DesignFileSystemSelector _selector, CustomizationDrawer
if (_state.GetOrCreate(id, data.Objects[0], out var state))
{
var (applyGear, applyCustomize, applyCrest) = UiHelpers.ConvertKeysToFlags();
using var _ = _selector.Selected!.TemporarilyRestrictApplication(applyGear, applyCustomize, applyCrest);
var (applyGear, applyCustomize, applyCrest, applyParameters) = UiHelpers.ConvertKeysToFlags();
using var _ = _selector.Selected!.TemporarilyRestrictApplication(applyGear, applyCustomize, applyCrest, applyParameters);
_state.ApplyDesign(_selector.Selected!, state, StateChanged.Source.Manual);
}
}

View file

@ -89,9 +89,9 @@ public class NpcPanel(
{
try
{
var (applyGear, applyCustomize, applyCrest) = UiHelpers.ConvertKeysToFlags();
var (applyGear, applyCustomize, applyCrest, applyParameters) = UiHelpers.ConvertKeysToFlags();
var data = ToDesignData();
var text = _converter.ShareBase64(data, applyGear, applyCustomize, applyCrest);
var text = _converter.ShareBase64(data, applyGear, applyCustomize, applyCrest, applyParameters);
ImGui.SetClipboardText(text);
}
catch (Exception ex)
@ -105,11 +105,11 @@ public class NpcPanel(
private void SaveDesignOpen()
{
ImGui.OpenPopup("Save as Design");
_newName = _selector.Selection.Name;
var (applyGear, applyCustomize, applyCrest) = UiHelpers.ConvertKeysToFlags();
_newName = _selector.Selection.Name;
var (applyGear, applyCustomize, applyCrest, applyParameters) = UiHelpers.ConvertKeysToFlags();
var data = ToDesignData();
_newDesign = _converter.Convert(data, applyGear, applyCustomize, applyCrest);
_newDesign = _converter.Convert(data, applyGear, applyCustomize, applyCrest, applyParameters);
}
private void SaveDesignDrawPopup()
@ -198,8 +198,8 @@ public class NpcPanel(
if (_state.GetOrCreate(id, data.Objects[0], out var state))
{
var (applyGear, applyCustomize, applyCrest) = UiHelpers.ConvertKeysToFlags();
var design = _converter.Convert(ToDesignData(), applyGear, applyCustomize, applyCrest);
var (applyGear, applyCustomize, applyCrest, applyParameters) = UiHelpers.ConvertKeysToFlags();
var design = _converter.Convert(ToDesignData(), applyGear, applyCustomize, applyCrest, applyParameters);
_state.ApplyDesign(design, state, StateChanged.Source.Manual);
}
}
@ -217,8 +217,8 @@ public class NpcPanel(
if (_state.GetOrCreate(id, data.Objects[0], out var state))
{
var (applyGear, applyCustomize, applyCrest) = UiHelpers.ConvertKeysToFlags();
var design = _converter.Convert(ToDesignData(), applyGear, applyCustomize, applyCrest);
var (applyGear, applyCustomize, applyCrest, applyParameters) = UiHelpers.ConvertKeysToFlags();
var design = _converter.Convert(ToDesignData(), applyGear, applyCustomize, applyCrest, applyParameters);
_state.ApplyDesign(design, state, StateChanged.Source.Manual);
}
}

View file

@ -60,8 +60,9 @@ public class SettingsTab : ITab
if (!child)
return;
Checkbox("Enable Auto Designs", "Enable the application of designs associated to characters in the Automation tab to be applied automatically.",
_config.EnableAutoDesigns, v => _config.EnableAutoDesigns = v);
Checkbox("Enable Auto Designs",
"Enable the application of designs associated to characters in the Automation tab to be applied automatically.",
_config.EnableAutoDesigns, v => _config.EnableAutoDesigns = v);
ImGui.NewLine();
ImGui.NewLine();
ImGui.NewLine();
@ -97,6 +98,8 @@ public class SettingsTab : ITab
Checkbox("Revert Manual Changes on Zone Change",
"Restores the old behaviour of reverting your character to its game or automation base whenever you change the zone.",
_config.RevertManualChangesOnZoneChange, v => _config.RevertManualChangesOnZoneChange = v);
Checkbox("Enable Advanced Customization Options", "Enable the display and editing of advanced customization options like arbitrary colors.",
_config.UseAdvancedParameters, v => _config.UseAdvancedParameters = v);
ImGui.NewLine();
}
@ -108,7 +111,8 @@ public class SettingsTab : ITab
EphemeralCheckbox("Show Quick Design Bar",
"Show a bar separate from the main window that allows you to quickly apply designs or revert your character and target.",
_config.Ephemeral.ShowDesignQuickBar, v => _config.Ephemeral.ShowDesignQuickBar = v);
EphemeralCheckbox("Lock Quick Design Bar", "Prevent the quick design bar from being moved and lock it in place.", _config.Ephemeral.LockDesignQuickBar,
EphemeralCheckbox("Lock Quick Design Bar", "Prevent the quick design bar from being moved and lock it in place.",
_config.Ephemeral.LockDesignQuickBar,
v => _config.Ephemeral.LockDesignQuickBar = v);
if (Widget.ModifiableKeySelector("Hotkey to Toggle Quick Design Bar", "Set a hotkey that opens or closes the quick design bar.",
100 * ImGuiHelpers.GlobalScale,
@ -138,7 +142,8 @@ public class SettingsTab : ITab
_config.HideWindowInCutscene = v;
_uiBuilder.DisableCutsceneUiHide = !v;
});
EphemeralCheckbox("Lock Main Window", "Prevent the main window from being moved and lock it in place.", _config.Ephemeral.LockMainWindow,
EphemeralCheckbox("Lock Main Window", "Prevent the main window from being moved and lock it in place.",
_config.Ephemeral.LockMainWindow,
v => _config.Ephemeral.LockMainWindow = v);
Checkbox("Open Main Window at Game Start", "Whether the main Glamourer window should be open or closed after launching the game.",
_config.OpenWindowAtStart, v => _config.OpenWindowAtStart = v);

View file

@ -1,6 +1,7 @@
using System.Numerics;
using Dalamud.Interface;
using Dalamud.Interface.Utility;
using Glamourer.GameData;
using Glamourer.Services;
using Glamourer.Unlocks;
using ImGuiNET;
@ -98,13 +99,13 @@ public static class UiHelpers
return (currentValue != newValue, currentApply != newApply);
}
public static (EquipFlag, CustomizeFlag, CrestFlag) ConvertKeysToFlags()
public static (EquipFlag, CustomizeFlag, CrestFlag, CustomizeParameterFlag) ConvertKeysToFlags()
=> (ImGui.GetIO().KeyCtrl, ImGui.GetIO().KeyShift) switch
{
(false, false) => (EquipFlagExtensions.All, CustomizeFlagExtensions.AllRelevant, CrestExtensions.All),
(true, true) => (EquipFlagExtensions.All, CustomizeFlagExtensions.AllRelevant, CrestExtensions.All),
(true, false) => (EquipFlagExtensions.All, (CustomizeFlag)0, CrestExtensions.All),
(false, true) => ((EquipFlag)0, CustomizeFlagExtensions.AllRelevant, 0),
(false, false) => (EquipFlagExtensions.All, CustomizeFlagExtensions.AllRelevant, CrestExtensions.All, CustomizeParameterExtensions.All),
(true, true) => (EquipFlagExtensions.All, CustomizeFlagExtensions.AllRelevant, CrestExtensions.All, CustomizeParameterExtensions.All),
(true, false) => (EquipFlagExtensions.All, (CustomizeFlag)0, CrestExtensions.All, 0),
(false, true) => ((EquipFlag)0, CustomizeFlagExtensions.AllRelevant, 0, CustomizeParameterExtensions.All),
};
public static (bool, bool) ConvertKeysToBool()