Change how customization config works a bit.

This commit is contained in:
Ottermandias 2023-07-14 14:34:30 +02:00
parent 25cded7f9f
commit 519bfffbb2
5 changed files with 57 additions and 55 deletions

View file

@ -25,6 +25,7 @@ public partial class CustomizationDrawer
ImGui.OpenPopup(ColorPickerPopupName); ImGui.OpenPopup(ColorPickerPopupName);
} }
var npc = false;
if (current < 0) if (current < 0)
{ {
using var font = ImRaii.PushFont(UiBuilder.IconFont); using var font = ImRaii.PushFont(UiBuilder.IconFont);
@ -32,13 +33,14 @@ public partial class CustomizationDrawer
var pos = ImGui.GetItemRectMin() + (ImGui.GetItemRectSize() - size) / 2; var pos = ImGui.GetItemRectMin() + (ImGui.GetItemRectSize() - size) / 2;
ImGui.GetWindowDrawList().AddText(pos, ImGui.GetColorU32(ImGuiCol.Text), FontAwesomeIcon.Question.ToIconString()); ImGui.GetWindowDrawList().AddText(pos, ImGui.GetColorU32(ImGuiCol.Text), FontAwesomeIcon.Question.ToIconString());
current = 0; current = 0;
npc = true;
} }
ImGui.SameLine(); ImGui.SameLine();
using (var group = ImRaii.Group()) using (var group = ImRaii.Group())
{ {
DataInputInt(current); DataInputInt(current, npc);
if (_withApply) if (_withApply)
{ {
ApplyCheckbox(); ApplyCheckbox();
@ -46,7 +48,7 @@ public partial class CustomizationDrawer
} }
ImGui.AlignTextToFramePadding(); ImGui.AlignTextToFramePadding();
ImGui.TextUnformatted(custom.Color == 0 ? $"{_currentOption} (Custom #{custom.Value})" : _currentOption); ImGui.TextUnformatted(custom.Color == 0 ? $"{_currentOption} (NPC)" : _currentOption);
} }
DrawColorPickerPopup(); DrawColorPickerPopup();

View file

@ -19,11 +19,13 @@ public partial class CustomizationDrawer
var label = _currentOption; var label = _currentOption;
var current = _set.DataByValue(index, _currentByte, out var custom, _customize.Face); var current = _set.DataByValue(index, _currentByte, out var custom, _customize.Face);
var npc = false;
if (current < 0) if (current < 0)
{ {
label = $"{_currentOption} (Custom #{_customize[index]})"; label = $"{_currentOption} (NPC)";
current = 0; current = 0;
custom = _set.Data(index, 0); custom = _set.Data(index, 0);
npc = true;
} }
var icon = _service.AwaitedService.GetIcon(custom!.Value.IconId); var icon = _service.AwaitedService.GetIcon(custom!.Value.IconId);
@ -34,10 +36,7 @@ public partial class CustomizationDrawer
ImGui.SameLine(); ImGui.SameLine();
using (var group = ImRaii.Group()) using (var group = ImRaii.Group())
{ {
if (_currentIndex == CustomizeIndex.Face) DataInputInt(current, npc);
FaceInputInt(current);
else
DataInputInt(current);
if (_withApply) if (_withApply)
{ {
@ -45,38 +44,12 @@ public partial class CustomizationDrawer
ImGui.SameLine(); ImGui.SameLine();
} }
ImGui.TextUnformatted($"{label} ({custom.Value.Value})"); ImGui.TextUnformatted(label);
} }
DrawIconPickerPopup(); DrawIconPickerPopup();
} }
private bool UpdateFace(CustomizeData data)
{
// Hrothgar Hack
var value = _set.Race == Race.Hrothgar ? data.Value + 4 : data.Value;
if (_customize.Face == value)
return false;
_customize.Face = value;
Changed |= CustomizeFlag.Face;
return true;
}
private void FaceInputInt(int currentIndex)
{
++currentIndex;
ImGui.SetNextItemWidth(_inputIntSize);
if (ImGui.InputInt("##text", ref currentIndex, 1, 1))
{
currentIndex = Math.Clamp(currentIndex - 1, 0, _currentCount - 1);
var data = _set.Data(_currentIndex, currentIndex, _customize.Face);
UpdateFace(data);
}
ImGuiUtil.HoverTooltip($"Input Range: [1, {_currentCount}]");
}
private void DrawIconPickerPopup() private void DrawIconPickerPopup()
{ {
using var popup = ImRaii.Popup(IconSelectorPopup, ImGuiWindowFlags.AlwaysAutoResize); using var popup = ImRaii.Popup(IconSelectorPopup, ImGuiWindowFlags.AlwaysAutoResize);
@ -93,10 +66,7 @@ public partial class CustomizationDrawer
{ {
if (ImGui.ImageButton(icon.ImGuiHandle, _iconSize)) if (ImGui.ImageButton(icon.ImGuiHandle, _iconSize))
{ {
if (_currentIndex == CustomizeIndex.Face) UpdateValue(custom.Value);
UpdateFace(custom);
else
UpdateValue(custom.Value);
ImGui.CloseCurrentPopup(); ImGui.CloseCurrentPopup();
} }

View file

@ -1,8 +1,10 @@
using System; using System;
using System.Numerics;
using Glamourer.Customization; using Glamourer.Customization;
using ImGuiNET; using ImGuiNET;
using OtterGui; using OtterGui;
using OtterGui.Raii; using OtterGui.Raii;
using Penumbra.GameData.Enums;
namespace Glamourer.Gui.Customization; namespace Glamourer.Gui.Customization;
@ -45,18 +47,33 @@ public partial class CustomizationDrawer
} }
// Integral input for an icon- or color based item. // Integral input for an icon- or color based item.
private void DataInputInt(int currentIndex) private void DataInputInt(int currentIndex, bool npc)
{ {
++currentIndex; int value = _currentByte.Value;
ImGui.SetNextItemWidth(_inputIntSize); // Hrothgar face hack.
if (ImGui.InputInt("##text", ref currentIndex, 1, 1)) if (_currentIndex is CustomizeIndex.Face && _set.Race is Race.Hrothgar)
{ value -= 4;
currentIndex = Math.Clamp(currentIndex - 1, 0, _currentCount - 1);
var data = _set.Data(_currentIndex, currentIndex, _customize.Face);
UpdateValue(data.Value);
}
ImGuiUtil.HoverTooltip($"Input Range: [1, {_currentCount}]"); ImGui.SetNextItemWidth(_inputIntSizeNoButtons);
if (ImGui.InputInt("##text", ref value, 0, 0))
{
var index = _set.DataByValue(_currentIndex, (CustomizeValue)value, out var data, _customize.Face);
if (index >= 0)
UpdateValue(data!.Value.Value);
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.");
ImGui.SameLine();
if (ImGuiUtil.DrawDisabledButton("-", new Vector2(ImGui.GetFrameHeight()), "Select the previous available option in order.",
currentIndex <= 0))
UpdateValue(_set.Data(_currentIndex, currentIndex - 1, _customize.Face).Value);
ImGui.SameLine();
if (ImGuiUtil.DrawDisabledButton("+", new Vector2(ImGui.GetFrameHeight()), "Select the next available option in order.",
currentIndex >= _currentCount - 1 || npc))
UpdateValue(_set.Data(_currentIndex, currentIndex + 1, _customize.Face).Value);
} }
private void DrawListSelector(CustomizeIndex index) private void DrawListSelector(CustomizeIndex index)
@ -109,7 +126,8 @@ public partial class CustomizationDrawer
var tmp = _currentByte != CustomizeValue.Zero; var tmp = _currentByte != CustomizeValue.Zero;
if (_withApply) if (_withApply)
{ {
switch (UiHelpers.DrawMetaToggle(_currentIndex.ToDefaultName(), string.Empty, tmp, _currentApply, out var newValue, out var newApply, _locked)) switch (UiHelpers.DrawMetaToggle(_currentIndex.ToDefaultName(), string.Empty, tmp, _currentApply, out var newValue,
out var newApply, _locked))
{ {
case DataChange.Item: case DataChange.Item:
ChangeApply = newApply ? ChangeApply | _currentFlag : ChangeApply & ~_currentFlag; ChangeApply = newApply ? ChangeApply | _currentFlag : ChangeApply & ~_currentFlag;

View file

@ -8,6 +8,7 @@ using Glamourer.Services;
using ImGuiNET; using ImGuiNET;
using OtterGui; using OtterGui;
using OtterGui.Raii; using OtterGui.Raii;
using Penumbra.GameData.Enums;
using CustomizeData = Penumbra.GameData.Structs.CustomizeData; using CustomizeData = Penumbra.GameData.Structs.CustomizeData;
namespace Glamourer.Gui.Customization; namespace Glamourer.Gui.Customization;
@ -42,6 +43,7 @@ public partial class CustomizationDrawer : IDisposable
private Vector2 _iconSize; private Vector2 _iconSize;
private Vector2 _framedIconSize; private Vector2 _framedIconSize;
private float _inputIntSize; private float _inputIntSize;
private float _inputIntSizeNoButtons;
private float _comboSelectorSize; private float _comboSelectorSize;
private float _raceSelectorWidth; private float _raceSelectorWidth;
private bool _withApply; private bool _withApply;
@ -116,6 +118,10 @@ public partial class CustomizationDrawer : IDisposable
if (_currentByte == value) if (_currentByte == value)
return; return;
// Hrothgar Face Hack.
if (_currentIndex is CustomizeIndex.Face && _set.Race is Race.Hrothgar)
value += 4;
_customize[_currentIndex] = value; _customize[_currentIndex] = value;
Changed |= _currentFlag; Changed |= _currentFlag;
} }
@ -198,6 +204,7 @@ public partial class CustomizationDrawer : IDisposable
_iconSize = new Vector2(ImGui.GetTextLineHeight() * 2 + ImGui.GetStyle().ItemSpacing.Y + 2 * ImGui.GetStyle().FramePadding.Y); _iconSize = new Vector2(ImGui.GetTextLineHeight() * 2 + ImGui.GetStyle().ItemSpacing.Y + 2 * ImGui.GetStyle().FramePadding.Y);
_framedIconSize = _iconSize + 2 * ImGui.GetStyle().FramePadding; _framedIconSize = _iconSize + 2 * ImGui.GetStyle().FramePadding;
_inputIntSize = 2 * _framedIconSize.X + 1 * _spacing.X; _inputIntSize = 2 * _framedIconSize.X + 1 * _spacing.X;
_inputIntSizeNoButtons = _inputIntSize - 2 * _spacing.X - 2 * ImGui.GetFrameHeight();
_comboSelectorSize = 4 * _framedIconSize.X + 3 * _spacing.X; _comboSelectorSize = 4 * _framedIconSize.X + 3 * _spacing.X;
_raceSelectorWidth = _inputIntSize + _comboSelectorSize - _framedIconSize.X; _raceSelectorWidth = _inputIntSize + _comboSelectorSize - _framedIconSize.X;
} }

View file

@ -107,6 +107,7 @@ public class EquipmentDrawer
StainId cMainhandStain, out StainId rMainhandStain, StainId cOffhandStain, out StainId rOffhandStain, EquipFlag? cApply, StainId cMainhandStain, out StainId rMainhandStain, StainId cOffhandStain, out StainId rOffhandStain, EquipFlag? cApply,
out bool rApplyMainhand, out bool rApplyMainhandStain, out bool rApplyOffhand, out bool rApplyOffhandStain, bool locked) out bool rApplyMainhand, out bool rApplyMainhandStain, out bool rApplyOffhand, out bool rApplyOffhandStain, bool locked)
{ {
var allWeapons = cApply.HasValue;
if (_config.HideApplyCheckmarks) if (_config.HideApplyCheckmarks)
cApply = null; cApply = null;
@ -116,10 +117,12 @@ public class EquipmentDrawer
if (_config.SmallEquip) if (_config.SmallEquip)
return DrawWeaponsSmall(cMainhand, out rMainhand, cOffhand, out rOffhand, cMainhandStain, out rMainhandStain, cOffhandStain, return DrawWeaponsSmall(cMainhand, out rMainhand, cOffhand, out rOffhand, cMainhandStain, out rMainhandStain, cOffhandStain,
out rOffhandStain, cApply, out rApplyMainhand, out rApplyMainhandStain, out rApplyOffhand, out rApplyOffhandStain, locked); out rOffhandStain, cApply, out rApplyMainhand, out rApplyMainhandStain, out rApplyOffhand, out rApplyOffhandStain, locked,
allWeapons);
return DrawWeaponsNormal(cMainhand, out rMainhand, cOffhand, out rOffhand, cMainhandStain, out rMainhandStain, cOffhandStain, return DrawWeaponsNormal(cMainhand, out rMainhand, cOffhand, out rOffhand, cMainhandStain, out rMainhandStain, cOffhandStain,
out rOffhandStain, cApply, out rApplyMainhand, out rApplyMainhandStain, out rApplyOffhand, out rApplyOffhandStain, locked); out rOffhandStain, cApply, out rApplyMainhand, out rApplyMainhandStain, out rApplyOffhand, out rApplyOffhandStain, locked,
allWeapons);
} }
public bool DrawHatState(bool currentValue, out bool newValue, bool locked) public bool DrawHatState(bool currentValue, out bool newValue, bool locked)
@ -408,7 +411,8 @@ public class EquipmentDrawer
private DataChange DrawWeaponsSmall(EquipItem cMainhand, out EquipItem rMainhand, EquipItem cOffhand, out EquipItem rOffhand, private DataChange DrawWeaponsSmall(EquipItem cMainhand, out EquipItem rMainhand, EquipItem cOffhand, out EquipItem rOffhand,
StainId cMainhandStain, out StainId rMainhandStain, StainId cOffhandStain, out StainId rOffhandStain, EquipFlag? cApply, StainId cMainhandStain, out StainId rMainhandStain, StainId cOffhandStain, out StainId rOffhandStain, EquipFlag? cApply,
out bool rApplyMainhand, out bool rApplyMainhandStain, out bool rApplyOffhand, out bool rApplyOffhandStain, bool locked) out bool rApplyMainhand, out bool rApplyMainhandStain, out bool rApplyOffhand, out bool rApplyOffhandStain, bool locked,
bool allWeapons)
{ {
var changes = DataChange.None; var changes = DataChange.None;
if (DrawStain(EquipSlot.MainHand, cMainhandStain, out rMainhandStain, locked, true)) if (DrawStain(EquipSlot.MainHand, cMainhandStain, out rMainhandStain, locked, true))
@ -416,7 +420,7 @@ public class EquipmentDrawer
ImGui.SameLine(); ImGui.SameLine();
rOffhand = cOffhand; rOffhand = cOffhand;
if (DrawMainhand(cMainhand, cApply.HasValue, out rMainhand, out var mainhandLabel, locked, true)) if (DrawMainhand(cMainhand, allWeapons, out rMainhand, out var mainhandLabel, locked, true))
{ {
changes |= DataChange.Item; changes |= DataChange.Item;
if (rMainhand.Type.ValidOffhand() != cMainhand.Type.ValidOffhand()) if (rMainhand.Type.ValidOffhand() != cMainhand.Type.ValidOffhand())
@ -480,7 +484,8 @@ public class EquipmentDrawer
private DataChange DrawWeaponsNormal(EquipItem cMainhand, out EquipItem rMainhand, EquipItem cOffhand, out EquipItem rOffhand, private DataChange DrawWeaponsNormal(EquipItem cMainhand, out EquipItem rMainhand, EquipItem cOffhand, out EquipItem rOffhand,
StainId cMainhandStain, out StainId rMainhandStain, StainId cOffhandStain, out StainId rOffhandStain, EquipFlag? cApply, StainId cMainhandStain, out StainId rMainhandStain, StainId cOffhandStain, out StainId rOffhandStain, EquipFlag? cApply,
out bool rApplyMainhand, out bool rApplyMainhandStain, out bool rApplyOffhand, out bool rApplyOffhandStain, bool locked) out bool rApplyMainhand, out bool rApplyMainhandStain, out bool rApplyOffhand, out bool rApplyOffhandStain, bool locked,
bool allWeapons)
{ {
var changes = DataChange.None; var changes = DataChange.None;
@ -492,7 +497,7 @@ public class EquipmentDrawer
using (var group = ImRaii.Group()) using (var group = ImRaii.Group())
{ {
rOffhand = cOffhand; rOffhand = cOffhand;
if (DrawMainhand(cMainhand, cApply.HasValue, out rMainhand, out var mainhandLabel, locked, false)) if (DrawMainhand(cMainhand, allWeapons, out rMainhand, out var mainhandLabel, locked, false))
{ {
changes |= DataChange.Item; changes |= DataChange.Item;
if (rMainhand.Type.ValidOffhand() != cMainhand.Type.ValidOffhand()) if (rMainhand.Type.ValidOffhand() != cMainhand.Type.ValidOffhand())