From a79d7f9e45c8499548e179ce614e18f607b1d5a7 Mon Sep 17 00:00:00 2001 From: catloversg <152669316+catloversg@users.noreply.github.com> Date: Tue, 7 May 2024 00:13:56 +0700 Subject: [PATCH] BUGFIX: Fix wrong zoom factor in Electron app (#1245) --- electron/gameWindow.js | 4 +++- electron/menu.js | 2 +- electron/utils.js | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/electron/gameWindow.js b/electron/gameWindow.js index e114a6b1d..598ec95dd 100644 --- a/electron/gameWindow.js +++ b/electron/gameWindow.js @@ -44,6 +44,9 @@ async function createWindow(killall) { window.removeMenu(); noScripts = killall ? { query: { noScripts: killall } } : {}; window.loadFile("index.html", noScripts); + window.once("ready-to-show", () => { + utils.setZoomFactor(window, utils.getZoomFactor()); + }); window.show(); if (debug) window.webContents.openDevTools(); @@ -60,7 +63,6 @@ async function createWindow(killall) { achievements.enableAchievementsInterval(window); utils.attachUnresponsiveAppHandler(window); - utils.setZoomFactor(window); try { await api.initialize(window); diff --git a/electron/menu.js b/electron/menu.js index f0a233218..ca93d5304 100644 --- a/electron/menu.js +++ b/electron/menu.js @@ -212,7 +212,7 @@ function getMenu(window) { click: () => window.loadFile("index.html"), }, { - label: "Reload & Kill All Scripts", + label: "Reload && Kill All Scripts", click: () => utils.reloadAndKill(window, true), }, ], diff --git a/electron/utils.js b/electron/utils.js index 83f1f8700..5cd1d61e0 100644 --- a/electron/utils.js +++ b/electron/utils.js @@ -7,8 +7,12 @@ const store = new Store(); function reloadAndKill(window, killScripts) { log.info("Reloading & Killing all scripts..."); + const zoomFactor = getZoomFactor(); window.webContents.forcefullyCrashRenderer(); window.loadFile("index.html", killScripts ? { query: { noScripts: true } } : {}); + window.once("ready-to-show", () => { + setZoomFactor(window, zoomFactor); + }); } function promptForReload(window) {