From 53c49d6718d504938b8f838a0e32eb57926a92e5 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Mon, 12 Aug 2024 16:22:24 +0200 Subject: [PATCH] Hide 'cannot execute at this time' toasts when navmesh diving and moving upwards --- Questionable/Controller/QuestController.cs | 12 ++++++++--- Questionable/Controller/Steps/IToastAware.cs | 2 +- .../Steps/Interactions/EquipItem.cs | 4 +++- Questionable/Controller/Steps/Shared/Move.cs | 21 +++++++++++++++++-- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/Questionable/Controller/QuestController.cs b/Questionable/Controller/QuestController.cs index 0df885de6..ea397d841 100644 --- a/Questionable/Controller/QuestController.cs +++ b/Questionable/Controller/QuestController.cs @@ -788,15 +788,21 @@ internal sealed class QuestController : MiniTaskController, IDi conditionChangeAware.OnConditionChange(flag, value); } - private void OnNormalToast(ref SeString message, ref ToastOptions options, ref bool ishandled) + private void OnNormalToast(ref SeString message, ref ToastOptions options, ref bool isHandled) { _gatheringController.OnNormalToast(message); } - private void OnErrorToast(ref SeString message, ref bool ishandled) + private void OnErrorToast(ref SeString message, ref bool isHandled) { if (_currentTask is IToastAware toastAware) - toastAware.OnErrorToast(message); + { + if (toastAware.OnErrorToast(message)) + { + isHandled = true; + return; + } + } } public void Dispose() diff --git a/Questionable/Controller/Steps/IToastAware.cs b/Questionable/Controller/Steps/IToastAware.cs index aea7eaffa..67a1c7f62 100644 --- a/Questionable/Controller/Steps/IToastAware.cs +++ b/Questionable/Controller/Steps/IToastAware.cs @@ -4,5 +4,5 @@ namespace Questionable.Controller.Steps; public interface IToastAware { - void OnErrorToast(SeString message); + bool OnErrorToast(SeString message); } diff --git a/Questionable/Controller/Steps/Interactions/EquipItem.cs b/Questionable/Controller/Steps/Interactions/EquipItem.cs index 3f3b48f45..84952fe7a 100644 --- a/Questionable/Controller/Steps/Interactions/EquipItem.cs +++ b/Questionable/Controller/Steps/Interactions/EquipItem.cs @@ -174,11 +174,13 @@ internal static class EquipItem public override string ToString() => $"Equip({_item.Name})"; - public void OnErrorToast(SeString message) + public bool OnErrorToast(SeString message) { string? insufficientArmoryChestSpace = dataManager.GetString(709, x => x.Text); if (GameFunctions.GameStringEquals(message.TextValue, insufficientArmoryChestSpace)) _attempts = MaxAttempts; + + return false; } } } diff --git a/Questionable/Controller/Steps/Shared/Move.cs b/Questionable/Controller/Steps/Shared/Move.cs index 8ba93503a..83b0f932d 100644 --- a/Questionable/Controller/Steps/Shared/Move.cs +++ b/Questionable/Controller/Steps/Shared/Move.cs @@ -4,17 +4,21 @@ using System.Globalization; using System.Numerics; using Dalamud.Game.ClientState.Conditions; using Dalamud.Game.ClientState.Objects.Types; +using Dalamud.Game.Text.SeStringHandling; using Dalamud.Plugin.Services; using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.Game.Character; +using LLib; +using Lumina.Excel.GeneratedSheets; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using Questionable.Controller.NavigationOverrides; using Questionable.Controller.Steps.Common; using Questionable.Data; using Questionable.Functions; using Questionable.Model; using Questionable.Model.Questing; +using Action = System.Action; +using Quest = Questionable.Model.Quest; namespace Questionable.Controller.Steps.Shared; @@ -146,8 +150,12 @@ internal static class Move internal sealed class MoveInternal( MovementController movementController, GameFunctions gameFunctions, - ILogger logger) : ITask + ILogger logger, + ICondition condition, + IDataManager dataManager) : ITask, IToastAware { + private string _cannotExecuteAtThisTime = dataManager.GetString(579, x => x.Text)!; + public Action StartAction { get; set; } = null!; public Vector3 Destination { get; set; } @@ -221,6 +229,15 @@ internal static class Move } public override string ToString() => $"MoveTo({Destination.ToString("G", CultureInfo.InvariantCulture)})"; + + public bool OnErrorToast(SeString message) + { + if (GameFunctions.GameStringEquals(_cannotExecuteAtThisTime, message.TextValue) && + condition[ConditionFlag.Diving]) + return true; + + return false; + } } internal sealed class ExpectToBeNearDataId(GameFunctions gameFunctions, IClientState clientState) : ITask