From 045400ecd65402007f70714927a15653e416167a Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Fri, 30 Dec 2022 18:26:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=A9=E7=95=A5=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/libs/maps.js | 58 ++++++++------ public/libs/ui.js | 5 +- public/project/plugins.js | 154 -------------------------------------- 3 files changed, 39 insertions(+), 178 deletions(-) diff --git a/public/libs/maps.js b/public/libs/maps.js index 6b85e2b..13aaa34 100644 --- a/public/libs/maps.js +++ b/public/libs/maps.js @@ -640,8 +640,8 @@ maps.prototype.resizeMap = function (floorId) { core.canvas[cn].canvas.style.height = height * core.domStyle.scale + 'px'; core.canvas[cn].translate( - core.bigmap.v2 ? 32 : 0, - core.bigmap.v2 ? 32 : 0 + core.bigmap.v2 ? 32 * devicePixelRatio : 0, + core.bigmap.v2 ? 32 * devicePixelRatio : 0 ); if (main.mode === 'editor' && editor.isMobile) { core.canvas[cn].canvas.style.width = @@ -2751,31 +2751,43 @@ maps.prototype._drawThumbnail_drawToTarget = function (floorId, options) { hh = core._HALF_HEIGHT_, W = core._WIDTH_, H = core._HEIGHT_; - var ratio = core.domStyle.isVertical - ? core.domStyle.ratio - : core.domStyle.scale; if (main.mode == 'editor') { pw = ph = core.__PIXELS__; hw = hh = core.__HALF_SIZE__; W = H = core.__SIZE__; } if (options.v2) { - core.drawImage( - ctx, - tempCanvas.canvas, - 0, - 0, - pw * ratio, - ph * ratio, - x, - y, - w, - h - ); + if (options.noHD) { + core.drawImage( + ctx, + tempCanvas.canvas, + 0, + 0, + pw, + ph, + x, + y, + w, + h + ); + } else { + const scale = devicePixelRatio * core.domStyle.scale; + core.drawImage( + ctx, + tempCanvas.canvas, + 0, + 0, + pw * scale, + ph * scale, + x, + y, + w, + h + ); + } } else { var offsetX = core.clamp(centerX - hw, 0, width - W), - offsetY = core.clamp(centerY - hh, 0, height - H), - c = options.noHD ? 1 : core.domStyle.scale; + offsetY = core.clamp(centerY - hh, 0, height - H); if (options.noHD) { core.drawImage( ctx, @@ -2794,10 +2806,10 @@ maps.prototype._drawThumbnail_drawToTarget = function (floorId, options) { core.drawImage( ctx, tempCanvas.canvas, - offsetX * 32 * ratio, - offsetY * 32 * ratio, - pw * ratio, - ph * ratio, + offsetX * 32, + offsetY * 32, + pw, + ph, x, y, w, diff --git a/public/libs/ui.js b/public/libs/ui.js index a9e5695..6d96c36 100644 --- a/public/libs/ui.js +++ b/public/libs/ui.js @@ -193,7 +193,10 @@ ui.prototype.fillBoldText = function ( this.setFontForMaxWidth(ctx, text, maxWidth); } ctx.strokeStyle = strokeStyle; - ctx.lineWidth = 1 * core.domStyle.scale * devicePixelRatio; + ctx.lineWidth = + 1 * + (core.domStyle.isVertical ? core.domStyle.ratio : core.domStyle.scale) * + devicePixelRatio; ctx.fillStyle = style; ctx.strokeText(text, x, y); ctx.fillText(text, x, y); diff --git a/public/project/plugins.js b/public/project/plugins.js index 297ae4e..b541bd9 100644 --- a/public/project/plugins.js +++ b/public/project/plugins.js @@ -3424,160 +3424,6 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { }); document.body.addEventListener('keyup', keyboard); } - - maps.prototype._drawThumbnail_drawToTarget = function ( - floorId, - options - ) { - const ctx = core.getContextByName(options.ctx); - if (ctx == null) return; - const x = options.x || 0, - y = options.y || 0, - size = options.size || 1; - // size的含义改为(0,1]范围的系数以适配长方形,默认为1,楼传为3/4,SL界面为0.3 - let w = Math.ceil(size * core._PX_), - h = Math.ceil(size * core._PY_); - // 特判是否为编辑器,编辑器中长宽均采用core.js的遗留正方形像素边长,以保证下面的绘制正常 - if (main.mode == 'editor') w = h = size * core.__PIXELS__; - const width = core.floors[floorId].width, - height = core.floors[floorId].height; - let centerX = options.centerX, - centerY = options.centerY; - if (centerX == null) centerX = Math.floor(width / 2); - if (centerY == null) centerY = Math.floor(height / 2); - const tempCanvas = core.bigmap.tempCanvas; - - if (options.all) { - const tempWidth = tempCanvas.canvas.width, - tempHeight = tempCanvas.canvas.height; - // 绘制全景图 - if (tempWidth <= tempHeight) { - const realHeight = h, - realWidth = (realHeight * tempWidth) / tempHeight; - const side = (w - realWidth) / 2; - if (options.fromMap) { - return core.drawImage( - ctx, - tempCanvas.canvas, - 0, - 0, - tempWidth, - tempHeight, - x, - y, - realWidth, - realHeight - ); - } - core.fillRect(ctx, x, y, side, realHeight, '#000000'); - core.fillRect(ctx, x + w - side, y, side, realHeight); - core.drawImage( - ctx, - tempCanvas.canvas, - 0, - 0, - tempWidth, - tempHeight, - x + side, - y, - realWidth, - realHeight - ); - } else { - const realWidth = w, - realHeight = (realWidth * tempHeight) / tempWidth; - const side = (h - realHeight) / 2; - if (options.fromMap) { - return core.drawImage( - ctx, - tempCanvas.canvas, - 0, - 0, - tempWidth, - tempHeight, - x, - y, - realWidth, - realHeight - ); - } - core.fillRect(ctx, x, y, realWidth, side, '#000000'); - core.fillRect(ctx, x, y + h - side, realWidth, side); - core.drawImage( - ctx, - tempCanvas.canvas, - 0, - 0, - tempWidth, - tempHeight, - x, - y + side, - realWidth, - realHeight - ); - } - } else { - // 只绘制可见窗口 - let pw = core._PX_, - ph = core._PY_, - hw = core._HALF_WIDTH_, - hh = core._HALF_HEIGHT_, - W = core._WIDTH_, - H = core._HEIGHT_; - const ratio = core.domStyle.isVertical - ? core.domStyle.ratio - : core.domStyle.scale; - if (main.mode == 'editor') { - pw = ph = core.__PIXELS__; - hw = hh = core.__HALF_SIZE__; - W = H = core.__SIZE__; - } - if (options.v2) { - core.drawImage( - ctx, - tempCanvas.canvas, - 0, - 0, - pw * ratio, - ph * ratio, - x, - y, - w, - h - ); - } else { - const offsetX = core.clamp(centerX - hw, 0, width - W), - offsetY = core.clamp(centerY - hh, 0, height - H); - if (options.noHD) { - core.drawImage( - ctx, - tempCanvas.canvas, - offsetX * 32, - offsetY * 32, - pw, - ph, - x, - y, - w, - h - ); - return; - } - core.drawImage( - ctx, - tempCanvas.canvas, - offsetX * 32 * ratio, - offsetY * 32 * ratio, - pw * ratio, - ph * ratio, - x, - y, - w, - h - ); - } - } - }; }, towerBoss: function () { // 智慧boss