2024-05-26 21:45:26 +02:00
|
|
|
|
using System;
|
2024-06-08 21:16:57 +02:00
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
|
using Dalamud.Extensions.MicrosoftLogging;
|
2024-05-25 23:51:37 +02:00
|
|
|
|
using Dalamud.Game;
|
|
|
|
|
using Dalamud.Game.ClientState.Objects;
|
|
|
|
|
using Dalamud.Interface.Windowing;
|
|
|
|
|
using Dalamud.Plugin;
|
|
|
|
|
using Dalamud.Plugin.Services;
|
2024-06-08 21:16:57 +02:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
2024-05-25 23:51:37 +02:00
|
|
|
|
using Questionable.Controller;
|
2024-07-14 03:42:30 +02:00
|
|
|
|
using Questionable.Controller.CombatModules;
|
2024-08-18 01:55:38 +02:00
|
|
|
|
using Questionable.Controller.GameUi;
|
2024-07-12 10:31:34 +02:00
|
|
|
|
using Questionable.Controller.NavigationOverrides;
|
2024-08-14 09:28:41 +02:00
|
|
|
|
using Questionable.Controller.Steps;
|
2024-07-12 21:18:53 +02:00
|
|
|
|
using Questionable.Controller.Steps.Shared;
|
|
|
|
|
using Questionable.Controller.Steps.Common;
|
2024-08-03 11:17:20 +02:00
|
|
|
|
using Questionable.Controller.Steps.Gathering;
|
2024-07-12 21:18:53 +02:00
|
|
|
|
using Questionable.Controller.Steps.Interactions;
|
2024-08-08 01:49:14 +02:00
|
|
|
|
using Questionable.Controller.Steps.Leves;
|
2024-05-27 21:54:34 +02:00
|
|
|
|
using Questionable.Data;
|
2024-05-25 23:51:37 +02:00
|
|
|
|
using Questionable.External;
|
2024-08-05 17:09:49 +02:00
|
|
|
|
using Questionable.Functions;
|
2024-07-16 00:18:10 +02:00
|
|
|
|
using Questionable.Validation;
|
|
|
|
|
using Questionable.Validation.Validators;
|
2024-05-25 23:51:37 +02:00
|
|
|
|
using Questionable.Windows;
|
2024-08-18 19:51:24 +02:00
|
|
|
|
using Questionable.Windows.JournalComponents;
|
2024-07-21 15:30:10 +02:00
|
|
|
|
using Questionable.Windows.QuestComponents;
|
2024-07-12 21:18:53 +02:00
|
|
|
|
using Action = Questionable.Controller.Steps.Interactions.Action;
|
2024-05-25 23:51:37 +02:00
|
|
|
|
|
|
|
|
|
namespace Questionable;
|
|
|
|
|
|
2024-06-08 21:16:57 +02:00
|
|
|
|
[SuppressMessage("ReSharper", "UnusedType.Global")]
|
2024-05-27 21:54:34 +02:00
|
|
|
|
public sealed class QuestionablePlugin : IDalamudPlugin
|
2024-05-25 23:51:37 +02:00
|
|
|
|
{
|
2024-06-08 21:16:57 +02:00
|
|
|
|
private readonly ServiceProvider? _serviceProvider;
|
|
|
|
|
|
2024-07-03 21:00:04 +02:00
|
|
|
|
public QuestionablePlugin(IDalamudPluginInterface pluginInterface,
|
2024-06-08 21:16:57 +02:00
|
|
|
|
IClientState clientState,
|
|
|
|
|
ITargetManager targetManager,
|
|
|
|
|
IFramework framework,
|
|
|
|
|
IGameGui gameGui,
|
|
|
|
|
IDataManager dataManager,
|
|
|
|
|
ISigScanner sigScanner,
|
|
|
|
|
IObjectTable objectTable,
|
|
|
|
|
IPluginLog pluginLog,
|
|
|
|
|
ICondition condition,
|
|
|
|
|
IChatGui chatGui,
|
|
|
|
|
ICommandManager commandManager,
|
2024-06-09 16:30:53 +02:00
|
|
|
|
IAddonLifecycle addonLifecycle,
|
2024-08-04 16:03:23 +02:00
|
|
|
|
IKeyState keyState,
|
2024-08-09 23:58:19 +02:00
|
|
|
|
IContextMenu contextMenu,
|
2024-08-18 01:55:38 +02:00
|
|
|
|
IToastGui toastGui,
|
|
|
|
|
IGameInteropProvider gameInteropProvider)
|
2024-05-25 23:51:37 +02:00
|
|
|
|
{
|
2024-05-26 21:45:26 +02:00
|
|
|
|
ArgumentNullException.ThrowIfNull(pluginInterface);
|
2024-08-05 17:09:49 +02:00
|
|
|
|
ArgumentNullException.ThrowIfNull(chatGui);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ServiceCollection serviceCollection = new();
|
|
|
|
|
serviceCollection.AddLogging(builder => builder.SetMinimumLevel(LogLevel.Trace)
|
|
|
|
|
.ClearProviders()
|
|
|
|
|
.AddDalamudLogger(pluginLog, t => t[(t.LastIndexOf('.') + 1)..]));
|
|
|
|
|
serviceCollection.AddSingleton<IDalamudPlugin>(this);
|
|
|
|
|
serviceCollection.AddSingleton(pluginInterface);
|
|
|
|
|
serviceCollection.AddSingleton(clientState);
|
|
|
|
|
serviceCollection.AddSingleton(targetManager);
|
|
|
|
|
serviceCollection.AddSingleton(framework);
|
|
|
|
|
serviceCollection.AddSingleton(gameGui);
|
|
|
|
|
serviceCollection.AddSingleton(dataManager);
|
|
|
|
|
serviceCollection.AddSingleton(sigScanner);
|
|
|
|
|
serviceCollection.AddSingleton(objectTable);
|
|
|
|
|
serviceCollection.AddSingleton(pluginLog);
|
|
|
|
|
serviceCollection.AddSingleton(condition);
|
|
|
|
|
serviceCollection.AddSingleton(chatGui);
|
|
|
|
|
serviceCollection.AddSingleton(commandManager);
|
|
|
|
|
serviceCollection.AddSingleton(addonLifecycle);
|
|
|
|
|
serviceCollection.AddSingleton(keyState);
|
|
|
|
|
serviceCollection.AddSingleton(contextMenu);
|
2024-08-09 23:58:19 +02:00
|
|
|
|
serviceCollection.AddSingleton(toastGui);
|
2024-08-18 01:55:38 +02:00
|
|
|
|
serviceCollection.AddSingleton(gameInteropProvider);
|
2024-08-05 17:09:49 +02:00
|
|
|
|
serviceCollection.AddSingleton(new WindowSystem(nameof(Questionable)));
|
|
|
|
|
serviceCollection.AddSingleton((Configuration?)pluginInterface.GetPluginConfig() ?? new Configuration());
|
|
|
|
|
|
|
|
|
|
AddBasicFunctionsAndData(serviceCollection);
|
|
|
|
|
AddTaskFactories(serviceCollection);
|
|
|
|
|
AddControllers(serviceCollection);
|
|
|
|
|
AddWindows(serviceCollection);
|
|
|
|
|
AddQuestValidators(serviceCollection);
|
|
|
|
|
|
|
|
|
|
serviceCollection.AddSingleton<CommandHandler>();
|
|
|
|
|
serviceCollection.AddSingleton<DalamudInitializer>();
|
|
|
|
|
|
|
|
|
|
_serviceProvider = serviceCollection.BuildServiceProvider();
|
|
|
|
|
Initialize(_serviceProvider);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
chatGui.PrintError("Unable to load plugin, check /xllog for details", "Questionable");
|
|
|
|
|
throw;
|
|
|
|
|
}
|
2024-07-17 15:05:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void AddBasicFunctionsAndData(ServiceCollection serviceCollection)
|
|
|
|
|
{
|
2024-08-11 02:29:34 +02:00
|
|
|
|
serviceCollection.AddSingleton<AetheryteFunctions>();
|
2024-08-05 17:09:49 +02:00
|
|
|
|
serviceCollection.AddSingleton<ExcelFunctions>();
|
2024-06-08 21:16:57 +02:00
|
|
|
|
serviceCollection.AddSingleton<GameFunctions>();
|
2024-06-20 21:55:48 +02:00
|
|
|
|
serviceCollection.AddSingleton<ChatFunctions>();
|
2024-08-05 17:09:49 +02:00
|
|
|
|
serviceCollection.AddSingleton<QuestFunctions>();
|
|
|
|
|
|
2024-07-08 20:46:01 +02:00
|
|
|
|
serviceCollection.AddSingleton<AetherCurrentData>();
|
2024-06-08 21:16:57 +02:00
|
|
|
|
serviceCollection.AddSingleton<AetheryteData>();
|
2024-08-03 11:17:20 +02:00
|
|
|
|
serviceCollection.AddSingleton<GatheringData>();
|
2024-08-08 01:49:14 +02:00
|
|
|
|
serviceCollection.AddSingleton<LeveData>();
|
2024-07-29 16:54:18 +02:00
|
|
|
|
serviceCollection.AddSingleton<JournalData>();
|
2024-07-11 02:56:42 +02:00
|
|
|
|
serviceCollection.AddSingleton<QuestData>();
|
2024-06-08 21:16:57 +02:00
|
|
|
|
serviceCollection.AddSingleton<TerritoryData>();
|
|
|
|
|
serviceCollection.AddSingleton<NavmeshIpc>();
|
|
|
|
|
serviceCollection.AddSingleton<LifestreamIpc>();
|
2024-06-16 17:43:42 +02:00
|
|
|
|
serviceCollection.AddSingleton<YesAlreadyIpc>();
|
2024-08-16 20:42:11 +02:00
|
|
|
|
serviceCollection.AddSingleton<ArtisanIpc>();
|
2024-08-31 14:03:53 +02:00
|
|
|
|
serviceCollection.AddSingleton<QuestionableIpc>();
|
2024-07-17 15:05:24 +02:00
|
|
|
|
}
|
2024-06-08 21:16:57 +02:00
|
|
|
|
|
2024-07-17 15:05:24 +02:00
|
|
|
|
private static void AddTaskFactories(ServiceCollection serviceCollection)
|
|
|
|
|
{
|
2024-06-09 16:30:53 +02:00
|
|
|
|
// individual tasks
|
2024-08-03 11:17:20 +02:00
|
|
|
|
serviceCollection.AddTransient<MoveToLandingLocation>();
|
2024-08-03 17:26:49 +02:00
|
|
|
|
serviceCollection.AddTransient<DoGather>();
|
|
|
|
|
serviceCollection.AddTransient<DoGatherCollectable>();
|
2024-08-05 17:09:49 +02:00
|
|
|
|
serviceCollection.AddTransient<SwitchClassJob>();
|
2024-08-20 02:48:06 +02:00
|
|
|
|
serviceCollection.AddSingleton<Mount.Factory>();
|
2024-06-09 16:30:53 +02:00
|
|
|
|
|
2024-07-17 15:05:24 +02:00
|
|
|
|
// task factories
|
2024-08-20 02:48:06 +02:00
|
|
|
|
serviceCollection.AddTaskFactory<StepDisabled.Factory>();
|
|
|
|
|
serviceCollection.AddTaskFactory<EquipRecommended.BeforeDutyOrInstance>();
|
|
|
|
|
serviceCollection.AddTaskFactory<GatheringRequiredItems.Factory>();
|
|
|
|
|
serviceCollection.AddTaskFactory<AetheryteShortcut.Factory>();
|
|
|
|
|
serviceCollection.AddTaskFactory<SkipCondition.Factory>();
|
|
|
|
|
serviceCollection.AddTaskFactory<AethernetShortcut.Factory>();
|
|
|
|
|
serviceCollection.AddTaskFactory<WaitAtStart.Factory>();
|
|
|
|
|
serviceCollection.AddTaskFactory<MoveTo.Factory>();
|
2024-06-09 16:30:53 +02:00
|
|
|
|
|
2024-08-20 02:48:06 +02:00
|
|
|
|
serviceCollection.AddTaskFactory<NextQuest.Factory>();
|
|
|
|
|
serviceCollection.AddTaskFactory<AetherCurrent.Factory>();
|
|
|
|
|
serviceCollection.AddTaskFactory<AethernetShard.Factory>();
|
|
|
|
|
serviceCollection.AddTaskFactory<Aetheryte.Factory>();
|
|
|
|
|
serviceCollection.AddTaskFactory<Combat.Factory>();
|
|
|
|
|
serviceCollection.AddTaskFactory<Duty.Factory>();
|
|
|
|
|
serviceCollection.AddTaskFactory<Emote.Factory>();
|
|
|
|
|
serviceCollection.AddTaskFactory<Action.Factory>();
|
|
|
|
|
serviceCollection.AddTaskFactory<Interact.Factory>();
|
|
|
|
|
serviceCollection.AddTaskFactory<Jump.Factory>();
|
|
|
|
|
serviceCollection.AddTaskFactory<Dive.Factory>();
|
|
|
|
|
serviceCollection.AddTaskFactory<Say.Factory>();
|
|
|
|
|
serviceCollection.AddTaskFactory<UseItem.Factory>();
|
|
|
|
|
serviceCollection.AddTaskFactory<EquipItem.Factory>();
|
|
|
|
|
serviceCollection.AddTaskFactory<EquipRecommended.Factory>();
|
|
|
|
|
serviceCollection.AddTaskFactory<Craft.Factory>();
|
|
|
|
|
serviceCollection.AddTaskFactory<TurnInDelivery.Factory>();
|
|
|
|
|
serviceCollection.AddTaskFactory<InitiateLeve.Factory>();
|
2024-06-09 16:30:53 +02:00
|
|
|
|
|
2024-08-20 02:48:06 +02:00
|
|
|
|
serviceCollection.AddTaskFactory<WaitAtEnd.Factory>();
|
2024-06-24 18:15:45 +02:00
|
|
|
|
serviceCollection.AddTransient<WaitAtEnd.WaitQuestAccepted>();
|
|
|
|
|
serviceCollection.AddTransient<WaitAtEnd.WaitQuestCompleted>();
|
2024-08-16 01:21:15 +02:00
|
|
|
|
|
|
|
|
|
serviceCollection.AddSingleton<TaskCreator>();
|
2024-07-17 15:05:24 +02:00
|
|
|
|
}
|
2024-06-09 16:30:53 +02:00
|
|
|
|
|
2024-07-17 15:05:24 +02:00
|
|
|
|
private static void AddControllers(ServiceCollection serviceCollection)
|
|
|
|
|
{
|
2024-06-08 21:16:57 +02:00
|
|
|
|
serviceCollection.AddSingleton<MovementController>();
|
2024-07-12 10:31:34 +02:00
|
|
|
|
serviceCollection.AddSingleton<MovementOverrideController>();
|
2024-08-05 20:00:02 +02:00
|
|
|
|
serviceCollection.AddSingleton<GatheringPointRegistry>();
|
2024-06-08 21:16:57 +02:00
|
|
|
|
serviceCollection.AddSingleton<QuestRegistry>();
|
|
|
|
|
serviceCollection.AddSingleton<QuestController>();
|
2024-07-14 03:42:30 +02:00
|
|
|
|
serviceCollection.AddSingleton<CombatController>();
|
2024-08-03 11:17:20 +02:00
|
|
|
|
serviceCollection.AddSingleton<GatheringController>();
|
2024-08-04 16:03:23 +02:00
|
|
|
|
serviceCollection.AddSingleton<ContextMenuController>();
|
2024-07-14 03:42:30 +02:00
|
|
|
|
|
2024-08-18 01:55:38 +02:00
|
|
|
|
serviceCollection.AddSingleton<CraftworksSupplyController>();
|
|
|
|
|
serviceCollection.AddSingleton<CreditsController>();
|
|
|
|
|
serviceCollection.AddSingleton<HelpUiController>();
|
|
|
|
|
serviceCollection.AddSingleton<InteractionUiController>();
|
|
|
|
|
serviceCollection.AddSingleton<LeveUiController>();
|
|
|
|
|
|
2024-09-01 15:14:28 +02:00
|
|
|
|
serviceCollection.AddSingleton<ICombatModule, Mount128Module>();
|
2024-07-14 03:42:30 +02:00
|
|
|
|
serviceCollection.AddSingleton<ICombatModule, RotationSolverRebornModule>();
|
2024-07-17 15:05:24 +02:00
|
|
|
|
}
|
2024-06-08 21:16:57 +02:00
|
|
|
|
|
2024-07-17 15:05:24 +02:00
|
|
|
|
private static void AddWindows(ServiceCollection serviceCollection)
|
|
|
|
|
{
|
2024-07-21 15:30:10 +02:00
|
|
|
|
serviceCollection.AddSingleton<UiUtils>();
|
|
|
|
|
|
|
|
|
|
serviceCollection.AddSingleton<ActiveQuestComponent>();
|
|
|
|
|
serviceCollection.AddSingleton<ARealmRebornComponent>();
|
|
|
|
|
serviceCollection.AddSingleton<CreationUtilsComponent>();
|
2024-08-19 15:19:15 +02:00
|
|
|
|
serviceCollection.AddSingleton<EventInfoComponent>();
|
2024-07-29 16:54:18 +02:00
|
|
|
|
serviceCollection.AddSingleton<QuestTooltipComponent>();
|
2024-07-21 15:30:10 +02:00
|
|
|
|
serviceCollection.AddSingleton<QuickAccessButtonsComponent>();
|
|
|
|
|
serviceCollection.AddSingleton<RemainingTasksComponent>();
|
|
|
|
|
|
2024-08-18 19:51:24 +02:00
|
|
|
|
serviceCollection.AddSingleton<QuestJournalComponent>();
|
|
|
|
|
serviceCollection.AddSingleton<GatheringJournalComponent>();
|
|
|
|
|
|
2024-06-18 17:51:23 +02:00
|
|
|
|
serviceCollection.AddSingleton<QuestWindow>();
|
2024-06-12 18:03:48 +02:00
|
|
|
|
serviceCollection.AddSingleton<ConfigWindow>();
|
2024-06-18 17:51:23 +02:00
|
|
|
|
serviceCollection.AddSingleton<DebugOverlay>();
|
2024-07-14 21:31:07 +02:00
|
|
|
|
serviceCollection.AddSingleton<QuestSelectionWindow>();
|
2024-07-16 00:18:10 +02:00
|
|
|
|
serviceCollection.AddSingleton<QuestValidationWindow>();
|
2024-07-29 16:54:18 +02:00
|
|
|
|
serviceCollection.AddSingleton<JournalProgressWindow>();
|
2024-08-25 01:30:42 +02:00
|
|
|
|
serviceCollection.AddSingleton<PriorityWindow>();
|
2024-07-17 15:05:24 +02:00
|
|
|
|
}
|
2024-07-16 00:18:10 +02:00
|
|
|
|
|
2024-07-17 15:05:24 +02:00
|
|
|
|
private static void AddQuestValidators(ServiceCollection serviceCollection)
|
|
|
|
|
{
|
2024-07-16 00:18:10 +02:00
|
|
|
|
serviceCollection.AddSingleton<QuestValidator>();
|
|
|
|
|
serviceCollection.AddSingleton<IQuestValidator, QuestDisabledValidator>();
|
|
|
|
|
serviceCollection.AddSingleton<IQuestValidator, BasicSequenceValidator>();
|
|
|
|
|
serviceCollection.AddSingleton<IQuestValidator, UniqueStartStopValidator>();
|
2024-07-16 14:43:31 +02:00
|
|
|
|
serviceCollection.AddSingleton<IQuestValidator, NextQuestValidator>();
|
2024-07-16 00:18:10 +02:00
|
|
|
|
serviceCollection.AddSingleton<IQuestValidator, CompletionFlagsValidator>();
|
2024-07-28 00:13:52 +02:00
|
|
|
|
serviceCollection.AddSingleton<IQuestValidator, AethernetShortcutValidator>();
|
2024-08-05 17:09:49 +02:00
|
|
|
|
serviceCollection.AddSingleton<IQuestValidator, DialogueChoiceValidator>();
|
2024-07-17 15:05:24 +02:00
|
|
|
|
serviceCollection.AddSingleton<JsonSchemaValidator>();
|
|
|
|
|
serviceCollection.AddSingleton<IQuestValidator>(sp => sp.GetRequiredService<JsonSchemaValidator>());
|
2024-05-25 23:51:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-05 17:09:49 +02:00
|
|
|
|
private static void Initialize(IServiceProvider serviceProvider)
|
|
|
|
|
{
|
|
|
|
|
serviceProvider.GetRequiredService<QuestRegistry>().Reload();
|
2024-08-05 20:00:02 +02:00
|
|
|
|
serviceProvider.GetRequiredService<GatheringPointRegistry>().Reload();
|
2024-08-05 17:09:49 +02:00
|
|
|
|
serviceProvider.GetRequiredService<CommandHandler>();
|
|
|
|
|
serviceProvider.GetRequiredService<ContextMenuController>();
|
2024-08-18 01:55:38 +02:00
|
|
|
|
serviceProvider.GetRequiredService<CraftworksSupplyController>();
|
|
|
|
|
serviceProvider.GetRequiredService<CreditsController>();
|
|
|
|
|
serviceProvider.GetRequiredService<HelpUiController>();
|
|
|
|
|
serviceProvider.GetRequiredService<LeveUiController>();
|
2024-08-31 14:03:53 +02:00
|
|
|
|
serviceProvider.GetRequiredService<QuestionableIpc>();
|
2024-08-05 17:09:49 +02:00
|
|
|
|
serviceProvider.GetRequiredService<DalamudInitializer>();
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-25 23:51:37 +02:00
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
2024-06-08 21:16:57 +02:00
|
|
|
|
_serviceProvider?.Dispose();
|
2024-05-25 23:51:37 +02:00
|
|
|
|
}
|
|
|
|
|
}
|