1
0
forked from liza/Questionable

Use fixed-size icons for validation issue button

This commit is contained in:
Liza 2024-08-29 09:20:51 +02:00
parent a5419bb455
commit c57395fbfd
Signed by: liza
GPG Key ID: 7199F8D727D55F67

View File

@ -7,6 +7,7 @@ using Dalamud.Interface.Colors;
using Dalamud.Interface.Components; using Dalamud.Interface.Components;
using Dalamud.Interface.Utility; using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii; using Dalamud.Interface.Utility.Raii;
using Dalamud.Plugin;
using Dalamud.Plugin.Services; using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.UI.Agent; using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using ImGuiNET; using ImGuiNET;
@ -28,6 +29,7 @@ internal sealed class QuickAccessButtonsComponent
private readonly IClientState _clientState; private readonly IClientState _clientState;
private readonly ICondition _condition; private readonly ICondition _condition;
private readonly ICommandManager _commandManager; private readonly ICommandManager _commandManager;
private readonly IDalamudPluginInterface _pluginInterface;
public QuickAccessButtonsComponent( public QuickAccessButtonsComponent(
MovementController movementController, MovementController movementController,
@ -39,7 +41,8 @@ internal sealed class QuickAccessButtonsComponent
JournalProgressWindow journalProgressWindow, JournalProgressWindow journalProgressWindow,
IClientState clientState, IClientState clientState,
ICondition condition, ICondition condition,
ICommandManager commandManager) ICommandManager commandManager,
IDalamudPluginInterface pluginInterface)
{ {
_movementController = movementController; _movementController = movementController;
_gameFunctions = gameFunctions; _gameFunctions = gameFunctions;
@ -51,6 +54,7 @@ internal sealed class QuickAccessButtonsComponent
_clientState = clientState; _clientState = clientState;
_condition = condition; _condition = condition;
_commandManager = commandManager; _commandManager = commandManager;
_pluginInterface = pluginInterface;
} }
public event EventHandler? Reload; public event EventHandler? Reload;
@ -109,12 +113,14 @@ internal sealed class QuickAccessButtonsComponent
int partsToRender = errorCount == 0 || infoCount == 0 ? 1 : 2; int partsToRender = errorCount == 0 || infoCount == 0 ? 1 : 2;
using var id = ImRaii.PushId("validationissues"); using var id = ImRaii.PushId("validationissues");
ImGui.PushFont(UiBuilder.IconFont);
var icon1 = FontAwesomeIcon.TimesCircle; var icon1 = FontAwesomeIcon.TimesCircle;
var icon2 = FontAwesomeIcon.InfoCircle; var icon2 = FontAwesomeIcon.InfoCircle;
Vector2 iconSize1 = errorCount > 0 ? ImGui.CalcTextSize(icon1.ToIconString()) : Vector2.Zero; Vector2 iconSize1, iconSize2;
Vector2 iconSize2 = infoCount > 0 ? ImGui.CalcTextSize(icon2.ToIconString()) : Vector2.Zero; using (var _ = _pluginInterface.UiBuilder.IconFontFixedWidthHandle.Push())
ImGui.PopFont(); {
iconSize1 = errorCount > 0 ? ImGui.CalcTextSize(icon1.ToIconString()) : Vector2.Zero;
iconSize2 = infoCount > 0 ? ImGui.CalcTextSize(icon2.ToIconString()) : Vector2.Zero;
}
string text1 = errorCount > 0 ? errorCount.ToString(CultureInfo.InvariantCulture) : string.Empty; string text1 = errorCount > 0 ? errorCount.ToString(CultureInfo.InvariantCulture) : string.Empty;
string text2 = infoCount > 0 ? infoCount.ToString(CultureInfo.InvariantCulture) : string.Empty; string text2 = infoCount > 0 ? infoCount.ToString(CultureInfo.InvariantCulture) : string.Empty;
@ -136,9 +142,11 @@ internal sealed class QuickAccessButtonsComponent
cursor.Y + ImGui.GetStyle().FramePadding.Y); cursor.Y + ImGui.GetStyle().FramePadding.Y);
if (errorCount > 0) if (errorCount > 0)
{ {
ImGui.PushFont(UiBuilder.IconFont); using (var _ = _pluginInterface.UiBuilder.IconFontFixedWidthHandle.Push())
{
dl.AddText(position, ImGui.GetColorU32(ImGuiColors.DalamudRed), icon1.ToIconString()); dl.AddText(position, ImGui.GetColorU32(ImGuiColors.DalamudRed), icon1.ToIconString());
ImGui.PopFont(); }
position = position with { X = position.X + iconSize1.X + iconPadding }; position = position with { X = position.X + iconSize1.X + iconPadding };
// Draw the text on the window drawlist // Draw the text on the window drawlist
@ -148,9 +156,11 @@ internal sealed class QuickAccessButtonsComponent
if (infoCount > 0) if (infoCount > 0)
{ {
ImGui.PushFont(UiBuilder.IconFont); using (var _ = _pluginInterface.UiBuilder.IconFontFixedWidthHandle.Push())
{
dl.AddText(position, ImGui.GetColorU32(ImGuiColors.ParsedBlue), icon2.ToIconString()); dl.AddText(position, ImGui.GetColorU32(ImGuiColors.ParsedBlue), icon2.ToIconString());
ImGui.PopFont(); }
position = position with { X = position.X + iconSize2.X + iconPadding }; position = position with { X = position.X + iconSize2.X + iconPadding };
// Draw the text on the window drawlist // Draw the text on the window drawlist