diff --git a/Il2CppInspector.Redux.GUI.UI/src/lib/components/Footer.svelte b/Il2CppInspector.Redux.GUI.UI/src/lib/components/Footer.svelte index 423c3a9..2cb6201 100644 --- a/Il2CppInspector.Redux.GUI.UI/src/lib/components/Footer.svelte +++ b/Il2CppInspector.Redux.GUI.UI/src/lib/components/Footer.svelte @@ -1,9 +1,36 @@ + + diff --git a/Il2CppInspector.Redux.GUI.UI/src/lib/signalr/api.svelte.ts b/Il2CppInspector.Redux.GUI.UI/src/lib/signalr/api.svelte.ts index 57e36dd..88ae0e3 100644 --- a/Il2CppInspector.Redux.GUI.UI/src/lib/signalr/api.svelte.ts +++ b/Il2CppInspector.Redux.GUI.UI/src/lib/signalr/api.svelte.ts @@ -16,7 +16,7 @@ class SignalRApi { } class SignalRState { - api = $state(); + api = $state(); get apiAvailable() { return this.api !== undefined; diff --git a/Il2CppInspector.Redux.GUI.UI/src/lib/signalr/client-api.ts b/Il2CppInspector.Redux.GUI.UI/src/lib/signalr/client-api.ts index 2a5b4b9..ebd9364 100644 --- a/Il2CppInspector.Redux.GUI.UI/src/lib/signalr/client-api.ts +++ b/Il2CppInspector.Redux.GUI.UI/src/lib/signalr/client-api.ts @@ -45,6 +45,12 @@ export class SignalRClientApi { return this.registerHandler("OnImportCompleted", handler); } + onSetInspectorVersion( + handler: (version: string) => Promise, + ): () => void { + return this.registerHandler("SetInspectorVersion", handler); + } + private registerHandler( name: string, handler: (...args: any[]) => Promise, diff --git a/Il2CppInspector.Redux.GUI/DictionaryExtensions.cs b/Il2CppInspector.Redux.GUI/Extensions.cs similarity index 69% rename from Il2CppInspector.Redux.GUI/DictionaryExtensions.cs rename to Il2CppInspector.Redux.GUI/Extensions.cs index 6f954a4..3219443 100644 --- a/Il2CppInspector.Redux.GUI/DictionaryExtensions.cs +++ b/Il2CppInspector.Redux.GUI/Extensions.cs @@ -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 dict, string key, bool defaultValue) { @@ -18,4 +20,7 @@ public static class DictionaryExtensions return defaultValue; } + + public static string? GetAssemblyVersion(this Assembly assembly) + => assembly.GetCustomAttribute()?.InformationalVersion; } \ No newline at end of file diff --git a/Il2CppInspector.Redux.GUI/Il2CppHub.cs b/Il2CppInspector.Redux.GUI/Il2CppHub.cs index 86d22a5..c4d3651 100644 --- a/Il2CppInspector.Redux.GUI/Il2CppHub.cs +++ b/Il2CppInspector.Redux.GUI/Il2CppHub.cs @@ -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() { diff --git a/Il2CppInspector.Redux.GUI/UiClient.cs b/Il2CppInspector.Redux.GUI/UiClient.cs index 512dd60..3dfbb86 100644 --- a/Il2CppInspector.Redux.GUI/UiClient.cs +++ b/Il2CppInspector.Redux.GUI/UiClient.cs @@ -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); } \ No newline at end of file diff --git a/Il2CppInspector.Redux.GUI/UiContext.cs b/Il2CppInspector.Redux.GUI/UiContext.cs index b8bc265..596bb34 100644 --- a/Il2CppInspector.Redux.GUI/UiContext.cs +++ b/Il2CppInspector.Redux.GUI/UiContext.cs @@ -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() ?? "", cancellationToken); } public async Task LoadInputFiles(UiClient client, List inputFiles,