From 9d569266b5bf8f5a7745f6fcf8deecdc5971897f Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 31 Jul 2024 16:58:33 +0200 Subject: [PATCH] Improve job filter in unlocks tab. --- Glamourer.Api | 2 +- Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs | 50 ++++++++++++++++---- OtterGui | 2 +- Penumbra.GameData | 2 +- 4 files changed, 44 insertions(+), 12 deletions(-) diff --git a/Glamourer.Api b/Glamourer.Api index ca00339..663702b 160000 --- a/Glamourer.Api +++ b/Glamourer.Api @@ -1 +1 @@ -Subproject commit ca003395306791b9e595683c47824b4718385311 +Subproject commit 663702b57303368b3a897e9c6eae4b34b4339534 diff --git a/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs b/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs index 600546f..558c4df 100644 --- a/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs +++ b/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs @@ -9,6 +9,7 @@ using ImGuiNET; using OtterGui; using OtterGui.Raii; using OtterGui.Table; +using OtterGui.Text; using Penumbra.GameData.Enums; using Penumbra.GameData.Structs; @@ -23,16 +24,16 @@ public class UnlockTable : Table, IDisposable : base("ItemUnlockTable", new ItemList(items), new FavoriteColumn(favorites, @event) { Label = "F" }, new NameColumn(textures, tooltip) { Label = "Item Name..." }, - new SlotColumn() { Label = "Equip Slot" }, - new TypeColumn() { Label = "Item Type..." }, + new SlotColumn { Label = "Equip Slot" }, + new TypeColumn { Label = "Item Type..." }, new UnlockDateColumn(itemUnlocks) { Label = "Unlocked" }, - new ItemIdColumn() { Label = "Item Id..." }, + new ItemIdColumn { Label = "Item Id..." }, new ModelDataColumn(items) { Label = "Model Data..." }, new JobColumn(jobs) { Label = "Jobs" }, - new RequiredLevelColumn() { Label = "Level..." }, - new DyableColumn() { Label = "Dye" }, - new CrestColumn() { Label = "Crest" }, - new TradableColumn() { Label = "Trade" } + new RequiredLevelColumn { Label = "Level..." }, + new DyableColumn { Label = "Dye" }, + new CrestColumn { Label = "Crest" }, + new TradableColumn { Label = "Trade" } ) { _event = @event; @@ -334,11 +335,42 @@ public class UnlockTable : Table, IDisposable public JobColumn(JobService jobs) { _jobs = jobs; - _values = _jobs.Jobs.Values.Skip(1).Select(j => j.Flag).ToArray(); - _names = _jobs.Jobs.Values.Skip(1).Select(j => j.Abbreviation).ToArray(); + _values = _jobs.Jobs.Ordered.Select(j => j.Flag).ToArray(); + _names = _jobs.Jobs.Ordered.Select(j => j.Abbreviation).ToArray(); AllFlags = _values.Aggregate((l, r) => l | r); _filterValue = AllFlags; Flags &= ~ImGuiTableColumnFlags.NoResize; + ComboFlags |= ImGuiComboFlags.HeightLargest; + } + + protected override bool DrawCheckbox(int idx, out bool ret) + { + var job = _jobs.Jobs.Ordered[idx]; + var color = job.Role switch + { + Job.JobRole.Tank => 0xFFFFD0D0, + Job.JobRole.Melee => 0xFFD0D0FF, + Job.JobRole.RangedPhysical => 0xFFD0FFFF, + Job.JobRole.RangedMagical => 0xFFFFD0FF, + Job.JobRole.Healer => 0xFFD0FFD0, + Job.JobRole.Crafter => 0xFF808080, + Job.JobRole.Gatherer => 0xFFD0D0D0, + _ => ImGui.GetColorU32(ImGuiCol.Text), + }; + using var c = ImRaii.PushColor(ImGuiCol.Text, color); + var r = base.DrawCheckbox(idx, out ret); + if (ImGui.IsItemClicked(ImGuiMouseButton.Right)) + { + _filterValue = job.Flag & _filterValue; + ret = true; + r = true; + } + + ImUtf8.HoverTooltip("Right-Click to disable all other jobs."u8); + + if (idx < _names.Length - 1 && idx % 2 == 0) + ImGui.SameLine(ImGui.GetFrameHeight() * 4); + return r; } protected override void SetValue(JobFlag value, bool enable) diff --git a/OtterGui b/OtterGui index c2738e1..3a14692 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit c2738e1d42974cddbe5a31238c6ed236a831d17d +Subproject commit 3a14692e38708ca9f18652898e6f5c8cc87b517b diff --git a/Penumbra.GameData b/Penumbra.GameData index da99d9b..cd40d49 160000 --- a/Penumbra.GameData +++ b/Penumbra.GameData @@ -1 +1 @@ -Subproject commit da99d9b2b3c51b2bbeb40226c692dff2cbcd5cbc +Subproject commit cd40d497f4791e946c0fd4bd5663da578f7680ed