mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 18:27:24 +01:00
Improve unlocks table.
This commit is contained in:
parent
909966d411
commit
7a94c4ee07
4 changed files with 49 additions and 86 deletions
|
|
@ -184,7 +184,7 @@ public class DesignQuickBar : Window, IDisposable
|
||||||
if (available == 0)
|
if (available == 0)
|
||||||
tooltip = "Neither player character nor target are available, have state modified by Glamourer, or their state is locked.";
|
tooltip = "Neither player character nor target are available, have state modified by Glamourer, or their state is locked.";
|
||||||
|
|
||||||
var (clicked, id, data, state) = ResolveTarget(FontAwesomeIcon.RedoAlt, buttonSize, tooltip, available);
|
var (clicked, id, data, state) = ResolveTarget(FontAwesomeIcon.UndoAlt, buttonSize, tooltip, available);
|
||||||
if (clicked)
|
if (clicked)
|
||||||
_stateManager.ResetState(state!, StateChanged.Source.Manual);
|
_stateManager.ResetState(state!, StateChanged.Source.Manual);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using Dalamud.Game.Text.SeStringHandling;
|
using Dalamud.Game.Text.SeStringHandling;
|
||||||
using Dalamud.Interface;
|
|
||||||
using Dalamud.Interface.Utility;
|
using Dalamud.Interface.Utility;
|
||||||
using Glamourer.Events;
|
using Glamourer.Events;
|
||||||
using Glamourer.Interop;
|
using Glamourer.Interop;
|
||||||
|
|
@ -35,7 +34,7 @@ public class UnlockTable : Table<EquipItem>, IDisposable
|
||||||
new ItemIdColumn() { Label = "Item Id..." },
|
new ItemIdColumn() { Label = "Item Id..." },
|
||||||
new ModelDataColumn(items) { Label = "Model Data..." },
|
new ModelDataColumn(items) { Label = "Model Data..." },
|
||||||
new JobColumn(jobs) { Label = "Jobs" },
|
new JobColumn(jobs) { Label = "Jobs" },
|
||||||
new LevelColumn() { Label = "Level..." },
|
new RequiredLevelColumn() { Label = "Level..." },
|
||||||
new DyableColumn() { Label = "Dye" },
|
new DyableColumn() { Label = "Dye" },
|
||||||
new CrestColumn() { Label = "Crest" },
|
new CrestColumn() { Label = "Crest" },
|
||||||
new TradableColumn() { Label = "Trade" }
|
new TradableColumn() { Label = "Trade" }
|
||||||
|
|
@ -43,14 +42,14 @@ public class UnlockTable : Table<EquipItem>, IDisposable
|
||||||
{
|
{
|
||||||
_event = @event;
|
_event = @event;
|
||||||
Sortable = true;
|
Sortable = true;
|
||||||
Flags |= ImGuiTableFlags.Hideable;
|
Flags |= ImGuiTableFlags.Hideable | ImGuiTableFlags.Reorderable | ImGuiTableFlags.Resizable;
|
||||||
_event.Subscribe(OnObjectUnlock, ObjectUnlocked.Priority.UnlockTable);
|
_event.Subscribe(OnObjectUnlock, ObjectUnlocked.Priority.UnlockTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
=> _event.Unsubscribe(OnObjectUnlock);
|
=> _event.Unsubscribe(OnObjectUnlock);
|
||||||
|
|
||||||
private sealed class FavoriteColumn : YesNoColumn
|
private sealed class FavoriteColumn : YesNoColumn<EquipItem>
|
||||||
{
|
{
|
||||||
public override float Width
|
public override float Width
|
||||||
=> ImGui.GetFrameHeightWithSpacing();
|
=> ImGui.GetFrameHeightWithSpacing();
|
||||||
|
|
@ -60,8 +59,9 @@ public class UnlockTable : Table<EquipItem>, IDisposable
|
||||||
|
|
||||||
public FavoriteColumn(FavoriteManager favorites, ObjectUnlocked hackEvent)
|
public FavoriteColumn(FavoriteManager favorites, ObjectUnlocked hackEvent)
|
||||||
{
|
{
|
||||||
_favorites = favorites;
|
_favorites = favorites;
|
||||||
_hackEvent = hackEvent;
|
_hackEvent = hackEvent;
|
||||||
|
Flags |= ImGuiTableColumnFlags.NoResize;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool GetValue(EquipItem item)
|
protected override bool GetValue(EquipItem item)
|
||||||
|
|
@ -145,8 +145,9 @@ public class UnlockTable : Table<EquipItem>, IDisposable
|
||||||
|
|
||||||
public SlotColumn()
|
public SlotColumn()
|
||||||
{
|
{
|
||||||
AllFlags = Values.Aggregate((a, b) => a | b);
|
Flags &= ~ImGuiTableColumnFlags.NoResize;
|
||||||
_filterValue = AllFlags;
|
AllFlags = Values.Aggregate((a, b) => a | b);
|
||||||
|
_filterValue = AllFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DrawColumn(EquipItem item, int idx)
|
public override void DrawColumn(EquipItem item, int idx)
|
||||||
|
|
@ -225,7 +226,10 @@ public class UnlockTable : Table<EquipItem>, IDisposable
|
||||||
=> 110 * ImGuiHelpers.GlobalScale;
|
=> 110 * ImGuiHelpers.GlobalScale;
|
||||||
|
|
||||||
public UnlockDateColumn(ItemUnlockManager unlocks)
|
public UnlockDateColumn(ItemUnlockManager unlocks)
|
||||||
=> _unlocks = unlocks;
|
{
|
||||||
|
_unlocks = unlocks;
|
||||||
|
Flags &= ~ImGuiTableColumnFlags.NoResize;
|
||||||
|
}
|
||||||
|
|
||||||
public override void DrawColumn(EquipItem item, int idx)
|
public override void DrawColumn(EquipItem item, int idx)
|
||||||
{
|
{
|
||||||
|
|
@ -245,22 +249,17 @@ public class UnlockTable : Table<EquipItem>, IDisposable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private sealed class ItemIdColumn : ColumnString<EquipItem>
|
private sealed class ItemIdColumn : ColumnNumber<EquipItem>
|
||||||
{
|
{
|
||||||
public override float Width
|
public override float Width
|
||||||
=> 70 * ImGuiHelpers.GlobalScale;
|
=> 70 * ImGuiHelpers.GlobalScale;
|
||||||
|
|
||||||
public override int Compare(EquipItem lhs, EquipItem rhs)
|
public override int ToValue(EquipItem item)
|
||||||
=> lhs.ItemId.Id.CompareTo(rhs.ItemId.Id);
|
=> (int) item.Id.Id;
|
||||||
|
|
||||||
public override string ToName(EquipItem item)
|
public ItemIdColumn()
|
||||||
=> item.ItemId.ToString();
|
: base(ComparisonMethod.Equal)
|
||||||
|
{ }
|
||||||
public override void DrawColumn(EquipItem item, int _)
|
|
||||||
{
|
|
||||||
ImGui.AlignTextToFramePadding();
|
|
||||||
ImGuiUtil.RightAlign(item.ItemId.ToString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private sealed class ModelDataColumn : ColumnString<EquipItem>
|
private sealed class ModelDataColumn : ColumnString<EquipItem>
|
||||||
|
|
@ -287,7 +286,7 @@ public class UnlockTable : Table<EquipItem>, IDisposable
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int Compare(EquipItem lhs, EquipItem rhs)
|
public override int Compare(EquipItem lhs, EquipItem rhs)
|
||||||
=> lhs.Weapon().Value.CompareTo(rhs.Weapon().Value);
|
=> lhs.Weapon().CompareTo(rhs.Weapon());
|
||||||
|
|
||||||
public override bool FilterFunc(EquipItem item)
|
public override bool FilterFunc(EquipItem item)
|
||||||
{
|
{
|
||||||
|
|
@ -306,7 +305,7 @@ public class UnlockTable : Table<EquipItem>, IDisposable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private sealed class LevelColumn : ColumnString<EquipItem>
|
private sealed class RequiredLevelColumn : ColumnNumber<EquipItem>
|
||||||
{
|
{
|
||||||
public override float Width
|
public override float Width
|
||||||
=> 70 * ImGuiHelpers.GlobalScale;
|
=> 70 * ImGuiHelpers.GlobalScale;
|
||||||
|
|
@ -314,11 +313,12 @@ public class UnlockTable : Table<EquipItem>, IDisposable
|
||||||
public override string ToName(EquipItem item)
|
public override string ToName(EquipItem item)
|
||||||
=> item.Level.ToString();
|
=> item.Level.ToString();
|
||||||
|
|
||||||
public override void DrawColumn(EquipItem item, int _)
|
public override int ToValue(EquipItem item)
|
||||||
=> ImGuiUtil.RightAlign(item.Level.Value.ToString());
|
=> item.Level.Value;
|
||||||
|
|
||||||
public override int Compare(EquipItem lhs, EquipItem rhs)
|
public RequiredLevelColumn()
|
||||||
=> lhs.Level.Value.CompareTo(rhs.Level.Value);
|
: base(ComparisonMethod.LessEqual)
|
||||||
|
{ }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -338,11 +338,12 @@ public class UnlockTable : Table<EquipItem>, IDisposable
|
||||||
|
|
||||||
public JobColumn(JobService jobs)
|
public JobColumn(JobService jobs)
|
||||||
{
|
{
|
||||||
_jobs = jobs;
|
_jobs = jobs;
|
||||||
_values = _jobs.Jobs.Values.Skip(1).Select(j => j.Flag).ToArray();
|
_values = _jobs.Jobs.Values.Skip(1).Select(j => j.Flag).ToArray();
|
||||||
_names = _jobs.Jobs.Values.Skip(1).Select(j => j.Abbreviation).ToArray();
|
_names = _jobs.Jobs.Values.Skip(1).Select(j => j.Abbreviation).ToArray();
|
||||||
AllFlags = _values.Aggregate((l, r) => l | r);
|
AllFlags = _values.Aggregate((l, r) => l | r);
|
||||||
_filterValue = AllFlags;
|
_filterValue = AllFlags;
|
||||||
|
Flags &= ~ImGuiTableColumnFlags.NoResize;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SetValue(JobFlag value, bool enable)
|
protected override void SetValue(JobFlag value, bool enable)
|
||||||
|
|
@ -383,57 +384,7 @@ public class UnlockTable : Table<EquipItem>, IDisposable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Flags]
|
private sealed class DyableColumn : YesNoColumn<EquipItem>
|
||||||
private enum YesNoFlag
|
|
||||||
{
|
|
||||||
Yes = 0x01,
|
|
||||||
No = 0x02,
|
|
||||||
};
|
|
||||||
|
|
||||||
private class YesNoColumn : ColumnFlags<YesNoFlag, EquipItem>
|
|
||||||
{
|
|
||||||
public string Tooltip = string.Empty;
|
|
||||||
|
|
||||||
private YesNoFlag _filterValue;
|
|
||||||
|
|
||||||
public override YesNoFlag FilterValue
|
|
||||||
=> _filterValue;
|
|
||||||
|
|
||||||
public YesNoColumn()
|
|
||||||
{
|
|
||||||
AllFlags = YesNoFlag.Yes | YesNoFlag.No;
|
|
||||||
_filterValue = AllFlags;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void SetValue(YesNoFlag value, bool enable)
|
|
||||||
=> _filterValue = enable ? _filterValue | value : _filterValue & ~value;
|
|
||||||
|
|
||||||
protected virtual bool GetValue(EquipItem item)
|
|
||||||
=> false;
|
|
||||||
|
|
||||||
public override float Width
|
|
||||||
=> ImGui.GetFrameHeight() * 2;
|
|
||||||
|
|
||||||
public override bool FilterFunc(EquipItem item)
|
|
||||||
=> GetValue(item)
|
|
||||||
? FilterValue.HasFlag(YesNoFlag.Yes)
|
|
||||||
: FilterValue.HasFlag(YesNoFlag.No);
|
|
||||||
|
|
||||||
public override int Compare(EquipItem lhs, EquipItem rhs)
|
|
||||||
=> GetValue(lhs).CompareTo(GetValue(rhs));
|
|
||||||
|
|
||||||
public override void DrawColumn(EquipItem item, int idx)
|
|
||||||
{
|
|
||||||
using (var font = ImRaii.PushFont(UiBuilder.IconFont))
|
|
||||||
{
|
|
||||||
ImGuiUtil.Center(GetValue(item) ? FontAwesomeIcon.Check.ToIconString() : FontAwesomeIcon.Times.ToIconString());
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGuiUtil.HoverTooltip(Tooltip);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private sealed class DyableColumn : YesNoColumn
|
|
||||||
{
|
{
|
||||||
public DyableColumn()
|
public DyableColumn()
|
||||||
=> Tooltip = "Whether the item is dyable.";
|
=> Tooltip = "Whether the item is dyable.";
|
||||||
|
|
@ -442,7 +393,7 @@ public class UnlockTable : Table<EquipItem>, IDisposable
|
||||||
=> item.Flags.HasFlag(ItemFlags.IsDyable);
|
=> item.Flags.HasFlag(ItemFlags.IsDyable);
|
||||||
}
|
}
|
||||||
|
|
||||||
private sealed class TradableColumn : YesNoColumn
|
private sealed class TradableColumn : YesNoColumn<EquipItem>
|
||||||
{
|
{
|
||||||
public TradableColumn()
|
public TradableColumn()
|
||||||
=> Tooltip = "Whether the item is tradable.";
|
=> Tooltip = "Whether the item is tradable.";
|
||||||
|
|
@ -451,7 +402,7 @@ public class UnlockTable : Table<EquipItem>, IDisposable
|
||||||
=> item.Flags.HasFlag(ItemFlags.IsTradable);
|
=> item.Flags.HasFlag(ItemFlags.IsTradable);
|
||||||
}
|
}
|
||||||
|
|
||||||
private sealed class CrestColumn : YesNoColumn
|
private sealed class CrestColumn : YesNoColumn<EquipItem>
|
||||||
{
|
{
|
||||||
public CrestColumn()
|
public CrestColumn()
|
||||||
=> Tooltip = "Whether a crest can be applied to the item..";
|
=> Tooltip = "Whether a crest can be applied to the item..";
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ public class UnlocksTab : Window, ITab
|
||||||
_table.Draw(ImGui.GetFrameHeightWithSpacing());
|
_table.Draw(ImGui.GetFrameHeightWithSpacing());
|
||||||
else
|
else
|
||||||
_overview.Draw();
|
_overview.Draw();
|
||||||
|
_table.Flags |= ImGuiTableFlags.Resizable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Draw()
|
public override void Draw()
|
||||||
|
|
@ -64,6 +65,8 @@ public class UnlocksTab : Window, ITab
|
||||||
var buttonSize = new Vector2(ImGui.GetContentRegionAvail().X / 2, ImGui.GetFrameHeight());
|
var buttonSize = new Vector2(ImGui.GetContentRegionAvail().X / 2, ImGui.GetFrameHeight());
|
||||||
if (!IsOpen)
|
if (!IsOpen)
|
||||||
buttonSize.X -= ImGui.GetFrameHeight() / 2;
|
buttonSize.X -= ImGui.GetFrameHeight() / 2;
|
||||||
|
if (DetailMode)
|
||||||
|
buttonSize.X -= ImGui.GetFrameHeight() / 2;
|
||||||
|
|
||||||
if (ImGuiUtil.DrawDisabledButton("Overview Mode", buttonSize, "Show tinted icons of sets of unlocks.", !DetailMode))
|
if (ImGuiUtil.DrawDisabledButton("Overview Mode", buttonSize, "Show tinted icons of sets of unlocks.", !DetailMode))
|
||||||
DetailMode = false;
|
DetailMode = false;
|
||||||
|
|
@ -72,6 +75,15 @@ public class UnlocksTab : Window, ITab
|
||||||
if (ImGuiUtil.DrawDisabledButton("Detailed Mode", buttonSize, "Show all unlockable data as a combined filterable and sortable table.",
|
if (ImGuiUtil.DrawDisabledButton("Detailed Mode", buttonSize, "Show all unlockable data as a combined filterable and sortable table.",
|
||||||
DetailMode))
|
DetailMode))
|
||||||
DetailMode = true;
|
DetailMode = true;
|
||||||
|
|
||||||
|
if (DetailMode)
|
||||||
|
{
|
||||||
|
ImGui.SameLine();
|
||||||
|
if (ImGuiUtil.DrawDisabledButton(FontAwesomeIcon.Expand.ToIconString(), new Vector2(ImGui.GetFrameHeight()),
|
||||||
|
"Restore all columns to their original size.", false, true))
|
||||||
|
_table.Flags &= ~ImGuiTableFlags.Resizable;
|
||||||
|
}
|
||||||
|
|
||||||
if (!IsOpen)
|
if (!IsOpen)
|
||||||
{
|
{
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 0c0554e7c482fac35110c3375e890540ee31abb3
|
Subproject commit 6a0daf2f309c27c5a260825bce31094987fce3d1
|
||||||
Loading…
Add table
Add a link
Reference in a new issue