forked from liza/Questionable
Extend error toast handling
This commit is contained in:
parent
4bd0b990b9
commit
4f6914d835
@ -51,7 +51,7 @@ internal sealed unsafe class GatheringController : MiniTaskController<GatheringC
|
|||||||
IServiceProvider serviceProvider,
|
IServiceProvider serviceProvider,
|
||||||
IDataManager dataManager,
|
IDataManager dataManager,
|
||||||
IPluginLog pluginLog)
|
IPluginLog pluginLog)
|
||||||
: base(chatGui, condition, serviceProvider, logger)
|
: base(chatGui, condition, serviceProvider, dataManager, logger)
|
||||||
{
|
{
|
||||||
_movementController = movementController;
|
_movementController = movementController;
|
||||||
_gatheringPointRegistry = gatheringPointRegistry;
|
_gatheringPointRegistry = gatheringPointRegistry;
|
||||||
|
@ -2,14 +2,18 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Dalamud.Game.ClientState.Conditions;
|
using Dalamud.Game.ClientState.Conditions;
|
||||||
|
using Dalamud.Game.Text.SeStringHandling;
|
||||||
using Dalamud.Plugin.Services;
|
using Dalamud.Plugin.Services;
|
||||||
|
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.Steps;
|
using Questionable.Controller.Steps;
|
||||||
using Questionable.Controller.Steps.Common;
|
|
||||||
using Questionable.Controller.Steps.Interactions;
|
using Questionable.Controller.Steps.Interactions;
|
||||||
using Questionable.Controller.Steps.Shared;
|
using Questionable.Controller.Steps.Shared;
|
||||||
|
using Questionable.Functions;
|
||||||
using Questionable.Model.Questing;
|
using Questionable.Model.Questing;
|
||||||
|
using Mount = Questionable.Controller.Steps.Common.Mount;
|
||||||
|
|
||||||
namespace Questionable.Controller;
|
namespace Questionable.Controller;
|
||||||
|
|
||||||
@ -22,13 +26,17 @@ internal abstract class MiniTaskController<T>
|
|||||||
private readonly IServiceProvider _serviceProvider;
|
private readonly IServiceProvider _serviceProvider;
|
||||||
private readonly ILogger<T> _logger;
|
private readonly ILogger<T> _logger;
|
||||||
|
|
||||||
|
private readonly string _actionCanceledText;
|
||||||
|
|
||||||
protected MiniTaskController(IChatGui chatGui, ICondition condition, IServiceProvider serviceProvider,
|
protected MiniTaskController(IChatGui chatGui, ICondition condition, IServiceProvider serviceProvider,
|
||||||
ILogger<T> logger)
|
IDataManager dataManager, ILogger<T> logger)
|
||||||
{
|
{
|
||||||
_chatGui = chatGui;
|
_chatGui = chatGui;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_serviceProvider = serviceProvider;
|
_serviceProvider = serviceProvider;
|
||||||
_condition = condition;
|
_condition = condition;
|
||||||
|
|
||||||
|
_actionCanceledText = dataManager.GetString<LogMessage>(1314, x => x.Text)!;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void UpdateCurrentTask()
|
protected virtual void UpdateCurrentTask()
|
||||||
@ -172,4 +180,22 @@ internal abstract class MiniTaskController<T>
|
|||||||
foreach (ITask task in _taskQueue.RemainingTasks)
|
foreach (ITask task in _taskQueue.RemainingTasks)
|
||||||
_logger.LogInformation("- {TaskName}", task);
|
_logger.LogInformation("- {TaskName}", task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnErrorToast(ref SeString message, ref bool isHandled)
|
||||||
|
{
|
||||||
|
if (_taskQueue.CurrentTaskExecutor is IToastAware toastAware)
|
||||||
|
{
|
||||||
|
if (toastAware.OnErrorToast(message))
|
||||||
|
{
|
||||||
|
isHandled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isHandled)
|
||||||
|
{
|
||||||
|
if (GameFunctions.GameStringEquals(_actionCanceledText, message.TextValue) &&
|
||||||
|
!_condition[ConditionFlag.InFlight])
|
||||||
|
InterruptQueueWithCombat();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,6 @@ internal sealed class QuestController : MiniTaskController<QuestController>, IDi
|
|||||||
private readonly TaskCreator _taskCreator;
|
private readonly TaskCreator _taskCreator;
|
||||||
private readonly ILogger<QuestController> _logger;
|
private readonly ILogger<QuestController> _logger;
|
||||||
|
|
||||||
private readonly string _actionCanceledText;
|
|
||||||
|
|
||||||
private readonly object _progressLock = new();
|
private readonly object _progressLock = new();
|
||||||
|
|
||||||
private QuestProgress? _startedQuest;
|
private QuestProgress? _startedQuest;
|
||||||
@ -84,7 +82,7 @@ internal sealed class QuestController : MiniTaskController<QuestController>, IDi
|
|||||||
TaskCreator taskCreator,
|
TaskCreator taskCreator,
|
||||||
IServiceProvider serviceProvider,
|
IServiceProvider serviceProvider,
|
||||||
IDataManager dataManager)
|
IDataManager dataManager)
|
||||||
: base(chatGui, condition, serviceProvider, logger)
|
: base(chatGui, condition, serviceProvider, dataManager, logger)
|
||||||
{
|
{
|
||||||
_clientState = clientState;
|
_clientState = clientState;
|
||||||
_gameFunctions = gameFunctions;
|
_gameFunctions = gameFunctions;
|
||||||
@ -105,8 +103,6 @@ internal sealed class QuestController : MiniTaskController<QuestController>, IDi
|
|||||||
_condition.ConditionChange += OnConditionChange;
|
_condition.ConditionChange += OnConditionChange;
|
||||||
_toastGui.Toast += OnNormalToast;
|
_toastGui.Toast += OnNormalToast;
|
||||||
_toastGui.ErrorToast += OnErrorToast;
|
_toastGui.ErrorToast += OnErrorToast;
|
||||||
|
|
||||||
_actionCanceledText = dataManager.GetString<LogMessage>(1314, x => x.Text)!;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public EAutomationType AutomationType
|
public EAutomationType AutomationType
|
||||||
@ -809,24 +805,6 @@ internal sealed class QuestController : MiniTaskController<QuestController>, IDi
|
|||||||
_gatheringController.OnNormalToast(message);
|
_gatheringController.OnNormalToast(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnErrorToast(ref SeString message, ref bool isHandled)
|
|
||||||
{
|
|
||||||
if (_taskQueue.CurrentTaskExecutor is IToastAware toastAware)
|
|
||||||
{
|
|
||||||
if (toastAware.OnErrorToast(message))
|
|
||||||
{
|
|
||||||
isHandled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isHandled)
|
|
||||||
{
|
|
||||||
if (GameFunctions.GameStringEquals(_actionCanceledText, message.TextValue) &&
|
|
||||||
!_condition[ConditionFlag.InFlight])
|
|
||||||
InterruptQueueWithCombat();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_toastGui.ErrorToast -= OnErrorToast;
|
_toastGui.ErrorToast -= OnErrorToast;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using Dalamud.Game.ClientState.Objects.Enums;
|
using Dalamud.Game.ClientState.Objects.Enums;
|
||||||
|
using Dalamud.Game.Text.SeStringHandling;
|
||||||
using Dalamud.Plugin.Services;
|
using Dalamud.Plugin.Services;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Questionable.Controller.Steps.Shared;
|
using Questionable.Controller.Steps.Shared;
|
||||||
@ -26,7 +27,7 @@ internal static class MoveToLandingLocation
|
|||||||
MoveTo.MoveExecutor moveExecutor,
|
MoveTo.MoveExecutor moveExecutor,
|
||||||
GameFunctions gameFunctions,
|
GameFunctions gameFunctions,
|
||||||
IObjectTable objectTable,
|
IObjectTable objectTable,
|
||||||
ILogger<MoveToLandingLocationExecutor> logger) : TaskExecutor<Task>
|
ILogger<MoveToLandingLocationExecutor> logger) : TaskExecutor<Task>, IToastAware
|
||||||
{
|
{
|
||||||
private ITask _moveTask = null!;
|
private ITask _moveTask = null!;
|
||||||
|
|
||||||
@ -57,5 +58,6 @@ internal static class MoveToLandingLocation
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override ETaskResult Update() => moveExecutor.Update();
|
public override ETaskResult Update() => moveExecutor.Update();
|
||||||
|
public bool OnErrorToast(SeString message) => moveExecutor.OnErrorToast(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Dalamud.Game.Text;
|
using Dalamud.Game.Text;
|
||||||
|
using Dalamud.Game.Text.SeStringHandling;
|
||||||
using Dalamud.Plugin.Services;
|
using Dalamud.Plugin.Services;
|
||||||
using FFXIVClientStructs.FFXIV.Application.Network.WorkDefinitions;
|
using FFXIVClientStructs.FFXIV.Application.Network.WorkDefinitions;
|
||||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||||
@ -124,7 +125,8 @@ internal static class Gather
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal sealed class StartGathering(GatheringController gatheringController) : TaskExecutor<GatheringTask>
|
internal sealed class StartGathering(GatheringController gatheringController) : TaskExecutor<GatheringTask>,
|
||||||
|
IToastAware
|
||||||
{
|
{
|
||||||
protected override bool Start()
|
protected override bool Start()
|
||||||
{
|
{
|
||||||
@ -140,6 +142,13 @@ internal static class Gather
|
|||||||
|
|
||||||
return ETaskResult.StillRunning;
|
return ETaskResult.StillRunning;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool OnErrorToast(SeString message)
|
||||||
|
{
|
||||||
|
bool isHandled = false;
|
||||||
|
gatheringController.OnErrorToast(ref message, ref isHandled);
|
||||||
|
return isHandled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user