diff --git a/Questionable/Controller/GameUiController.cs b/Questionable/Controller/GameUiController.cs index efba25f06..bd26ba71d 100644 --- a/Questionable/Controller/GameUiController.cs +++ b/Questionable/Controller/GameUiController.cs @@ -383,8 +383,12 @@ internal sealed class GameUiController : IDisposable } var simulatedQuest = _questController.SimulatedQuest; - if (simulatedQuest != null) - HandleTravelYesNo(addonSelectYesno, simulatedQuest, actualPrompt); + if (simulatedQuest != null && HandleTravelYesNo(addonSelectYesno, simulatedQuest, actualPrompt)) + return; + + var nextQuest = _questController.NextQuest; + if (nextQuest != null) + HandleTravelYesNo(addonSelectYesno, nextQuest, actualPrompt); } private unsafe bool HandleDefaultYesNo(AddonSelectYesno* addonSelectYesno, Quest quest, diff --git a/Questionable/Controller/QuestController.cs b/Questionable/Controller/QuestController.cs index b9a011d7e..310784f77 100644 --- a/Questionable/Controller/QuestController.cs +++ b/Questionable/Controller/QuestController.cs @@ -141,12 +141,7 @@ internal sealed class QuestController { DebugState = null; - byte currentSequence = 0; - if (_simulatedQuest != null) - { - currentSequence = _simulatedQuest.Sequence; - } - else if (_nextQuest != null) + if (_simulatedQuest == null && _nextQuest != null) { // if the quest is accepted, we no longer track it bool canUseNextQuest; @@ -158,19 +153,25 @@ internal sealed class QuestController if (!canUseNextQuest) { _logger.LogInformation("Next quest {QuestId} accepted or completed", _nextQuest.Quest.QuestId); - _nextQuest = null; - currentSequence = 0; - } - else - { - currentSequence = _nextQuest.Sequence; // by definition, this should always be 0 - if (_nextQuest.Step == 0 && _currentTask == null && _taskQueue.Count == 0 && _automatic) - ExecuteNextStep(true); } } - if (_simulatedQuest == null && _nextQuest == null) + QuestProgress? questToRun; + byte currentSequence; + if (_simulatedQuest != null) + { + currentSequence = _simulatedQuest.Sequence; + questToRun = _simulatedQuest; + } + else if (_nextQuest != null && _gameFunctions.IsReadyToAcceptQuest(_nextQuest.Quest.QuestId)) + { + questToRun = _nextQuest; + currentSequence = _nextQuest.Sequence; // by definition, this should always be 0 + if (_nextQuest.Step == 0 && _currentTask == null && _taskQueue.Count == 0 && _automatic) + ExecuteNextStep(true); + } + else { (ushort currentQuestId, currentSequence) = _gameFunctions.GetCurrentQuest(); if (currentQuestId == 0) @@ -181,6 +182,8 @@ internal sealed class QuestController _startedQuest = null; Stop("Resetting current quest"); } + + questToRun = null; } else if (_startedQuest == null || _startedQuest.Quest.QuestId != currentQuestId) { @@ -205,9 +208,10 @@ internal sealed class QuestController return; } + else + questToRun = _startedQuest; } - var questToRun = CurrentQuest; if (questToRun == null) { DebugState = "No quest active"; @@ -230,7 +234,8 @@ internal sealed class QuestController if (questToRun.Sequence != currentSequence) { questToRun.SetSequence(currentSequence); - Stop("New sequence", continueIfAutomatic: true); + Stop($"New sequence {questToRun == _startedQuest}/{_gameFunctions.GetCurrentQuestInternal()}", + continueIfAutomatic: true); } var q = questToRun.Quest; @@ -316,6 +321,7 @@ internal sealed class QuestController private void ClearTasksInternal() { + _logger.LogDebug("Clearing task (internally)"); _currentTask = null; if (_taskQueue.Count > 0) @@ -626,8 +632,7 @@ internal sealed class QuestController { SetNextQuest(quest); _chatGui.Print( - "[Questionable] Picking up quest '{Name}' as a priority over current main story/side quests", - quest.Info.Name); + $"[Questionable] Picking up quest '{quest.Info.Name}' as a priority over current main story/side quests."); return true; } } diff --git a/Questionable/Controller/Steps/Shared/WaitAtEnd.cs b/Questionable/Controller/Steps/Shared/WaitAtEnd.cs index 6af28d975..16a5589bf 100644 --- a/Questionable/Controller/Steps/Shared/WaitAtEnd.cs +++ b/Questionable/Controller/Steps/Shared/WaitAtEnd.cs @@ -123,7 +123,7 @@ internal static class WaitAtEnd var complete = serviceProvider.GetRequiredService() .With(step.TurnInQuestId ?? quest.QuestId); var delay = serviceProvider.GetRequiredService(); - if (step.NextQuestId != null) + if (step.TurnInQuestId != null) return [complete, delay, Next(quest, sequence)]; else return [complete, delay]; diff --git a/Questionable/Windows/QuestComponents/ARealmRebornComponent.cs b/Questionable/Windows/QuestComponents/ARealmRebornComponent.cs index dbc880c68..a3b7e0694 100644 --- a/Questionable/Windows/QuestComponents/ARealmRebornComponent.cs +++ b/Questionable/Windows/QuestComponents/ARealmRebornComponent.cs @@ -35,12 +35,14 @@ internal sealed class ARealmRebornComponent public void Draw() { - var completedPrimals = UIState.IsInstanceContentCompleted(RequiredPrimalInstances.Last()); - bool completedRaids = _gameFunctions.IsQuestComplete(RequiredAllianceRaidQuests.Last()); - bool complete = completedPrimals && completedRaids; - bool hover = _uiUtils.ChecklistItem("ARR Primals & Raids", - complete ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudRed, - complete ? FontAwesomeIcon.Check : FontAwesomeIcon.Times); + DrawPrimals(); + DrawAllianceRaids(); + } + + private void DrawPrimals() + { + bool complete = UIState.IsInstanceContentCompleted(RequiredPrimalInstances.Last()); + bool hover = _uiUtils.ChecklistItem("Hard Mode Primals", complete); if (complete || !hover) return; @@ -48,14 +50,24 @@ internal sealed class ARealmRebornComponent if (!tooltip) return; - ImGui.Text("Primals:"); foreach (var instanceId in RequiredPrimalInstances) { (Vector4 color, FontAwesomeIcon icon) = UiUtils.GetInstanceStyle(instanceId); _uiUtils.ChecklistItem(_territoryData.GetInstanceName(instanceId) ?? "?", color, icon); } + } + + private void DrawAllianceRaids() + { + bool complete = _gameFunctions.IsQuestComplete(RequiredAllianceRaidQuests.Last()); + bool hover = _uiUtils.ChecklistItem("Crystal Tower Raids", complete); + if (complete || !hover) + return; + + using var tooltip = ImRaii.Tooltip(); + if (!tooltip) + return; - ImGui.Text("Alliance Raids:"); foreach (var questId in RequiredAllianceRaidQuests) { (Vector4 color, FontAwesomeIcon icon, _) = _uiUtils.GetQuestStyle(questId); diff --git a/Questionable/Windows/QuestComponents/ActiveQuestComponent.cs b/Questionable/Windows/QuestComponents/ActiveQuestComponent.cs index 48b9434a2..b24f45e4b 100644 --- a/Questionable/Windows/QuestComponents/ActiveQuestComponent.cs +++ b/Questionable/Windows/QuestComponents/ActiveQuestComponent.cs @@ -91,40 +91,38 @@ internal sealed class ActiveQuestComponent { if (currentQuestType == QuestController.CurrentQuestType.Simulated) { - var simulatedQuest = _questController.SimulatedQuest ?? currentQuest; using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudRed); ImGui.TextUnformatted( - $"Simulated Quest: {simulatedQuest.Quest.Info.Name} / {simulatedQuest.Sequence} / {simulatedQuest.Step}"); + $"Simulated Quest: {currentQuest.Quest.Info.Name} / {currentQuest.Sequence} / {currentQuest.Step}"); } - else if (currentQuestType == QuestController.CurrentQuestType.Next) + else { var startedQuest = _questController.StartedQuest; if (startedQuest != null) - DrawCurrentQuest(startedQuest); + { + ImGui.TextUnformatted( + $"Quest: {startedQuest.Quest.Info.Name} / {startedQuest.Sequence} / {startedQuest.Step}"); - using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudYellow); - ImGui.TextUnformatted( - $"Next Quest: {currentQuest.Quest.Info.Name} / {currentQuest.Sequence} / {currentQuest.Step}"); - } - else - DrawCurrentQuest(currentQuest); - } + if (startedQuest.Quest.Root.Disabled) + { + ImGui.SameLine(); + ImGui.TextColored(ImGuiColors.DalamudRed, "Disabled"); + } - private void DrawCurrentQuest(QuestController.QuestProgress currentQuest) - { - ImGui.TextUnformatted( - $"Quest: {currentQuest.Quest.Info.Name} / {currentQuest.Sequence} / {currentQuest.Step}"); + if (_configuration.Advanced.AdditionalStatusInformation && _questController.IsInterruptible()) + { + ImGui.SameLine(); + ImGui.TextColored(ImGuiColors.DalamudYellow, "Interruptible"); + } + } - if (currentQuest.Quest.Root.Disabled) - { - ImGui.SameLine(); - ImGui.TextColored(ImGuiColors.DalamudRed, "Disabled"); - } - - if (_configuration.Advanced.AdditionalStatusInformation && _questController.IsInterruptible()) - { - ImGui.SameLine(); - ImGui.TextColored(ImGuiColors.DalamudYellow, "Interruptible"); + var nextQuest = _questController.NextQuest; + if (nextQuest != null) + { + using var _ = ImRaii.PushColor(ImGuiCol.Text, ImGuiColors.DalamudYellow); + ImGui.TextUnformatted( + $"Next Quest: {currentQuest.Quest.Info.Name} / {currentQuest.Sequence} / {currentQuest.Step}"); + } } } diff --git a/Questionable/Windows/UiUtils.cs b/Questionable/Windows/UiUtils.cs index f64b06f1c..ff51d9631 100644 --- a/Questionable/Windows/UiUtils.cs +++ b/Questionable/Windows/UiUtils.cs @@ -54,4 +54,11 @@ internal sealed class UiUtils ImGui.TextUnformatted(text); return hover; } + + public bool ChecklistItem(string text, bool complete) + { + return ChecklistItem(text, + complete ? ImGuiColors.ParsedGreen : ImGuiColors.DalamudRed, + complete ? FontAwesomeIcon.Check : FontAwesomeIcon.Times); + } }