forked from aly/qstbak
muffin v7.4.7
This commit is contained in:
parent
1cc65e495d
commit
63f975ff4f
16 changed files with 1659 additions and 939 deletions
|
|
@ -51,6 +51,17 @@ internal sealed class QuestionableIpc : IDisposable
|
|||
public required int TargetValue { get; init; }
|
||||
}
|
||||
|
||||
public sealed class MsqLevelLockData
|
||||
{
|
||||
public required bool IsLevelLocked { get; init; }
|
||||
|
||||
public required int LevelsNeeded { get; init; }
|
||||
|
||||
public required int RequiredLevel { get; init; }
|
||||
|
||||
public required string? QuestName { get; init; }
|
||||
}
|
||||
|
||||
private const string IpcIsRunning = "Questionable.IsRunning";
|
||||
|
||||
private const string IpcGetCurrentQuestId = "Questionable.GetCurrentQuestId";
|
||||
|
|
@ -145,6 +156,18 @@ internal sealed class QuestionableIpc : IDisposable
|
|||
|
||||
private const string IpcGetAllQuestSequenceStopConditions = "Questionable.GetAllQuestSequenceStopConditions";
|
||||
|
||||
private const string IpcGetLevelStopMode = "Questionable.GetLevelStopMode";
|
||||
|
||||
private const string IpcSetLevelStopMode = "Questionable.SetLevelStopMode";
|
||||
|
||||
private const string IpcGetSequenceStopMode = "Questionable.GetSequenceStopMode";
|
||||
|
||||
private const string IpcSetSequenceStopMode = "Questionable.SetSequenceStopMode";
|
||||
|
||||
private const string IpcGetQuestStopMode = "Questionable.GetQuestStopMode";
|
||||
|
||||
private const string IpcSetQuestStopMode = "Questionable.SetQuestStopMode";
|
||||
|
||||
private const string IpcGetAlliedSocietyRemainingAllowances = "Questionable.AlliedSociety.GetRemainingAllowances";
|
||||
|
||||
private const string IpcGetAlliedSocietyTimeUntilReset = "Questionable.AlliedSociety.GetTimeUntilReset";
|
||||
|
|
@ -163,6 +186,16 @@ internal sealed class QuestionableIpc : IDisposable
|
|||
|
||||
private const string IpcGetAlliedSocietyOptimalQuests = "Questionable.AlliedSociety.GetOptimalQuests";
|
||||
|
||||
private const string IpcIsLevelingModeEnabled = "Questionable.IsLevelingModeEnabled";
|
||||
|
||||
private const string IpcSetLevelingModeEnabled = "Questionable.SetLevelingModeEnabled";
|
||||
|
||||
private const string IpcGetMsqLevelLockInfo = "Questionable.GetMsqLevelLockInfo";
|
||||
|
||||
private const string IpcStartLevelingMode = "Questionable.StartLevelingMode";
|
||||
|
||||
private const string IpcStopLevelingMode = "Questionable.StopLevelingMode";
|
||||
|
||||
private readonly QuestController _questController;
|
||||
|
||||
private readonly QuestRegistry _questRegistry;
|
||||
|
|
@ -181,6 +214,8 @@ internal sealed class QuestionableIpc : IDisposable
|
|||
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
private readonly AutoDutyIpc _autoDutyIpc;
|
||||
|
||||
private readonly ICallGateProvider<bool> _isRunning;
|
||||
|
||||
private readonly ICallGateProvider<string?> _getCurrentQuestId;
|
||||
|
|
@ -275,6 +310,18 @@ internal sealed class QuestionableIpc : IDisposable
|
|||
|
||||
private readonly ICallGateProvider<Dictionary<string, int>> _getAllQuestSequenceStopConditions;
|
||||
|
||||
private readonly ICallGateProvider<int> _getLevelStopMode;
|
||||
|
||||
private readonly ICallGateProvider<int, bool> _setLevelStopMode;
|
||||
|
||||
private readonly ICallGateProvider<int> _getSequenceStopMode;
|
||||
|
||||
private readonly ICallGateProvider<int, bool> _setSequenceStopMode;
|
||||
|
||||
private readonly ICallGateProvider<string, int> _getQuestStopMode;
|
||||
|
||||
private readonly ICallGateProvider<string, int, bool> _setQuestStopMode;
|
||||
|
||||
private readonly ICallGateProvider<int> _getAlliedSocietyRemainingAllowances;
|
||||
|
||||
private readonly ICallGateProvider<long> _getAlliedSocietyTimeUntilReset;
|
||||
|
|
@ -293,7 +340,17 @@ internal sealed class QuestionableIpc : IDisposable
|
|||
|
||||
private readonly ICallGateProvider<byte, List<string>> _getAlliedSocietyOptimalQuests;
|
||||
|
||||
public QuestionableIpc(QuestController questController, EventInfoComponent eventInfoComponent, QuestRegistry questRegistry, QuestFunctions questFunctions, QuestData questData, ManualPriorityComponent manualPriorityComponent, PresetBuilderComponent presetBuilderComponent, Configuration configuration, IDalamudPluginInterface pluginInterface, IServiceProvider serviceProvider)
|
||||
private readonly ICallGateProvider<bool> _isLevelingModeEnabled;
|
||||
|
||||
private readonly ICallGateProvider<bool, bool> _setLevelingModeEnabled;
|
||||
|
||||
private readonly ICallGateProvider<MsqLevelLockData?> _getMsqLevelLockInfo;
|
||||
|
||||
private readonly ICallGateProvider<bool> _startLevelingMode;
|
||||
|
||||
private readonly ICallGateProvider<bool> _stopLevelingMode;
|
||||
|
||||
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;
|
||||
_questController = questController;
|
||||
|
|
@ -305,6 +362,7 @@ internal sealed class QuestionableIpc : IDisposable
|
|||
_configuration = configuration;
|
||||
_pluginInterface = pluginInterface;
|
||||
_serviceProvider = serviceProvider;
|
||||
_autoDutyIpc = autoDutyIpc;
|
||||
_isRunning = pluginInterface.GetIpcProvider<bool>("Questionable.IsRunning");
|
||||
_isRunning.RegisterFunc(() => questController.AutomationType != QuestController.EAutomationType.Manual || questController.IsRunning);
|
||||
_getCurrentQuestId = pluginInterface.GetIpcProvider<string>("Questionable.GetCurrentQuestId");
|
||||
|
|
@ -400,6 +458,62 @@ internal sealed class QuestionableIpc : IDisposable
|
|||
_removeQuestSequenceStopCondition.RegisterFunc(RemoveQuestSequenceStopCondition);
|
||||
_getAllQuestSequenceStopConditions = pluginInterface.GetIpcProvider<Dictionary<string, int>>("Questionable.GetAllQuestSequenceStopConditions");
|
||||
_getAllQuestSequenceStopConditions.RegisterFunc(GetAllQuestSequenceStopConditions);
|
||||
_getLevelStopMode = pluginInterface.GetIpcProvider<int>("Questionable.GetLevelStopMode");
|
||||
_getLevelStopMode.RegisterFunc(() => (int)questionableIpc._configuration.Stop.LevelStopMode);
|
||||
_setLevelStopMode = pluginInterface.GetIpcProvider<int, bool>("Questionable.SetLevelStopMode");
|
||||
_setLevelStopMode.RegisterFunc(delegate(int mode)
|
||||
{
|
||||
if (!Enum.IsDefined(typeof(Configuration.EStopConditionMode), mode))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
questionableIpc._configuration.Stop.LevelStopMode = (Configuration.EStopConditionMode)mode;
|
||||
questionableIpc._pluginInterface.SavePluginConfig(questionableIpc._configuration);
|
||||
return true;
|
||||
});
|
||||
_getSequenceStopMode = pluginInterface.GetIpcProvider<int>("Questionable.GetSequenceStopMode");
|
||||
_getSequenceStopMode.RegisterFunc(() => (int)questionableIpc._configuration.Stop.SequenceStopMode);
|
||||
_setSequenceStopMode = pluginInterface.GetIpcProvider<int, bool>("Questionable.SetSequenceStopMode");
|
||||
_setSequenceStopMode.RegisterFunc(delegate(int mode)
|
||||
{
|
||||
if (!Enum.IsDefined(typeof(Configuration.EStopConditionMode), mode))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
questionableIpc._configuration.Stop.SequenceStopMode = (Configuration.EStopConditionMode)mode;
|
||||
questionableIpc._pluginInterface.SavePluginConfig(questionableIpc._configuration);
|
||||
return true;
|
||||
});
|
||||
_getQuestStopMode = pluginInterface.GetIpcProvider<string, int>("Questionable.GetQuestStopMode");
|
||||
_getQuestStopMode.RegisterFunc((string questId) => (int)(questionableIpc._configuration.Stop.QuestStopModes.TryGetValue(questId, out var value) ? value : ((Configuration.EStopConditionMode)(-1))));
|
||||
_setQuestStopMode = pluginInterface.GetIpcProvider<string, int, bool>("Questionable.SetQuestStopMode");
|
||||
_setQuestStopMode.RegisterFunc(delegate(string questId, int mode)
|
||||
{
|
||||
if (!Enum.IsDefined(typeof(Configuration.EStopConditionMode), mode))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (ElementId.TryFromString(questId, out ElementId elementId) && elementId != null && questionableIpc._questRegistry.IsKnownQuest(elementId))
|
||||
{
|
||||
if (mode == 0)
|
||||
{
|
||||
questionableIpc._configuration.Stop.QuestsToStopAfter.Remove(elementId);
|
||||
questionableIpc._configuration.Stop.QuestStopModes.Remove(questId);
|
||||
questionableIpc._configuration.Stop.QuestSequences.Remove(questId);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!questionableIpc._configuration.Stop.QuestsToStopAfter.Contains(elementId))
|
||||
{
|
||||
questionableIpc._configuration.Stop.QuestsToStopAfter.Add(elementId);
|
||||
}
|
||||
questionableIpc._configuration.Stop.QuestStopModes[questId] = (Configuration.EStopConditionMode)mode;
|
||||
}
|
||||
questionableIpc._pluginInterface.SavePluginConfig(questionableIpc._configuration);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
_getAlliedSocietyRemainingAllowances = pluginInterface.GetIpcProvider<int>("Questionable.AlliedSociety.GetRemainingAllowances");
|
||||
_getAlliedSocietyRemainingAllowances.RegisterFunc(GetAlliedSocietyRemainingAllowances);
|
||||
_getAlliedSocietyTimeUntilReset = pluginInterface.GetIpcProvider<long>("Questionable.AlliedSociety.GetTimeUntilReset");
|
||||
|
|
@ -418,6 +532,16 @@ internal sealed class QuestionableIpc : IDisposable
|
|||
_addAlliedSocietyOptimalQuests.RegisterFunc(AddAlliedSocietyOptimalQuests);
|
||||
_getAlliedSocietyOptimalQuests = pluginInterface.GetIpcProvider<byte, List<string>>("Questionable.AlliedSociety.GetOptimalQuests");
|
||||
_getAlliedSocietyOptimalQuests.RegisterFunc(GetAlliedSocietyOptimalQuests);
|
||||
_isLevelingModeEnabled = pluginInterface.GetIpcProvider<bool>("Questionable.IsLevelingModeEnabled");
|
||||
_isLevelingModeEnabled.RegisterFunc(IsLevelingModeEnabled);
|
||||
_setLevelingModeEnabled = pluginInterface.GetIpcProvider<bool, bool>("Questionable.SetLevelingModeEnabled");
|
||||
_setLevelingModeEnabled.RegisterFunc(SetLevelingModeEnabled);
|
||||
_getMsqLevelLockInfo = pluginInterface.GetIpcProvider<MsqLevelLockData>("Questionable.GetMsqLevelLockInfo");
|
||||
_getMsqLevelLockInfo.RegisterFunc(GetMsqLevelLockInfo);
|
||||
_startLevelingMode = pluginInterface.GetIpcProvider<bool>("Questionable.StartLevelingMode");
|
||||
_startLevelingMode.RegisterFunc(StartLevelingMode);
|
||||
_stopLevelingMode = pluginInterface.GetIpcProvider<bool>("Questionable.StopLevelingMode");
|
||||
_stopLevelingMode.RegisterFunc(StopLevelingMode);
|
||||
}
|
||||
|
||||
private bool StartQuest(string questId, bool single)
|
||||
|
|
@ -969,7 +1093,7 @@ internal sealed class QuestionableIpc : IDisposable
|
|||
{
|
||||
return new StopConditionData
|
||||
{
|
||||
Enabled = _configuration.Stop.LevelToStopAfter,
|
||||
Enabled = (_configuration.Stop.LevelStopMode != Configuration.EStopConditionMode.Off),
|
||||
TargetValue = _configuration.Stop.TargetLevel
|
||||
};
|
||||
}
|
||||
|
|
@ -980,7 +1104,7 @@ internal sealed class QuestionableIpc : IDisposable
|
|||
{
|
||||
return false;
|
||||
}
|
||||
_configuration.Stop.LevelToStopAfter = enabled;
|
||||
_configuration.Stop.LevelStopMode = (enabled ? Configuration.EStopConditionMode.Pause : Configuration.EStopConditionMode.Off);
|
||||
_configuration.Stop.TargetLevel = targetLevel;
|
||||
_pluginInterface.SavePluginConfig(_configuration);
|
||||
return true;
|
||||
|
|
@ -990,7 +1114,7 @@ internal sealed class QuestionableIpc : IDisposable
|
|||
{
|
||||
return new StopConditionData
|
||||
{
|
||||
Enabled = _configuration.Stop.SequenceToStopAfter,
|
||||
Enabled = (_configuration.Stop.SequenceStopMode != Configuration.EStopConditionMode.Off),
|
||||
TargetValue = _configuration.Stop.TargetSequence
|
||||
};
|
||||
}
|
||||
|
|
@ -1001,7 +1125,7 @@ internal sealed class QuestionableIpc : IDisposable
|
|||
{
|
||||
return false;
|
||||
}
|
||||
_configuration.Stop.SequenceToStopAfter = enabled;
|
||||
_configuration.Stop.SequenceStopMode = (enabled ? Configuration.EStopConditionMode.Pause : Configuration.EStopConditionMode.Off);
|
||||
_configuration.Stop.TargetSequence = targetSequence;
|
||||
_pluginInterface.SavePluginConfig(_configuration);
|
||||
return true;
|
||||
|
|
@ -1213,6 +1337,56 @@ internal sealed class QuestionableIpc : IDisposable
|
|||
select q.QuestId.ToString()).ToList();
|
||||
}
|
||||
|
||||
private bool IsLevelingModeEnabled()
|
||||
{
|
||||
return _configuration.Duties.RunLevelingModeWhenUnderleveled;
|
||||
}
|
||||
|
||||
private bool SetLevelingModeEnabled(bool enabled)
|
||||
{
|
||||
_configuration.Duties.RunLevelingModeWhenUnderleveled = enabled;
|
||||
_pluginInterface.SavePluginConfig(_configuration);
|
||||
return true;
|
||||
}
|
||||
|
||||
private MsqLevelLockData? GetMsqLevelLockInfo()
|
||||
{
|
||||
var (flag, levelsNeeded, requiredLevel, questName) = _questFunctions.GetMsqLevelLockInfo();
|
||||
if (!flag)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new MsqLevelLockData
|
||||
{
|
||||
IsLevelLocked = flag,
|
||||
LevelsNeeded = levelsNeeded,
|
||||
RequiredLevel = requiredLevel,
|
||||
QuestName = questName
|
||||
};
|
||||
}
|
||||
|
||||
private bool StartLevelingMode()
|
||||
{
|
||||
if (!_autoDutyIpc.IsConfiguredToRunLevelingMode())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return _autoDutyIpc.StartLevelingMode();
|
||||
}
|
||||
|
||||
private bool StopLevelingMode()
|
||||
{
|
||||
try
|
||||
{
|
||||
_autoDutyIpc.Stop();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_exportQuestPriority.UnregisterFunc();
|
||||
|
|
@ -1262,6 +1436,12 @@ internal sealed class QuestionableIpc : IDisposable
|
|||
_getStopQuestList.UnregisterFunc();
|
||||
_setStopConditionsEnabled.UnregisterFunc();
|
||||
_getStopConditionsEnabled.UnregisterFunc();
|
||||
_setQuestStopMode.UnregisterFunc();
|
||||
_getQuestStopMode.UnregisterFunc();
|
||||
_setSequenceStopMode.UnregisterFunc();
|
||||
_getSequenceStopMode.UnregisterFunc();
|
||||
_setLevelStopMode.UnregisterFunc();
|
||||
_getLevelStopMode.UnregisterFunc();
|
||||
_getAlliedSocietiesWithAvailableQuests.UnregisterFunc();
|
||||
_getAlliedSocietyCurrentRank.UnregisterFunc();
|
||||
_getAlliedSocietyIsMaxRank.UnregisterFunc();
|
||||
|
|
@ -1271,5 +1451,10 @@ internal sealed class QuestionableIpc : IDisposable
|
|||
_getAlliedSocietyRemainingAllowances.UnregisterFunc();
|
||||
_addAlliedSocietyOptimalQuests.UnregisterFunc();
|
||||
_getAlliedSocietyOptimalQuests.UnregisterFunc();
|
||||
_stopLevelingMode.UnregisterFunc();
|
||||
_startLevelingMode.UnregisterFunc();
|
||||
_getMsqLevelLockInfo.UnregisterFunc();
|
||||
_setLevelingModeEnabled.UnregisterFunc();
|
||||
_isLevelingModeEnabled.UnregisterFunc();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue