Add hover background to tables

This commit is contained in:
Liza 2024-06-26 10:53:15 +02:00
parent 92cf0f0ff3
commit bdffc18c39
Signed by: liza
GPG Key ID: 7199F8D727D55F67

View File

@ -71,7 +71,7 @@ internal sealed class EquipmentBrowserWindow : Window
return _clientState.IsLoggedIn; return _clientState.IsLoggedIn;
} }
public override void Draw() public override unsafe void Draw()
{ {
int currentClassJob = Array.IndexOf(_classJobIds, _selectedClassJob); int currentClassJob = Array.IndexOf(_classJobIds, _selectedClassJob);
if (currentClassJob == -1) if (currentClassJob == -1)
@ -124,6 +124,10 @@ internal sealed class EquipmentBrowserWindow : Window
or EEquipSlotCategory.TwoHandedMainHand or EEquipSlotCategory.TwoHandedMainHand
&& !itemList.ClassJob.IsCrafter() && !itemList.ClassJob.IsCrafter()
&& !itemList.ClassJob.IsGatherer(); && !itemList.ClassJob.IsGatherer();
var hoverColorPtr = ImGui.GetStyleColorVec4(ImGuiCol.HeaderHovered);
var hoverColor = new Vector4(hoverColorPtr->X, hoverColorPtr->Y, hoverColorPtr->Z, 0.3f);
if (ImGui.BeginTable("ItemList", 2 + (includeDamage ? 1 : 0) + itemList.SubstatPriorities.Count, if (ImGui.BeginTable("ItemList", 2 + (includeDamage ? 1 : 0) + itemList.SubstatPriorities.Count,
ImGuiTableFlags.Borders | ImGuiTableFlags.Resizable)) ImGuiTableFlags.Borders | ImGuiTableFlags.Resizable))
{ {
@ -136,6 +140,7 @@ internal sealed class EquipmentBrowserWindow : Window
ImGui.TableHeadersRow(); ImGui.TableHeadersRow();
ImGui.PushStyleColor(ImGuiCol.HeaderHovered, hoverColor);
foreach (var item in itemList.Items.DistinctBy(x => new { x.ItemId, x.Hq, Materia = x.MateriaStats?.GetHashCode() })) foreach (var item in itemList.Items.DistinctBy(x => new { x.ItemId, x.Hq, Materia = x.MateriaStats?.GetHashCode() }))
{ {
if (item is not InventoryItem) if (item is not InventoryItem)
@ -168,12 +173,15 @@ internal sealed class EquipmentBrowserWindow : Window
name += $" {SeIconChar.HighQuality.ToIconString()}"; name += $" {SeIconChar.HighQuality.ToIconString()}";
if (item is InventoryItem { MateriaStats: not null } inventoryItem) if (item is InventoryItem { MateriaStats: not null } inventoryItem)
name += name +=
$" {string.Join("", Enumerable.Repeat(SeIconChar.Circle.ToIconString(), inventoryItem.MateriaStats.Count))}"; $" {string.Join("", Enumerable.Repeat(SeIconChar.Circle.ToIconString(), inventoryItem.MateriaStats!.Count))}";
if (color != null) if (color != null)
ImGui.TextColored(color.Value, name); ImGui.PushStyleColor(ImGuiCol.Text, color.Value);
else
ImGui.Text(name); ImGui.Selectable(name, false, ImGuiSelectableFlags.SpanAllColumns);
if (color != null)
ImGui.PopStyleColor();
if (ImGui.IsItemClicked()) if (ImGui.IsItemClicked())
{ {
@ -215,6 +223,7 @@ internal sealed class EquipmentBrowserWindow : Window
} }
} }
ImGui.PopStyleColor();
ImGui.EndTable(); ImGui.EndTable();
} }
} }