Add NotificationsComponent
All checks were successful
Build / Compute Version (push) Successful in 6s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 1m36s
Build / Build Nuget package (NuGet) (push) Successful in 1m49s
Build / Build Nuget package (CringePlugins) (push) Successful in 3m10s
Build / Build Nuget package (SharedCringe) (push) Successful in 2m40s
Build / Build Launcher (push) Successful in 3m26s
All checks were successful
Build / Compute Version (push) Successful in 6s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 1m36s
Build / Build Nuget package (NuGet) (push) Successful in 1m49s
Build / Build Nuget package (CringePlugins) (push) Successful in 3m10s
Build / Build Nuget package (SharedCringe) (push) Successful in 2m40s
Build / Build Launcher (push) Successful in 3m26s
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using NLog;
|
||||
using CringePlugins.Ui;
|
||||
using ImGuiNET;
|
||||
using NLog;
|
||||
using VRage.Plugins;
|
||||
|
||||
namespace CringePlugins.Loader;
|
||||
@@ -13,6 +15,8 @@ internal sealed class PluginWrapper(PluginMetadata metadata, IPlugin plugin) : I
|
||||
|
||||
private readonly IHandleInputPlugin? _handleInputPlugin = plugin as IHandleInputPlugin;
|
||||
|
||||
private const float ErrorShowTime = 10f;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
try
|
||||
@@ -23,6 +27,7 @@ internal sealed class PluginWrapper(PluginMetadata metadata, IPlugin plugin) : I
|
||||
{
|
||||
Log.Error(e, "Exception while Disposing {Metadata}", metadata);
|
||||
LastException = e;
|
||||
NotificationsComponent.SpawnNotification(ErrorShowTime, RenderError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +44,7 @@ internal sealed class PluginWrapper(PluginMetadata metadata, IPlugin plugin) : I
|
||||
{
|
||||
Log.Error(e, "Exception while Updating {Metadata}", metadata);
|
||||
LastException = e;
|
||||
NotificationsComponent.SpawnNotification(ErrorShowTime, RenderError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +58,7 @@ internal sealed class PluginWrapper(PluginMetadata metadata, IPlugin plugin) : I
|
||||
{
|
||||
Log.Error(e, "Exception while Initializing {Metadata}", metadata);
|
||||
LastException = e;
|
||||
NotificationsComponent.SpawnNotification(ErrorShowTime, RenderError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,8 +75,16 @@ internal sealed class PluginWrapper(PluginMetadata metadata, IPlugin plugin) : I
|
||||
{
|
||||
Log.Error(e, "Exception while Updating {Metadata}", metadata);
|
||||
LastException = e;
|
||||
NotificationsComponent.SpawnNotification(ErrorShowTime, RenderError);
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString() => metadata.ToString();
|
||||
|
||||
private void RenderError()
|
||||
{
|
||||
ImGui.TextColored(new System.Numerics.Vector4(1f, 0f, 0f, 0f), "Error: ");
|
||||
ImGui.SameLine();
|
||||
ImGui.TextWrapped($"Fatal error in {metadata.Name}: {LastException?.Message}");
|
||||
}
|
||||
}
|
||||
|
@@ -63,6 +63,9 @@ public class PluginsLifetime(string gameFolder) : ILoadingStage
|
||||
|
||||
progress.Report("Loading plugins");
|
||||
|
||||
//we can move this, but it should be before plugin init
|
||||
RenderHandler.Current.RegisterComponent(new NotificationsComponent());
|
||||
|
||||
await LoadPlugins(cachedPackages, sourceMapping, packagesConfig);
|
||||
|
||||
RenderHandler.Current.RegisterComponent(new PluginListComponent(packagesConfig, sourceMapping, configPath, gameFolder, _plugins));
|
||||
|
Reference in New Issue
Block a user