1
0
forked from liza/Questionable

Hide 'cannot execute at this time' toasts when navmesh diving and moving upwards

This commit is contained in:
Liza 2024-08-12 16:22:24 +02:00
parent 59684ce212
commit 53c49d6718
Signed by: liza
GPG Key ID: 7199F8D727D55F67
4 changed files with 32 additions and 7 deletions

View File

@ -788,15 +788,21 @@ internal sealed class QuestController : MiniTaskController<QuestController>, IDi
conditionChangeAware.OnConditionChange(flag, value); 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); _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) if (_currentTask is IToastAware toastAware)
toastAware.OnErrorToast(message); {
if (toastAware.OnErrorToast(message))
{
isHandled = true;
return;
}
}
} }
public void Dispose() public void Dispose()

View File

@ -4,5 +4,5 @@ namespace Questionable.Controller.Steps;
public interface IToastAware public interface IToastAware
{ {
void OnErrorToast(SeString message); bool OnErrorToast(SeString message);
} }

View File

@ -174,11 +174,13 @@ internal static class EquipItem
public override string ToString() => $"Equip({_item.Name})"; 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); string? insufficientArmoryChestSpace = dataManager.GetString<LogMessage>(709, x => x.Text);
if (GameFunctions.GameStringEquals(message.TextValue, insufficientArmoryChestSpace)) if (GameFunctions.GameStringEquals(message.TextValue, insufficientArmoryChestSpace))
_attempts = MaxAttempts; _attempts = MaxAttempts;
return false;
} }
} }
} }

View File

@ -4,17 +4,21 @@ using System.Globalization;
using System.Numerics; using System.Numerics;
using Dalamud.Game.ClientState.Conditions; using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Objects.Types; using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Plugin.Services; using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.Character; using FFXIVClientStructs.FFXIV.Client.Game.Character;
using LLib;
using Lumina.Excel.GeneratedSheets;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Questionable.Controller.NavigationOverrides;
using Questionable.Controller.Steps.Common; using Questionable.Controller.Steps.Common;
using Questionable.Data; using Questionable.Data;
using Questionable.Functions; using Questionable.Functions;
using Questionable.Model; using Questionable.Model;
using Questionable.Model.Questing; using Questionable.Model.Questing;
using Action = System.Action;
using Quest = Questionable.Model.Quest;
namespace Questionable.Controller.Steps.Shared; namespace Questionable.Controller.Steps.Shared;
@ -146,8 +150,12 @@ internal static class Move
internal sealed class MoveInternal( internal sealed class MoveInternal(
MovementController movementController, MovementController movementController,
GameFunctions gameFunctions, 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 Action StartAction { get; set; } = null!;
public Vector3 Destination { get; set; } public Vector3 Destination { get; set; }
@ -221,6 +229,15 @@ internal static class Move
} }
public override string ToString() => $"MoveTo({Destination.ToString("G", CultureInfo.InvariantCulture)})"; 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 internal sealed class ExpectToBeNearDataId(GameFunctions gameFunctions, IClientState clientState) : ITask