This commit is contained in:
Anna 2022-09-07 02:05:13 -04:00
parent bdd89607a1
commit 8fc555e5de
2 changed files with 53 additions and 1 deletions

37
client/Ui/ImGuiExt.cs Normal file
View File

@ -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();
}
}

View File

@ -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();