display faulted plugins as red with details tooltip
All checks were successful
Build / Compute Version (push) Successful in 4s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 8m23s
Build / Build Nuget package (NuGet) (push) Successful in 8m53s
Build / Build Nuget package (CringePlugins) (push) Successful in 10m28s
Build / Build Nuget package (SharedCringe) (push) Successful in 9m37s
Build / Build Launcher (push) Successful in 14m20s

This commit is contained in:
zznty
2024-11-09 20:18:50 +07:00
parent eac2a42d1e
commit 2e4c7f5e15
2 changed files with 20 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ using CringePlugins.Abstractions;
using CringePlugins.Config;
using CringePlugins.Loader;
using CringePlugins.Resolver;
using CringePlugins.Utils;
using ImGuiNET;
using NLog;
using NuGet;
@@ -96,8 +97,18 @@ internal class PluginListComponent : IRenderComponent
TableNextColumn();
BeginDisabled(!plugin.HasConfig);
if (plugin.WrappedInstance?.LastException is not null)
PushStyleColor(plugin.HasConfig ? ImGuiCol.Text : ImGuiCol.TextDisabled,
plugin.HasConfig ? Color.Red.ToFloat4() : Color.DarkRed.ToFloat4());
if (Selectable(plugin.Metadata.Name, false, ImGuiSelectableFlags.SpanAllColumns))
plugin.OpenConfig();
if (plugin.WrappedInstance?.LastException is not null)
{
PopStyleColor();
if (IsItemHovered(ImGuiHoveredFlags.ForTooltip))
SetTooltip(
$"{plugin.WrappedInstance.LastException.GetType()}: {plugin.WrappedInstance.LastException.Message}");
}
EndDisabled();
TableNextColumn();
Text(plugin.Metadata.Version.ToString());

View File

@@ -0,0 +1,9 @@
using System.Numerics;
namespace CringePlugins.Utils;
public static class ColorExtensions
{
public static Vector4 ToFloat4(this Color color) =>
new((float)color.R / 255, (float)color.G / 255, (float)color.B / 255, (float)color.A / 255);
}