1
0
forked from liza/Questionable

Add currently visible unaccepted quest markers to /qst zone (only for unknown/not mapped quests)

This commit is contained in:
Liza 2024-07-16 11:15:28 +02:00
parent e239edb22c
commit fb9e31cd80
Signed by: liza
GPG Key ID: 7199F8D727D55F67
2 changed files with 22 additions and 21 deletions

View File

@ -1,10 +1,8 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using Dalamud.Game.ClientState.Objects; using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.Command; using Dalamud.Game.Command;
using Dalamud.Plugin.Services; using Dalamud.Plugin.Services;
using Questionable.Data;
using Questionable.Model; using Questionable.Model;
using Questionable.Windows; using Questionable.Windows;
@ -23,13 +21,11 @@ internal sealed class CommandHandler : IDisposable
private readonly QuestSelectionWindow _questSelectionWindow; private readonly QuestSelectionWindow _questSelectionWindow;
private readonly ITargetManager _targetManager; private readonly ITargetManager _targetManager;
private readonly GameFunctions _gameFunctions; private readonly GameFunctions _gameFunctions;
private readonly IClientState _clientState;
public CommandHandler(ICommandManager commandManager, IChatGui chatGui, QuestController questController, public CommandHandler(ICommandManager commandManager, IChatGui chatGui, QuestController questController,
MovementController movementController, QuestRegistry questRegistry, MovementController movementController, QuestRegistry questRegistry,
ConfigWindow configWindow, DebugOverlay debugOverlay, QuestWindow questWindow, ConfigWindow configWindow, DebugOverlay debugOverlay, QuestWindow questWindow,
QuestSelectionWindow questSelectionWindow, ITargetManager targetManager, GameFunctions gameFunctions, QuestSelectionWindow questSelectionWindow, ITargetManager targetManager, GameFunctions gameFunctions)
IClientState clientState)
{ {
_commandManager = commandManager; _commandManager = commandManager;
_chatGui = chatGui; _chatGui = chatGui;
@ -42,7 +38,6 @@ internal sealed class CommandHandler : IDisposable
_questSelectionWindow = questSelectionWindow; _questSelectionWindow = questSelectionWindow;
_targetManager = targetManager; _targetManager = targetManager;
_gameFunctions = gameFunctions; _gameFunctions = gameFunctions;
_clientState = clientState;
_commandManager.AddHandler("/qst", new CommandInfo(ProcessCommand) _commandManager.AddHandler("/qst", new CommandInfo(ProcessCommand)
{ {
@ -87,7 +82,7 @@ internal sealed class CommandHandler : IDisposable
case "z": case "z":
case "zone": case "zone":
_questSelectionWindow.OpenForZone(_clientState.TerritoryType); _questSelectionWindow.OpenForCurrentZone();
break; break;
default: default:

View File

@ -9,6 +9,7 @@ using Dalamud.Interface.Components;
using Dalamud.Interface.Utility.Raii; using Dalamud.Interface.Utility.Raii;
using Dalamud.Plugin; using Dalamud.Plugin;
using Dalamud.Plugin.Services; using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game.UI;
using FFXIVClientStructs.FFXIV.Client.UI; using FFXIVClientStructs.FFXIV.Client.UI;
using ImGuiNET; using ImGuiNET;
using LLib.GameUI; using LLib.GameUI;
@ -30,6 +31,7 @@ internal sealed class QuestSelectionWindow : LWindow
private readonly QuestRegistry _questRegistry; private readonly QuestRegistry _questRegistry;
private readonly IDalamudPluginInterface _pluginInterface; private readonly IDalamudPluginInterface _pluginInterface;
private readonly TerritoryData _territoryData; private readonly TerritoryData _territoryData;
private readonly IClientState _clientState;
private List<QuestInfo> _quests = []; private List<QuestInfo> _quests = [];
private List<QuestInfo> _offeredQuests = []; private List<QuestInfo> _offeredQuests = [];
@ -37,7 +39,7 @@ internal sealed class QuestSelectionWindow : LWindow
public QuestSelectionWindow(QuestData questData, IGameGui gameGui, IChatGui chatGui, GameFunctions gameFunctions, public QuestSelectionWindow(QuestData questData, IGameGui gameGui, IChatGui chatGui, GameFunctions gameFunctions,
QuestController questController, QuestRegistry questRegistry, IDalamudPluginInterface pluginInterface, QuestController questController, QuestRegistry questRegistry, IDalamudPluginInterface pluginInterface,
TerritoryData territoryData) TerritoryData territoryData, IClientState clientState)
: base($"Quest Selection{WindowId}") : base($"Quest Selection{WindowId}")
{ {
_questData = questData; _questData = questData;
@ -48,6 +50,7 @@ internal sealed class QuestSelectionWindow : LWindow
_questRegistry = questRegistry; _questRegistry = questRegistry;
_pluginInterface = pluginInterface; _pluginInterface = pluginInterface;
_territoryData = territoryData; _territoryData = territoryData;
_clientState = clientState;
Size = new Vector2(500, 200); Size = new Vector2(500, 200);
SizeCondition = ImGuiCond.Once; SizeCondition = ImGuiCond.Once;
@ -57,18 +60,15 @@ internal sealed class QuestSelectionWindow : LWindow
}; };
} }
public uint TargetId { get; private set; }
public string TargetName { get; private set; } = string.Empty;
public unsafe void OpenForTarget(IGameObject? gameObject) public unsafe void OpenForTarget(IGameObject? gameObject)
{ {
if (gameObject != null) if (gameObject != null)
{ {
TargetId = gameObject.DataId; var targetId = gameObject.DataId;
TargetName = gameObject.Name.ToString(); var targetName = gameObject.Name.ToString();
WindowName = $"Quests starting with {TargetName} [{TargetId}]{WindowId}"; WindowName = $"Quests starting with {targetName} [{targetId}]{WindowId}";
_quests = _questData.GetAllByIssuerDataId(TargetId); _quests = _questData.GetAllByIssuerDataId(targetId);
if (_gameGui.TryGetAddonByName<AddonSelectIconString>("SelectIconString", out var addonSelectIconString)) if (_gameGui.TryGetAddonByName<AddonSelectIconString>("SelectIconString", out var addonSelectIconString))
{ {
var answers = GameUiController.GetChoices(addonSelectIconString); var answers = GameUiController.GetChoices(addonSelectIconString);
@ -88,24 +88,30 @@ internal sealed class QuestSelectionWindow : LWindow
IsOpen = _quests.Count > 0; IsOpen = _quests.Count > 0;
} }
public void OpenForZone(ushort territoryId) public unsafe void OpenForCurrentZone()
{ {
TargetId = territoryId; var territoryId = _clientState.TerritoryType;
TargetName = _territoryData.GetNameAndId(territoryId); var territoryName = _territoryData.GetNameAndId(territoryId);
WindowName = $"Quests starting in {TargetName}{WindowId}"; WindowName = $"Quests starting in {territoryName}{WindowId}";
_quests = _questRegistry.AllQuests _quests = _questRegistry.AllQuests
.Where(x => x.FindSequence(0)?.FindStep(0)?.TerritoryId == territoryId) .Where(x => x.FindSequence(0)?.FindStep(0)?.TerritoryId == territoryId)
.Select(x => _questData.GetQuestInfo(x.QuestId)) .Select(x => _questData.GetQuestInfo(x.QuestId))
.ToList(); .ToList();
foreach (var unacceptedQuest in Map.Instance()->UnacceptedQuestMarkers)
{
ushort questId = (ushort)(unacceptedQuest.ObjectiveId & 0xFFFF);
if (_quests.All(q => q.QuestId != questId))
_quests.Add(_questData.GetQuestInfo(questId));
}
_offeredQuests = []; _offeredQuests = [];
IsOpen = true; IsOpen = true;
} }
public override void OnClose() public override void OnClose()
{ {
TargetId = default;
TargetName = string.Empty;
_quests = []; _quests = [];
_offeredQuests = []; _offeredQuests = [];
} }