muffin v7.4.10
This commit is contained in:
parent
2df81c5d15
commit
b8dd142c23
47 changed files with 3604 additions and 1058 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Threading.Tasks;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Ipc;
|
||||
using Dalamud.Plugin.Ipc.Exceptions;
|
||||
|
|
@ -20,7 +21,9 @@ internal sealed class PandorasBoxIpc : IDisposable
|
|||
"Pandora Quick Gather", "Switch Gatherers Automatically"
|
||||
}.ToImmutableHashSet();
|
||||
|
||||
private readonly IFramework _framework;
|
||||
private const string AutoActiveTimeManeuverFeature = "Auto Active Time Maneuver";
|
||||
|
||||
private readonly Configuration _configuration;
|
||||
|
||||
private readonly QuestController _questController;
|
||||
|
||||
|
|
@ -34,58 +37,35 @@ internal sealed class PandorasBoxIpc : IDisposable
|
|||
|
||||
private readonly ICallGateSubscriber<string, bool, object?> _setFeatureEnabled;
|
||||
|
||||
private bool _loggedIpcError;
|
||||
|
||||
private HashSet<string>? _pausedFeatures;
|
||||
|
||||
public bool IsAutoActiveTimeManeuverEnabled
|
||||
public PandorasBoxIpc(Configuration configuration, IDalamudPluginInterface pluginInterface, QuestController questController, TerritoryData territoryData, IClientState clientState, ILogger<PandorasBoxIpc> logger)
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return _getFeatureEnabled.InvokeFunc("Auto Active Time Maneuver") == true;
|
||||
}
|
||||
catch (IpcError exception)
|
||||
{
|
||||
if (!_loggedIpcError)
|
||||
{
|
||||
_loggedIpcError = true;
|
||||
_logger.LogWarning(exception, "Could not query pandora's box for feature status, probably not installed");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PandorasBoxIpc(IDalamudPluginInterface pluginInterface, IFramework framework, QuestController questController, TerritoryData territoryData, IClientState clientState, ILogger<PandorasBoxIpc> logger)
|
||||
{
|
||||
_framework = framework;
|
||||
_configuration = configuration;
|
||||
_questController = questController;
|
||||
_territoryData = territoryData;
|
||||
_clientState = clientState;
|
||||
_logger = logger;
|
||||
_getFeatureEnabled = pluginInterface.GetIpcSubscriber<string, bool?>("PandorasBox.GetFeatureEnabled");
|
||||
_setFeatureEnabled = pluginInterface.GetIpcSubscriber<string, bool, object>("PandorasBox.SetFeatureEnabled");
|
||||
logger.LogInformation("Pandora's Box auto active time maneuver enabled: {IsAtmEnabled}", IsAutoActiveTimeManeuverEnabled);
|
||||
_framework.Update += OnUpdate;
|
||||
_questController.AutomationTypeChanged += OnAutomationTypeChanged;
|
||||
}
|
||||
|
||||
private void OnUpdate(IFramework framework)
|
||||
private void OnAutomationTypeChanged(object sender, QuestController.EAutomationType automationType)
|
||||
{
|
||||
if ((_questController.IsRunning || _questController.AutomationType != QuestController.EAutomationType.Manual) && !_territoryData.IsDutyInstance(_clientState.TerritoryType))
|
||||
if (automationType != QuestController.EAutomationType.Manual && !_territoryData.IsDutyInstance(_clientState.TerritoryType))
|
||||
{
|
||||
DisableConflictingFeatures();
|
||||
Task.Run((Action)DisableConflictingFeatures);
|
||||
}
|
||||
else
|
||||
{
|
||||
RestoreConflictingFeatures();
|
||||
Task.Run((Action)RestoreConflictingFeatures);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_framework.Update -= OnUpdate;
|
||||
_questController.AutomationTypeChanged -= OnAutomationTypeChanged;
|
||||
RestoreConflictingFeatures();
|
||||
}
|
||||
|
||||
|
|
@ -98,20 +78,28 @@ internal sealed class PandorasBoxIpc : IDisposable
|
|||
_pausedFeatures = new HashSet<string>();
|
||||
foreach (string conflictingFeature in ConflictingFeatures)
|
||||
{
|
||||
try
|
||||
TryDisableFeature(conflictingFeature);
|
||||
}
|
||||
if (_configuration.General.AutoSolveQte)
|
||||
{
|
||||
TryDisableFeature("Auto Active Time Maneuver");
|
||||
}
|
||||
}
|
||||
|
||||
private void TryDisableFeature(string feature)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_getFeatureEnabled.InvokeFunc(feature) == true)
|
||||
{
|
||||
if (_getFeatureEnabled.InvokeFunc(conflictingFeature) == true)
|
||||
{
|
||||
_setFeatureEnabled.InvokeAction(conflictingFeature, arg2: false);
|
||||
_pausedFeatures.Add(conflictingFeature);
|
||||
_logger.LogInformation("Paused Pandora's Box feature: {Feature}", conflictingFeature);
|
||||
}
|
||||
}
|
||||
catch (IpcError exception)
|
||||
{
|
||||
_logger.LogWarning(exception, "Failed to pause Pandora's Box feature: {Feature}", conflictingFeature);
|
||||
_setFeatureEnabled.InvokeAction(feature, arg2: false);
|
||||
_pausedFeatures.Add(feature);
|
||||
_logger.LogInformation("Paused Pandora's Box feature: {Feature}", feature);
|
||||
}
|
||||
}
|
||||
catch (IpcError)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private void RestoreConflictingFeatures()
|
||||
|
|
@ -127,9 +115,8 @@ internal sealed class PandorasBoxIpc : IDisposable
|
|||
_setFeatureEnabled.InvokeAction(pausedFeature, arg2: true);
|
||||
_logger.LogInformation("Restored Pandora's Box feature: {Feature}", pausedFeature);
|
||||
}
|
||||
catch (IpcError exception)
|
||||
catch (IpcError)
|
||||
{
|
||||
_logger.LogWarning(exception, "Failed to restore Pandora's Box feature: {Feature}", pausedFeature);
|
||||
}
|
||||
}
|
||||
_pausedFeatures = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue