Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Commit

Permalink
Always reapply settings a bit after game start to workaround #99
Browse files Browse the repository at this point in the history
  • Loading branch information
NGnius committed Jun 10, 2023
1 parent 441a635 commit ebf7487
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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!");
})();

Expand Down Expand Up @@ -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.");
},
Expand Down

0 comments on commit ebf7487

Please sign in to comment.