From 518c139556c97277acef301ce5a8c99e49464060 Mon Sep 17 00:00:00 2001 From: unamed <1319491857@qq.com> Date: Wed, 2 Feb 2022 10:03:59 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=94=BE=E7=BC=A9=E6=9C=80?= =?UTF-8?q?=E5=A4=A7=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/control.js | 15 ++++++++++++--- main.js | 24 ++++++++++++------------ runtime.d.ts | 14 ++++++++++---- styles.css | 7 +++++++ 4 files changed, 41 insertions(+), 19 deletions(-) diff --git a/libs/control.js b/libs/control.js index d0c49a27..dc2eba6e 100644 --- a/libs/control.js +++ b/libs/control.js @@ -3276,7 +3276,7 @@ control.prototype.resize = function () { core.domStyle.isVertical = false; core.domStyle.availableScale = []; - [1, 1.25, 1.5, 1.75, 2].forEach(function (v) { + [1, 1.25, 1.5, 1.75, 2, 2.25, 2.5].forEach(function (v) { if (clientWidth - 3 * BORDER >= v * (CANVAS_WIDTH + BAR_WIDTH) && horizontalMaxRatio >= v) { core.domStyle.availableScale.push(v); } @@ -3371,8 +3371,16 @@ control.prototype._resize_gameGroup = function (obj) { control.prototype._resize_canvas = function (obj) { var innerSize = (obj.CANVAS_WIDTH * core.domStyle.scale) + "px"; - for (var i = 0; i < core.dom.gameCanvas.length; ++i) - core.dom.gameCanvas[i].style.width = core.dom.gameCanvas[i].style.height = innerSize; + for (var i = 0; i < core.dom.gameCanvas.length; ++i) { + var ctx = core.dom.gameCanvas[i].getContext('2d'); + // core.maps._setHDCanvasSize(ctx); + core.resizeCanvas(ctx, core.__PIXELS__, core.__PIXELS__); + if (core.status && core.status.maps) { + core.redrawMap(); + core.drawHero(); + core.setWeather(core.animateFrame.weather.type, core.animateFrame.weather.level); + } + } core.dom.gif.style.width = core.dom.gif.style.height = innerSize; core.dom.gif2.style.width = core.dom.gif2.style.height = innerSize; core.dom.gameDraw.style.width = core.dom.gameDraw.style.height = innerSize; @@ -3388,6 +3396,7 @@ control.prototype._resize_canvas = function (obj) { // resize dynamic canvas for (var name in core.dymCanvas) { var ctx = core.dymCanvas[name], canvas = ctx.canvas; + core.maps._setHDCanvasSize(ctx, parseFloat(canvas.getAttribute('_width')), parseFloat(canvas.getAttribute('_height'))); canvas.style.left = parseFloat(canvas.getAttribute("_left")) * core.domStyle.scale + "px"; canvas.style.top = parseFloat(canvas.getAttribute("_top")) * core.domStyle.scale + "px"; var scale = canvas.getAttribute('_scale'); diff --git a/main.js b/main.js index edfc2c00..9c218a77 100644 --- a/main.js +++ b/main.js @@ -1,3 +1,4 @@ +/// function main () { //------------------------ 用户修改内容 ------------------------// @@ -236,6 +237,17 @@ main.prototype.init = function (mode, callback) { }) main.core.init(coreData, callback); main.core.resize(); + // 自动放缩最大化 + 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); + 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) }; }); }); }); @@ -785,18 +797,6 @@ main.prototype.listen = function () { } catch (ee) { console.error(ee) } } - main.dom.enlargeBtn.onclick = function () { - try { - if (main.core) { - main.core.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) }; - } - window.onblur = function () { if (main.core && main.core.control) { try { diff --git a/runtime.d.ts b/runtime.d.ts index d35e63ab..4fe00cdd 100644 --- a/runtime.d.ts +++ b/runtime.d.ts @@ -1638,13 +1638,18 @@ declare class maps { automaticRoute(destX: number, destY: number): Array<{ direction: direction, x: number, y: number }> /** - * 地图重绘 - * @example core.drawMap(); // 重绘当前地图,常用于更改贴图后或自动元件的刷新 + * 地图绘制 + * @example core.drawMap(); // 绘制当前地图 * @param floorId 地图id,省略表示当前楼层 * @param callback 重绘完毕后的回调函数,可选 */ drawMap(floorId?: string, callback?: () => void): void + /** + * 重绘地图 + */ + redrawMap(): void + /** * 绘制背景层(含贴图,其与背景层矩阵的绘制顺序可通过复写此函数来改变) * @example core.drawBg(); // 绘制当前地图的背景层 @@ -2937,9 +2942,9 @@ type core = { } & control & events & loader & enemys & items & maps & ui & utils & icons & actions & plugin -declare class main { +type main = { readonly core: core - readonly dom = core.dom + readonly dom: { [key: string]: HTMLElement } /** 游戏版本,发布后会被随机,请勿使用该属性 */ readonly version: string readonly useCompress: boolean @@ -2957,6 +2962,7 @@ declare class main { log(e: string | Error, error: boolean): void } +declare let main: main declare let core: core declare let flags: { [x: string]: any } declare let hero = core.status.hero \ No newline at end of file diff --git a/styles.css b/styles.css index 835992b5..d5b7930c 100644 --- a/styles.css +++ b/styles.css @@ -108,6 +108,7 @@ } #startLogo { + user-select: none; position: absolute; z-index: 290; left: 0; @@ -121,6 +122,7 @@ } #startTitle { + user-select: none; position: absolute; z-index: 280; } @@ -215,6 +217,7 @@ padding: 3px; } #statusBar .status{ + user-select: none; position: relative; display: block; float: left; @@ -227,10 +230,12 @@ max-height: 1.6em; } #statusBar span{ + user-select: none; font: bold italic 1.1em Verdana; display: inline; } #statusBar p { + user-select: none; display: inline-block; vertical-align: middle; width: 60%; @@ -256,6 +261,7 @@ } p#hard { + user-select: none; width: 6em; vertical-align: middle; display: inline-block; @@ -267,6 +273,7 @@ p#hard { } span#poison, span#weak, span#curse, span#pickaxe, span#bomb, span#fly { + user-select: none; font-style: normal; font-size: 1em; }