From e43a17a3c65bc40407a726d06f9283ec9f861d98 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 24 Sep 2023 15:30:55 +0200 Subject: [PATCH] Fix some issues with customization drawing, add tooltips. --- .../CustomizationDrawer.GenderRace.cs | 55 +++++++++++-------- .../Customization/CustomizationDrawer.Icon.cs | 7 ++- .../CustomizationDrawer.Simple.cs | 8 ++- .../Gui/Customization/CustomizationDrawer.cs | 4 +- 4 files changed, 44 insertions(+), 30 deletions(-) diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.GenderRace.cs b/Glamourer/Gui/Customization/CustomizationDrawer.GenderRace.cs index 698d20c..9cfe301 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.GenderRace.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.GenderRace.cs @@ -23,10 +23,12 @@ public partial class CustomizationDrawer 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)) + 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(); - if (UiHelpers.DrawCheckbox("##applyClan", "Apply clan of this design.", ChangeApply.HasFlag(CustomizeFlag.Clan), out var applyClan, _locked)) + if (UiHelpers.DrawCheckbox("##applyClan", "Apply clan of this design.", ChangeApply.HasFlag(CustomizeFlag.Clan), out var applyClan, + _locked)) ChangeApply = applyClan ? ChangeApply | CustomizeFlag.Clan : ChangeApply & ~CustomizeFlag.Clan; ImGui.SameLine(); } @@ -37,34 +39,43 @@ public partial class CustomizationDrawer private void DrawGenderSelector() { - using var disabled = ImRaii.Disabled(_locked || _lockedRedraw); - var icon = _customize.Gender switch + using (var disabled = ImRaii.Disabled(_locked || _lockedRedraw)) { - Gender.Male when _customize.Race is Race.Hrothgar => FontAwesomeIcon.MarsDouble, - Gender.Male => FontAwesomeIcon.Mars, - Gender.Female => FontAwesomeIcon.Venus, - _ => FontAwesomeIcon.Question, - }; + var icon = _customize.Gender switch + { + Gender.Male when _customize.Race is Race.Hrothgar => FontAwesomeIcon.MarsDouble, + Gender.Male => FontAwesomeIcon.Mars, + Gender.Female => FontAwesomeIcon.Venus, + _ => FontAwesomeIcon.Question, + }; - if (!ImGuiUtil.DrawDisabledButton(icon.ToIconString(), _framedIconSize, string.Empty, - icon is not FontAwesomeIcon.Mars and not FontAwesomeIcon.Venus, true)) - return; + if (ImGuiUtil.DrawDisabledButton(icon.ToIconString(), _framedIconSize, string.Empty, + icon is not FontAwesomeIcon.Mars and not FontAwesomeIcon.Venus, true)) + Changed |= _service.ChangeGender(ref _customize, icon is FontAwesomeIcon.Mars ? Gender.Female : Gender.Male); + } - Changed |= _service.ChangeGender(ref _customize, icon is FontAwesomeIcon.Mars ? Gender.Female : Gender.Male); + if (_lockedRedraw && ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) + ImGui.SetTooltip( + "The gender can not be changed as this requires a redraw of the character, which is not supported for this actor."); } 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) - return; - - foreach (var subRace in Enum.GetValues().Skip(1)) // Skip Unknown + using (var disabled = ImRaii.Disabled(_locked || _lockedRedraw)) { - if (ImGui.Selectable(_service.ClanName(subRace, _customize.Gender), subRace == _customize.Clan)) - Changed |= _service.ChangeClan(ref _customize, subRace); + ImGui.SetNextItemWidth(_raceSelectorWidth); + using (var combo = ImRaii.Combo("##subRaceCombo", _service.ClanName(_customize.Clan, _customize.Gender))) + { + if (combo) + foreach (var subRace in Enum.GetValues().Skip(1)) // Skip Unknown + { + if (ImGui.Selectable(_service.ClanName(subRace, _customize.Gender), subRace == _customize.Clan)) + Changed |= _service.ChangeClan(ref _customize, subRace); + } + } } + + if (_lockedRedraw && ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) + ImGui.SetTooltip("The race can not be changed as this requires a redraw of the character, which is not supported for this actor."); } } diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs b/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs index 9f73a9a..31d593d 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.Icon.cs @@ -1,10 +1,8 @@ -using System; -using System.Numerics; +using System.Numerics; using Glamourer.Customization; using ImGuiNET; using OtterGui; using OtterGui.Raii; -using Penumbra.GameData.Enums; namespace Glamourer.Gui.Customization; @@ -41,6 +39,9 @@ public partial class CustomizationDrawer using (var group = ImRaii.Group()) { DataInputInt(current, npc); + if (_lockedRedraw && ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) + ImGui.SetTooltip( + "The face can not be changed as this requires a redraw of the character, which is not supported for this actor."); if (_withApply) { diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs b/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs index 3ba088d..a67f389 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.Simple.cs @@ -64,6 +64,7 @@ public partial class CustomizationDrawer if (_currentIndex is CustomizeIndex.Face && _set.Race is Race.Hrothgar && value is > 4 and < 9) value -= 4; + using var group = ImRaii.Group(); using var disabled = ImRaii.Disabled(_locked || _currentIndex is CustomizeIndex.Face && _lockedRedraw); ImGui.SetNextItemWidth(_inputIntSizeNoButtons); if (ImGui.InputInt("##text", ref value, 0, 0)) @@ -134,6 +135,7 @@ public partial class CustomizationDrawer : Math.Clamp(tmp - 1, 0, _currentCount - 1)); UpdateValue(newValue); } + ImGuiUtil.HoverTooltip($"Input Range: [1, {_currentCount}]\n" + "Hold Control to force updates with invalid/unknown options at your own risk."); } @@ -145,11 +147,12 @@ public partial class CustomizationDrawer var tmp = _currentByte != CustomizeValue.Zero; if (_withApply) { - switch (UiHelpers.DrawMetaToggle(_currentIndex.ToDefaultName(), string.Empty, tmp, _currentApply, out var newValue, + switch (UiHelpers.DrawMetaToggle(_currentIndex.ToDefaultName(), + $"This attribute will be {(_currentApply ? tmp ? "enabled." : "disabled." : "kept as is.")}", tmp, _currentApply, + out var newValue, out var newApply, _locked)) { case DataChange.Item: - ChangeApply = newApply ? ChangeApply | _currentFlag : ChangeApply & ~_currentFlag; _customize.Set(idx, newValue ? CustomizeValue.Max : CustomizeValue.Zero); Changed |= _currentFlag; break; @@ -157,6 +160,7 @@ public partial class CustomizationDrawer ChangeApply = newApply ? ChangeApply | _currentFlag : ChangeApply & ~_currentFlag; break; case DataChange.Item | DataChange.ApplyItem: + ChangeApply = newApply ? ChangeApply | _currentFlag : ChangeApply & ~_currentFlag; _customize.Set(idx, newValue ? CustomizeValue.Max : CustomizeValue.Zero); Changed |= _currentFlag; break; diff --git a/Glamourer/Gui/Customization/CustomizationDrawer.cs b/Glamourer/Gui/Customization/CustomizationDrawer.cs index 3b9f5b3..60ab3fa 100644 --- a/Glamourer/Gui/Customization/CustomizationDrawer.cs +++ b/Glamourer/Gui/Customization/CustomizationDrawer.cs @@ -36,7 +36,6 @@ public partial class CustomizationDrawer : IDisposable private CustomizeFlag _initialApply; private bool _locked = false; private bool _lockedRedraw = false; - private Vector2 _defaultSpacing; private Vector2 _spacing; private Vector2 _iconSize; private Vector2 _framedIconSize; @@ -157,7 +156,7 @@ public partial class CustomizationDrawer : IDisposable Functions.IteratePairwise(_set.Order[CharaMakeParams.MenuType.ColorPicker], DrawColorPicker, ImGui.SameLine); Functions.IteratePairwise(_set.Order[CharaMakeParams.MenuType.Checkmark], DrawCheckbox, - () => ImGui.SameLine(_comboSelectorSize - _framedIconSize.X + _spacing.X)); + () => ImGui.SameLine(_comboSelectorSize - _framedIconSize.X + ImGui.GetStyle().WindowPadding.X)); return Changed != 0 || ChangeApply != _initialApply; } catch (Exception ex) @@ -197,7 +196,6 @@ 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;