Fix some issues with customization drawing, add tooltips.

This commit is contained in:
Ottermandias 2023-09-24 15:30:55 +02:00
parent 4abc509102
commit e43a17a3c6
4 changed files with 44 additions and 30 deletions

View file

@ -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<SubRace>().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<SubRace>().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.");
}
}

View file

@ -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)
{

View file

@ -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;

View file

@ -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;