76 lines
2.2 KiB
C#
76 lines
2.2 KiB
C#
using Dalamud.Bindings.ImGui;
|
|
using Dalamud.Interface;
|
|
using Dalamud.Interface.Components;
|
|
using Dalamud.Interface.Utility.Raii;
|
|
using Dalamud.Plugin.Services;
|
|
using Questionable.Controller;
|
|
using Questionable.Functions;
|
|
using Questionable.Model;
|
|
using Questionable.Model.Questing;
|
|
|
|
namespace Questionable.Windows.JournalComponents;
|
|
|
|
internal sealed class QuestJournalUtils
|
|
{
|
|
private readonly QuestController _questController;
|
|
|
|
private readonly QuestFunctions _questFunctions;
|
|
|
|
private readonly ICommandManager _commandManager;
|
|
|
|
public QuestJournalUtils(QuestController questController, QuestFunctions questFunctions, ICommandManager commandManager)
|
|
{
|
|
_questController = questController;
|
|
_questFunctions = questFunctions;
|
|
_commandManager = commandManager;
|
|
}
|
|
|
|
public void ShowContextMenu(IQuestInfo questInfo, Quest? quest, string label)
|
|
{
|
|
ImU8String strId;
|
|
if (ImGui.IsItemClicked(ImGuiMouseButton.Right))
|
|
{
|
|
strId = new ImU8String(12, 1);
|
|
strId.AppendLiteral("##QuestPopup");
|
|
strId.AppendFormatted(questInfo.QuestId);
|
|
ImGui.OpenPopup(strId);
|
|
}
|
|
strId = new ImU8String(12, 1);
|
|
strId.AppendLiteral("##QuestPopup");
|
|
strId.AppendFormatted(questInfo.QuestId);
|
|
using ImRaii.IEndObject endObject = ImRaii.Popup(strId);
|
|
if (!endObject)
|
|
{
|
|
return;
|
|
}
|
|
using (ImRaii.Disabled(!_questFunctions.IsReadyToAcceptQuest(questInfo.QuestId)))
|
|
{
|
|
if (ImGui.MenuItem("Start as next quest"))
|
|
{
|
|
_questController.SetNextQuest(quest);
|
|
_questController.Start(label);
|
|
}
|
|
}
|
|
bool flag = _commandManager.Commands.ContainsKey("/questinfo");
|
|
using (ImRaii.Disabled(!(questInfo.QuestId is QuestId) || !flag))
|
|
{
|
|
if (ImGui.MenuItem("View in Quest Map"))
|
|
{
|
|
_commandManager.ProcessCommand($"/questinfo {questInfo.QuestId}");
|
|
}
|
|
}
|
|
}
|
|
|
|
internal static void ShowFilterContextMenu(QuestJournalComponent journalUi)
|
|
{
|
|
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Filter, "Filter"))
|
|
{
|
|
ImGui.OpenPopup("##QuestFilters");
|
|
}
|
|
using ImRaii.IEndObject endObject = ImRaii.Popup("##QuestFilters");
|
|
if (!(!endObject) && (ImGui.Checkbox("Show only Available Quests", ref journalUi.Filter.AvailableOnly) || ImGui.Checkbox("Hide Quests Without Path", ref journalUi.Filter.HideNoPaths)))
|
|
{
|
|
journalUi.UpdateFilter();
|
|
}
|
|
}
|
|
}
|