1
0
forked from liza/Questionable

Add mini quest window

This commit is contained in:
Liza 2024-08-10 00:57:09 +02:00
parent 7dc78ed8cb
commit 6f2ca7d438
Signed by: liza
GPG Key ID: 7199F8D727D55F67
4 changed files with 130 additions and 84 deletions

View File

@ -17,7 +17,6 @@ internal sealed class CommandHandler : IDisposable
private readonly IChatGui _chatGui;
private readonly QuestController _questController;
private readonly MovementController _movementController;
private readonly QuickAccessButtonsComponent _quickAccessButtonsComponent;
private readonly QuestRegistry _questRegistry;
private readonly ConfigWindow _configWindow;
private readonly DebugOverlay _debugOverlay;
@ -31,7 +30,6 @@ internal sealed class CommandHandler : IDisposable
IChatGui chatGui,
QuestController questController,
MovementController movementController,
QuickAccessButtonsComponent quickAccessButtonsComponent,
QuestRegistry questRegistry,
ConfigWindow configWindow,
DebugOverlay debugOverlay,
@ -44,7 +42,6 @@ internal sealed class CommandHandler : IDisposable
_chatGui = chatGui;
_questController = questController;
_movementController = movementController;
_quickAccessButtonsComponent = quickAccessButtonsComponent;
_questRegistry = questRegistry;
_configWindow = configWindow;
_debugOverlay = debugOverlay;
@ -87,7 +84,7 @@ internal sealed class CommandHandler : IDisposable
break;
case "reload":
_quickAccessButtonsComponent.Reload();
_questWindow.Reload();
break;
case "do":

View File

@ -56,7 +56,9 @@ internal sealed class ActiveQuestComponent
_chatGui = chatGui;
}
public void Draw()
public event EventHandler? Reload;
public void Draw(bool isMinimized)
{
var currentQuestDetails = _questController.CurrentQuestDetails;
QuestController.QuestProgress? currentQuest = currentQuestDetails?.Progress;
@ -64,7 +66,7 @@ internal sealed class ActiveQuestComponent
if (currentQuest != null)
{
DrawQuestNames(currentQuest, currentQuestType);
var questWork = DrawQuestWork(currentQuest);
var questWork = DrawQuestWork(currentQuest, isMinimized);
if (_combatController.IsRunning)
ImGui.TextColored(ImGuiColors.DalamudOrange, "In Combat");
@ -77,6 +79,8 @@ internal sealed class ActiveQuestComponent
QuestSequence? currentSequence = currentQuest.Quest.FindSequence(currentQuest.Sequence);
QuestStep? currentStep = currentSequence?.FindStep(currentQuest.Step);
if (!isMinimized)
{
bool colored = currentStep is
{ InteractionType: EInteractionType.Instruction or EInteractionType.WaitForManualProgress };
if (colored)
@ -90,14 +94,16 @@ internal sealed class ActiveQuestComponent
//ImGui.BeginDisabled(nextStep.Step == null);
ImGui.Text(_questController.ToStatString());
//ImGui.EndDisabled();
}
DrawQuestButtons(currentQuest, currentStep, questWork);
DrawQuestButtons(currentQuest, currentStep, questWork, isMinimized);
DrawSimulationControls();
}
else
{
ImGui.Text("No active quest");
if (!isMinimized)
ImGui.TextColored(ImGuiColors.DalamudGrey, $"{_questRegistry.Count} quests loaded");
if (ImGuiComponents.IconButton(FontAwesomeIcon.Stop))
@ -157,11 +163,16 @@ internal sealed class ActiveQuestComponent
}
}
private QuestProgressInfo? DrawQuestWork(QuestController.QuestProgress currentQuest)
private QuestProgressInfo? DrawQuestWork(QuestController.QuestProgress currentQuest, bool isMinimized)
{
var questWork = _questFunctions.GetQuestProgressInfo(currentQuest.Quest.Id);
if (questWork != null)
{
if (isMinimized)
return questWork;
Vector4 color;
unsafe
{
@ -203,7 +214,7 @@ internal sealed class ActiveQuestComponent
}
private void DrawQuestButtons(QuestController.QuestProgress currentQuest, QuestStep? currentStep,
QuestProgressInfo? questProgressInfo)
QuestProgressInfo? questProgressInfo, bool isMinimized)
{
ImGui.BeginDisabled(_questController.IsRunning);
if (ImGuiComponents.IconButton(FontAwesomeIcon.Play))
@ -215,12 +226,15 @@ internal sealed class ActiveQuestComponent
_questController.ExecuteNextStep(QuestController.EAutomationType.Automatic);
}
if (!isMinimized)
{
ImGui.SameLine();
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.StepForward, "Step"))
{
_questController.ExecuteNextStep(QuestController.EAutomationType.Manual);
}
}
ImGui.EndDisabled();
ImGui.SameLine();
@ -232,6 +246,14 @@ internal sealed class ActiveQuestComponent
_gatheringController.Stop("Manual");
}
if (isMinimized)
{
ImGui.SameLine();
if (ImGuiComponents.IconButton(FontAwesomeIcon.RedoAlt))
Reload?.Invoke(this, EventArgs.Empty);
}
else
{
bool lastStep = currentStep ==
currentQuest.Quest.FindSequence(currentQuest.Sequence)?.Steps.LastOrDefault();
bool colored = currentStep != null
@ -267,6 +289,7 @@ internal sealed class ActiveQuestComponent
_pluginInterface.SavePluginConfig(_configuration);
}
}
}
private void DrawSimulationControls()
{

View File

@ -18,9 +18,7 @@ namespace Questionable.Windows.QuestComponents;
internal sealed class QuickAccessButtonsComponent
{
private readonly QuestController _questController;
private readonly MovementController _movementController;
private readonly GameUiController _gameUiController;
private readonly GameFunctions _gameFunctions;
private readonly ChatFunctions _chatFunctions;
private readonly QuestRegistry _questRegistry;
@ -29,12 +27,10 @@ internal sealed class QuickAccessButtonsComponent
private readonly JournalProgressWindow _journalProgressWindow;
private readonly IClientState _clientState;
private readonly ICondition _condition;
private readonly IFramework _framework;
private readonly ICommandManager _commandManager;
public QuickAccessButtonsComponent(QuestController questController,
public QuickAccessButtonsComponent(
MovementController movementController,
GameUiController gameUiController,
GameFunctions gameFunctions,
ChatFunctions chatFunctions,
QuestRegistry questRegistry,
@ -43,12 +39,9 @@ internal sealed class QuickAccessButtonsComponent
JournalProgressWindow journalProgressWindow,
IClientState clientState,
ICondition condition,
IFramework framework,
ICommandManager commandManager)
{
_questController = questController;
_movementController = movementController;
_gameUiController = gameUiController;
_gameFunctions = gameFunctions;
_chatFunctions = chatFunctions;
_questRegistry = questRegistry;
@ -57,10 +50,11 @@ internal sealed class QuickAccessButtonsComponent
_journalProgressWindow = journalProgressWindow;
_clientState = clientState;
_condition = condition;
_framework = framework;
_commandManager = commandManager;
}
public event EventHandler? Reload;
public unsafe void Draw()
{
var map = AgentMap.Instance();
@ -89,8 +83,8 @@ internal sealed class QuickAccessButtonsComponent
ImGui.SetTooltip("Hold CTRL to enable this button.\nRebuilding the navmesh will take some time.");
}
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.RedoAlt,"Reload Data"))
Reload();
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.RedoAlt, "Reload Data"))
Reload?.Invoke(this, EventArgs.Empty);
ImGui.SameLine();
if (ImGuiComponents.IconButton(FontAwesomeIcon.ChartColumn))
@ -105,13 +99,6 @@ internal sealed class QuickAccessButtonsComponent
}
}
public void Reload()
{
_questController.Reload();
_framework.RunOnTick(() => _gameUiController.HandleCurrentDialogueChoices(),
TimeSpan.FromMilliseconds(200));
}
private bool DrawValidationIssuesButton()
{
int errorCount = _questRegistry.ValidationErrorCount;

View File

@ -1,5 +1,6 @@
using System;
using System.Numerics;
using Dalamud.Interface;
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using ImGuiNET;
@ -24,6 +25,9 @@ internal sealed class QuestWindow : LWindow, IPersistableWindowConfig
private readonly CreationUtilsComponent _creationUtilsComponent;
private readonly QuickAccessButtonsComponent _quickAccessButtonsComponent;
private readonly RemainingTasksComponent _remainingTasksComponent;
private readonly IFramework _framework;
private readonly GameUiController _gameUiController;
private readonly TitleBarButton _minimizeButton;
public QuestWindow(IDalamudPluginInterface pluginInterface,
QuestController questController,
@ -34,8 +38,11 @@ internal sealed class QuestWindow : LWindow, IPersistableWindowConfig
ARealmRebornComponent aRealmRebornComponent,
CreationUtilsComponent creationUtilsComponent,
QuickAccessButtonsComponent quickAccessButtonsComponent,
RemainingTasksComponent remainingTasksComponent)
: base($"Questionable v{PluginVersion.ToString(2)}###Questionable", ImGuiWindowFlags.AlwaysAutoResize)
RemainingTasksComponent remainingTasksComponent,
IFramework framework,
GameUiController gameUiController)
: base($"Questionable v{PluginVersion.ToString(2)}###Questionable",
ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoCollapse)
{
_pluginInterface = pluginInterface;
_questController = questController;
@ -47,6 +54,8 @@ internal sealed class QuestWindow : LWindow, IPersistableWindowConfig
_creationUtilsComponent = creationUtilsComponent;
_quickAccessButtonsComponent = quickAccessButtonsComponent;
_remainingTasksComponent = remainingTasksComponent;
_framework = framework;
_gameUiController = gameUiController;
#if DEBUG
IsOpen = true;
@ -57,9 +66,27 @@ internal sealed class QuestWindow : LWindow, IPersistableWindowConfig
MaximumSize = default
};
RespectCloseHotkey = false;
_minimizeButton = new TitleBarButton
{
Icon = FontAwesomeIcon.Minus,
Priority = int.MinValue,
IconOffset = new Vector2(1.5f, 1),
Click = _ =>
{
IsMinimized = !IsMinimized;
_minimizeButton!.Icon = IsMinimized ? FontAwesomeIcon.WindowMaximize : FontAwesomeIcon.Minus;
},
AvailableClickthrough = true,
};
TitleBarButtons.Insert(0, _minimizeButton);
_activeQuestComponent.Reload += OnReload;
_quickAccessButtonsComponent.Reload += OnReload;
}
public WindowConfig WindowConfig => _configuration.DebugWindowConfig;
public bool IsMinimized { get; set; }
public void SaveWindowConfig() => _pluginInterface.SavePluginConfig(_configuration);
@ -82,7 +109,9 @@ internal sealed class QuestWindow : LWindow, IPersistableWindowConfig
public override void Draw()
{
_activeQuestComponent.Draw();
_activeQuestComponent.Draw(IsMinimized);
if (!IsMinimized)
{
ImGui.Separator();
if (_aRealmRebornComponent.ShouldDraw)
@ -97,4 +126,14 @@ internal sealed class QuestWindow : LWindow, IPersistableWindowConfig
_quickAccessButtonsComponent.Draw();
_remainingTasksComponent.Draw();
}
}
private void OnReload(object? sender, EventArgs e) => Reload();
internal void Reload()
{
_questController.Reload();
_framework.RunOnTick(() => _gameUiController.HandleCurrentDialogueChoices(),
TimeSpan.FromMilliseconds(200));
}
}