2024-06-18 17:51:23 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Numerics;
|
|
|
|
|
using Dalamud.Interface.Utility;
|
|
|
|
|
using Dalamud.Interface.Windowing;
|
|
|
|
|
using Dalamud.Plugin.Services;
|
|
|
|
|
using ImGuiNET;
|
|
|
|
|
using Questionable.Controller;
|
2024-07-08 20:46:01 +02:00
|
|
|
|
using Questionable.Model;
|
2024-06-18 17:51:23 +02:00
|
|
|
|
using Questionable.Model.V1;
|
|
|
|
|
|
|
|
|
|
namespace Questionable.Windows;
|
|
|
|
|
|
|
|
|
|
internal sealed class DebugOverlay : Window
|
|
|
|
|
{
|
|
|
|
|
private readonly QuestController _questController;
|
2024-07-08 20:46:01 +02:00
|
|
|
|
private readonly QuestRegistry _questRegistry;
|
2024-06-18 17:51:23 +02:00
|
|
|
|
private readonly IGameGui _gameGui;
|
2024-06-19 09:45:43 +02:00
|
|
|
|
private readonly IClientState _clientState;
|
2024-06-18 17:51:23 +02:00
|
|
|
|
private readonly Configuration _configuration;
|
|
|
|
|
|
2024-07-08 20:46:01 +02:00
|
|
|
|
public DebugOverlay(QuestController questController, QuestRegistry questRegistry, IGameGui gameGui,
|
|
|
|
|
IClientState clientState, Configuration configuration)
|
2024-06-18 17:51:23 +02:00
|
|
|
|
: base("Questionable Debug Overlay###QuestionableDebugOverlay",
|
|
|
|
|
ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoBackground |
|
|
|
|
|
ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoSavedSettings, true)
|
|
|
|
|
{
|
|
|
|
|
_questController = questController;
|
2024-07-08 20:46:01 +02:00
|
|
|
|
_questRegistry = questRegistry;
|
2024-06-18 17:51:23 +02:00
|
|
|
|
_gameGui = gameGui;
|
2024-06-19 09:45:43 +02:00
|
|
|
|
_clientState = clientState;
|
2024-06-18 17:51:23 +02:00
|
|
|
|
_configuration = configuration;
|
|
|
|
|
|
|
|
|
|
Position = Vector2.Zero;
|
|
|
|
|
PositionCondition = ImGuiCond.Always;
|
|
|
|
|
Size = ImGui.GetIO().DisplaySize;
|
|
|
|
|
SizeCondition = ImGuiCond.Always;
|
|
|
|
|
IsOpen = true;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-08 20:46:01 +02:00
|
|
|
|
public ushort? HighlightedQuest { get; set; }
|
|
|
|
|
|
2024-07-12 21:18:53 +02:00
|
|
|
|
public override bool DrawConditions()
|
|
|
|
|
{
|
|
|
|
|
return _configuration.Advanced.DebugOverlay && _clientState is
|
|
|
|
|
{ IsLoggedIn: true, LocalPlayer: not null, IsPvPExcludingDen: false };
|
|
|
|
|
}
|
2024-06-18 17:51:23 +02:00
|
|
|
|
|
|
|
|
|
public override void PreDraw()
|
|
|
|
|
{
|
|
|
|
|
Size = ImGui.GetIO().DisplaySize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Draw()
|
2024-07-08 20:46:01 +02:00
|
|
|
|
{
|
|
|
|
|
DrawCurrentQuest();
|
|
|
|
|
DrawHighlightedQuest();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DrawCurrentQuest()
|
2024-06-18 17:51:23 +02:00
|
|
|
|
{
|
|
|
|
|
var currentQuest = _questController.CurrentQuest;
|
|
|
|
|
if (currentQuest == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var sequence = currentQuest.Quest.FindSequence(currentQuest.Sequence);
|
|
|
|
|
if (sequence == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (int i = currentQuest.Step; i <= sequence.Steps.Count; ++i)
|
|
|
|
|
{
|
|
|
|
|
QuestStep? step = sequence.FindStep(i);
|
2024-07-08 20:46:01 +02:00
|
|
|
|
DrawStep(i.ToString(CultureInfo.InvariantCulture), step);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DrawHighlightedQuest()
|
|
|
|
|
{
|
|
|
|
|
if (HighlightedQuest == null || !_questRegistry.TryGetQuest(HighlightedQuest.Value, out var quest))
|
|
|
|
|
return;
|
|
|
|
|
|
2024-07-11 02:56:42 +02:00
|
|
|
|
foreach (var sequence in quest.Root.QuestSequence)
|
2024-07-08 20:46:01 +02:00
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < sequence.Steps.Count; ++i)
|
|
|
|
|
{
|
|
|
|
|
QuestStep? step = sequence.FindStep(i);
|
|
|
|
|
DrawStep($"{quest.QuestId} / {sequence.Sequence} / {i}", step, 0xFFFFFFFF);
|
|
|
|
|
}
|
2024-06-18 17:51:23 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-08 20:46:01 +02:00
|
|
|
|
|
|
|
|
|
private void DrawStep(string counter, QuestStep? step, uint color = 0xFF0000FF)
|
|
|
|
|
{
|
|
|
|
|
if (step == null ||
|
|
|
|
|
step.Position == null ||
|
|
|
|
|
step.Disabled ||
|
|
|
|
|
step.TerritoryId != _clientState.TerritoryType)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
bool visible = _gameGui.WorldToScreen(step.Position.Value, out Vector2 screenPos);
|
|
|
|
|
if (!visible)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
ImGui.GetWindowDrawList().AddCircleFilled(screenPos, 3f, color);
|
|
|
|
|
ImGui.GetWindowDrawList().AddText(screenPos + new Vector2(10, -8), color,
|
2024-07-12 02:42:37 +02:00
|
|
|
|
$"{counter}: {step.InteractionType}\n{step.Position.Value.ToString("G", CultureInfo.InvariantCulture)} [{(step.Position.Value - _clientState.LocalPlayer!.Position).Length():N2}]\n{step.Comment}");
|
2024-07-08 20:46:01 +02:00
|
|
|
|
}
|
2024-06-18 17:51:23 +02:00
|
|
|
|
}
|