Hide 'cannot execute at this time' toasts when navmesh diving and moving upwards
authorLiza Carvelli <liza@carvel.li>
Mon, 12 Aug 2024 14:22:24 +0000 (16:22 +0200)
committerLiza Carvelli <liza@carvel.li>
Mon, 12 Aug 2024 14:22:24 +0000 (16:22 +0200)
Questionable/Controller/QuestController.cs
Questionable/Controller/Steps/IToastAware.cs
Questionable/Controller/Steps/Interactions/EquipItem.cs
Questionable/Controller/Steps/Shared/Move.cs

index 0df885de69e00bfca105d0fe82db797d6c94d9f0..ea397d841437d34a477435db71df154a65a7e843 100644 (file)
@@ -788,15 +788,21 @@ internal sealed class QuestController : MiniTaskController<QuestController>, 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()
index aea7eaffaa3b9a5b45b397a7fc4fde60a7f4642d..67a1c7f62514a015a7c4757b43388403d5fde24e 100644 (file)
@@ -4,5 +4,5 @@ namespace Questionable.Controller.Steps;
 
 public interface IToastAware
 {
-    void OnErrorToast(SeString message);
+    bool OnErrorToast(SeString message);
 }
index 3f3b48f45130cade81e315a4112ca21fd4f980cd..84952fe7add66c47d3cf59f8989cadb9662c4d4c 100644 (file)
@@ -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<LogMessage>(709, x => x.Text);
             if (GameFunctions.GameStringEquals(message.TextValue, insufficientArmoryChestSpace))
                 _attempts = MaxAttempts;
+
+            return false;
         }
     }
 }
index 8ba93503a3a2fba141d334907ec647616d8b641c..83b0f932d9da0e9f927fbcbdbd506f77f4c6a91f 100644 (file)
@@ -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<MoveInternal> logger) : ITask
+        ILogger<MoveInternal> logger,
+        ICondition condition,
+        IDataManager dataManager) : ITask, IToastAware
     {
+        private string _cannotExecuteAtThisTime = dataManager.GetString<LogMessage>(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