diff --git a/Glamourer/Designs/DesignBase.cs b/Glamourer/Designs/DesignBase.cs index 867ee9d..4e3f5b6 100644 --- a/Glamourer/Designs/DesignBase.cs +++ b/Glamourer/Designs/DesignBase.cs @@ -444,7 +444,7 @@ public class DesignBase if (!TryGetToken(flag, out var token)) continue; - var value = Math.Clamp(token["Percentage"]?.ToObject() ?? 0f, 0f, 1f); + var value = token["Percentage"]?.ToObject() ?? 0f; design.GetDesignDataRef().Parameters[flag] = new CustomizeParameterValue(value); } @@ -453,9 +453,9 @@ public class DesignBase if (!TryGetToken(flag, out var token)) continue; - var r = Math.Clamp(token["Red"]?.ToObject() ?? 0f, 0, 1); - var g = Math.Clamp(token["Green"]?.ToObject() ?? 0f, 0, 1); - var b = Math.Clamp(token["Blue"]?.ToObject() ?? 0f, 0, 1); + var r = token["Red"]?.ToObject() ?? 0f; + var g = token["Green"]?.ToObject() ?? 0f; + var b = token["Blue"]?.ToObject() ?? 0f; design.GetDesignDataRef().Parameters[flag] = new CustomizeParameterValue(r, g, b); } @@ -464,10 +464,10 @@ public class DesignBase if (!TryGetToken(flag, out var token)) continue; - var r = Math.Clamp(token["Red"]?.ToObject() ?? 0f, 0, 1); - var g = Math.Clamp(token["Green"]?.ToObject() ?? 0f, 0, 1); - var b = Math.Clamp(token["Blue"]?.ToObject() ?? 0f, 0, 1); - var a = Math.Clamp(token["Alpha"]?.ToObject() ?? 0f, 0, 1); + var r = token["Red"]?.ToObject() ?? 0f; + var g = token["Green"]?.ToObject() ?? 0f; + var b = token["Blue"]?.ToObject() ?? 0f; + var a = token["Alpha"]?.ToObject() ?? 0f; design.GetDesignDataRef().Parameters[flag] = new CustomizeParameterValue(r, g, b, a); } diff --git a/Glamourer/Events/DesignChanged.cs b/Glamourer/Events/DesignChanged.cs index 4bdb1df..2217c34 100644 --- a/Glamourer/Events/DesignChanged.cs +++ b/Glamourer/Events/DesignChanged.cs @@ -65,7 +65,7 @@ public sealed class DesignChanged() /// An existing design had a crest visibility changed. Data is the old crest visibility, the new crest visibility and the slot [(bool, bool, EquipSlot)]. Crest, - /// An existing design had a customize parameter changed. Data is the old value, the new value and the flag [(Vector3, Vector3, CustomizeParameterFlag)]. + /// An existing design had a customize parameter changed. Data is the old value, the new value and the flag [(CustomizeParameterValue, CustomizeParameterValue, CustomizeParameterFlag)]. Parameter, /// An existing design changed whether a specific customization is applied. Data is the type of customization [CustomizeIndex]. diff --git a/Glamourer/Events/StateChanged.cs b/Glamourer/Events/StateChanged.cs index 50c3d2e..58dd49c 100644 --- a/Glamourer/Events/StateChanged.cs +++ b/Glamourer/Events/StateChanged.cs @@ -39,7 +39,7 @@ public sealed class StateChanged() /// A characters saved state had a crest visibility changed. Data is the old crest visibility, the new crest visibility and the slot [(bool, bool, EquipSlot)]. Crest, - /// A characters saved state had its customize parameter changed. Data is the old value, the new value and the type [(Vector3, Vector3, CustomizeParameterFlag)]. + /// A characters saved state had its customize parameter changed. Data is the old value, the new value and the type [(CustomizeParameterValue, CustomizeParameterValue, CustomizeParameterFlag)]. Parameter, /// A characters saved state had a design applied. This means everything may have changed. Data is the applied design. [DesignBase] diff --git a/Glamourer/GameData/CustomizeParameterData.cs b/Glamourer/GameData/CustomizeParameterData.cs index 0ffbad6..ee1d5ae 100644 --- a/Glamourer/GameData/CustomizeParameterData.cs +++ b/Glamourer/GameData/CustomizeParameterData.cs @@ -105,7 +105,7 @@ public struct CustomizeParameterData }; if (flags.HasFlag(CustomizeParameterFlag.SkinSpecular)) - parameters.SkinFresnelValue0 = new CustomizeParameterValue(SkinDiffuse).XivQuadruple; + parameters.SkinFresnelValue0 = new CustomizeParameterValue(SkinSpecular).XivQuadruple; if (flags.HasFlag(CustomizeParameterFlag.HairDiffuse)) parameters.MainColor = new CustomizeParameterValue(HairDiffuse).XivTriple; if (flags.HasFlag(CustomizeParameterFlag.HairSpecular)) diff --git a/Glamourer/GameData/CustomizeParameterValue.cs b/Glamourer/GameData/CustomizeParameterValue.cs index fc3e28d..0e22d18 100644 --- a/Glamourer/GameData/CustomizeParameterValue.cs +++ b/Glamourer/GameData/CustomizeParameterValue.cs @@ -40,7 +40,7 @@ public readonly struct CustomizeParameterValue => x < 0 ? -x * x : x * x; private static float Root(float x) - => x < 0 ? -(float)Math.Sqrt(-x) : x; + => x < 0 ? -(float)Math.Sqrt(-x) : (float)Math.Sqrt(x); public float this[int idx] => _data[idx]; diff --git a/Glamourer/Gui/Customization/CustomizeParameterDrawer.cs b/Glamourer/Gui/Customization/CustomizeParameterDrawer.cs index 5f5c5cb..3434011 100644 --- a/Glamourer/Gui/Customization/CustomizeParameterDrawer.cs +++ b/Glamourer/Gui/Customization/CustomizeParameterDrawer.cs @@ -55,7 +55,7 @@ public class CustomizeParameterDrawer(Configuration config) : IService var value = data.CurrentValue.InternalTriple; using (_ = ImRaii.Disabled(data.Locked)) { - if (ImGui.ColorEdit3("##value", ref value, ImGuiColorEditFlags.Float | ImGuiColorEditFlags.HDR | ImGuiColorEditFlags.NoOptions)) + if (ImGui.ColorEdit3("##value", ref value, GetFlags())) data.ValueSetter(new CustomizeParameterValue(value)); } @@ -70,7 +70,7 @@ public class CustomizeParameterDrawer(Configuration config) : IService var value = data.CurrentValue.InternalQuadruple; using (_ = ImRaii.Disabled(data.Locked)) { - if (ImGui.ColorEdit4("##value", ref value, ImGuiColorEditFlags.Float | ImGuiColorEditFlags.HDR | ImGuiColorEditFlags.NoOptions)) + if (ImGui.ColorEdit4("##value", ref value, GetFlags())) data.ValueSetter(new CustomizeParameterValue(value)); } @@ -140,4 +140,9 @@ public class CustomizeParameterDrawer(Configuration config) : IService ImGui.SameLine(0, ImGui.GetStyle().ItemInnerSpacing.X); ImGui.TextUnformatted(data.Flag.ToName()); } + + private static ImGuiColorEditFlags GetFlags() + => ImGui.GetIO().KeyCtrl + ? ImGuiColorEditFlags.Float | ImGuiColorEditFlags.HDR | ImGuiColorEditFlags.NoOptions + : ImGuiColorEditFlags.Float | ImGuiColorEditFlags.HDR; } diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs index 8edc8fc..431eed0 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs @@ -134,7 +134,8 @@ public class ActorPanel( var header = _state!.ModelData.ModelId == 0 ? "Customization" : $"Customization (Model Id #{_state.ModelData.ModelId})###Customization"; - if (!ImGui.CollapsingHeader(header)) + using var h = ImRaii.CollapsingHeader(header); + if (!h) return; if (_customizationDrawer.Draw(_state!.ModelData.Customize, _state.IsLocked, _lockedRedraw)) @@ -146,7 +147,8 @@ public class ActorPanel( private void DrawEquipmentHeader() { - if (!ImGui.CollapsingHeader("Equipment")) + using var h = ImRaii.CollapsingHeader("Equipment"); + if (!h) return; _equipmentDrawer.Prepare(); @@ -171,7 +173,11 @@ public class ActorPanel( private void DrawParameterHeader() { - if (!_config.UseAdvancedParameters || !ImGui.CollapsingHeader("Advanced Customizations")) + if (!_config.UseAdvancedParameters) + return; + + using var h = ImRaii.CollapsingHeader("Advanced Customizations"); + if (!h) return; _parameterDrawer.Draw(_stateManager, _state!); diff --git a/Glamourer/Gui/Tabs/DebugTab/DebugTabHeader.cs b/Glamourer/Gui/Tabs/DebugTab/DebugTabHeader.cs index 0c4d617..b2b7bdb 100644 --- a/Glamourer/Gui/Tabs/DebugTab/DebugTabHeader.cs +++ b/Glamourer/Gui/Tabs/DebugTab/DebugTabHeader.cs @@ -12,7 +12,8 @@ public class DebugTabHeader(string label, params IGameDataDrawer[] subTrees) public void Draw() { - if (!ImGui.CollapsingHeader(Label)) + using var h = ImRaii.CollapsingHeader(Label); + if (!h) return; foreach (var subTree in SubTrees) diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs b/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs index 88c2bdb..00a23cc 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignDetailTab.cs @@ -41,7 +41,8 @@ public class DesignDetailTab public void Draw() { - if (!ImGui.CollapsingHeader("Design Details")) + using var h = ImRaii.CollapsingHeader("Design Details"); + if (!h) return; DrawDesignInfoTable(); diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index b3c1b4a..6cefc63 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -92,7 +92,8 @@ public class DesignPanel( private void DrawEquipment() { - if (!ImGui.CollapsingHeader("Equipment")) + using var h = ImRaii.CollapsingHeader("Equipment"); + if (!h) return; _equipmentDrawer.Prepare(); @@ -142,7 +143,8 @@ public class DesignPanel( var header = _selector.Selected!.DesignData.ModelId == 0 ? "Customization" : $"Customization (Model Id #{_selector.Selected!.DesignData.ModelId})###Customization"; - if (!ImGui.CollapsingHeader(header)) + using var h = ImRaii.CollapsingHeader(header); + if (!h) return; if (_customizationDrawer.Draw(_selector.Selected!.DesignData.Customize, _selector.Selected.ApplyCustomizeRaw, @@ -162,7 +164,10 @@ public class DesignPanel( private void DrawCustomizeParameters() { - if (!_config.UseAdvancedParameters || !ImGui.CollapsingHeader("Advanced Customization")) + if (!_config.UseAdvancedParameters) + return; + using var h = ImRaii.CollapsingHeader("Advanced Customizations"); + if (!h) return; _parameterDrawer.Draw(_manager, _selector.Selected!); @@ -214,7 +219,8 @@ public class DesignPanel( private void DrawApplicationRules() { - if (!ImGui.CollapsingHeader("Application Rules")) + using var h = ImRaii.CollapsingHeader("Application Rules"); + if (!h) return; using (var _ = ImRaii.Group()) diff --git a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs index 7624c0b..e70cbec 100644 --- a/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs +++ b/Glamourer/Gui/Tabs/DesignTab/ModAssociationsTab.cs @@ -28,13 +28,13 @@ public class ModAssociationsTab public void Draw() { - var headerOpen = ImGui.CollapsingHeader("Mod Associations"); + using var h = ImRaii.CollapsingHeader("Mod Associations"); ImGuiUtil.HoverTooltip( "This tab can store information about specific mods associated with this design.\n\n" + "It does NOT change any mod settings automatically, though there is functionality to apply desired mod settings manually.\n" + "You can also use it to quickly open the associated mod page in Penumbra.\n\n" + "It is not feasible to apply those changes automatically in general cases, since there would be no way to revert those changes, handle multiple designs applying at once, etc."); - if (!headerOpen) + if (!h) return; DrawApplyAllButton(); diff --git a/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs b/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs index f815e3d..c6d5be4 100644 --- a/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs +++ b/Glamourer/Gui/Tabs/NpcTab/NpcPanel.cs @@ -141,7 +141,8 @@ public class NpcPanel( private void DrawCustomization() { - if (!ImGui.CollapsingHeader("Customization")) + using var h = ImRaii.CollapsingHeader("Customization"); + if (!h) return; _customizeDrawer.Draw(_selector.Selection.Customize, true, true); @@ -150,7 +151,8 @@ public class NpcPanel( private void DrawEquipment() { - if (!ImGui.CollapsingHeader("Equipment")) + using var h = ImRaii.CollapsingHeader("Equipment"); + if (!h) return; _equipDrawer.Prepare(); @@ -223,7 +225,8 @@ public class NpcPanel( private void DrawAppearanceInfo() { - if (!ImGui.CollapsingHeader("Appearance Details")) + using var h = ImRaii.CollapsingHeader("Appearance Details"); + if (!h) return; using var table = ImRaii.Table("Details", 2); diff --git a/Glamourer/State/StateManager.cs b/Glamourer/State/StateManager.cs index 4d5098d..0eace8b 100644 --- a/Glamourer/State/StateManager.cs +++ b/Glamourer/State/StateManager.cs @@ -456,7 +456,7 @@ public class StateManager( _applier.ChangeWeaponState(actors, state.ModelData.IsWeaponVisible()); _applier.ChangeVisor(actors, state.ModelData.IsVisorToggled()); _applier.ChangeCrests(actors, state.ModelData.CrestVisibility); - _applier.ChangeParameters(actors, state.OnlyChangedParameters(), state.ModelData.Parameters); + _applier.ChangeParameters(actors, state.OnlyChangedParameters(), state.ModelData.Parameters, state.IsLocked); } return actors; diff --git a/OtterGui b/OtterGui index f8f3e0b..9f9705f 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit f8f3e0b9bd39ed58f1233affc40df187b0c2b70e +Subproject commit 9f9705f417114d006c7b1f043637083f0782bb6b