diff --git a/client/Helpers/ImGuiHelper.cs b/client/Helpers/ImGuiHelper.cs index cc78828..2b1dc57 100644 --- a/client/Helpers/ImGuiHelper.cs +++ b/client/Helpers/ImGuiHelper.cs @@ -1,9 +1,10 @@ using Dalamud.Interface; +using Dalamud.Interface.Style; using ImGuiNET; namespace OrangeGuidanceTomestone.Helpers; -internal static class ImGuiExt { +internal static class ImGuiHelper { private static bool InternalIconButton(Func func, FontAwesomeIcon icon, string? id = null) { var label = icon.ToIconString(); if (id != null) { @@ -31,16 +32,7 @@ internal static class ImGuiExt { 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(); + TextTooltip(text); } internal static unsafe ImGuiListClipperPtr Clipper(int itemsCount) { @@ -49,4 +41,33 @@ internal static class ImGuiExt { return clipper; } + + internal static void TextTooltip(string tooltip) { + if (!ImGui.IsItemHovered()) { + return; + } + + var width = ImGui.CalcTextSize("m") * 40; + ImGui.BeginTooltip(); + ImGui.PushTextWrapPos(width.X); + ImGui.TextUnformatted(tooltip); + ImGui.PopTextWrapPos(); + ImGui.EndTooltip(); + } + + internal static void WarningText(string text) { + var style = StyleModel.GetConfiguredStyle() ?? StyleModel.GetFromCurrent(); + var dalamudOrange = style.BuiltInColors?.DalamudOrange; + if (dalamudOrange != null) { + ImGui.PushStyleColor(ImGuiCol.Text, dalamudOrange.Value); + } + + ImGui.PushTextWrapPos(); + ImGui.TextUnformatted(text); + ImGui.PopTextWrapPos(); + + if (dalamudOrange != null) { + ImGui.PopStyleColor(); + } + } } diff --git a/client/Message.cs b/client/Message.cs index 80804fe..0258488 100644 --- a/client/Message.cs +++ b/client/Message.cs @@ -43,6 +43,7 @@ internal class MessageWithTerritory { public int UserVote { get; set; } public int Glyph { get; set; } + public bool IsHidden { get; set; } internal Vector3 Position => new(this.X, this.Y, this.Z); @@ -59,6 +60,7 @@ internal class MessageWithTerritory { NegativeVotes = message.NegativeVotes, UserVote = message.UserVote, Glyph = message.Glyph, + IsHidden = false, }; } } diff --git a/client/Ui/MainWindowTabs/MessageList.cs b/client/Ui/MainWindowTabs/MessageList.cs index 720e679..e4a59c6 100644 --- a/client/Ui/MainWindowTabs/MessageList.cs +++ b/client/Ui/MainWindowTabs/MessageList.cs @@ -72,7 +72,7 @@ internal class MessageList : ITab { ImGui.TextUnformatted($"Location: {territoryName}"); ImGui.SameLine(); - if (ImGuiExt.SmallIconButton(FontAwesomeIcon.MapMarkerAlt, $"{message.Id}") && territory != null) { + if (ImGuiHelper.SmallIconButton(FontAwesomeIcon.MapMarkerAlt, $"{message.Id}") && territory != null) { this.Plugin.GameGui.OpenMapWithMapLink(new MapLinkPayload( territory.RowId, territory.Map.Row, @@ -81,6 +81,10 @@ internal class MessageList : ITab { )); } + if (message.IsHidden) { + ImGuiHelper.WarningText("This message's score is too low and will not be shown to other players."); + } + var ctrl = ImGui.GetIO().KeyCtrl; var appraisals = Math.Max(0, message.PositiveVotes - message.NegativeVotes); @@ -99,7 +103,7 @@ internal class MessageList : ITab { } ImGui.SameLine(); - ImGuiExt.HelpIcon("Hold Ctrl to enable the delete button."); + ImGuiHelper.HelpIcon("Hold Ctrl to enable the delete button."); ImGui.TreePop(); diff --git a/client/Ui/MainWindowTabs/Settings.cs b/client/Ui/MainWindowTabs/Settings.cs index a02606b..9387c8f 100644 --- a/client/Ui/MainWindowTabs/Settings.cs +++ b/client/Ui/MainWindowTabs/Settings.cs @@ -136,7 +136,7 @@ internal class Settings : ITab { var toAdd = -1L; var toRemove = -1L; - var clipper = ImGuiExt.Clipper(this.FilteredTerritories.Count); + var clipper = ImGuiHelper.Clipper(this.FilteredTerritories.Count); while (clipper.Step()) { for (var i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) { var (terrId, isBanned, name) = this.FilteredTerritories[i]; @@ -275,7 +275,7 @@ internal class Settings : ITab { } ImGui.SameLine(); - ImGuiExt.HelpIcon("Hold Ctrl to enable delete button."); + ImGuiHelper.HelpIcon("Hold Ctrl to enable delete button."); ImGui.TextUnformatted("This will delete all your messages and votes."); } diff --git a/client/Ui/Viewer.cs b/client/Ui/Viewer.cs index ba9edba..4faa7fc 100644 --- a/client/Ui/Viewer.cs +++ b/client/Ui/Viewer.cs @@ -70,7 +70,7 @@ internal class Viewer { ImGui.BeginDisabled(); } - if (ImGuiExt.IconButton(FontAwesomeIcon.AngleLeft)) { + if (ImGuiHelper.IconButton(FontAwesomeIcon.AngleLeft)) { this._idx -= 1; } @@ -167,7 +167,7 @@ internal class Viewer { ImGui.BeginDisabled(); } - if (ImGuiExt.IconButton(FontAwesomeIcon.AngleRight)) { + if (ImGuiHelper.IconButton(FontAwesomeIcon.AngleRight)) { this._idx += 1; }