Include quest id + add context menu for quests in journal window
authorLiza Carvelli <liza@carvel.li>
Thu, 22 Aug 2024 16:40:19 +0000 (18:40 +0200)
committerLiza Carvelli <liza@carvel.li>
Thu, 22 Aug 2024 16:40:19 +0000 (18:40 +0200)
Questionable/Windows/JournalComponents/QuestJournalComponent.cs

index e6688cdee0d4960c05f60505a41e0ee284636934..9aa04a7e669c73277f92f9c4b61d5395c16070fb 100644 (file)
@@ -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<FilteredSection> _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