From 56e5070f0a6a00c3443272241a2089f360f621c4 Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Wed, 31 Oct 2018 23:48:56 +0800 Subject: [PATCH 1/3] fix autotile append size bug --- _server/editor_mode.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/_server/editor_mode.js b/_server/editor_mode.js index b53b9025..cc0022cc 100644 --- a/_server/editor_mode.js +++ b/_server/editor_mode.js @@ -581,8 +581,11 @@ editor_mode = function (editor) { editor_mode.appendPic.height = image.height; if (selectAppend.value == 'autotile') { - sprite.style.width = (sprite.width = image.width) / ratio + 'px'; - sprite.style.height = (sprite.height = image.height) / ratio + 'px'; + for (var ii = 0; ii < 3; ii++) { + var newsprite = appendPicCanvas.children[ii]; + newsprite.style.width = (newsprite.width = image.width) / ratio + 'px'; + newsprite.style.height = (newsprite.height = image.height) / ratio + 'px'; + } sprite_ctx.clearRect(0, 0, sprite.width, sprite.height); sprite_ctx.drawImage(image, 0, 0); } @@ -804,11 +807,12 @@ editor_mode = function (editor) { appendConfirm.onclick = function () { var confirmAutotile = function () { - if (sprite.width % 96 !=0 || sprite.height != 128) { + var image = editor_mode.appendPic.img; + if (image.width % 96 !=0 || image.height != 128) { printe("不合法的Autotile图片!"); return; } - var imgData = source_ctx.getImageData(0,0,sprite.width,sprite.height); + var imgData = source_ctx.getImageData(0,0,image.width,image.height); sprite_ctx.putImageData(imgData, 0, 0); var imgbase64 = sprite.toDataURL().split(',')[1]; From f8220a2a632ba502234248f005b84eeb62273a52 Mon Sep 17 00:00:00 2001 From: oc Date: Thu, 1 Nov 2018 00:16:01 +0800 Subject: [PATCH 2/3] paint draw mode --- libs/ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/ui.js b/libs/ui.js index 7049a4f2..1d02d218 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -836,7 +836,7 @@ ui.prototype.drawSettings = function () { core.status.event.id = 'settings'; this.drawChoices(null, [ - "系统设置", "快捷商店", "浏览地图", "打开画板", "同步存档", "返回标题", "数据统计", "操作帮助", "关于本塔", "返回游戏" + "系统设置", "快捷商店", "浏览地图", "绘图模式", "同步存档", "返回标题", "数据统计", "操作帮助", "关于本塔", "返回游戏" ]); } From 49474e28592bbcc4d5f420161688f6c0e8e6b073 Mon Sep 17 00:00:00 2001 From: oc Date: Thu, 1 Nov 2018 00:28:38 +0800 Subject: [PATCH 3/3] onup --- libs/actions.js | 23 ++--------------------- libs/core.js | 4 ++-- main.js | 12 +++--------- 3 files changed, 7 insertions(+), 32 deletions(-) diff --git a/libs/actions.js b/libs/actions.js index 1724c529..a43b19ce 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -372,18 +372,10 @@ actions.prototype.onmove = function (loc) { } ////// 当点击(触摸)事件放开时 ////// -actions.prototype.onup = function (loc) { +actions.prototype.onup = function () { if (core.isset(core.status.replay)&&core.status.replay.replaying &&core.status.event.id!='save'&&(core.status.event.id||"").indexOf('book')!=0&&core.status.event.id!='viewMaps') return; - // 画板 - if (core.status.played && (core.status.event||{}).id=='paint') { - this.onupPaint(loc.x, loc.y) - return; - } - - var x = parseInt(loc.x / loc.size), y = parseInt(loc.y / loc.size); - clearTimeout(core.timeout.onDownTimeout); core.timeout.onDownTimeout = null; clearInterval(core.interval.onDownInterval); @@ -2452,18 +2444,7 @@ actions.prototype.onmovePaint = function (x, y) { core.status.event.data.y = y; } -actions.prototype.onupPaint = function (x,y) { - x+=core.bigmap.offsetX; - y+=core.bigmap.offsetY; - if (core.status.event.data.erase) { - core.clearMap('route', x-5, y-5, 10, 10); - } - else if (core.status.event.data.x!=null) { - var midx = (core.status.event.data.x+x)/2, midy = (core.status.event.data.y+y)/2; - core.canvas.route.quadraticCurveTo(midx, midy, x, y); - core.canvas.route.stroke(); - } - +actions.prototype.onupPaint = function () { core.status.event.data.x = null; core.status.event.data.y = null; // 保存 diff --git a/libs/core.js b/libs/core.js index 77ad01e9..bda156dc 100644 --- a/libs/core.js +++ b/libs/core.js @@ -407,8 +407,8 @@ core.prototype.onmove = function (loc) { } ////// 当点击(触摸)事件放开时 ////// -core.prototype.onup = function (loc) { - return core.actions.onup(loc); +core.prototype.onup = function () { + return core.actions.onup(); } ////// 获得点击事件相对左上角的坐标(0到12之间) ////// diff --git a/main.js b/main.js index 2def3d70..f82481fd 100644 --- a/main.js +++ b/main.js @@ -344,12 +344,9 @@ main.dom.data.onmousemove = function (e) { } ////// 鼠标放开时 ////// -main.dom.data.onmouseup = function (e) { +main.dom.data.onmouseup = function () { try { - e.stopPropagation(); - var loc = main.core.getClickLoc(e.clientX, e.clientY); - if (loc == null) return; - main.core.onup(loc); + main.core.onup(); }catch (e) {} } @@ -386,10 +383,7 @@ main.dom.data.ontouchmove = function (e) { ////// 手指离开触摸屏时 ////// main.dom.data.ontouchend = function () { try { - e.preventDefault(); - var loc = main.core.getClickLoc(e.targetTouches[0].clientX, e.targetTouches[0].clientY); - if (loc == null) return; - main.core.onup(loc); + main.core.onup(); } catch (e) { } }