From ebf74871ee9664e59f1a1cb7783f18109faa5744 Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Sat, 10 Jun 2023 16:26:21 -0400 Subject: [PATCH] Always reapply settings a bit after game start to workaround #99 --- src/index.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 5a7daaa..a342ba5 100755 --- a/src/index.tsx +++ b/src/index.tsx @@ -67,6 +67,7 @@ import { Cpus } from "./components/cpus"; var periodicHook: NodeJS.Timer | null = null; var lifetimeHook: any = null; var startHook: any = null; +var endHook: any = null; var usdplReady = false; type MinMax = { @@ -185,6 +186,12 @@ const reload = function() { ); }); + //@ts-ignore + endHook = SteamClient.Apps.RegisterForGameActionEnd((actionType) => { + backend.log(backend.LogLevel.Info, "RegisterForGameActionEnd callback(" + actionType + ")"); + setTimeout(() => backend.forceApplySettings(), 2000 /* ms */); + }); + backend.log(backend.LogLevel.Debug, "Registered PowerTools callbacks, hello!"); })(); @@ -321,8 +328,9 @@ export default definePlugin((serverApi: ServerAPI) => { backend.log(backend.LogLevel.Debug, "PowerTools shutting down"); clearInterval(periodicHook!); periodicHook = null; - lifetimeHook!.unregister(); - startHook!.unregister(); + lifetimeHook?.unregister(); + startHook?.unregister(); + endHook?.unregister(); //serverApi.routerHook.removeRoute("/decky-plugin-test"); backend.log(backend.LogLevel.Debug, "Unregistered PowerTools callbacks, so long and thanks for all the fish."); },