From cb28673a7d4ccbb06762bd0f459c576d2bfef98f Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Thu, 22 Nov 2018 11:30:53 +0800 Subject: [PATCH 1/6] define object.assign --- libs/utils.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/libs/utils.js b/libs/utils.js index 44e23fd9..f3ce0012 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -8,6 +8,31 @@ function utils() { } utils.prototype.init = function () { + // 定义Object.assign + if (typeof Object.assign != "function") { + Object.assign = function(target, varArgs) { // .length of function is 2 + if (target == null) { // TypeError if undefined or null + throw new TypeError('Cannot convert undefined or null to object'); + } + + var to = Object(target); + + for (var index = 1; index < arguments.length; index++) { + var nextSource = arguments[index]; + + if (nextSource != null) { // Skip over if undefined or null + for (var nextKey in nextSource) { + // Avoid bugs when hasOwnProperty is shadowed + if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { + to[nextKey] = nextSource[nextKey]; + } + } + } + } + return to; + }; + } + } From 6913a2eaebf6528b83b8624d26e7ed6f6dbbf36d Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Thu, 22 Nov 2018 11:49:42 +0800 Subject: [PATCH 2/6] define object.assign --- libs/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/utils.js b/libs/utils.js index f3ce0012..206a0ea3 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -4,7 +4,7 @@ utils.js 工具类 */ function utils() { - + this.init(); } utils.prototype.init = function () { From 14e79668d1ad44c9da4b948f41d9283952e6c5c5 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Thu, 22 Nov 2018 16:53:33 +0800 Subject: [PATCH 3/6] display damage --- docs/event.md | 4 ++-- libs/control.js | 12 +++--------- libs/maps.js | 20 ++++++-------------- 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/docs/event.md b/docs/event.md index ea24d46a..12b2aacb 100644 --- a/docs/event.md +++ b/docs/event.md @@ -1234,7 +1234,7 @@ text为提示文字,可以在这里给输入提示文字。这里同样可以 ``` js "x,y": [ // 实际执行的事件列表 - {"type": "swtich", "condition": "...", // 计算某个表达式 + {"type": "switch", "condition": "...", // 计算某个表达式 "caseList": [ {"case": "a", "action": [// 若表达式的值等于a则执行该处事件 @@ -1282,7 +1282,7 @@ text为提示文字,可以在这里给输入提示文字。这里同样可以 需要额外注意的几点: -- 各个条件分支的判断是顺序执行的,因此若多个分支的条件都满足,将只执行最靠前的分支,同理,请不要在`"default"`分支后添加分支,这些分支将不可能被执行。 +- 各个条件分支的判断是顺序执行的,因此若多个分支的条件都满足,将只执行最靠前的分支,同理,请不要在`default`分支后添加分支,这些分支将不可能被执行。 - `default`分支并不是必要的,如果删除,则在没有满足条件的分支时将不执行任何事件。 - 即使某个场合不执行事件,对应的action数组也需要存在,不过简单的留空就好。 - switch可以不断进行嵌套,一层套一层;如某条件成立的场合再进行另一个switch判断等。 diff --git a/libs/control.js b/libs/control.js index 6ec7e3eb..134ae37f 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1536,15 +1536,9 @@ control.prototype.updateDamage = function (floorId, canvas) { if (core.isset(mapBlocks[b].event) && mapBlocks[b].event.cls.indexOf('enemy')==0 && !mapBlocks[b].disable) { - // 非系统默认的战斗事件(被覆盖) - if (mapBlocks[b].event.trigger != 'battle') { - // 判断显伤 - var event = core.floors[floorId].events[x+","+y]; - if (core.isset(event) && !(event instanceof Array)) { - if (event.displayDamage === false) - continue; - } - } + // 判定是否显伤 + if (mapBlocks[b].event.displayDamage === false) + continue; var id = mapBlocks[b].event.id; diff --git a/libs/maps.js b/libs/maps.js index 20d50ef3..510141d3 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -123,28 +123,20 @@ maps.prototype.addEvent = function (block, x, y, event) { if (!core.isset(event.data)) event.data = []; - // 覆盖noPass - if (core.isset(event.noPass)) - block.event.noPass = event.noPass; - // 覆盖enable if (!core.isset(block.disable) && core.isset(event.enable)) { block.disable=!event.enable; } - // 覆盖trigger - if (!core.isset(block.event.trigger)) { - if (core.isset(event.trigger)) block.event.trigger=event.trigger; - else block.event.trigger='action'; - } - else if (core.isset(event.trigger) && event.trigger!='checkBlock') { - block.event.trigger=event.trigger; - } - // 覆盖其他属性 + // 覆盖所有属性 for (var key in event) { - if (key!="disable" && key!="trigger" && key!="noPass" && core.isset(event[key])) { + if (key!="enable" && core.isset(event[key])) { block.event[key]=core.clone(event[key]); } } + // 给无trigger的增加trigger:action + if (!core.isset(block.event.trigger)) { + block.event.trigger = 'action'; + } } ////// 向该楼层添加剧本的楼层转换事件 ////// From 94f25319793df0cdbc810d9e07a1a1ed9b66082b Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Thu, 22 Nov 2018 17:29:37 +0800 Subject: [PATCH 4/6] Append Multi Image --- _server/editor_mode.js | 12 ++++++++---- libs/actions.js | 10 ++++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/_server/editor_mode.js b/_server/editor_mode.js index 15e40174..3dd40ece 100644 --- a/_server/editor_mode.js +++ b/_server/editor_mode.js @@ -928,19 +928,23 @@ editor_mode = function (editor) { } var ysize = selectAppend.value.indexOf('48') === -1 ? 32 : 48; - var height = editor_mode.appendPic.toImg.height; for (var ii = 0, v; v = editor_mode.appendPic.selectPos[ii]; ii++) { - var imgData = source_ctx.getImageData(v.x * 32, v.y * ysize, 32, ysize); - sprite_ctx.putImageData(imgData, ii * 32, height); + // var imgData = source_ctx.getImageData(v.x * 32, v.y * ysize, 32, ysize); + // sprite_ctx.putImageData(imgData, ii * 32, sprite.height - ysize); // sprite_ctx.drawImage(editor_mode.appendPic.img, v.x * 32, v.y * ysize, 32, ysize, ii * 32, height, 32, ysize) + + sprite_ctx.drawImage(source_ctx.canvas, v.x*32, v.y*ysize, 32, ysize, 32*ii, sprite.height - ysize, 32, ysize); } + var dt = sprite_ctx.getImageData(0, 0, sprite.width, sprite.height); var imgbase64 = sprite.toDataURL().split(',')[1]; fs.writeFile('./project/images/' + editor_mode.appendPic.imageName + '.png', imgbase64, 'base64', function (err, data) { if (err) { printe(err); throw(err) } - printe('追加素材成功,请F5刷新编辑器'); + printe('追加素材成功,请F5刷新编辑器,或继续追加当前素材'); + sprite.style.height = (sprite.height = (sprite.height+ysize)) + "px"; + sprite_ctx.putImageData(dt, 0, 0); }); } diff --git a/libs/actions.js b/libs/actions.js index 94ad235e..6275251b 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -1819,10 +1819,16 @@ actions.prototype.clickSwitchs = function (x,y) { core.ui.drawSwitchs(); break; case 8: - window.open(core.platform.isPC?"editor.html":"editor-mobile.html", "_blank"); + if (core.platform.isPC) + window.open("editor.html", "_blank"); + else + window.location.href = "editor-mobile.html"; break; case 9: - window.open(core.firstData.name+".zip", "_blank"); + if (core.platform.isPC) + window.open(core.firstData.name+".zip"); + else + window.location.href = core.firstData.name+".zip"; break; case 10: core.status.event.selection=0; From 2f9e028eecea5b93109708958cb4a79b34ac3f8e Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Thu, 22 Nov 2018 20:56:58 +0800 Subject: [PATCH 5/6] Check Console Opened --- libs/utils.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/libs/utils.js b/libs/utils.js index 206a0ea3..0a33d6da 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -825,12 +825,19 @@ utils.prototype.decodeCanvas = function (arr, width, height) { } utils.prototype.consoleOpened = function () { + if (window.Firebug && window.Firebug.chrome && window.Firebug.chrome.isInitialized) + return true; + var zoom = [1,1.1,1.25,1.5,1.75,2]; + var ow = window.outerWidth, oh = window.outerHeight; + var iw = window.innerWidth, ih = window.innerHeight; var threshold = 160; - var widthThreshold = window.outerWidth - window.innerWidth > threshold; - var heightThreshold = window.outerHeight - window.innerHeight > threshold; - return !(heightThreshold && widthThreshold) && - ((window.Firebug && window.Firebug.chrome && window.Firebug.chrome.isInitialized) - || widthThreshold || heightThreshold); + + for (var i in zoom) { + var cw = iw * zoom[i], ch = ih * zoom[i]; + if (cw>ow-threshold && ch>oh-threshold) return false; + if (cw>ow-threshold || ch>oh-threshold) return true; + } + return false; } utils.prototype.hashCode = function (obj) { From 2b43aaf5cde3f34c568344546b9590a875b86e6b Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Thu, 22 Nov 2018 21:15:42 +0800 Subject: [PATCH 6/6] Check console opened --- libs/utils.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/libs/utils.js b/libs/utils.js index 0a33d6da..ecf5178c 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -827,17 +827,10 @@ utils.prototype.decodeCanvas = function (arr, width, height) { utils.prototype.consoleOpened = function () { if (window.Firebug && window.Firebug.chrome && window.Firebug.chrome.isInitialized) return true; - var zoom = [1,1.1,1.25,1.5,1.75,2]; - var ow = window.outerWidth, oh = window.outerHeight; - var iw = window.innerWidth, ih = window.innerHeight; var threshold = 160; - - for (var i in zoom) { - var cw = iw * zoom[i], ch = ih * zoom[i]; - if (cw>ow-threshold && ch>oh-threshold) return false; - if (cw>ow-threshold || ch>oh-threshold) return true; - } - return false; + var zoom = Math.min(window.outerWidth/window.innerWidth, window.outerHeight/window.innerHeight); + return window.outerWidth - zoom*window.innerWidth > threshold + || window.outerHeight - zoom*window.innerHeight > threshold; } utils.prototype.hashCode = function (obj) {