forked from liza/Questionable
Add minimal debug overlay
This commit is contained in:
parent
7dff411947
commit
2f73fd64fb
@ -285,8 +285,7 @@
|
||||
},
|
||||
"TerritoryId": 958,
|
||||
"InteractionType": "Interact",
|
||||
"Mount": false,
|
||||
"Comment": "TODO Should cancel Navmesh on fade out"
|
||||
"Mount": false
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -21,6 +21,7 @@ internal sealed class Configuration : IPluginConfiguration
|
||||
|
||||
internal sealed class AdvancedConfiguration
|
||||
{
|
||||
public bool DebugOverlay { get; set; }
|
||||
public bool NeverFly { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -17,13 +17,13 @@ internal sealed class DalamudInitializer : IDisposable
|
||||
private readonly MovementController _movementController;
|
||||
private readonly NavigationShortcutController _navigationShortcutController;
|
||||
private readonly WindowSystem _windowSystem;
|
||||
private readonly DebugWindow _debugWindow;
|
||||
private readonly QuestWindow _questWindow;
|
||||
private readonly ConfigWindow _configWindow;
|
||||
|
||||
public DalamudInitializer(DalamudPluginInterface pluginInterface, IFramework framework,
|
||||
ICommandManager commandManager, QuestController questController, MovementController movementController,
|
||||
GameUiController gameUiController, NavigationShortcutController navigationShortcutController,
|
||||
WindowSystem windowSystem, DebugWindow debugWindow, ConfigWindow configWindow)
|
||||
WindowSystem windowSystem, QuestWindow questWindow, DebugOverlay debugOverlay, ConfigWindow configWindow)
|
||||
{
|
||||
_pluginInterface = pluginInterface;
|
||||
_framework = framework;
|
||||
@ -32,14 +32,15 @@ internal sealed class DalamudInitializer : IDisposable
|
||||
_movementController = movementController;
|
||||
_navigationShortcutController = navigationShortcutController;
|
||||
_windowSystem = windowSystem;
|
||||
_debugWindow = debugWindow;
|
||||
_questWindow = questWindow;
|
||||
_configWindow = configWindow;
|
||||
|
||||
_windowSystem.AddWindow(debugWindow);
|
||||
_windowSystem.AddWindow(questWindow);
|
||||
_windowSystem.AddWindow(configWindow);
|
||||
_windowSystem.AddWindow(debugOverlay);
|
||||
|
||||
_pluginInterface.UiBuilder.Draw += _windowSystem.Draw;
|
||||
_pluginInterface.UiBuilder.OpenMainUi += _debugWindow.Toggle;
|
||||
_pluginInterface.UiBuilder.OpenMainUi += _questWindow.Toggle;
|
||||
_pluginInterface.UiBuilder.OpenConfigUi += _configWindow.Toggle;
|
||||
_framework.Update += FrameworkUpdate;
|
||||
_commandManager.AddHandler("/qst", new CommandInfo(ProcessCommand)
|
||||
@ -70,14 +71,14 @@ internal sealed class DalamudInitializer : IDisposable
|
||||
if (arguments is "c" or "config")
|
||||
_configWindow.Toggle();
|
||||
else
|
||||
_debugWindow.Toggle();
|
||||
_questWindow.Toggle();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_commandManager.RemoveHandler("/qst");
|
||||
_framework.Update -= FrameworkUpdate;
|
||||
_pluginInterface.UiBuilder.OpenMainUi -= _debugWindow.Toggle;
|
||||
_pluginInterface.UiBuilder.OpenMainUi -= _questWindow.Toggle;
|
||||
_pluginInterface.UiBuilder.Draw -= _windowSystem.Draw;
|
||||
|
||||
_windowSystem.RemoveAllWindows();
|
||||
|
@ -80,6 +80,7 @@ public sealed class QuestionablePlugin : IDalamudPlugin
|
||||
serviceCollection.AddTaskWithFactory<AetheryteShortcut.Factory, AetheryteShortcut.UseAetheryteShortcut>();
|
||||
serviceCollection.AddTaskWithFactory<SkipCondition.Factory, SkipCondition.CheckTask>();
|
||||
serviceCollection.AddTaskWithFactory<AethernetShortcut.Factory, AethernetShortcut.UseAethernetShortcut>();
|
||||
serviceCollection.AddTaskWithFactory<WaitAtStart.Factory, WaitAtStart.WaitDelay>();
|
||||
serviceCollection.AddTaskWithFactory<Move.Factory, Move.MoveInternal, Move.ExpectToBeNearDataId>();
|
||||
serviceCollection.AddTransient<Move.MoveBuilder>();
|
||||
|
||||
@ -109,13 +110,14 @@ public sealed class QuestionablePlugin : IDalamudPlugin
|
||||
serviceCollection.AddSingleton<GameUiController>();
|
||||
serviceCollection.AddSingleton<NavigationShortcutController>();
|
||||
|
||||
serviceCollection.AddSingleton<DebugWindow>();
|
||||
serviceCollection.AddSingleton<QuestWindow>();
|
||||
serviceCollection.AddSingleton<ConfigWindow>();
|
||||
serviceCollection.AddSingleton<DebugOverlay>();
|
||||
serviceCollection.AddSingleton<DalamudInitializer>();
|
||||
|
||||
_serviceProvider = serviceCollection.BuildServiceProvider();
|
||||
_serviceProvider.GetRequiredService<QuestRegistry>().Reload();
|
||||
_serviceProvider.GetRequiredService<DebugWindow>();
|
||||
_serviceProvider.GetRequiredService<QuestWindow>();
|
||||
_serviceProvider.GetRequiredService<DalamudInitializer>();
|
||||
}
|
||||
|
||||
|
@ -79,6 +79,13 @@ internal sealed class ConfigWindow : LWindow, IPersistableWindowConfig
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
bool debugOverlay = _configuration.Advanced.DebugOverlay;
|
||||
if (ImGui.Checkbox("Enable debug overlay", ref debugOverlay))
|
||||
{
|
||||
_configuration.Advanced.DebugOverlay = debugOverlay;
|
||||
Save();
|
||||
}
|
||||
|
||||
bool neverFly = _configuration.Advanced.NeverFly;
|
||||
if (ImGui.Checkbox("Disable flying (even if unlocked for the zone)", ref neverFly))
|
||||
{
|
||||
|
68
Questionable/Windows/DebugOverlay.cs
Normal file
68
Questionable/Windows/DebugOverlay.cs
Normal file
@ -0,0 +1,68 @@
|
||||
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;
|
||||
using Questionable.Model.V1;
|
||||
|
||||
namespace Questionable.Windows;
|
||||
|
||||
internal sealed class DebugOverlay : Window
|
||||
{
|
||||
private readonly QuestController _questController;
|
||||
private readonly IGameGui _gameGui;
|
||||
private readonly Configuration _configuration;
|
||||
|
||||
public DebugOverlay(QuestController questController, IGameGui gameGui, Configuration configuration)
|
||||
: base("Questionable Debug Overlay###QuestionableDebugOverlay",
|
||||
ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoBackground |
|
||||
ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoSavedSettings, true)
|
||||
{
|
||||
_questController = questController;
|
||||
_gameGui = gameGui;
|
||||
_configuration = configuration;
|
||||
|
||||
Position = Vector2.Zero;
|
||||
PositionCondition = ImGuiCond.Always;
|
||||
Size = ImGui.GetIO().DisplaySize;
|
||||
SizeCondition = ImGuiCond.Always;
|
||||
IsOpen = true;
|
||||
}
|
||||
|
||||
public override bool DrawConditions() => _configuration.Advanced.DebugOverlay;
|
||||
|
||||
public override void PreDraw()
|
||||
{
|
||||
Size = ImGui.GetIO().DisplaySize;
|
||||
}
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
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);
|
||||
if (step == null || step.Position == null)
|
||||
continue;
|
||||
|
||||
bool visible = _gameGui.WorldToScreen(step.Position.Value, out Vector2 screenPos);
|
||||
if (!visible)
|
||||
continue;
|
||||
|
||||
ImGui.GetWindowDrawList().AddCircleFilled(screenPos, 3f, 0xFF0000FF);
|
||||
ImGui.GetWindowDrawList().AddText(screenPos + new Vector2(10, -8), 0xFF0000FF,
|
||||
$"{i}: {step.InteractionType}\n{step.Position.Value.ToString("G", CultureInfo.InvariantCulture)}\n{step.Comment}");
|
||||
}
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ using Questionable.Model.V1;
|
||||
|
||||
namespace Questionable.Windows;
|
||||
|
||||
internal sealed class DebugWindow : LWindow, IPersistableWindowConfig
|
||||
internal sealed class QuestWindow : LWindow, IPersistableWindowConfig
|
||||
{
|
||||
private readonly DalamudPluginInterface _pluginInterface;
|
||||
private readonly MovementController _movementController;
|
||||
@ -36,9 +36,9 @@ internal sealed class DebugWindow : LWindow, IPersistableWindowConfig
|
||||
private readonly GameUiController _gameUiController;
|
||||
private readonly Configuration _configuration;
|
||||
private readonly NavmeshIpc _navmeshIpc;
|
||||
private readonly ILogger<DebugWindow> _logger;
|
||||
private readonly ILogger<QuestWindow> _logger;
|
||||
|
||||
public DebugWindow(DalamudPluginInterface pluginInterface,
|
||||
public QuestWindow(DalamudPluginInterface pluginInterface,
|
||||
MovementController movementController,
|
||||
QuestController questController,
|
||||
GameFunctions gameFunctions,
|
||||
@ -48,8 +48,8 @@ internal sealed class DebugWindow : LWindow, IPersistableWindowConfig
|
||||
GameUiController gameUiController,
|
||||
Configuration configuration,
|
||||
NavmeshIpc navmeshIpc,
|
||||
ILogger<DebugWindow> logger)
|
||||
: base("Questionable", ImGuiWindowFlags.AlwaysAutoResize)
|
||||
ILogger<QuestWindow> logger)
|
||||
: base("Questionable###Questionable", ImGuiWindowFlags.AlwaysAutoResize)
|
||||
{
|
||||
_pluginInterface = pluginInterface;
|
||||
_movementController = movementController;
|
Loading…
Reference in New Issue
Block a user