diff --git a/_docs/api.md b/_docs/api.md index 2a18a9e7..94635318 100644 --- a/_docs/api.md +++ b/_docs/api.md @@ -1998,7 +1998,7 @@ getToolboxItems: fn(cls: string) -> [string] loadCanvas: fn(name: string|CanvasRenderingContext2D) 加载某个canvas状态 -relocateCanvas: fn(name: string, x: number, y: number) +relocateCanvas: fn(name: string, x: number, y: number, useDelta: bool) 重新定位一个自定义画布 resizeCanvas: fn(name: string, x: number, y: number) diff --git a/_server/CodeMirror/defs.js b/_server/CodeMirror/defs.js index 1830642c..9eb4de71 100644 --- a/_server/CodeMirror/defs.js +++ b/_server/CodeMirror/defs.js @@ -3520,7 +3520,7 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [ }, "relocateCanvas": { "!doc": "重新定位一个自定义画布", - "!type": "fn(name: string, x: number, y: number)" + "!type": "fn(name: string, x: number, y: number, useDelta: bool)" }, "rotateCanvas": { "!doc": "设置一个自定义画布的旋转角度
centerX, centerY: 旋转中心(以屏幕像素为基准);不填视为图片正中心。", diff --git a/_server/css/editor.css b/_server/css/editor.css index 3ec13178..5132f8f2 100644 --- a/_server/css/editor.css +++ b/_server/css/editor.css @@ -426,7 +426,7 @@ table.row { top: 50%; left: 50%; transform: translate(-50%, -55%); - width: calc(20px + 1.25 * var(--pixel)); + width: 560px; } #uieventHead { @@ -448,8 +448,8 @@ table.row { } #uieventBody { - width: calc(1.25 * var(--pixel)); - height: calc(1.25 * var(--pixel)); + width: 540px; + height: 540px; position: relative; margin-left: 10px; margin-bottom: 5px; diff --git a/_server/editor_uievent.js b/_server/editor_uievent.js index 9b3e244d..d19cdf84 100644 --- a/_server/editor_uievent.js +++ b/_server/editor_uievent.js @@ -108,7 +108,7 @@ editor_uievent_wrapper = function (editor) { uievent.selectPoint = function (floorId, x, y, bigmap, callback) { uievent.values.bigmap = bigmap; - uievent.values.size = editor.isMobile ? window.innerWidth / core.__SIZE__ : 32 * 1.25; + uievent.values.size = editor.isMobile ? window.innerWidth / core.__SIZE__ : 32 * 540 / core.__PIXELS__; uievent.isOpen = true; uievent.elements.div.style.display = 'block'; diff --git a/libs/events.js b/libs/events.js index 70f01d15..616d73ee 100644 --- a/libs/events.js +++ b/libs/events.js @@ -783,6 +783,7 @@ events.prototype._changeFloor_getHeroLoc = function (floorId, stair, heroLoc) { } events.prototype._changeFloor_beforeChange = function (info, callback) { + this._changeFloor_playSound(); // 需要 setTimeout 执行,不然会出错 window.setTimeout(function () { if (info.time == 0) @@ -794,6 +795,16 @@ events.prototype._changeFloor_beforeChange = function (info, callback) { }, 25) } +events.prototype._changeFloor_playSound = function () { + // 播放换层音效 + if (core.hasFlag('__fromLoad__')) // 是否是读档造成的切换 + core.playSound('读档'); + else if (core.hasFlag('__isFlying__')) // 是否是楼传造成的切换 + core.playSound('飞行器'); + else + core.playSound('上下楼'); +} + events.prototype._changeFloor_changing = function (info, callback) { this.changingFloor(info.floorId, info.heroLoc); // 回归视角 diff --git a/libs/ui.js b/libs/ui.js index ba5059ed..4f552203 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -3393,14 +3393,22 @@ ui.prototype.createCanvas = function (name, x, y, width, height, z) { } ////// canvas重定位 ////// -ui.prototype.relocateCanvas = function (name, x, y) { +ui.prototype.relocateCanvas = function (name, x, y, useDelta) { var ctx = core.getContextByName(name); if (!ctx) return null; if (x != null) { + // 增量模式 + if (useDelta) { + x += parseFloat(ctx.canvas.getAttribute("_left")) || 0; + } ctx.canvas.style.left = x * core.domStyle.scale + 'px'; ctx.canvas.setAttribute("_left", x); } if (y != null) { + // 增量模式 + if (useDelta) { + y += parseFloat(ctx.canvas.getAttribute("_top")) || 0; + } ctx.canvas.style.top = y * core.domStyle.scale + 'px'; ctx.canvas.setAttribute("_top", y); } diff --git a/libs/utils.js b/libs/utils.js index 22b04674..dc6e41b3 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -503,7 +503,7 @@ utils.prototype.formatTime = function (time) { ////// 两位数显示 ////// utils.prototype.setTwoDigits = function (x) { - return parseInt(x) < 10 ? "0" + x : x; + return (parseInt(x) < 10 && parseInt(x) >= 0) ? "0" + x : x; } utils.prototype.formatSize = function (size) { diff --git a/project/functions.js b/project/functions.js index e43c4cd0..93829d47 100644 --- a/project/functions.js +++ b/project/functions.js @@ -112,14 +112,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // core.deleteAllCanvas(); // } - // 播放换层音效 - if (fromLoad) - core.playSound('读档'); - else if (isFlying) - core.playSound('飞行器'); - else if (currentId) - core.playSound('上下楼'); - // 根据分区信息自动砍层与恢复 if (core.autoRemoveMaps) core.autoRemoveMaps(floorId); diff --git a/runtime.d.ts b/runtime.d.ts index f99e7754..f1703043 100644 --- a/runtime.d.ts +++ b/runtime.d.ts @@ -2148,7 +2148,7 @@ declare class ui { createCanvas(name: string, x: number, y: number, width: number, height: number, zIndex: number): CanvasRenderingContext2D /** 重新定位一个自定义画布 */ - relocateCanvas(name: string, x: number, y: number): void + relocateCanvas(name: string, x: number, y: number, useDelta: boolean): void /** 重新设置一个自定义画布的大小 */ resizeCanvas(name: string, x: number, y: number): void