From 8fc555e5de535222c161e5d02aeed8a1304e7bbb Mon Sep 17 00:00:00 2001 From: Anna Date: Wed, 7 Sep 2022 02:05:13 -0400 Subject: [PATCH] beep --- client/Ui/ImGuiExt.cs | 37 +++++++++++++++++++++++++ client/Ui/MainWindowTabs/MessageList.cs | 17 +++++++++++- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 client/Ui/ImGuiExt.cs diff --git a/client/Ui/ImGuiExt.cs b/client/Ui/ImGuiExt.cs new file mode 100644 index 0000000..fb6adbc --- /dev/null +++ b/client/Ui/ImGuiExt.cs @@ -0,0 +1,37 @@ +using Dalamud.Interface; +using ImGuiNET; + +namespace OrangeGuidanceTomestone.Ui; + +internal static class ImGuiExt { + internal static bool SmallIconButton(FontAwesomeIcon icon, string? id = null) { + var label = icon.ToIconString(); + if (id != null) { + label += $"##{id}"; + } + + ImGui.PushFont(UiBuilder.IconFont); + var ret = ImGui.SmallButton(label); + ImGui.PopFont(); + + return ret; + } + + internal static void HelpIcon(string text) { + var colour = ImGui.GetStyle().Colors[(int) ImGuiCol.TextDisabled]; + ImGui.PushStyleColor(ImGuiCol.Text, colour); + ImGui.TextUnformatted("(?)"); + ImGui.PopStyleColor(); + + if (!ImGui.IsItemHovered()) { + return; + } + + var width = ImGui.CalcTextSize("m") * 40; + ImGui.BeginTooltip(); + ImGui.PushTextWrapPos(width.X); + ImGui.TextUnformatted(text); + ImGui.PopTextWrapPos(); + ImGui.EndTooltip(); + } +} diff --git a/client/Ui/MainWindowTabs/MessageList.cs b/client/Ui/MainWindowTabs/MessageList.cs index 6365291..720e679 100644 --- a/client/Ui/MainWindowTabs/MessageList.cs +++ b/client/Ui/MainWindowTabs/MessageList.cs @@ -1,4 +1,5 @@ using Dalamud.Game.Text.SeStringHandling.Payloads; +using Dalamud.Interface; using Dalamud.Utility; using ImGuiNET; using Lumina.Excel.GeneratedSheets; @@ -71,7 +72,7 @@ internal class MessageList : ITab { ImGui.TextUnformatted($"Location: {territoryName}"); ImGui.SameLine(); - if (ImGui.SmallButton($"Open map##{message.Id}") && territory != null) { + if (ImGuiExt.SmallIconButton(FontAwesomeIcon.MapMarkerAlt, $"{message.Id}") && territory != null) { this.Plugin.GameGui.OpenMapWithMapLink(new MapLinkPayload( territory.RowId, territory.Map.Row, @@ -80,12 +81,26 @@ internal class MessageList : ITab { )); } + var ctrl = ImGui.GetIO().KeyCtrl; + var appraisals = Math.Max(0, message.PositiveVotes - message.NegativeVotes); ImGui.TextUnformatted($"Appraisals: {appraisals:N0} ({message.PositiveVotes:N0} - {message.NegativeVotes:N0})"); + + if (!ctrl) { + ImGui.BeginDisabled(); + } + if (ImGui.Button($"Delete##{message.Id}")) { this.Delete(message.Id); } + if (!ctrl) { + ImGui.EndDisabled(); + } + + ImGui.SameLine(); + ImGuiExt.HelpIcon("Hold Ctrl to enable the delete button."); + ImGui.TreePop(); ImGui.Separator();