From d977075f34e75fd400f5420c84fa155049ac905d Mon Sep 17 00:00:00 2001 From: ShakeFlower Date: Sat, 1 Mar 2025 00:00:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E7=BC=A9=E6=94=BE=E7=82=B8=E5=BD=95=E5=83=8F=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 123 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 70 insertions(+), 53 deletions(-) diff --git a/main.js b/main.js index 6aa50d3e..53901f52 100644 --- a/main.js +++ b/main.js @@ -195,7 +195,8 @@ function main () { main.prototype.init = function (mode, callback) { for (var i = 0; i < main.dom.gameCanvas.length; i++) { - main.canvas[main.dom.gameCanvas[i].id] = main.dom.gameCanvas[i].getContext('2d'); + main.canvas[main.dom.gameCanvas[i].id] = + main.dom.gameCanvas[i].getContext('2d'); } main.mode = mode; @@ -213,7 +214,7 @@ main.prototype.init = function (mode, callback) { (function (span, str_) { span.onclick = function () { core.events.startGame(str_); - } + }; })(span, value.name || ''); main.dom.levelChooseButtons.appendChild(span); }); @@ -231,67 +232,83 @@ main.prototype.init = function (mode, callback) { main.loadFloors(function () { var coreData = {}; - ["dom", "statusBar", "canvas", "images", "tilesets", "materials", - "animates", "bgms", "sounds", "floorIds", "floors", "floorPartitions"].forEach(function (t) { - coreData[t] = main[t]; - }) + [ + 'dom', + 'statusBar', + 'canvas', + 'images', + 'tilesets', + 'materials', + 'animates', + 'bgms', + 'sounds', + 'floorIds', + 'floors', + 'floorPartitions' + ].forEach(function (t) { + coreData[t] = main[t]; + }); main.core.init(coreData, callback); main.core.resize(); // 自动放缩最大化 - if (core.getLocalStorage('autoScale') == null) { - core.setLocalStorage('autoScale', true); - } - if ( - core.getLocalStorage('autoScale') && - !core.domStyle.isVertical - ) { - try { - if (main.core) { - var index = - main.core.domStyle.availableScale.indexOf( - core.domStyle.scale + if (!main.replayChecking) { + if (core.getLocalStorage('autoScale') == null) { + core.setLocalStorage('autoScale', true); + } + if ( + core.getLocalStorage('autoScale') && + !core.domStyle.isVertical + ) { + try { + if (main.core) { + var index = + main.core.domStyle.availableScale.indexOf( + core.domStyle.scale + ); + main.core.control.setDisplayScale( + main.core.domStyle.availableScale.length - + 1 - + index ); - main.core.control.setDisplayScale( - main.core.domStyle.availableScale.length - - 1 - - index - ); - if ( - !main.core.isPlaying() && - main.core.flags.enableHDCanvas - ) { - main.core.domStyle.ratio = Math.max( - window.devicePixelRatio || 1, - main.core.domStyle.scale - ); - main.core.resize(); - } - requestAnimationFrame(function () { - var style = getComputedStyle( - main.dom.gameGroup - ); - var height = parseFloat(style.height); - if (height > window.innerHeight * 0.95) { - main.core.control.setDisplayScale(-1); - if ( - !main.core.isPlaying() && - main.core.flags.enableHDCanvas - ) { - main.core.domStyle.ratio = Math.max( - window.devicePixelRatio || 1, - main.core.domStyle.scale - ); - main.core.resize(); - } + if ( + !main.core.isPlaying() && + main.core.flags.enableHDCanvas + ) { + main.core.domStyle.ratio = Math.max( + window.devicePixelRatio || 1, + main.core.domStyle.scale + ); + main.core.resize(); } - }); + requestAnimationFrame(function () { + var style = getComputedStyle( + main.dom.gameGroup + ); + var height = parseFloat(style.height); + if (height > window.innerHeight * 0.95) { + main.core.control.setDisplayScale(-1); + if ( + !main.core.isPlaying() && + main.core.flags.enableHDCanvas + ) { + main.core.domStyle.ratio = Math.max( + window.devicePixelRatio || 1, + main.core.domStyle.scale + ); + main.core.resize(); + } + } + }); + } + } catch (e) { + console.error(e); } - } catch (e) { console.error(e) }; + } } }); }); }); -} +}; ////// 动态加载所有核心JS文件 ////// main.prototype.loadJs = function (dir, loadList, callback) {