 14575a4a6b
			
		
	
	14575a4a6b
	
	
	
		
			
			* add jwt expiry * start of 0.9 api impl * some stuff idk * some more impl * some cleanup * remove grouppair, add configuration, rework some pair drawing stuff * do some stuff * rework some ui * I don't even know anymore * add cancellationtoken * token bla * ui fixes etc * probably individual adding/removing now working fully as expected * add working report popup * I guess it's more syncshell shit or so * popup shit idk * work out most of the syncshell bullshit I guess * delete some old crap * are we actually getting closer to the end * update pair info stuff * more fixes/adjustments, idk * refactor some things * some rework * some more cleanup * cleanup * make menu buttons w i d e * better icon text buttons * add all syncshell folder and ordering fixes --------- Co-authored-by: rootdarkarchon <root.darkarchon@outlook.com>
		
			
				
	
	
		
			156 lines
		
	
	
		
			9.7 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			156 lines
		
	
	
		
			9.7 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using Dalamud.ContextMenu;
 | |
| using Dalamud.Interface.ImGuiFileDialog;
 | |
| using Dalamud.Interface.Windowing;
 | |
| using Dalamud.Plugin;
 | |
| using Dalamud.Plugin.Services;
 | |
| using MareSynchronos.FileCache;
 | |
| using MareSynchronos.Interop;
 | |
| using MareSynchronos.MareConfiguration;
 | |
| using MareSynchronos.PlayerData.Export;
 | |
| using MareSynchronos.PlayerData.Factories;
 | |
| using MareSynchronos.PlayerData.Pairs;
 | |
| using MareSynchronos.PlayerData.Services;
 | |
| using MareSynchronos.Services;
 | |
| using MareSynchronos.Services.Mediator;
 | |
| using MareSynchronos.Services.ServerConfiguration;
 | |
| using MareSynchronos.UI;
 | |
| using MareSynchronos.UI.Components;
 | |
| using MareSynchronos.UI.Components.Popup;
 | |
| using MareSynchronos.UI.Handlers;
 | |
| using MareSynchronos.WebAPI;
 | |
| using MareSynchronos.WebAPI.Files;
 | |
| using MareSynchronos.WebAPI.SignalR;
 | |
| using Microsoft.Extensions.DependencyInjection;
 | |
| using Microsoft.Extensions.Hosting;
 | |
| using Microsoft.Extensions.Logging;
 | |
| 
 | |
| namespace MareSynchronos;
 | |
| 
 | |
| public sealed class Plugin : IDalamudPlugin
 | |
| {
 | |
|     private readonly CancellationTokenSource _pluginCts = new();
 | |
| 
 | |
|     public Plugin(DalamudPluginInterface pluginInterface, ICommandManager commandManager, IDataManager gameData,
 | |
|         IFramework framework, IObjectTable objectTable, IClientState clientState, ICondition condition, IChatGui chatGui,
 | |
|         IGameGui gameGui, IDtrBar dtrBar, IPluginLog pluginLog)
 | |
|     {
 | |
|         _ = new HostBuilder()
 | |
|         .UseContentRoot(pluginInterface.ConfigDirectory.FullName)
 | |
|         .ConfigureLogging(lb =>
 | |
|         {
 | |
|             lb.ClearProviders();
 | |
|             lb.AddDalamudLogging(pluginLog);
 | |
|             lb.SetMinimumLevel(LogLevel.Trace);
 | |
|         })
 | |
|         .ConfigureServices(collection =>
 | |
|         {
 | |
|             collection.AddSingleton(new WindowSystem("MareSynchronos"));
 | |
|             collection.AddSingleton<FileDialogManager>();
 | |
|             collection.AddSingleton(new Dalamud.Localization("MareSynchronos.Localization.", "", useEmbedded: true));
 | |
| 
 | |
|             // add mare related singletons
 | |
|             collection.AddSingleton<MareMediator>();
 | |
|             collection.AddSingleton<FileCacheManager>();
 | |
|             collection.AddSingleton<ServerConfigurationManager>();
 | |
|             collection.AddSingleton<PairManager>();
 | |
|             collection.AddSingleton<ApiController>();
 | |
|             collection.AddSingleton<MareCharaFileManager>();
 | |
|             collection.AddSingleton<PerformanceCollectorService>();
 | |
|             collection.AddSingleton<HubFactory>();
 | |
|             collection.AddSingleton<FileUploadManager>();
 | |
|             collection.AddSingleton<FileTransferOrchestrator>();
 | |
|             collection.AddSingleton<MarePlugin>();
 | |
|             collection.AddSingleton<MareProfileManager>();
 | |
|             collection.AddSingleton<GameObjectHandlerFactory>();
 | |
|             collection.AddSingleton<FileDownloadManagerFactory>();
 | |
|             collection.AddSingleton<PairHandlerFactory>();
 | |
|             collection.AddSingleton<PairFactory>();
 | |
|             collection.AddSingleton<CharacterAnalyzer>();
 | |
|             collection.AddSingleton<TokenProvider>();
 | |
|             collection.AddSingleton<PluginWarningNotificationService>();
 | |
|             collection.AddSingleton<FileCompactor>();
 | |
|             collection.AddSingleton<TagHandler>();
 | |
|             collection.AddSingleton<IdDisplayHandler>();
 | |
|             collection.AddSingleton<DrawEntityFactory>();
 | |
|             collection.AddSingleton<SelectPairForTagUi>();
 | |
|             collection.AddSingleton<SelectTagForPairUi>();
 | |
|             collection.AddSingleton((s) => new DalamudContextMenu(pluginInterface));
 | |
|             collection.AddSingleton((s) => new DalamudUtilService(s.GetRequiredService<ILogger<DalamudUtilService>>(),
 | |
|                 clientState, objectTable, framework, gameGui, condition, gameData,
 | |
|                 s.GetRequiredService<MareMediator>(), s.GetRequiredService<PerformanceCollectorService>()));
 | |
|             collection.AddSingleton((s) => new DtrEntry(s.GetRequiredService<ILogger<DtrEntry>>(), dtrBar, s.GetRequiredService<MareConfigService>(),
 | |
|                 s.GetRequiredService<MareMediator>(), s.GetRequiredService<PairManager>(), s.GetRequiredService<ApiController>()));
 | |
|             collection.AddSingleton((s) => new IpcManager(s.GetRequiredService<ILogger<IpcManager>>(),
 | |
|                 pluginInterface, s.GetRequiredService<DalamudUtilService>(), s.GetRequiredService<MareMediator>()));
 | |
| 
 | |
|             collection.AddSingleton((s) => new MareConfigService(pluginInterface.ConfigDirectory.FullName));
 | |
|             collection.AddSingleton((s) => new ServerConfigService(pluginInterface.ConfigDirectory.FullName));
 | |
|             collection.AddSingleton((s) => new NotesConfigService(pluginInterface.ConfigDirectory.FullName));
 | |
|             collection.AddSingleton((s) => new ServerTagConfigService(pluginInterface.ConfigDirectory.FullName));
 | |
|             collection.AddSingleton((s) => new TransientConfigService(pluginInterface.ConfigDirectory.FullName));
 | |
|             collection.AddSingleton((s) => new ConfigurationMigrator(s.GetRequiredService<ILogger<ConfigurationMigrator>>(), pluginInterface));
 | |
|             collection.AddSingleton((s) => new HubFactory(s.GetRequiredService<ILogger<HubFactory>>(), s.GetRequiredService<MareMediator>(),
 | |
|                 s.GetRequiredService<ServerConfigurationManager>(), s.GetRequiredService<MareConfigService>(),
 | |
|                 s.GetRequiredService<TokenProvider>(), pluginLog));
 | |
| 
 | |
|             // func factory method singletons
 | |
|             collection.AddSingleton(s =>
 | |
|                 new Func<Pair, StandaloneProfileUi>((pair) =>
 | |
|                     new StandaloneProfileUi(s.GetRequiredService<ILogger<StandaloneProfileUi>>(),
 | |
|                     s.GetRequiredService<MareMediator>(),
 | |
|                     s.GetRequiredService<UiSharedService>(),
 | |
|                     s.GetRequiredService<ServerConfigurationManager>(),
 | |
|                     s.GetRequiredService<MareProfileManager>(),
 | |
|                     s.GetRequiredService<PairManager>(), pair)));
 | |
| 
 | |
|             // add scoped services
 | |
|             collection.AddScoped<PeriodicFileScanner>();
 | |
|             collection.AddScoped<WindowMediatorSubscriberBase, SettingsUi>();
 | |
|             collection.AddScoped<WindowMediatorSubscriberBase, CompactUi>();
 | |
|             collection.AddScoped<WindowMediatorSubscriberBase, GposeUi>();
 | |
|             collection.AddScoped<WindowMediatorSubscriberBase, IntroUi>();
 | |
|             collection.AddScoped<WindowMediatorSubscriberBase, DownloadUi>();
 | |
|             collection.AddScoped<WindowMediatorSubscriberBase, PopoutProfileUi>();
 | |
|             collection.AddScoped<WindowMediatorSubscriberBase, DataAnalysisUi>();
 | |
|             collection.AddScoped<WindowMediatorSubscriberBase, EditProfileUi>((s) => new EditProfileUi(s.GetRequiredService<ILogger<EditProfileUi>>(),
 | |
|                 s.GetRequiredService<MareMediator>(), s.GetRequiredService<ApiController>(), pluginInterface.UiBuilder, s.GetRequiredService<UiSharedService>(),
 | |
|                 s.GetRequiredService<FileDialogManager>(), s.GetRequiredService<MareProfileManager>()));
 | |
|             collection.AddScoped<WindowMediatorSubscriberBase, PopupHandler>();
 | |
|             collection.AddScoped<IPopupHandler, ReportPopupHandler>();
 | |
|             collection.AddScoped<IPopupHandler, BanUserPopupHandler>();
 | |
|             collection.AddScoped<IPopupHandler, CreateSyncshellPopupHandler>();
 | |
|             collection.AddScoped<IPopupHandler, JoinSyncshellPopupHandler>();
 | |
|             collection.AddScoped<IPopupHandler, SyncshellAdminPopupHandler>();
 | |
|             collection.AddScoped<CacheCreationService>();
 | |
|             collection.AddScoped<TransientResourceManager>();
 | |
|             collection.AddScoped<PlayerDataFactory>();
 | |
|             collection.AddScoped<OnlinePlayerManager>();
 | |
|             collection.AddScoped((s) => new UiService(s.GetRequiredService<ILogger<UiService>>(), pluginInterface, s.GetRequiredService<MareConfigService>(),
 | |
|                 s.GetRequiredService<WindowSystem>(), s.GetServices<WindowMediatorSubscriberBase>(), s.GetRequiredService<Func<Pair, StandaloneProfileUi>>(),
 | |
|                 s.GetRequiredService<FileDialogManager>(), s.GetRequiredService<MareMediator>()));
 | |
|             collection.AddScoped((s) => new CommandManagerService(commandManager, s.GetRequiredService<PerformanceCollectorService>(),
 | |
|                 s.GetRequiredService<ServerConfigurationManager>(), s.GetRequiredService<PeriodicFileScanner>(), s.GetRequiredService<ApiController>(),
 | |
|                 s.GetRequiredService<MareMediator>()));
 | |
|             collection.AddScoped((s) => new NotificationService(s.GetRequiredService<ILogger<NotificationService>>(),
 | |
|                 s.GetRequiredService<MareMediator>(), pluginInterface.UiBuilder, chatGui, s.GetRequiredService<MareConfigService>()));
 | |
|             collection.AddScoped((s) => new UiSharedService(s.GetRequiredService<ILogger<UiSharedService>>(), s.GetRequiredService<IpcManager>(), s.GetRequiredService<ApiController>(),
 | |
|                 s.GetRequiredService<PeriodicFileScanner>(), s.GetRequiredService<FileDialogManager>(), s.GetRequiredService<MareConfigService>(), s.GetRequiredService<DalamudUtilService>(),
 | |
|                 pluginInterface, s.GetRequiredService<Dalamud.Localization>(), s.GetRequiredService<ServerConfigurationManager>(), s.GetRequiredService<MareMediator>()));
 | |
| 
 | |
|             collection.AddHostedService(p => p.GetRequiredService<MareMediator>());
 | |
|             collection.AddHostedService(p => p.GetRequiredService<ConfigurationMigrator>());
 | |
|             collection.AddHostedService(p => p.GetRequiredService<DalamudUtilService>());
 | |
|             collection.AddHostedService(p => p.GetRequiredService<PerformanceCollectorService>());
 | |
|             collection.AddHostedService(p => p.GetRequiredService<DtrEntry>());
 | |
|             collection.AddHostedService(p => p.GetRequiredService<MarePlugin>());
 | |
|         })
 | |
|         .Build()
 | |
|         .RunAsync(_pluginCts.Token);
 | |
|     }
 | |
| 
 | |
|     public void Dispose()
 | |
|     {
 | |
|         _pluginCts.Cancel();
 | |
|         _pluginCts.Dispose();
 | |
|     }
 | |
| } |