forked from liza/Questionable
Add right click menu to Allied Society journal tab
This commit is contained in:
parent
312a16f85f
commit
5bf6cbfcbb
@ -262,6 +262,7 @@ public sealed class QuestionablePlugin : IDalamudPlugin
|
||||
serviceCollection.AddSingleton<QuickAccessButtonsComponent>();
|
||||
serviceCollection.AddSingleton<RemainingTasksComponent>();
|
||||
|
||||
serviceCollection.AddSingleton<QuestJournalUtils>();
|
||||
serviceCollection.AddSingleton<QuestJournalComponent>();
|
||||
serviceCollection.AddSingleton<GatheringJournalComponent>();
|
||||
serviceCollection.AddSingleton<AlliedSocietyJournalComponent>();
|
||||
|
@ -21,6 +21,7 @@ internal sealed class AlliedSocietyJournalComponent
|
||||
private readonly AlliedSocietyQuestFunctions _alliedSocietyQuestFunctions;
|
||||
private readonly QuestData _questData;
|
||||
private readonly QuestRegistry _questRegistry;
|
||||
private readonly QuestJournalUtils _questJournalUtils;
|
||||
private readonly QuestTooltipComponent _questTooltipComponent;
|
||||
private readonly UiUtils _uiUtils;
|
||||
|
||||
@ -29,6 +30,7 @@ internal sealed class AlliedSocietyJournalComponent
|
||||
AlliedSocietyQuestFunctions alliedSocietyQuestFunctions,
|
||||
QuestData questData,
|
||||
QuestRegistry questRegistry,
|
||||
QuestJournalUtils questJournalUtils,
|
||||
QuestTooltipComponent questTooltipComponent,
|
||||
UiUtils uiUtils)
|
||||
{
|
||||
@ -36,6 +38,7 @@ internal sealed class AlliedSocietyJournalComponent
|
||||
_alliedSocietyQuestFunctions = alliedSocietyQuestFunctions;
|
||||
_questData = questData;
|
||||
_questRegistry = questRegistry;
|
||||
_questJournalUtils = questJournalUtils;
|
||||
_questTooltipComponent = questTooltipComponent;
|
||||
_uiUtils = uiUtils;
|
||||
}
|
||||
@ -85,13 +88,15 @@ internal sealed class AlliedSocietyJournalComponent
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawQuest(QuestInfo quest)
|
||||
private void DrawQuest(QuestInfo questInfo)
|
||||
{
|
||||
var (color, icon, tooltipText) = _uiUtils.GetQuestStyle(quest.QuestId);
|
||||
if (!_questRegistry.IsKnownQuest(quest.QuestId))
|
||||
var (color, icon, tooltipText) = _uiUtils.GetQuestStyle(questInfo.QuestId);
|
||||
if (!_questRegistry.TryGetQuest(questInfo.QuestId, out var quest))
|
||||
color = ImGuiColors.DalamudGrey;
|
||||
|
||||
if (_uiUtils.ChecklistItem($"{quest.Name} ({tooltipText})", color, icon))
|
||||
_questTooltipComponent.Draw(quest);
|
||||
if (_uiUtils.ChecklistItem($"{questInfo.Name} ({tooltipText})", color, icon))
|
||||
_questTooltipComponent.Draw(questInfo);
|
||||
|
||||
_questJournalUtils.ShowContextMenu(questInfo, quest, nameof(AlliedSocietyJournalComponent));
|
||||
}
|
||||
}
|
||||
|
@ -30,8 +30,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 readonly QuestJournalUtils _questJournalUtils;
|
||||
private readonly QuestValidator _questValidator;
|
||||
|
||||
private List<FilteredSection> _filteredSections = [];
|
||||
@ -39,7 +38,7 @@ internal sealed class QuestJournalComponent
|
||||
|
||||
public QuestJournalComponent(JournalData journalData, QuestRegistry questRegistry, QuestFunctions questFunctions,
|
||||
UiUtils uiUtils, QuestTooltipComponent questTooltipComponent, IDalamudPluginInterface pluginInterface,
|
||||
QuestController questController, ICommandManager commandManager, QuestValidator questValidator)
|
||||
QuestJournalUtils questJournalUtils, QuestValidator questValidator)
|
||||
{
|
||||
_journalData = journalData;
|
||||
_questRegistry = questRegistry;
|
||||
@ -47,8 +46,7 @@ internal sealed class QuestJournalComponent
|
||||
_uiUtils = uiUtils;
|
||||
_questTooltipComponent = questTooltipComponent;
|
||||
_pluginInterface = pluginInterface;
|
||||
_questController = questController;
|
||||
_commandManager = commandManager;
|
||||
_questJournalUtils = questJournalUtils;
|
||||
_questValidator = questValidator;
|
||||
}
|
||||
|
||||
@ -184,23 +182,7 @@ internal sealed class QuestJournalComponent
|
||||
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();
|
||||
}
|
||||
_questJournalUtils.ShowContextMenu(questInfo, quest, nameof(QuestJournalComponent));
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
float spacing;
|
||||
|
44
Questionable/Windows/JournalComponents/QuestJournalUtils.cs
Normal file
44
Questionable/Windows/JournalComponents/QuestJournalUtils.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using Dalamud.Interface.Utility.Raii;
|
||||
using Dalamud.Plugin.Services;
|
||||
using ImGuiNET;
|
||||
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)
|
||||
{
|
||||
using var popup = ImRaii.ContextPopup($"##QuestPopup{questInfo.QuestId}", ImGuiPopupFlags.MouseButtonRight);
|
||||
if (!popup)
|
||||
return;
|
||||
|
||||
if (ImGui.MenuItem("Start as next quest", _questFunctions.IsReadyToAcceptQuest(questInfo.QuestId)))
|
||||
{
|
||||
_questController.SetNextQuest(quest);
|
||||
_questController.Start(label);
|
||||
}
|
||||
|
||||
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!);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user