diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.GenderRace.cs b/Glamourer/Gui/Customization/CustomizationDrawer.GenderRace.cs index 23f8c8d..698d20c 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.GenderRace.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.GenderRace.cs @@ -22,6 +22,7 @@ public partial class CustomizationDrawer var clan = _service.AwaitedService.GetName(CustomName.Clan); if (_withApply) { + using var disabled = ImRaii.Disabled(_locked); if (UiHelpers.DrawCheckbox("##applyGender", "Apply gender of this design.", ChangeApply.HasFlag(CustomizeFlag.Gender), out var applyGender, _locked)) ChangeApply = applyGender ? ChangeApply | CustomizeFlag.Gender : ChangeApply & ~CustomizeFlag.Gender; ImGui.SameLine(); @@ -36,6 +37,7 @@ public partial class CustomizationDrawer private void DrawGenderSelector() { + using var disabled = ImRaii.Disabled(_locked || _lockedRedraw); var icon = _customize.Gender switch { Gender.Male when _customize.Race is Race.Hrothgar => FontAwesomeIcon.MarsDouble, @@ -53,6 +55,7 @@ public partial class CustomizationDrawer private void DrawRaceCombo() { + using var disabled = ImRaii.Disabled(_locked || _lockedRedraw); ImGui.SetNextItemWidth(_raceSelectorWidth); using var combo = ImRaii.Combo("##subRaceCombo", _service.ClanName(_customize.Clan, _customize.Gender)); if (!combo) diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs b/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs index 34a6490..9f73a9a 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs @@ -29,8 +29,12 @@ public partial class CustomizationDrawer } var icon = _service.AwaitedService.GetIcon(custom!.Value.IconId); - if (ImGui.ImageButton(icon.ImGuiHandle, _iconSize)) - ImGui.OpenPopup(IconSelectorPopup); + using (var disabled = ImRaii.Disabled(_locked || _currentIndex is CustomizeIndex.Face && _lockedRedraw)) + { + if (ImGui.ImageButton(icon.ImGuiHandle, _iconSize)) + ImGui.OpenPopup(IconSelectorPopup); + } + ImGuiUtil.HoverIconTooltip(icon, _iconSize); ImGui.SameLine(); @@ -88,6 +92,7 @@ public partial class CustomizationDrawer private void DrawMultiIconSelector() { using var bigGroup = ImRaii.Group(); + using var disabled = ImRaii.Disabled(_locked); DrawMultiIcons(); ImGui.SameLine(); using var group = ImRaii.Group(); @@ -110,12 +115,16 @@ public partial class CustomizationDrawer { ImGui.SameLine(); ImGui.AlignTextToFramePadding(); + using var _ = ImRaii.Enabled(); ImGui.TextUnformatted("(Using Face 1)"); } ImGui.SetCursorPosY(ImGui.GetCursorPosY() + _spacing.Y); ImGui.AlignTextToFramePadding(); - ImGui.TextUnformatted(_set.Option(CustomizeIndex.LegacyTattoo)); + using (var _ = ImRaii.Enabled()) + { + ImGui.TextUnformatted(_set.Option(CustomizeIndex.LegacyTattoo)); + } if (_withApply) { diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs b/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs index e338dc9..cd72f2d 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs @@ -15,13 +15,16 @@ public partial class CustomizationDrawer using var _ = SetId(index); using var bigGroup = ImRaii.Group(); - DrawPercentageSlider(); - ImGui.SameLine(); - PercentageInputInt(); - if (_withApply) + using (var disabled = ImRaii.Disabled(_locked)) { + DrawPercentageSlider(); ImGui.SameLine(); - ApplyCheckbox(); + PercentageInputInt(); + if (_withApply) + { + ImGui.SameLine(); + ApplyCheckbox(); + } } ImGui.SameLine(); @@ -54,6 +57,7 @@ public partial class CustomizationDrawer if (_currentIndex is CustomizeIndex.Face && _set.Race is Race.Hrothgar) value -= 4; + using var disabled = ImRaii.Disabled(_locked || _currentIndex is CustomizeIndex.Face && _lockedRedraw); ImGui.SetNextItemWidth(_inputIntSizeNoButtons); if (ImGui.InputInt("##text", ref value, 0, 0)) { @@ -63,6 +67,7 @@ public partial class CustomizationDrawer else if (ImGui.GetIO().KeyCtrl) UpdateValue((CustomizeValue)value); } + if (!_withApply) ImGuiUtil.HoverTooltip("Hold Control to force updates with invalid/unknown options at your own risk."); @@ -81,6 +86,7 @@ public partial class CustomizationDrawer using var _ = SetId(index); using var bigGroup = ImRaii.Group(); + using var disabled = ImRaii.Disabled(_locked); ListCombo(); ImGui.SameLine(); ListInputInt(); @@ -143,10 +149,19 @@ public partial class CustomizationDrawer break; } } - else if (ImGui.Checkbox(_currentIndex.ToDefaultName(), ref tmp)) + else { - _customize.Set(idx, tmp ? CustomizeValue.Max : CustomizeValue.Zero); - Changed |= _currentFlag; + using (var disabled = ImRaii.Disabled(_locked)) + { + if (ImGui.Checkbox("##toggle", ref tmp)) + { + _customize.Set(idx, tmp ? CustomizeValue.Max : CustomizeValue.Zero); + Changed |= _currentFlag; + } + } + + ImGui.SameLine(); + ImGui.TextUnformatted(_currentIndex.ToDefaultName()); } } diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.cs b/Glamourer/Gui/Customization/CustomizationDrawer.cs index 17410ad..be37b1e 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.cs @@ -37,7 +37,8 @@ public partial class CustomizationDrawer : IDisposable => Changed.RequiresRedraw(); private CustomizeFlag _initialApply; - private bool _locked = false; + private bool _locked = false; + private bool _lockedRedraw = false; private Vector2 _defaultSpacing; private Vector2 _spacing; private Vector2 _iconSize; @@ -64,32 +65,33 @@ public partial class CustomizationDrawer : IDisposable _legacyTattoo?.Dispose(); } - public bool Draw(Customize current, bool locked) + public bool Draw(Customize current, bool locked, bool lockedRedraw) { CurrentFlag = CustomizeFlagExtensions.All; _withApply = false; - Init(current, locked); + Init(current, locked, lockedRedraw); return DrawInternal(); } - public bool Draw(Customize current, CustomizeFlag apply, bool locked) + public bool Draw(Customize current, CustomizeFlag apply, bool locked, bool lockedRedraw) { CurrentFlag = CustomizeFlagExtensions.All; ChangeApply = apply; _initialApply = apply; _withApply = !_config.HideApplyCheckmarks; - Init(current, locked); + Init(current, locked, lockedRedraw); return DrawInternal(); } - private void Init(Customize current, bool locked) + private void Init(Customize current, bool locked, bool lockedRedraw) { UpdateSizes(); _terminate = null; Changed = 0; _customize.Load(current); - _locked = locked; + _locked = locked; + _lockedRedraw = lockedRedraw; } // Set state for drawing of current customization. @@ -136,7 +138,6 @@ public partial class CustomizationDrawer : IDisposable private bool DrawInternal() { using var spacing = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, _spacing); - using var disabled = ImRaii.Disabled(_locked); try { @@ -199,11 +200,11 @@ public partial class CustomizationDrawer : IDisposable private void UpdateSizes() { - _defaultSpacing = ImGui.GetStyle().ItemSpacing; - _spacing = ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemInnerSpacing.X }; - _iconSize = new Vector2(ImGui.GetTextLineHeight() * 2 + ImGui.GetStyle().ItemSpacing.Y + 2 * ImGui.GetStyle().FramePadding.Y); - _framedIconSize = _iconSize + 2 * ImGui.GetStyle().FramePadding; - _inputIntSize = 2 * _framedIconSize.X + 1 * _spacing.X; + _defaultSpacing = ImGui.GetStyle().ItemSpacing; + _spacing = ImGui.GetStyle().ItemSpacing with { X = ImGui.GetStyle().ItemInnerSpacing.X }; + _iconSize = new Vector2(ImGui.GetTextLineHeight() * 2 + ImGui.GetStyle().ItemSpacing.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; diff --git a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs index 4a5c41f..5b63afb 100644 --- a/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs +++ b/Glamourer/Gui/Tabs/ActorTab/ActorPanel.cs @@ -116,7 +116,7 @@ public class ActorPanel if (!ImGui.CollapsingHeader("Customizations")) return; - if (_customizationDrawer.Draw(_state!.ModelData.Customize, _state.IsLocked)) + if (_customizationDrawer.Draw(_state!.ModelData.Customize, _state.IsLocked, _identifier.Type is IdentifierType.Special)) _stateManager.ChangeCustomize(_state, _customizationDrawer.Customize, _customizationDrawer.Changed, StateChanged.Source.Manual); if (_customizationDrawer.DrawWetnessState(_state!.ModelData.IsWet(), out var newWetness, _state.IsLocked)) diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs index ef8218f..9e5637a 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignPanel.cs @@ -167,7 +167,7 @@ public class DesignPanel return; if (_customizationDrawer.Draw(_selector.Selected!.DesignData.Customize, _selector.Selected.ApplyCustomize, - _selector.Selected!.WriteProtected())) + _selector.Selected!.WriteProtected(), false)) foreach (var idx in Enum.GetValues()) { var flag = idx.ToFlag(); diff --git a/Glamourer/Gui/UiHelpers.cs b/Glamourer/Gui/UiHelpers.cs index f00064f..1050ea5 100644 --- a/Glamourer/Gui/UiHelpers.cs +++ b/Glamourer/Gui/UiHelpers.cs @@ -55,18 +55,23 @@ public static class UiHelpers return ret; } - public static DataChange DrawMetaToggle(string label, string tooltip, bool currentValue, bool currentApply, out bool newValue, out bool newApply, + public static DataChange DrawMetaToggle(string label, string tooltip, bool currentValue, bool currentApply, out bool newValue, + out bool newApply, bool locked) { - var flags = currentApply ? currentValue ? 3 : 0 : 2; - bool ret; + var flags = currentApply ? currentValue ? 3 : 0 : 2; + bool ret; + using var style = ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, ImGui.GetStyle().ItemInnerSpacing); using (var disabled = ImRaii.Disabled(locked)) { - ret = ImGui.CheckboxFlags(label, ref flags, 3); + ret = ImGui.CheckboxFlags("##" + label, ref flags, 3); } ImGuiUtil.HoverTooltip(tooltip); + ImGui.SameLine(); + ImGui.TextUnformatted(label); + if (ret) { (newValue, newApply, var change) = (currentValue, currentApply) switch