DI: Cleanup

This commit is contained in:
Liza 2023-02-16 22:09:29 +01:00
parent 29342264c0
commit a5456a54a0
2 changed files with 10 additions and 4 deletions

View File

@ -171,10 +171,13 @@ namespace Pal.Client
PluginLog.Information("Async init complete"); PluginLog.Information("Async init complete");
} }
catch (ObjectDisposedException)
{
}
catch (Exception e) catch (Exception e)
{ {
PluginLog.Error(e, "Async load failed"); PluginLog.Error(e, "Async load failed");
chatGui.PrintError($"Async loading failed: {e}"); chatGui.PrintError($"Async loading failed: {e.GetType()}: {e.Message}");
} }
}); });
} }

View File

@ -23,17 +23,20 @@ namespace Pal.Client
private readonly DalamudPluginInterface _pluginInterface; private readonly DalamudPluginInterface _pluginInterface;
private readonly IPalacePalConfiguration _configuration; private readonly IPalacePalConfiguration _configuration;
private readonly RenderAdapter _renderAdapter; private readonly RenderAdapter _renderAdapter;
private readonly WindowSystem _windowSystem;
public Plugin( public Plugin(
IServiceProvider serviceProvider, IServiceProvider serviceProvider,
DalamudPluginInterface pluginInterface, DalamudPluginInterface pluginInterface,
IPalacePalConfiguration configuration, IPalacePalConfiguration configuration,
RenderAdapter renderAdapter) RenderAdapter renderAdapter,
WindowSystem windowSystem)
{ {
_serviceProvider = serviceProvider; _serviceProvider = serviceProvider;
_pluginInterface = pluginInterface; _pluginInterface = pluginInterface;
_configuration = configuration; _configuration = configuration;
_renderAdapter = renderAdapter; _renderAdapter = renderAdapter;
_windowSystem = windowSystem;
LanguageChanged(pluginInterface.UiLanguage); LanguageChanged(pluginInterface.UiLanguage);
@ -63,14 +66,14 @@ namespace Pal.Client
private void LanguageChanged(string languageCode) private void LanguageChanged(string languageCode)
{ {
Localization.Culture = new CultureInfo(languageCode); Localization.Culture = new CultureInfo(languageCode);
_serviceProvider.GetRequiredService<WindowSystem>().Windows.OfType<ILanguageChanged>() _windowSystem.Windows.OfType<ILanguageChanged>()
.Each(w => w.LanguageChanged()); .Each(w => w.LanguageChanged());
} }
private void Draw() private void Draw()
{ {
_renderAdapter.DrawLayers(); _renderAdapter.DrawLayers();
_serviceProvider.GetRequiredService<WindowSystem>().Draw(); _windowSystem.Draw();
} }
} }
} }