forked from aly/qstbak
muffin v7.4.10
This commit is contained in:
parent
2df81c5d15
commit
b8dd142c23
47 changed files with 3604 additions and 1058 deletions
|
|
@ -1,42 +1,123 @@
|
|||
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;
|
||||
using Dalamud.Plugin.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Questionable.Controller;
|
||||
using Questionable.Data;
|
||||
|
||||
namespace Questionable.External;
|
||||
|
||||
internal sealed class AutomatonIpc
|
||||
internal sealed class AutomatonIpc : IDisposable
|
||||
{
|
||||
private static readonly ImmutableHashSet<string> ConflictingTweaks = new HashSet<string>
|
||||
{
|
||||
"DateWithDestiny", "AutoFollow", "AutoPillion", "AutoInvite", "AutoBusy", "AutoEquipXPBoosts", "FateToolKit", "AutoMerge", "AutoQueue", "EnhancedDutyStartEnd",
|
||||
"EnhancedLoginLogout", "GettingTooAttached", "RetrieveMateria"
|
||||
}.ToImmutableHashSet();
|
||||
|
||||
private const string AutoSnipeTweak = "AutoSnipeQuests";
|
||||
|
||||
private readonly Configuration _configuration;
|
||||
|
||||
private readonly QuestController _questController;
|
||||
|
||||
private readonly TerritoryData _territoryData;
|
||||
|
||||
private readonly IClientState _clientState;
|
||||
|
||||
private readonly ILogger<AutomatonIpc> _logger;
|
||||
|
||||
private readonly ICallGateSubscriber<string, bool> _isTweakEnabled;
|
||||
|
||||
private bool _loggedIpcError;
|
||||
private readonly ICallGateSubscriber<string, bool, object?> _setTweakState;
|
||||
|
||||
public bool IsAutoSnipeEnabled
|
||||
private HashSet<string>? _pausedTweaks;
|
||||
|
||||
public AutomatonIpc(Configuration configuration, IDalamudPluginInterface pluginInterface, QuestController questController, TerritoryData territoryData, IClientState clientState, ILogger<AutomatonIpc> logger)
|
||||
{
|
||||
get
|
||||
_configuration = configuration;
|
||||
_questController = questController;
|
||||
_territoryData = territoryData;
|
||||
_clientState = clientState;
|
||||
_logger = logger;
|
||||
_isTweakEnabled = pluginInterface.GetIpcSubscriber<string, bool>("Automaton.IsTweakEnabled");
|
||||
_setTweakState = pluginInterface.GetIpcSubscriber<string, bool, object>("Automaton.SetTweakState");
|
||||
_questController.AutomationTypeChanged += OnAutomationTypeChanged;
|
||||
}
|
||||
|
||||
private void OnAutomationTypeChanged(object sender, QuestController.EAutomationType automationType)
|
||||
{
|
||||
if (automationType != QuestController.EAutomationType.Manual && !_territoryData.IsDutyInstance(_clientState.TerritoryType))
|
||||
{
|
||||
try
|
||||
{
|
||||
return _isTweakEnabled.InvokeFunc("AutoSnipeQuests");
|
||||
}
|
||||
catch (IpcError exception)
|
||||
{
|
||||
if (!_loggedIpcError)
|
||||
{
|
||||
_loggedIpcError = true;
|
||||
_logger.LogWarning(exception, "Could not query automaton for tweak status, probably not installed");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Task.Run((Action)DisableConflictingTweaks);
|
||||
}
|
||||
else
|
||||
{
|
||||
Task.Run((Action)RestoreConflictingTweaks);
|
||||
}
|
||||
}
|
||||
|
||||
public AutomatonIpc(IDalamudPluginInterface pluginInterface, ILogger<AutomatonIpc> logger)
|
||||
private void DisableConflictingTweaks()
|
||||
{
|
||||
_logger = logger;
|
||||
_isTweakEnabled = pluginInterface.GetIpcSubscriber<string, bool>("Automaton.IsTweakEnabled");
|
||||
logger.LogInformation("Automaton auto-snipe enabled: {IsTweakEnabled}", IsAutoSnipeEnabled);
|
||||
if (_pausedTweaks != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_pausedTweaks = new HashSet<string>();
|
||||
foreach (string conflictingTweak in ConflictingTweaks)
|
||||
{
|
||||
TryDisableTweak(conflictingTweak);
|
||||
}
|
||||
if (_configuration.General.AutoSnipe)
|
||||
{
|
||||
TryDisableTweak("AutoSnipeQuests");
|
||||
}
|
||||
}
|
||||
|
||||
private void TryDisableTweak(string tweak)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_isTweakEnabled.InvokeFunc(tweak))
|
||||
{
|
||||
_setTweakState.InvokeAction(tweak, arg2: false);
|
||||
_pausedTweaks.Add(tweak);
|
||||
_logger.LogInformation("Paused Automaton tweak: {Tweak}", tweak);
|
||||
}
|
||||
}
|
||||
catch (IpcError)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private void RestoreConflictingTweaks()
|
||||
{
|
||||
if (_pausedTweaks == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (string pausedTweak in _pausedTweaks)
|
||||
{
|
||||
try
|
||||
{
|
||||
_setTweakState.InvokeAction(pausedTweak, arg2: true);
|
||||
_logger.LogInformation("Restored Automaton tweak: {Tweak}", pausedTweak);
|
||||
}
|
||||
catch (IpcError)
|
||||
{
|
||||
}
|
||||
}
|
||||
_pausedTweaks = null;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_questController.AutomationTypeChanged -= OnAutomationTypeChanged;
|
||||
RestoreConflictingTweaks();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -196,6 +196,20 @@ internal sealed class QuestionableIpc : IDisposable
|
|||
|
||||
private const string IpcStopLevelingMode = "Questionable.StopLevelingMode";
|
||||
|
||||
private const string IpcGetBlacklistedQuests = "Questionable.GetBlacklistedQuests";
|
||||
|
||||
private const string IpcAddBlacklistedQuest = "Questionable.AddBlacklistedQuest";
|
||||
|
||||
private const string IpcRemoveBlacklistedQuest = "Questionable.RemoveBlacklistedQuest";
|
||||
|
||||
private const string IpcClearBlacklistedQuests = "Questionable.ClearBlacklistedQuests";
|
||||
|
||||
private const string IpcIsQuestBlacklisted = "Questionable.IsQuestBlacklisted";
|
||||
|
||||
private const string IpcGetMsqPriorityMode = "Questionable.GetMsqPriorityMode";
|
||||
|
||||
private const string IpcSetMsqPriorityMode = "Questionable.SetMsqPriorityMode";
|
||||
|
||||
private readonly QuestController _questController;
|
||||
|
||||
private readonly QuestRegistry _questRegistry;
|
||||
|
|
@ -350,6 +364,20 @@ internal sealed class QuestionableIpc : IDisposable
|
|||
|
||||
private readonly ICallGateProvider<bool> _stopLevelingMode;
|
||||
|
||||
private readonly ICallGateProvider<List<string>> _getBlacklistedQuests;
|
||||
|
||||
private readonly ICallGateProvider<string, bool> _addBlacklistedQuest;
|
||||
|
||||
private readonly ICallGateProvider<string, bool> _removeBlacklistedQuest;
|
||||
|
||||
private readonly ICallGateProvider<bool> _clearBlacklistedQuests;
|
||||
|
||||
private readonly ICallGateProvider<string, bool> _isQuestBlacklisted;
|
||||
|
||||
private readonly ICallGateProvider<int> _getMsqPriorityMode;
|
||||
|
||||
private readonly ICallGateProvider<int, bool> _setMsqPriorityMode;
|
||||
|
||||
public QuestionableIpc(QuestController questController, EventInfoComponent eventInfoComponent, QuestRegistry questRegistry, QuestFunctions questFunctions, QuestData questData, ManualPriorityComponent manualPriorityComponent, PresetBuilderComponent presetBuilderComponent, Configuration configuration, IDalamudPluginInterface pluginInterface, IServiceProvider serviceProvider, AutoDutyIpc autoDutyIpc)
|
||||
{
|
||||
QuestionableIpc questionableIpc = this;
|
||||
|
|
@ -542,6 +570,20 @@ internal sealed class QuestionableIpc : IDisposable
|
|||
_startLevelingMode.RegisterFunc(StartLevelingMode);
|
||||
_stopLevelingMode = pluginInterface.GetIpcProvider<bool>("Questionable.StopLevelingMode");
|
||||
_stopLevelingMode.RegisterFunc(StopLevelingMode);
|
||||
_getBlacklistedQuests = pluginInterface.GetIpcProvider<List<string>>("Questionable.GetBlacklistedQuests");
|
||||
_getBlacklistedQuests.RegisterFunc(GetBlacklistedQuests);
|
||||
_addBlacklistedQuest = pluginInterface.GetIpcProvider<string, bool>("Questionable.AddBlacklistedQuest");
|
||||
_addBlacklistedQuest.RegisterFunc(AddBlacklistedQuest);
|
||||
_removeBlacklistedQuest = pluginInterface.GetIpcProvider<string, bool>("Questionable.RemoveBlacklistedQuest");
|
||||
_removeBlacklistedQuest.RegisterFunc(RemoveBlacklistedQuest);
|
||||
_clearBlacklistedQuests = pluginInterface.GetIpcProvider<bool>("Questionable.ClearBlacklistedQuests");
|
||||
_clearBlacklistedQuests.RegisterFunc(ClearBlacklistedQuests);
|
||||
_isQuestBlacklisted = pluginInterface.GetIpcProvider<string, bool>("Questionable.IsQuestBlacklisted");
|
||||
_isQuestBlacklisted.RegisterFunc(IsQuestBlacklistedIpc);
|
||||
_getMsqPriorityMode = pluginInterface.GetIpcProvider<int>("Questionable.GetMsqPriorityMode");
|
||||
_getMsqPriorityMode.RegisterFunc(GetMsqPriorityMode);
|
||||
_setMsqPriorityMode = pluginInterface.GetIpcProvider<int, bool>("Questionable.SetMsqPriorityMode");
|
||||
_setMsqPriorityMode.RegisterFunc(SetMsqPriorityMode);
|
||||
}
|
||||
|
||||
private bool StartQuest(string questId, bool single)
|
||||
|
|
@ -1387,6 +1429,67 @@ internal sealed class QuestionableIpc : IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
private List<string> GetBlacklistedQuests()
|
||||
{
|
||||
return _configuration.General.BlacklistedQuests.Select((ElementId q) => q.ToString()).ToList();
|
||||
}
|
||||
|
||||
private bool AddBlacklistedQuest(string questId)
|
||||
{
|
||||
if (ElementId.TryFromString(questId, out ElementId elementId) && elementId != null && _configuration.General.BlacklistedQuests.Add(elementId))
|
||||
{
|
||||
_pluginInterface.SavePluginConfig(_configuration);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool RemoveBlacklistedQuest(string questId)
|
||||
{
|
||||
if (ElementId.TryFromString(questId, out ElementId elementId) && elementId != null)
|
||||
{
|
||||
bool num = _configuration.General.BlacklistedQuests.Remove(elementId);
|
||||
if (num)
|
||||
{
|
||||
_pluginInterface.SavePluginConfig(_configuration);
|
||||
}
|
||||
return num;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool ClearBlacklistedQuests()
|
||||
{
|
||||
_configuration.General.BlacklistedQuests.Clear();
|
||||
_pluginInterface.SavePluginConfig(_configuration);
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool IsQuestBlacklistedIpc(string questId)
|
||||
{
|
||||
if (ElementId.TryFromString(questId, out ElementId elementId) && elementId != null)
|
||||
{
|
||||
return _questFunctions.IsQuestBlacklisted(elementId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private int GetMsqPriorityMode()
|
||||
{
|
||||
return (int)_configuration.General.MsqPriority;
|
||||
}
|
||||
|
||||
private bool SetMsqPriorityMode(int mode)
|
||||
{
|
||||
if (!Enum.IsDefined(typeof(Configuration.EMsqPriorityMode), mode))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_configuration.General.MsqPriority = (Configuration.EMsqPriorityMode)mode;
|
||||
_pluginInterface.SavePluginConfig(_configuration);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_exportQuestPriority.UnregisterFunc();
|
||||
|
|
@ -1456,5 +1559,12 @@ internal sealed class QuestionableIpc : IDisposable
|
|||
_getMsqLevelLockInfo.UnregisterFunc();
|
||||
_setLevelingModeEnabled.UnregisterFunc();
|
||||
_isLevelingModeEnabled.UnregisterFunc();
|
||||
_isQuestBlacklisted.UnregisterFunc();
|
||||
_clearBlacklistedQuests.UnregisterFunc();
|
||||
_removeBlacklistedQuest.UnregisterFunc();
|
||||
_addBlacklistedQuest.UnregisterFunc();
|
||||
_getBlacklistedQuests.UnregisterFunc();
|
||||
_setMsqPriorityMode.UnregisterFunc();
|
||||
_getMsqPriorityMode.UnregisterFunc();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue