98 lines
3.4 KiB
C#
98 lines
3.4 KiB
C#
using System.Numerics;
|
|
using Dalamud.Bindings.ImGui;
|
|
using Dalamud.Interface;
|
|
using Dalamud.Interface.Colors;
|
|
using Dalamud.Plugin;
|
|
using FFXIVClientStructs.FFXIV.Client.Game.UI;
|
|
using Questionable.Controller;
|
|
using Questionable.Functions;
|
|
using Questionable.Model.Questing;
|
|
|
|
namespace Questionable.Windows;
|
|
|
|
internal sealed class UiUtils
|
|
{
|
|
private readonly QuestFunctions _questFunctions;
|
|
|
|
private readonly QuestRegistry _questRegistry;
|
|
|
|
private readonly IDalamudPluginInterface _pluginInterface;
|
|
|
|
public UiUtils(QuestFunctions questFunctions, QuestRegistry questRegistry, IDalamudPluginInterface pluginInterface)
|
|
{
|
|
_questFunctions = questFunctions;
|
|
_questRegistry = questRegistry;
|
|
_pluginInterface = pluginInterface;
|
|
}
|
|
|
|
public (Vector4 Color, FontAwesomeIcon Icon, string Status) GetQuestStyle(ElementId elementId)
|
|
{
|
|
if (_questFunctions.IsQuestAccepted(elementId))
|
|
{
|
|
return (Color: ImGuiColors.DalamudYellow, Icon: FontAwesomeIcon.PersonWalkingArrowRight, Status: "Active");
|
|
}
|
|
if (elementId is QuestId questId && _questFunctions.IsDailyAlliedSocietyQuestAndAvailableToday(questId))
|
|
{
|
|
if (!_questFunctions.IsReadyToAcceptQuest(questId))
|
|
{
|
|
return (Color: ImGuiColors.ParsedGreen, Icon: FontAwesomeIcon.Check, Status: "Complete");
|
|
}
|
|
if (_questFunctions.IsQuestComplete(questId))
|
|
{
|
|
return (Color: ImGuiColors.ParsedBlue, Icon: FontAwesomeIcon.Running, Status: "Available (Complete)");
|
|
}
|
|
return (Color: ImGuiColors.DalamudYellow, Icon: FontAwesomeIcon.Running, Status: "Available");
|
|
}
|
|
if (_questFunctions.IsQuestAcceptedOrComplete(elementId))
|
|
{
|
|
return (Color: ImGuiColors.ParsedGreen, Icon: FontAwesomeIcon.Check, Status: "Complete");
|
|
}
|
|
if (_questFunctions.IsQuestUnobtainable(elementId))
|
|
{
|
|
return (Color: ImGuiColors.DalamudGrey, Icon: FontAwesomeIcon.Minus, Status: "Unobtainable");
|
|
}
|
|
if (_questFunctions.IsQuestLocked(elementId) || !_questFunctions.IsReadyToAcceptQuest(elementId) || !_questRegistry.IsKnownQuest(elementId))
|
|
{
|
|
return (Color: ImGuiColors.DalamudRed, Icon: FontAwesomeIcon.Times, Status: "Locked");
|
|
}
|
|
return (Color: ImGuiColors.DalamudYellow, Icon: FontAwesomeIcon.Running, Status: "Available");
|
|
}
|
|
|
|
public static (Vector4 color, FontAwesomeIcon icon) GetInstanceStyle(ushort instanceId)
|
|
{
|
|
if (UIState.IsInstanceContentCompleted(instanceId))
|
|
{
|
|
return (color: ImGuiColors.ParsedGreen, icon: FontAwesomeIcon.Check);
|
|
}
|
|
if (UIState.IsInstanceContentUnlocked(instanceId))
|
|
{
|
|
return (color: ImGuiColors.DalamudYellow, icon: FontAwesomeIcon.Running);
|
|
}
|
|
return (color: ImGuiColors.DalamudRed, icon: FontAwesomeIcon.Times);
|
|
}
|
|
|
|
public bool ChecklistItem(string text, Vector4 color, FontAwesomeIcon icon, float extraPadding = 0f)
|
|
{
|
|
if (extraPadding > 0f)
|
|
{
|
|
ImGui.SetCursorPosX(ImGui.GetCursorPosX() + extraPadding);
|
|
}
|
|
using (_pluginInterface.UiBuilder.IconFontFixedWidthHandle.Push())
|
|
{
|
|
ImGui.TextColored(in color, icon.ToIconString());
|
|
}
|
|
bool num = ImGui.IsItemHovered();
|
|
ImGui.SameLine();
|
|
if (extraPadding > 0f)
|
|
{
|
|
ImGui.SetCursorPosX(ImGui.GetCursorPosX() + extraPadding);
|
|
}
|
|
ImGui.TextUnformatted(text);
|
|
return num | ImGui.IsItemHovered();
|
|
}
|
|
|
|
public bool ChecklistItem(string text, bool complete, Vector4? colorOverride = null)
|
|
{
|
|
return ChecklistItem(text, colorOverride ?? (complete ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudRed), complete ? FontAwesomeIcon.Check : FontAwesomeIcon.Times);
|
|
}
|
|
}
|