1
0
forked from liza/Questionable

Add /qst reload

This commit is contained in:
Liza 2024-07-22 10:09:23 +02:00
parent 39f698242d
commit 325b529337
Signed by: liza
GPG Key ID: 7199F8D727D55F67
3 changed files with 43 additions and 12 deletions

View File

@ -5,6 +5,7 @@ using Dalamud.Game.Command;
using Dalamud.Plugin.Services; using Dalamud.Plugin.Services;
using Questionable.Model; using Questionable.Model;
using Questionable.Windows; using Questionable.Windows;
using Questionable.Windows.QuestComponents;
namespace Questionable.Controller; namespace Questionable.Controller;
@ -14,6 +15,7 @@ internal sealed class CommandHandler : IDisposable
private readonly IChatGui _chatGui; private readonly IChatGui _chatGui;
private readonly QuestController _questController; private readonly QuestController _questController;
private readonly MovementController _movementController; private readonly MovementController _movementController;
private readonly QuickAccessButtonsComponent _quickAccessButtonsComponent;
private readonly QuestRegistry _questRegistry; private readonly QuestRegistry _questRegistry;
private readonly ConfigWindow _configWindow; private readonly ConfigWindow _configWindow;
private readonly DebugOverlay _debugOverlay; private readonly DebugOverlay _debugOverlay;
@ -22,15 +24,25 @@ internal sealed class CommandHandler : IDisposable
private readonly ITargetManager _targetManager; private readonly ITargetManager _targetManager;
private readonly GameFunctions _gameFunctions; private readonly GameFunctions _gameFunctions;
public CommandHandler(ICommandManager commandManager, IChatGui chatGui, QuestController questController, public CommandHandler(
MovementController movementController, QuestRegistry questRegistry, ICommandManager commandManager,
ConfigWindow configWindow, DebugOverlay debugOverlay, QuestWindow questWindow, IChatGui chatGui,
QuestSelectionWindow questSelectionWindow, ITargetManager targetManager, GameFunctions gameFunctions) QuestController questController,
MovementController movementController,
QuickAccessButtonsComponent quickAccessButtonsComponent,
QuestRegistry questRegistry,
ConfigWindow configWindow,
DebugOverlay debugOverlay,
QuestWindow questWindow,
QuestSelectionWindow questSelectionWindow,
ITargetManager targetManager,
GameFunctions gameFunctions)
{ {
_commandManager = commandManager; _commandManager = commandManager;
_chatGui = chatGui; _chatGui = chatGui;
_questController = questController; _questController = questController;
_movementController = movementController; _movementController = movementController;
_quickAccessButtonsComponent = quickAccessButtonsComponent;
_questRegistry = questRegistry; _questRegistry = questRegistry;
_configWindow = configWindow; _configWindow = configWindow;
_debugOverlay = debugOverlay; _debugOverlay = debugOverlay;
@ -41,7 +53,14 @@ internal sealed class CommandHandler : IDisposable
_commandManager.AddHandler("/qst", new CommandInfo(ProcessCommand) _commandManager.AddHandler("/qst", new CommandInfo(ProcessCommand)
{ {
HelpMessage = "Opens the Questing window" HelpMessage = string.Join($"{Environment.NewLine}\t",
"Opens the Questing window",
"/qst config - opens the configuration window",
"/qst start - starts doing quests",
"/qst stop - stops doing quests",
"/qst reload - reload all quest data",
"/qst which - shows all quests starting with your selected target",
"/qst zone - shows all quests starting in the current zone (only includes quests with a known quest path, and currently visible unaccepted quests)")
}); });
} }
@ -56,6 +75,7 @@ internal sealed class CommandHandler : IDisposable
break; break;
case "start": case "start":
_questWindow.IsOpen = true;
_questController.ExecuteNextStep(true); _questController.ExecuteNextStep(true);
break; break;
@ -64,6 +84,10 @@ internal sealed class CommandHandler : IDisposable
_questController.Stop("Stop command"); _questController.Stop("Stop command");
break; break;
case "reload":
_quickAccessButtonsComponent.Reload();
break;
case "do": case "do":
ConfigureDebugOverlay(parts.Skip(1).ToArray()); ConfigureDebugOverlay(parts.Skip(1).ToArray());
break; break;
@ -85,9 +109,13 @@ internal sealed class CommandHandler : IDisposable
_questSelectionWindow.OpenForCurrentZone(); _questSelectionWindow.OpenForCurrentZone();
break; break;
default: case "":
_questWindow.Toggle(); _questWindow.Toggle();
break; break;
default:
_chatGui.PrintError($"Unknown subcommand {parts[0]}", "Questionable");
break;
} }
} }

View File

@ -321,7 +321,7 @@ internal sealed class QuestController
private void ClearTasksInternal() private void ClearTasksInternal()
{ {
_logger.LogDebug("Clearing task (internally)"); //_logger.LogDebug("Clearing task (internally)");
_currentTask = null; _currentTask = null;
if (_taskQueue.Count > 0) if (_taskQueue.Count > 0)

View File

@ -73,11 +73,7 @@ internal sealed class QuickAccessButtonsComponent
ImGui.EndDisabled(); ImGui.EndDisabled();
if (ImGui.Button("Reload Data")) if (ImGui.Button("Reload Data"))
{ Reload();
_questController.Reload();
_framework.RunOnTick(() => _gameUiController.HandleCurrentDialogueChoices(),
TimeSpan.FromMilliseconds(200));
}
if (_questRegistry.ValidationIssueCount > 0) if (_questRegistry.ValidationIssueCount > 0)
{ {
@ -87,6 +83,13 @@ internal sealed class QuickAccessButtonsComponent
} }
} }
public void Reload()
{
_questController.Reload();
_framework.RunOnTick(() => _gameUiController.HandleCurrentDialogueChoices(),
TimeSpan.FromMilliseconds(200));
}
private bool DrawValidationIssuesButton() private bool DrawValidationIssuesButton()
{ {
int errorCount = _questRegistry.ValidationErrorCount; int errorCount = _questRegistry.ValidationErrorCount;