From 6bc0789c9b6e4552d7ff0aa8fdada30e035516ee Mon Sep 17 00:00:00 2001 From: OleSTEEP Date: Sun, 24 Mar 2024 11:58:51 +0300 Subject: [PATCH] Change FPS Counter toggling method --- www.eng/js/porting/fps_counter.js | 14 +------------- www.rus/js/porting/fps_counter.js | 14 +------------- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/www.eng/js/porting/fps_counter.js b/www.eng/js/porting/fps_counter.js index 60b2523..073c285 100644 --- a/www.eng/js/porting/fps_counter.js +++ b/www.eng/js/porting/fps_counter.js @@ -6,23 +6,11 @@ function create_fps_button() { FPSBtn.id = "buttonF2"; document.body.appendChild(FPSBtn); - console.log(`Setting up the FPS key...`); - FPSBtn.addEventListener("pointerdown", (event) => { - console.log(`Pointer down for F2`); event.stopImmediatePropagation(); event.preventDefault(); - sendEvent(false, 113); + Graphics._switchFPSMeter(); }); - - FPSBtn.addEventListener("pointerup", () => { - sendEvent(true, 113); - }); -} - -function sendEvent(isUp, keycode) { - document.getElementById("GameCanvas").focus(); - document.dispatchEvent(new KeyboardEvent(isUp ? 'keyup' : 'keydown', { 'key': '', keyCode: keycode })) } window.addEventListener('load', () => { diff --git a/www.rus/js/porting/fps_counter.js b/www.rus/js/porting/fps_counter.js index 60b2523..073c285 100644 --- a/www.rus/js/porting/fps_counter.js +++ b/www.rus/js/porting/fps_counter.js @@ -6,23 +6,11 @@ function create_fps_button() { FPSBtn.id = "buttonF2"; document.body.appendChild(FPSBtn); - console.log(`Setting up the FPS key...`); - FPSBtn.addEventListener("pointerdown", (event) => { - console.log(`Pointer down for F2`); event.stopImmediatePropagation(); event.preventDefault(); - sendEvent(false, 113); + Graphics._switchFPSMeter(); }); - - FPSBtn.addEventListener("pointerup", () => { - sendEvent(true, 113); - }); -} - -function sendEvent(isUp, keycode) { - document.getElementById("GameCanvas").focus(); - document.dispatchEvent(new KeyboardEvent(isUp ? 'keyup' : 'keydown', { 'key': '', keyCode: keycode })) } window.addEventListener('load', () => {