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,9 +1,36 @@
<script lang="ts">
import { signalRState } from "$lib/signalr/api.svelte";
let inspectorVersion = $state<string>();
$effect(() => {
if (signalRState.api === undefined) return;
const unregisterSetInspectorVersion =
signalRState.api.client.onSetInspectorVersion(async (version) => {
inspectorVersion = version;
});
return () => {
unregisterSetInspectorVersion();
};
});
</script>
<div <div
class="absolute inset-x-0 bottom-0 flex h-[--footer-height] flex-row border-t-2 text-center" class="absolute inset-x-0 bottom-0 flex h-[--footer-height] flex-row justify-between border-t-2 text-center"
> >
<div class="ml-4 mt-1"> <div class="ml-4 mt-1">
<p class="text-sm text-muted-foreground"> <p class="text-sm text-muted-foreground">
Il2CppInspectorRedux - created by djkaty, maintained by LukeFZ Il2CppInspectorRedux - created by djkaty, maintained by LukeFZ
</p> </p>
</div> </div>
{#if inspectorVersion !== undefined}
<div class="mr-4 mt-1">
<p class="text-sm text-muted-foreground">
{inspectorVersion}
</p>
</div>
{/if}
</div> </div>

View File

@@ -16,7 +16,7 @@ class SignalRApi {
} }
class SignalRState { class SignalRState {
api = $state<SignalRApi | undefined>(); api = $state<SignalRApi>();
get apiAvailable() { get apiAvailable() {
return this.api !== undefined; return this.api !== undefined;

View File

@@ -45,6 +45,12 @@ export class SignalRClientApi {
return this.registerHandler("OnImportCompleted", handler); return this.registerHandler("OnImportCompleted", handler);
} }
onSetInspectorVersion(
handler: (version: string) => Promise<void>,
): () => void {
return this.registerHandler("SetInspectorVersion", handler);
}
private registerHandler( private registerHandler(
name: string, name: string,
handler: (...args: any[]) => Promise<void>, handler: (...args: any[]) => Promise<void>,

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) public static bool GetAsBooleanOrDefault(this Dictionary<string, string> dict, string key, bool defaultValue)
{ {
@@ -18,4 +20,7 @@ public static class DictionaryExtensions
return defaultValue; 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 internal class Il2CppHub : Hub
{ {
public UiContext State private const string ContextKey = "context";
private UiContext State
{ {
get get
{ {
if (!Context.Items.TryGetValue("context", out var context) if (!Context.Items.TryGetValue(ContextKey, out var context)
|| context is not UiContext ctx) || context is not UiContext ctx)
{ {
Context.Items["context"] = ctx = new UiContext(); Context.Items[ContextKey] = ctx = new UiContext();
} }
return ctx; return ctx;
} }
} }
public UiClient Client => new(Clients.Caller); private UiClient Client => new(Clients.Caller);
public async Task OnUiLaunched() public async Task OnUiLaunched()
{ {

View File

@@ -41,4 +41,7 @@ public class UiClient(ISingleClientProxy client)
public async Task OnImportCompleted(CancellationToken cancellationToken = default) public async Task OnImportCompleted(CancellationToken cancellationToken = default)
=> await client.SendAsync(nameof(OnImportCompleted), cancellationToken); => 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) public async Task Initialize(UiClient client, CancellationToken cancellationToken = default)
{ {
await client.ShowSuccessToast("SignalR initialized!", cancellationToken); await client.ShowSuccessToast("SignalR initialized!", cancellationToken);
await client.SetInspectorVersion(typeof(UiContext).Assembly.GetAssemblyVersion() ?? "<unknown>", cancellationToken);
} }
public async Task LoadInputFiles(UiClient client, List<string> inputFiles, public async Task LoadInputFiles(UiClient client, List<string> inputFiles,