show current version and hash in new ui footer

This commit is contained in:
LukeFZ
2025-07-29 18:56:49 +02:00
parent 5d92ceb2f3
commit 62a27ee47f
7 changed files with 52 additions and 8 deletions

View File

@@ -1,6 +1,8 @@
namespace Il2CppInspector.Redux.GUI;
using System.Reflection;
public static class DictionaryExtensions
namespace Il2CppInspector.Redux.GUI;
public static class Extensions
{
public static bool GetAsBooleanOrDefault(this Dictionary<string, string> dict, string key, bool defaultValue)
{
@@ -18,4 +20,7 @@ public static class DictionaryExtensions
return defaultValue;
}
public static string? GetAssemblyVersion(this Assembly assembly)
=> assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
}

View File

@@ -4,21 +4,23 @@ namespace Il2CppInspector.Redux.GUI;
internal class Il2CppHub : Hub
{
public UiContext State
private const string ContextKey = "context";
private UiContext State
{
get
{
if (!Context.Items.TryGetValue("context", out var context)
if (!Context.Items.TryGetValue(ContextKey, out var context)
|| context is not UiContext ctx)
{
Context.Items["context"] = ctx = new UiContext();
Context.Items[ContextKey] = ctx = new UiContext();
}
return ctx;
}
}
public UiClient Client => new(Clients.Caller);
private UiClient Client => new(Clients.Caller);
public async Task OnUiLaunched()
{

View File

@@ -41,4 +41,7 @@ public class UiClient(ISingleClientProxy client)
public async Task OnImportCompleted(CancellationToken cancellationToken = default)
=> await client.SendAsync(nameof(OnImportCompleted), cancellationToken);
public async Task SetInspectorVersion(string version, CancellationToken cancellationToken = default)
=> await client.SendAsync(nameof(SetInspectorVersion), version, cancellationToken);
}

View File

@@ -122,6 +122,7 @@ public class UiContext
public async Task Initialize(UiClient client, CancellationToken cancellationToken = default)
{
await client.ShowSuccessToast("SignalR initialized!", cancellationToken);
await client.SetInspectorVersion(typeof(UiContext).Assembly.GetAssemblyVersion() ?? "<unknown>", cancellationToken);
}
public async Task LoadInputFiles(UiClient client, List<string> inputFiles,