Test state done.

This commit is contained in:
Ottermandias 2023-07-13 00:34:48 +02:00
parent 129f9e070f
commit b37167f2dd
18 changed files with 521 additions and 156 deletions

View file

@ -1,3 +1,4 @@
using System;
using System.Numerics;
using Dalamud.Interface;
using Glamourer.Services;
@ -8,6 +9,20 @@ using Penumbra.GameData.Structs;
namespace Glamourer.Gui;
[Flags]
public enum DataChange : byte
{
None = 0x00,
Item = 0x01,
Stain = 0x02,
ApplyItem = 0x04,
ApplyStain = 0x08,
Item2 = 0x10,
Stain2 = 0x20,
ApplyItem2 = 0x40,
ApplyStain2 = 0x80,
}
public static class UiHelpers
{
public static void DrawIcon(this EquipItem item, TextureService textures, Vector2 size)
@ -40,15 +55,32 @@ public static class UiHelpers
return ret;
}
public static bool DrawVisor(bool current, out bool on, bool locked)
=> DrawCheckbox("##visorToggled", string.Empty, current, out on, locked);
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;
using (var disabled = ImRaii.Disabled(locked))
{
ret = ImGui.CheckboxFlags(label, ref flags, 3);
}
public static bool DrawHat(bool current, out bool on, bool locked)
=> DrawCheckbox("##hatVisible", string.Empty, current, out on, locked);
ImGuiUtil.HoverTooltip(tooltip);
public static bool DrawWeapon(bool current, out bool on, bool locked)
=> DrawCheckbox("##weaponVisible", string.Empty, current, out on, locked);
if (ret)
{
(newValue, newApply, var change) = (currentValue, currentApply) switch
{
(false, false) => (false, true, DataChange.ApplyItem),
(false, true) => (true, true, DataChange.Item),
(true, false) => (false, false, DataChange.Item), // Should not happen
(true, true) => (false, false, DataChange.Item | DataChange.ApplyItem),
};
return change;
}
public static bool DrawWetness(bool current, out bool on, bool locked)
=> DrawCheckbox("##wetness", string.Empty, current, out on, locked);
newValue = currentValue;
newApply = currentApply;
return DataChange.None;
}
}