From 6f450592f010fd00d234ee063e5642dff8136e2a Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Sun, 10 May 2020 23:28:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=BC=BA=E8=87=AA=E5=8A=A8=E8=A1=A5?= =?UTF-8?q?=E5=85=A8=E5=8A=9F=E8=83=BD;=E5=90=88=E5=B9=B6=E9=83=A8?= =?UTF-8?q?=E5=88=86=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/MotaAction.g4 | 78 ++++++++++++--------------------------- _server/editor_blockly.js | 77 ++++++++++++++++++++++++++++++-------- _server/editor_ui.js | 6 ++- libs/icons.js | 9 +++++ libs/utils.js | 2 +- v2.x-final更新.txt | 8 ++-- 6 files changed, 103 insertions(+), 77 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index ff7e86d7..86cfd54e 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -362,8 +362,7 @@ action | openDoor_s | closeDoor_s | changeFloor_s - | changePos_0_s - | changePos_1_s + | changePos_s | setViewport_s | moveViewport_s | useItem_s @@ -380,8 +379,7 @@ action | hideImage_s | showTextImage_s | moveImage_s - | showGif_0_s - | showGif_1_s + | showGif_s | setCurtain_0_s | setCurtain_1_s | screenFlash_s @@ -1175,30 +1173,18 @@ var code = '{"type": "changeFloor", "floorId": "'+IdString_0+'"'+floorstr+Direct return code; */; -changePos_0_s - : '位置切换' 'x' PosString ',' 'y' PosString '朝向' DirectionEx_List Newline +changePos_s + : '位置朝向切换' 'x' PosString? ',' 'y' PosString? '朝向' DirectionEx_List Newline -/* changePos_0_s +/* changePos_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 -default : ["0","0",null] +default : ["","",null] colour : this.dataColor +var loc = (PosString_0 && PosString_1) ? (', "loc": ['+PosString_0+','+PosString_1+']') : ''; DirectionEx_List_0 = DirectionEx_List_0 && (', "direction": "'+DirectionEx_List_0+'"'); -var code = '{"type": "changePos", "loc": ['+PosString_0+','+PosString_1+']'+DirectionEx_List_0+'},\n'; -return code; -*/; - -changePos_1_s - : '勇士转向' Direction_List Newline - - -/* 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 -colour : this.dataColor -default : [null] -var code = '{"type": "changePos", "direction": "'+Direction_List_0+'"},\n'; +var code = '{"type": "changePos"'+loc+DirectionEx_List_0+'},\n'; return code; */; @@ -1434,28 +1420,18 @@ var code = '{"type": "hideImage", "code": '+Int_0+', "time": '+Int_1+async+'},\n return code; */; -showGif_0_s - : '显示动图' EvalString '起点像素位置' 'x' PosString 'y' PosString Newline +showGif_s + : '显示动图' EvalString? '起点像素位置' 'x' PosString? 'y' PosString? Newline -/* showGif_0_s +/* showGif_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 -default : ["bg.gif","0","0"] +default : ["","",""] colour : this.printColor -var code = '{"type": "showGif", "name": "'+EvalString_0+'", "loc": ['+PosString_0+','+PosString_1+']},\n'; -return code; -*/; - -showGif_1_s - : '清除所有动图' Newline - - -/* 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 -colour : this.printColor -var code = '{"type": "showGif"},\n'; +EvalString_0 = EvalString_0 ? (', "name": "'+EvalString_0+'"') : ''; +var loc = (PosString_0 && PosString_1) ? (', "loc": ['+PosString_0+','+PosString_1+']') : ''; +var code = '{"type": "showGif"'+EvalString_0+loc+'},\n'; return code; */; @@ -2579,7 +2555,7 @@ idString_3_e colour : this.idstring_eColor default : ['greenSlime',"攻击"] //todo 将其output改成'idString_e' -var code = 'enemy:'+IdString_0+'.'+EnemyId_List_0; +var code = 'enemy:'+IdString_0+':'+EnemyId_List_0; return [code, Blockly.JavaScript.ORDER_ATOMIC]; */; @@ -3180,13 +3156,9 @@ ActionParser.prototype.parseAction = function() { data.floorId,data.loc[0],data.loc[1],data.direction,data.time,this.next]); break; case "changePos": // 直接更换勇士位置, 不切换楼层 - if(this.isset(data.loc)){ - this.next = MotaActionBlocks['changePos_0_s'].xmlText([ - data.loc[0],data.loc[1],data.direction,this.next]); - } else { - this.next = MotaActionBlocks['changePos_1_s'].xmlText([ - data.direction,this.next]); - } + data.loc=data.loc||['',''] + this.next = MotaActionBlocks['changePos_s'].xmlText([ + data.loc[0],data.loc[1],data.direction,this.next]); break; case "follow": // 跟随勇士 this.next = MotaActionBlocks['follow_s'].xmlText([data.name||"", this.next]); @@ -3240,14 +3212,10 @@ ActionParser.prototype.parseAction = function() { data.code, data.to[0], data.to[1], data.opacity, data.time||0, data.async||false, this.next]); break; case "showGif": // 显示动图 - if(this.isset(data.name)){ - this.next = MotaActionBlocks['showGif_0_s'].xmlText([ - data.name,data.loc[0],data.loc[1],this.next]); - } else { - this.next = MotaActionBlocks['showGif_1_s'].xmlText([ - this.next]); - } - break; + data.loc=data.loc||['',''] + this.next = MotaActionBlocks['showGif_s'].xmlText([ + data.name,data.loc[0],data.loc[1],this.next]); + break; case "setCurtain": // 颜色渐变 if(this.isset(data.color)){ data.color = this.Colour(data.color); diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 3bd99924..111e96f4 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -83,8 +83,7 @@ editor_blockly = function () { MotaActionBlocks['hideImage_s'].xmlText(), MotaActionBlocks['showTextImage_s'].xmlText(), MotaActionBlocks['moveImage_s'].xmlText(), - MotaActionBlocks['showGif_0_s'].xmlText(), - MotaActionBlocks['showGif_1_s'].xmlText(), + MotaActionBlocks['showGif_s'].xmlText(), MotaActionBlocks['tip_s'].xmlText(), MotaActionBlocks['win_s'].xmlText(), MotaActionBlocks['lose_s'].xmlText(), @@ -111,8 +110,7 @@ editor_blockly = function () { MotaActionBlocks['moveHero_s'].xmlText(), MotaActionBlocks['jumpHero_s'].xmlText(), MotaActionBlocks['changeFloor_s'].xmlText(), - MotaActionBlocks['changePos_0_s'].xmlText(), - MotaActionBlocks['changePos_1_s'].xmlText(), + MotaActionBlocks['changePos_s'].xmlText(), MotaActionBlocks['battle_s'].xmlText(), MotaActionBlocks['useItem_s'].xmlText(), MotaActionBlocks['loadEquip_s'].xmlText(), @@ -829,7 +827,7 @@ function omitedcheckUpdateFunction(event) { "changeFloor_m": ["Number_0", "Number_1", "IdString_0", true], "jumpHero_s": ["PosString_0", "PosString_1"], "changeFloor_s": ["PosString_0", "PosString_1", "IdString_0", true], - "changePos_0_s": ["PosString_0", "PosString_1"], + "changePos_s": ["PosString_0", "PosString_1"], "battle_1_s": ["PosString_0", "PosString_1"], "openDoor_s": ["PosString_0", "PosString_1", "IdString_0"], "closeDoor_s": ["PosString_0", "PosString_1"], @@ -883,7 +881,7 @@ function omitedcheckUpdateFunction(event) { }); } - editor_blockly.getAutoCompletions = function (content) { + editor_blockly.getAutoCompletions = function (content, type, name) { // --- content为当前框中输入内容;将返回一个列表,为后续所有可补全内容 // 检查 status:xxx,item:xxx和flag:xxx @@ -977,6 +975,61 @@ function omitedcheckUpdateFunction(event) { }).sort(); } + // 对任意图块提供补全 + if ((type == 'text_1_s' && name == 'EvalString_1') || (type == 'autoText_s' && name == 'EvalString_1') + || (type == 'choices_s' && name == 'IdString_0') || (type == 'choicesContext' && name == 'IdString_0') + || (type == 'closeDoor_s' && name == 'IdString_0') || (type == 'setBlock_s' && name == 'EvalString_0') + || (type == 'setBgFgBlock_s' && name == 'EvalString_0') || (type == 'drawIcon_s' && name == 'IdString_0') + ) { + return core.getAllIconIds().filter(function (one) { + return one != content && one.startsWith(content); + }).sort(); + } + + // 对怪物ID提供补全 + if ((type == 'idString_3_e' || type == 'battle_s' || type == 'setEnemy_s') && name == 'IdString_0') { + return Object.keys(core.material.enemys).filter(function (one) { + return one != content && one.startsWith(content); + }).sort(); + } + + // 对道具ID进行补全 + if ((type == 'useItem_s' || type == 'loadEquip_s') && name == 'IdString_0') { + return Object.keys(core.material.items).filter(function (one) { + return one != content && one.startsWith(content); + }).sort(); + } + + // 对图片名进行补全 + if ((type == 'showImage_s' || type == 'showImage_1_s' || type == 'showGif_s' || type == 'setHeroIcon_s' + || type == 'follow_s' || type == 'unfollow_s' || type == 'drawImage_s' || type == 'drawImage_1_s') && name == 'EvalString_0') { + return Object.keys(core.material.images.images).filter(function (one) { + return one != content && one.startsWith(content); + }).sort(); + } + + // 对动画进行补全 + if (type == 'animate_s' && name == 'IdString_0') { + return Object.keys(core.material.animates).filter(function (one) { + return one != content && one.startsWith(content); + }).sort(); + } + + // 对音乐进行补全 + if ((type == 'playBgm_s' || type == 'loadBgm_s' || type == 'freeBgm_s') && name == 'EvalString_0') { + return Object.keys(core.material.bgms).filter(function (one) { + return one != content && one.startsWith(content); + }).sort(); + } + + // 对音效进行补全 + if (type == 'playSound_s' && name == 'EvalString_0') { + return Object.keys(core.material.sounds).filter(function (one) { + return one != content && one.startsWith(content); + }).sort(); + } + + return []; } @@ -1079,7 +1132,7 @@ Blockly.FieldTextInput.prototype.showInlineEditor_ = function(quietInput) { // --- awesomplete var awesomplete = new Awesomplete(htmlInput, { - minChars: pb.type == "idString_3_e" ? 1 : 2, + minChars: 1, maxItems: 12, autoFirst: true, replace: function (text) { @@ -1124,7 +1177,7 @@ Blockly.FieldTextInput.prototype.showInlineEditor_ = function(quietInput) { if (index == null) index = value.length; value = value.substring(0, index); // cal prefix - awesomplete.prefix = ""; + awesomplete.prefix = value; for (var i = index - 1; i>=0; i--) { var c = value.charAt(i); if (!/^[a-zA-Z0-9_\u4E00-\u9FCC]$/.test(c)) { @@ -1133,13 +1186,7 @@ Blockly.FieldTextInput.prototype.showInlineEditor_ = function(quietInput) { } } - var list = editor_blockly.getAutoCompletions(value); - if (pb.type == "idString_3_e") { - list = list.concat(Object.keys(core.material.enemys).filter(function (one) { - return one != value && one.startsWith(value); - })); - list.sort(); - } + var list = editor_blockly.getAutoCompletions(value, pb.type, self.name); awesomplete.list = list; awesomplete.ul.style.marginLeft = getCaretCoordinates(htmlInput, htmlInput.selectionStart).left - diff --git a/_server/editor_ui.js b/_server/editor_ui.js index d2764df8..9e5d3256 100644 --- a/_server/editor_ui.js +++ b/_server/editor_ui.js @@ -545,7 +545,8 @@ editor_ui_wrapper = function (editor) { uievent.elements.selectPoint.style.display = 'block'; uievent.elements.yes.style.display = 'inline'; uievent.elements.selectBackground.style.display = 'none'; - uievent.elements.selectFloor.style.display = hideFloor ? 'none' : 'inline'; + // uievent.elements.selectFloor.style.display = hideFloor ? 'none' : 'inline'; + uievent.elements.selectFloor.style.display = 'inline'; uievent.elements.selectPointBox.style.display = 'block'; uievent.elements.canvas.style.display = 'block'; uievent.elements.usedFlags.style.display = 'none'; @@ -646,7 +647,8 @@ editor_ui_wrapper = function (editor) { })(); uievent.elements.div.onmousewheel = function (e) { - if (uievent.mode != 'selectPoint' || uievent.values.hideFloor) return; + // if (uievent.mode != 'selectPoint' || uievent.values.hideFloor) return; + if (uievent.mode != 'selectPoint') return; var index = core.floorIds.indexOf(uievent.values.floorId); try { if (e.wheelDelta) diff --git a/libs/icons.js b/libs/icons.js index 45051561..a21780f3 100644 --- a/libs/icons.js +++ b/libs/icons.js @@ -27,6 +27,15 @@ icons.prototype.getClsFromId = function (id) { return null; } +icons.prototype.getAllIconIds = function () { + if (this.allIconIds) return this.allIconIds; + this.allIconIds = []; + for (var type in this.icons) { + this.allIconIds = this.allIconIds.concat(Object.keys(this.icons[type])); + } + return this.allIconIds; +} + icons.prototype._getAnimateFrames = function (cls, useOriginValue) { if (cls == 'enemys' || cls == 'npcs') { return 2; diff --git a/libs/utils.js b/libs/utils.js index 7a97243f..ba920a20 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -82,7 +82,7 @@ utils.prototype.replaceValue = function (value) { if (value.indexOf('global:') >= 0) value = value.replace(/global:([a-zA-Z0-9_\u4E00-\u9FCC]+)/g, "core.getGlobal('$1', 0)"); if (value.indexOf('enemy:')>=0) - value = value.replace(/enemy:([a-zA-Z0-9_]+)\.([a-zA-Z0-9_]+)/g, "core.material.enemys['$1'].$2"); + value = value.replace(/enemy:([a-zA-Z0-9_]+)[\.:]([a-zA-Z0-9_]+)/g, "core.material.enemys['$1'].$2"); if (value.indexOf('blockId:')>=0) value = value.replace(/blockId:(\d+),(\d+)/g, "core.getBlockId($1, $2)"); if (value.indexOf('blockCls:')>=0) diff --git a/v2.x-final更新.txt b/v2.x-final更新.txt index 337fc4d2..16110daa 100644 --- a/v2.x-final更新.txt +++ b/v2.x-final更新.txt @@ -27,7 +27,7 @@ (已完成!) cannotIn / cannotOut使用选项框 (已完成!) noPass->canPass改成选择框 初始化&读档优化:不一次读取全部楼层并创建 -绿钥匙进状态栏 +(已完成!) 绿钥匙进状态栏 (已完成!) 图块ID不可全数字 怪物详细信息富文本化 (已完成!) for和forEach事件 @@ -36,8 +36,8 @@ (已完成!) 合并数值操作事件 (已完成!) fromLoad,聚集问题 (已完成!) 注释优化 -状态栏显示项的优化 -动画/音乐/音效自动补全 +(已完成!) 状态栏显示项的优化 +(已完成!) 动画/音乐/音效自动补全 (不处理) 0. 部分文案的修改,如“地图编辑器”(启动服务.exe中)、“enemys”、“snipe” @@ -103,7 +103,7 @@ (文档相关给秋橙) 58. 建议在在线文档中给\r支持的颜色单词做一下枚举并写出对应的RGB值 (不处理) 59. 在标题画面调用core.hideStartAnimate(core.startGame)会立即开始游戏并跳过难度选择,可能造成非作者预期的效果,有办法优化吗? (已完成!) 60. “设置怪物属性”事件的下拉框目前只支持一部分,另一部分只能通过手敲json再解析来得到,希望提供完整支持 -61. 在事件编辑器中进行地图选点时,有些事件指令虽然只能用于同楼层,但实际生效时勇士可能已经不在当前正在编辑的楼层(比如在一个楼层切换事件指令后)了,所以希望地图选点始终提供楼层下拉表 +(已完成!) 61. 在事件编辑器中进行地图选点时,有些事件指令虽然只能用于同楼层,但实际生效时勇士可能已经不在当前正在编辑的楼层(比如在一个楼层切换事件指令后)了,所以希望地图选点始终提供楼层下拉表 (文档相关给秋橙) 62. 希望在线文档介绍一下楼层和startText的独立开关的flag表示 63. 希望给core.moveAction(callback)函数提供一个对应的事件指令,用于在事件流处理中让勇士进行一些有游戏性意义(即非纯演出)的移动。如果做不到的话希望参照本文的46号issue作为原生脚本勾选async的例子讲解如何使用 64. “打开全局商店”事件指令建议在用于公共事件版商店时简单地退化为“插入公共事件”而不要打断当前事件流,由作者在这个公共事件结尾去决定“立刻结束当前事件”还是不结束