From 7705e34918d4e48dec707c571c0d532e2a3f5dea Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Thu, 22 Aug 2024 18:40:19 +0200 Subject: [PATCH] Include quest id + add context menu for quests in journal window --- .../QuestJournalComponent.cs | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/Questionable/Windows/JournalComponents/QuestJournalComponent.cs b/Questionable/Windows/JournalComponents/QuestJournalComponent.cs index e6688cde..9aa04a7e 100644 --- a/Questionable/Windows/JournalComponents/QuestJournalComponent.cs +++ b/Questionable/Windows/JournalComponents/QuestJournalComponent.cs @@ -12,6 +12,7 @@ using Questionable.Controller; using Questionable.Data; using Questionable.Functions; using Questionable.Model; +using Questionable.Model.Questing; using Questionable.Windows.QuestComponents; namespace Questionable.Windows.JournalComponents; @@ -28,6 +29,7 @@ internal sealed class QuestJournalComponent private readonly UiUtils _uiUtils; private readonly QuestTooltipComponent _questTooltipComponent; private readonly IDalamudPluginInterface _pluginInterface; + private readonly QuestController _questController; private readonly ICommandManager _commandManager; private List _filteredSections = []; @@ -35,7 +37,7 @@ internal sealed class QuestJournalComponent public QuestJournalComponent(JournalData journalData, QuestRegistry questRegistry, QuestFunctions questFunctions, UiUtils uiUtils, QuestTooltipComponent questTooltipComponent, IDalamudPluginInterface pluginInterface, - ICommandManager commandManager) + QuestController questController, ICommandManager commandManager) { _journalData = journalData; _questRegistry = questRegistry; @@ -43,6 +45,7 @@ internal sealed class QuestJournalComponent _uiUtils = uiUtils; _questTooltipComponent = questTooltipComponent; _pluginInterface = pluginInterface; + _questController = questController; _commandManager = commandManager; } @@ -171,19 +174,30 @@ internal sealed class QuestJournalComponent ImGui.TableNextRow(); ImGui.TableNextColumn(); - ImGui.TreeNodeEx(questInfo.Name, + ImGui.TreeNodeEx($"{questInfo.Name} ({questInfo.QuestId})", ImGuiTreeNodeFlags.Leaf | ImGuiTreeNodeFlags.NoTreePushOnOpen | ImGuiTreeNodeFlags.SpanFullWidth); - if (questInfo is QuestInfo && ImGui.IsItemClicked() && - _commandManager.Commands.TryGetValue("/questinfo", out var commandInfo)) - { - _commandManager.DispatchCommand("/questinfo", questInfo.QuestId.ToString() ?? string.Empty, commandInfo); - } - if (ImGui.IsItemHovered()) _questTooltipComponent.Draw(questInfo); + if (ImGui.BeginPopupContextItem($"##QuestPopup{questInfo.QuestId}", ImGuiPopupFlags.MouseButtonRight)) + { + if (ImGui.MenuItem("Start as next quest", _questFunctions.IsReadyToAcceptQuest(questInfo.QuestId))) + { + _questController.SetNextQuest(quest); + _questController.Start("SeasonalEventSelection"); + } + + bool openInQuestMap = _commandManager.Commands.TryGetValue("/questinfo", out var commandInfo); + if (ImGui.MenuItem("View in Quest Map", questInfo.QuestId is QuestId && openInQuestMap)) + { + _commandManager.DispatchCommand("/questinfo", questInfo.QuestId.ToString() ?? string.Empty, commandInfo!); + } + + ImGui.EndPopup(); + } + ImGui.TableNextColumn(); float spacing; // ReSharper disable once UnusedVariable