From 58c4600fbd8e0f6e1fcb04f563bb4ef1ab7c2828 Mon Sep 17 00:00:00 2001 From: oc Date: Tue, 14 May 2019 16:51:34 +0800 Subject: [PATCH 01/46] doAction keepUI --- _docs/api.md | 3 ++- libs/events.js | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/_docs/api.md b/_docs/api.md index c1c65a3d..712e04cd 100644 --- a/_docs/api.md +++ b/_docs/api.md @@ -952,10 +952,11 @@ core.startEvents(list, x, y, callback) 此函数将调用core.setEvents,然后停止勇士,再执行core.doAction()。 -core.doAction() +core.doAction(keepUI) 执行下一个自定义事件。 此函数将检测事件列表是否全部执行完毕,如果是则执行回调函数。 否则,将从事件列表中弹出下一个事件,并调用core.doEvent进行执行。 +如果keepUI为true,则不会清掉UI层和selector,适合于自己用脚本的绘制。 core.insertAction(action, x, y, callback, addToLast) diff --git a/libs/events.js b/libs/events.js index 8c72173f..e76c89dc 100644 --- a/libs/events.js +++ b/libs/events.js @@ -788,11 +788,13 @@ events.prototype.startEvents = function (list, x, y, callback) { } ////// 执行当前自定义事件列表中的下一个事件 ////// -events.prototype.doAction = function () { - // 清空boxAnimate和UI层 - core.clearUI(); - clearInterval(core.status.event.interval); - core.status.event.interval = null; +events.prototype.doAction = function (keepUI) { + if (!keepUI) { + // 清空boxAnimate和UI层 + core.clearUI(); + clearInterval(core.status.event.interval); + core.status.event.interval = null; + } // 判定是否执行完毕 if (this._doAction_finishEvents()) return; // 当前点坐标和前缀 From dae1ace3ffb539539e7c5e71f973818df6576644 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Tue, 21 May 2019 13:34:23 +0800 Subject: [PATCH 02/46] toolbox description --- libs/events.js | 2 +- libs/ui.js | 30 ++++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/libs/events.js b/libs/events.js index e76c89dc..f0807d4c 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1876,7 +1876,7 @@ events.prototype.setGlobalFlag = function (name, value) { events.prototype.closeDoor = function (x, y, id, callback) { id = id || ""; if (!(id.endsWith("Door") || id.endsWith("Wall")) - || !core.material.icons.animates[id] || core.getBlock(x, y) != null) { + || core.material.icons.animates[id] == null || core.getBlock(x, y) != null) { if (callback) callback(); return; } diff --git a/libs/ui.js b/libs/ui.js index d67f17db..4cbb3260 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -1664,8 +1664,19 @@ ui.prototype.drawFly = function(page) { core.setTextAlign('ui', 'center'); core.fillText('ui', '楼层跳跃', this.HPIXEL, 60, '#FFFFFF', this._buildFont(28, true)); core.fillText('ui', '返回游戏', this.HPIXEL, this.PIXEL - 13, null, this._buildFont(15, true)) - core.fillText('ui', title, this.PIXEL - 60, this.HPIXEL + 39, null, this._buildFont(19, true)); + var middle = this.HPIXEL + 39; + + // 换行 + var lines = core.splitLines('ui', title, 120, this._buildFont(19, true)); + var start_y = middle - (lines.length - 1) * 11; + for (var i in lines) { + core.fillText('ui', lines[i], this.PIXEL - 60, start_y); + start_y += 22; + } + + // core.fillText('ui', title, this.PIXEL - 60, this.HPIXEL + 39, null, this._buildFont(19, true)); + if (core.actions._getNextFlyFloor(1) != page) { core.fillText('ui', '▲', this.PIXEL - 60, middle - 64, null, this._buildFont(17, false)); core.fillText('ui', '▲', this.PIXEL - 60, middle - 96); @@ -1913,9 +1924,12 @@ ui.prototype._drawToolbox_drawDescription = function (info, max_height) { // 检查能否eval text = core.replaceText(text); } catch (e) {} - var lines = core.splitLines('ui', text, this.PIXEL - 15, this._buildFont(17, false)); - // --- 开始逐行绘制 - var curr = 62, line_height = 25; + + for (var font_size = 17; font_size >= 14; font_size -= 3) { + var lines = core.splitLines('ui', text, this.PIXEL - 15, this._buildFont(font_size, false)); + var line_height = parseInt(font_size * 1.4), curr = 37 + line_height; + if (curr + lines.length * line_height < max_height) break; + } core.setFillStyle('ui', '#FFFFFF'); for (var i=0;i= 11; font_size -= 3) { + var lines = core.splitLines('ui', text, this.PIXEL - 15, this._buildFont(font_size, false)); + var line_height = parseInt(font_size * 1.4), curr = 37 + line_height; + if (curr + lines.length * line_height < max_height) break; + } core.setFillStyle('ui', '#FFFFFF'); for (var i = 0; i < lines.length; ++i) { core.fillText('ui', lines[i], 10, curr); From fa46aef44b4368b03751ecfad7d227b11918fcbc Mon Sep 17 00:00:00 2001 From: oc Date: Tue, 21 May 2019 19:30:35 +0800 Subject: [PATCH 03/46] fillTextWithMaxWidth --- _docs/api.md | 3 ++- libs/ui.js | 23 +++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/_docs/api.md b/_docs/api.md index 712e04cd..3943d347 100644 --- a/_docs/api.md +++ b/_docs/api.md @@ -1616,9 +1616,10 @@ core.clearMap(name) 该函数的name也可以是'all',若为'all'则为清空所有系统画布。 -core.fillText(name, text, x, y, style, font) +core.fillText(name, text, x, y, style, font, maxWidth) 在某个画布上绘制一段文字。 text为要绘制的文本,x,y为要绘制的坐标,style可选为绘制的样式,font可选为绘制的字体。(下同) +如果maxWidth不为null,则视为文字最大宽度,如果超过此宽度则会自动放缩文字直到自适应为止。 请注意textAlign和textBaseline将决定绘制的左右对齐和上下对齐方式。 具体可详见core.setTextAlign()和core.setTextBaseline()函数。 diff --git a/libs/ui.js b/libs/ui.js index 4cbb3260..cdc20de8 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -53,11 +53,30 @@ ui.prototype.clearMap = function (name, x, y, width, height) { } ////// 在某个canvas上绘制一段文字 ////// -ui.prototype.fillText = function (name, text, x, y, style, font) { +ui.prototype.fillText = function (name, text, x, y, style, font, maxWidth) { if (style) core.setFillStyle(name, style); if (font) core.setFont(name, font); var ctx = this.getContextByName(name); - if (ctx) ctx.fillText(text, x, y); + if (ctx) { + // 如果存在最大宽度 + if (maxWidth != null) + this._fillTextWithMaxWidth(ctx, text, x, y, maxWidth); + else + ctx.fillText(text, x, y); + } +} + +////// 自适配字体大小 +ui.prototype._fillTextWithMaxWidth = function (ctx, text, x, y, maxWidth) { + // 获得当前字体 + var font = ctx.font, u = /(\d+)px/.exec(font); + if (u == null) return ctx.fillText(text, x, y); + for (var font_size = parseInt(u[1]); font_size >= 8; font_size--) { + ctx.font = font.replace(/(\d+)px/, font_size+"px"); + if (ctx.measureText(text).width <= maxWidth) break; + } + ctx.fillText(text, x, y); + ctx.font = font; } ////// 在某个canvas上绘制粗体 ////// From 42d45233a13ad72e909c928694c9fbbbac7682ae Mon Sep 17 00:00:00 2001 From: oc Date: Tue, 21 May 2019 19:52:27 +0800 Subject: [PATCH 04/46] server case sensitive --- 启动服务.exe | Bin 54272 -> 54784 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/启动服务.exe b/启动服务.exe index f426d69b93d0520214c33580eae96a15420d1bc9..0735ba06154a05bebee8544b995c6446beaa1cde 100644 GIT binary patch delta 13527 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 delta 12964 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 From f90f71db2120338113ce915efa34bd4a941095c8 Mon Sep 17 00:00:00 2001 From: oc Date: Wed, 22 May 2019 22:34:43 +0800 Subject: [PATCH 05/46] drawTextBox lineHeight --- libs/ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/ui.js b/libs/ui.js index cdc20de8..21ce736e 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -894,7 +894,7 @@ ui.prototype._drawTextBox_getHorizontalPosition = function (content, titleInfo, ui.prototype._drawTextBox_getVerticalPosition = function (content, titleInfo, posInfo, validWidth) { var textAttribute = core.status.textAttribute || core.initStatus.textAttribute; - var lineHeight = textAttribute.textfont + 5; + var lineHeight = textAttribute.textfont + 6; var realContent = this._getRealContent(content); var height = 30 + lineHeight * core.splitLines("ui", realContent, validWidth, this._buildFont()).length; if (titleInfo.title) height += textAttribute.titlefont + 5; From 272d40315c5a1b1142e5c955413cb4c0e9b4d4b1 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Thu, 23 May 2019 12:52:39 +0800 Subject: [PATCH 06/46] getNumberById --- _docs/api.md | 3 ++- libs/maps.js | 6 ++++++ libs/ui.js | 25 ++++++++++++++++++++++--- project/functions.js | 8 ++++---- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/_docs/api.md b/_docs/api.md index 712e04cd..3943d347 100644 --- a/_docs/api.md +++ b/_docs/api.md @@ -1616,9 +1616,10 @@ core.clearMap(name) 该函数的name也可以是'all',若为'all'则为清空所有系统画布。 -core.fillText(name, text, x, y, style, font) +core.fillText(name, text, x, y, style, font, maxWidth) 在某个画布上绘制一段文字。 text为要绘制的文本,x,y为要绘制的坐标,style可选为绘制的样式,font可选为绘制的字体。(下同) +如果maxWidth不为null,则视为文字最大宽度,如果超过此宽度则会自动放缩文字直到自适应为止。 请注意textAlign和textBaseline将决定绘制的左右对齐和上下对齐方式。 具体可详见core.setTextAlign()和core.setTextBaseline()函数。 diff --git a/libs/maps.js b/libs/maps.js index fe9fd6bf..ffa3f590 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -62,6 +62,12 @@ maps.prototype._mapIntoBlocks = function (map, floor, floorId) { ////// 从ID获得数字 ////// maps.prototype.getNumberById = function (id) { + core.status.id2number = core.status.id2number || {}; + if (core.status.id2number[id] != null) return core.status.id2number[id]; + return core.status.id2number[id] = this._getNumberById(id); +} + +maps.prototype._getNumberById = function (id) { for (var number in this.blocksInfo) { if ((this.blocksInfo[number] || {}).id == id) return parseInt(number) || 0; diff --git a/libs/ui.js b/libs/ui.js index 4cbb3260..21ce736e 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -53,11 +53,30 @@ ui.prototype.clearMap = function (name, x, y, width, height) { } ////// 在某个canvas上绘制一段文字 ////// -ui.prototype.fillText = function (name, text, x, y, style, font) { +ui.prototype.fillText = function (name, text, x, y, style, font, maxWidth) { if (style) core.setFillStyle(name, style); if (font) core.setFont(name, font); var ctx = this.getContextByName(name); - if (ctx) ctx.fillText(text, x, y); + if (ctx) { + // 如果存在最大宽度 + if (maxWidth != null) + this._fillTextWithMaxWidth(ctx, text, x, y, maxWidth); + else + ctx.fillText(text, x, y); + } +} + +////// 自适配字体大小 +ui.prototype._fillTextWithMaxWidth = function (ctx, text, x, y, maxWidth) { + // 获得当前字体 + var font = ctx.font, u = /(\d+)px/.exec(font); + if (u == null) return ctx.fillText(text, x, y); + for (var font_size = parseInt(u[1]); font_size >= 8; font_size--) { + ctx.font = font.replace(/(\d+)px/, font_size+"px"); + if (ctx.measureText(text).width <= maxWidth) break; + } + ctx.fillText(text, x, y); + ctx.font = font; } ////// 在某个canvas上绘制粗体 ////// @@ -875,7 +894,7 @@ ui.prototype._drawTextBox_getHorizontalPosition = function (content, titleInfo, ui.prototype._drawTextBox_getVerticalPosition = function (content, titleInfo, posInfo, validWidth) { var textAttribute = core.status.textAttribute || core.initStatus.textAttribute; - var lineHeight = textAttribute.textfont + 5; + var lineHeight = textAttribute.textfont + 6; var realContent = this._getRealContent(content); var height = 30 + lineHeight * core.splitLines("ui", realContent, validWidth, this._buildFont()).length; if (titleInfo.title) height += textAttribute.titlefont + 5; diff --git a/project/functions.js b/project/functions.js index fc876771..9ff2e15b 100644 --- a/project/functions.js +++ b/project/functions.js @@ -913,9 +913,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = "saveData": function () { // 存档操作,此函数应该返回“具体要存档的内容” - // 勇士和hash值(防改存档文件来作弊) - var hero = core.clone(core.status.hero), - hashCode = core.utils.hashCode(hero); // 差异化存储values var values = {}; for (var key in core.values) { @@ -926,7 +923,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 要存档的内容 var data = { 'floorId': core.status.floorId, - 'hero': hero, + 'hero': core.clone(core.status.hero), 'hard': core.status.hard, 'maps': core.maps.saveMap(), 'route': core.encodeRoute(core.status.route), @@ -936,6 +933,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = "time": new Date().getTime(), "hashCode": hashCode }; + if (core.flags.checkConsole) { + data.hashCode = core.utils.hashCode(data.hero); + } // 设置商店次数 for (var shopId in core.status.shops) { data.shops[shopId] = { From a778dda4de1ce5bd960b1cd2f1284c2742c81d4a Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Thu, 23 May 2019 17:08:06 +0800 Subject: [PATCH 07/46] quickLoadEquip --- libs/items.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/libs/items.js b/libs/items.js index a68aa04c..d55066c5 100644 --- a/libs/items.js +++ b/libs/items.js @@ -372,7 +372,8 @@ items.prototype._realLoadEquip = function (type, loadId, unloadId, callback) { } items.prototype._realLoadEquip_playSound = function () { - core.stopSound(); // 先停止所有音效(为了避免快捷换装很乱) + if (core.hasFlag("__quickLoadEquip__")) return; + core.stopSound(); core.playSound('equip.mp3'); } @@ -398,20 +399,30 @@ items.prototype.quickLoadEquip = function (index) { if (v && !this.canEquip(v, true)) return; } + core.setFlag("__quickLoadEquip__", true); // 快速换装 + var toEquip = []; for (var i = 0; i < equipSize; i++) { var now = core.status.hero.equipment[i]; - if (now) { - this.unloadEquip(i); - core.status.route.push("unEquip:" + i); + // --- 只考虑diff的装备 + var to = current[i]; + if (now != to) { + toEquip.push(to || null); + if (now) { + this.unloadEquip(i); + core.status.route.push("unEquip:" + i); + } } } - for (var i = 0; i < equipSize; i++) { - var to = current[i]; + for (var i in toEquip) { + var to = toEquip[i]; if (to) { this.loadEquip(to); core.status.route.push("equip:" + to); } } + core.removeFlag("__quickLoadEquip__"); + this._realLoadEquip_playSound(); + core.drawTip("成功换上" + index + "号套装"); } From 22f89277086bab52268b636739d312ef28ffb944 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Fri, 24 May 2019 11:34:55 +0800 Subject: [PATCH 08/46] getEnemyInfo query cache --- project/functions.js | 112 +++++++++++++++++++++++-------------------- 1 file changed, 60 insertions(+), 52 deletions(-) diff --git a/project/functions.js b/project/functions.js index 9ff2e15b..8e84d5e4 100644 --- a/project/functions.js +++ b/project/functions.js @@ -513,64 +513,72 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = mon_def = hero_atk - 1; } - // 光环检查 - // 从V2.5.4开始,对光环效果增加缓存,以解决多次重复计算的问题,从而大幅提升运行效率。 - // 检查当前楼层所有光环怪物(数字25) - var hp_buff = 0, - atk_buff = 0, - def_buff = 0, - cnt = 0; // ------ 支援 ------ var guards = []; - // 检查光环缓存 - var index = x != null && y != null ? (x + "," + y) : "floor"; - if (!core.status.checkBlock) core.status.checkBlock = {}; - if (!core.status.checkBlock.cache) core.status.checkBlock.cache = {}; - var cache = core.status.checkBlock.cache[index]; - if (!cache) { - // 没有该点的缓存,则遍历每个图块 - core.status.maps[floorId].blocks.forEach(function (block) { - if (!block.disable) { - // 获得该图块的ID - var id = block.event.id, - enemy = core.material.enemys[id]; - // 检查是不是怪物,且是否拥有该特殊属性 - if (enemy && core.hasSpecial(enemy.special, 25)) { - // 检查是否可叠加 - if (enemy.add || cnt == 0) { - hp_buff += enemy.value || 0; - atk_buff += enemy.atkValue || 0; - def_buff += enemy.defValue || 0; - cnt++; - } - } - // 检查【支援】技能 - if (enemy && core.hasSpecial(enemy.special, 26) && - // 检查支援条件,坐标存在,距离为1,且不能是自己 - // 其他类型的支援怪,比如十字之类的话.... 看着做是一样的 - x != null && y != null && Math.abs(block.x - x) <= 1 && Math.abs(block.y - y) <= 1 && !(x == block.x && y == block.y)) { - // 记录怪物的x,y,ID - guards.push([block.x, block.y, id]); - } - // TODO:如果有其他类型光环怪物在这里仿照添加检查 - } - }); - - core.status.checkBlock.cache[index] = { "hp_buff": hp_buff, "atk_buff": atk_buff, "def_buff": def_buff, "guards": guards }; - } else { - // 直接使用缓存数据 - hp_buff = cache.hp_buff; - atk_buff = cache.atk_buff; - def_buff = cache.def_buff; - guards = cache.guards; + // 光环检查 + // 在这里判定是否需要遍历全图(由于光环需要遍历全图,应尽可能不需要以减少计算量,尤其是大地图) + var query = function () { + var floorIds = ["MTx"]; // 在这里给出所有需要遍历的楼层(即有光环或支援等) + return core.inArray(floorIds, floorId); // 也可以写其他的判定条件 } - // 增加比例;如果要增加数值可以直接在这里修改 - mon_hp *= (1 + hp_buff / 100); - mon_atk *= (1 + atk_buff / 100); - mon_def *= (1 + def_buff / 100); + if (query()) { + // 从V2.5.4开始,对光环效果增加缓存,以解决多次重复计算的问题,从而大幅提升运行效率。 + // 检查当前楼层所有光环怪物(数字25) + var hp_buff = 0, + atk_buff = 0, + def_buff = 0, + cnt = 0; + // 检查光环缓存 + var index = x != null && y != null ? (x + "," + y) : "floor"; + if (!core.status.checkBlock) core.status.checkBlock = {}; + if (!core.status.checkBlock.cache) core.status.checkBlock.cache = {}; + var cache = core.status.checkBlock.cache[index]; + if (!cache) { + // 没有该点的缓存,则遍历每个图块 + core.status.maps[floorId].blocks.forEach(function (block) { + if (!block.disable) { + // 获得该图块的ID + var id = block.event.id, + enemy = core.material.enemys[id]; + // 检查是不是怪物,且是否拥有该特殊属性 + if (enemy && core.hasSpecial(enemy.special, 25)) { + // 检查是否可叠加 + if (enemy.add || cnt == 0) { + hp_buff += enemy.value || 0; + atk_buff += enemy.atkValue || 0; + def_buff += enemy.defValue || 0; + cnt++; + } + } + // 检查【支援】技能 + if (enemy && core.hasSpecial(enemy.special, 26) && + // 检查支援条件,坐标存在,距离为1,且不能是自己 + // 其他类型的支援怪,比如十字之类的话.... 看着做是一样的 + x != null && y != null && Math.abs(block.x - x) <= 1 && Math.abs(block.y - y) <= 1 && !(x == block.x && y == block.y)) { + // 记录怪物的x,y,ID + guards.push([block.x, block.y, id]); + } + // TODO:如果有其他类型光环怪物在这里仿照添加检查 + } + }); + + core.status.checkBlock.cache[index] = { "hp_buff": hp_buff, "atk_buff": atk_buff, "def_buff": def_buff, "guards": guards }; + } else { + // 直接使用缓存数据 + hp_buff = cache.hp_buff; + atk_buff = cache.atk_buff; + def_buff = cache.def_buff; + guards = cache.guards; + } + + // 增加比例;如果要增加数值可以直接在这里修改 + mon_hp *= (1 + hp_buff / 100); + mon_atk *= (1 + atk_buff / 100); + mon_def *= (1 + def_buff / 100); + } // TODO:可以在这里新增其他的怪物数据变化 // 比如仿攻(怪物攻击不低于勇士攻击): From a57771d1bfbc1940780c5e2cd4fcd0352bf4acf6 Mon Sep 17 00:00:00 2001 From: oc Date: Sun, 26 May 2019 12:01:39 +0800 Subject: [PATCH 09/46] changeFloor symmetry point --- _server/MotaAction.g4 | 8 ++++---- _server/editor_mode.js | 2 +- _server/editor_unsorted_1.js | 17 ++++++++++++++--- libs/events.js | 13 ++++++++++++- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index d8593e39..82deb5dc 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -228,7 +228,7 @@ default : [null,"MT1",null,0,0,null,500,null] var toFloorId = IdString_0; if (Floor_List_0!='floorId') toFloorId = Floor_List_0; var loc = ', "loc": ['+Number_0+', '+Number_1+']'; -if (Stair_List_0==='now')loc = ''; +if (Stair_List_0===':now') loc = ''; else if (Stair_List_0!=='loc')loc = ', "stair": "'+Stair_List_0+'"'; DirectionEx_List_0 = DirectionEx_List_0 && (', "direction": "'+DirectionEx_List_0+'"'); Int_0 = (Int_0!=='') ?(', "time": '+Int_0):''; @@ -2032,8 +2032,8 @@ Floor_List /*Floor_List ['floorId',':before',':next']*/; Stair_List - : '坐标'|'上楼梯'|'下楼梯'|'保持不变' - /*Stair_List ['loc','upFloor','downFloor','now']*/; + : '坐标'|'上楼梯'|'下楼梯'|'保持不变'|'中心对称点'|'x对称点'|'y对称点' + /*Stair_List ['loc','upFloor','downFloor',':now',':symmetry',':symmetry_x',':symmetry_y']*/; SetTextPosition_List : '不改变'|'距离顶部'|'居中'|'距离底部' @@ -2220,7 +2220,7 @@ ActionParser.prototype.parse = function (obj,type) { if(!obj)obj={}; if(!this.isset(obj.loc)) { obj.loc=[0,0]; - if (!this.isset(obj.stair)) obj.stair='now'; + if (!this.isset(obj.stair)) obj.stair=':now'; } if (obj.floorId==':before'||obj.floorId==':next') { obj.floorType=obj.floorId; diff --git a/_server/editor_mode.js b/_server/editor_mode.js index 8bf22dc9..f0215cf0 100644 --- a/_server/editor_mode.js +++ b/_server/editor_mode.js @@ -57,7 +57,7 @@ editor_mode = function (editor) { printe(objs_.slice(-1)[0]); throw(objs_.slice(-1)[0]) } - ;printf('修改成功'); + ;printf('修改成功' + (data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.firstData.name == 'template' ? '\n\n请注意:全塔属性的name尚未修改,请及时予以设置' : '')); } switch (mode) { case 'loc': diff --git a/_server/editor_unsorted_1.js b/_server/editor_unsorted_1.js index 0d3861d8..c37078e1 100644 --- a/_server/editor_unsorted_1.js +++ b/_server/editor_unsorted_1.js @@ -502,6 +502,10 @@ editor.constructor.prototype.listen=function () { addFloorEvent.style.display='block'; addFloorEvent.children[0].innerHTML='绑定下楼事件'; } + else if (['leftPortal','rightPortal','downPortal','upPortal'].indexOf(thisevent.id)>=0) { + addFloorEvent.style.display='block'; + addFloorEvent.children[0].innerHTML='绑定楼传事件'; + } else addFloorEvent.style.display='none'; chooseThis.children[0].innerHTML='选中此点'+'('+editor.pos.x+','+editor.pos.y+')' @@ -524,20 +528,27 @@ editor.constructor.prototype.listen=function () { editor.hideMidMenu(); e.stopPropagation(); var thisevent = editor.map[editor.pos.y][editor.pos.x]; + var loc = editor.pos.x+","+editor.pos.y; if (thisevent.id=='upFloor') { - editor.currentFloorData.changeFloor[editor.pos.x+","+editor.pos.y] = {"floorId": ":next", "stair": "downFloor"}; + editor.currentFloorData.changeFloor[loc] = {"floorId": ":next", "stair": "downFloor"}; } else if (thisevent.id=='downFloor') { - editor.currentFloorData.changeFloor[editor.pos.x+","+editor.pos.y] = {"floorId": ":before", "stair": "upFloor"}; + editor.currentFloorData.changeFloor[loc] = {"floorId": ":before", "stair": "upFloor"}; + } + else if (thisevent.id=='leftPortal' || thisevent.id=='rightPortal') { + editor.currentFloorData.changeFloor[loc] = {"floorId": ":next", "stair": ":symmetry_x"} + } + else if (thisevent.id=='upPortal' || thisevent.id=='downPortal') { + editor.currentFloorData.changeFloor[loc] = {"floorId": ":next", "stair": ":symmetry_y"} } editor.file.saveFloorFile(function (err) { if (err) { printe(err); throw(err) } - ;printf('添加楼梯事件成功'); editor.drawPosSelection(); editor_mode.showMode('loc'); + printf('添加楼梯事件成功'); }); } diff --git a/libs/events.js b/libs/events.js index f0807d4c..41a3b1c7 100644 --- a/libs/events.js +++ b/libs/events.js @@ -548,8 +548,19 @@ events.prototype._changeFloor_getHeroLoc = function (floorId, stair, heroLoc) { if (!heroLoc) heroLoc = core.clone(core.status.hero.loc); if (stair) { + // --- 对称 + if (stair == ':now') + heroLoc = core.clone(core.status.hero.loc); + else if (stair == ':symmetry') { + heroLoc.x = core.bigmap.width - 1 - core.getHeroLoc('x'); + heroLoc.y = core.bigmap.height - 1 - core.getHeroLoc('y'); + } + else if (stair == ':symmetry_x') + heroLoc.x = core.bigmap.width - 1 - core.getHeroLoc('x'); + else if (stair == ':symmetry_y') + heroLoc.y = core.bigmap.height - 1 - core.getHeroLoc('y'); // 检查该层地图的 upFloor & downFloor - if (core.status.maps[floorId][stair]) { + else if (core.status.maps[floorId][stair]) { heroLoc.x = core.status.maps[floorId][stair][0]; heroLoc.y = core.status.maps[floorId][stair][1]; } From 304bd80bbcd2936c864c28789bcca2d2a28beff6 Mon Sep 17 00:00:00 2001 From: oc Date: Sun, 26 May 2019 13:58:08 +0800 Subject: [PATCH 10/46] uievent runtime --- libs/control.js | 7 ++- libs/events.js | 70 ++++++++++++++++++++++ libs/ui.js | 156 +++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 216 insertions(+), 17 deletions(-) diff --git a/libs/control.js b/libs/control.js index d3289e37..905be87f 100644 --- a/libs/control.js +++ b/libs/control.js @@ -152,8 +152,11 @@ control.prototype._animationFrame_globalAnimate = function (timestamp) { } control.prototype._animationFrame_selector = function (timestamp) { - if (timestamp - core.animateFrame.selectorTime <= 20 || !core.dymCanvas._selector) return; - var opacity = parseFloat(core.dymCanvas._selector.canvas.style.opacity); + if (timestamp - core.animateFrame.selectorTime <= 20) return; + var opacity = null; + if (core.dymCanvas._selector) opacity = parseFloat(core.dymCanvas._selector.canvas.style.opacity); + else if (core.dymCanvas._uievent_selector) opacity = parseFloat(core.dymCanvas._uievent_selector.canvas.style.opacity); + if (!core.isset(opacity)) return; if (core.animateFrame.selectorUp) opacity += 0.02; else diff --git a/libs/events.js b/libs/events.js index 41a3b1c7..67d409e8 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1620,6 +1620,76 @@ events.prototype._action_exit = function (data, x, y, prefix) { core.doAction(); } +events.prototype._action_previewUIEvent = function (data, x, y, prefix) { + this.insert(data.action); + core.doAction(); +} + +events.prototype._action_clearMap = function (data, x, y, prefix) { + core.ui._uievent_clearMap(data); + core.doAction(); +} + +events.prototype._action_fillText = function (data, x, y, prefix) { + core.ui._uievent_fillText(data); + core.doAction(); +} + +events.prototype._action_fillBoldText = function (data, x, y, prefix) { + core.ui._uievent_fillBoldText(data); + core.doAction(); +} + +events.prototype._action_fillRect = function (data, x, y, prefix) { + core.ui._uievent_fillRect(data); + core.doAction(); +} + +events.prototype._action_strokeRect = function (data, x, y, prefix) { + core.ui._uievent_strokeRect(data); + core.doAction(); +} + +events.prototype._action_drawLine = function (data, x, y, prefix) { + core.ui._uievent_drawLine(data); + core.doAction(); +} + +events.prototype._action_drawArrow = function (data, x, y, prefix) { + core.ui._uievent_drawArrow(data); + core.doAction(); +} + +events.prototype._action_setAttribute = function (data, x, y, prefix) { + core.ui._uievent_setAttribute(data); + core.doAction(); +} + +events.prototype._action_drawImage = function (data, x, y, prefix) { + core.ui._uievent_drawImage(data); + core.doAction(); +} + +events.prototype._action_drawIcon = function (data, x, y, prefix) { + core.ui._uievent_drawIcon(data); + core.doAction(); +} + +events.prototype._action_drawSelector = function (data, x, y, prefix) { + core.ui._uievent_drawSelector(data); + core.doAction(); +} + +events.prototype._action_drawBackground = function (data, x, y, prefix) { + core.ui._uievent_drawBackground(data); + core.doAction(); +} + +events.prototype._action_drawTextContent = function (data, x, y, prefix) { + core.ui._uievent_drawTextContent(data); + core.doAction(); +} + // ------ 点击状态栏图标所进行的一些操作 ------ // ////// 判断当前能否进入某个事件 ////// diff --git a/libs/ui.js b/libs/ui.js index 21ce736e..f06a9a87 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -37,6 +37,13 @@ ui.prototype.getContextByName = function (name) { return null; } +ui.prototype._createUIEvent = function () { + if (main.mode == 'editor') return; + if (!core.dymCanvas['uievent']) { + core.createCanvas('uievent', 0, 0, this.PIXEL, this.PIXEL, 135); + } +} + ////// 清除地图 ////// ui.prototype.clearMap = function (name, x, y, width, height) { if (name == 'all') { @@ -52,6 +59,15 @@ ui.prototype.clearMap = function (name, x, y, width, height) { } } +ui.prototype._uievent_clearMap = function (data) { + if (main.mode != 'editor' && (data.x == null || data.y == null || data.width == null || data.height == null)) { + this.deleteCanvas('uievent'); + return; + } + this._createUIEvent(); + this.clearMap('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.width), core.calValue(data.height)); +} + ////// 在某个canvas上绘制一段文字 ////// ui.prototype.fillText = function (name, text, x, y, style, font, maxWidth) { if (style) core.setFillStyle(name, style); @@ -66,6 +82,11 @@ ui.prototype.fillText = function (name, text, x, y, style, font, maxWidth) { } } +ui.prototype._uievent_fillText = function (data) { + this._createUIEvent(); + this.fillText('uievent', core.replaceText(data.text), core.calValue(data.x), core.calValue(data.y), data.style, data.font, data.maxWidth); +} + ////// 自适配字体大小 ui.prototype._fillTextWithMaxWidth = function (ctx, text, x, y, maxWidth) { // 获得当前字体 @@ -94,6 +115,11 @@ ui.prototype.fillBoldText = function (name, text, x, y, style, font) { ctx.fillText(text, x, y); } +ui.prototype._uievent_fillBoldText = function (data) { + this._createUIEvent(); + this.fillBoldText('uievent', core.replaceText(data.text), core.calValue(data.x), core.calValue(data.y), data.style, data.font); +} + ////// 在某个canvas上绘制一个矩形 ////// ui.prototype.fillRect = function (name, x, y, width, height, style) { if (style) core.setFillStyle(name, style); @@ -101,6 +127,11 @@ ui.prototype.fillRect = function (name, x, y, width, height, style) { if (ctx) ctx.fillRect(x, y, width, height); } +ui.prototype._uievent_fillRect = function (data) { + this._createUIEvent(); + this.fillRect('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.width), core.calValue(data.height), data.style); +} + ////// 在某个canvas上绘制一个矩形的边框 ////// ui.prototype.strokeRect = function (name, x, y, width, height, style, lineWidth) { if (style) core.setStrokeStyle(name, style); @@ -109,6 +140,11 @@ ui.prototype.strokeRect = function (name, x, y, width, height, style, lineWidth) if (ctx) ctx.strokeRect(x, y, width, height); } +ui.prototype._uievent_strokeRect = function (data) { + this._createUIEvent(); + this.strokeRect('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.width), core.calValue(data.height), data.style, data.lineWidth); +} + ////// 在某个canvas上绘制一条线 ////// ui.prototype.drawLine = function (name, x1, y1, x2, y2, style, lineWidth) { if (style) core.setStrokeStyle(name, style); @@ -121,6 +157,11 @@ ui.prototype.drawLine = function (name, x1, y1, x2, y2, style, lineWidth) { ctx.stroke(); } +ui.prototype._uievent_drawLine = function (data) { + this._createUIEvent(); + this.drawLine('uievent', core.calValue(data.x1), core.calValue(data.y1), core.calValue(data.x2), core.calValue(data.y2), data.style, data.lineWidth); +} + ////// 在某个canvas上绘制一个箭头 ////// ui.prototype.drawArrow = function (name, x1, y1, x2, y2, style, lineWidth) { if (x1==x2 && y1==y2) return; @@ -140,6 +181,11 @@ ui.prototype.drawArrow = function (name, x1, y1, x2, y2, style, lineWidth) { ctx.stroke(); } +ui.prototype._uievent_drawArrow = function (data) { + this._createUIEvent(); + this.drawArrow('uievent', core.calValue(data.x1), core.calValue(data.y1), core.calValue(data.x2), core.calValue(data.y2), data.style, data.lineWidth); +} + ////// 设置某个canvas的文字字体 ////// ui.prototype.setFont = function (name, font) { var ctx = this.getContextByName(name); @@ -200,6 +246,17 @@ ui.prototype.setTextBaseline = function (name, baseline) { if (ctx) ctx.textBaseline = baseline; } +ui.prototype._uievent_setAttribute = function (data) { + this._createUIEvent(); + if (data.font) this.setFont('uievent', data.font); + if (data.lineWidth) this.setLineWidth('uievent', data.lineWidth); + if (data.alpha != null) this.setAlpha('uievent', data.alpha); + if (data.fillStyle) this.setFillStyle('uievent', data.fillStyle); + if (data.strokeStyle) this.setStrokeStyle('uievent', data.strokeStyle); + if (data.align) this.setTextAlign('uievent', data.align); + if (data.baseline) this.setTextBaseline('uievent', data.baseline); +} + ////// 计算某段文字的宽度 ////// ui.prototype.calWidth = function (name, text, font) { var ctx = this.getContextByName(name); @@ -251,9 +308,9 @@ ui.prototype.drawImage = function (name, image, x, y, w, h, x1, y1, w1, h1) { } // 只能接受2, 4, 8个参数 - if (core.isset(x) && core.isset(y)) { - if (core.isset(w) && core.isset(h)) { - if (core.isset(x1) && core.isset(y1) && core.isset(w1) && core.isset(h1)) { + if (x != null && y != null) { + if (w != null && h != null) { + if (x1 != null && y1 != null && w1 != null && h1 != null) { ctx.drawImage(image, x, y, w, h, x1, y1, w1, h1); return; } @@ -265,6 +322,30 @@ ui.prototype.drawImage = function (name, image, x, y, w, h, x1, y1, w1, h1) { } } +ui.prototype._uievent_drawImage = function (data) { + this._createUIEvent(); + this.drawImage(data.name, core.calValue(data.x), core.calValue(data.y), core.calValue(data.w), core.calValue(data.h), + core.calValue(data.x1), core.calValue(data.y1), core.calValue(data.w1), core.calValue(data.h1)); +} + +ui.prototype.drawIcon = function (name, id, x, y, w, h) { + var ctx = this.getContextByName(name); + if (!ctx) return; + var info = core.getBlockInfo(id); + if (!info) { + // 检查状态栏图标 + if (core.statusBar.icons[id] instanceof Image) + info = {image: core.statusBar.icons[id], posX: 0, posY: 0, height: 32}; + else return; + } + ctx.drawImage(info.image, 32 * info.posX, info.height * info.posY, 32, info.height, x, y, w || 32, h || info.height); +} + +ui.prototype._uievent_drawIcon = function (data) { + this._createUIEvent(); + this.drawIcon('uievent', data.id, core.calValue(data.x), core.calValue(data.y), core.calValue(data.width), core.calValue(data.height)); +} + ///////////////// UI绘制 ////// 结束一切事件和绘制,关闭UI窗口,返回游戏进程 ////// @@ -465,23 +546,44 @@ ui.prototype._getPosition = function (content) { ////// 绘制选择光标 ui.prototype.drawWindowSelector = function(background, x, y, w, h) { + w = Math.round(w), h = Math.round(h); + var ctx = core.ui.createCanvas("_selector", x, y, w, h, 165); + ctx.canvas.style.opacity = 0.8; + this._drawSelector(ctx, background, x, y, w, h); +} + +ui.prototype._uievent_drawSelector = function (data) { + var background = data.background || core.status.textAttribute.background; + if (typeof background != 'string') return; + var x = core.calValue(data.x), y = core.calValue(data.y), w = core.calValue(data.width), h = core.calValue(data.height); + w = Math.round(w); h = Math.round(h); + if (main.mode == 'editor') { + this._drawSelector('uievent', background, x, y, w, h); + return; + } + var ctx = core.createCanvas('_uievent_selector', x, y, w, h, 136); + ctx.canvas.style.opacity = 0.8; + this._drawSelector(ctx, background, x, y, w, h); +} + +ui.prototype._drawSelector = function (ctx, background, x, y, w, h) { + ctx = this.getContextByName(ctx); + if (!ctx) return; if (typeof background == 'string') background = core.material.images.images[background]; - w = Math.round(w), h = Math.round(h); - var dstImage = core.ui.createCanvas("_selector", x, y, w, h, 165); - core.setOpacity("_selector", 0.8); + if (!(background instanceof Image)) return; // back - dstImage.drawImage(background, 130, 66, 28, 28, 2, 2,w-4,h-4); + ctx.drawImage(background, 130, 66, 28, 28, 2, 2,w-4,h-4); // corner - dstImage.drawImage(background, 128, 64, 2, 2, 0, 0, 2, 2); - dstImage.drawImage(background, 158, 64, 2, 2,w-2, 0, 2, 2); - dstImage.drawImage(background, 128, 94, 2, 2, 0,h-2, 2, 2); - dstImage.drawImage(background, 158, 94, 2, 2,w-2,h-2, 2, 2); + ctx.drawImage(background, 128, 64, 2, 2, 0, 0, 2, 2); + ctx.drawImage(background, 158, 64, 2, 2,w-2, 0, 2, 2); + ctx.drawImage(background, 128, 94, 2, 2, 0,h-2, 2, 2); + ctx.drawImage(background, 158, 94, 2, 2,w-2,h-2, 2, 2); // border - dstImage.drawImage(background, 130, 64, 28, 2, 2, 0,w-4, 2); - dstImage.drawImage(background, 130, 94, 28, 2, 2,h-2,w-4, 2); - dstImage.drawImage(background, 128, 66, 2, 28, 0, 2, 2,h-4); - dstImage.drawImage(background, 158, 66, 2, 28,w-2, 2, 2,h-4); + ctx.drawImage(background, 130, 64, 28, 2, 2, 0,w-4, 2); + ctx.drawImage(background, 130, 94, 28, 2, 2,h-2,w-4, 2); + ctx.drawImage(background, 128, 66, 2, 28, 0, 2, 2,h-4); + ctx.drawImage(background, 158, 66, 2, 28,w-2, 2, 2,h-4); } ////// 绘制 WindowSkin @@ -543,6 +645,25 @@ ui.prototype.drawBackground = function (left, top, right, bottom, posInfo) { return false; } +ui.prototype._uievent_drawBackground = function (data) { + this._createUIEvent(); + var background = data.background || core.status.textAttribute.background; + var x = core.calValue(data.x), y = core.calValue(data.y), w = core.calValue(data.width), h = core.calValue(data.height); + if (typeof background == 'string') { + if (data.alpha != null) this.setAlpha('uievent', data.alpha); + this.drawWindowSkin(background, 'uievent', x, y, w, h); + } + else if (background instanceof Array) { + var alpha = background[3]; + if (alpha == null) alpha = 1; + if (data.alpha != null) alpha = data.alpha; + this.setAlpha('uievent', alpha); + this.setLineWidth('uievent', 2); + this.fillRect('uievent', x, y, w, h, core.arrayToRGB(background)); + this.strokeRect('uievent', x, y, w, h, core.status.globalAttribute.borderColor); + } +} + ui.prototype._drawWindowSkin_getOpacity = function () { return core.getFlag("__winskin_opacity__", 0.85); } @@ -678,6 +799,11 @@ ui.prototype.drawTextContent = function (ctx, content, config) { tempCtx.textBaseline = _textBaseLine; } +ui.prototype._uievent_drawTextContent = function (data) { + this._createUIEvent(); + this.drawTextContent('uievent', core.replaceText(data.content), data); +} + // 绘制的基本逻辑: // 1. 一个个字符绘制到对应画布上(靠左对齐);这个过程中,记下来每个字对应的方块 [x, y, w, h] // 2. 每次换行时,计算当前行的宽度,然后如果是居中或者靠右对齐,则对当前行的每个小方块增加偏移量 From a6f3e18efc46bf985c7fdc8cd9f5ace437b329e3 Mon Sep 17 00:00:00 2001 From: oc Date: Sun, 26 May 2019 14:10:17 +0800 Subject: [PATCH 11/46] uievent runtime --- _docs/api.md | 7 +++++++ libs/control.js | 1 + libs/events.js | 2 +- libs/ui.js | 6 ++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/_docs/api.md b/_docs/api.md index 3943d347..0aa05bfe 100644 --- a/_docs/api.md +++ b/_docs/api.md @@ -1695,6 +1695,13 @@ core.drawImage(name, image, x, y, w, h, x1, y1, w1, h1) http://www.w3school.com.cn/html5/canvas_drawimage.asp 这里的image允许传一个图片,画布。也允许传递图片名,将从你导入的图片中获取图片内容。 + +core.drawIcon(name, id, x, y, w, h) +在一张画布上绘制一个图标。 +id为注册过的图标ID,也可以使用状态栏的图标ID,例如lv, hp, up, save, settings等。 +x和y为绘制的左上角坐标;w和h可选为绘制的宽高,如果不填或null则使用该图标的默认宽高。 + + // ------ 具体的某个UI界面的绘制 ------ // core.closePanel() 结束一切事件和UI绘制,关闭UI窗口,返回游戏。 diff --git a/libs/control.js b/libs/control.js index 905be87f..4a9c8b84 100644 --- a/libs/control.js +++ b/libs/control.js @@ -164,6 +164,7 @@ control.prototype._animationFrame_selector = function (timestamp) { if (opacity > 0.95 || opacity < 0.55) core.animateFrame.selectorUp = !core.animateFrame.selectorUp; core.setOpacity("_selector", opacity); + core.setOpacity("_uievent_selector", opacity); core.animateFrame.selectorTime = timestamp; } diff --git a/libs/events.js b/libs/events.js index 67d409e8..a3481278 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1621,7 +1621,7 @@ events.prototype._action_exit = function (data, x, y, prefix) { } events.prototype._action_previewUIEvent = function (data, x, y, prefix) { - this.insert(data.action); + this.insertAction(data.action); core.doAction(); } diff --git a/libs/ui.js b/libs/ui.js index f06a9a87..0ce671c4 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -553,6 +553,12 @@ ui.prototype.drawWindowSelector = function(background, x, y, w, h) { } ui.prototype._uievent_drawSelector = function (data) { + if (data.x == null || data.y == null || data.width == null || data.height == null) { + if (main.mode != 'editor') + core.deleteCanvas('_uievent_selector'); + return; + } + var background = data.background || core.status.textAttribute.background; if (typeof background != 'string') return; var x = core.calValue(data.x), y = core.calValue(data.y), w = core.calValue(data.width), h = core.calValue(data.height); From 01edcfbc986233210def70b1ea57e5f431dff247 Mon Sep 17 00:00:00 2001 From: oc Date: Sun, 26 May 2019 16:33:42 +0800 Subject: [PATCH 12/46] uievents part 1 --- _docs/event.md | 68 +++++++ _server/MotaAction.g4 | 381 ++++++++++++++++++++++++++------------ _server/editor_blockly.js | 35 ++-- libs/events.js | 2 +- libs/ui.js | 16 +- 5 files changed, 354 insertions(+), 148 deletions(-) diff --git a/_docs/event.md b/_docs/event.md index 34fff45b..dfd2245c 100644 --- a/_docs/event.md +++ b/_docs/event.md @@ -1795,6 +1795,74 @@ yes和no均为必填项,即用户点击确认或取消后执行的事件。 该事件会进行等待,直到所有可能的异步事件(异步动画除外)执行完毕。 +### previewUI:UI绘制预览 + +此项可在地图编辑器中预览UI界面的绘制效果。 + +在编辑器中将会把此项包含的所有UI绘制事件进行绘制从而可以进行预览。 + +值得注意的是,在游戏中,UI绘制事件都是绘制在uievent层上的。 + +### clearMap:清除画布 + +UI绘制事件。 + +`{"type": "clearMap"}`可以清除`uievent`画布的内容。 + +```js +[ + {"type": "clearMap", "x": 0, "y": 0, "width": "flag:width", "height": 416}, // 清除画布的一部分 + {"type": "clearMap"}, // 清空并删除画布 +] +``` + +x, y, width, height均可选,表示要清除的坐标和长宽。也可以使用`flag:xxx`。 + +如果存在某一项不填则会清空全部画布并删除。 + +### setAttribute:设置画布属性 + +UI绘制事件。 + +此项可以设置`uievent`画布的各项属性。 + +```js +[ + {"type": "setAttribute", "font": "17px Verdana", "fillStyle": [255,0,0,1]}, +] +``` + +可以选择性的设置如下几项内容: +- `font`:字体,必须是`[italic] [bold] 14px Verdana`这种形式 +- `fillStyle`:填充样式,必须是三元组RGB或四元组RGBA +- `strokeStyle`:边框样式,必须是三元组RGB或者四元组RGBA +- `lineWidth`:线宽度,必须是正整数 +- `alpha`:不透明度,必须是0到1之间的浮点数 +- `align`:对齐方式,只能是`left`, `center`, `right`,分别代表左对齐,居中和右对齐 +- `baseline`:基准线,只能是`top`, `middle`, `alphabetic`, `bottom`,分别代表顶部,居中,标准值和底部。 + +### fillText:绘制文本 + +UI绘制事件。 + +此项可以绘制一行文本。 + +```js +[ + {"type": "fillText", "text":"要绘制的文本", "x": 10, "y": 20, "maxWidth": 50} +] +``` + +text必填,为要绘制的文本,支持`${}`的写法,不支持一切转义字符或换行符。 + +x和y必填,为要绘制的左上角坐标。请使用`setAttribute`来设置绘制的对齐方式和基准线。 + +style可选,如果设置需要是三元组RGB或四元组RBGA,代表绘制样式。 + +font可选,如果设置则是要绘制的字体。 + +maxWidth可选,如果设置且不为0,则代表要绘制的最大宽度;超过此宽度会自动放缩。 + ### function: 自定义JS脚本 上述给出了这么多事件,但有时候往往不能满足需求,这时候就需要执行自定义脚本了。 diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 82deb5dc..a2adf880 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -10,7 +10,7 @@ event_m /* event_m tooltip : 编辑魔塔的事件 -helpUrl : https://h5mota.com/games/template/docs/#/event +helpUrl : https://h5mota.com/games/template/_docs/#/event default : [false,null,null,null,null] B_0_List_0=eval(B_0_List_0); var code = { @@ -33,7 +33,7 @@ level_m /* level_m tooltip : 升级事件 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=%e7%bb%8f%e9%aa%8c%e5%8d%87%e7%ba%a7%ef%bc%88%e8%bf%9b%e9%98%b6%2f%e5%a2%83%e7%95%8c%e5%a1%94%ef%bc%89 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=%e7%bb%8f%e9%aa%8c%e5%8d%87%e7%ba%a7%ef%bc%88%e8%bf%9b%e9%98%b6%2f%e5%a2%83%e7%95%8c%e5%a1%94%ef%bc%89 var code = '[\n'+levelCase_0+']\n'; return code; */; @@ -44,7 +44,7 @@ levelCase /* levelCase tooltip : 升级设定 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=%e7%bb%8f%e9%aa%8c%e5%8d%87%e7%ba%a7%ef%bc%88%e8%bf%9b%e9%98%b6%2f%e5%a2%83%e7%95%8c%e5%a1%94%ef%bc%89 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=%e7%bb%8f%e9%aa%8c%e5%8d%87%e7%ba%a7%ef%bc%88%e8%bf%9b%e9%98%b6%2f%e5%a2%83%e7%95%8c%e5%a1%94%ef%bc%89 default : [0,"",false,null] colour : this.subColor Bool_0 = Bool_0?', "clear": true':''; @@ -58,7 +58,7 @@ shop_m /* shop_m tooltip : 全局商店列表 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=%e5%85%a8%e5%b1%80%e5%95%86%e5%ba%97 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=%e5%85%a8%e5%b1%80%e5%95%86%e5%ba%97 var code = '['+shoplist_0+']\n'; return code; */; @@ -83,7 +83,7 @@ shopcommonevent /* shopcommonevent tooltip : 全局商店, 执行一个公共事件 -helpUrl : https://h5mota.com/games/template/docs/#/ +helpUrl : https://h5mota.com/games/template/_docs/#/ default : ["shop1","回收钥匙商店",false,"回收钥匙商店",""] if (EvalString_2) { if (EvalString_2.indexOf('"')>=0) @@ -114,7 +114,7 @@ shopsub /* shopsub tooltip : 全局商店,消耗填-1表示每个选项的消耗不同,正数表示消耗数值 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=%e5%85%a8%e5%b1%80%e5%95%86%e5%ba%97 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=%e5%85%a8%e5%b1%80%e5%95%86%e5%ba%97 default : ["shop1","贪婪之神","blueShop","1F金币商店",false,false,null,"20+10*times*(times+1)","勇敢的武士啊, 给我${need}金币就可以:"] var code = { 'id': IdString_0, @@ -138,7 +138,7 @@ shopChoices /* shopChoices tooltip : 商店选项,商店消耗是-1时,这里的消耗对应各自选项的消耗,商店消耗不是-1时这里的消耗不填 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=%e5%85%a8%e5%b1%80%e5%95%86%e5%ba%97 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=%e5%85%a8%e5%b1%80%e5%95%86%e5%ba%97 default : ["攻击+1",""] colour : this.subColor EvalString_1 = EvalString_1 && (', "need": "'+EvalString_1+'"'); @@ -163,7 +163,7 @@ afterBattle_m /* afterBattle_m tooltip : 系统引发的自定义事件 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=%e7%b3%bb%e7%bb%9f%e5%bc%95%e5%8f%91%e7%9a%84%e8%87%aa%e5%ae%9a%e4%b9%89%e4%ba%8b%e4%bb%b6 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=%e7%b3%bb%e7%bb%9f%e5%bc%95%e5%8f%91%e7%9a%84%e8%87%aa%e5%ae%9a%e4%b9%89%e4%ba%8b%e4%bb%b6 var code = '[\n'+action_0+']\n'; return code; */; @@ -175,7 +175,7 @@ afterGetItem_m /* afterGetItem_m tooltip : 系统引发的自定义事件 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=%e7%b3%bb%e7%bb%9f%e5%bc%95%e5%8f%91%e7%9a%84%e8%87%aa%e5%ae%9a%e4%b9%89%e4%ba%8b%e4%bb%b6 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=%e7%b3%bb%e7%bb%9f%e5%bc%95%e5%8f%91%e7%9a%84%e8%87%aa%e5%ae%9a%e4%b9%89%e4%ba%8b%e4%bb%b6 var code = '[\n'+action_0+']\n'; return code; */; @@ -187,7 +187,7 @@ afterOpenDoor_m /* afterOpenDoor_m tooltip : 系统引发的自定义事件 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=%e7%b3%bb%e7%bb%9f%e5%bc%95%e5%8f%91%e7%9a%84%e8%87%aa%e5%ae%9a%e4%b9%89%e4%ba%8b%e4%bb%b6 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=%e7%b3%bb%e7%bb%9f%e5%bc%95%e5%8f%91%e7%9a%84%e8%87%aa%e5%ae%9a%e4%b9%89%e4%ba%8b%e4%bb%b6 var code = '[\n'+action_0+']\n'; return code; */; @@ -199,7 +199,7 @@ firstArrive_m /* firstArrive_m tooltip : 首次到达楼层 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=%e7%b3%bb%e7%bb%9f%e5%bc%95%e5%8f%91%e7%9a%84%e8%87%aa%e5%ae%9a%e4%b9%89%e4%ba%8b%e4%bb%b6 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=%e7%b3%bb%e7%bb%9f%e5%bc%95%e5%8f%91%e7%9a%84%e8%87%aa%e5%ae%9a%e4%b9%89%e4%ba%8b%e4%bb%b6 var code = '[\n'+action_0+']\n'; return code; */; @@ -211,7 +211,7 @@ eachArrive_m /* eachArrive_m tooltip : 每次到达楼层 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=%e7%b3%bb%e7%bb%9f%e5%bc%95%e5%8f%91%e7%9a%84%e8%87%aa%e5%ae%9a%e4%b9%89%e4%ba%8b%e4%bb%b6 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=%e7%b3%bb%e7%bb%9f%e5%bc%95%e5%8f%91%e7%9a%84%e8%87%aa%e5%ae%9a%e4%b9%89%e4%ba%8b%e4%bb%b6 var code = '[\n'+action_0+']\n'; return code; */; @@ -223,7 +223,7 @@ changeFloor_m /* changeFloor_m tooltip : 楼梯, 传送门, 如果目标楼层有多个楼梯, 写upFloor或downFloor可能会导致到达的楼梯不确定, 这时候请使用loc方式来指定具体的点位置 -helpUrl : https://h5mota.com/games/template/docs/#/element?id=%e8%b7%af%e9%9a%9c%ef%bc%8c%e6%a5%bc%e6%a2%af%ef%bc%8c%e4%bc%a0%e9%80%81%e9%97%a8 +helpUrl : https://h5mota.com/games/template/_docs/#/element?id=%e8%b7%af%e9%9a%9c%ef%bc%8c%e6%a5%bc%e6%a2%af%ef%bc%8c%e4%bc%a0%e9%80%81%e9%97%a8 default : [null,"MT1",null,0,0,null,500,null] var toFloorId = IdString_0; if (Floor_List_0!='floorId') toFloorId = Floor_List_0; @@ -244,7 +244,7 @@ commonEvent_m /* commonEvent_m tooltip : 公共事件 -helpUrl : https://h5mota.com/games/template/docs/#/event +helpUrl : https://h5mota.com/games/template/_docs/#/event var code = '[\n'+action_0+']\n'; return code; */; @@ -341,6 +341,11 @@ action | callSave_s | autoSave_s | callLoad_s + | previewUI_s + | clearMap_s + | clearMap_1_s + | setAttribute_s + | fillText_s | unknown_s | function_s | pass_s @@ -352,7 +357,7 @@ text_0_s /* text_0_s tooltip : text:显示一段文字(剧情) -helpUrl : https://h5mota.com/games/template/docs/#/event?id=text%EF%BC%9A%E6%98%BE%E7%A4%BA%E4%B8%80%E6%AE%B5%E6%96%87%E5%AD%97%EF%BC%88%E5%89%A7%E6%83%85%EF%BC%89 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=text%EF%BC%9A%E6%98%BE%E7%A4%BA%E4%B8%80%E6%AE%B5%E6%96%87%E5%AD%97%EF%BC%88%E5%89%A7%E6%83%85%EF%BC%89 default : ["欢迎使用事件编辑器(双击方块进入多行编辑)"] var code = '"'+EvalString_0+'",\n'; return code; @@ -364,7 +369,7 @@ text_1_s /* text_1_s tooltip : text:显示一段文字(剧情),选项较多请右键点击帮助 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=text%EF%BC%9A%E6%98%BE%E7%A4%BA%E4%B8%80%E6%AE%B5%E6%96%87%E5%AD%97%EF%BC%88%E5%89%A7%E6%83%85%EF%BC%89 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=text%EF%BC%9A%E6%98%BE%E7%A4%BA%E4%B8%80%E6%AE%B5%E6%96%87%E5%AD%97%EF%BC%88%E5%89%A7%E6%83%85%EF%BC%89 default : ["小妖精","fairy","","欢迎使用事件编辑器(双击方块进入多行编辑)"] var title=''; if (EvalString_0==''){ @@ -388,7 +393,7 @@ comment_s /* comment_s tooltip : comment:添加一段会被游戏跳过的注释内容 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=comment%ef%bc%9a%e6%b7%bb%e5%8a%a0%e6%b3%a8%e9%87%8a +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=comment%ef%bc%9a%e6%b7%bb%e5%8a%a0%e6%b3%a8%e9%87%8a default : ["可以在这里写添加任何注释内容"] colour : this.commentColor var code = '{"type": "comment", "text": "'+EvalString_0+'"},\n'; @@ -401,7 +406,7 @@ autoText_s /* autoText_s tooltip : autoText:自动剧情文本,用户无法跳过自动剧情文本,大段剧情文本请添加“是否跳过剧情”的提示 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=autotext%EF%BC%9A%E8%87%AA%E5%8A%A8%E5%89%A7%E6%83%85%E6%96%87%E6%9C%AC +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=autotext%EF%BC%9A%E8%87%AA%E5%8A%A8%E5%89%A7%E6%83%85%E6%96%87%E6%9C%AC default : ["小妖精","fairy","",3000,"用户无法跳过自动剧情文本,大段剧情文本请添加“是否跳过剧情”的提示"] var title=''; if (EvalString_0==''){ @@ -425,7 +430,7 @@ scrollText_s /* scrollText_s tooltip : scrollText:滚动剧情文本,将从下到上进行滚动显示。 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=scrollText%ef%bc%9a%e6%bb%9a%e5%8a%a8%e5%89%a7%e6%83%85%e6%96%87%e6%9c%ac +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=scrollText%ef%bc%9a%e6%bb%9a%e5%8a%a8%e5%89%a7%e6%83%85%e6%96%87%e6%9c%ac default : [5000,1.4,false,"时间是总时间,可以使用setText事件来控制字体、颜色、大小、偏移量等"] Bool_0 = Bool_0?', "async": true':''; var code = '{"type": "scrollText", "text": "'+EvalString_0+'"'+Bool_0+', "time" :'+Int_0+', "lineHeight": '+Number_0+'},\n'; @@ -433,15 +438,15 @@ return code; */; setText_s - : '设置剧情文本的属性' '位置' SetTextPosition_List '偏移像素' EvalString? '对齐' SetTextAlign_List? BGNL? '标题颜色' EvalString? Colour '正文颜色' EvalString? Colour '背景色' EvalString? Colour BGNL? '粗体' B_1_List '标题字体大小' EvalString? '正文字体大小' EvalString? '打字间隔' EvalString? Newline + : '设置剧情文本的属性' '位置' SetTextPosition_List '偏移像素' EvalString? '对齐' TextAlign_List? BGNL? '标题颜色' EvalString? Colour '正文颜色' EvalString? Colour '背景色' EvalString? Colour BGNL? '粗体' B_1_List '标题字体大小' EvalString? '正文字体大小' EvalString? '打字间隔' EvalString? Newline /* setText_s tooltip : setText:设置剧情文本的属性,颜色为RGB三元组或RGBA四元组,打字间隔为剧情文字添加的时间间隔,为整数或不填 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=settext%EF%BC%9A%E8%AE%BE%E7%BD%AE%E5%89%A7%E6%83%85%E6%96%87%E6%9C%AC%E7%9A%84%E5%B1%9E%E6%80%A7 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=settext%EF%BC%9A%E8%AE%BE%E7%BD%AE%E5%89%A7%E6%83%85%E6%96%87%E6%9C%AC%E7%9A%84%E5%B1%9E%E6%80%A7 default : [null,"",null,"",'rgba(255,255,255,1)',"",'rgba(255,255,255,1)',"",'rgba(255,255,255,1)',null,"","",""] SetTextPosition_List_0 =SetTextPosition_List_0==='null'?'': ', "position": "'+SetTextPosition_List_0+'"'; -SetTextAlign_List_0 =SetTextAlign_List_0==='null'?'': ', "align": "'+SetTextAlign_List_0+'"'; +TextAlign_List_0 = TextAlign_List_0==='null'?'': ', "align": "'+TextAlign_List_0+'"'; var colorRe = MotaActionFunctions.pattern.colorRe; if (EvalString_0) { if (!/^\d+$/.test(EvalString_0))throw new Error('像素偏移量必须是整数或不填'); @@ -479,7 +484,7 @@ if (EvalString_6) { EvalString_6 = ', "time": '+EvalString_6; } B_1_List_0 = B_1_List_0==='null'?'':', "bold": '+B_1_List_0; -var code = '{"type": "setText"'+SetTextPosition_List_0+EvalString_0+SetTextAlign_List_0+EvalString_1+EvalString_2+B_1_List_0+EvalString_3+EvalString_4+EvalString_5+EvalString_6+'},\n'; +var code = '{"type": "setText"'+SetTextPosition_List_0+EvalString_0+TextAlign_List_0+EvalString_1+EvalString_2+B_1_List_0+EvalString_3+EvalString_4+EvalString_5+EvalString_6+'},\n'; return code; */; @@ -489,7 +494,7 @@ tip_s /* tip_s tooltip : tip:显示一段提示文字 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=tip%EF%BC%9A%E6%98%BE%E7%A4%BA%E4%B8%80%E6%AE%B5%E6%8F%90%E7%A4%BA%E6%96%87%E5%AD%97 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=tip%EF%BC%9A%E6%98%BE%E7%A4%BA%E4%B8%80%E6%AE%B5%E6%8F%90%E7%A4%BA%E6%96%87%E5%AD%97 default : ["这段话将在左上角以气泡形式显示",""] IdString_0 = IdString_0 && (', "icon": "' + IdString_0 + '"'); var code = '{"type": "tip", "text": "'+EvalString_0+'"'+IdString_0+'},\n'; @@ -502,7 +507,7 @@ setValue_s /* setValue_s tooltip : setValue:设置勇士的某个属性、道具个数, 或某个变量/Flag的值 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=setvalue%EF%BC%9A%E8%AE%BE%E7%BD%AE%E5%8B%87%E5%A3%AB%E7%9A%84%E6%9F%90%E4%B8%AA%E5%B1%9E%E6%80%A7%E3%80%81%E9%81%93%E5%85%B7%E4%B8%AA%E6%95%B0%EF%BC%8C%E6%88%96%E6%9F%90%E4%B8%AA%E5%8F%98%E9%87%8Fflag%E7%9A%84%E5%80%BC +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setvalue%EF%BC%9A%E8%AE%BE%E7%BD%AE%E5%8B%87%E5%A3%AB%E7%9A%84%E6%9F%90%E4%B8%AA%E5%B1%9E%E6%80%A7%E3%80%81%E9%81%93%E5%85%B7%E4%B8%AA%E6%95%B0%EF%BC%8C%E6%88%96%E6%9F%90%E4%B8%AA%E5%8F%98%E9%87%8Fflag%E7%9A%84%E5%80%BC colour : this.dataColor var code = '{"type": "setValue", "name": "'+idString_e_0+'", "value": "'+expression_0+'"},\n'; return code; @@ -514,7 +519,7 @@ addValue_s /* addValue_s tooltip : addValue:增减勇士的某个属性、道具个数, 或某个变量/Flag的值 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=addValue%ef%bc%9a%e5%a2%9e%e5%87%8f%e5%8b%87%e5%a3%ab%e7%9a%84%e6%9f%90%e4%b8%aa%e5%b1%9e%e6%80%a7%e3%80%81%e9%81%93%e5%85%b7%e4%b8%aa%e6%95%b0%ef%bc%8c%e6%88%96%e6%9f%90%e4%b8%aa%e5%8f%98%e9%87%8f%2fFlag%e7%9a%84%e5%80%bc +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=addValue%ef%bc%9a%e5%a2%9e%e5%87%8f%e5%8b%87%e5%a3%ab%e7%9a%84%e6%9f%90%e4%b8%aa%e5%b1%9e%e6%80%a7%e3%80%81%e9%81%93%e5%85%b7%e4%b8%aa%e6%95%b0%ef%bc%8c%e6%88%96%e6%9f%90%e4%b8%aa%e5%8f%98%e9%87%8f%2fFlag%e7%9a%84%e5%80%bc colour : this.dataColor var code = '{"type": "addValue", "name": "'+idString_e_0+'", "value": "'+expression_0+'"},\n'; return code; @@ -526,7 +531,7 @@ setFloor_s /* setFloor_s tooltip : setFloor:设置楼层属性;该楼层属性和编辑器中的楼层属性一一对应 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=setFloor%ef%bc%9a%e8%ae%be%e7%bd%ae%e6%a5%bc%e5%b1%82%e5%b1%9e%e6%80%a7 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setFloor%ef%bc%9a%e8%ae%be%e7%bd%ae%e6%a5%bc%e5%b1%82%e5%b1%9e%e6%80%a7 default : ["title","","'字符串类型的值要加引号,其他类型则不用'"] colour : this.dataColor IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"'); @@ -541,7 +546,7 @@ setGlobalAttribute_s /* setGlobalAttribute_s tooltip : setGlobalAttribute:设置全局属性 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=setGlobalAttribute%ef%bc%9a%e8%ae%be%e7%bd%ae%e4%b8%80%e4%b8%aa%e5%85%a8%e5%b1%80%e5%b1%9e%e6%80%a7 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setGlobalAttribute%ef%bc%9a%e8%ae%be%e7%bd%ae%e4%b8%80%e4%b8%aa%e5%85%a8%e5%b1%80%e5%b1%9e%e6%80%a7 default : ["font","Verdana"] colour : this.dataColor var code = '{"type": "setGlobalAttribute", "name": "'+Global_Attribute_List_0+'", "value": "'+EvalString_0+'"},\n'; @@ -555,7 +560,7 @@ setGlobalValue_s /* setGlobalValue_s tooltip : setGlobalValue:设置全局属性 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=setGlobalValue%ef%bc%9a%e8%ae%be%e7%bd%ae%e4%b8%80%e4%b8%aa%e5%85%a8%e5%b1%80%e6%95%b0%e5%80%bc +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setGlobalValue%ef%bc%9a%e8%ae%be%e7%bd%ae%e4%b8%80%e4%b8%aa%e5%85%a8%e5%b1%80%e6%95%b0%e5%80%bc default : ["lavaDamage","100"] colour : this.dataColor var code = '{"type": "setGlobalValue", "name": "'+Global_Value_List_0+'", "value": '+EvalString_0+'},\n'; @@ -569,7 +574,7 @@ setGlobalFlag_s /* setGlobalFlag_s tooltip : setGlobalFlag:设置系统开关 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=setGlobalFlag%ef%bc%9a%e8%ae%be%e7%bd%ae%e4%b8%80%e4%b8%aa%e7%b3%bb%e7%bb%9f%e5%bc%80%e5%85%b3 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setGlobalFlag%ef%bc%9a%e8%ae%be%e7%bd%ae%e4%b8%80%e4%b8%aa%e7%b3%bb%e7%bb%9f%e5%bc%80%e5%85%b3 default : ["enableFloor","true"] colour : this.dataColor var code = '{"type": "setGlobalFlag", "name": "'+Global_Flag_List_0+'", "value": '+Bool_0+'},\n'; @@ -583,7 +588,7 @@ show_s /* show_s tooltip : show: 将禁用事件启用,楼层和动画时间可不填,xy可用逗号分隔表示多个点 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=show%EF%BC%9A%E5%B0%86%E4%B8%80%E4%B8%AA%E7%A6%81%E7%94%A8%E4%BA%8B%E4%BB%B6%E5%90%AF%E7%94%A8 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=show%EF%BC%9A%E5%B0%86%E4%B8%80%E4%B8%AA%E7%A6%81%E7%94%A8%E4%BA%8B%E4%BB%B6%E5%90%AF%E7%94%A8 default : ["","","",500,false] colour : this.mapColor var floorstr = ''; @@ -616,7 +621,7 @@ hide_s /* hide_s tooltip : hide: 将一个启用事件禁用,所有参数均可不填,代表禁用事件自身,xy可用逗号分隔表示多个点 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=hide%EF%BC%9A%E5%B0%86%E4%B8%80%E4%B8%AA%E5%90%AF%E7%94%A8%E4%BA%8B%E4%BB%B6%E7%A6%81%E7%94%A8 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=hide%EF%BC%9A%E5%B0%86%E4%B8%80%E4%B8%AA%E5%90%AF%E7%94%A8%E4%BA%8B%E4%BB%B6%E7%A6%81%E7%94%A8 default : ["","","",500,false] colour : this.mapColor var floorstr = ''; @@ -649,7 +654,7 @@ trigger_s /* trigger_s tooltip : trigger: 立即触发另一个地点的事件 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=trigger%EF%BC%9A%E7%AB%8B%E5%8D%B3%E8%A7%A6%E5%8F%91%E5%8F%A6%E4%B8%80%E4%B8%AA%E5%9C%B0%E7%82%B9%E7%9A%84%E4%BA%8B%E4%BB%B6 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=trigger%EF%BC%9A%E7%AB%8B%E5%8D%B3%E8%A7%A6%E5%8F%91%E5%8F%A6%E4%B8%80%E4%B8%AA%E5%9C%B0%E7%82%B9%E7%9A%84%E4%BA%8B%E4%BB%B6 default : ["0","0",false] colour : this.eventColor Bool_0 = Bool_0 ?', "keep": true':''; @@ -663,7 +668,7 @@ insert_1_s /* insert_1_s tooltip : insert: 插入公共事件并执行 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=insert%ef%bc%9a%e6%8f%92%e5%85%a5%e5%85%ac%e5%85%b1%e4%ba%8b%e4%bb%b6%e6%88%96%e5%8f%a6%e4%b8%80%e4%b8%aa%e5%9c%b0%e7%82%b9%e7%9a%84%e4%ba%8b%e4%bb%b6%e5%b9%b6%e6%89%a7%e8%a1%8c +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=insert%ef%bc%9a%e6%8f%92%e5%85%a5%e5%85%ac%e5%85%b1%e4%ba%8b%e4%bb%b6%e6%88%96%e5%8f%a6%e4%b8%80%e4%b8%aa%e5%9c%b0%e7%82%b9%e7%9a%84%e4%ba%8b%e4%bb%b6%e5%b9%b6%e6%89%a7%e8%a1%8c default : ["加点事件", ""] colour : this.eventColor if (EvalString_1) { @@ -688,7 +693,7 @@ insert_2_s /* insert_2_s tooltip : insert: 立即插入另一个地点的事件执行,当前事件不会中断,事件坐标不会改变 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=insert%ef%bc%9a%e6%8f%92%e5%85%a5%e5%85%ac%e5%85%b1%e4%ba%8b%e4%bb%b6%e6%88%96%e5%8f%a6%e4%b8%80%e4%b8%aa%e5%9c%b0%e7%82%b9%e7%9a%84%e4%ba%8b%e4%bb%b6%e5%b9%b6%e6%89%a7%e8%a1%8c +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=insert%ef%bc%9a%e6%8f%92%e5%85%a5%e5%85%ac%e5%85%b1%e4%ba%8b%e4%bb%b6%e6%88%96%e5%8f%a6%e4%b8%80%e4%b8%aa%e5%9c%b0%e7%82%b9%e7%9a%84%e4%ba%8b%e4%bb%b6%e5%b9%b6%e6%89%a7%e8%a1%8c default : ["0","0",null,"",""] colour : this.eventColor IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"'); @@ -716,7 +721,7 @@ revisit_s /* revisit_s tooltip : revisit: 立即重启当前事件 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=revisit%EF%BC%9A%E7%AB%8B%E5%8D%B3%E9%87%8D%E5%90%AF%E5%BD%93%E5%89%8D%E4%BA%8B%E4%BB%B6 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=revisit%EF%BC%9A%E7%AB%8B%E5%8D%B3%E9%87%8D%E5%90%AF%E5%BD%93%E5%89%8D%E4%BA%8B%E4%BB%B6 colour : this.eventColor var code = '{"type": "revisit"},\n'; return code; @@ -728,7 +733,7 @@ exit_s /* exit_s tooltip : exit: 立刻结束当前事件 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=exit%EF%BC%9A%E7%AB%8B%E5%88%BB%E7%BB%93%E6%9D%9F%E5%BD%93%E5%89%8D%E4%BA%8B%E4%BB%B6 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=exit%EF%BC%9A%E7%AB%8B%E5%88%BB%E7%BB%93%E6%9D%9F%E5%BD%93%E5%89%8D%E4%BA%8B%E4%BB%B6 colour : this.eventColor var code = '{"type": "exit"},\n'; return code; @@ -740,7 +745,7 @@ setBlock_s /* setBlock_s tooltip : setBlock:设置某个图块,忽略坐标楼层则为当前事件 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=setblock%EF%BC%9A%E8%AE%BE%E7%BD%AE%E6%9F%90%E4%B8%AA%E5%9B%BE%E5%9D%97 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setblock%EF%BC%9A%E8%AE%BE%E7%BD%AE%E6%9F%90%E4%B8%AA%E5%9B%BE%E5%9D%97 colour : this.mapColor default : ["yellowDoor","","",""] var floorstr = ''; @@ -758,7 +763,7 @@ showFloorImg_s /* showFloorImg_s tooltip : showFloorImg: 显示一个贴图,xy为左上角坐标,可用逗号分隔表示多个点 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=showFloorImg%ef%bc%9a%e6%98%be%e7%a4%ba%e8%b4%b4%e5%9b%be +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=showFloorImg%ef%bc%9a%e6%98%be%e7%a4%ba%e8%b4%b4%e5%9b%be default : ["","",""] colour : this.mapColor var floorstr = ''; @@ -789,7 +794,7 @@ hideFloorImg_s /* hideFloorImg_s tooltip : hideFloorImg: 隐藏一个贴图,xy为左上角坐标,可用逗号分隔表示多个点 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=hideFloorImg%ef%bc%9a%e9%9a%90%e8%97%8f%e8%b4%b4%e5%9b%be +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=hideFloorImg%ef%bc%9a%e9%9a%90%e8%97%8f%e8%b4%b4%e5%9b%be default : ["","",""] colour : this.mapColor var floorstr = ''; @@ -820,7 +825,7 @@ showBgFgMap_s /* showBgFgMap_s tooltip : showBgFgMap: 显示图层块,即背景图层/前景图层的某些图块,xy为左上角坐标,可用逗号分隔表示多个点 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=showFloorImg%ef%bc%9a%e6%98%be%e7%a4%ba%e8%b4%b4%e5%9b%be +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=showFloorImg%ef%bc%9a%e6%98%be%e7%a4%ba%e8%b4%b4%e5%9b%be default : ["bg","","",""] colour : this.mapColor var floorstr = ''; @@ -851,7 +856,7 @@ hideBgFgMap_s /* hideBgFgMap_s tooltip : hideBgFgMap: 隐藏图层块,即背景图层/前景图层的某些图块,xy为左上角坐标,可用逗号分隔表示多个点 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=hideFloorImg%ef%bc%9a%e9%9a%90%e8%97%8f%e8%b4%b4%e5%9b%be +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=hideFloorImg%ef%bc%9a%e9%9a%90%e8%97%8f%e8%b4%b4%e5%9b%be default : ["bg","","",""] colour : this.mapColor var floorstr = ''; @@ -882,7 +887,7 @@ setBgFgBlock_s /* setBgFgBlock_s tooltip : setBgFgBlock:设置某个图层块,忽略坐标楼层则为当前点 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=setblock%EF%BC%9A%E8%AE%BE%E7%BD%AE%E6%9F%90%E4%B8%AA%E5%9B%BE%E5%9D%97 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setblock%EF%BC%9A%E8%AE%BE%E7%BD%AE%E6%9F%90%E4%B8%AA%E5%9B%BE%E5%9D%97 colour : this.mapColor default : ["bg","yellowDoor","","",""] var floorstr = ''; @@ -900,7 +905,7 @@ setHeroIcon_s /* setHeroIcon_s tooltip : setHeroIcon:更改角色行走图 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=setheroicon%EF%BC%9A%E6%9B%B4%E6%94%B9%E8%A7%92%E8%89%B2%E8%A1%8C%E8%B5%B0%E5%9B%BE +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setheroicon%EF%BC%9A%E6%9B%B4%E6%94%B9%E8%A7%92%E8%89%B2%E8%A1%8C%E8%B5%B0%E5%9B%BE colour : this.dataColor default : ["hero.png"] EvalString_0 = EvalString_0 && (', "name": "'+EvalString_0+'"'); @@ -914,7 +919,7 @@ update_s /* update_s tooltip : update: 立刻更新状态栏和地图显伤 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=update%EF%BC%9A%E7%AB%8B%E5%88%BB%E6%9B%B4%E6%96%B0%E7%8A%B6%E6%80%81%E6%A0%8F%E5%92%8C%E5%9C%B0%E5%9B%BE%E6%98%BE%E4%BC%A4 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=update%EF%BC%9A%E7%AB%8B%E5%88%BB%E6%9B%B4%E6%96%B0%E7%8A%B6%E6%80%81%E6%A0%8F%E5%92%8C%E5%9C%B0%E5%9B%BE%E6%98%BE%E4%BC%A4 colour : this.dataColor var code = '{"type": "update"},\n'; return code; @@ -926,7 +931,7 @@ showStatusBar_s /* showStatusBar_s tooltip : showStatusBar: 显示状态栏 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=showStatusBar%ef%bc%9a%e6%98%be%e7%a4%ba%e7%8a%b6%e6%80%81%e6%a0%8f +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=showStatusBar%ef%bc%9a%e6%98%be%e7%a4%ba%e7%8a%b6%e6%80%81%e6%a0%8f colour : this.soundColor var code = '{"type": "showStatusBar"},\n'; return code; @@ -938,7 +943,7 @@ hideStatusBar_s /* hideStatusBar_s tooltip : hideStatusBar: 隐藏状态栏 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=hideStatusBar%ef%bc%9a%e9%9a%90%e8%97%8f%e7%8a%b6%e6%80%81%e6%a0%8f +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=hideStatusBar%ef%bc%9a%e9%9a%90%e8%97%8f%e7%8a%b6%e6%80%81%e6%a0%8f colour : this.soundColor default : [false] Bool_0 = Bool_0?', "toolbox": true':''; @@ -952,7 +957,7 @@ updateEnemys_s /* updateEnemys_s tooltip : updateEnemys: 立刻更新怪物数据 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=updateEnemys%ef%bc%9a%e6%9b%b4%e6%96%b0%e6%80%aa%e7%89%a9%e6%95%b0%e6%8d%ae +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=updateEnemys%ef%bc%9a%e6%9b%b4%e6%96%b0%e6%80%aa%e7%89%a9%e6%95%b0%e6%8d%ae colour : this.dataColor var code = '{"type": "updateEnemys"},\n'; return code; @@ -964,7 +969,7 @@ sleep_s /* sleep_s tooltip : sleep: 等待多少毫秒 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=sleep%EF%BC%9A%E7%AD%89%E5%BE%85%E5%A4%9A%E5%B0%91%E6%AF%AB%E7%A7%92 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=sleep%EF%BC%9A%E7%AD%89%E5%BE%85%E5%A4%9A%E5%B0%91%E6%AF%AB%E7%A7%92 default : [500, false] colour : this.soundColor Bool_0 = Bool_0?', "noSkip": true':''; @@ -979,7 +984,7 @@ battle_s /* battle_s tooltip : battle: 强制战斗 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=battle%EF%BC%9A%E5%BC%BA%E5%88%B6%E6%88%98%E6%96%97 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=battle%EF%BC%9A%E5%BC%BA%E5%88%B6%E6%88%98%E6%96%97 default : ["greenSlime"] colour : this.dataColor var code = '{"type": "battle", "id": "'+IdString_0+'"},\n'; @@ -993,7 +998,7 @@ battle_1_s /* battle_1_s tooltip : battle: 强制战斗 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=battle%EF%BC%9A%E5%BC%BA%E5%88%B6%E6%88%98%E6%96%97 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=battle%EF%BC%9A%E5%BC%BA%E5%88%B6%E6%88%98%E6%96%97 default : ["","",""] colour : this.mapColor var floorstr = ''; @@ -1010,7 +1015,7 @@ openDoor_s /* openDoor_s tooltip : openDoor: 开门,楼层可不填表示当前层 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=opendoor%EF%BC%9A%E5%BC%80%E9%97%A8 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=opendoor%EF%BC%9A%E5%BC%80%E9%97%A8 default : ["","","",false,false] colour : this.mapColor IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"'); @@ -1030,7 +1035,7 @@ closeDoor_s /* closeDoor_s tooltip : closeDoor: 关门事件,需要该点本身无事件 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=opendoor%EF%BC%9A%E5%BC%80%E9%97%A8 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=opendoor%EF%BC%9A%E5%BC%80%E9%97%A8 default : ["","","yellowDoor",false] colour : this.mapColor var floorstr = ''; @@ -1048,7 +1053,7 @@ changeFloor_s /* changeFloor_s tooltip : changeFloor: 楼层切换,动画时间可不填 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=changefloor%EF%BC%9A%E6%A5%BC%E5%B1%82%E5%88%87%E6%8D%A2 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=changefloor%EF%BC%9A%E6%A5%BC%E5%B1%82%E5%88%87%E6%8D%A2 default : ["MT1","0","0",null,500] colour : this.dataColor DirectionEx_List_0 = DirectionEx_List_0 && (', "direction": "'+DirectionEx_List_0+'"'); @@ -1067,7 +1072,7 @@ changePos_0_s /* changePos_0_s tooltip : changePos: 当前位置切换 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=changepos%EF%BC%9A%E5%BD%93%E5%89%8D%E4%BD%8D%E7%BD%AE%E5%88%87%E6%8D%A2%E5%8B%87%E5%A3%AB%E8%BD%AC%E5%90%91 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=changepos%EF%BC%9A%E5%BD%93%E5%89%8D%E4%BD%8D%E7%BD%AE%E5%88%87%E6%8D%A2%E5%8B%87%E5%A3%AB%E8%BD%AC%E5%90%91 default : ["","",null] colour : this.dataColor DirectionEx_List_0 = DirectionEx_List_0 && (', "direction": "'+DirectionEx_List_0+'"'); @@ -1081,7 +1086,7 @@ changePos_1_s /* changePos_1_s tooltip : changePos: 勇士转向 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=changepos%EF%BC%9A%E5%BD%93%E5%89%8D%E4%BD%8D%E7%BD%AE%E5%88%87%E6%8D%A2%E5%8B%87%E5%A3%AB%E8%BD%AC%E5%90%91 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=changepos%EF%BC%9A%E5%BD%93%E5%89%8D%E4%BD%8D%E7%BD%AE%E5%88%87%E6%8D%A2%E5%8B%87%E5%A3%AB%E8%BD%AC%E5%90%91 colour : this.dataColor default : [null] var code = '{"type": "changePos", "direction": "'+Direction_List_0+'"},\n'; @@ -1094,7 +1099,7 @@ useItem_s /* useItem_s tooltip : useItem: 使用道具 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=useItem%ef%bc%9a%e4%bd%bf%e7%94%a8%e9%81%93%e5%85%b7 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=useItem%ef%bc%9a%e4%bd%bf%e7%94%a8%e9%81%93%e5%85%b7 colour : this.dataColor default : ["pickaxe"] var code = '{"type": "useItem", "id": "'+IdString_0+'"},\n'; @@ -1107,7 +1112,7 @@ openShop_s /* openShop_s tooltip : 全局商店 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=openshop%EF%BC%9A%E6%89%93%E5%BC%80%E4%B8%80%E4%B8%AA%E5%85%A8%E5%B1%80%E5%95%86%E5%BA%97 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=openshop%EF%BC%9A%E6%89%93%E5%BC%80%E4%B8%80%E4%B8%AA%E5%85%A8%E5%B1%80%E5%95%86%E5%BA%97 colour : this.dataColor default : ["shop1"] var code = '{"type": "openShop", "id": "'+IdString_0+'"},\n'; @@ -1120,7 +1125,7 @@ disableShop_s /* disableShop_s tooltip : 全局商店 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=disableshop%EF%BC%9A%E7%A6%81%E7%94%A8%E4%B8%80%E4%B8%AA%E5%85%A8%E5%B1%80%E5%95%86%E5%BA%97 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=disableshop%EF%BC%9A%E7%A6%81%E7%94%A8%E4%B8%80%E4%B8%AA%E5%85%A8%E5%B1%80%E5%95%86%E5%BA%97 default : ["shop1"] colour : this.dataColor var code = '{"type": "disableShop", "id": "'+IdString_0+'"},\n'; @@ -1133,7 +1138,7 @@ follow_s /* follow_s tooltip : follow: 跟随勇士 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=follow%ef%bc%9a%e8%b7%9f%e9%9a%8f%e5%8b%87%e5%a3%ab +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=follow%ef%bc%9a%e8%b7%9f%e9%9a%8f%e5%8b%87%e5%a3%ab default : ["npc.png"] colour : this.dataColor var code = '{"type": "follow", "name": "'+EvalString_0+'"},\n'; @@ -1146,7 +1151,7 @@ unfollow_s /* unfollow_s tooltip : unfollow: 取消跟随 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=unfollow%ef%bc%9a%e5%8f%96%e6%b6%88%e8%b7%9f%e9%9a%8f +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=unfollow%ef%bc%9a%e5%8f%96%e6%b6%88%e8%b7%9f%e9%9a%8f default : [""] colour : this.dataColor EvalString_0 = EvalString_0 ? (', "name": "' + EvalString_0 + '"') : ""; @@ -1160,7 +1165,7 @@ vibrate_s /* vibrate_s tooltip : vibrate: 画面震动 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=vibrate%ef%bc%9a%e7%94%bb%e9%9d%a2%e9%9c%87%e5%8a%a8 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=vibrate%ef%bc%9a%e7%94%bb%e9%9d%a2%e9%9c%87%e5%8a%a8 default : [2000,false] colour : this.soundColor Int_0 = Int_0 ?(', "time": '+Int_0):''; @@ -1175,7 +1180,7 @@ animate_s /* animate_s tooltip : animate:显示动画,位置填hero或者1,2形式的位置,或者不填代表当前事件点 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=animate%EF%BC%9A%E6%98%BE%E7%A4%BA%E5%8A%A8%E7%94%BB +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=animate%EF%BC%9A%E6%98%BE%E7%A4%BA%E5%8A%A8%E7%94%BB default : ["zone","hero",false] colour : this.soundColor if (EvalString_0) { @@ -1201,7 +1206,7 @@ showImage_s /* showImage_s tooltip : showImage:显示图片 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=showImage%ef%bc%9a%e6%98%be%e7%a4%ba%e5%9b%be%e7%89%87 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=showImage%ef%bc%9a%e6%98%be%e7%a4%ba%e5%9b%be%e7%89%87 default : [1,"bg.jpg","0","0",1,0,false] colour : this.printColor if(Int_0<=0 || Int_0>50) throw new Error('图片编号在1~50之间'); @@ -1218,7 +1223,7 @@ showImage_1_s /* showImage_1_s tooltip : showImage_1:显示图片 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=showImage%ef%bc%9a%e6%98%be%e7%a4%ba%e5%9b%be%e7%89%87 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=showImage%ef%bc%9a%e6%98%be%e7%a4%ba%e5%9b%be%e7%89%87 default : [1,"bg.jpg","0","0","","",1,"0","0","","",0,false] colour : this.printColor if(Int_0<=0 || Int_0>50) throw new Error('图片编号在1~50之间'); @@ -1237,7 +1242,7 @@ showTextImage_s /* showTextImage_s tooltip : showTextImage:显示图片化文本 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=showTextImage%ef%bc%9a%e6%98%be%e7%a4%ba%e6%96%87%e6%9c%ac%e5%8c%96%e5%9b%be%e7%89%87 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=showTextImage%ef%bc%9a%e6%98%be%e7%a4%ba%e6%96%87%e6%9c%ac%e5%8c%96%e5%9b%be%e7%89%87 colour : this.printColor default : ["可以使用setText事件来控制字体、颜色、大小、偏移量等",1,"0","0",1.4,1,0,false] if(Int_0<=0 || Int_0>50) throw new Error('图片编号在1~50之间'); @@ -1252,7 +1257,7 @@ hideImage_s /* hideImage_s tooltip : hideImage:清除图片 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=hideImage%ef%bc%9a%e6%b8%85%e9%99%a4%e5%9b%be%e7%89%87 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=hideImage%ef%bc%9a%e6%b8%85%e9%99%a4%e5%9b%be%e7%89%87 colour : this.printColor default : [1,0,false] if(Int_0<=0 || Int_0>50) throw new Error('图片编号在1~50之间'); @@ -1267,7 +1272,7 @@ showGif_0_s /* showGif_0_s tooltip : showGif:显示动图 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=showgif%EF%BC%9A%E6%98%BE%E7%A4%BA%E5%8A%A8%E5%9B%BE +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=showgif%EF%BC%9A%E6%98%BE%E7%A4%BA%E5%8A%A8%E5%9B%BE default : ["bg.gif","0","0"] colour : this.printColor var code = '{"type": "showGif", "name": "'+EvalString_0+'", "loc": ['+PosString_0+','+PosString_1+']},\n'; @@ -1280,7 +1285,7 @@ showGif_1_s /* showGif_1_s tooltip : showGif:清除所有显示的动图 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=showgif%EF%BC%9A%E6%98%BE%E7%A4%BA%E5%8A%A8%E5%9B%BE +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=showgif%EF%BC%9A%E6%98%BE%E7%A4%BA%E5%8A%A8%E5%9B%BE colour : this.printColor var code = '{"type": "showGif"},\n'; return code; @@ -1293,7 +1298,7 @@ moveImage_s /* moveImage_s tooltip : moveImage:图片移动 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=moveImage%ef%bc%9a%e5%9b%be%e7%89%87%e7%a7%bb%e5%8a%a8 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=moveImage%ef%bc%9a%e5%9b%be%e7%89%87%e7%a7%bb%e5%8a%a8 default : [1,'','','',500,false] colour : this.printColor if(Int_0<=0 || Int_0>50) throw new Error('图片编号在1~50之间'); @@ -1312,7 +1317,7 @@ setCurtain_0_s /* setCurtain_0_s tooltip : setCurtain: 更改画面色调,动画时间可不填 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=setcurtain%EF%BC%9A%E6%9B%B4%E6%94%B9%E7%94%BB%E9%9D%A2%E8%89%B2%E8%B0%83 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setcurtain%EF%BC%9A%E6%9B%B4%E6%94%B9%E7%94%BB%E9%9D%A2%E8%89%B2%E8%B0%83 default : ["255,255,255,1",'rgba(255,255,255,1)',500,false] colour : this.soundColor var colorRe = MotaActionFunctions.pattern.colorRe; @@ -1329,7 +1334,7 @@ setCurtain_1_s /* setCurtain_1_s tooltip : setCurtain: 恢复画面色调,动画时间可不填 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=setcurtain%EF%BC%9A%E6%9B%B4%E6%94%B9%E7%94%BB%E9%9D%A2%E8%89%B2%E8%B0%83 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setcurtain%EF%BC%9A%E6%9B%B4%E6%94%B9%E7%94%BB%E9%9D%A2%E8%89%B2%E8%B0%83 default : [500,false] colour : this.soundColor Int_0 = Int_0!=='' ?(', "time": '+Int_0):''; @@ -1343,7 +1348,7 @@ screenFlash_s /* screenFlash_s tooltip : screenFlash: 画面闪烁,动画时间可不填 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=screenFlash%EF%BC%9A%E7%94%BB%E9%9D%A2%E9%97%AA%E7%83%81 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=screenFlash%EF%BC%9A%E7%94%BB%E9%9D%A2%E9%97%AA%E7%83%81 default : ["255,255,255,1",'rgba(255,255,255,1)',500,1,false] colour : this.soundColor var colorRe = MotaActionFunctions.pattern.colorRe; @@ -1360,7 +1365,7 @@ setWeather_s /* setWeather_s tooltip : setWeather:更改天气 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=setweather%EF%BC%9A%E6%9B%B4%E6%94%B9%E5%A4%A9%E6%B0%94 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setweather%EF%BC%9A%E6%9B%B4%E6%94%B9%E5%A4%A9%E6%B0%94 default : [null,1] colour : this.soundColor if(Int_0<1 || Int_0>10) throw new Error('天气的强度等级, 在1-10之间'); @@ -1375,7 +1380,7 @@ move_s /* move_s tooltip : move: 让某个NPC/怪物移动,位置可不填代表当前事件 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=move%EF%BC%9A%E8%AE%A9%E6%9F%90%E4%B8%AAnpc%E6%80%AA%E7%89%A9%E7%A7%BB%E5%8A%A8 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=move%EF%BC%9A%E8%AE%A9%E6%9F%90%E4%B8%AAnpc%E6%80%AA%E7%89%A9%E7%A7%BB%E5%8A%A8 default : ["","",500,false,false,"上右3下2后4左前2"] colour : this.mapColor var floorstr = ''; @@ -1395,7 +1400,7 @@ moveHero_s /* moveHero_s tooltip : moveHero:移动勇士,用这种方式移动勇士的过程中将无视一切地形, 无视一切事件, 中毒状态也不会扣血 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=movehero%EF%BC%9A%E7%A7%BB%E5%8A%A8%E5%8B%87%E5%A3%AB +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=movehero%EF%BC%9A%E7%A7%BB%E5%8A%A8%E5%8B%87%E5%A3%AB default : [500,false,"上右3下2后4左前2"] colour : this.dataColor Int_0 = Int_0!=='' ?(', "time": '+Int_0):''; @@ -1410,7 +1415,7 @@ jump_s /* jump_s tooltip : jump: 让某个NPC/怪物跳跃 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=jump%EF%BC%9A%E8%AE%A9%E6%9F%90%E4%B8%AANPC%2F%E6%80%AA%E7%89%A9%E8%B7%B3%E8%B7%83 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=jump%EF%BC%9A%E8%AE%A9%E6%9F%90%E4%B8%AANPC%2F%E6%80%AA%E7%89%A9%E8%B7%B3%E8%B7%83 default : ["","","","",500,true,false] colour : this.mapColor var floorstr = ''; @@ -1433,7 +1438,7 @@ jumpHero_s /* jumpHero_s tooltip : jumpHero: 跳跃勇士 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=jumpHero%EF%BC%9A%E8%B7%B3%E8%B7%83%E5%8B%87%E5%A3%AB +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=jumpHero%EF%BC%9A%E8%B7%B3%E8%B7%83%E5%8B%87%E5%A3%AB default : ["","",500,false] colour : this.dataColor var floorstr = ''; @@ -1452,7 +1457,7 @@ playBgm_s /* playBgm_s tooltip : playBgm: 播放背景音乐 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=playbgm%EF%BC%9A%E6%92%AD%E6%94%BE%E8%83%8C%E6%99%AF%E9%9F%B3%E4%B9%90 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=playbgm%EF%BC%9A%E6%92%AD%E6%94%BE%E8%83%8C%E6%99%AF%E9%9F%B3%E4%B9%90 default : ["bgm.mp3"] colour : this.soundColor var code = '{"type": "playBgm", "name": "'+EvalString_0+'"},\n'; @@ -1465,7 +1470,7 @@ pauseBgm_s /* pauseBgm_s tooltip : pauseBgm: 暂停背景音乐 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=pausebgm%EF%BC%9A%E6%9A%82%E5%81%9C%E8%83%8C%E6%99%AF%E9%9F%B3%E4%B9%90 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=pausebgm%EF%BC%9A%E6%9A%82%E5%81%9C%E8%83%8C%E6%99%AF%E9%9F%B3%E4%B9%90 colour : this.soundColor var code = '{"type": "pauseBgm"},\n'; return code; @@ -1477,7 +1482,7 @@ resumeBgm_s /* resumeBgm_s tooltip : resumeBgm: 恢复背景音乐 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=resumebgm%EF%BC%9A%E6%81%A2%E5%A4%8D%E8%83%8C%E6%99%AF%E9%9F%B3%E4%B9%90 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=resumebgm%EF%BC%9A%E6%81%A2%E5%A4%8D%E8%83%8C%E6%99%AF%E9%9F%B3%E4%B9%90 colour : this.soundColor var code = '{"type": "resumeBgm"},\n'; return code; @@ -1489,7 +1494,7 @@ loadBgm_s /* loadBgm_s tooltip : loadBgm: 预加载某个背景音乐,之后可以直接播放 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=loadBgm%ef%bc%9a%e9%a2%84%e5%8a%a0%e8%bd%bd%e4%b8%80%e4%b8%aa%e8%83%8c%e6%99%af%e9%9f%b3%e4%b9%90 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=loadBgm%ef%bc%9a%e9%a2%84%e5%8a%a0%e8%bd%bd%e4%b8%80%e4%b8%aa%e8%83%8c%e6%99%af%e9%9f%b3%e4%b9%90 default : ["bgm.mp3"] colour : this.soundColor var code = '{"type": "loadBgm", "name": "'+EvalString_0+'"},\n'; @@ -1502,7 +1507,7 @@ freeBgm_s /* freeBgm_s tooltip : freeBgm: 释放背景音乐的缓存 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=freeBgm%ef%bc%9a%e9%87%8a%e6%94%be%e4%b8%80%e4%b8%aa%e8%83%8c%e6%99%af%e9%9f%b3%e4%b9%90%e7%9a%84%e7%bc%93%e5%ad%98 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=freeBgm%ef%bc%9a%e9%87%8a%e6%94%be%e4%b8%80%e4%b8%aa%e8%83%8c%e6%99%af%e9%9f%b3%e4%b9%90%e7%9a%84%e7%bc%93%e5%ad%98 default : ["bgm.mp3"] colour : this.soundColor var code = '{"type": "freeBgm", "name": "'+EvalString_0+'"},\n'; @@ -1515,7 +1520,7 @@ playSound_s /* playSound_s tooltip : playSound: 播放音效 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=playsound%EF%BC%9A%E6%92%AD%E6%94%BE%E9%9F%B3%E6%95%88 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=playsound%EF%BC%9A%E6%92%AD%E6%94%BE%E9%9F%B3%E6%95%88 default : ["item.mp3",false] colour : this.soundColor Bool_0 = Bool_0 ? ', "stop": true' : ''; @@ -1529,7 +1534,7 @@ stopSound_s /* stopSound_s tooltip : stopSound: 停止所有音效 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=stopSound%ef%bc%9a%e5%81%9c%e6%ad%a2%e6%89%80%e6%9c%89%e9%9f%b3%e6%95%88 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=stopSound%ef%bc%9a%e5%81%9c%e6%ad%a2%e6%89%80%e6%9c%89%e9%9f%b3%e6%95%88 colour : this.soundColor var code = '{"type": "stopSound"},\n'; return code; @@ -1541,7 +1546,7 @@ setVolume_s /* setVolume_s tooltip : setVolume: 设置音量 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=setvolume%EF%BC%9A%E8%AE%BE%E7%BD%AE%E9%9F%B3%E9%87%8F +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setvolume%EF%BC%9A%E8%AE%BE%E7%BD%AE%E9%9F%B3%E9%87%8F default : [90, 500, false] colour : this.soundColor Int_1 = Int_1!==''?(', "time": '+Int_1):"" @@ -1556,7 +1561,7 @@ win_s /* win_s tooltip : win: 获得胜利, 该事件会显示获胜页面, 并重新游戏 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=win%EF%BC%9A%E8%8E%B7%E5%BE%97%E8%83%9C%E5%88%A9 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=win%EF%BC%9A%E8%8E%B7%E5%BE%97%E8%83%9C%E5%88%A9 default : ["",false] Bool_0 = Bool_0?', "norank": 1':''; var code = '{"type": "win", "reason": "'+EvalString_0+'"'+Bool_0+'},\n'; @@ -1569,7 +1574,7 @@ lose_s /* lose_s tooltip : lose: 游戏失败, 该事件会显示失败页面, 并重新开始游戏 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=lose%EF%BC%9A%E6%B8%B8%E6%88%8F%E5%A4%B1%E8%B4%A5 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=lose%EF%BC%9A%E6%B8%B8%E6%88%8F%E5%A4%B1%E8%B4%A5 default : [""] var code = '{"type": "lose", "reason": "'+EvalString_0+'"},\n'; return code; @@ -1581,7 +1586,7 @@ restart_s /* restart_s tooltip : restart: 直接回到标题界面 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=restart%ef%bc%9a%e7%9b%b4%e6%8e%a5%e5%9b%9e%e5%88%b0%e6%a0%87%e9%a2%98%e7%95%8c%e9%9d%a2 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=restart%ef%bc%9a%e7%9b%b4%e6%8e%a5%e5%9b%9e%e5%88%b0%e6%a0%87%e9%a2%98%e7%95%8c%e9%9d%a2 var code = '{"type": "restart"},\n'; return code; */; @@ -1592,7 +1597,7 @@ input_s /* input_s tooltip : input:接受用户输入数字, 事件只能接受非负整数输入, 所有非法的输入将全部变成0 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=input%ef%bc%9a%e6%8e%a5%e5%8f%97%e7%94%a8%e6%88%b7%e8%be%93%e5%85%a5%e6%95%b0%e5%ad%97 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=input%ef%bc%9a%e6%8e%a5%e5%8f%97%e7%94%a8%e6%88%b7%e8%be%93%e5%85%a5%e6%95%b0%e5%ad%97 default : ["请输入一个数"] colour : this.dataColor var code = '{"type": "input", "text": "'+EvalString_0+'"},\n'; @@ -1605,7 +1610,7 @@ input2_s /* input2_s tooltip : input2:接受用户输入文本, 允许用户输入任何形式的文本 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=input2%ef%bc%9a%e6%8e%a5%e5%8f%97%e7%94%a8%e6%88%b7%e8%be%93%e5%85%a5%e6%96%87%e6%9c%ac +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=input2%ef%bc%9a%e6%8e%a5%e5%8f%97%e7%94%a8%e6%88%b7%e8%be%93%e5%85%a5%e6%96%87%e6%9c%ac default : ["请输入文本"] colour : this.dataColor var code = '{"type": "input2", "text": "'+EvalString_0+'"},\n'; @@ -1618,7 +1623,7 @@ if_s /* if_s tooltip : if: 条件判断 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=if%EF%BC%9A%E6%9D%A1%E4%BB%B6%E5%88%A4%E6%96%AD +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=if%EF%BC%9A%E6%9D%A1%E4%BB%B6%E5%88%A4%E6%96%AD colour : this.eventColor var code = ['{"type": "if", "condition": "',expression_0,'",\n', '"true": [\n',action_0,'],\n', @@ -1633,7 +1638,7 @@ if_1_s /* if_1_s tooltip : if: 条件判断 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=if%EF%BC%9A%E6%9D%A1%E4%BB%B6%E5%88%A4%E6%96%AD +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=if%EF%BC%9A%E6%9D%A1%E4%BB%B6%E5%88%A4%E6%96%AD colour : this.eventColor var code = ['{"type": "if", "condition": "',expression_0,'",\n', '"true": [\n',action_0,'],\n', @@ -1647,7 +1652,7 @@ switch_s /* switch_s tooltip : switch: 多重条件分歧 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=switch%EF%BC%9A%E5%A4%9A%E9%87%8D%E6%9D%A1%E4%BB%B6%E5%88%86%E6%AD%A7 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=switch%EF%BC%9A%E5%A4%9A%E9%87%8D%E6%9D%A1%E4%BB%B6%E5%88%86%E6%AD%A7 default : ["判别值"] colour : this.eventColor var code = ['{"type": "switch", "condition": "',expression_0,'", "caseList": [\n', @@ -1662,7 +1667,7 @@ switchCase /* switchCase tooltip : 选项的选择 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=switch%EF%BC%9A%E5%A4%9A%E9%87%8D%E6%9D%A1%E4%BB%B6%E5%88%86%E6%AD%A7 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=switch%EF%BC%9A%E5%A4%9A%E9%87%8D%E6%9D%A1%E4%BB%B6%E5%88%86%E6%AD%A7 default : ["", false] colour : this.subColor Bool_0 = Bool_0?', "nobreak": true':''; @@ -1676,7 +1681,7 @@ choices_s /* choices_s tooltip : choices: 给用户提供选项 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=choices%EF%BC%9A%E7%BB%99%E7%94%A8%E6%88%B7%E6%8F%90%E4%BE%9B%E9%80%89%E9%A1%B9 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=choices%EF%BC%9A%E7%BB%99%E7%94%A8%E6%88%B7%E6%8F%90%E4%BE%9B%E9%80%89%E9%A1%B9 default : ["","流浪者","woman"] var title=''; if (EvalString_1==''){ @@ -1700,7 +1705,7 @@ choicesContext /* choicesContext tooltip : 选项的选择 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=choices%EF%BC%9A%E7%BB%99%E7%94%A8%E6%88%B7%E6%8F%90%E4%BE%9B%E9%80%89%E9%A1%B9 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=choices%EF%BC%9A%E7%BB%99%E7%94%A8%E6%88%B7%E6%8F%90%E4%BE%9B%E9%80%89%E9%A1%B9 default : ["提示文字:红钥匙","",""] colour : this.subColor if (EvalString_1) { @@ -1720,7 +1725,7 @@ confirm_s /* confirm_s tooltip : 弹出确认框 -helpUrl : https://h5mota.com/games/template/docs/#/ +helpUrl : https://h5mota.com/games/template/_docs/#/ default : ["确认要xxx吗?",false] Bool_0 = Bool_0?', "default": true':'' var code = ['{"type": "confirm"'+Bool_0+', "text": "',EvalString_0,'",\n', @@ -1735,7 +1740,7 @@ while_s /* while_s tooltip : while:前置条件循环 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=while%ef%bc%9a%e5%89%8d%e7%bd%ae%e6%9d%a1%e4%bb%b6%e5%be%aa%e7%8e%af +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=while%ef%bc%9a%e5%89%8d%e7%bd%ae%e6%9d%a1%e4%bb%b6%e5%be%aa%e7%8e%af colour : this.eventColor var code = ['{"type": "while", "condition": "',expression_0,'",\n', '"data": [\n',action_0,'],\n', @@ -1748,7 +1753,7 @@ dowhile_s /* dowhile_s tooltip : dowhile:后置条件循环 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=dowhile%ef%bc%9a%e5%90%8e%e7%bd%ae%e6%9d%a1%e4%bb%b6%e5%be%aa%e7%8e%af +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=dowhile%ef%bc%9a%e5%90%8e%e7%bd%ae%e6%9d%a1%e4%bb%b6%e5%be%aa%e7%8e%af colour : this.eventColor var code = ['{"type": "dowhile", "condition": "',expression_0,'",\n', '"data": [\n',action_0,'],\n', @@ -1761,7 +1766,7 @@ break_s /* break_s tooltip : break:跳出循环, 如果break事件不在任何循环中被执行,则和exit等价,即会立刻结束当前事件! -helpUrl : https://h5mota.com/games/template/docs/#/event?id=break%EF%BC%9A%E8%B7%B3%E5%87%BA%E5%BE%AA%E7%8E%AF +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=break%EF%BC%9A%E8%B7%B3%E5%87%BA%E5%BE%AA%E7%8E%AF colour : this.eventColor var code = '{"type": "break"},\n'; return code; @@ -1772,7 +1777,7 @@ continue_s /* continue_s tooltip : continue:继续执行当前循环的下一轮, 如果continue事件不在任何循环中被执行,则和exit等价,即会立刻结束当前事件! -helpUrl : https://h5mota.com/games/template/docs/#/event?id=continue%EF%BC%9A%E7%BB%A7%E7%BB%AD%E6%89%A7%E8%A1%8C%E5%BD%93%E5%89%8D%E5%BE%AA%E7%8E%AF +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=continue%EF%BC%9A%E7%BB%A7%E7%BB%AD%E6%89%A7%E8%A1%8C%E5%BD%93%E5%89%8D%E5%BE%AA%E7%8E%AF colour : this.eventColor var code = '{"type": "continue"},\n'; return code; @@ -1785,7 +1790,7 @@ wait_s /* wait_s tooltip : wait: 等待用户操作并获得按键或点击信息(具体用法看文档) -helpUrl : https://h5mota.com/games/template/docs/#/event?id=wait%EF%BC%9A%E7%AD%89%E5%BE%85%E7%94%A8%E6%88%B7%E6%93%8D%E4%BD%9C +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=wait%EF%BC%9A%E7%AD%89%E5%BE%85%E7%94%A8%E6%88%B7%E6%93%8D%E4%BD%9C colour : this.soundColor var code = '{"type": "wait"},\n'; return code; @@ -1798,7 +1803,7 @@ waitAsync_s /* waitAsync_s tooltip : waitAsync: 等待所有异步事件执行完毕 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=waitAsync%ef%bc%9a%e7%ad%89%e5%be%85%e6%89%80%e6%9c%89%e5%bc%82%e6%ad%a5%e4%ba%8b%e4%bb%b6%e6%89%a7%e8%a1%8c%e5%ae%8c%e6%af%95 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=waitAsync%ef%bc%9a%e7%ad%89%e5%be%85%e6%89%80%e6%9c%89%e5%bc%82%e6%ad%a5%e4%ba%8b%e4%bb%b6%e6%89%a7%e8%a1%8c%e5%ae%8c%e6%af%95 colour : this.soundColor var code = '{"type": "waitAsync"},\n'; return code; @@ -1811,7 +1816,7 @@ callBook_s /* callBook_s tooltip : callBook: 呼出怪物手册;返回游戏后将继续执行后面的事件 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=callBook%ef%bc%9a%e5%91%bc%e5%87%ba%e6%80%aa%e7%89%a9%e6%89%8b%e5%86%8c +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=callBook%ef%bc%9a%e5%91%bc%e5%87%ba%e6%80%aa%e7%89%a9%e6%89%8b%e5%86%8c colour : this.soundColor var code = '{"type": "callBook"},\n'; return code; @@ -1824,7 +1829,7 @@ callSave_s /* callSave_s tooltip : callSave: 呼出存档页面 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=callSave%ef%bc%9a%e5%91%bc%e5%87%ba%e5%ad%98%e6%a1%a3%e7%95%8c%e9%9d%a2 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=callSave%ef%bc%9a%e5%91%bc%e5%87%ba%e5%ad%98%e6%a1%a3%e7%95%8c%e9%9d%a2 colour : this.soundColor var code = '{"type": "callSave"},\n'; return code; @@ -1837,7 +1842,7 @@ autoSave_s /* autoSave_s tooltip : autoSave: 自动存档 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=autoSave%ef%bc%9a%e8%87%aa%e5%8a%a8%e5%ad%98%e6%a1%a3 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=autoSave%ef%bc%9a%e8%87%aa%e5%8a%a8%e5%ad%98%e6%a1%a3 colour : this.soundColor var code = '{"type": "autoSave"},\n'; return code; @@ -1850,18 +1855,121 @@ callLoad_s /* callLoad_s tooltip : callLoad: 呼出存档页面;返回游戏后将继续执行后面的事件 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=callLoad%ef%bc%9a%e5%91%bc%e5%87%ba%e8%af%bb%e6%a1%a3%e7%95%8c%e9%9d%a2 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=callLoad%ef%bc%9a%e5%91%bc%e5%87%ba%e8%af%bb%e6%a1%a3%e7%95%8c%e9%9d%a2 colour : this.soundColor var code = '{"type": "callLoad"},\n'; return code; */; + +previewUI_s + : 'UI绘制预览' '(双击此项可进行预览)' BGNL? Newline action+ BEND Newline + + +/* previewUI_s +tooltip : previewUI: UI绘制预览 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=previewUI%ef%bc%9aUI%e7%bb%98%e5%88%b6%e9%a2%84%e8%a7%88 +colour : this.commentColor +var code = ['{"type": "previewUI", "action": [\n', action_0,']},\n'].join(''); +return code; +*/; + + +clearMap_s + : '清除画布' '起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString Newline + +/* clearMap_s +tooltip : clearMap: 清除画布 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=clearMap%ef%bc%9a%e6%b8%85%e9%99%a4%e7%94%bb%e5%b8%83 +colour : this.subColor +default : ["0", "0", "416", "480"] +var code = '{"type": "clearMap", "x": ' + PosString_0 + ', "y": ' + PosString_1 + + ', "width": ' + PosString_2 + ', "height": ' + PosString_3 + '},\n'; +return code; +*/; + + +clearMap_1_s + : '清空画布' + +/* clearMap_1_s +tooltip : clearMap: 清除画布 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=clearMap%ef%bc%9a%e6%b8%85%e9%99%a4%e7%94%bb%e5%b8%83 +colour : this.subColor +var code = '{"type": "clearMap"},\n'; +return code; +*/; + + +setAttribute_s + : '设置画布属性' '字体' EvalString? '填充样式' EvalString? Colour '边框样式' EvalString? Colour BGNL? '线宽度' EvalString? '不透明度' EvalString? '对齐' TextAlign_List '基准线' TextBaseline_List Newline + +/* setAttribute_s +tooltip : setAttribute:设置画布属性 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setAttribute%ef%bc%9a%e8%ae%be%e7%bd%ae%e7%94%bb%e5%b8%83%e5%b1%9e%e6%80%a7 +colour : this.subColor +default : ["","",'rgba(255,255,255,1)',"",'rgba(255,255,255,1)',"","",null,null] +TextAlign_List_0 = TextAlign_List_0==='null'?'': ', "align": "'+TextAlign_List_0+'"'; +TextBaseline_List_0 = TextBaseline_List_0==='null'?'': ', "baseline": "'+TextBaseline_List_0+'"'; +var colorRe = MotaActionFunctions.pattern.colorRe; +var fontRe = MotaActionFunctions.pattern.fontRe; +if (EvalString_0) { + if (!fontRe.test(EvalString_0)) throw new Error('字体必须是 [italic] [bold] 14px Verdana 这种形式或不填'); + EvalString_0 = ', "font": "' + EvalString_0 + '"'; +} +if (EvalString_1) { + if (!colorRe.test(EvalString_1))throw new Error('颜色格式错误,形如:0~255,0~255,0~255,0~1'); + EvalString_1 = ', "fillStyle": ['+EvalString_1+']'; +} +if (EvalString_2) { + if (!colorRe.test(EvalString_2))throw new Error('颜色格式错误,形如:0~255,0~255,0~255,0~1'); + EvalString_2 = ', "strokeStyle": ['+EvalString_2+']'; +} +if (EvalString_3) { + if (!/^\d+$/.test(EvalString_3))throw new Error('线宽必须是整数或不填'); + EvalString_3 = ', "lineWidth": '+EvalString_3; +} +if (EvalString_4) { + var f = parseFloat(EvalString_4); + if (isNaN(f) || f<0 || f>1) throw new Error('不透明度必须是0到1的浮点数或不填'); + EvalString_4 = ', "alpha": '+EvalString_4; +} +var code = '{"type": "setAttribute"'+EvalString_0+EvalString_1+EvalString_2+EvalString_3+EvalString_4+TextAlign_List_0+TextBaseline_List_0+'},\n'; +return code; +*/; + +fillText_s + : '绘制文本' 'x' PosString 'y' PosString '样式' EvalString? Colour '字体' EvalString? '最大宽度' EvalString? BGNL? EvalString Newline + +/* fillText_s +tooltip : fillText:绘制一行文本;可以设置最大宽度进行放缩 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=fillText%ef%bc%9a%e7%bb%98%e5%88%b6%e6%96%87%e6%9c%ac +colour : this.subColor +default : ["0","0","",'rgba(255,255,255,1)',"","","绘制一行文本"] +var colorRe = MotaActionFunctions.pattern.colorRe; +var fontRe = MotaActionFunctions.pattern.fontRe; +if (EvalString_0) { + if (!colorRe.test(EvalString_0))throw new Error('颜色格式错误,形如:0~255,0~255,0~255,0~1'); + EvalString_0 = ', "style": ['+EvalString_0+']'; +} +if (EvalString_1) { + if (!fontRe.test(EvalString_1)) throw new Error('字体必须是 [italic] [bold] 14px Verdana 这种形式或不填'); + EvalString_1 = ', "font": "' + EvalString_1 + '"'; +} +if (EvalString_2) { + if (!/^\d+$/.test(EvalString_2)) throw new Error('最大宽度必须是整数或不填'); + EvalString_2 = ', "maxWidth": ' + EvalString_2; +} +var code = '{"type": "fillText", "x": '+PosString_0+', "y": '+PosString_1+EvalString_0+EvalString_1+EvalString_2+', "text": "'+EvalString_3+'"},\n'; +return code; +*/; + unknown_s : '自定义事件' BGNL? RawEvalString /* unknown_s tooltip : 通过脚本自定义的事件类型, 以及编辑器不识别的事件类型 -helpUrl : https://h5mota.com/games/template/docs/#/ +helpUrl : https://h5mota.com/games/template/_docs/#/ default : ['{"type":"test", "data": "这是自定义的参数"}'] colour : this.dataColor try { @@ -1878,7 +1986,7 @@ function_s /* function_s tooltip : 可双击多行编辑,请勿使用异步代码。常见API参见文档附录。 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=function%EF%BC%9A%E8%87%AA%E5%AE%9A%E4%B9%89js%E8%84%9A%E6%9C%AC +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=function%EF%BC%9A%E8%87%AA%E5%AE%9A%E4%B9%89js%E8%84%9A%E6%9C%AC default : [false,"alert(core.getStatus(\"atk\"));"] colour : this.dataColor Bool_0 = Bool_0?', "async": true':''; @@ -2039,9 +2147,13 @@ SetTextPosition_List : '不改变'|'距离顶部'|'居中'|'距离底部' /*SetTextPosition_List ['null','up','center','down']*/; -SetTextAlign_List +TextAlign_List : '不改变'|'左对齐'|'左右居中'|'右对齐' - /*SetTextAlign_List ['null','left','center','right']*/; + /*TextAlign_List ['null','left','center','right']*/; + +TextBaseline_List + : '不改变'|'顶部'|'居中'|'标准值'|'底部' + /*TextBaseline_List ['null','top','middle','alphabetic','bottom']*/; ShopUse_List : '金币' | '经验' @@ -2348,11 +2460,10 @@ ActionParser.prototype.parseAction = function() { this.next = MotaActionBlocks['comment_s'].xmlText([this.EvalString(data.text),this.next],null,data.text); break; case "setText": // 设置剧情文本的属性 - var setTextfunc = function(a){return a?JSON.stringify(a).slice(1,-1):null;} - data.title=setTextfunc(data.title); - data.text=setTextfunc(data.text); + data.title=this.Colour(data.title); + data.text=this.Colour(data.text); if (!/^\w+\.png$/.test(data.background)) - data.background=setTextfunc(data.background); + data.background=this.Colour(data.background); this.next = MotaActionBlocks['setText_s'].xmlText([ data.position,data.offset,data.align,data.title,'rgba('+data.title+')', data.text,'rgba('+data.text+')',data.background,'rgba('+data.background+')', @@ -2453,7 +2564,7 @@ ActionParser.prototype.parseAction = function() { this.next = MotaActionBlocks['move_s'].xmlText([ data.loc[0],data.loc[1],data.time||0,data.keep||false,data.async||false,this.StepString(data.steps),this.next]); break; - case "moveHero": + case "moveHero": // 移动勇士 this.next = MotaActionBlocks['moveHero_s'].xmlText([ data.time||0,data.async||false,this.StepString(data.steps),this.next]); break; @@ -2536,6 +2647,7 @@ ActionParser.prototype.parseAction = function() { case "setFg": // 颜色渐变 case "setCurtain": if(this.isset(data.color)){ + data.color = this.Colour(data.color); this.next = MotaActionBlocks['setCurtain_0_s'].xmlText([ data.color,'rgba('+data.color+')',data.time||0,data.async||false,this.next]); } else { @@ -2544,6 +2656,7 @@ ActionParser.prototype.parseAction = function() { } break; case "screenFlash": // 画面闪烁 + data.color = this.Colour(data.color); this.next = MotaActionBlocks['screenFlash_s'].xmlText([ data.color,'rgba('+data.color+')',data.time||500,data.times||1,data.async||false,this.next]); break; @@ -2708,6 +2821,7 @@ ActionParser.prototype.parseAction = function() { case "choices": // 提供选项 var text_choices = null; for(var ii=data.choices.length-1,choice;choice=data.choices[ii];ii--) { + choice.color = this.Colour(choice.color); text_choices=MotaActionBlocks['choicesContext'].xmlText([ choice.text,choice.icon,choice.color,'rgba('+choice.color+')',this.insertActionList(choice.action),text_choices]); } @@ -2806,6 +2920,34 @@ ActionParser.prototype.parseAction = function() { this.next = MotaActionBlocks['exit_s'].xmlText([ this.next]); break; + case "previewUI": // UI绘制预览 + this.next = MotaActionBlocks['previewUI_s'].xmlText([ + this.insertActionList(data.action), this.next + ]); + break; + case "clearMap": // 清除画布 + if (data.x != null && data.y != null && data.width != null && data.height != null) { + this.next = MotaActionBlocks['clearMap_s'].xmlText([ + data.x, data.y, data.width, data.height, this.next + ]); + } + else { + this.next = MotaActionBlocks['clearMap_1_s'].xmlText([this.next]); + } + break; + case "setAttribute": // 设置画布属性 + data.fillStyle=this.Colour(data.fillStyle); + data.strokeStyle=this.Colour(data.strokeStyle); + this.next = MotaActionBlocks['setAttribute_s'].xmlText([ + data.font,data.fillStyle,'rgba('+data.fillStyle+')',data.strokeStyle,'rgba('+data.strokeStyle+')', + data.lineWidth,data.alpha,data.align,data.baseline,this.next]); + break; + case "fillText": // 绘制一行文本 + data.style = this.Colour(data.style); + this.next = MotaActionBlocks['fillText_s'].xmlText([ + data.x, data.y, data.style, 'rgba('+data.style+')', data.font, data.maxWidth, this.EvalString(data.text), this.next + ]); + break; case "animateImage": // 兼容 animateImage break; default: @@ -2859,6 +3001,10 @@ ActionParser.prototype.EvalString = function(EvalString) { return EvalString.split('\b').join('\\b').split('\t').join('\\t').split('\n').join('\\n'); } +ActionParser.prototype.Colour = function(color) { + return color?JSON.stringify(color).slice(1,-1):null; +} + ActionParser.prototype.tryToUseEvFlag_e = function(defaultType, args, isShadow, comment) { var match=/^switch:([A-F])$/.exec(args[0]) if(match){ @@ -2940,5 +3086,6 @@ MotaActionFunctions.pattern.id=/^flag:([a-zA-Z0-9_\u4E00-\u9FCC]+)$/; MotaActionFunctions.pattern.id2=/^flag:([a-zA-Z0-9_\u4E00-\u9FCC]+),flag:([a-zA-Z0-9_\u4E00-\u9FCC]+)$/; MotaActionFunctions.pattern.idWithoutFlag=/^[0-9a-zA-Z_][0-9a-zA-Z_\-:]*$/; MotaActionFunctions.pattern.colorRe=/^(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d),(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d),(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(,0(\.\d+)?|,1)?$/; +MotaActionFunctions.pattern.fontRe=/^(italic )?(bold )?(\d+)px ([a-zA-Z0-9_\u4E00-\u9FCC]+)$/; */ \ No newline at end of file diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index b81d675a..02964fc0 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -169,6 +169,13 @@ editor_blockly = function () { MotaActionBlocks['autoSave_s'].xmlText(), MotaActionBlocks['callLoad_s'].xmlText(), ], + 'UI绘制':[ + MotaActionBlocks['previewUI_s'].xmlText(), + MotaActionBlocks['clearMap_s'].xmlText(), + MotaActionBlocks['clearMap_1_s'].xmlText(), + MotaActionBlocks['setAttribute_s'].xmlText(), + MotaActionBlocks['fillText_s'].xmlText(), + ], '原生脚本':[ MotaActionBlocks['function_s'].xmlText(), MotaActionBlocks['unknown_s'].xmlText(), @@ -650,40 +657,26 @@ function omitedcheckUpdateFunction(event) { // Index from 1 - 9 editor_blockly.openToolbox = function(index) { - // var element = document.getElementById(':'+index); - // if (element == null || element.getAttribute("aria-selected")=="true") return; - // element.click(); - editor_blockly.workspace.toolbox_.tree_.setSelectedItem(editor_blockly.workspace.toolbox_.tree_.children_[index-1]); + if (index < 0) index += editor_blockly.workspace.toolbox_.tree_.children_.length; + editor_blockly.workspace.toolbox_.tree_.setSelectedItem(editor_blockly.workspace.toolbox_.tree_.children_[index]); } editor_blockly.reopenToolbox = function(index) { - // var element = document.getElementById(':'+index); - // if (element == null) return; - // if (element.getAttribute("aria-selected")=="true") element.click(); - // element.click(); - editor_blockly.workspace.toolbox_.tree_.setSelectedItem(editor_blockly.workspace.toolbox_.tree_.children_[index-1]); - editor_blockly.workspace.getFlyout_().show(editor_blockly.workspace.toolbox_.tree_.children_[index-1].blocks); + if (index < 0) index += editor_blockly.workspace.toolbox_.tree_.children_.length; + editor_blockly.workspace.toolbox_.tree_.setSelectedItem(editor_blockly.workspace.toolbox_.tree_.children_[index]); + editor_blockly.workspace.getFlyout_().show(editor_blockly.workspace.toolbox_.tree_.children_[index].blocks); } editor_blockly.closeToolbox = function() { - /* - for (var i=1; i<=10; i++) { - var element = document.getElementById(':'+i); - if (element && element.getAttribute("aria-selected")=="true") { - element.click(); - return; - } - } - */ editor_blockly.workspace.toolbox_.clearSelection(); } var searchInput = document.getElementById("searchBlock"); searchInput.onfocus = function () { - editor_blockly.reopenToolbox(10); + editor_blockly.reopenToolbox(-1); } searchInput.oninput = function () { - editor_blockly.reopenToolbox(10); + editor_blockly.reopenToolbox(-1); } editor_blockly.searchBlock = function (value) { diff --git a/libs/events.js b/libs/events.js index a3481278..49844643 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1620,7 +1620,7 @@ events.prototype._action_exit = function (data, x, y, prefix) { core.doAction(); } -events.prototype._action_previewUIEvent = function (data, x, y, prefix) { +events.prototype._action_previewUI = function (data, x, y, prefix) { this.insertAction(data.action); core.doAction(); } diff --git a/libs/ui.js b/libs/ui.js index 0ce671c4..6557a452 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -225,12 +225,14 @@ ui.prototype.setOpacity = function (name, opacity) { ////// 设置某个canvas的绘制属性(如颜色等) ////// ui.prototype.setFillStyle = function (name, style) { var ctx = this.getContextByName(name); + if (style instanceof Array) style = core.arrayToRGBA(style); if (ctx) ctx.fillStyle = style; } ////// 设置某个canvas边框属性 ////// ui.prototype.setStrokeStyle = function (name, style) { var ctx = this.getContextByName(name); + if (style instanceof Array) style = core.arrayToRGBA(style); if (ctx) ctx.strokeStyle = style; } @@ -656,17 +658,11 @@ ui.prototype._uievent_drawBackground = function (data) { var background = data.background || core.status.textAttribute.background; var x = core.calValue(data.x), y = core.calValue(data.y), w = core.calValue(data.width), h = core.calValue(data.height); if (typeof background == 'string') { - if (data.alpha != null) this.setAlpha('uievent', data.alpha); this.drawWindowSkin(background, 'uievent', x, y, w, h); } else if (background instanceof Array) { - var alpha = background[3]; - if (alpha == null) alpha = 1; - if (data.alpha != null) alpha = data.alpha; - this.setAlpha('uievent', alpha); - this.setLineWidth('uievent', 2); - this.fillRect('uievent', x, y, w, h, core.arrayToRGB(background)); - this.strokeRect('uievent', x, y, w, h, core.status.globalAttribute.borderColor); + this.fillRect('uievent', x, y, w, h, core.arrayToRGBA(background)); + this.strokeRect('uievent', x, y, w, h); } } @@ -800,7 +796,9 @@ ui.prototype.drawTextContent = function (ctx, content, config) { var _textBaseLine = tempCtx.textBaseline; tempCtx.textBaseline = 'top'; tempCtx.font = this._buildFont(config.fontSize, config.bold); - tempCtx.fillStyle = config.color; + var color = config.color; + if (color instanceof Array) color = core.arrayToRGBA(color); + tempCtx.fillStyle = color; this._drawTextContent_draw(ctx, tempCtx, content, config); tempCtx.textBaseline = _textBaseLine; } From 2586ec9b76ff5ce162e21f233d66fef7b5b8d090 Mon Sep 17 00:00:00 2001 From: oc Date: Sun, 26 May 2019 23:02:46 +0800 Subject: [PATCH 13/46] uievents --- _docs/api.md | 2 +- _docs/event.md | 193 +++++++++++++++++ _server/MotaAction.g4 | 385 +++++++++++++++++++++++++++++++++ _server/colorPicker/jsColor.js | 6 +- _server/editor_blockly.js | 14 ++ libs/events.js | 10 + libs/ui.js | 61 +++++- project/functions.js | 3 +- 8 files changed, 662 insertions(+), 12 deletions(-) diff --git a/_docs/api.md b/_docs/api.md index 0aa05bfe..640f74fc 100644 --- a/_docs/api.md +++ b/_docs/api.md @@ -1755,7 +1755,7 @@ config为绘制的配置项,目前可以包括如下几项: - bold:是否粗体。如果不设置默认为false。 - align:文字对齐方式,仅在maxWidth设置时有效,默认为'left'。 - fontSize:字体大小,如果不设置则使用剧情文本设置中的正文字体大小。 - - lineHeight:绘制的行距值,如果不设置则使用fontSize*1.3(即1.3被行距)。 + - lineHeight:绘制的行距值,如果不设置则使用fontSize*1.3(即1.3倍行距)。 - time:打字机效果。若不为0,则会逐个字进行绘制,并设置core.status.event.interval定时器。 diff --git a/_docs/event.md b/_docs/event.md index dfd2245c..a673d714 100644 --- a/_docs/event.md +++ b/_docs/event.md @@ -1863,6 +1863,199 @@ font可选,如果设置则是要绘制的字体。 maxWidth可选,如果设置且不为0,则代表要绘制的最大宽度;超过此宽度会自动放缩。 +### fillBoldText:绘制描边文本 + +UI绘制事件。 + +此项可以绘制一行描边文本。 + +```js +[ + {"type": "fillText", "text":"要绘制的描边文本", "x": 10, "y": 20, "style": [255,0,0,1]} +] +``` + +text必填,为要绘制的文本,支持`${}`的写法,不支持一切转义字符或换行符。 + +x和y必填,为要绘制的左上角坐标。请使用`setAttribute`来设置绘制的对齐方式和基准线。 + +style可选,如果设置需要是三元组RGB或四元组RBGA,代表绘制样式。 + +font可选,如果设置则是要绘制的字体。 + +### drawTextContent:绘制多行文本 + +UI绘制事件。 + +此项可以绘制多行文本。 + +```js +[ + {"type": "drawTextContent", "text":"要绘制的多行文本", "left": 10, "top": 20, "maxWidth": 100} +] +``` + +text必填,为要绘制的文本,支持所有的文字效果(如\n,${},\r,\\i等),但不支持支持\t和\b的语法。 + +left和top必填,为要绘制的起始像素坐标。实际绘制时会将textBaseline设置为'top',因此只需要考虑第一个字的左上角位置。 + +maxWidth可选,为单行最大宽度,超过此宽度将自动换行,不设置不会自动换行。 + +color可选,表示绘制时的颜色,为三元组RGB或四元组RGBA。如果不设置则使用剧情文本设置中的正文颜色。 + +bold可选,是否粗体。如果不设置默认为false。 + +align可选,文字对齐方式,仅在maxWidth设置时有效,默认为'left'。 + +fontSize可选,为字体大小,如果不设置则使用剧情文本设置中的正文字体大小。 + +lineHeight可选,绘制的行距值,如果不设置则使用fontSize*1.3(即1.3倍行距)。 + +### fillRect:绘制矩形 + +UI绘制事件。此项可以绘制一个矩形。 + +```js +[ + {"type": "fillRect", "x": 100, "y": 100, "width": 120, "height": 120, "style": [255,0,0,1]} +] +``` + +x, y, width, height必填,为要绘制的起点坐标和宽高;也可以用`flag:xxx`。 + +color可选,表示绘制时的颜色,为三元组RGB或四元组RGBA。 + +### strokeRect:绘制矩形边框 + +UI绘制事件。此项可以绘制一个矩形边框。 + +```js +[ + {"type": "strokeRect", "x": 100, "y": 100, "width": 120, "height": 120, "style": [255,0,0,1], "lineWidth": 4} +] +``` + +x, y, width, height必填,为要绘制的起点坐标和宽高;也可以用`flag:xxx`。 + +style可选,表示绘制时的颜色,为三元组RGB或四元组RGBA。 + +lineWidth可选,表示边框的线宽。 + +### drawLine:绘制线段 + +UI绘制事件。此事件可以绘制一个函数。 + +```js +[ + {"type": "drawLine", "x1": 0, "y1": 0, "x2": "flag:x", "y2": 200, "style": [255,0,0,1]} +] +``` + +x1, y1, x2, x2必填,为要绘制的起点和终点坐标;也可以用`flag:xxx`的写法。 + +style可选,表示绘制时的颜色,为三元组RGB或四元组RGBA。 + +lineWidth可选,表示边框的线宽。 + +### drawArrow:绘制箭头 + +UI绘制事件。此事件可以绘制一个箭头。 + +参数和写法与`drawLine`完全一致,只不过是会多画一个箭头标记。 + +### fillPolygon:绘制多边形 + +UI绘制事件。此事件可以绘制一个多边形。 + +```js +[ + {"type": "fillPolygon", "nodes": [[0,0],[0,100],[100,0]], "style": [255,0,0,1]} +] +``` + +nodes必填,为一个二维数组,其中每一项都是多边形一个顶点坐标。(与显示/隐藏事件写法相同) + +style可选,表示绘制时的颜色,为三元组RGB或四元组RGBA。 + +### strokePolygon:绘制多边形边框 + +UI绘制事件。此事件可以绘制一个多边形边框。 + +参数列表和`fillPolygon`基本相同,不过多了一个`lineWidth`表示的绘制线宽。 + +### drawImage:绘制图片 + +UI绘制事件。此事件可以绘制一个图片。 + +```js +[ + {"type": "drawImage", "image": "bg.jpg", "x": 0, "y": 0}, // 在(0,0)绘制bg.jpg + {"type": "drawImage", "image": "bg.jpg", "x": 0, "y": 0, "w": 100, "h": 100}, // 在(0,0)绘制bg.jpg,且放缩到100x100 + // 裁剪并放缩图片 + {"type": "drawImage", "image": "bg.jpg", "x": 0, "y": 0, "w": 100, "h": 100, "x1": 0, "y1": 0, "w1": 100, "h1": 100} +] +``` + +image必填,为图片名。图片必须在全塔属性中被注册过。 + +此函数有三种写法: + +- 只写x和y:表示要绘制到的位置。 +- 写x, y, w, h:表示要绘制到的位置,且将图片放缩到指定宽高。 +- 写x, y, w, h, x1, y1, w1, h1:从原始图片上裁剪[x,y,w,h]的图片,并绘制画布上的[x1,y1,w1,h1] + +可以查看下面的文档以了解各项参数的信息: +http://www.w3school.com.cn/html5/canvas_drawimage.asp + +### drawIcon:绘制图标 + +UI绘制事件。此事件可以绘制一个图标。 + +```js +[ + {"type": "drawIcon", "id": "yellowKey", "x": 100, "y": 100}, // 在(100,100)绘制黄钥匙 +] +``` + +id必填,为要绘制的图标ID。可以是一个注册过的图标ID,也可以使用状态栏的图标ID,例如lv, hp, up, save, settings等。 + +x, y必填,为要绘制的左上角坐标。width和height可选,如果设置则会将图标放缩成对应的宽高。 + +### drawBackground:绘制背景图 + +UI绘制事件。此事件可以绘制一个背景图。 + +```js +[ + {"type": "drawBackground", "background": "winskin.png", "x": 0, "y": 0, "width": 100, "height": 100}, +] +``` + +background必填,为要绘制的背景图内容。其可以是一个三元组RGB或四元组RGBA(纯色绘制),或一个WindowSkin的图片名。 + +x, y, width, height必填,分别为要绘制的起点坐标和长宽。 + +可以使用“设置画布属性”来设置不透明度和纯色绘制时的边框颜色。 + +### drawSelector:绘制闪烁光标 + +UI绘制事件。此事件可以绘制闪烁光标。 + +```js +[ + {"type": "drawSelector", "image": "winskin.png", "x": 0, "y": 0, "width": 100, "height": 100}, + {"type": "drawSelector"} // 清除闪烁光标 +] +``` + +image为要绘制的WindowSkin图片名;如果不填则视为“清除闪烁光标”。 + +x, y, width, height分别为要绘制的起点坐标和长宽。 + +请注意,同时只会有一个闪烁光标存在,如果创建多个则后者会替换前者。 + +闪烁光标将会一直存在即使事件流结束;请使用本事件并不填`image`来清除闪烁光标。 + ### function: 自定义JS脚本 上述给出了这么多事件,但有时候往往不能满足需求,这时候就需要执行自定义脚本了。 diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index a2adf880..5f8f8425 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -346,6 +346,20 @@ action | clearMap_1_s | setAttribute_s | fillText_s + | fillBoldText_s + | drawTextContent_s + | fillRect_s + | strokeRect_s + | drawLine_s + | drawArrow_s + | fillPolygon_s + | strokePolygon_s + | drawImage_s + | drawImage_1_s + | drawIcon_s + | drawBackground_s + | drawSelector_s + | drawSelector_1_s | unknown_s | function_s | pass_s @@ -1964,6 +1978,285 @@ var code = '{"type": "fillText", "x": '+PosString_0+', "y": '+PosString_1+EvalSt return code; */; +fillBoldText_s + : '绘制描边文本' 'x' PosString 'y' PosString '样式' EvalString? Colour '字体' EvalString? BGNL? EvalString Newline + +/* fillBoldText_s +tooltip : fillBoldText:绘制一行描边文本 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=fillBoldText%ef%bc%9a%e7%bb%98%e5%88%b6%e6%8f%8f%e8%be%b9%e6%96%87%e6%9c%ac +colour : this.subColor +default : ["0","0","",'rgba(255,255,255,1)',"","绘制一行描边文本"] +var colorRe = MotaActionFunctions.pattern.colorRe; +var fontRe = MotaActionFunctions.pattern.fontRe; +if (EvalString_0) { + if (!colorRe.test(EvalString_0))throw new Error('颜色格式错误,形如:0~255,0~255,0~255,0~1'); + EvalString_0 = ', "style": ['+EvalString_0+']'; +} +if (EvalString_1) { + if (!fontRe.test(EvalString_1)) throw new Error('字体必须是 [italic] [bold] 14px Verdana 这种形式或不填'); + EvalString_1 = ', "font": "' + EvalString_1 + '"'; +} +var code = '{"type": "fillBoldText", "x": '+PosString_0+', "y": '+PosString_1+EvalString_0+EvalString_1+', "text": "'+EvalString_2+'"},\n'; +return code; +*/; + +drawTextContent_s + : '绘制多行文本' EvalString BGNL? '左上角坐标' 'x' PosString 'y' PosString '最大宽度' EvalString? '颜色' EvalString? Colour BGNL? '对齐' TextAlign_List '字体大小' EvalString? '行距' EvalString? '粗体' Bool Newline + +/* drawTextContent_s +tooltip : drawTextContent:绘制多行文本 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=drawTextContent%ef%bc%9a%e7%bb%98%e5%88%b6%e5%a4%9a%e8%a1%8c%e6%96%87%e6%9c%ac +colour : this.subColor +default : ["绘制多行文本\\n第二行","0","0","","",'rgba(255,255,255,1)',null,"","",false] +var colorRe = MotaActionFunctions.pattern.colorRe; +TextAlign_List_0 = TextAlign_List_0==='null'?'': ', "align": "'+TextAlign_List_0+'"'; +Bool_0 = Bool_0 ? (', "bold": true') : ''; +if (EvalString_1) { + if (!/^\d+$/.test(EvalString_1)) throw new Error('最大宽度必须是整数或不填'); + EvalString_1 = ', "maxWidth": ' + EvalString_1; +} +if (EvalString_2) { + if (!colorRe.test(EvalString_2))throw new Error('颜色格式错误,形如:0~255,0~255,0~255,0~1'); + EvalString_2 = ', "color": ['+EvalString_2+']'; +} +if (EvalString_3) { + if (!/^\d+$/.test(EvalString_3)) throw new Error('字体大小必须是整数或不填'); + EvalString_3 = ', "fontSize": ' + EvalString_3; +} +if (EvalString_4) { + if (!/^\d+$/.test(EvalString_4)) throw new Error('行距必须是整数或不填'); + EvalString_4 = ', "lineHeight": ' + EvalString_4; +} +var code = '{"type": "drawTextContent", "text": "'+EvalString_0+'", "left": '+PosString_0+', "top": '+PosString_1+TextAlign_List_0+EvalString_1+EvalString_2+EvalString_3+EvalString_4+Bool_0+'},\n'; +return code; +*/; + +fillRect_s + : '绘制矩形' '起点像素坐标' 'x' PosString 'y' PosString '宽' PosString '高' PosString '颜色' EvalString? Colour Newline + +/* fillRect_s +tooltip : fillRect:绘制矩形 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=fillRect%ef%bc%9a%e7%bb%98%e5%88%b6%e7%9f%a9%e5%bd%a2 +colour : this.subColor +default : ["0","0","flag:x","300","",null] +var colorRe = MotaActionFunctions.pattern.colorRe; +if (EvalString_0) { + if (!colorRe.test(EvalString_0))throw new Error('颜色格式错误,形如:0~255,0~255,0~255,0~1'); + EvalString_0 = ', "style": ['+EvalString_0+']'; +} +var code = '{"type": "fillRect", "x": '+PosString_0+', "y": '+PosString_1+', "width": '+PosString_2+', "height": '+PosString_3+EvalString_0+'},\n'; +return code; +*/; + +strokeRect_s + : '绘制矩形边框' '起点像素坐标' 'x' PosString 'y' PosString '宽' PosString '高' PosString '颜色' EvalString? Colour '线宽' EvalString? Newline + +/* strokeRect_s +tooltip : strokeRect:绘制矩形边框 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=strokeRect%ef%bc%9a%e7%bb%98%e5%88%b6%e7%9f%a9%e5%bd%a2%e8%be%b9%e6%a1%86 +colour : this.subColor +default : ["0","0","flag:x","300","",null,""] +var colorRe = MotaActionFunctions.pattern.colorRe; +if (EvalString_0) { + if (!colorRe.test(EvalString_0))throw new Error('颜色格式错误,形如:0~255,0~255,0~255,0~1'); + EvalString_0 = ', "style": ['+EvalString_0+']'; +} +if (EvalString_1) { + if (!/^\d+$/.test(EvalString_1))throw new Error('线宽必须是整数或不填'); + EvalString_1 = ', "lineWidth": '+EvalString_1; +} +var code = '{"type": "strokeRect", "x": '+PosString_0+', "y": '+PosString_1+', "width": '+PosString_2+', "height": '+PosString_3+EvalString_0+EvalString_1+'},\n'; +return code; +*/; + +drawLine_s + : '绘制线段' '起点像素坐标' 'x' PosString 'y' PosString '终点像素坐标' 'x' PosString 'y' PosString '颜色' EvalString? Colour '线宽' EvalString? Newline + +/* drawLine_s +tooltip : drawLine:绘制线段 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=drawLine%ef%bc%9a%e7%bb%98%e5%88%b6%e7%ba%bf%e6%ae%b5 +colour : this.subColor +default : ["0","0","flag:x","300","",null,""] +var colorRe = MotaActionFunctions.pattern.colorRe; +if (EvalString_0) { + if (!colorRe.test(EvalString_0))throw new Error('颜色格式错误,形如:0~255,0~255,0~255,0~1'); + EvalString_0 = ', "style": ['+EvalString_0+']'; +} +if (EvalString_1) { + if (!/^\d+$/.test(EvalString_1))throw new Error('线宽必须是整数或不填'); + EvalString_1 = ', "lineWidth": '+EvalString_1; +} +var code = '{"type": "drawLine", "x1": '+PosString_0+', "y1": '+PosString_1+', "x2": '+PosString_2+', "y2": '+PosString_3+EvalString_0+EvalString_1+'},\n'; +return code; +*/; + +drawArrow_s + : '绘制箭头' '起点像素坐标' 'x' PosString 'y' PosString '终点像素坐标' 'x' PosString 'y' PosString '颜色' EvalString? Colour '线宽' EvalString? Newline + +/* drawArrow_s +tooltip : drawArrow:绘制箭头 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=drawArrow%ef%bc%9a%e7%bb%98%e5%88%b6%e7%ae%ad%e5%a4%b4 +colour : this.subColor +default : ["0","0","flag:x","300","",null,""] +var colorRe = MotaActionFunctions.pattern.colorRe; +if (EvalString_0) { + if (!colorRe.test(EvalString_0))throw new Error('颜色格式错误,形如:0~255,0~255,0~255,0~1'); + EvalString_0 = ', "style": ['+EvalString_0+']'; +} +if (EvalString_1) { + if (!/^\d+$/.test(EvalString_1))throw new Error('线宽必须是整数或不填'); + EvalString_1 = ', "lineWidth": '+EvalString_1; +} +var code = '{"type": "drawArrow", "x1": '+PosString_0+', "y1": '+PosString_1+', "x2": '+PosString_2+', "y2": '+PosString_3+EvalString_0+EvalString_1+'},\n'; +return code; +*/; + + +fillPolygon_s + : '绘制多边形' '顶点像素列表' 'x' EvalString 'y' EvalString '颜色' EvalString? Colour Newline + +/* fillPolygon_s +tooltip : fillPolygon:绘制多边形 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=fillPolygon%ef%bc%9a%e7%bb%98%e5%88%b6%e5%a4%9a%e8%be%b9%e5%bd%a2 +colour : this.subColor +default : ["0,0,100","0,100,0","",null] +var colorRe = MotaActionFunctions.pattern.colorRe; +var pattern2 = /^([+-]?\d+)(,[+-]?\d+)*$/; +if(!pattern2.test(EvalString_0) || !pattern2.test(EvalString_1))throw new Error('坐标格式错误,请右键点击帮助查看格式'); +EvalString_0=EvalString_0.split(','); +EvalString_1=EvalString_1.split(','); +if(EvalString_0.length!==EvalString_1.length)throw new Error('坐标格式错误,请右键点击帮助查看格式'); +for(var ii=0;ii Date: Sun, 26 May 2019 23:06:21 +0800 Subject: [PATCH 14/46] uievents --- _server/MotaAction.g4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 5f8f8425..27e2f435 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -2233,13 +2233,13 @@ return code; */; drawSelector_s - : '绘制闪烁光标' EvalString Colour '起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString Newline + : '绘制闪烁光标' EvalString '起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString Newline /* drawSelector_s tooltip : drawSelector:绘制闪烁光标 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=drawSelector%ef%bc%9a%e7%bb%98%e5%88%b6%e9%97%aa%e7%83%81%e5%85%89%e6%a0%87 -default : ["winskin.png",null,"0","0","100","100"] +default : ["winskin.png","0","0","100","100"] colour : this.subColor var code = '{"type": "drawSelector", "image": "'+EvalString_0+'", "x": '+PosString_0+', "y": '+PosString_1+', "width": '+PosString_2+', "height": '+PosString_3+'},\n'; return code; From 0c6176f5f6abbc6a14e558675ef6d3ae17c50564 Mon Sep 17 00:00:00 2001 From: oc Date: Sun, 26 May 2019 23:10:28 +0800 Subject: [PATCH 15/46] uievents --- _docs/event.md | 2 +- _server/MotaAction.g4 | 10 +++++----- _server/editor_blockly.js | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/_docs/event.md b/_docs/event.md index a673d714..28a93950 100644 --- a/_docs/event.md +++ b/_docs/event.md @@ -1795,7 +1795,7 @@ yes和no均为必填项,即用户点击确认或取消后执行的事件。 该事件会进行等待,直到所有可能的异步事件(异步动画除外)执行完毕。 -### previewUI:UI绘制预览 +### previewUI:UI绘制并预览 此项可在地图编辑器中预览UI界面的绘制效果。 diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 27e2f435..abaaa615 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -1877,13 +1877,13 @@ return code; previewUI_s - : 'UI绘制预览' '(双击此项可进行预览)' BGNL? Newline action+ BEND Newline + : 'ui绘制并预览' '(双击此项可进行预览)' BGNL? Newline action+ BEND Newline /* previewUI_s -tooltip : previewUI: UI绘制预览 -helpUrl : https://h5mota.com/games/template/_docs/#/event?id=previewUI%ef%bc%9aUI%e7%bb%98%e5%88%b6%e9%a2%84%e8%a7%88 -colour : this.commentColor +tooltip : previewUI: ui绘制并预览 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=previewUI%ef%bc%9aUI%e7%bb%98%e5%88%b6%e5%b9%b6%e9%a2%84%e8%a7%88 +colour : this.subColor var code = ['{"type": "previewUI", "action": [\n', action_0,']},\n'].join(''); return code; */; @@ -2007,7 +2007,7 @@ drawTextContent_s tooltip : drawTextContent:绘制多行文本 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=drawTextContent%ef%bc%9a%e7%bb%98%e5%88%b6%e5%a4%9a%e8%a1%8c%e6%96%87%e6%9c%ac colour : this.subColor -default : ["绘制多行文本\\n第二行","0","0","","",'rgba(255,255,255,1)',null,"","",false] +default : ["绘制多行文本\\n可双击编辑","0","0","","",'rgba(255,255,255,1)',null,"","",false] var colorRe = MotaActionFunctions.pattern.colorRe; TextAlign_List_0 = TextAlign_List_0==='null'?'': ', "align": "'+TextAlign_List_0+'"'; Bool_0 = Bool_0 ? (', "bold": true') : ''; diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 6fe22edc..ffc9b010 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -624,6 +624,7 @@ function omitedcheckUpdateFunction(event) { 'function_s': 'RawEvalString_0', 'shopsub': 'EvalString_3', 'confirm_s': 'EvalString_0', + 'drawTextContent_s': 'EvalString_0', } var f = b ? textStringDict[b.type] : null; if (f) { From 6b23361b61d624463fc15ba95fd6dd682cf2b396 Mon Sep 17 00:00:00 2001 From: oc Date: Sun, 26 May 2019 23:26:50 +0800 Subject: [PATCH 16/46] uievents --- _docs/event.md | 2 ++ _server/MotaAction.g4 | 15 +++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/_docs/event.md b/_docs/event.md index 28a93950..7cd66565 100644 --- a/_docs/event.md +++ b/_docs/event.md @@ -1911,6 +1911,8 @@ fontSize可选,为字体大小,如果不设置则使用剧情文本设置中 lineHeight可选,绘制的行距值,如果不设置则使用fontSize*1.3(即1.3倍行距)。 +此项不支持字体样式的设置,使用的是全塔属性中的全局字体;如有需要请使用“设置全局属性”事件来设置字体样式。 + ### fillRect:绘制矩形 UI绘制事件。此项可以绘制一个矩形。 diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index abaaa615..d4adc924 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -1883,7 +1883,6 @@ previewUI_s /* previewUI_s tooltip : previewUI: ui绘制并预览 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=previewUI%ef%bc%9aUI%e7%bb%98%e5%88%b6%e5%b9%b6%e9%a2%84%e8%a7%88 -colour : this.subColor var code = ['{"type": "previewUI", "action": [\n', action_0,']},\n'].join(''); return code; */; @@ -2001,7 +2000,7 @@ return code; */; drawTextContent_s - : '绘制多行文本' EvalString BGNL? '左上角坐标' 'x' PosString 'y' PosString '最大宽度' EvalString? '颜色' EvalString? Colour BGNL? '对齐' TextAlign_List '字体大小' EvalString? '行距' EvalString? '粗体' Bool Newline + : '绘制多行文本' EvalString BGNL? '起点像素' 'x' PosString 'y' PosString '最大宽度' EvalString? '颜色' EvalString? Colour BGNL? '对齐' TextAlign_List '字体大小' EvalString? '行距' EvalString? '粗体' Bool Newline /* drawTextContent_s tooltip : drawTextContent:绘制多行文本 @@ -2032,7 +2031,7 @@ return code; */; fillRect_s - : '绘制矩形' '起点像素坐标' 'x' PosString 'y' PosString '宽' PosString '高' PosString '颜色' EvalString? Colour Newline + : '绘制矩形' '起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString '颜色' EvalString? Colour Newline /* fillRect_s tooltip : fillRect:绘制矩形 @@ -2049,7 +2048,7 @@ return code; */; strokeRect_s - : '绘制矩形边框' '起点像素坐标' 'x' PosString 'y' PosString '宽' PosString '高' PosString '颜色' EvalString? Colour '线宽' EvalString? Newline + : '绘制矩形边框' '起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString '颜色' EvalString? Colour '线宽' EvalString? Newline /* strokeRect_s tooltip : strokeRect:绘制矩形边框 @@ -2070,7 +2069,7 @@ return code; */; drawLine_s - : '绘制线段' '起点像素坐标' 'x' PosString 'y' PosString '终点像素坐标' 'x' PosString 'y' PosString '颜色' EvalString? Colour '线宽' EvalString? Newline + : '绘制线段' '起点像素' 'x' PosString 'y' PosString '终点像素' 'x' PosString 'y' PosString '颜色' EvalString? Colour '线宽' EvalString? Newline /* drawLine_s tooltip : drawLine:绘制线段 @@ -2091,7 +2090,7 @@ return code; */; drawArrow_s - : '绘制箭头' '起点像素坐标' 'x' PosString 'y' PosString '终点像素坐标' 'x' PosString 'y' PosString '颜色' EvalString? Colour '线宽' EvalString? Newline + : '绘制箭头' '起点像素' 'x' PosString 'y' PosString '终点像素' 'x' PosString 'y' PosString '颜色' EvalString? Colour '线宽' EvalString? Newline /* drawArrow_s tooltip : drawArrow:绘制箭头 @@ -2164,7 +2163,7 @@ return code; */; drawImage_s - : '绘制图片' '图片' EvalString '起点像素' 'x' PosString 'y' PosString '宽' PosString? '高' PosString? Newline + : '绘制图片' EvalString '起点像素' 'x' PosString 'y' PosString '宽' PosString? '高' PosString? Newline /* drawImage_s @@ -2179,7 +2178,7 @@ return code; */; drawImage_1_s - : '绘制图片' '图片' EvalString BGNL? '裁剪的起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString BGNL? + : '绘制图片' EvalString '裁剪的起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString BGNL? '绘制的起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString Newline From ba7eccbf5eef8186487ec357437302cf8279be72 Mon Sep 17 00:00:00 2001 From: oc Date: Mon, 27 May 2019 21:56:28 +0800 Subject: [PATCH 17/46] toolboxReplay --- _server/MotaAction.g4 | 12 +++++++----- _server/editor_file_unsorted.js | 16 +++++++++------- libs/actions.js | 30 +++++++++++++++++++++++++----- libs/control.js | 22 ++++++++++++++++++++++ libs/events.js | 2 +- 5 files changed, 64 insertions(+), 18 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index d4adc924..291180ff 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -1851,20 +1851,22 @@ return code; autoSave_s - : '自动存档' + : '自动存档' '不提示' Bool Newline /* autoSave_s tooltip : autoSave: 自动存档 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=autoSave%ef%bc%9a%e8%87%aa%e5%8a%a8%e5%ad%98%e6%a1%a3 colour : this.soundColor -var code = '{"type": "autoSave"},\n'; +default : [false] +Bool_0 = Bool_0 ? (', "nohint": true') : ''; +var code = '{"type": "autoSave"'+Bool_0+'},\n'; return code; */; callLoad_s - : '呼出读档页面' + : '呼出读档页面' Newline /* callLoad_s @@ -1903,7 +1905,7 @@ return code; clearMap_1_s - : '清空画布' + : '清空画布' Newline /* clearMap_1_s tooltip : clearMap: 清除画布 @@ -3202,7 +3204,7 @@ ActionParser.prototype.parseAction = function() { break; case "autoSave": // 自动存档 this.next = MotaActionBlocks['autoSave_s'].xmlText([ - this.next]); + this.nohint, this.next]); break; case "callLoad": // 呼出读档界面 this.next = MotaActionBlocks['callLoad_s'].xmlText([ diff --git a/_server/editor_file_unsorted.js b/_server/editor_file_unsorted.js index 04c46d99..c6206fe9 100644 --- a/_server/editor_file_unsorted.js +++ b/_server/editor_file_unsorted.js @@ -15,13 +15,15 @@ editor_file = function (editor, callback) { var filename = 'project/floors/' + editor.currentFloorId + '.js'; var datastr = ['main.floors.', editor.currentFloorId, '=\n']; - for(var ii=0,name;name=['map','bgmap','fgmap'][ii];ii++){ - var mapArray=editor[name].map(function (v) { - return v.map(function (v) { - return v.idnum || v || 0 - }) - }); - editor.currentFloorData[name]=mapArray; + if (core.floorIds.indexOf(editor.currentFloorId) >= 0) { + for(var ii=0,name;name=['map','bgmap','fgmap'][ii];ii++){ + var mapArray=editor[name].map(function (v) { + return v.map(function (v) { + return v.idnum || v || 0 + }) + }); + editor.currentFloorData[name]=mapArray; + } } // format 更改实现方式以支持undefined删除 diff --git a/libs/actions.js b/libs/actions.js index b3885841..e4a79cb4 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -113,7 +113,8 @@ actions.prototype.doRegisteredAction = function (action) { actions.prototype._checkReplaying = function () { if (core.isReplaying() && core.status.event.id != 'save' - && (core.status.event.id || "").indexOf('book') != 0 && core.status.event.id != 'viewMaps') + && (core.status.event.id || "").indexOf('book') != 0 && core.status.event.id != 'viewMaps' + && core.status.event.id != 'toolbox' && core.status.event.id != 'equipbox') return true; return false; } @@ -170,6 +171,10 @@ actions.prototype._sys_onkeyUp_replay = function (e) { core.viewMapReplay(); else if (e.keyCode == 78) // N core.stepReplay(); + else if (e.keyCode == 84) // T + core.toolboxReplay(); + else if (e.keyCode == 81) // Q + core.equipboxReplay(); else if (e.keyCode >= 49 && e.keyCode <= 51) // 1-3 core.setReplaySpeed(e.keyCode - 48); else if (e.keyCode == 52) // 4 @@ -1317,7 +1322,10 @@ actions.prototype._clickToolbox = function (x, y) { // 装备栏 if (x >= this.LAST - 2 && y == 0) { core.ui.closePanel(); - core.openEquipbox(); + if (core.isReplaying()) + core.equipboxReplay(); + else + core.openEquipbox(); return; } if (x >= this.LAST - 2 && y == this.LAST) { @@ -1376,6 +1384,7 @@ actions.prototype._clickToolboxIndex = function (index) { if (select >= items.length) return; var itemId = items[select]; if (itemId == core.status.event.data.selectId) { + if (core.isReplaying()) return; core.events.tryUseItem(itemId); } else { @@ -1478,7 +1487,10 @@ actions.prototype._keyDownToolbox = function (keycode) { actions.prototype._keyUpToolbox = function (keycode) { if (keycode == 81) { core.ui.closePanel(); - core.openEquipbox(); + if (core.isReplaying()) + core.equipboxReplay(); + else + core.openEquipbox(); return; } if (keycode == 84 || keycode == 27 || keycode == 88) { @@ -1498,7 +1510,10 @@ actions.prototype._clickEquipbox = function (x, y) { // 道具栏 if (x >= this.LAST - 2 && y == 0) { core.ui.closePanel(); - core.openToolbox(); + if (core.isReplaying()) + core.toolboxReplay(); + else + core.openToolbox(); return; } // 返回 @@ -1547,6 +1562,7 @@ actions.prototype._clickEquipboxIndex = function (index) { if (index < this.LAST) { if (index >= core.status.globalAttribute.equipName.length) return; if (index == core.status.event.selection && core.status.hero.equipment[index]) { + if (core.isReplaying()) return; core.unloadEquip(index); core.status.route.push("unEquip:" + index); } @@ -1554,6 +1570,7 @@ actions.prototype._clickEquipboxIndex = function (index) { else { var equips = Object.keys(core.status.hero.items.equips || {}).sort(); if (index == core.status.event.selection) { + if (core.isReplaying()) return; var equipId = equips[index - this.LAST + (core.status.event.data.page - 1) * this.LAST]; core.loadEquip(equipId); core.status.route.push("equip:" + equipId); @@ -1645,7 +1662,10 @@ actions.prototype._keyUpEquipbox = function (keycode, altKey) { } if (keycode == 84) { core.ui.closePanel(); - core.openToolbox(); + if (core.isReplaying()) + core.toolboxReplay(); + else + core.openToolbox(); return; } if (keycode == 81 || keycode == 27 || keycode == 88) { diff --git a/libs/control.js b/libs/control.js index 4a9c8b84..6a9764a2 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1223,6 +1223,28 @@ control.prototype.viewMapReplay = function () { core.ui.drawMaps(); } +control.prototype.toolboxReplay = function () { + if (!core.isPlaying() || !core.isReplaying()) return; + if (!core.status.replay.pausing) return core.drawTip("请先暂停录像"); + if (core.isMoving() || core.status.replay.animate || core.status.event.id) + return core.drawTip("请等待当前事件的处理结束"); + + core.lockControl(); + core.status.event.id='toolbox'; + core.ui.drawToolbox(); +} + +control.prototype.equipboxReplay = function () { + if (!core.isPlaying() || !core.isReplaying()) return; + if (!core.status.replay.pausing) return core.drawTip("请先暂停录像"); + if (core.isMoving() || core.status.replay.animate || core.status.event.id) + return core.drawTip("请等待当前事件的处理结束"); + + core.lockControl(); + core.status.event.id='equipbox'; + core.ui.drawEquipbox(); +} + ////// 是否正在播放录像 ////// control.prototype.isReplaying = function () { return (core.status.replay||{}).replaying; diff --git a/libs/events.js b/libs/events.js index b196aa0e..2b070207 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1603,7 +1603,7 @@ events.prototype._action_callSave = function (data, x, y, prefix) { events.prototype._action_autoSave = function (data, x, y, prefix) { core.autosave(); - core.drawTip("已自动存档"); + if (!data.nohint) core.drawTip("已自动存档"); core.doAction(); } From 414dd86c81b43ea6d1802f0517523c2a93763ccc Mon Sep 17 00:00:00 2001 From: oc Date: Mon, 27 May 2019 23:23:32 +0800 Subject: [PATCH 18/46] previewUI part 1 --- _server/MotaAction.g4 | 2 +- _server/css/editor.css | 49 ++++++++++++++++++++++++++++++++++ _server/editor_unsorted_3.js | 51 ++++++++++++++++++++++++++++++++++++ editor-mobile.html | 2 +- editor.html | 25 +++++++++++++++++- 5 files changed, 126 insertions(+), 3 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 291180ff..419688ce 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -3204,7 +3204,7 @@ ActionParser.prototype.parseAction = function() { break; case "autoSave": // 自动存档 this.next = MotaActionBlocks['autoSave_s'].xmlText([ - this.nohint, this.next]); + data.nohint||false, this.next]); break; case "callLoad": // 呼出读档界面 this.next = MotaActionBlocks['callLoad_s'].xmlText([ diff --git a/_server/css/editor.css b/_server/css/editor.css index dd9c0e18..f4a372cf 100644 --- a/_server/css/editor.css +++ b/_server/css/editor.css @@ -458,4 +458,53 @@ table.row td { left: 6px; top: 6px; background-image:url('data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGJhc2VQcm9maWxlPSJmdWxsIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4bWxuczpldj0iaHR0cDovL3d3dy53My5vcmcvMjAwMS94bWwtZXZlbnRzIj4KPGc%2BCgk8cG9seWdvbiBmaWxsPSIjNjY2IiBwb2ludHM9IjkuMjA3LDYuMTI2IDcuNzkzLDcuNTQxIDExLjc5MywxMS41NDEgMTMuMjA3LDEwLjEyNiIgLz4KCTxwYXRoIGZpbGw9IiM2NjYiIGQ9Ik01LjkxNywyYzEuNjA4LDAsMi45MTcsMS4zMDgsMi45MTcsMi45MTdTNy41MjUsNy44MzMsNS45MTcsNy44MzNTMyw2LjUyNSwzLDQuOTE3UzQuMzA4LDIsNS45MTcsMgoJCSBNNS45MTcsMEMzLjIwMSwwLDEsMi4yMDEsMSw0LjkxN3MyLjIwMSw0LjkxNyw0LjkxNyw0LjkxN3M0LjkxNy0yLjIwMSw0LjkxNy00LjkxN0MxMC44MzMsMi4yMDEsOC42MzIsMCw1LjkxNywwTDUuOTE3LDB6IiAvPgo8L2c%2BCjwvc3ZnPgo%3D'); +} + +#uieventDiv { + display: none; + width: 100%; + height: 100%; + position: fixed; + top: 0; + left: 0; + background: rgba(127,127,127,0.6); + z-index: 2000 +} + +#uieventDialog { + position: fixed; + top: 50%; + left: 50%; + transform: translate(-50%, -60%); + background: white; + width: 436px; +} + +#uieventHead { + margin: 10px 20px; +} + +#uieventTitle { + font-weight: bold; +} + +#uieventNo { + float: right; +} + +#uieventYes { + display: none; + float: right; + margin-right: 15px; +} + +#uievent { + width: 416px; + height: 416px; + position: relative; + margin-left: 10px; +} + +#selectPoint { + display: none; } \ No newline at end of file diff --git a/_server/editor_unsorted_3.js b/_server/editor_unsorted_3.js index 170238e9..3c106459 100644 --- a/_server/editor_unsorted_3.js +++ b/_server/editor_unsorted_3.js @@ -367,3 +367,54 @@ selectBox.isSelected=function(value){ return selectBox._isSelected } +// ------ UI预览 & 地图选点相关 ------ // + +uievent = {}; + +uievent.uieventDiv = document.getElementById('uieventDiv'); + +uievent.uieventNo = document.getElementById('uieventNo'); +uievent.uieventNo.onclick = function () { + uievent.close(); +} + +uievent.uieventYes = document.getElementById('uieventYes'); +uievent.uieventYes.onclick = function () { + uievent.close(); + if (uievent.callback) { + uievent.callback(uievent.floorId, uievent.x, uievent.y); + } + delete uievent.callback; +} + +uievent.title = document.getElementById('uieventTitle'); +uievent.selectPoint = document.getElementById('selectPoint'); + +uievent.close = function () { + uievent.isOpen = false; + uievent.uieventDiv.style.display = 'none'; +} + +uievent.previewUI = function (list) { + uievent.isOpen = true; + uievent.uieventDiv.style.display = 'block'; + uievent.mode = 'previewUI'; + uievent.selectPoint.style.display = 'none'; + uievent.uieventYes.style.display = 'none'; + uievent.title.innerText = 'UI绘制预览'; + + core.clearMap('uievent'); + + // 绘制UI + core.drawThumbnail(editor.currentFloorId, null, {}, 'uievent'); + if (list instanceof Array) { + list.forEach(function (data) { + var type = data.type; + if (!type || !core.ui["_uievent_"+type]) return; + core.ui["_uievent_"+type](data); + }) + } +} + + + diff --git a/editor-mobile.html b/editor-mobile.html index 67db31dd..33c1f152 100644 --- a/editor-mobile.html +++ b/editor-mobile.html @@ -514,7 +514,7 @@ 此浏览器不支持HTML5 - + + From 4391e8cd7d20cfb1078a4e7f2df03d352716f2cc Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Fri, 31 May 2019 20:12:50 +0800 Subject: [PATCH 28/46] selectPoint fix bug --- _server/editor_blockly.js | 31 ++++++++++++++----------------- _server/editor_unsorted_3.js | 1 + 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 2fa83442..b236153f 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -734,11 +734,11 @@ function omitedcheckUpdateFunction(event) { // ------ select point ------ - // id: [x, y, floorId] + // id: [x, y, floorId, forceFloor] var selectPointBlocks = { - "changeFloor_m": ["Number_0", "Number_1", "IdString_0"], + "changeFloor_m": ["Number_0", "Number_1", "IdString_0", true], "jumpHero_s": ["PosString_0", "PosString_1"], - "changeFloor_s": ["PosString_0", "PosString_1", "IdString_0"], + "changeFloor_s": ["PosString_0", "PosString_1", "IdString_0", true], "changePos_0_s": ["PosString_0", "PosString_1"], "battle_1_s": ["PosString_0", "PosString_1"], "openDoor_s": ["PosString_0", "PosString_1", "IdString_0"], @@ -758,26 +758,23 @@ function omitedcheckUpdateFunction(event) { } editor_blockly.selectPoint = function () { - var block = Blockly.selected, x_area = null, y_area = null, floor_area = null; + var block = Blockly.selected, arr = null; var floorId = editor.currentFloorId, pos = editor.pos, x = pos.x, y = pos.y; if (block != null && block.type in selectPointBlocks) { - var arr = selectPointBlocks[block.type]; - x_area = arr[0]; - y_area = arr[1]; - floor_area = arr[2]; - var xv = parseInt(block.getFieldValue(x_area)), yv = parseInt(block.getFieldValue(y_area)); + arr = selectPointBlocks[block.type]; + var xv = parseInt(block.getFieldValue(arr[0])), yv = parseInt(block.getFieldValue(arr[1])); if (!isNaN(xv)) x = xv; if (!isNaN(yv)) y = yv; - if (floor_area != null) floorId = block.getFieldValue(floor_area) || floorId; + if (arr[2] != null) floorId = block.getFieldValue(arr[2]) || floorId; } - uievent.selectPoint(floorId, x, y, floor_area == null, function (fv, xv, yv) { - if (x_area == null || y_area == null) return; - if (floor_area != null) { - if (fv != editor.currentFloorId) block.setFieldValue(fv, floor_area); - else block.setFieldValue("", floor_area); + uievent.selectPoint(floorId, x, y, arr && arr[2] == null, function (fv, xv, yv) { + if (!arr) return; + if (arr[2] != null) { + if (fv != editor.currentFloorId) block.setFieldValue(fv, arr[2]); + else block.setFieldValue(arr[3] ? fv : "", arr[2]); } - block.setFieldValue(xv, x_area); - block.setFieldValue(yv, y_area); + block.setFieldValue(xv+"", arr[0]); + block.setFieldValue(yv+"", arr[1]); }); } diff --git a/_server/editor_unsorted_3.js b/_server/editor_unsorted_3.js index 55e92389..34d9fc38 100644 --- a/_server/editor_unsorted_3.js +++ b/_server/editor_unsorted_3.js @@ -483,6 +483,7 @@ uievent.updateSelectPoint = function (redraw) { } uievent.setPoint = function (floorId, x, y) { + if (core.floorIds.indexOf(floorId) == -1) floorId = editor.currentFloorId; uievent.values.floorId = floorId; uievent.elements.selectFloor.value = floorId; uievent.values.x = x != null ? x : ( uievent.values.x || 0); From b4a702f9280db0b89809dd260faace235b510a41 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Fri, 31 May 2019 20:14:06 +0800 Subject: [PATCH 29/46] selectPoint fix bug --- _server/editor_unsorted_3.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_server/editor_unsorted_3.js b/_server/editor_unsorted_3.js index 34d9fc38..5be3711f 100644 --- a/_server/editor_unsorted_3.js +++ b/_server/editor_unsorted_3.js @@ -449,6 +449,8 @@ uievent.selectPoint = function (floorId, x, y, hideFloor, callback) { uievent.values.hideFloor = hideFloor; uievent.values.callback = callback; uievent.values.size = editor.isMobile ? window.innerWidth / core.__SIZE__ : 32; + uievent.elements.selectPointBox.style.width = (uievent.values.size - 6) + "px"; + uievent.elements.selectPointBox.style.height = (uievent.values.size - 6) + "px"; uievent.isOpen = true; uievent.elements.div.style.display = 'block'; @@ -476,8 +478,6 @@ uievent.updateSelectPoint = function (redraw) { {ctx: 'uievent', centerX: uievent.values.left + core.__HALF_SIZE__, centerY: uievent.values.top + core.__HALF_SIZE__}); } - uievent.elements.selectPointBox.style.width = (uievent.values.size - 6) + "px"; - uievent.elements.selectPointBox.style.height = (uievent.values.size - 6) + "px"; uievent.elements.selectPointBox.style.left = uievent.values.size * (uievent.values.x - uievent.values.left) + "px"; uievent.elements.selectPointBox.style.top = uievent.values.size * (uievent.values.y - uievent.values.top) + "px"; } From ef31d39bed50dc89ad8d7b453f3371d4b081c34e Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Fri, 31 May 2019 20:45:53 +0800 Subject: [PATCH 30/46] setBlock selectPoint --- _server/editor_blockly.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index b236153f..d24e57cd 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -745,7 +745,7 @@ function omitedcheckUpdateFunction(event) { "closeDoor_s": ["PosString_0", "PosString_1"], "show_s": ["EvalString_0", "EvalString_1", "IdString_0"], "hide_s": ["EvalString_0", "EvalString_1", "IdString_0"], - "setBlock_s": ["PosString_0", "PosString_1"], + "setBlock_s": ["PosString_0", "PosString_1", "IdString_0"], "move_s": ["PosString_0", "PosString_1"], "jump_s": ["PosString_2", "PosString_3"], // 跳跃暂时只考虑终点 "showBgFgMap_s": ["EvalString_0", "EvalString_1", "IdString_0"], From 07646a8491e03d9bca6bd0d166e9777ab3d9f96a Mon Sep 17 00:00:00 2001 From: oc Date: Fri, 31 May 2019 22:52:58 +0800 Subject: [PATCH 31/46] uievent z --- _docs/event.md | 1 + _docs/personalization.md | 3 +++ _server/MotaAction.g4 | 12 ++++++++---- libs/ui.js | 10 +++++++++- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/_docs/event.md b/_docs/event.md index 7cd66565..64a598d1 100644 --- a/_docs/event.md +++ b/_docs/event.md @@ -1840,6 +1840,7 @@ UI绘制事件。 - `alpha`:不透明度,必须是0到1之间的浮点数 - `align`:对齐方式,只能是`left`, `center`, `right`,分别代表左对齐,居中和右对齐 - `baseline`:基准线,只能是`top`, `middle`, `alphabetic`, `bottom`,分别代表顶部,居中,标准值和底部。 +- `z`:画布的z值,必须是正整数。初始创建时画布的z值是135。请注意,闪烁光标所在画布的z值永远比该画布大1。 ### fillText:绘制文本 diff --git a/_docs/personalization.md b/_docs/personalization.md index 72de08cd..5b71c8c3 100644 --- a/_docs/personalization.md +++ b/_docs/personalization.md @@ -22,6 +22,7 @@ HTML5魔塔是使用画布(canvas)来绘制,存在若干个图层,它们 - paint**[D]**:绘图层;主要用来进行绘图模式。(z-index: 95) - curtain:色调层;用来控制当前楼层的画面色调 (z-index: 125) - image1\~50**[D]**:图片层;用来绘制图片等操作。(z-index: 100+code, 101~150) +- uievent**[D]**:自定义UI绘制层;用来进行自定义UI绘制等操作。(z-index:135,可以通过事件设置该值) - ui:UI层;用来绘制一切UI窗口,如剧情文本、怪物手册、楼传器、系统菜单等等 (z-index: 140) - data:数据层;用来绘制一些顶层的或更新比较快的数据,如左上角的提示,战斗界面中数据的变化等等。 (z-index: 170) @@ -29,6 +30,8 @@ HTML5魔塔是使用画布(canvas)来绘制,存在若干个图层,它们 而,色调层的z-index是25,ui层的z-index是140;因此,图片编号在1~24的将被色调层遮挡,25~40的将被ui层遮挡,41~50的将遮挡UI层。 +uievent层为自定义UI绘制所在的层,其z值初始是135,可以通过事件设置;自定义绘制的闪烁光标所在层的z值永远比该值大1。 + ### 动态创建canvas 从V2.5.3开始,可以在H5样板中任意动态创建canvas并进行使用。 diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 2d0a5276..1d87eba5 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -1917,13 +1917,13 @@ return code; setAttribute_s - : '设置画布属性' '字体' EvalString? '填充样式' EvalString? Colour '边框样式' EvalString? Colour BGNL? '线宽度' EvalString? '不透明度' EvalString? '对齐' TextAlign_List '基准线' TextBaseline_List Newline + : '设置画布属性' '字体' EvalString? '填充样式' EvalString? Colour '边框样式' EvalString? Colour BGNL? '线宽度' EvalString? '不透明度' EvalString? '对齐' TextAlign_List '基准线' TextBaseline_List 'z值' EvalString? Newline /* setAttribute_s tooltip : setAttribute:设置画布属性 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setAttribute%ef%bc%9a%e8%ae%be%e7%bd%ae%e7%94%bb%e5%b8%83%e5%b1%9e%e6%80%a7 colour : this.subColor -default : ["","",'rgba(255,255,255,1)',"",'rgba(255,255,255,1)',"","",null,null] +default : ["","",'rgba(255,255,255,1)',"",'rgba(255,255,255,1)',"","",null,null,""] TextAlign_List_0 = TextAlign_List_0==='null'?'': ', "align": "'+TextAlign_List_0+'"'; TextBaseline_List_0 = TextBaseline_List_0==='null'?'': ', "baseline": "'+TextBaseline_List_0+'"'; var colorRe = MotaActionFunctions.pattern.colorRe; @@ -1949,7 +1949,11 @@ if (EvalString_4) { if (isNaN(f) || f<0 || f>1) throw new Error('不透明度必须是0到1的浮点数或不填'); EvalString_4 = ', "alpha": '+EvalString_4; } -var code = '{"type": "setAttribute"'+EvalString_0+EvalString_1+EvalString_2+EvalString_3+EvalString_4+TextAlign_List_0+TextBaseline_List_0+'},\n'; +if (EvalString_5) { + if (!/^\d+$/.test(EvalString_5))throw new Error('z值必须是整数或不填'); + EvalString_5 = ', "z": '+EvalString_5; +} +var code = '{"type": "setAttribute"'+EvalString_0+EvalString_1+EvalString_2+EvalString_3+EvalString_4+TextAlign_List_0+TextBaseline_List_0+EvalString_5+'},\n'; return code; */; @@ -3234,7 +3238,7 @@ ActionParser.prototype.parseAction = function() { data.strokeStyle=this.Colour(data.strokeStyle); this.next = MotaActionBlocks['setAttribute_s'].xmlText([ data.font,data.fillStyle,'rgba('+data.fillStyle+')',data.strokeStyle,'rgba('+data.strokeStyle+')', - data.lineWidth,data.alpha,data.align,data.baseline,this.next]); + data.lineWidth,data.alpha,data.align,data.baseline,data.z,this.next]); break; case "fillText": // 绘制一行文本 data.style = this.Colour(data.style); diff --git a/libs/ui.js b/libs/ui.js index c4b5ecbb..d2ef8f88 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -301,6 +301,12 @@ ui.prototype._uievent_setAttribute = function (data) { if (data.strokeStyle) this.setStrokeStyle('uievent', data.strokeStyle); if (data.align) this.setTextAlign('uievent', data.align); if (data.baseline) this.setTextBaseline('uievent', data.baseline); + if (data.z != null && main.mode != 'editor') { + var z = parseInt(data.z) || 135; + core.dymCanvas.uievent.canvas.style.zIndex = z; + if (core.dymCanvas._uievent_selector) + core.dymCanvas._uievent_selector.canvas.style.zIndex = z + 1; + } } ////// 计算某段文字的宽度 ////// @@ -613,7 +619,9 @@ ui.prototype._uievent_drawSelector = function (data) { this._drawSelector('uievent', background, w, h, x, y); return; } - var ctx = core.createCanvas('_uievent_selector', x, y, w, h, 136); + var z = 136; + if (core.dymCanvas.uievent) z = (parseInt(core.dymCanvas.uievent.canvas.style.zIndex) || 135) + 1; + var ctx = core.createCanvas('_uievent_selector', x, y, w, h, z); ctx.canvas.style.opacity = 0.8; this._drawSelector(ctx, background, w, h); } From 2899167a3be356f2ce5ff519236b108d66fb7a07 Mon Sep 17 00:00:00 2001 From: oc Date: Fri, 31 May 2019 23:31:01 +0800 Subject: [PATCH 32/46] fix g4 bug --- _server/MotaAction.g4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 1d87eba5..ccddca7a 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -109,7 +109,7 @@ return code; */; shopsub - : '商店 id' IdString '标题' EvalString '图标' IdString BGNL? Newline '快捷商店栏中名称' EvalString '共用times' Bool BGNL? Newline '未开启状态则不显示在列表中' Bool BGNL? NewLine '使用' ShopUse_List '消耗' EvalString BGNL? Newline '显示文字' EvalString BGNL? Newline shopChoices+ BEND + : '商店 id' IdString '标题' EvalString '图标' IdString BGNL? Newline '快捷商店栏中名称' EvalString '共用times' Bool BGNL? Newline '未开启状态则不显示在列表中' Bool BGNL? Newline '使用' ShopUse_List '消耗' EvalString BGNL? Newline '显示文字' EvalString BGNL? Newline shopChoices+ BEND /* shopsub @@ -702,7 +702,7 @@ return code; */; insert_2_s - : '插入事件' 'x' PosString ',' 'y' PosString Event_List? '楼层' IdString? '参数列表' EvalString? ENewline + : '插入事件' 'x' PosString ',' 'y' PosString Event_List? '楼层' IdString? '参数列表' EvalString? Newline /* insert_2_s From 718852b9ef9e30c0bc5cf78884b6b63efc32cfee Mon Sep 17 00:00:00 2001 From: oc Date: Sun, 2 Jun 2019 10:23:46 +0800 Subject: [PATCH 33/46] fix bugs --- _server/editor_file_unsorted.js | 4 ++-- libs/events.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/_server/editor_file_unsorted.js b/_server/editor_file_unsorted.js index c6206fe9..eec1667a 100644 --- a/_server/editor_file_unsorted.js +++ b/_server/editor_file_unsorted.js @@ -58,8 +58,8 @@ editor_file = function (editor, callback) { title = "主塔 "+name+" 层"; } - var width = parseInt(document.getElementById('newMapsWidth').value); - var height = parseInt(document.getElementById('newMapsHeight').value); + var width = parseInt(document.getElementById('newMapWidth').value); + var height = parseInt(document.getElementById('newMapHeight').value); var row = [], map = []; for (var i=0;i Date: Sun, 2 Jun 2019 14:49:54 +0800 Subject: [PATCH 34/46] long press arrow --- _server/editor_unsorted_1.js | 25 +++++++++++++++++-- _server/editor_unsorted_3.js | 47 ++++++++++++++++++++++++------------ 2 files changed, 55 insertions(+), 17 deletions(-) diff --git a/_server/editor_unsorted_1.js b/_server/editor_unsorted_1.js index 06fda791..0df1beaf 100644 --- a/_server/editor_unsorted_1.js +++ b/_server/editor_unsorted_1.js @@ -760,10 +760,31 @@ editor.constructor.prototype.listen=function () { } var viewportButtons=document.getElementById('viewportButtons'); + var pressTimer = null; for(var ii=0,node;node=viewportButtons.children[ii];ii++){ (function(x,y){ - node.onclick=function(){ - editor.moveViewport(x,y); + var move = function () { + editor.moveViewport(x, y); + } + node.onmousedown = function () { + clearTimeout(pressTimer); + pressTimer = setTimeout(function () { + pressTimer = -1; + var f = function () { + if (pressTimer != null) { + move(); + setTimeout(f, 150); + } + } + f(); + }, 500); + }; + node.onmouseup = function () { + if (pressTimer >= 0) { + clearTimeout(pressTimer); + move(); + } + pressTimer = null; } })([-1,0,0,1][ii],[0,-1,1,0][ii]); } diff --git a/_server/editor_unsorted_3.js b/_server/editor_unsorted_3.js index 5be3711f..fc196d31 100644 --- a/_server/editor_unsorted_3.js +++ b/_server/editor_unsorted_3.js @@ -511,23 +511,40 @@ uievent.move = function (dx, dy) { uievent.values.left = core.clamp(uievent.values.left + dx, 0, uievent.values.width - core.__SIZE__); uievent.values.top = core.clamp(uievent.values.top + dy, 0, uievent.values.height - core.__SIZE__); this.updateSelectPoint(true); -} +}; -uievent.elements.selectPointButtons.children[0].onclick = function () { - uievent.move(-1, 0); -} +(function() { -uievent.elements.selectPointButtons.children[1].onclick = function () { - uievent.move(0, -1); -} - -uievent.elements.selectPointButtons.children[2].onclick = function () { - uievent.move(0, 1); -} - -uievent.elements.selectPointButtons.children[3].onclick = function () { - uievent.move(1, 0); -} + var viewportButtons = uievent.elements.selectPointButtons; + var pressTimer = null; + for(var ii=0,node;node=viewportButtons.children[ii];ii++){ + (function(x,y){ + var move = function () { + uievent.move(x, y); + } + node.onmousedown = function () { + clearTimeout(pressTimer); + pressTimer = setTimeout(function () { + pressTimer = -1; + var f = function () { + if (pressTimer != null) { + move(); + setTimeout(f, 150); + } + } + f(); + }, 500); + }; + node.onmouseup = function () { + if (pressTimer >= 0) { + clearTimeout(pressTimer); + move(); + } + pressTimer = null; + } + })([-1,0,0,1][ii],[0,-1,1,0][ii]); + } +})(); uievent.elements.div.onmousewheel = function (e) { if (uievent.mode != 'selectPoint' || uievent.values.hideFloor) return; From 10fc17993474440e1fab66c62b7cc478cb1c1fb7 Mon Sep 17 00:00:00 2001 From: oc Date: Sun, 2 Jun 2019 15:32:14 +0800 Subject: [PATCH 35/46] editor help & plugin new function --- _server/editor_multi.js | 2 ++ _server/editor_unsorted_1.js | 47 ++++++++++++++++++++++++++++-------- _server/editor_unsorted_2.js | 9 ++++--- _server/editor_unsorted_3.js | 11 +++++---- 4 files changed, 51 insertions(+), 18 deletions(-) diff --git a/_server/editor_multi.js b/_server/editor_multi.js index 476536bb..069855cc 100644 --- a/_server/editor_multi.js +++ b/_server/editor_multi.js @@ -94,6 +94,8 @@ editor_multi = function () { editor_multi.lintAutocomplete = false; if (args.lint === true) editor_multi.lintAutocomplete = true; if (field.indexOf('Effect') !== -1) editor_multi.lintAutocomplete = true; + if ((!input.value || input.value == 'null') && editor_mode.mode == 'plugins') + input.value = '"function () {\\n\\t// 在此增加新插件\\n\\t\\n}"'; if (input.value.slice(0, 1) === '"' || args.string) { editor_multi.isString = true; codeEditor.setValue(JSON.parse(input.value) || ''); diff --git a/_server/editor_unsorted_1.js b/_server/editor_unsorted_1.js index 0df1beaf..6eec656c 100644 --- a/_server/editor_unsorted_1.js +++ b/_server/editor_unsorted_1.js @@ -379,18 +379,45 @@ editor.constructor.prototype.listen=function () { } var focusElement = document.activeElement; if (!focusElement || focusElement.tagName.toLowerCase()=='body') { - // wasd平移大地图 - if (e.keyCode==87) - editor.moveViewport(0,-1) - else if (e.keyCode==65) - editor.moveViewport(-1,0) - else if (e.keyCode==83) - editor.moveViewport(0,1); - else if (e.keyCode==68) - editor.moveViewport(1,0); + switch (e.keyCode) { + // WASD + case 87: editor.moveViewport(0,-1); break; + case 65: editor.moveViewport(-1,0); break; + case 83: editor.moveViewport(0,1); break; + case 68: editor.moveViewport(1,0); break; + // Z~. + case 90: editor_mode.change('map'); break; // Z + case 88: editor_mode.change('loc'); break; // X + case 67: editor_mode.change('enemyitem'); break; // C + case 86: editor_mode.change('floor'); break; // V + case 66: editor_mode.change('tower'); break; // B + case 78: editor_mode.change('functions'); break; // N + case 77: editor_mode.change('appendpic'); break; // M + case 188: editor_mode.change('commonevent'); break; // , + case 190: editor_mode.change('plugins'); break; // . + // H + case 72: editor.showHelp(); break; + } } } + editor.showHelp = function () { + alert( + "快捷操作帮助:\n" + + "点击空白处:自动保存当前修改" + + "WASD / 长按箭头:平移大地图\n" + + "PgUp, PgDn / 鼠标滚轮:上下切换楼层\n" + + "Z~.(键盘的第三排):快捷切换标签\n" + + "双击地图:选中对应点的素材\n" + + "右键地图:弹出菜单栏\n" + + "Alt+0~9:保存当前使用的图块\n" + + "Ctrl+0~9:选中保存的图块\n" + + "Ctrl+Z / Ctrl+Y:撤销/重做上次绘制\n" + + "Ctrl+S:事件与脚本编辑器的保存并退出\n" + + "双击事件编辑器:长文本编辑/脚本编辑/地图选点/UI绘制预览" + ); + } + var getScrollBarHeight = function () { var outer = document.createElement("div"); outer.style.visibility = "hidden"; @@ -780,7 +807,7 @@ editor.constructor.prototype.listen=function () { }, 500); }; node.onmouseup = function () { - if (pressTimer >= 0) { + if (pressTimer > 0) { clearTimeout(pressTimer); move(); } diff --git a/_server/editor_unsorted_2.js b/_server/editor_unsorted_2.js index 17b8092e..042b617b 100644 --- a/_server/editor_unsorted_2.js +++ b/_server/editor_unsorted_2.js @@ -568,11 +568,14 @@ editor_unsorted_2_wrapper=function(editor_mode){ }); } + editor_mode.change = function (value) { + editor_mode.onmode('nextChange'); + editor_mode.onmode(value); + if(editor.isMobile)editor.showdataarea(false); + } var editModeSelect = document.getElementById('editModeSelect'); editModeSelect.onchange = function () { - editor_mode.onmode('nextChange'); - editor_mode.onmode(editModeSelect.value); - if(editor.isMobile)editor.showdataarea(false); + editor_mode.change(editModeSelect.value); } editor_mode.checkUnique = function (thiseval) { diff --git a/_server/editor_unsorted_3.js b/_server/editor_unsorted_3.js index fc196d31..c33c5c07 100644 --- a/_server/editor_unsorted_3.js +++ b/_server/editor_unsorted_3.js @@ -207,10 +207,11 @@ printe = function (str_) { printf(str_, 'error') } tip_in_showMode = [ - '涉及图片的更改需要F5刷新浏览器来生效', - '文本域可以通过双击,在文本编辑器或事件编辑器中编辑', - '事件编辑器中的显示文本和自定义脚本的方块也可以双击', - "画出的地图要点击\"保存地图\"才会写入到文件中", + '表格的文本域可以双击进行编辑', + '双击地图可以选中素材,右键可以弹出菜单', + '双击事件编辑器的图块可以进行长文本编辑/脚本编辑/地图选点/UI绘制预览等操作', + '点击空白处可以自动保存当前修改', + 'H键可以打开操作帮助哦', ]; tip=document.getElementById('tip') tip._infos= {} @@ -536,7 +537,7 @@ uievent.move = function (dx, dy) { }, 500); }; node.onmouseup = function () { - if (pressTimer >= 0) { + if (pressTimer > 0) { clearTimeout(pressTimer); move(); } From 4753b47eb4e346dfd46c3dd7bbac2ba5c3e00068 Mon Sep 17 00:00:00 2001 From: oc Date: Sun, 2 Jun 2019 17:10:37 +0800 Subject: [PATCH 36/46] editor.viewportLoc --- _server/editor.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/_server/editor.js b/_server/editor.js index aa5a21ec..b8c770e4 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -144,14 +144,15 @@ editor.prototype.changeFloor = function (floorId, callback) { } editor.preMapData = null; core.changeFloor(floorId, null, {"x": 0, "y": 0, "direction": "up"}, null, function () { - core.bigmap.offsetX=0; - core.bigmap.offsetY=0; - editor.moveViewport(0,0); - editor.game.fetchMapFromCore(); editor.updateMap(); editor_mode.floor(); editor.drawEventBlock(); + + editor.viewportLoc = editor.viewportLoc || {}; + var loc = editor.viewportLoc[floorId] || [], x = loc[0] || 0, y = loc[1] || 0; + editor.setViewport(x, y); + if (callback) callback(); }); } @@ -256,14 +257,19 @@ editor.prototype.updateMap = function () { } -editor.prototype.moveViewport=function(x,y){ - core.bigmap.offsetX = core.clamp(core.bigmap.offsetX+32*x, 0, 32*core.bigmap.width-core.__PIXELS__); - core.bigmap.offsetY = core.clamp(core.bigmap.offsetY+32*y, 0, 32*core.bigmap.height-core.__PIXELS__); +editor.prototype.setViewport=function (x, y) { + core.bigmap.offsetX = core.clamp(x, 0, 32*core.bigmap.width-core.__PIXELS__); + core.bigmap.offsetY = core.clamp(y, 0, 32*core.bigmap.height-core.__PIXELS__); + editor.viewportLoc[editor.currentFloorId] = [core.bigmap.offsetX, core.bigmap.offsetY]; core.control.updateViewport(); editor.buildMark(); editor.drawPosSelection(); } +editor.prototype.moveViewport=function(x,y){ + this.setViewport(core.bigmap.offsetX+32*x, core.bigmap.offsetY+32*y); +} + /////////// 界面交互相关 /////////// editor.prototype.drawInitData = function (icons) { From bcb3bfc8fd13d2b85d7743a8120ecb03d3b02a12 Mon Sep 17 00:00:00 2001 From: oc Date: Mon, 3 Jun 2019 01:10:07 +0800 Subject: [PATCH 37/46] expand / fold materials --- _server/css/editor.css | 7 ++ _server/css/editor_mobile.css | 9 ++- _server/editor.js | 127 +++++++++++++++++----------------- _server/editor_unsorted_1.js | 40 ++++++++--- editor-mobile.html | 1 + editor.html | 1 + libs/utils.js | 7 +- 7 files changed, 116 insertions(+), 76 deletions(-) diff --git a/_server/css/editor.css b/_server/css/editor.css index e053cafd..df5e2670 100644 --- a/_server/css/editor.css +++ b/_server/css/editor.css @@ -287,6 +287,13 @@ body { 0 0 0 3px #000; } +#iconExpandBtn { + position: absolute; + left: 10px; + bottom: 30px; + display: none; +} + .warnText { color: #D50000; font-weight: 700; diff --git a/_server/css/editor_mobile.css b/_server/css/editor_mobile.css index ef6d2f72..4a46198b 100644 --- a/_server/css/editor_mobile.css +++ b/_server/css/editor_mobile.css @@ -272,6 +272,13 @@ body { 0 0 0 3px #000; } +#iconExpandBtn { + position: absolute; + left: 10px; + bottom: 30px; + display: none; +} + .warnText { color: #D50000; font-weight: 700; @@ -433,7 +440,7 @@ div.row .rowtd .rowtext{ font: normal 2.5vw Arial, sans-serif; list-style: none; margin: 0; - padding: 4px 7em 4px 28px; + padding: 4px 7em 4px 4px; white-space: nowrap; /* padding-left: 12px; */ diff --git a/_server/editor.js b/_server/editor.js index b8c770e4..24401e84 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -267,7 +267,7 @@ editor.prototype.setViewport=function (x, y) { } editor.prototype.moveViewport=function(x,y){ - this.setViewport(core.bigmap.offsetX+32*x, core.bigmap.offsetY+32*y); + editor.setViewport(core.bigmap.offsetX+32*x, core.bigmap.offsetY+32*y); } /////////// 界面交互相关 /////////// @@ -278,6 +278,9 @@ editor.prototype.drawInitData = function (icons) { var maxHeight = 700; var sumWidth = 0; editor.widthsX = {}; + editor.folded = core.getLocalStorage('folded', false); + // editor.folded = true; + editor.foldPerCol = 30; // var imgNames = Object.keys(images); //还是固定顺序吧; var imgNames = ["terrains", "animates", "enemys", "enemy48", "items", "npcs", "npc48", "autotile"]; @@ -288,20 +291,21 @@ editor.prototype.drawInitData = function (icons) { for (var im in autotiles) { tempy += autotiles[im].height; } - editor.widthsX[img] = [img, sumWidth / 32, (sumWidth + 3 * 32) / 32, tempy]; - sumWidth += 3 * 32; + var tempx = editor.folded ? 32 : 3 * 32; + editor.widthsX[img] = [img, sumWidth / 32, (sumWidth + tempx) / 32, tempy]; + sumWidth += tempx; maxHeight = Math.max(maxHeight, tempy); continue; } - if (img == 'terrains') { - editor.widthsX[img] = [img, sumWidth / 32, (sumWidth + images[img].width) / 32, images[img].height + 32*2] - sumWidth += images[img].width; - maxHeight = Math.max(maxHeight, images[img].height + 32*2); - continue; + var width = images[img].width, height = images[img].height, mh = height; + if (editor.folded) { + var per_height = (img == 'enemy48' || img == 'npc48' ? 48 : 32); + width = Math.ceil(height / per_height / editor.foldPerCol) * 32; + if (width > 32) mh = per_height * editor.foldPerCol; } - editor.widthsX[img] = [img, sumWidth / 32, (sumWidth + images[img].width) / 32, images[img].height]; - sumWidth += images[img].width; - maxHeight = Math.max(maxHeight, images[img].height); + editor.widthsX[img] = [img, sumWidth / 32, (sumWidth + width) / 32, height]; + sumWidth += width; + maxHeight = Math.max(maxHeight, mh + 64); } var tilesets = images.tilesets; for (var ii in core.tilesets) { @@ -318,82 +322,75 @@ editor.prototype.drawInitData = function (icons) { if (fullWidth > edata.width) edata.style.width = (edata.width = fullWidth) / ratio + 'px'; edata.style.height = (edata.height = fullHeight) / ratio + 'px'; */ + var iconImages = document.getElementById('iconImages'); iconImages.style.width = (iconImages.width = fullWidth) / ratio + 'px'; iconImages.style.height = (iconImages.height = fullHeight) / ratio + 'px'; - var dc = {drawImage:function(){ - var image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight; - var a=Array.prototype.slice.call(arguments) - if(arguments.length==3){ - // [image, dx, dy]=arguments - // [sx, sy, sWidth, sHeight, dWidth, dHeight]=[0,0,image.width,image.height,image.width,image.height] - image=a[0] - a=[a[0],0,0,image.width,image.height,a[1],a[2],image.width,image.height] - } - if(arguments.length==5){ - // [image, dx, dy, dWidth, dHeight]=arguments - // [sx, sy, sWidth, sHeight]=[0,0,image.width,image.height] - image=a[0] - a=[a[0],0,0,image.width,image.height,a[1],a[2],a[3],a[4]] - } - if(arguments.length==9){ - // [image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight]=arguments - } - image=a[0]; - sx=a[1]; - sy=a[2]; - sWidth=a[3]; - sHeight=a[4]; - dx=a[5]; - dy=a[6]; - dWidth=a[7]; - dHeight=a[8]; - //放弃对 dWidth, dHeight 的支持, 始终画一样大的 - var dimg=new Image() - dimg.src = image.src; - dimg.style.clip=['rect(',sy,'px,',sx+sWidth,'px,',sy+sHeight,'px,',sx,'px)'].join('') - dimg.style.top=dy-sy+'px' - dimg.style.left=dx-sx+'px' - dimg.width=image.width/ratio - dimg.height=image.height/ratio - iconImages.appendChild(dimg) - }} - // var dc = edata.getContext('2d'); - var nowx = 0; - var nowy = 0; + var drawImage = function (image, x, y) { + image.style.left = x + 'px'; + image.style.top = y + 'px'; + iconImages.appendChild(image); + } + + var nowx = 0, nowy = 0; for (var ii = 0; ii < imgNames.length; ii++) { var img = imgNames[ii]; if (img == 'terrains') { - (function(image,dc,nowx){ + (function(image,nowx){ if (image.complete) { - dc.drawImage(image, nowx, 32); + drawImage(image, nowx, 32); core.material.images.airwall = image; delete(editor.airwallImg); } else image.onload = function () { - dc.drawImage(image, nowx, 32); + drawImage(image, nowx, 32); core.material.images.airwall = image; delete(editor.airwallImg); editor.updateMap(); } - })(editor.airwallImg,dc,nowx); - dc.drawImage(images[img], nowx, 32*2); - nowx += images[img].width; + })(editor.airwallImg,nowx); + if (editor.folded) { + // --- 单列 & 折行 + var subimgs = core.splitImage(images[img], 32, editor.foldPerCol * 32); + var frames = images[img].width / 32; + for (var i = 0; i < subimgs.length; i+=frames) { + drawImage(subimgs[i], nowx, i==0?2*32:0); + nowx += 32; + } + } + else { + drawImage(images[img], nowx, 32*2); + nowx += images[img].width; + } continue; } if (img == 'autotile') { var autotiles = images[img]; + var tempx = editor.folded ? 32 : 96; for (var im in autotiles) { - dc.drawImage(autotiles[im], 0, 0, 96, 128, nowx, nowy, 96, 128); + var subimgs = core.splitImage(autotiles[im], tempx, autotiles[im].height); + drawImage(subimgs[0], nowx, nowy); nowy += autotiles[im].height; } - nowx += 3 * 32; + nowx += tempx; continue; } - dc.drawImage(images[img], nowx, 0) - nowx += images[img].width; + if (editor.folded) { + // --- 单列 & 折行 + var per_height = img.endsWith('48') ? 48 : 32; + var subimgs = core.splitImage(images[img], 32, editor.foldPerCol * per_height); + var frames = images[img].width / 32; + for (var i = 0; i < subimgs.length; i+=frames) { + drawImage(subimgs[i], nowx, 0); + nowx += 32; + } + } + else { + drawImage(images[img], nowx, 0); + nowx += images[img].width; + } } for (var ii in core.tilesets) { var img = core.tilesets[ii]; - dc.drawImage(tilesets[img], nowx, 0) + drawImage(tilesets[img], nowx, 0); nowx += tilesets[img].width; } //editor.mapInit(); @@ -467,8 +464,12 @@ editor.prototype.setSelectBoxFromInfo=function(thisevent){ pos.x=editor.widthsX[thisevent.images][1]; pos.y=thisevent.y; if(thisevent.x)pos.x+=thisevent.x; - if(thisevent.images=='terrains')pos.y+=2; ysize = thisevent.images.endsWith('48') ? 48 : 32; + if (editor.folded) { + pos.x += Math.floor(pos.y / editor.foldPerCol); + pos.y %= editor.foldPerCol; + } + if(pos.x == 0) pos.y+=2; } var dataSelection = document.getElementById('dataSelection'); dataSelection.style.left = pos.x * 32 + 'px'; diff --git a/_server/editor_unsorted_1.js b/_server/editor_unsorted_1.js index 6eec656c..b31510d6 100644 --- a/_server/editor_unsorted_1.js +++ b/_server/editor_unsorted_1.js @@ -444,11 +444,22 @@ editor.constructor.prototype.listen=function () { } var scrollBarHeight = getScrollBarHeight(); + var iconExpandBtn = document.getElementById('iconExpandBtn'); + iconExpandBtn.style.display = 'block'; + iconExpandBtn.innerText = editor.folded ? "展开" : "折叠"; + iconExpandBtn.onclick = function () { + if (confirm(editor.folded ? "你想要展开素材吗?\n展开模式下将显示全素材内容。" + : ("你想要折叠素材吗?\n折叠模式下每个素材将仅显示单列,并且每"+editor.foldPerCol+"个自动换列。"))) { + core.setLocalStorage('folded', !editor.folded); + window.location.reload(); + } + } + var dataSelection = document.getElementById('dataSelection'); var iconLib=document.getElementById('iconLib'); iconLib.onmousedown = function (e) { e.stopPropagation(); - if (!editor.isMobile && e.clientY>=((core.__SIZE__==13?630:655) - scrollBarHeight)) return; + if (!editor.isMobile && e.clientY>=iconLib.offsetHeight - scrollBarHeight) return; var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft; var scrollTop = document.documentElement.scrollTop || document.body.scrollTop; var loc = { @@ -460,11 +471,11 @@ editor.constructor.prototype.listen=function () { var pos = locToPos(loc); for (var spriter in editor.widthsX) { if (pos.x >= editor.widthsX[spriter][1] && pos.x < editor.widthsX[spriter][2]) { - var ysize = spriter.indexOf('48') === -1 ? 32 : 48; + var ysize = spriter.endsWith('48') ? 48 : 32; loc.ysize = ysize; pos.images = editor.widthsX[spriter][0]; pos.y = ~~(loc.y / loc.ysize); - if(core.tilesets.indexOf(pos.images)==-1)pos.x = editor.widthsX[spriter][1]; + if(!editor.folded && core.tilesets.indexOf(pos.images)==-1) pos.x = editor.widthsX[spriter][1]; var autotiles = core.material.images['autotile']; if (pos.images == 'autotile') { var imNames = Object.keys(autotiles); @@ -478,8 +489,15 @@ editor.constructor.prototype.listen=function () { } } } - } else if ((pos.y + 1) * ysize > editor.widthsX[spriter][3]) - pos.y = ~~(editor.widthsX[spriter][3] / ysize) - 1; + } + else { + var height = editor.widthsX[spriter][3], col = height / ysize; + if (editor.folded) { + col = (pos.x == editor.widthsX[spriter][2] - 1) ? ((col - 1) % editor.foldPerCol + 1) : editor.foldPerCol; + } + if (spriter == 'terrains' && pos.x == editor.widthsX[spriter][1]) col += 2; + pos.y = Math.min(pos.y, col - 1); + } selectBox.isSelected(true); // console.log(pos,core.material.images[pos.images].height) @@ -493,10 +511,16 @@ editor.constructor.prototype.listen=function () { } else if(pos.x == 0 && pos.y == 1){ editor.info = editor.ids[editor.indexs[17]]; } else { - if (Object.prototype.hasOwnProperty.call(autotiles, pos.images)) editor.info = {'images': pos.images, 'y': 0}; - else if (pos.images == 'terrains') editor.info = {'images': pos.images, 'y': pos.y - 2}; + if (autotiles[pos.images]) editor.info = {'images': pos.images, 'y': 0}; else if (core.tilesets.indexOf(pos.images)!=-1) editor.info = {'images': pos.images, 'y': pos.y, 'x': pos.x-editor.widthsX[spriter][1]}; - else editor.info = {'images': pos.images, 'y': pos.y}; + else { + var y = pos.y; + if (editor.folded) { + y += editor.foldPerCol * (pos.x-editor.widthsX[spriter][1]); + } + if (pos.images == 'terrains' && pos.x == 0) y -= 2; + editor.info = {'images': pos.images, 'y': y} + } for (var ii = 0; ii < editor.ids.length; ii++) { if ((core.tilesets.indexOf(pos.images)!=-1 && editor.info.images == editor.ids[ii].images diff --git a/editor-mobile.html b/editor-mobile.html index d76491b1..e12accb8 100644 --- a/editor-mobile.html +++ b/editor-mobile.html @@ -308,6 +308,7 @@ +
diff --git a/editor.html b/editor.html index 0a0f0d96..7ffc7df3 100644 --- a/editor.html +++ b/editor.html @@ -352,6 +352,7 @@
+ diff --git a/editor.html b/editor.html index 7ffc7df3..43200cfe 100644 --- a/editor.html +++ b/editor.html @@ -293,7 +293,7 @@ - +
From f2796b1bd03158948ca5926ea61c1720953b91f5 Mon Sep 17 00:00:00 2001 From: oc Date: Tue, 4 Jun 2019 01:56:20 +0800 Subject: [PATCH 44/46] move, copy, cut and paste blocks --- _server/editor_unsorted_1.js | 12 +++++++++--- _server/editor_unsorted_3.js | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/_server/editor_unsorted_1.js b/_server/editor_unsorted_1.js index 31381e02..d0623f6f 100644 --- a/_server/editor_unsorted_1.js +++ b/_server/editor_unsorted_1.js @@ -403,19 +403,19 @@ editor.constructor.prototype.listen=function () { return; } // Ctrl+C, Ctrl+X, Ctrl+V - if (e.ctrlKey && e.keyCode == 67) { + if (e.ctrlKey && e.keyCode == 67 && !selectBox.isSelected()) { copyedInfo = editor.copyFromPos(); printf('该点事件已复制'); return; } - if (e.ctrlKey && e.keyCode == 88) { + if (e.ctrlKey && e.keyCode == 88 && !selectBox.isSelected()) { copyedInfo = editor.copyFromPos(); editor.clearPos(true, null, function () { printf('该点事件已剪切'); }) return; } - if (e.keyCode == 86) { + if (e.ctrlKey && e.keyCode == 86 && !selectBox.isSelected()) { if (!copyedInfo) { printe("没有复制的事件"); return; @@ -432,6 +432,12 @@ editor.constructor.prototype.listen=function () { }); return; } + // DELETE + if (e.keyCode == 46 && !selectBox.isSelected()) { + editor.clearPos(true); + return; + } + // ESC if (e.keyCode == 27) { if (selectBox.isSelected()) { editor_mode.onmode(''); diff --git a/_server/editor_unsorted_3.js b/_server/editor_unsorted_3.js index 11e40ea2..fd6ec89e 100644 --- a/_server/editor_unsorted_3.js +++ b/_server/editor_unsorted_3.js @@ -215,7 +215,7 @@ tip.showHelp = function(value) { 'ESC或点击空白处可以自动保存当前修改', 'H键可以打开操作帮助哦', 'tileset贴图模式下可以按选中tileset素材,并在地图上拖动来一次绘制一个区域', - '可以拖动地图上的图块和事件,或按Ctrl+C, Ctrl+X和Ctrl+V进行复制,剪切和粘贴' + '可以拖动地图上的图块和事件,或按Ctrl+C, Ctrl+X和Ctrl+V进行复制,剪切和粘贴,Delete删除' ]; if (value == null) value = Math.floor(Math.random() * tips.length); printf('tips: ' + tips[value]) From d0b8c2088f0ccb7948dfcc0636f40225e2df4cb2 Mon Sep 17 00:00:00 2001 From: oc Date: Tue, 4 Jun 2019 02:04:23 +0800 Subject: [PATCH 45/46] ctrl+C/X/V --- _server/editor_unsorted_1.js | 91 +++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 44 deletions(-) diff --git a/_server/editor_unsorted_1.js b/_server/editor_unsorted_1.js index d0623f6f..ef27a102 100644 --- a/_server/editor_unsorted_1.js +++ b/_server/editor_unsorted_1.js @@ -349,7 +349,7 @@ editor.constructor.prototype.listen=function () { return; // 禁止快捷键的默认行为 - if (e.ctrlKey && [88, 67, 86, 89, 90, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57].indexOf(e.keyCode) !== -1) + if (e.ctrlKey && [89, 90, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57].indexOf(e.keyCode) !== -1) e.preventDefault(); if (e.altKey && [48, 49, 50, 51, 52, 53, 54, 55, 56, 57].indexOf(e.keyCode) !== -1) e.preventDefault(); @@ -402,59 +402,62 @@ editor.constructor.prototype.listen=function () { core.setLocalStorage('shortcut',shortcut); return; } - // Ctrl+C, Ctrl+X, Ctrl+V - if (e.ctrlKey && e.keyCode == 67 && !selectBox.isSelected()) { - copyedInfo = editor.copyFromPos(); - printf('该点事件已复制'); - return; - } - if (e.ctrlKey && e.keyCode == 88 && !selectBox.isSelected()) { - copyedInfo = editor.copyFromPos(); - editor.clearPos(true, null, function () { - printf('该点事件已剪切'); - }) - return; - } - if (e.ctrlKey && e.keyCode == 86 && !selectBox.isSelected()) { - if (!copyedInfo) { - printe("没有复制的事件"); + var focusElement = document.activeElement; + if (!focusElement || focusElement.tagName.toLowerCase()=='body') { + // Ctrl+C, Ctrl+X, Ctrl+V + if (e.ctrlKey && e.keyCode == 67 && !selectBox.isSelected()) { + e.preventDefault(); + copyedInfo = editor.copyFromPos(); + printf('该点事件已复制'); return; } - editor.pasteToPos(copyedInfo); - editor.updateMap(); - editor.file.saveFloorFile(function (err) { - if (err) { - printe(err); - throw(err) + if (e.ctrlKey && e.keyCode == 88 && !selectBox.isSelected()) { + e.preventDefault(); + copyedInfo = editor.copyFromPos(); + editor.clearPos(true, null, function () { + printf('该点事件已剪切'); + }) + return; + } + if (e.ctrlKey && e.keyCode == 86 && !selectBox.isSelected()) { + e.preventDefault(); + if (!copyedInfo) { + printe("没有复制的事件"); + return; } - ;printf('粘贴事件成功'); - editor.drawPosSelection(); - }); - return; - } - // DELETE - if (e.keyCode == 46 && !selectBox.isSelected()) { - editor.clearPos(true); - return; - } - // ESC - if (e.keyCode == 27) { - if (selectBox.isSelected()) { - editor_mode.onmode(''); + editor.pasteToPos(copyedInfo); + editor.updateMap(); editor.file.saveFloorFile(function (err) { if (err) { printe(err); throw(err) } - ;printf('地图保存成功'); + ;printf('粘贴事件成功'); + editor.drawPosSelection(); }); + return; + } + // DELETE + if (e.keyCode == 46 && !selectBox.isSelected()) { + editor.clearPos(true); + return; + } + // ESC + if (e.keyCode == 27) { + if (selectBox.isSelected()) { + editor_mode.onmode(''); + editor.file.saveFloorFile(function (err) { + if (err) { + printe(err); + throw(err) + } + ;printf('地图保存成功'); + }); + } + selectBox.isSelected(false); + editor.info = {}; + return; } - selectBox.isSelected(false); - editor.info = {}; - return; - } - var focusElement = document.activeElement; - if (!focusElement || focusElement.tagName.toLowerCase()=='body') { switch (e.keyCode) { // WASD case 87: editor.moveViewport(0,-1); break; From b0c580ad99ab295f28cd04c5fd199a566f6c41e1 Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Tue, 4 Jun 2019 12:54:21 +0800 Subject: [PATCH 46/46] update refactoring.md --- _server/refactoring.md | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/_server/refactoring.md b/_server/refactoring.md index 8ea8c365..168d1e6f 100644 --- a/_server/refactoring.md +++ b/_server/refactoring.md @@ -16,12 +16,19 @@ editor_file之后是更改editor.map的储存方式, 现有的存对象的模式 ## 文件结构 +(全部小写,必要时用下划线分割) + + [ ] editor_blockly 图块化事件编辑器 + [ ] editor_multi 多行文本编辑器 + [x] editor_table 处理表格的生成, 及其响应的事件, 从原editor\_mode中分离 + [ ] editor_file 调用fs.js编辑文件, 把原editor\_file模块化, 并且只负责文件写入 + [ ] editor_game 处理游戏数据, 导入为editor的数据, 编辑数据, 从原editor和editor_file中抽离. **只有此文件允许`\s(main|core)`形式的调用**(以及其初始化`editor_game_wrapper(editor, main, core);`) + [x] editor_util 生成guid/处理颜色 等函数, 从editor分离 ++ [ ] editor_action 处理界面上的按钮/下拉框点击等用户的操作与功能函数的绑定, 维护editor.dom, unsorted_1/2中的绑定挪到此处, 其中的函数内容, 分类放在其他文件 ++ [ ] editor_mappanel 与地图面板相关的功能, <-unsorted_1/2/3 ++ [ ] editor_datapanel 与数据面板相关的功能, <-unsorted_1/2/3 ++ [ ] editor_materialpanel 与素材面板相关的功能, <-unsorted_1/2/3 ++ [ ] editor_ui 维护printe/printf/tip, 以及之后可能的窗口化 + [ ] editor 执行初始化流程加组合各组件 + [ ] 原editor_mode 移除 + [x] 原vm 移除 @@ -72,9 +79,11 @@ editor: { + editor.widthX特别不直观 ++ ? 编辑器使用可拖拽和调大小的窗口做容器 + ## 功能改进 -+ [ ] 大地图 ++ [x] 大地图 在切换时, 每次都回到最左上->每个楼层记录一个位置 四个箭头支持长按 ? 滚动条 @@ -87,12 +96,12 @@ editor: { + [ ] ? 简洁的事件方块注册 `editor.registerEvent('log',[['test','Int','测试',0],['floorId','Idstring','楼层','MT0']])` -+ [ ] 一个显示所有快捷键的文本 ++ [x] 一个显示所有快捷键的文本 -+ [ ] 更多快捷键 ++ [x] 更多快捷键 【全塔属性】、【楼层属性】等常用的编辑栏切换 -+ [ ] ? 地图编辑优化 ++ [x] ? 地图编辑优化 常用的地图编辑快捷键/命令:复制ctrl+c、粘贴ctrl+v、(复制可绑定为现在的“选中xx位置事件” 粘贴为复制xx事件到此处),撤回ctrl+z、取消撤回ctrl+y 可以按住拖动图块与事件。 @@ -103,18 +112,20 @@ editor: { + [x] 修改系统的触发器(下拉菜单增加新项) 在编辑器修改`comment.js`:现场发readFile请求读文件,然后开脚本编辑器进行编辑 -+ [ ] ? 删除注册项/修改图块ID ++ [x] ? 删除注册项/修改图块ID + [ ] ? 怪物和道具也能像其他类型那样查看“图块信息”(而不只是具体的怪物属性) -+ [ ] 素材区自动换列 ++ [x] 素材区自动换列 怪物或道具太多时, 按照每100个进行拆分新开列来显示 -+ [ ] 多帧素材只显示第一帧 ++ [x] 多帧素材只显示第一帧 -+ [ ] `显示文章`以及`选项`等方块, 把`标题`和`图像`从字符串提取出填回相应的空 ++ [x] `显示文章`以及`选项`等方块, 把`标题`和`图像`从字符串提取出填回相应的空 -+ [ ] blockly中某些需要选点的填空, 增加按钮, 点击后从缩略图中点击位置 ++ [x] blockly中某些需要选点的填空, 增加按钮, 点击后从缩略图中点击位置 + ++ [ ] 插件编写增加判定,如果保存时框内不是以 "function\s*()" 开头(也就是用户直接写的脚本),则自动添加一个 function() { } 将代码包装起来。 ## 左侧页面模式