From a5c75baf450c4cdecf198710b376dd697f9f79fd Mon Sep 17 00:00:00 2001 From: Dustin Brett Date: Sun, 19 Jan 2025 14:15:14 -0800 Subject: [PATCH] No right click on Q3 --- components/apps/Quake3/useQuake3.ts | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/components/apps/Quake3/useQuake3.ts b/components/apps/Quake3/useQuake3.ts index ea3b3b40..99a8f85c 100644 --- a/components/apps/Quake3/useQuake3.ts +++ b/components/apps/Quake3/useQuake3.ts @@ -6,7 +6,7 @@ import { type EmscriptenFS } from "contexts/fileSystem/useAsyncFs"; import { useProcesses } from "contexts/process"; import { useSession } from "contexts/session"; import { PREVENT_SCROLL, TRANSITIONS_IN_MILLISECONDS } from "utils/constants"; -import { loadFiles, pxToNum } from "utils/functions"; +import { haltEvent, loadFiles, pxToNum } from "utils/functions"; import useIsolatedContentWindow from "hooks/useIsolatedContentWindow"; declare global { @@ -87,8 +87,22 @@ const useQuake3 = ({ newContentWindow.ioq3.callMain([]); setLoading(false); - mountEmFs(newContentWindow.FS as EmscriptenFS, "Quake3"); - setContentWindow(newContentWindow); + + const initCanvas = (): void => { + if (newContentWindow.ioq3?.canvas) { + newContentWindow.ioq3.canvas.addEventListener( + "contextmenu", + haltEvent + ); + + mountEmFs(newContentWindow.FS as EmscriptenFS, "Quake3"); + setContentWindow(newContentWindow); + } else { + requestAnimationFrame(initCanvas); + } + }; + + initCanvas(); } ); }