[Draft] Update 0.8 (#46)

* move stuff out into file transfer manager

* obnoxious unsupported version text, adjustments to filetransfermanager

* add back file upload transfer progress

* restructure code

* cleanup some more stuff I guess

* downloadids by playername

* individual anim/sound bs

* fix migration stuff, finalize impl of individual sound/anim pause

* fixes with logging stuff

* move download manager to transient

* rework dl ui first iteration

* some refactoring and cleanup

* more code cleanup

* refactoring

* switch to hostbuilder

* some more rework I guess

* more refactoring

* clean up mediator calls and disposal

* fun code cleanup

* push error message when log level is set to anything but information in non-debug builds

* remove notificationservice

* move message to after login

* add download bars to gameworld

* fixes download progress bar

* set gpose ui min and max size

* remove unnecessary usings

* adjustments to reconnection logic

* add options to set visible/offline groups visibility

* add impl of uploading display, transfer list in settings ui

* attempt to fix issues with server selection

* add back download status to compact ui

* make dl bar fixed size based

* some fixes for upload/download handling

* adjust text from Syncing back to Uploading

---------

Co-authored-by: rootdarkarchon <root.darkarchon@outlook.com>
Co-authored-by: Stanley Dimant <stanley.dimant@varian.com>
This commit is contained in:
rootdarkarchon
2023-03-14 19:48:35 +01:00
committed by GitHub
parent 0824ba434b
commit 0c87e84f25
109 changed files with 7323 additions and 6488 deletions

View File

@@ -1,109 +1,150 @@
using Dalamud.Game.Command;
using Dalamud.Plugin;
using MareSynchronos.Factories;
using Dalamud.Data;
using Dalamud.Game;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.ClientState;
using Dalamud.Interface.ImGuiFileDialog;
using MareSynchronos.Managers;
using MareSynchronos.WebAPI;
using Dalamud.Interface.Windowing;
using MareSynchronos.UI;
using MareSynchronos.Utils;
using Dalamud.Game.ClientState.Conditions;
using MareSynchronos.FileCache;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.Command;
using Dalamud.Game.Gui;
using MareSynchronos.Export;
using Dalamud.Data;
using Dalamud.Interface.ImGuiFileDialog;
using Dalamud.Interface.Windowing;
using Dalamud.Plugin;
using MareSynchronos.API.Data.Enum;
using MareSynchronos.API.Dto.User;
using MareSynchronos.FileCache;
using MareSynchronos.Interop;
using MareSynchronos.MareConfiguration;
using MareSynchronos.Mediator;
using MareSynchronos.PlayerData.Export;
using MareSynchronos.PlayerData.Factories;
using MareSynchronos.PlayerData.Handlers;
using MareSynchronos.PlayerData.Pairs;
using MareSynchronos.PlayerData.Services;
using MareSynchronos.Services;
using MareSynchronos.Services.Mediator;
using MareSynchronos.Services.ServerConfiguration;
using MareSynchronos.UI;
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 MarePlugin _plugin;
public string Name => "Mare Synchronos";
private readonly ILogger<Plugin> _pluginLogger;
private readonly CancellationTokenSource _pluginCts = new();
public Plugin(DalamudPluginInterface pluginInterface, CommandManager commandManager, DataManager gameData,
Framework framework, ObjectTable objectTable, ClientState clientState, Condition condition, ChatGui chatGui)
Framework framework, ObjectTable objectTable, ClientState clientState, Condition condition, ChatGui chatGui,
GameGui gameGui)
{
IServiceCollection collection = new ServiceCollection();
collection.AddLogging(o =>
new HostBuilder()
.UseContentRoot(pluginInterface.ConfigDirectory.FullName)
.ConfigureLogging(lb =>
{
o.AddDalamudLogging();
o.SetMinimumLevel(LogLevel.Trace);
});
lb.ClearProviders();
lb.AddDalamudLogging();
lb.SetMinimumLevel(LogLevel.Trace);
})
.ConfigureServices(collection =>
{
collection.AddSingleton(new WindowSystem("MareSynchronos"));
collection.AddSingleton<FileDialogManager>();
collection.AddSingleton(new Dalamud.Localization("MareSynchronos.Localization.", "", useEmbedded: true));
// inject dalamud stuff
collection.AddSingleton(pluginInterface);
collection.AddSingleton(commandManager);
collection.AddSingleton(gameData);
collection.AddSingleton(framework);
collection.AddSingleton(objectTable);
collection.AddSingleton(clientState);
collection.AddSingleton(condition);
collection.AddSingleton(chatGui);
collection.AddSingleton(pluginInterface.UiBuilder);
collection.AddSingleton(new WindowSystem("MareSynchronos"));
collection.AddSingleton<FileDialogManager>();
// 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((s) => new DalamudUtilService(s.GetRequiredService<ILogger<DalamudUtilService>>(),
clientState, objectTable, framework, gameGui, condition, gameData,
s.GetRequiredService<MareMediator>(), s.GetRequiredService<PerformanceCollectorService>()));
collection.AddSingleton((s) => new IpcManager(s.GetRequiredService<ILogger<IpcManager>>(),
pluginInterface, s.GetRequiredService<DalamudUtilService>(), s.GetRequiredService<MareMediator>()));
// add mare related stuff
collection.AddSingleton(new Dalamud.Localization("MareSynchronos.Localization.", "", useEmbedded: true));
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<ConfigurationMigrator>();
collection.AddSingleton<MareConfigService>();
collection.AddSingleton<ServerTagConfigService>();
collection.AddSingleton<TransientConfigService>();
collection.AddSingleton<NotesConfigService>();
collection.AddSingleton<ServerConfigService>();
collection.AddSingleton<MareMediator>();
collection.AddSingleton<DalamudUtil>();
collection.AddSingleton<IpcManager>();
collection.AddSingleton<FileCacheManager>();
collection.AddSingleton<CachedPlayerFactory>();
collection.AddSingleton<PairFactory>();
collection.AddSingleton<ServerConfigurationManager>();
collection.AddSingleton<PairManager>();
collection.AddSingleton<ApiController>();
collection.AddSingleton<PeriodicFileScanner>();
collection.AddSingleton<MareCharaFileManager>();
collection.AddSingleton<NotificationService>();
collection.AddSingleton<GameObjectHandlerFactory>();
collection.AddSingleton<PerformanceCollector>();
collection.AddSingleton<HubFactory>();
// func factory method singletons
collection.AddSingleton(s =>
new Func<ObjectKind, Func<nint>, bool, GameObjectHandler>((o, f, b)
=> new GameObjectHandler(s.GetRequiredService<ILogger<GameObjectHandler>>(),
s.GetRequiredService<PerformanceCollectorService>(),
s.GetRequiredService<MareMediator>(),
s.GetRequiredService<DalamudUtilService>(),
o, f, b)));
collection.AddSingleton(s =>
new Func<OnlineUserIdentDto, CachedPlayer>((o)
=> new CachedPlayer(s.GetRequiredService<ILogger<CachedPlayer>>(),
o,
s.GetRequiredService<Func<ObjectKind, Func<nint>, bool, GameObjectHandler>>(),
s.GetRequiredService<IpcManager>(),
s.GetRequiredService<Func<FileDownloadManager>>().Invoke(),
s.GetRequiredService<DalamudUtilService>(),
s.GetRequiredService<IHostApplicationLifetime>(),
s.GetRequiredService<FileCacheManager>(),
s.GetRequiredService<MareMediator>())));
collection.AddSingleton(s =>
new Func<Pair>(()
=> new Pair(s.GetRequiredService<ILogger<Pair>>(),
s.GetRequiredService<Func<OnlineUserIdentDto, CachedPlayer>>(),
s.GetRequiredService<MareConfigService>(),
s.GetRequiredService<ServerConfigurationManager>())));
collection.AddSingleton(s =>
new Func<FileDownloadManager>(()
=> new FileDownloadManager(s.GetRequiredService<ILogger<FileDownloadManager>>(),
s.GetRequiredService<MareMediator>(),
s.GetRequiredService<FileTransferOrchestrator>(),
s.GetRequiredService<FileCacheManager>())));
collection.AddSingleton<UiShared>();
collection.AddSingleton<SettingsUi>();
collection.AddSingleton<CompactUi>();
collection.AddSingleton<GposeUi>();
collection.AddSingleton<IntroUi>();
collection.AddSingleton<DownloadUi>();
// 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<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<FileDialogManager>(), s.GetRequiredService<MareMediator>()));
collection.AddScoped((s) => new CommandManagerService(commandManager, s.GetRequiredService<PerformanceCollectorService>(), s.GetRequiredService<UiService>(),
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.AddScoped<CacheCreationService>();
collection.AddScoped<TransientResourceManager>();
collection.AddScoped<CharacterDataFactory>();
collection.AddScoped<OnlinePlayerManager>();
var serviceProvider = collection.BuildServiceProvider(new ServiceProviderOptions() { ValidateOnBuild = true, ValidateScopes = true });
_pluginLogger = serviceProvider.GetRequiredService<ILogger<Plugin>>();
_pluginLogger.LogDebug("Launching " + Name);
serviceProvider.GetRequiredService<Dalamud.Localization>().SetupWithLangCode("en");
serviceProvider.GetRequiredService<DalamudPluginInterface>().UiBuilder.DisableGposeUiHide = true;
var mediator = serviceProvider.GetRequiredService<MareMediator>();
var logger = serviceProvider.GetRequiredService<ILogger<MarePlugin>>();
_plugin = new MarePlugin(logger, serviceProvider, mediator);
collection.AddHostedService(p => p.GetRequiredService<DalamudUtilService>());
collection.AddHostedService(p => p.GetRequiredService<ConfigurationMigrator>());
collection.AddHostedService(p => p.GetRequiredService<PerformanceCollectorService>());
collection.AddHostedService(p => p.GetRequiredService<MarePlugin>());
})
.Build()
.RunAsync(_pluginCts.Token);
}
public string Name => "Mare Synchronos";
public void Dispose()
{
_pluginLogger.LogTrace($"Disposing {GetType()}");
_plugin.Dispose();
_pluginCts.Cancel();
_pluginCts.Dispose();
}
}
}