diff --git a/QuestPaths/Endwalker/MSQ/B-Garlemald/4385_How the Mighty Are Fallen.json b/QuestPaths/Endwalker/MSQ/B-Garlemald/4385_How the Mighty Are Fallen.json index 94d98301a..aa95cdb21 100644 --- a/QuestPaths/Endwalker/MSQ/B-Garlemald/4385_How the Mighty Are Fallen.json +++ b/QuestPaths/Endwalker/MSQ/B-Garlemald/4385_How the Mighty Are Fallen.json @@ -285,8 +285,7 @@ }, "TerritoryId": 958, "InteractionType": "Interact", - "Mount": false, - "Comment": "TODO Should cancel Navmesh on fade out" + "Mount": false } ] }, diff --git a/Questionable/Configuration.cs b/Questionable/Configuration.cs index 7dc415b91..eaef49365 100644 --- a/Questionable/Configuration.cs +++ b/Questionable/Configuration.cs @@ -21,6 +21,7 @@ internal sealed class Configuration : IPluginConfiguration internal sealed class AdvancedConfiguration { + public bool DebugOverlay { get; set; } public bool NeverFly { get; set; } } } diff --git a/Questionable/DalamudInitializer.cs b/Questionable/DalamudInitializer.cs index 192a9ba92..e13709642 100644 --- a/Questionable/DalamudInitializer.cs +++ b/Questionable/DalamudInitializer.cs @@ -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(); diff --git a/Questionable/QuestionablePlugin.cs b/Questionable/QuestionablePlugin.cs index 4046b3bbf..a4f2f9b22 100644 --- a/Questionable/QuestionablePlugin.cs +++ b/Questionable/QuestionablePlugin.cs @@ -80,6 +80,7 @@ public sealed class QuestionablePlugin : IDalamudPlugin serviceCollection.AddTaskWithFactory(); serviceCollection.AddTaskWithFactory(); serviceCollection.AddTaskWithFactory(); + serviceCollection.AddTaskWithFactory(); serviceCollection.AddTaskWithFactory(); serviceCollection.AddTransient(); @@ -109,13 +110,14 @@ public sealed class QuestionablePlugin : IDalamudPlugin serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); - serviceCollection.AddSingleton(); + serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); + serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); _serviceProvider = serviceCollection.BuildServiceProvider(); _serviceProvider.GetRequiredService().Reload(); - _serviceProvider.GetRequiredService(); + _serviceProvider.GetRequiredService(); _serviceProvider.GetRequiredService(); } diff --git a/Questionable/Windows/ConfigWindow.cs b/Questionable/Windows/ConfigWindow.cs index 3a3ce0833..b820e7e59 100644 --- a/Questionable/Windows/ConfigWindow.cs +++ b/Questionable/Windows/ConfigWindow.cs @@ -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)) { diff --git a/Questionable/Windows/DebugOverlay.cs b/Questionable/Windows/DebugOverlay.cs new file mode 100644 index 000000000..191a7d5cf --- /dev/null +++ b/Questionable/Windows/DebugOverlay.cs @@ -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}"); + } + } +} diff --git a/Questionable/Windows/DebugWindow.cs b/Questionable/Windows/QuestWindow.cs similarity index 97% rename from Questionable/Windows/DebugWindow.cs rename to Questionable/Windows/QuestWindow.cs index 7cc3f977e..11672649e 100644 --- a/Questionable/Windows/DebugWindow.cs +++ b/Questionable/Windows/QuestWindow.cs @@ -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 _logger; + private readonly ILogger _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 logger) - : base("Questionable", ImGuiWindowFlags.AlwaysAutoResize) + ILogger logger) + : base("Questionable###Questionable", ImGuiWindowFlags.AlwaysAutoResize) { _pluginInterface = pluginInterface; _movementController = movementController;