Always reapply settings a bit after game start to workaround #99

This commit is contained in:
NGnius (Graham) 2023-06-10 16:26:21 -04:00
parent 441a635163
commit ebf74871ee

View file

@ -67,6 +67,7 @@ import { Cpus } from "./components/cpus";
var periodicHook: NodeJS.Timer | null = null; var periodicHook: NodeJS.Timer | null = null;
var lifetimeHook: any = null; var lifetimeHook: any = null;
var startHook: any = null; var startHook: any = null;
var endHook: any = null;
var usdplReady = false; var usdplReady = false;
type MinMax = { 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!"); 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"); backend.log(backend.LogLevel.Debug, "PowerTools shutting down");
clearInterval(periodicHook!); clearInterval(periodicHook!);
periodicHook = null; periodicHook = null;
lifetimeHook!.unregister(); lifetimeHook?.unregister();
startHook!.unregister(); startHook?.unregister();
endHook?.unregister();
//serverApi.routerHook.removeRoute("/decky-plugin-test"); //serverApi.routerHook.removeRoute("/decky-plugin-test");
backend.log(backend.LogLevel.Debug, "Unregistered PowerTools callbacks, so long and thanks for all the fish."); backend.log(backend.LogLevel.Debug, "Unregistered PowerTools callbacks, so long and thanks for all the fish.");
}, },