From 7d05e23d4c52b185ee25e8e4aacef581ceeb3f2d Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Sat, 16 May 2020 11:21:33 +0800 Subject: [PATCH 01/16] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E6=97=B6=E5=88=87=E6=8D=A2=E7=9B=AE=E6=A0=87=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/editor_mode.js | 14 ++++++-------- _server/editor_table.js | 8 ++++++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/_server/editor_mode.js b/_server/editor_mode.js index 5ca0f7b0..d7b8e728 100644 --- a/_server/editor_mode.js +++ b/_server/editor_mode.js @@ -97,14 +97,12 @@ editor_mode = function (editor) { } editor_mode.prototype.onmode = function (mode, callback) { - //setTimeout(function(){ - if (editor_mode.mode != mode) { - if (mode === 'save') editor_mode.doActionList(editor_mode.mode, editor_mode.actionList, callback); - if (editor_mode.mode === 'nextChange' && mode) editor_mode.showMode(mode); - if (mode !== 'save') editor_mode.mode = mode; - editor_mode.actionList = []; - } - //}) + if (editor_mode.mode != mode) { + if (mode === 'save') editor_mode.doActionList(editor_mode.mode, editor_mode.actionList, callback); + if (editor_mode.mode === 'nextChange' && mode) editor_mode.showMode(mode); + if (mode !== 'save') editor_mode.mode = mode; + editor_mode.actionList = []; + } } editor_mode.prototype.showMode = function (mode) { diff --git a/_server/editor_table.js b/_server/editor_table.js index 1788515b..bfb38185 100644 --- a/_server/editor_table.js +++ b/_server/editor_table.js @@ -224,8 +224,10 @@ editor_table_wrapper = function (editor) { var listen = function (guids) { // 每个叶节点的事件绑定 + var tableid = editor.util.guid(); + editor.mode.currentTable=tableid; guids.forEach(function (guid) { - editor.table.guidListen(guid, obj, commentObj) + editor.table.guidListen(guid, tableid, obj, commentObj) }); } return { "HTML": outstr.join(''), "guids": guids, "listen": listen }; @@ -309,7 +311,7 @@ editor_table_wrapper = function (editor) { * 监听一个guid对应的表格项 * @param {String} guid */ - editor_table.prototype.guidListen = function (guid, obj, commentObj) { + editor_table.prototype.guidListen = function (guid, tableid, obj, commentObj) { // tr>td[title=field] // >td[title=comment,cobj=cobj:json] // >td>div>input[value=thiseval] @@ -318,6 +320,7 @@ editor_table_wrapper = function (editor) { var field = thisTr.children[0].getAttribute('title'); var cobj = JSON.parse(thisTr.children[1].getAttribute('cobj')); var modeNode = thisTr.parentNode; + thisTr.setAttribute('tableid',tableid) while (!editor_mode._ids.hasOwnProperty(modeNode.getAttribute('id'))) { modeNode = modeNode.parentNode; } @@ -341,6 +344,7 @@ editor_table_wrapper = function (editor) { */ editor_table.prototype.onchange = function (guid, obj, commentObj, thisTr, input, field, cobj, modeNode) { editor_mode.onmode(editor_mode._ids[modeNode.getAttribute('id')]); + if (editor.mode.currentTable!=thisTr.getAttribute('tableid')) return; var thiseval = null; if (input.checked != null) input.value = input.checked; try { From f264ba9e533eae0d97c163438155d8fa1a678335 Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Sat, 16 May 2020 11:51:26 +0800 Subject: [PATCH 02/16] fix types of some eval-blocks --- _server/MotaAction.g4 | 32 ++++++++++++-------------------- _server/editor_blockly.js | 10 +++++----- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index bc5e64cd..ef872b1f 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -2510,6 +2510,10 @@ expression | idString_e | evFlag_e | evTemp_e + | enemyattr_e + | blockId_e + | blockCls_e + | equip_e | evalString_e @@ -2597,13 +2601,11 @@ return [code, Blockly.JavaScript.ORDER_ATOMIC]; */; -//这一条不会被antlr识别,总是会被归到idString_e -idString_3_e +enemyattr_e : '怪物' IdString '的' EnemyId_List -/* idString_3_e -colour : this.idstring_eColor +/* enemyattr_e default : ['greenSlime',"攻击"] //todo 将其output改成'idString_e' var code = 'enemy:'+IdString_0+':'+EnemyId_List_0; @@ -2611,39 +2613,33 @@ return [code, Blockly.JavaScript.ORDER_ATOMIC]; */; -//这一条不会被antlr识别,总是会被归到idString_e -idString_4_e +blockId_e : '图块ID:' Int ',' Int -/* idString_4_e -colour : this.idstring_eColor +/* blockId_e default : [0,0] var code = 'blockId:'+Int_0+','+Int_1; return [code, Blockly.JavaScript.ORDER_ATOMIC]; */; -//这一条不会被antlr识别,总是会被归到idString_e -idString_5_e +blockCls_e : '图块类别:' Int ',' Int -/* idString_5_e -colour : this.idstring_eColor +/* blockCls_e default : [0,0] var code = 'blockCls:'+Int_0+','+Int_1; return [code, Blockly.JavaScript.ORDER_ATOMIC]; */; -//这一条不会被antlr识别,总是会被归到idString_e -idString_6_e +equip_e : '装备孔:' Int -/* idString_6_e -colour : this.idstring_eColor +/* equip_e default : [0] var code = 'equip:'+Int_0; return [code, Blockly.JavaScript.ORDER_ATOMIC]; @@ -2901,10 +2897,6 @@ this.evisitor.mapColor=175; delete(this.block('negate_e').inputsInline); this.block('idString_1_e').output='idString_e'; this.block('idString_2_e').output='idString_e'; -this.block('idString_3_e').output='idString_e'; -this.block('idString_4_e').output='idString_e'; -this.block('idString_5_e').output='idString_e'; -this.block('idString_6_e').output='idString_e'; this.block('evFlag_e').output='idString_e'; this.block('evTemp_e').output='idString_e'; */ diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index c1908d51..f47ca6d2 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -227,10 +227,10 @@ editor_blockly = function () { MotaActionBlocks['idString_e'].xmlText(), MotaActionBlocks['idString_1_e'].xmlText(), MotaActionBlocks['idString_2_e'].xmlText(), - MotaActionBlocks['idString_3_e'].xmlText(), - MotaActionBlocks['idString_4_e'].xmlText(), - MotaActionBlocks['idString_5_e'].xmlText(), - MotaActionBlocks['idString_6_e'].xmlText(), + MotaActionBlocks['enemyattr_e'].xmlText(), + MotaActionBlocks['blockId_e'].xmlText(), + MotaActionBlocks['blockCls_e'].xmlText(), + MotaActionBlocks['equip_e'].xmlText(), MotaActionBlocks['evalString_e'].xmlText(), ], '常见事件模板':[ @@ -1011,7 +1011,7 @@ function omitedcheckUpdateFunction(event) { } // 对怪物ID提供补全 - if ((type == 'idString_3_e' || type == 'battle_s' || type == 'setEnemy_s') && name == 'IdString_0') { + if ((type == 'enemyattr_e' || type == 'battle_s' || type == 'setEnemy_s') && name == 'IdString_0') { return filter(allEnemys, content); } From 80a5d6491842e49826f4fc333855a4611149763d Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Sat, 16 May 2020 12:41:52 +0800 Subject: [PATCH 03/16] =?UTF-8?q?=E8=B0=83=E6=95=B4blockly=E4=B8=ADidStrin?= =?UTF-8?q?g=E7=B1=BB=E5=88=AB=E7=9A=84id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/MotaAction.g4 | 39 ++++++++++++++++++--------------------- _server/editor_blockly.js | 12 ++++++------ 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index ef872b1f..c92c3f26 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -2507,9 +2507,11 @@ expression : expression Arithmetic_List expression | negate_e | bool_e + | idFixedList_e + | idFlag_e + | idTemp_e + | idIdList_e | idString_e - | evFlag_e - | evTemp_e | enemyattr_e | blockId_e | blockCls_e @@ -2575,27 +2577,23 @@ var code = IdString_0; return [code, Blockly.JavaScript.ORDER_ATOMIC]; */; -//这一条不会被antlr识别,总是会被归到idString_e -idString_1_e +idIdList_e : Id_List ':' IdText -/* idString_1_e +/* idIdList_e colour : this.idstring_eColor default : [null,"自定义flag"] -//todo 将其output改成'idString_e' var code = MotaActionFunctions.replaceFromName(MotaActionFunctions.replaceToName(Id_List_0+':'+IdText_0)); return [code, Blockly.JavaScript.ORDER_ATOMIC]; */; -//这一条不会被antlr识别,总是会被归到idString_e -idString_2_e +idFixedList_e : FixedId_List -/* idString_2_e +/* idFixedList_e colour : this.idstring_eColor -//todo 将其output改成'idString_e' var code = FixedId_List_0; return [code, Blockly.JavaScript.ORDER_ATOMIC]; */; @@ -2607,7 +2605,6 @@ enemyattr_e /* enemyattr_e default : ['greenSlime',"攻击"] -//todo 将其output改成'idString_e' var code = 'enemy:'+IdString_0+':'+EnemyId_List_0; return [code, Blockly.JavaScript.ORDER_ATOMIC]; */; @@ -2646,11 +2643,11 @@ return [code, Blockly.JavaScript.ORDER_ATOMIC]; */; -evFlag_e +idFlag_e : '独立开关' Letter_List -/* evFlag_e +/* idFlag_e colour : this.idstring_eColor default : ["A"] var code = "switch:"+Letter_List_0; @@ -2658,11 +2655,11 @@ return [code, Blockly.JavaScript.ORDER_ATOMIC]; */; -evTemp_e +idTemp_e : '临时变量' Letter_List -/* evTemp_e +/* idTemp_e colour : this.idstring_eColor default : ["A"] var code = "temp:"+Letter_List_0; @@ -2895,10 +2892,10 @@ this.evisitor.mapColor=175; /* Function_1 delete(this.block('negate_e').inputsInline); -this.block('idString_1_e').output='idString_e'; -this.block('idString_2_e').output='idString_e'; -this.block('evFlag_e').output='idString_e'; -this.block('evTemp_e').output='idString_e'; +this.block('idIdList_e').output='idString_e'; +this.block('idFixedList_e').output='idString_e'; +this.block('idFlag_e').output='idString_e'; +this.block('idTemp_e').output='idString_e'; */ /* Functions @@ -3822,12 +3819,12 @@ ActionParser.prototype.tryToUseEvFlag_e = function(defaultType, args, isShadow, var match=/^switch:([A-Z])$/.exec(args[0]) if(match){ args[0]=match[1] - return MotaActionBlocks['evFlag_e'].xmlText(args, isShadow, comment); + return MotaActionBlocks['idFlag_e'].xmlText(args, isShadow, comment); } match=/^temp:([A-Z])$/.exec(args[0]) if(match){ args[0]=match[1] - return MotaActionBlocks['evTemp_e'].xmlText(args, isShadow, comment); + return MotaActionBlocks['idTemp_e'].xmlText(args, isShadow, comment); } return MotaActionBlocks[defaultType||'evalString_e'].xmlText(args, isShadow, comment); } diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index f47ca6d2..75754601 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -97,7 +97,7 @@ editor_blockly = function () { ], '数据相关':[ MotaActionBlocks['setValue_s'].xmlText([ - MotaActionBlocks['idString_1_e'].xmlText(['status','生命']), '=', '', false + MotaActionBlocks['idIdList_e'].xmlText(['status','生命']), '=', '', false ]), MotaActionBlocks['setEnemy_s'].xmlText(), MotaActionBlocks['setFloor_s'].xmlText(), @@ -217,16 +217,16 @@ editor_blockly = function () { ], '值块':[ MotaActionBlocks['setValue_s'].xmlText([ - MotaActionBlocks['idString_1_e'].xmlText(['status','生命']), '=', '', false + MotaActionBlocks['idIdList_e'].xmlText(['status','生命']), '=', '', false ]), MotaActionBlocks['expression_arithmetic_0'].xmlText(), - MotaActionBlocks['evFlag_e'].xmlText(), - MotaActionBlocks['evTemp_e'].xmlText(), + MotaActionBlocks['idFlag_e'].xmlText(), + MotaActionBlocks['idTemp_e'].xmlText(), MotaActionBlocks['negate_e'].xmlText(), MotaActionBlocks['bool_e'].xmlText(), MotaActionBlocks['idString_e'].xmlText(), - MotaActionBlocks['idString_1_e'].xmlText(), - MotaActionBlocks['idString_2_e'].xmlText(), + MotaActionBlocks['idIdList_e'].xmlText(), + MotaActionBlocks['idFixedList_e'].xmlText(), MotaActionBlocks['enemyattr_e'].xmlText(), MotaActionBlocks['blockId_e'].xmlText(), MotaActionBlocks['blockCls_e'].xmlText(), From d5989d9d53ba399b95322ecfc540378dfb0597b9 Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Sat, 16 May 2020 12:54:53 +0800 Subject: [PATCH 04/16] expandevalblock --- _server/MotaAction.g4 | 49 ++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index c92c3f26..ebd6571d 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -2946,7 +2946,7 @@ ActionParser.prototype.parse = function (obj,type) { var text_choices = null; for(var ii=obj.length-1,choice;choice=obj[ii];ii--) { text_choices=MotaActionBlocks['levelCase'].xmlText([ - MotaActionBlocks['evalString_e'].xmlText([choice.need]),choice.title,choice.clear||false,this.parseList(choice.action),text_choices]); + this.expandEvalBlock([choice.need]),choice.title,choice.clear||false,this.parseList(choice.action),text_choices]); } return MotaActionBlocks['level_m'].xmlText([text_choices]); @@ -3403,14 +3403,14 @@ ActionParser.prototype.parseAction = function() { break case "setValue": this.next = MotaActionBlocks['setValue_s'].xmlText([ - this.tryToUseEvFlag_e('idString_e', [data.name]), data["operator"]||'=', - MotaActionBlocks['evalString_e'].xmlText([data.value]), + this.expandIdBlock([data.name]), data["operator"]||'=', + this.expandEvalBlock([data.value]), data.norefresh || false, this.next]); break; case "setEnemy": this.next = MotaActionBlocks['setEnemy_s'].xmlText([ - data.id, data.name, MotaActionBlocks['evalString_e'].xmlText([data.value]), this.next]); + data.id, data.name, this.expandEvalBlock([data.value]), this.next]); break; case "setFloor": this.next = MotaActionBlocks['setFloor_s'].xmlText([ @@ -3439,14 +3439,14 @@ ActionParser.prototype.parseAction = function() { case "if": // 条件判断 if (data["false"]) { this.next = MotaActionBlocks['if_s'].xmlText([ - this.tryToUseEvFlag_e('evalString_e', [data.condition]), + this.expandEvalBlock([data.condition]), this.insertActionList(data["true"]), this.insertActionList(data["false"]), this.next]); } else { this.next = MotaActionBlocks['if_1_s'].xmlText([ - this.tryToUseEvFlag_e('evalString_e', [data.condition]), + this.expandEvalBlock([data.condition]), this.insertActionList(data["true"]), this.next]); } @@ -3462,11 +3462,10 @@ ActionParser.prototype.parseAction = function() { var case_caseList = null; for(var ii=data.caseList.length-1,caseNow;caseNow=data.caseList[ii];ii--) { case_caseList=MotaActionBlocks['switchCase'].xmlText([ - this.isset(caseNow.case)?MotaActionBlocks['evalString_e'].xmlText([caseNow.case]):"值",caseNow.nobreak,this.insertActionList(caseNow.action),case_caseList]); + this.isset(caseNow.case)?this.expandEvalBlock([caseNow.case]):"值",caseNow.nobreak,this.insertActionList(caseNow.action),case_caseList]); } this.next = MotaActionBlocks['switch_s'].xmlText([ - // MotaActionBlocks['evalString_e'].xmlText([data.condition]), - this.tryToUseEvFlag_e('evalString_e', [data.condition]), + this.expandEvalBlock([data.condition]), case_caseList,this.next]); break; case "choices": // 提供选项 @@ -3483,30 +3482,28 @@ ActionParser.prototype.parseAction = function() { break; case "for": // 循环遍历 this.next = MotaActionBlocks['for_s'].xmlText([ - this.tryToUseEvFlag_e('evalString_e', [data.name]), + this.expandEvalBlock([data.name]), data.from || 0, data.to || 0, data.step || 0, this.insertActionList(data.data), this.next]); break; case "forEach": // 循环遍历列表 this.next = MotaActionBlocks['forEach_s'].xmlText([ - this.tryToUseEvFlag_e('evalString_e', [data.name]), + this.expandEvalBlock([data.name]), JSON.stringify(data.list), this.insertActionList(data.data), this.next]); break; case "while": // 前置条件循环处理 this.next = MotaActionBlocks['while_s'].xmlText([ - // MotaActionBlocks['evalString_e'].xmlText([data.condition]), - this.tryToUseEvFlag_e('evalString_e', [data.condition]), + this.expandEvalBlock([data.condition]), this.insertActionList(data.data), this.next]); break; case "dowhile": // 后置条件循环处理 this.next = MotaActionBlocks['dowhile_s'].xmlText([ this.insertActionList(data.data), - // MotaActionBlocks['evalString_e'].xmlText([data.condition]), - this.tryToUseEvFlag_e('evalString_e', [data.condition]), + this.expandEvalBlock([data.condition]), this.next]); break; case "break": // 跳出循环 @@ -3815,7 +3812,7 @@ ActionParser.prototype.Colour = function(color) { return color?JSON.stringify(color).slice(1,-1):null; } -ActionParser.prototype.tryToUseEvFlag_e = function(defaultType, args, isShadow, comment) { +ActionParser.prototype.expandIdBlock = function(args, isShadow, comment) { var match=/^switch:([A-Z])$/.exec(args[0]) if(match){ args[0]=match[1] @@ -3826,7 +3823,25 @@ ActionParser.prototype.tryToUseEvFlag_e = function(defaultType, args, isShadow, args[0]=match[1] return MotaActionBlocks['idTemp_e'].xmlText(args, isShadow, comment); } - return MotaActionBlocks[defaultType||'evalString_e'].xmlText(args, isShadow, comment); + return MotaActionBlocks['idString_e'].xmlText(args, isShadow, comment); +} + +ActionParser.prototype.expandEvalBlock = function(args, isShadow, comment) { + var match=/^switch:([A-Z])$/.exec(args[0]) + if(match){ + args[0]=match[1] + return MotaActionBlocks['idFlag_e'].xmlText(args, isShadow, comment); + } + match=/^temp:([A-Z])$/.exec(args[0]) + if(match){ + args[0]=match[1] + return MotaActionBlocks['idTemp_e'].xmlText(args, isShadow, comment); + } + // todo + // 1. 将「数值设置」的名称尽可能替换掉;如果是 FixedId_List 那就用它;否则如果是 独立开关/临时变量 那就用对应的;否则用 A:B 的那个框 + // 2. 将「值块」尽可能替换掉,主要是「独立开关」,「临时变量」,「非 - 独立开关」,「非-临时变量」;以及true/false替换成勾选框;对于其他变量/属性等之类也尽可能进行替换 + + return MotaActionBlocks['evalString_e'].xmlText(args, isShadow, comment); } MotaActionFunctions.actionParser = new ActionParser(); From a67cc8595bc3e44de80c345597a7e181136514a1 Mon Sep 17 00:00:00 2001 From: YouWei Zhao Date: Sat, 16 May 2020 15:00:53 +0800 Subject: [PATCH 05/16] expand id --- _server/MotaAction.g4 | 45 +++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index ebd6571d..95e2450e 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -3812,31 +3812,48 @@ ActionParser.prototype.Colour = function(color) { return color?JSON.stringify(color).slice(1,-1):null; } -ActionParser.prototype.expandIdBlock = function(args, isShadow, comment) { - var match=/^switch:([A-Z])$/.exec(args[0]) +ActionParser.prototype.matchId = function(args, isShadow, comment) { + var rt=function(xml){ + return {xml:xml,ret:true} + } + var match = /nothing/.exec('nothing') + // 固定列表 + var FixedId_List=MotaActionBlocks.idFixedList_e.json.args0[0].options; // [["生命", "status:hp"], ...] + match=new RegExp('^('+FixedId_List.map(function(v){return v[1]}).join('|')+')$').exec(args[0]) + if(match){ + return rt(MotaActionBlocks['idFixedList_e'].xmlText(args, isShadow, comment)); + } + // 独立开关 + match=/^switch:([A-Z])$/.exec(args[0]) if(match){ args[0]=match[1] - return MotaActionBlocks['idFlag_e'].xmlText(args, isShadow, comment); + return rt(MotaActionBlocks['idFlag_e'].xmlText(args, isShadow, comment)); } + // 临时变量 match=/^temp:([A-Z])$/.exec(args[0]) if(match){ args[0]=match[1] - return MotaActionBlocks['idTemp_e'].xmlText(args, isShadow, comment); + return rt(MotaActionBlocks['idTemp_e'].xmlText(args, isShadow, comment)); } + // id列表 + var Id_List = MotaActionBlocks.idIdList_e.json.args0[0].options; // [["变量", "flag"], ...] + match=new RegExp('^('+Id_List.map(function(v){return v[1]}).join('|')+'):([a-zA-Z0-9_\\u4E00-\\u9FCC]+)$').exec(args[0]) + if(match){ + args=[match[1],match[2]].concat(args.slice(1)) + return rt(MotaActionBlocks['idIdList_e'].xmlText(args, isShadow, comment)); + } + return {xml:'',ret:false} +} + +ActionParser.prototype.expandIdBlock = function(args, isShadow, comment) { + var ret=this.matchId(args, isShadow, comment) + if (ret.ret) return ret.xml; return MotaActionBlocks['idString_e'].xmlText(args, isShadow, comment); } ActionParser.prototype.expandEvalBlock = function(args, isShadow, comment) { - var match=/^switch:([A-Z])$/.exec(args[0]) - if(match){ - args[0]=match[1] - return MotaActionBlocks['idFlag_e'].xmlText(args, isShadow, comment); - } - match=/^temp:([A-Z])$/.exec(args[0]) - if(match){ - args[0]=match[1] - return MotaActionBlocks['idTemp_e'].xmlText(args, isShadow, comment); - } + var ret=this.matchId(args, isShadow, comment) + if (ret.ret) return ret.xml; // todo // 1. 将「数值设置」的名称尽可能替换掉;如果是 FixedId_List 那就用它;否则如果是 独立开关/临时变量 那就用对应的;否则用 A:B 的那个框 // 2. 将「值块」尽可能替换掉,主要是「独立开关」,「临时变量」,「非 - 独立开关」,「非-临时变量」;以及true/false替换成勾选框;对于其他变量/属性等之类也尽可能进行替换 From 8a890bb55ea5d548beceae813f4d9c00c37feaf6 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Sat, 16 May 2020 22:34:17 +0800 Subject: [PATCH 06/16] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8E=A5=E6=A1=A3?= =?UTF-8?q?=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/editor_table.js | 3 +- libs/events.js | 24 +++++++---- v2.x-final更新.txt | 4 ++ v266-v2.7接档说明 | 91 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 113 insertions(+), 9 deletions(-) create mode 100644 v266-v2.7接档说明 diff --git a/_server/editor_table.js b/_server/editor_table.js index 1788515b..40dad003 100644 --- a/_server/editor_table.js +++ b/_server/editor_table.js @@ -27,7 +27,8 @@ editor_table_wrapper = function (editor) { return /* html */`\n` } editor_table.prototype.checkboxSet = function (value, keys, prefixStrings) { - if (!(value instanceof Array)) value = []; + if (value == null) value = []; + if (!(value instanceof Array)) value = [value]; keys=Array.from(keys) prefixStrings=Array.from(prefixStrings) for (var index = 0; index < value.length; index++) { diff --git a/libs/events.js b/libs/events.js index 460e676c..2a613771 100644 --- a/libs/events.js +++ b/libs/events.js @@ -937,13 +937,6 @@ events.prototype._popEvents = function (current, prefix) { events.prototype.insertAction = function (action, x, y, callback, addToLast) { if (core.hasFlag("__statistics__")) return; if (core.status.gameOver) return; - - // ------ 判定commonEvent - var commonEvent = this.getCommonEvent(action); - if (commonEvent instanceof Array) { - // 将公共事件视为一个do-while事件插入执行,可被break跳出 - action = [{"type": "dowhile", "condition": "false", "data": commonEvent}]; - } if (!action) return; action = this.precompile(action); @@ -960,6 +953,16 @@ events.prototype.insertAction = function (action, x, y, callback, addToLast) { } } +////// 往当前事件列表之前或之后添加一个公共事件 ////// +events.prototype.insertCommonEvent = function (name, x, y, callback, addToLast) { + var commonEvent = this.getCommonEvent(name); + if (!commonEvent) { + if (callback) callback(); + return; + } + this.insertAction(commonEvent, x, y, callback, addToLast); +} + ////// 获得一个公共事件 ////// events.prototype.getCommonEvent = function (name) { if (!name || typeof name !== 'string') return null; @@ -1562,7 +1565,7 @@ events.prototype._action_insert = function (data, x, y, prefix) { } if (data.name) { // 公共事件 core.setFlag('arg0', data.name); - core.insertAction(data.name); + core.insertCommonEvent(data.name); } else { var loc = this.__action_getLoc(data.loc, x, y, prefix); @@ -1632,6 +1635,11 @@ events.prototype._action_setValue = function (data, x, y, prefix) { core.doAction(); } +events.prototype._action_addValue = function (data, x, y, prefix) { + data.operator = '+='; + this._action_setValue(data, x, y, prefix); +} + events.prototype._action_setEnemy = function (data, x, y, prefix) { this.setEnemy(data.id, data.name, data.value, prefix); core.doAction(); diff --git a/v2.x-final更新.txt b/v2.x-final更新.txt index 2fc4b1c5..680d4953 100644 --- a/v2.x-final更新.txt +++ b/v2.x-final更新.txt @@ -51,6 +51,10 @@ 地图拉框选择复制剪切删除 (已完成!) 素材替换 大屏幕下放大游戏界面 +最近使用/最常使用的图块 +loader并行加载 +合并items.js +增加fonts目录,全塔属性增加fonts引用 ------------- diff --git a/v266-v2.7接档说明 b/v266-v2.7接档说明 new file mode 100644 index 00000000..baac3b03 --- /dev/null +++ b/v266-v2.7接档说明 @@ -0,0 +1,91 @@ +V2.6.6 -> V2.7 接档说明: + +此版本仅可接档【地图】,【事件】和【怪物数据】。脚本编辑等不可进行接档。 + +请严格按照此说明进行每一步操作以避免可能的bug。接档前请做好备份。 + +接档准备: + - Visual Studio Code + - 需要进行接档的V266的样板 + - 两个全新的V2.7的样板(一个用于接档结果,一个用于抄部分修改后的内容) + +接档步骤: +1. 将V266的样板中,【project】目录下的如下文件和文件夹,直接复制并覆盖到V2.7的样板中的project目录下: + - animates/ + - floors/ + - enemys.js + - events.js + - icons.js + - items.js + - maps.js + +2. 将V266样板中,【project/images】目录下的图片,拆分后放入V2.7的对应图片目录下: + - 系统默认图片放入materials中 + - 自动元件放入autotiles中 + - 额外素材放入tilesets中 + - 使用到的其他图片放入images中 +【请注意】hero.png在V2.7请放入images目录(而不是materials目录) + +3. 将V266样板中,【project/sounds】目录下的音乐和音效,分别放入V2.7的bgms和sounds目录。 + +4. 使用VSCode直接分别打开V266和V2.7的【project/data.js】,并执行以下操作: + - 将【main】一项的全部内容从V2.6.6直接复制到V2.7 + - 将【firstData】一项中的,【title】,【name】,【floorId】,【hero】直接复制到 + - 在注册的图片中,请手动补上【hero.png】项 + - 在【hero】中【name】上方增加 "image": "hero.png" + - 在【hero】中【steps】上方新增一项 "followers": [] + - 将【hero】中的【experience】改成【exp】 + - 删除【hero】中【items】中的【keys】项 +请勿覆盖或复制其他内容(例如全塔数值或全局开关),否则可能导致编辑器无法打开。 + +5. 使用VSCode分别打开接档后的V2.7和纯净的V2.7的【project/items.js】,并执行以下操作: + - 将三色钥匙的cls从"keys"改成"tools",并新增 "hideInToolbox": true + - 如下道具的【useItemEffect】和【canUseItemEffect】有所改变,请直接从纯净的V2.7覆盖到你要接档的V2.7: + - earthquake, pickaxe, icePickaxe, snow, bigKey, bomb, upFly, downFly + - 如果确认你的塔不会使用该道具,可忽略 + - 黄宝石和生命魔杖增加了【useItemEvent】;如需使用请进行复制 + +6. 使用VSCode打开接档后的V2.7的【project/icons.js】,并执行如下操作: + - 找到【terrains】中的三色墙和六色门,删除对应的这几行 + - yellowWall, blueWall, whiteWall, yellowDoor, blueDoor, redDoor, greenDoor, specialDoor, steelDoor + - (在V2.7中,terrains不再保留门的引用,门效果仅由animates决定) + - 将【terrains】中的 blueShop-left, blueShop-right, pinkShop-left, pinkShop-right 分别重命名为 + blueShopLeft, blueShopRight, pinkShopLeft, pinkShopRight + +7. 使用VSCode分别打开接档后的V2.7和纯净的V2.7的【project/maps.js】,并执行以下操作: + - 将纯净的V2.7中如下ID的行,直接替换掉要接档的V2.7: + - yellowWall, whiteWall, blueWall, blueShopLeft, blueShopRight, pinkShopLeft, pinkShopRight, + lavaNet, poisonNet, weakNet, curseNet, yellowDoor, blueDoor, redDoor, greenDoor, specialDoor, steelDoor, + arrowUp, arrowDown, arrowLeft, arrowRight, light + - 将所有的 "noPass":false 改成 "canPass":true 原来是 "noPass":true 的请直接删除 + - V2.7中,不再在图块属性使用noPass,而是全部改成了canPass;请检查此文件的全部noPass是否被替换或删除 + +8. 到这一步后已经可以打开编辑器了。 + - 如果打开编辑器白屏或报错,请检查一下上面是否每个步骤都完成了 + - 如果还有问题请联系小艾 + +9. 在编辑器中,切换到「全塔属性」标签,并进行修改: + - V2.7中,全局商店的结构完全重写了,请重新实现一遍 + - 全塔开关中,是否在状态栏显示XXX改成在同一个方框中 + - 删除了部分全局数值和全塔开关 + +10. 在编辑器中,切换到「脚本编辑」标签,并进行修改: + - setInitData已经被删除;移动到了开场剧情的startText中 + - 删除了afterChangeLight和afterPassNet脚本 + - 很多函数的实现有所改变,改变较为严重的有: + - resetGame, changingFloor, afterBattle, getDamageInfo, saveData, loadData, + updateStatusBar, updateCheckBlock, moveOneStep + - 修改脚本编辑(例如getDamageInfo)时,请勿直接拿原来的脚本进行覆盖,而是重新对函数进行修改! + +11. 在编辑器中,切换到「插件编写」标签,并重新增加新增的插件插件 + - 请勿随意修改已有的默认插件 + +12. 逐楼层检查firstArrive以及每个点的事件列表;主要事件API变化如下: + - 所有的「数值增减」事件已被删除,被数值设置+运算符替代 + - 编辑器将无法再解析「数值增减」事件(会被解析成自定义事件),但是游戏中仍然可以正确执行 + - 「隐藏事件」将不再默认删除该点(而只是纯粹的隐藏);请给有需要的「隐藏事件」勾选「同时删除」选项 + - 「重启当前事件」已经被删除并且无法在游戏中使用。请替换成等价的循环处理或者插入事件 + - 在V2.7中,所有的experience全部改名exp;请检查所有对经验值进行操作的地方 + + + From a4e3bd904f52a59a98529e6095fc7ac58dbe5659 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Sun, 17 May 2020 00:44:23 +0800 Subject: [PATCH 07/16] =?UTF-8?q?=E5=90=88=E5=B9=B6loader=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E8=BF=87=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/loader.js | 407 +++++++++++++++++++++++++++------------------ libs/utils.js | 8 +- main.js | 2 +- v2.x-final更新.txt | 2 +- 4 files changed, 258 insertions(+), 161 deletions(-) diff --git a/libs/loader.js b/libs/loader.js index 8f4ea8f6..0252d88a 100644 --- a/libs/loader.js +++ b/libs/loader.js @@ -25,115 +25,199 @@ loader.prototype._setStartLoadTipText = function (text) { } loader.prototype._load = function (callback) { - this._loadIcons(); - this._loadAnimates(); - this._loadMusic(); + if (main.useCompress) { + this._load_async(callback); + } else { + this._load_sync(callback); + } +} - core.loader._loadMaterialImages(function () { - core.loader._loadExtraImages(function () { - core.loader._loadAutotiles(function () { - core.loader._loadTilesets(callback); +loader.prototype._load_sync = function (callback) { + this._loadAnimates_sync(); + this._loadMusic_sync(); + core.loader._loadMaterials_sync(function () { + core.loader._loadExtraImages_sync(function () { + core.loader._loadAutotiles_sync(function () { + core.loader._loadTilesets_sync(callback); }) }) }); } -loader.prototype._loadIcons = function () { - this.loadImage("materials", "icons.png", function (id, image) { - var images = core.splitImage(image); - for (var key in core.statusBar.icons) { - if (typeof core.statusBar.icons[key] == 'number') { - core.statusBar.icons[key] = images[core.statusBar.icons[key]]; - if (core.statusBar.image[key] != null) - core.statusBar.image[key].src = core.statusBar.icons[key].src; +loader.prototype._load_async = function (callback) { + core.loader._setStartLoadTipText('正在加载资源文件...'); + var all = {}; + + var _makeOnProgress = function (name) { + if (!all[name]) all[name] = {loaded: 0, total: 0, finished: false}; + return function (loaded, total) { + all[name].loaded = loaded; + all[name].total = total; + var allLoaded = 0, allTotal = 0; + for (var one in all) { + allLoaded += all[one].loaded; + allTotal += all[one].total; } + if (allTotal > 0) { + if (allLoaded == allTotal) { + core.loader._setStartLoadTipText("正在处理资源文件... 请稍后..."); + } else { + core.loader._setStartLoadTipText('正在加载资源文件... ' + + core.formatSize(allLoaded) + " / " + core.formatSize(allTotal) + + " (" + (allLoaded / allTotal * 100).toFixed(2) + "%)"); + } + core.loader._setStartProgressVal(allLoaded / allTotal * 100); + } + }; + } + var _makeOnFinished = function (name) { + return function () { + setTimeout(function () { + all[name].finished = true; + for (var one in all) { + if (!all[one].finished) return; + } + callback(); + }); } + } + + this._loadAnimates_async(_makeOnProgress('animates'), _makeOnFinished('animates')); + this._loadMusic_async(_makeOnProgress('sounds'), _makeOnFinished('sounds')); + this._loadMaterials_async(_makeOnProgress('materials'), _makeOnFinished('materials')); + this._loadExtraImages_async(_makeOnProgress('images'), _makeOnFinished('images')); + this._loadAutotiles_async(_makeOnProgress('autotiles'), _makeOnFinished('autotiles')); + this._loadTilesets_async(_makeOnProgress('tilesets'), _makeOnFinished('tilesets')); +} + +// ----- 加载资源文件 ------ // + +loader.prototype._loadMaterials_sync = function (callback) { + this._setStartLoadTipText("正在加载资源文件..."); + this.loadImages("materials", core.materials, core.material.images, function () { + core.loader._loadMaterials_afterLoad(); + callback(); }); } -loader.prototype._loadMaterialImages = function (callback) { - this._setStartLoadTipText("正在加载资源文件..."); - if (main.useCompress) { - this.loadImagesFromZip('project/materials/materials.h5data', core.materials, core.material.images, callback); - } else { - this.loadImages("materials", core.materials, core.material.images, callback); +loader.prototype._loadMaterials_async = function (onprogress, onfinished) { + this.loadImagesFromZip('project/materials/materials.h5data', core.materials, core.material.images, onprogress, function () { + core.loader._loadMaterials_afterLoad(); + onfinished(); + }); +} + +loader.prototype._loadMaterials_afterLoad = function () { + var images = core.splitImage(core.material.images['icons']); + for (var key in core.statusBar.icons) { + if (typeof core.statusBar.icons[key] == 'number') { + core.statusBar.icons[key] = images[core.statusBar.icons[key]]; + if (core.statusBar.image[key] != null) + core.statusBar.image[key].src = core.statusBar.icons[key].src; + } } } -loader.prototype._loadExtraImages = function (callback) { +// ------ 加载使用的图片 ------ // + +loader.prototype._loadExtraImages_sync = function (callback) { core.material.images.images = {}; - - var images = core.clone(core.images); - this._setStartLoadTipText("正在加载图片文件..."); - if (main.useCompress) { - // Check .gif - var gifs = images.filter(function (name) { - return name.toLowerCase().endsWith('.gif'); - }); - images = images.filter(function (name) { - return !name.toLowerCase().endsWith('.gif'); - }); - - this.loadImagesFromZip('project/images/images.h5data', images, core.material.images.images, callback); - gifs.forEach(function (gif) { - this.loadImage("images", gif, function (id, image) { - if (image != null) { - core.material.images.images[gif] = image; - } - }); - }, this); - } else { - this.loadImages("images", images, core.material.images.images, callback); - } + core.loadImages("images", core.images, core.material.images.images, callback); } -loader.prototype._loadAutotiles = function (callback) { +loader.prototype._loadExtraImages_async = function (onprogress, onfinished) { + core.material.images.images = {}; + var images = core.images; + + // Check .gif + var gifs = images.filter(function (name) { + return name.toLowerCase().endsWith('.gif'); + }); + images = images.filter(function (name) { + return !name.toLowerCase().endsWith('.gif'); + }); + + this.loadImagesFromZip('project/images/images.h5data', images, core.material.images.images, onprogress, onfinished); + // gif没有被压缩在zip中,延迟加载... + gifs.forEach(function (gif) { + this.loadImage("images", gif, function (id, image) { + if (image != null) { + core.material.images.images[gif] = image; + } + }); + }, this); +} + +// ------ 加载自动元件 ------ // + +loader.prototype._loadAutotiles_sync = function (callback) { core.material.images.autotile = {}; var keys = Object.keys(core.material.icons.autotile); var autotiles = {}; - var _callback = function () { - keys.forEach(function (v) { - core.material.images.autotile[v] = autotiles[v]; - }); - setTimeout(function () { - core.maps._makeAutotileEdges(); - }); - - callback(); - } this._setStartLoadTipText("正在加载自动元件..."); - if (main.useCompress) { - this.loadImagesFromZip('project/autotiles/autotiles.h5data', keys, autotiles, _callback); - } else { - this.loadImages("autotiles", keys, autotiles, _callback); + this.loadImages("autotiles", keys, autotiles, function () { + core.loader._loadAutotiles_afterLoad(keys, autotiles); + callback(); + }); +} + +loader.prototype._loadAutotiles_async = function (onprogress, onfinished) { + core.material.images.autotile = {}; + var keys = Object.keys(core.material.icons.autotile); + var autotiles = {}; + + this.loadImagesFromZip('project/autotiles/autotiles.h5data', keys, autotiles, onprogress, function () { + core.loader._loadAutotiles_afterLoad(keys, autotiles); + onfinished(); + }); +} + +loader.prototype._loadAutotiles_afterLoad = function (keys, autotiles) { + // autotile需要保证顺序 + keys.forEach(function (v) { + core.material.images.autotile[v] = autotiles[v]; + }); + + setTimeout(function () { + core.maps._makeAutotileEdges(); + }); +} + +// ------ 加载额外素材 ------ // + +loader.prototype._loadTilesets_sync = function (callback) { + core.material.images.tilesets = {}; + this._setStartLoadTipText("正在加载额外素材..."); + this.loadImages("tilesets", core.tilesets, core.material.images.tilesets, function () { + core.loader._loadTilesets_afterLoad(); + callback(); + }); +} + +loader.prototype._loadTilesets_async = function (onprogress, onfinished) { + core.material.images.tilesets = {}; + this.loadImagesFromZip('project/tilesets/tilesets.h5data', core.tilesets, core.material.images.tilesets, onprogress, function () { + core.loader._loadTilesets_afterLoad(); + onfinished(); + }); +} + +loader.prototype._loadTilesets_afterLoad = function () { + // 检查宽高是32倍数,如果出错在控制台报错 + for (var imgName in core.material.images.tilesets) { + var img = core.material.images.tilesets[imgName]; + if (img.width % 32 != 0 || img.height % 32 != 0) { + console.warn("警告!" + imgName + "的宽或高不是32的倍数!"); + } + if (img.width * img.height > 32 * 32 * 3000) { + console.warn("警告!" + imgName + "上的图块素材个数大于3000!"); + } } } -loader.prototype._loadTilesets = function (callback) { - core.material.images.tilesets = {}; - core.tilesets = core.tilesets || []; - var _callback = function () { - // 检查宽高是32倍数,如果出错在控制台报错 - for (var imgName in core.material.images.tilesets) { - var img = core.material.images.tilesets[imgName]; - if (img.width % 32 != 0 || img.height % 32 != 0) { - console.warn("警告!" + imgName + "的宽或高不是32的倍数!"); - } - if (img.width * img.height > 32 * 32 * 3000) { - console.warn("警告!" + imgName + "上的图块素材个数大于3000!"); - } - } - callback(); - } - this._setStartLoadTipText("正在加载额外素材..."); - if (main.useCompress) { - this.loadImagesFromZip('project/tilesets/tilesets.h5data', core.tilesets, core.material.images.tilesets, _callback); - } else { - this.loadImages("tilesets", core.tilesets, core.material.images.tilesets, _callback); - } -} +// ------ 实际加载一系列图片 ------ // loader.prototype.loadImages = function (dir, names, toSave, callback) { if (!names || names.length == 0) { @@ -159,37 +243,6 @@ loader.prototype.loadImages = function (dir, names, toSave, callback) { } } -loader.prototype.loadImagesFromZip = function (url, names, toSave, callback) { - if (!names || names.length == 0) { - if (callback) callback(); - return; - } - - core.unzip(url + "?v=" + main.version, function (data) { - var cnt = 1; - names.forEach(function (name) { - var imgName = name; - if (imgName.indexOf('.') < 0) imgName += '.png'; - if (imgName in data) { - var img = new Image(); - var url = URL.createObjectURL(data[imgName]); - cnt++; - img.onload = function () { - cnt--; - URL.revokeObjectURL(url); - if (cnt == 0 && callback) callback(); - } - img.src = url; - toSave[name] = img; - } - }); - cnt--; - if (cnt == 0 && callback) callback(); - }, null, false, function (percentage) { - core.loader._setStartProgressVal(percentage * 100); - }); -} - loader.prototype.loadImage = function (dir, imgName, callback) { try { var name = imgName; @@ -211,28 +264,63 @@ loader.prototype.loadImage = function (dir, imgName, callback) { } } -loader.prototype._loadAnimates = function () { - this._setStartLoadTipText("正在加载动画文件..."); - if (main.useCompress) { - core.unzip('project/animates/animates.h5data?v=' + main.version, function (animates) { - for (var name in animates) { - if (name.endsWith(".animate")) { - var t = name.substring(0, name.length - 8); - if (core.animates.indexOf(t) >= 0) - core.loader._loadAnimate(t, animates[name]); - } - } - }, null, true); - } else { - core.animates.forEach(function (t) { - core.http('GET', 'project/animates/' + t + ".animate?v=" + main.version, null, function (content) { - core.loader._loadAnimate(t, content); - }, function (e) { - main.log(e); - core.material.animates[t] = null; - }, "text/plain; charset=x-user-defined") - }) +// ------ 从zip中加载一系列图片 ------ // + +loader.prototype.loadImagesFromZip = function (url, names, toSave, onprogress, onfinished) { + if (!names || names.length == 0) { + if (onfinished) onfinished(); + return; } + + core.unzip(url + "?v=" + main.version, function (data) { + var cnt = 1; + names.forEach(function (name) { + var imgName = name; + if (imgName.indexOf('.') < 0) imgName += '.png'; + if (imgName in data) { + var img = new Image(); + var url = URL.createObjectURL(data[imgName]); + cnt++; + img.onload = function () { + cnt--; + URL.revokeObjectURL(url); + if (cnt == 0 && onfinished) onfinished(); + } + img.src = url; + toSave[name] = img; + } + }); + cnt--; + if (cnt == 0 && onfinished) onfinished(); + }, null, false, onprogress); +} + +// ------ 加载动画文件 ------ // + +loader.prototype._loadAnimates_sync = function () { + this._setStartLoadTipText("正在加载动画文件..."); + + core.animates.forEach(function (t) { + core.http('GET', 'project/animates/' + t + ".animate?v=" + main.version, null, function (content) { + core.loader._loadAnimate(t, content); + }, function (e) { + main.log(e); + core.material.animates[t] = null; + }, "text/plain; charset=x-user-defined") + }); +} + +loader.prototype._loadAnimates_async = function (onprogress, onfinished) { + core.unzip('project/animates/animates.h5data?v=' + main.version, function (animates) { + for (var name in animates) { + if (name.endsWith(".animate")) { + var t = name.substring(0, name.length - 8); + if (core.animates.indexOf(t) >= 0) + core.loader._loadAnimate(t, animates[name]); + } + } + onfinished(); + }, null, true, onprogress); } loader.prototype._loadAnimate = function (name, content) { @@ -283,26 +371,36 @@ loader.prototype._loadAnimate = function (name, content) { } } -////// 加载音频 ////// -loader.prototype._loadMusic = function () { +// ------ 加载音乐和音效 ------ // + +loader.prototype._loadMusic_sync = function () { + this._setStartLoadTipText("正在加载音效文件..."); core.bgms.forEach(function (t) { core.loader.loadOneMusic(t); }); + core.sounds.forEach(function (t) { + core.loader.loadOneSound(t); + }); + // 直接开始播放 + core.playBgm(main.startBgm); +} - this._setStartLoadTipText("正在加载音效文件..."); - if (main.useCompress && core.musicStatus.audioContext) { - core.unzip('project/sounds/sounds.h5data?v=' + main.version, function (data) { +loader.prototype._loadMusic_async = function (onprogress, onfinished) { + core.bgms.forEach(function (t) { + core.loader.loadOneMusic(t); + }); + core.unzip('project/sounds/sounds.h5data?v=' + main.version, function (data) { + // 延迟解析 + setTimeout(function () { for (var name in data) { if (core.sounds.indexOf(name) >= 0) { core.loader._loadOneSound_decodeData(name, data[name]); } } }); - } else { - core.sounds.forEach(function (t) { - core.loader.loadOneSound(t); - }); - } + onfinished(); + }, null, false, onprogress); + // 直接开始播放 core.playBgm(main.startBgm); } @@ -317,19 +415,12 @@ loader.prototype.loadOneMusic = function (name) { } loader.prototype.loadOneSound = function (name) { - if (core.musicStatus.audioContext != null) { - core.http('GET', 'project/sounds/' + name + "?v=" + main.version, null, function (data) { - core.loader._loadOneSound_decodeData(name, data); - }, function (e) { - main.log(e); - core.material.sounds[name] = null; - }, null, 'arraybuffer'); - } - else { - var music = new Audio(); - music.src = 'project/sounds/' + name; - core.material.sounds[name] = music; - } + core.http('GET', 'project/sounds/' + name + "?v=" + main.version, null, function (data) { + core.loader._loadOneSound_decodeData(name, data); + }, function (e) { + main.log(e); + core.material.sounds[name] = null; + }, null, 'arraybuffer'); } loader.prototype._loadOneSound_decodeData = function (name, data) { diff --git a/libs/utils.js b/libs/utils.js index 7cd1ff71..1698c02e 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -392,6 +392,12 @@ utils.prototype.setTwoDigits = function (x) { return parseInt(x) < 10 ? "0" + x : x; } +utils.prototype.formatSize = function (size) { + if (size < 1024) return size + 'B'; + else if (size < 1024 * 1024) return (size/1024).toFixed(2) + "KB"; + else return (size/1024/1024).toFixed(2) + "MB"; +} + utils.prototype.formatBigNumber = function (x, onMap) { x = Math.floor(parseFloat(x)); if (!core.isset(x)) return '???'; @@ -1227,7 +1233,7 @@ utils.prototype.http = function (type, url, formData, success, error, mimeType, }; xhr.onprogress = function (e) { if (e.lengthComputable) { - if (onprogress) onprogress(e.loaded / e.total); + if (onprogress) onprogress(e.loaded, e.total); } } xhr.onabort = function () { diff --git a/main.js b/main.js index be30e993..6409434c 100644 --- a/main.js +++ b/main.js @@ -85,7 +85,7 @@ function main() { 'data', 'enemys', 'icons', 'maps', 'items', 'functions', 'events', 'plugins' ]; this.materials = [ - 'animates', 'enemys', 'items', 'npcs', 'terrains', 'enemy48', 'npc48' + 'animates', 'enemys', 'items', 'npcs', 'terrains', 'enemy48', 'npc48', 'icons' ]; this.statusBar = { diff --git a/v2.x-final更新.txt b/v2.x-final更新.txt index 680d4953..9d9991d1 100644 --- a/v2.x-final更新.txt +++ b/v2.x-final更新.txt @@ -53,7 +53,7 @@ 大屏幕下放大游戏界面 最近使用/最常使用的图块 loader并行加载 -合并items.js +(已完成!) 合并items.js 增加fonts目录,全塔属性增加fonts引用 ------------- From 47283d30a9469b689e8e6a7ccf77261bf664cfda Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Sun, 17 May 2020 10:42:00 +0800 Subject: [PATCH 08/16] =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=A2=9D=E5=A4=96?= =?UTF-8?q?=E7=9A=84=E5=AD=97=E4=BD=93=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/table/data.comment.js | 12 ++++++++++++ main.js | 14 ++++++++++++++ project/data.js | 3 +++ project/fonts/number.ttf | Bin 0 -> 4312 bytes styles.css | 2 +- v2.x-final更新.txt | 7 ++++--- 6 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 project/fonts/number.ttf diff --git a/_server/table/data.comment.js b/_server/table/data.comment.js index 4e6f5320..7e0a246f 100644 --- a/_server/table/data.comment.js +++ b/_server/table/data.comment.js @@ -91,6 +91,18 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "_docs": "本塔使用音效", "_data": "在此存放所有的SE,和文件名一致 \n音频名不能使用中文,不能带空格或特殊字符;可以直接改名拼音就好" }, + "fonts": { + "_leaf": true, + "_type": "material", + "_range": "editor.mode.checkUnique(thiseval)", + "_directory": "./project/fonts/", + "_transform": (function (one) { + if (one.endsWith(".ttf")) return one.substring(0, one.lastIndexOf('.')); + return null; + }).toString(), + "_docs": "本塔使用字体", + "_data": "在此存放所有可能使用的字体 \n 字体名不能使用中文,不能带空格或特殊字符" + }, "nameMap": { "_leaf": true, "_type": "textarea", diff --git a/main.js b/main.js index 6409434c..71421aca 100644 --- a/main.js +++ b/main.js @@ -215,6 +215,7 @@ main.prototype.init = function (mode, callback) { main.dom.levelChooseButtons.appendChild(span); }); main.createOnChoiceAnimation(); + main.importFonts(main.fonts); main.loadJs('libs', main.loadList, function () { main.core = core; @@ -371,6 +372,19 @@ main.prototype.selectButton = function (index) { } } +////// 创建字体 ////// +main.prototype.importFonts = function (fonts) { + if (!(fonts instanceof Array) || fonts.length == 0) return; + var style = document.createElement('style'); + style.type = 'text/css'; + var html = ''; + fonts.forEach(function (font) { + html += '@font-face { font-family: "'+font+'"; src: url("project/fonts/'+font+'.ttf") format("truetype")'; + }); + style.innerHTML = html; + document.body.appendChild(style); +} + main.prototype.listen = function () { ////// 窗口大小变化时 ////// diff --git a/project/data.js b/project/data.js index fad424a9..396be475 100644 --- a/project/data.js +++ b/project/data.js @@ -36,6 +36,9 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "bomb.mp3", "centerFly.mp3" ], + "fonts": [ + "number" + ], "nameMap": { "背景图.jpg": "bg.jpg", "背景音乐.mp3": "bgm.mp3" diff --git a/project/fonts/number.ttf b/project/fonts/number.ttf new file mode 100644 index 0000000000000000000000000000000000000000..bcf90fae15a92f26dae9f2bf31c86319c458ea77 GIT binary patch literal 4312 zcmchbe@xZa6~NE;fjr>B;{iSp0ePZ8iwKAg;Tzn-ox35h$nw*Tgm^ zZD!i6>$-JK)}~8cQ;S`eCTiW*)i|ei^JlgGER@=+P_bHFYug0QKKJ{+dyc4hneM}FBYGHN4pPSn>`*N*Nu>|yKZnhJR4h@+gAC+ zY%TD*>8H^ZZr#uPbjObpDnAu(q%A(QBV(;0!cV;#vDVWE>l2SX!=C5q)2s4|XS0Zw zM67k>_H6sdZ%h1g7rrsz!Amn~Lx==rPl~b6$V7L9pNyL7k!UmLKM>a8@U^QtS{N0Q zb&;Zr*h8Ph(`9TC>*YxE2-#ecbcdx#j8E(l{QBU+v`4&>=g<*SE`<&q$(ZF1Jqr3k zhmL}N$f3Ph_LxIQvx5!rR%8t8l*=;?ZApq8bZC$G<*Y+TNQ+!`=txPiY8-kLbcaJn zLI2#Ly%J^p-l3yqtktc-HWjny>| zET~(ty0N;|c&x5sQr_qeO2Ys#5#$KDH34V&bqp#O-IWbCRs#87Gm_ z!!r^z{5s|2kdXarArqp1bBLstqR8iHiIG_HG|sMyo6q_G_m;Edux3G9k8>C-!@w7e z`LrI9s4=v5k!S=lmF7@1V4il{EFGLY$7t!a8rp2yGFm%r6KyH2!JZ_N$ur>dMoCnZ z*M+!f!$-RiALA9TH^v43b$mi>v_wb8x)AUg-seK1FGgZwT-KKqXZSc5lH+3~Ha6ac z(bw@ozfXKVzY8e|hEH%IH6c#o;#@XiOu+B~7t)jb;`b-HkeQqy2?@zAgn|JH1cEM% zPf3)-#1t2D(vl@PIn9OqjGzRA87>rNrAlgQmJ220($t@ro zGWDhhv|G>VSv>>3uZQ&u{X&Ygls$Z)*Yp~dn8b`CSt2jV{TytwWgJx+sb4a(A3P3j z(dGIZeO9+y52AmAOqJV=CAuH&P5K;K59>$zk&)Sb)C|3y`X}(X?qQ`fMj}gDWv|@J zK{tuREJW^)WA!A{rLXE{Ey9jt_~EngTQh8_Z9e|EpUr?v^qsl{@r4 zIUs|K7yYxnkN5Om3Cb8rmE1wqs4@PWo=4XqeMK+JH;|>-(q8S=_Xt`SA$)^XjW(kPu%w1ODa9r(O(Qb` zR}I-^o+Fsy9bwwCeuuhrY#1jKzSwg)(Xx}Oo=g6j_$(tn_j$VH*0A=Go_B&WEH=*KYjhf^VqWl> zteS`;sVhB+%ikfXF6u?xp09%#7faC68Pm>P@Y`SoSC%x%ww?SGwXj9Xta(y4nBnOf zT%+f4g`a(ieG0s(J4mb^!^>E33Tx~m$+~dtS-qlHkWY|oE<3YiE?1B$C?TM|TtY-% zqcqafa^HzZvHk9@DdBx-}PSx}CkF*&#sgY}9Gm!D00WvqK|8N0xm;%;P3#Zc_le z{#Z|QkDN$t82%FcF;mr+Y$EU0k{98uGj1442FuFRzgs^hr(Og*WglkE;GA0~-y;S^ z1Fw3zlus&Mt&i!W`W^H>B0rS1oZ0hPc7s`nY+g!SX4!F>KsmbFhy0CTSk{H5!zEwo z95!(l3nbY!m4jE3Bv~(G*-7Gb+DXoUm~x1-eUgLq0ZGuSoF?Yg)5XY7IN##64I{P_ zm$yxFla_v7C%18v?!eoVx#8YQ9`L?r<`q3iL_>C7WD?E&ME)0e|JUfdhzot>4b@E5 zoAV1m{yyjEA>tX1q=`E+xw#g6;5&+tgcNUpXp`#ifks&DFF^`Dgf zS^bb+b5%7(QpEQ_8AWDZmgdD3;w3gk7I9%LH%gefo9x(2e)dpqfJYjLMZy1|Mm+P; z-;e)JqWw5Nzf3*`?UU{nc42&VVUUk+4u&8-lgRbO@-*KKZIo`IeV!Y8o??I7!MDI( z^0NS}!FL6Cy_hq$2OADz^;JHey;@*hK;v%LlObxzyt}d-Pj^!_y9T%0W6aJjXuq+V zI$SEd`S@HQ3)x|=5fPI!x(nQ Date: Sun, 17 May 2020 11:11:31 +0800 Subject: [PATCH 09/16] =?UTF-8?q?blockly=E8=A7=A3=E6=9E=90=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/editor_blockly.js | 40 ++++++++++++++++++++++++++++++--------- editor-mobile.html | 2 +- editor.html | 2 +- v2.x-final更新.txt | 2 +- 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 75754601..8b23bce8 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -398,22 +398,22 @@ function omitedcheckUpdateFunction(event) { } } if(editor_blockly.workspace.topBlocks_.length>=2){ - codeAreaHL.setValue('入口方块只能有一个'); + editor_blockly.setValue('入口方块只能有一个'); return; } var eventType = document.getElementById('entryType').value; if(editor_blockly.workspace.topBlocks_.length==1){ var blockType = editor_blockly.workspace.topBlocks_[0].type; if(blockType!==eventType+'_m'){ - codeAreaHL.setValue('入口方块类型错误'); + editor_blockly.setValue('入口方块类型错误'); return; } } try { var code = Blockly.JavaScript.workspaceToCode(workspace).replace(/\\\\(i|c|d|e|z)/g, '\\\\\\\\$1'); - codeAreaHL.setValue(code); + editor_blockly.setValue(code); } catch (error) { - codeAreaHL.setValue(String(error)); + editor_blockly.setValue(String(error)); if (error instanceof OmitedError){ var blockName = error.blockName; var varName = error.varName; @@ -529,13 +529,19 @@ function omitedcheckUpdateFunction(event) { xhr.open('GET', '_server/MotaAction.g4', true); xhr.send(null); - codeAreaHL = CodeMirror.fromTextArea(document.getElementById("codeArea"), { + var codeAreaHL = CodeMirror.fromTextArea(document.getElementById("codeArea"), { lineNumbers: true, matchBrackets: true, lineWrapping: true, continueComments: "Enter", - extraKeys: {"Ctrl-Q": "toggleComment"} + extraKeys: {"Ctrl-Q": "toggleComment"}, }); + codeAreaHL.on('changes', function () { + editor_blockly.highlightParse(!changeFromBlockly); + changeFromBlockly = false; + }); + var changeFromBlockly = false; + var shouldNotifyParse = false; editor_blockly.showXML = function () { var xml = Blockly.Xml.workspaceToDom(editor_blockly.workspace); @@ -561,6 +567,11 @@ function omitedcheckUpdateFunction(event) { } } + editor_blockly.setValue = function (value) { + changeFromBlockly = true; + codeAreaHL.setValue(value); + } + editor_blockly.parse = function () { MotaActionFunctions.parse( eval('obj=' + codeAreaHL.getValue().replace(/[<>&]/g, function (c) { @@ -580,7 +591,7 @@ function omitedcheckUpdateFunction(event) { var type = args.type; if (!type) return false; editor_blockly.id = id_; - codeAreaHL.setValue(input.value); + editor_blockly.setValue(input.value); document.getElementById('entryType').value = type; editor_blockly.parse(); editor_blockly.show(); @@ -604,6 +615,13 @@ function omitedcheckUpdateFunction(event) { } } + var blocklyParseBtn = document.getElementById('blocklyParse'); + editor_blockly.highlightParse = function (shouldHighLight) { + if (shouldNotifyParse == shouldHighLight) return; + shouldNotifyParse = shouldHighLight; + blocklyParseBtn.style.background = shouldNotifyParse ? '#FFCCAA' : 'unset'; + } + editor_blockly.cancel = function () { editor_blockly.id = ''; editor_blockly.hide(); @@ -614,15 +632,19 @@ function omitedcheckUpdateFunction(event) { editor_blockly.id = ''; return; } + if (shouldNotifyParse) { + alert('你尚未解析修改后的内容,请进行解析或放弃操作'); + return; + } if(editor_blockly.workspace.topBlocks_.length>=2){ - codeAreaHL.setValue('入口方块只能有一个'); + editor_blockly.setValue('入口方块只能有一个'); return; } var eventType = document.getElementById('entryType').value; if(editor_blockly.workspace.topBlocks_.length==1){ var blockType = editor_blockly.workspace.topBlocks_[0].type; if(blockType!==eventType+'_m'){ - codeAreaHL.setValue('入口方块类型错误'); + editor_blockly.setValue('入口方块类型错误'); return; } } diff --git a/editor-mobile.html b/editor-mobile.html index 143408e6..2b9bf8b0 100644 --- a/editor-mobile.html +++ b/editor-mobile.html @@ -219,7 +219,7 @@ - +
diff --git a/editor.html b/editor.html index 81adbb75..e29e5f85 100644 --- a/editor.html +++ b/editor.html @@ -215,7 +215,7 @@ - +
diff --git a/v2.x-final更新.txt b/v2.x-final更新.txt index 96a17c43..df70b9ae 100644 --- a/v2.x-final更新.txt +++ b/v2.x-final更新.txt @@ -55,7 +55,7 @@ (已完成!) loader并行加载 合并items.js (已完成!) 增加fonts目录,全塔属性增加fonts引用 -右边框输入完后解析按钮高亮 +(已完成!) 右边框输入完后解析按钮高亮 ------------- From 348aaeb85751a423ed404345e29b0894efd06f11 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Sun, 17 May 2020 11:52:09 +0800 Subject: [PATCH 10/16] =?UTF-8?q?=E5=8E=9F=E7=94=9F=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=9C=86=E8=A7=92=E8=BE=B9=E6=A1=86API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/MotaAction.g4 | 18 +++++---- libs/ui.js | 87 ++++++++++++++++++++++++++++++++----------- v2.x-final更新.txt | 2 +- 3 files changed, 77 insertions(+), 30 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 95e2450e..604ec50a 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -2242,29 +2242,31 @@ return code; */; fillRect_s - : '绘制矩形' '起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString '颜色' ColorString? Colour Newline + : '绘制矩形' '起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString '圆角半径' PosString? '颜色' ColorString? 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] +default : ["0","0","flag:x","300","","",null] ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : ''; -var code = '{"type": "fillRect", "x": '+PosString_0+', "y": '+PosString_1+', "width": '+PosString_2+', "height": '+PosString_3+ColorString_0+'},\n'; +PosString_4 = PosString_4 ? (', "radius": '+PosString_4) : ''; +var code = '{"type": "fillRect", "x": '+PosString_0+', "y": '+PosString_1+', "width": '+PosString_2+', "height": '+PosString_3+PosString_4+ColorString_0+'},\n'; return code; */; strokeRect_s - : '绘制矩形边框' '起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString '颜色' ColorString? Colour '线宽' IntString? Newline + : '绘制矩形边框' '起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString '圆角半径' PosString? '颜色' ColorString? Colour '线宽' IntString? 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,""] +default : ["0","0","flag:x","300","","",null,""] ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : ''; IntString_0 = IntString_0 ? (', "lineWidth": '+IntString_0) : ''; -var code = '{"type": "strokeRect", "x": '+PosString_0+', "y": '+PosString_1+', "width": '+PosString_2+', "height": '+PosString_3+ColorString_0+IntString_0+'},\n'; +PosString_4 = PosString_4 ? (', "radius": '+PosString_4) : ''; +var code = '{"type": "strokeRect", "x": '+PosString_0+', "y": '+PosString_1+', "width": '+PosString_2+', "height": '+PosString_3+PosString_4+ColorString_0+IntString_0+'},\n'; return code; */; @@ -3643,13 +3645,13 @@ ActionParser.prototype.parseAction = function() { case "fillRect": // 绘制矩形 data.style = this.Colour(data.style); this.next = MotaActionBlocks['fillRect_s'].xmlText([ - data.x, data.y, data.width, data.height, data.style, 'rgba('+data.style+')', this.next + data.x, data.y, data.width, data.height, data.radius, data.style, 'rgba('+data.style+')', this.next ]); break; case "strokeRect": // 绘制矩形边框 data.style = this.Colour(data.style); this.next = MotaActionBlocks['strokeRect_s'].xmlText([ - data.x, data.y, data.width, data.height, data.style, 'rgba('+data.style+')', data.lineWidth, this.next + data.x, data.y, data.width, data.height, data.radius, data.style, 'rgba('+data.style+')', data.lineWidth, this.next ]); break; case "drawLine": // 绘制线段 diff --git a/libs/ui.js b/libs/ui.js index 94a0a1e1..b0771b30 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -134,7 +134,65 @@ ui.prototype.fillRect = function (name, x, y, width, height, style) { 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); + if (data.radius) { + this.fillRoundRect('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.width), core.calValue(data.height), core.calValue(data.radius), data.style); + } else { + 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); + if (lineWidth) core.setLineWidth(name, lineWidth); + var ctx = this.getContextByName(name); + if (ctx) ctx.strokeRect(x, y, width, height); +} + +ui.prototype._uievent_strokeRect = function (data) { + this._createUIEvent(); + if (data.radius) { + this.strokeRoundRect('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.width), core.calValue(data.height), + core.calValue(data.radius), data.style, data.lineWidth); + } else { + 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.fillRoundRect = function (name, x, y, width, height, radius, style) { + if (style) core.setFillStyle(name, style); + var ctx = this.getContextByName(name); + if (ctx) { + this._roundRect_buildPath(ctx, x, y, width, height, radius); + ctx.fill(); + } +} + +////// 在某个canvas上绘制一个圆角矩形的边框 ////// +ui.prototype.strokeRoundRect = function (name, x, y, width, height, radius, style, lineWidth) { + if (style) core.setStrokeStyle(name, style); + if (lineWidth) core.setLineWidth(name, lineWidth); + var ctx = this.getContextByName(name); + if (ctx) { + this._roundRect_buildPath(ctx, x, y, width, height, radius); + ctx.stroke(); + } +} + + +ui.prototype._roundRect_buildPath = function (ctx, x, y, width, height, radius) { + ctx.beginPath(); + ctx.moveTo(x + radius, y); + ctx.lineTo(x + width - radius, y); + ctx.quadraticCurveTo(x + width, y, x + width, y + radius); + ctx.lineTo(x + width, y + height - radius); + ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height); + ctx.lineTo(x + radius, y + height); + ctx.quadraticCurveTo(x, y + height, x, y + height - radius); + ctx.lineTo(x, y + radius); + ctx.quadraticCurveTo(x, y, x + radius, y); + ctx.closePath(); } ////// 在某个canvas上绘制一个多边形 ////// @@ -158,19 +216,6 @@ ui.prototype._uievent_fillPolygon = function (data) { this.fillPolygon('uievent', data.nodes, data.style); } -////// 在某个canvas上绘制一个矩形的边框 ////// -ui.prototype.strokeRect = function (name, x, y, width, height, style, lineWidth) { - if (style) core.setStrokeStyle(name, style); - if (lineWidth) core.setLineWidth(name, lineWidth); - var ctx = this.getContextByName(name); - 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.strokePolygon = function (name, nodes, style, lineWidth) { if (style) core.setStrokeStyle(name, style); @@ -1496,8 +1541,8 @@ ui.prototype._drawChoices_drawChoices = function (choices, isWindowSkin, hPos, v this.drawWindowSelector(core.status.textAttribute.background, this.HPIXEL - len/2 - 5, vPos.choice_top + 32 * core.status.event.selection - 20, len + 10, 28); else - core.strokeRect('ui', this.HPIXEL - len/2 - 5, vPos.choice_top + 32 * core.status.event.selection - 20, - len+10, 28, "#FFD700", 2); + core.strokeRoundRect('ui', this.HPIXEL - len/2 - 5, vPos.choice_top + 32 * core.status.event.selection - 20, + len+10, 28, 6, "#FFD700", 2); } } @@ -1536,7 +1581,7 @@ ui.prototype.drawConfirmBox = function (text, yesCallback, noCallback) { if (isWindowSkin) this.drawWindowSelector(core.status.textAttribute.background, strokeLeft, rect.bottom-35-20, len+10, 28); else - core.strokeRect('ui', strokeLeft, rect.bottom-35-20, len+10, 28, "#FFD700", 2); + core.strokeRoundRect('ui', strokeLeft, rect.bottom-35-20, len+10, 28, 6, "#FFD700", 2); } } @@ -1750,7 +1795,7 @@ ui.prototype._drawBook_drawOne = function (floorId, index, enemy, pageinfo, sele this._drawBook_drawName(index, enemy, top, left, name_width); this._drawBook_drawContent(index, enemy, top, left + name_width); if (selected) - core.strokeRect('ui', 10, top + 1, this.PIXEL - 10 * 2, pageinfo.per_height, '#FFD700'); + core.strokeRoundRect('ui', 10, top + 1, this.PIXEL - 10 * 2, pageinfo.per_height, 10, '#FFD700'); } ui.prototype._drawBook_drawBox = function (index, enemy, top, pageinfo) { @@ -2273,7 +2318,7 @@ ui.prototype._drawToolbox_drawContent = function (info, line, items, page, drawC if (drawCount) core.fillText('ui', core.itemCount(item), 64 * (i % this.HSIZE) + 56, yoffset + 33, '#FFFFFF', this._buildFont(14, true)); if (info.selectId == item) - core.strokeRect('ui', 64 * (i % this.HSIZE) + 17, yoffset - 4, 40, 40, '#FFD700'); + core.strokeRoundRect('ui', 64 * (i % this.HSIZE) + 17, yoffset - 4, 40, 40, 6, '#FFD700'); } } @@ -2448,7 +2493,7 @@ ui.prototype._drawEquipbox_drawEquiped = function (info, line) { core.drawImage('ui', core.material.images.items, 0, 32 * icon, 32, 32, offset_image, y, 32, 32); } core.fillText('ui', info.allEquips[i] || "未知", offset_text, y + 27, '#FFFFFF', this._buildFont(16, true)) - core.strokeRect('ui', offset_image - 4, y - 4, 40, 40, info.index==i?'#FFD700':"#FFFFFF"); + core.strokeRoundRect('ui', offset_image - 4, y - 4, 40, 40, 6, info.index==i?'#FFD700':"#FFFFFF"); } } @@ -2631,7 +2676,7 @@ ui.prototype.drawKeyBoard = function () { if (isWindowSkin) this.drawWindowSelector(core.status.textAttribute.background, this.HPIXEL + 92, offset - 22, 72, 27); else - core.strokeRect('ui', this.HPIXEL + 92, offset - 22, 72, 27, "#FFD700", 2); + core.strokeRoundRect('ui', this.HPIXEL + 92, offset - 22, 72, 27, 6, "#FFD700", 2); } ////// 绘制状态栏 ///// diff --git a/v2.x-final更新.txt b/v2.x-final更新.txt index df70b9ae..f795c31f 100644 --- a/v2.x-final更新.txt +++ b/v2.x-final更新.txt @@ -43,7 +43,7 @@ (已完成!) 动画/音乐/音效自动补全 (已完成!) 重构全局商店! (已完成!) 读档时色调数据丢失 -圆角边框 +(已完成!) 圆角边框 像素高分辨率问题 (已完成!) 道具效果优化,删除部分道具相关的开关 (已完成!) 素材列表选择 From d1a1f223f160de9244a5690047d47fb1967cbc9c Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Sun, 17 May 2020 12:22:03 +0800 Subject: [PATCH 11/16] =?UTF-8?q?=E7=BB=98=E5=88=B6=E6=A4=AD=E5=9C=86API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/MotaAction.g4 | 46 ++++++++++++++++++++------------------- _server/editor_blockly.js | 6 ++--- libs/events.js | 9 ++++---- libs/ui.js | 28 ++++++++++++++++-------- 4 files changed, 51 insertions(+), 38 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 604ec50a..a23e90fb 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -430,8 +430,8 @@ action | drawArrow_s | fillPolygon_s | strokePolygon_s - | fillCircle_s - | strokeCircle_s + | fillEllipse_s + | strokeEllipse_s | drawImage_s | drawImage_1_s | drawIcon_s @@ -2339,30 +2339,32 @@ var code = '{"type": "strokePolygon", "nodes": ['+EvalString_0+']'+ColorString_0 return code; */; -fillCircle_s - : '绘制圆' '圆心' 'x' PosString 'y' PosString '半径' PosString '颜色' ColorString? Colour Newline +fillEllipse_s + : '绘制椭圆' '中心' 'x' PosString 'y' PosString '长半径' PosString '短半径' PosString '顺时针旋转度数' PosString? '颜色' ColorString? Colour Newline -/* fillCircle_s -tooltip : fillCircle:绘制圆 -helpUrl : https://h5mota.com/games/template/_docs/#/event?id=fillCircle%ef%bc%9a%e7%bb%98%e5%88%b6%e5%9c%86 +/* fillEllipse_s +tooltip : fillEllipse:绘制椭圆 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=fillEllipse%ef%bc%9a%e7%bb%98%e5%88%b6%e5%9c%86 colour : this.subColor -default : ["0","0","100","",null] +default : ["0","0","100","100","0","",null] ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : ''; -var code = '{"type": "fillCircle", "x": '+PosString_0+', "y": '+PosString_1+', "r": '+PosString_2+ColorString_0+'},\n'; +PosString_4 = PosString_4 ? (', "angle": ' + PosString_4) : ''; +var code = '{"type": "fillEllipse", "x": '+PosString_0+', "y": '+PosString_1+', "a": '+PosString_2+', "b": '+PosString_3+PosString_4+ColorString_0+'},\n'; return code; */; -strokeCircle_s - : '绘制圆边框' '圆心' 'x' PosString 'y' PosString '半径' PosString '颜色' ColorString? Colour '线宽' IntString? Newline +strokeEllipse_s + : '绘制椭圆边框' '中心' 'x' PosString 'y' PosString '长半径' PosString '短半径' PosString '顺时针旋转度数' PosString? '颜色' ColorString? Colour '线宽' IntString? Newline -/* strokeCircle_s -tooltip : strokeCircle:绘制圆边框 -helpUrl : https://h5mota.com/games/template/_docs/#/event?id=strokeCircle%ef%bc%9a%e7%bb%98%e5%88%b6%e5%9c%86%e8%be%b9%e6%a1%86 +/* strokeEllipse_s +tooltip : strokeEllipse:绘制椭圆边框 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=strokeEllipse%ef%bc%9a%e7%bb%98%e5%88%b6%e5%9c%86%e8%be%b9%e6%a1%86 colour : this.subColor -default : ["0","0","100","",null,""] +default : ["0","0","100","100","0","",null,""] ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : ''; IntString_0 = IntString_0 ? (', "lineWidth": '+IntString_0) : ''; -var code = '{"type": "strokeCircle", "x": '+PosString_0+', "y": '+PosString_1+', "r": '+PosString_2+ColorString_0+IntString_0+'},\n'; +PosString_4 = PosString_4 ? (', "angle": ' + PosString_4) : ''; +var code = '{"type": "strokeEllipse", "x": '+PosString_0+', "y": '+PosString_1+', "a": '+PosString_2+', "b": '+PosString_3+PosString_4+ColorString_0+IntString_0+'},\n'; return code; */; @@ -3688,16 +3690,16 @@ ActionParser.prototype.parseAction = function() { x_str.join(','), y_str.join(','), data.style, 'rgba('+data.style+')', data.lineWidth, this.next ]); break; - case "fillCircle": // 绘制圆 + case "fillEllipse": // 绘制椭圆 data.style = this.Colour(data.style); - this.next = MotaActionBlocks['fillCircle_s'].xmlText([ - data.x, data.y, data.r, data.style, 'rgba('+data.style+')', this.next + this.next = MotaActionBlocks['fillEllipse_s'].xmlText([ + data.x, data.y, data.a, data.b, data.angle, data.style, 'rgba('+data.style+')', this.next ]); break; - case "strokeCircle": // 绘制圆边框 + case "strokeEllipse": // 绘制椭圆边框 data.style = this.Colour(data.style); - this.next = MotaActionBlocks['strokeCircle_s'].xmlText([ - data.x, data.y, data.r, data.style, 'rgba('+data.style+')', data.lineWidth, this.next + this.next = MotaActionBlocks['strokeEllipse_s'].xmlText([ + data.x, data.y, data.a, data.b, data.angle, data.style, 'rgba('+data.style+')', data.lineWidth, this.next ]); break; case "drawImage": // 绘制图片 diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 8b23bce8..f67bca45 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -202,8 +202,8 @@ editor_blockly = function () { MotaActionBlocks['drawArrow_s'].xmlText(), MotaActionBlocks['fillPolygon_s'].xmlText(), MotaActionBlocks['strokePolygon_s'].xmlText(), - MotaActionBlocks['fillCircle_s'].xmlText(), - MotaActionBlocks['strokeCircle_s'].xmlText(), + MotaActionBlocks['fillEllipse_s'].xmlText(), + MotaActionBlocks['strokeEllipse_s'].xmlText(), MotaActionBlocks['drawImage_s'].xmlText(), MotaActionBlocks['drawImage_1_s'].xmlText(), MotaActionBlocks['drawIcon_s'].xmlText(), @@ -706,7 +706,7 @@ function omitedcheckUpdateFunction(event) { var types = [ "previewUI_s", "clearMap_s", "clearMap_1_s", "setAttribute_s", "fillText_s", "fillBoldText_s", "fillRect_s", "strokeRect_s", "drawLine_s", - "drawArrow_s", "fillPolygon_s", "strokePolygon_s", "fillCircle_s", "strokeCircle_s", + "drawArrow_s", "fillPolygon_s", "strokePolygon_s", "fillEllipse_s", "strokeEllipse_s", "drawImage_s", "drawImage_1_s", "drawIcon_s", "drawBackground_s", "drawSelector_s", "drawSelector_1_s", "waitContext_2" ]; diff --git a/libs/events.js b/libs/events.js index 2a613771..d0982ade 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1122,11 +1122,12 @@ events.prototype.__precompile_getArray = function () { "setValue", "setEnemy", "setFloor", "setGlobalValue", ]; var uievents = [ - "clearMap", "fillText", "fillBoldText", "fillRect", "strokeRect", "strokeCircle", + "clearMap", "fillText", "fillBoldText", "fillRect", "strokeRect", "fillEllipse", "strokeEllipse", "drawIcon", "drawSelector", "drawBackground", ]; var others = { - "strokeCircle": ["r"], + "fillEllipse": ["a", "b"], + "strokeEllipse": ["a", "b"], "drawLine": ["x1", "y1", "x2", "y2"], "drawArrow": ["x1", "y1", "x2", "y2"], "drawImage": ["x", "y", "w", "h", "x1", "y1", "w1", "h1"], @@ -2213,11 +2214,11 @@ events.prototype._precompile_strokePolygon = function (data) { return data; } -events.prototype._action_fillCircle = function (data, x, y, prefix) { +events.prototype._action_fillEllipse = function (data, x, y, prefix) { this.__action_doUIEvent(data); } -events.prototype._action_strokeCircle = function (data, x, y, prefix) { +events.prototype._action_strokeEllipse = function (data, x, y, prefix) { this.__action_doUIEvent(data); } diff --git a/libs/ui.js b/libs/ui.js index b0771b30..642a4776 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -238,35 +238,45 @@ ui.prototype._uievent_strokePolygon = function (data) { this.strokePolygon('uievent', data.nodes, data.style, data.lineWidth); } -////// 在某个canvas上绘制一个圆 ////// -ui.prototype.fillCircle = function (name, x, y, r, style) { +////// 在某个canvas上绘制一个椭圆 ////// +ui.prototype.fillEllipse = function (name, x, y, a, b, angle, style) { if (style) core.setFillStyle(name, style); var ctx = this.getContextByName(name); if (!ctx) return; ctx.beginPath(); - ctx.arc(x, y, r, 0, 2*Math.PI); + ctx.ellipse(x, y, a, b, angle, 0, 2*Math.PI); ctx.fill(); } -ui.prototype._uievent_fillCircle = function (data) { +ui.prototype.fillCircle = function (name, x, y, r, style) { + return this.fillEllipse(name, x, y, r, r, 0, style); +} + +ui.prototype._uievent_fillEllipse = function (data) { this._createUIEvent(); - this.fillCircle('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.r), data.style); + this.fillEllipse('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.a), + core.calValue(data.b), (core.calValue(data.angle) || 0) * Math.PI / 180, data.style); } ////// 在某个canvas上绘制一个圆的边框 ////// -ui.prototype.strokeCircle = function (name, x, y, r, style, lineWidth) { +ui.prototype.strokeEllipse = function (name, x, y, a, b, angle, style, lineWidth) { if (style) core.setStrokeStyle(name, style); if (lineWidth) core.setLineWidth(name, lineWidth); var ctx = this.getContextByName(name); if (!ctx) return; ctx.beginPath(); - ctx.arc(x, y, r, 0, 2*Math.PI); + ctx.ellipse(x, y, a, b, angle, 0, 2*Math.PI); ctx.stroke(); } -ui.prototype._uievent_strokeCircle = function (data) { +ui.prototype.strokeCircle = function (name, x, y, r, style, lineWidth) { + return this.strokeEllipse(name, x, y, r, r, 0, style, lineWidth); +} + +ui.prototype._uievent_strokeEllipse = function (data) { this._createUIEvent(); - this.strokeCircle('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.r), data.style, data.lineWidth); + this.strokeEllipse('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.a), + core.calValue(data.b), (core.calValue(data.angle) || 0) * Math.PI / 180, data.style, data.lineWidth); } ////// 在某个canvas上绘制一条线 ////// From 1feccfc185d241c6b3da94639bf29076f9ab3137 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Sun, 17 May 2020 13:29:57 +0800 Subject: [PATCH 12/16] =?UTF-8?q?=E7=BB=98=E5=88=B6=E6=89=87=E5=BD=A2?= =?UTF-8?q?=E5=92=8C=E5=BC=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/MotaAction.g4 | 43 +++++++++++++++++++++++++++++++++++++++ _server/editor_blockly.js | 4 +++- libs/events.js | 12 ++++++++++- libs/ui.js | 33 ++++++++++++++++++++++++++++++ v2.x-final更新.txt | 2 +- 5 files changed, 91 insertions(+), 3 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index a23e90fb..a7dc1ce6 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -432,6 +432,8 @@ action | strokePolygon_s | fillEllipse_s | strokeEllipse_s + | fillArc_s + | strokeArc_s | drawImage_s | drawImage_1_s | drawIcon_s @@ -2368,6 +2370,35 @@ var code = '{"type": "strokeEllipse", "x": '+PosString_0+', "y": '+PosString_1+' return code; */; +fillArc_s + : '绘制扇形' '中心' 'x' PosString 'y' PosString '半径' PosString '起点角度' PosString '终点角度' PosString '颜色' ColorString? Colour Newline + +/* fillArc_s +tooltip : fillArc:绘制扇形 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=fillEllipse%ef%bc%9a%e7%bb%98%e5%88%b6%e5%9c%86 +colour : this.subColor +default : ["0","0","100","0","90","",null,""] +ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : ''; +var code = '{"type": "fillArc", "x": '+PosString_0+', "y": '+PosString_1+', "r": '+PosString_2+', "start": '+PosString_3+', "end": '+PosString_4+ColorString_0+'},\n'; +return code; +*/; + + +strokeArc_s + : '绘制弧' '中心' 'x' PosString 'y' PosString '半径' PosString '起点角度' PosString '终点角度' PosString '颜色' ColorString? Colour '线宽' IntString? Newline + +/* strokeArc_s +tooltip : strokeArc:绘制弧 +helpUrl : https://h5mota.com/games/template/_docs/#/event?id=fillEllipse%ef%bc%9a%e7%bb%98%e5%88%b6%e5%9c%86 +colour : this.subColor +default : ["0","0","100","0","90","",null,""] +ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : ''; +IntString_0 = IntString_0 ? (', "lineWidth": '+IntString_0) : ''; +var code = '{"type": "strokeArc", "x": '+PosString_0+', "y": '+PosString_1+', "r": '+PosString_2+', "start": '+PosString_3+', "end": '+PosString_4+ColorString_0+IntString_0+'},\n'; +return code; +*/; + + drawImage_s : '绘制图片' EvalString '起点像素' 'x' PosString 'y' PosString '宽' PosString? '高' PosString? Newline @@ -3702,6 +3733,18 @@ ActionParser.prototype.parseAction = function() { data.x, data.y, data.a, data.b, data.angle, data.style, 'rgba('+data.style+')', data.lineWidth, this.next ]); break; + case "fillArc": // 绘制弧 + data.style = this.Colour(data.style); + this.next = MotaActionBlocks['fillArc_s'].xmlText([ + data.x, data.y, data.r, data.start, data.end, data.style, 'rgba('+data.style+')', this.next + ]); + break; + case "strokeArc": // 绘制弧 + data.style = this.Colour(data.style); + this.next = MotaActionBlocks['strokeArc_s'].xmlText([ + data.x, data.y, data.r, data.start, data.end, data.style, 'rgba('+data.style+')', data.lineWidth, this.next + ]); + break; case "drawImage": // 绘制图片 if (data.x1 != null && data.y1 != null && data.w1 != null && data.h1 != null) { this.next = MotaActionBlocks['drawImage_1_s'].xmlText([ diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index f67bca45..f3d74b07 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -204,6 +204,8 @@ editor_blockly = function () { MotaActionBlocks['strokePolygon_s'].xmlText(), MotaActionBlocks['fillEllipse_s'].xmlText(), MotaActionBlocks['strokeEllipse_s'].xmlText(), + MotaActionBlocks['fillArc_s'].xmlText(), + MotaActionBlocks['strokeArc_s'].xmlText(), MotaActionBlocks['drawImage_s'].xmlText(), MotaActionBlocks['drawImage_1_s'].xmlText(), MotaActionBlocks['drawIcon_s'].xmlText(), @@ -706,7 +708,7 @@ function omitedcheckUpdateFunction(event) { var types = [ "previewUI_s", "clearMap_s", "clearMap_1_s", "setAttribute_s", "fillText_s", "fillBoldText_s", "fillRect_s", "strokeRect_s", "drawLine_s", - "drawArrow_s", "fillPolygon_s", "strokePolygon_s", "fillEllipse_s", "strokeEllipse_s", + "drawArrow_s", "fillPolygon_s", "strokePolygon_s", "fillEllipse_s", "strokeEllipse_s", "fillArc_s", "strokeArc_s", "drawImage_s", "drawImage_1_s", "drawIcon_s", "drawBackground_s", "drawSelector_s", "drawSelector_1_s", "waitContext_2" ]; diff --git a/libs/events.js b/libs/events.js index d0982ade..b7601032 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1123,11 +1123,13 @@ events.prototype.__precompile_getArray = function () { ]; var uievents = [ "clearMap", "fillText", "fillBoldText", "fillRect", "strokeRect", "fillEllipse", "strokeEllipse", - "drawIcon", "drawSelector", "drawBackground", + "fillArc", "strokeArc", "drawIcon", "drawSelector", "drawBackground", ]; var others = { "fillEllipse": ["a", "b"], "strokeEllipse": ["a", "b"], + "fillArc": ["r", "start", "end"], + "strokeArc": ["r", "start", "end"], "drawLine": ["x1", "y1", "x2", "y2"], "drawArrow": ["x1", "y1", "x2", "y2"], "drawImage": ["x", "y", "w", "h", "x1", "y1", "w1", "h1"], @@ -2222,6 +2224,14 @@ events.prototype._action_strokeEllipse = function (data, x, y, prefix) { this.__action_doUIEvent(data); } +events.prototype._action_fillArc = function (data, x, y, prefix) { + this.__action_doUIEvent(data); +} + +events.prototype._action_strokeArc = function (data, x, y, prefix) { + this.__action_doUIEvent(data); +} + events.prototype._action_drawLine = function (data, x, y, prefix) { this.__action_doUIEvent(data); } diff --git a/libs/ui.js b/libs/ui.js index 642a4776..204796d0 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -279,6 +279,39 @@ ui.prototype._uievent_strokeEllipse = function (data) { core.calValue(data.b), (core.calValue(data.angle) || 0) * Math.PI / 180, data.style, data.lineWidth); } +ui.prototype.fillArc = function (name, x, y, r, start, end, style) { + if (style) core.setFillStyle(name, style); + var ctx = this.getContextByName(name); + if (!ctx) return; + ctx.beginPath(); + ctx.moveTo(x, y); + ctx.arc(x, y, r, start, end); + ctx.closePath(); + ctx.fill(); +} + +ui.prototype._uievent_fillArc = function (data) { + this._createUIEvent(); + this.fillArc('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.r), + (core.calValue(data.start) || 0) * Math.PI / 180, (core.calValue(data.end) || 0) * Math.PI / 180, data.style); +} + +ui.prototype.strokeArc = function (name, x, y, r, start, end, style, lineWidth) { + if (style) core.setStrokeStyle(name, style); + if (lineWidth) core.setLineWidth(name, lineWidth); + var ctx = this.getContextByName(name); + if (!ctx) return; + ctx.beginPath(); + ctx.arc(x, y, r, start, end); + ctx.stroke(); +} + +ui.prototype._uievent_strokeArc = function (data) { + this._createUIEvent(); + this.strokeArc('uievent', core.calValue(data.x), core.calValue(data.y), core.calValue(data.r), + (core.calValue(data.start) || 0) * Math.PI / 180, (core.calValue(data.end) || 0) * Math.PI / 180, data.style, data.lineWidth); +} + ////// 在某个canvas上绘制一条线 ////// ui.prototype.drawLine = function (name, x1, y1, x2, y2, style, lineWidth) { if (style) core.setStrokeStyle(name, style); diff --git a/v2.x-final更新.txt b/v2.x-final更新.txt index f795c31f..7cbd5c2f 100644 --- a/v2.x-final更新.txt +++ b/v2.x-final更新.txt @@ -134,7 +134,7 @@ 70. “显隐勇士”事件指令希望加个淡入淡出时间参数 (不处理,请用等待事件) 1. 希望给core.drawTip()和core.playSound()出个同步版本,目前只有异步版本,后者如果要模拟同步就得绑在一个透明动画上 (已完成!) 72. “绘制描边文本”事件希望加一个“描边颜色”参数,目前只能描黑边 -73. 画弧既然有现成的API,那建议也作为UI绘制事件提供。甚至希望提供画椭圆功能(长短轴水平或铅直的那种)参数为中心坐标和长短轴长度 +(已完成!) 73. 画弧既然有现成的API,那建议也作为UI绘制事件提供。甚至希望提供画椭圆功能(长短轴水平或铅直的那种)参数为中心坐标和长短轴长度 (已完成!) 74. “设置画布属性”的基准线建议增加'hanging'和'ideographic'这两种模式 (已完成!) 75. 建议修复“绘制多行文本”时行距比字号大不太多会导致各行下缘丢失的bug(加大行距又会导致第一行的纵坐标难以估计),此bug在道具商店和1.3倍行距英文看的很明显 (已完成!) 76. (来自群友)建议给第一代全局商店像“显示选择项”一样提供图标、颜色和出现条件 From a62e0119fdfd48d964d03e1cc3c9143144992adb Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Sun, 17 May 2020 17:04:41 +0800 Subject: [PATCH 13/16] =?UTF-8?q?=E9=A2=84=E8=A7=88=E9=9F=B3=E4=B9=90?= =?UTF-8?q?=E5=8F=AF=E6=8B=96=E5=8A=A8=E8=BF=9B=E5=BA=A6=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/editor_ui.js | 38 +++++++++++++++++++++++++++++++------- project/data.js | 4 +--- project/fonts/number.ttf | Bin 4312 -> 0 bytes server.py | 5 ++++- styles.css | 2 +- 5 files changed, 37 insertions(+), 12 deletions(-) delete mode 100644 project/fonts/number.ttf diff --git a/_server/editor_ui.js b/_server/editor_ui.js index 4965f1ea..cc9588ed 100644 --- a/_server/editor_ui.js +++ b/_server/editor_ui.js @@ -792,8 +792,10 @@ editor_ui_wrapper = function (editor) { } // 试听音频 if (one.endsWith('.mp3') || one.endsWith('.wmv') || one.endsWith('.ogg') || one.endsWith('.wav')) { - html += ""; - html += '
'; + html += ""; + html += `0:00 / 0:00
+ + `; } html += '
'; }); @@ -824,19 +826,41 @@ editor_ui_wrapper = function (editor) { } uievent._previewMaterialAudio = function (button) { - var br = button.nextElementSibling; + var span = button.nextElementSibling; + var br = span.nextElementSibling; var audio = br.nextElementSibling; + var progress = audio.nextElementSibling; if (br.style.display == 'none') { - button.innerText = '折叠'; + button.innerText = '暂停'; br.style.display = 'block'; - audio.style.display = 'block'; + progress.style.display = 'block'; + span.style.display = 'inline'; + audio.play(); } else { - button.innerText = '试听'; + button.innerText = '播放'; br.style.display = 'none'; - audio.style.display = 'none'; + progress.style.display='none'; + span.style.display = 'none'; + audio.pause(); } } + uievent._previewMaterialAudio_onTimeUpdate = function (audio) { + var _format = function (time) { return parseInt(time/60) + ":" + core.setTwoDigits(parseInt(time) % 60); } + if (audio.duration > 0) { + audio.previousElementSibling.previousElementSibling.innerText = _format(audio.currentTime) + " / " + _format(audio.duration); + audio.nextElementSibling.setAttribute('value', audio.currentTime / audio.duration); + } + } + + uievent._previewMaterialAudio_seek = function (element, event) { + var audio = element.previousElementSibling; + var value = event.offsetX * element.max / element.offsetWidth; + element.setAttribute("value", value); + audio.currentTime = audio.duration * value; + if (audio.paused) audio.play(); + } + editor.constructor.prototype.uievent=uievent; } \ No newline at end of file diff --git a/project/data.js b/project/data.js index 396be475..4f33fa23 100644 --- a/project/data.js +++ b/project/data.js @@ -36,9 +36,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "bomb.mp3", "centerFly.mp3" ], - "fonts": [ - "number" - ], + "fonts": [], "nameMap": { "背景图.jpg": "bg.jpg", "背景音乐.mp3": "bgm.mp3" diff --git a/project/fonts/number.ttf b/project/fonts/number.ttf deleted file mode 100644 index bcf90fae15a92f26dae9f2bf31c86319c458ea77..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4312 zcmchbe@xZa6~NE;fjr>B;{iSp0ePZ8iwKAg;Tzn-ox35h$nw*Tgm^ zZD!i6>$-JK)}~8cQ;S`eCTiW*)i|ei^JlgGER@=+P_bHFYug0QKKJ{+dyc4hneM}FBYGHN4pPSn>`*N*Nu>|yKZnhJR4h@+gAC+ zY%TD*>8H^ZZr#uPbjObpDnAu(q%A(QBV(;0!cV;#vDVWE>l2SX!=C5q)2s4|XS0Zw zM67k>_H6sdZ%h1g7rrsz!Amn~Lx==rPl~b6$V7L9pNyL7k!UmLKM>a8@U^QtS{N0Q zb&;Zr*h8Ph(`9TC>*YxE2-#ecbcdx#j8E(l{QBU+v`4&>=g<*SE`<&q$(ZF1Jqr3k zhmL}N$f3Ph_LxIQvx5!rR%8t8l*=;?ZApq8bZC$G<*Y+TNQ+!`=txPiY8-kLbcaJn zLI2#Ly%J^p-l3yqtktc-HWjny>| zET~(ty0N;|c&x5sQr_qeO2Ys#5#$KDH34V&bqp#O-IWbCRs#87Gm_ z!!r^z{5s|2kdXarArqp1bBLstqR8iHiIG_HG|sMyo6q_G_m;Edux3G9k8>C-!@w7e z`LrI9s4=v5k!S=lmF7@1V4il{EFGLY$7t!a8rp2yGFm%r6KyH2!JZ_N$ur>dMoCnZ z*M+!f!$-RiALA9TH^v43b$mi>v_wb8x)AUg-seK1FGgZwT-KKqXZSc5lH+3~Ha6ac z(bw@ozfXKVzY8e|hEH%IH6c#o;#@XiOu+B~7t)jb;`b-HkeQqy2?@zAgn|JH1cEM% zPf3)-#1t2D(vl@PIn9OqjGzRA87>rNrAlgQmJ220($t@ro zGWDhhv|G>VSv>>3uZQ&u{X&Ygls$Z)*Yp~dn8b`CSt2jV{TytwWgJx+sb4a(A3P3j z(dGIZeO9+y52AmAOqJV=CAuH&P5K;K59>$zk&)Sb)C|3y`X}(X?qQ`fMj}gDWv|@J zK{tuREJW^)WA!A{rLXE{Ey9jt_~EngTQh8_Z9e|EpUr?v^qsl{@r4 zIUs|K7yYxnkN5Om3Cb8rmE1wqs4@PWo=4XqeMK+JH;|>-(q8S=_Xt`SA$)^XjW(kPu%w1ODa9r(O(Qb` zR}I-^o+Fsy9bwwCeuuhrY#1jKzSwg)(Xx}Oo=g6j_$(tn_j$VH*0A=Go_B&WEH=*KYjhf^VqWl> zteS`;sVhB+%ikfXF6u?xp09%#7faC68Pm>P@Y`SoSC%x%ww?SGwXj9Xta(y4nBnOf zT%+f4g`a(ieG0s(J4mb^!^>E33Tx~m$+~dtS-qlHkWY|oE<3YiE?1B$C?TM|TtY-% zqcqafa^HzZvHk9@DdBx-}PSx}CkF*&#sgY}9Gm!D00WvqK|8N0xm;%;P3#Zc_le z{#Z|QkDN$t82%FcF;mr+Y$EU0k{98uGj1442FuFRzgs^hr(Og*WglkE;GA0~-y;S^ z1Fw3zlus&Mt&i!W`W^H>B0rS1oZ0hPc7s`nY+g!SX4!F>KsmbFhy0CTSk{H5!zEwo z95!(l3nbY!m4jE3Bv~(G*-7Gb+DXoUm~x1-eUgLq0ZGuSoF?Yg)5XY7IN##64I{P_ zm$yxFla_v7C%18v?!eoVx#8YQ9`L?r<`q3iL_>C7WD?E&ME)0e|JUfdhzot>4b@E5 zoAV1m{yyjEA>tX1q=`E+xw#g6;5&+tgcNUpXp`#ifks&DFF^`Dgf zS^bb+b5%7(QpEQ_8AWDZmgdD3;w3gk7I9%LH%gefo9x(2e)dpqfJYjLMZy1|Mm+P; z-;e)JqWw5Nzf3*`?UU{nc42&VVUUk+4u&8-lgRbO@-*KKZIo`IeV!Y8o??I7!MDI( z^0NS}!FL6Cy_hq$2OADz^;JHey;@*hK;v%LlObxzyt}d-Pj^!_y9T%0W6aJjXuq+V zI$SEd`S@HQ3)x|=5fPI!x(nQ Date: Sun, 17 May 2020 17:53:52 +0800 Subject: [PATCH 14/16] =?UTF-8?q?=E6=9C=80=E8=BF=91=E4=BD=BF=E7=94=A8/?= =?UTF-8?q?=E6=9C=80=E5=B8=B8=E4=BD=BF=E7=94=A8=E5=9B=BE=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/editor.js | 24 ++++++++++++++++++++++-- _server/editor_mappanel.js | 20 ++++++++++++++++++-- editor-mobile.html | 2 +- editor.html | 2 +- v2.x-final更新.txt | 3 ++- 5 files changed, 44 insertions(+), 7 deletions(-) diff --git a/_server/editor.js b/_server/editor.js index 56487191..8704fea1 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -55,6 +55,7 @@ function editor() { editModeSelect :document.getElementById('editModeSelect'), mid2 : document.getElementById('mid2'), clearLastUsedBtn: document.getElementById('clearLastUsedBtn'), + lastUsedTitle: document.getElementById('lastUsedTitle'), lastUsedDiv: document.getElementById('lastUsedDiv'), lastUsed: document.getElementById('lastUsed'), lastUsedCtx: document.getElementById('lastUsed').getContext('2d'), @@ -105,6 +106,7 @@ function editor() { lockMode: false, // 最近使用的图块 + lastUsedType: null, lastUsed: [], }; @@ -406,16 +408,33 @@ editor.prototype.updateMap = function () { this.updateLastUsedMap(); } +editor.prototype.setLastUsedType = function (type) { + if (type == editor.uivalues.lastUsedType) return; + editor.uivalues.lastUsedType = type; + var _buildHtml = function (type, text) { + if (type == null) return "" + text + ""; + else return `${text}`; + } + editor.dom.lastUsedTitle.innerHTML + = type == 'frequent' ? (_buildHtml('recent', '最近使用') + " | " + _buildHtml(null, '最常使用')) + : (_buildHtml(null, '最近使用') + " | " + _buildHtml('frequent', '最常使用')); + this.updateLastUsedMap(); +} + editor.prototype.updateLastUsedMap = function () { + var lastUsed = editor.uivalues.lastUsed.sort(function (a, b) { + return (b[editor.uivalues.lastUsedType] || 0) - (a[editor.uivalues.lastUsedType] || 0); + }); + // 绘制最近使用事件 var ctx = editor.dom.lastUsedCtx; ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); ctx.strokeStyle = 'rgba(255,128,0,0.85)'; ctx.lineWidth = 4; - for (var i = 0; i < editor.uivalues.lastUsed.length; ++i) { + for (var i = 0; i < lastUsed.length; ++i) { try { var x = i % core.__SIZE__, y = parseInt(i / core.__SIZE__); - var info = editor.uivalues.lastUsed[i]; + var info = lastUsed[i]; if (!info || !info.images) continue; if (info.isTile && core.material.images.tilesets[info.images]) { ctx.drawImage(core.material.images.tilesets[info.images], 32 * info.x, 32 * info.y, 32, 32, x*32, y*32, 32, 32); @@ -458,6 +477,7 @@ editor.prototype.drawInitData = function (icons) { // editor.uivalues.folded = true; editor.uivalues.foldPerCol = editor.config.get('foldPerCol', 50); // var imgNames = Object.keys(images); //还是固定顺序吧; + editor.setLastUsedType(editor.config.get('lastUsedType', 'recent')); editor.uivalues.lastUsed = editor.config.get("lastUsed", []); var imgNames = ["terrains", "animates", "enemys", "enemy48", "items", "npcs", "npc48", "autotile"]; diff --git a/_server/editor_mappanel.js b/_server/editor_mappanel.js index fcfb0fd3..e84a600d 100644 --- a/_server/editor_mappanel.js +++ b/_server/editor_mappanel.js @@ -257,7 +257,17 @@ editor_mappanel_wrapper = function (editor) { } // console.log(editor.map); if (editor.info.y != null) { - editor.uivalues.lastUsed = [editor.info].concat(editor.uivalues.lastUsed.filter(function (e) { return e.id != editor.info.id})); + var found = false; + editor.uivalues.lastUsed.forEach(function (one) { + if (one.id == editor.info.id) { + found = true; + one.recent = new Date().getTime(); + one.frequent = (one.frequent || 0) + 1; + } + }) + if (!found) { + editor.uivalues.lastUsed.push(Object.assign({}, editor.info, {recent: new Date().getTime(), frequent: 1})); + } editor.config.set("lastUsed", editor.uivalues.lastUsed); } editor.updateMap(); @@ -781,7 +791,13 @@ editor_mappanel_wrapper = function (editor) { var x = parseInt(px / 32), y = parseInt(py / 32); var index = x + core.__SIZE__ * y; if (index >= editor.uivalues.lastUsed.length) return; - editor.setSelectBoxFromInfo(editor.uivalues.lastUsed[index]); + var lastUsed = editor.uivalues.lastUsed.sort(function (a, b) { + return (b[editor.uivalues.lastUsedType] || 0) - (a[editor.uivalues.lastUsedType] || 0); + }); + var one = Object.assign({}, lastUsed[index]); + delete one['recent']; + delete one['frequent']; + editor.setSelectBoxFromInfo(one); return; } diff --git a/editor-mobile.html b/editor-mobile.html index 2b9bf8b0..dabddf55 100644 --- a/editor-mobile.html +++ b/editor-mobile.html @@ -320,7 +320,7 @@
-

最近使用的图块列表(Ctrl+滚轮放缩)

+

(Ctrl+滚轮放缩)

diff --git a/v2.x-final更新.txt b/v2.x-final更新.txt index 7cbd5c2f..cc988fc5 100644 --- a/v2.x-final更新.txt +++ b/v2.x-final更新.txt @@ -51,11 +51,12 @@ 地图拉框选择复制剪切删除 (已完成!) 素材替换 大屏幕下放大游戏界面 -最近使用/最常使用的图块 +(已完成!) 最近使用/最常使用的图块 (已完成!) loader并行加载 合并items.js (已完成!) 增加fonts目录,全塔属性增加fonts引用 (已完成!) 右边框输入完后解析按钮高亮 +32x48的门 ------------- From 7d9653f6e6521cdccb37c9ff5203c1db967d1ac0 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Sun, 17 May 2020 19:27:37 +0800 Subject: [PATCH 15/16] =?UTF-8?q?=E7=BD=AE=E9=A1=B6=E5=B8=B8=E7=94=A8?= =?UTF-8?q?=E5=9B=BE=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/editor.js | 5 +++++ _server/editor_listen.js | 1 + _server/editor_mappanel.js | 22 +++++++++++++++++----- editor.html | 2 +- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/_server/editor.js b/_server/editor.js index 8704fea1..6f282c4c 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -423,6 +423,7 @@ editor.prototype.setLastUsedType = function (type) { editor.prototype.updateLastUsedMap = function () { var lastUsed = editor.uivalues.lastUsed.sort(function (a, b) { + if ((a.istop || 0) != (b.istop || 0)) return (b.istop || 0) - (a.istop || 0); return (b[editor.uivalues.lastUsedType] || 0) - (a[editor.uivalues.lastUsedType] || 0); }); @@ -430,6 +431,7 @@ editor.prototype.updateLastUsedMap = function () { var ctx = editor.dom.lastUsedCtx; ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); ctx.strokeStyle = 'rgba(255,128,0,0.85)'; + ctx.fillStyle = 'rgba(255,0,0,0.85)'; ctx.lineWidth = 4; for (var i = 0; i < lastUsed.length; ++i) { try { @@ -444,6 +446,9 @@ editor.prototype.updateLastUsedMap = function () { var per_height = info.images.endsWith('48') ? 48 : 32; ctx.drawImage(core.material.images[info.images], 0, info.y * per_height, 32, per_height, x * 32, y * 32, 32, 32); } + if (info.istop) { + ctx.fillRect(32 * x, 32 * y + 24, 8, 8); + } if (selectBox.isSelected() && editor.info.id == info.id) { ctx.strokeRect(32 * x + 2, 32 * y + 2, 28, 28); } diff --git a/_server/editor_listen.js b/_server/editor_listen.js index 7fff8ff5..f5994f4e 100644 --- a/_server/editor_listen.js +++ b/_server/editor_listen.js @@ -35,6 +35,7 @@ editor_listen_wrapper = function (editor) { editor.dom.clearLoc.onmousedown = editor.uifunctions.clearLoc_click editor.dom.lastUsed.onmousedown = editor.uifunctions.lastUsed_click; + editor.dom.lastUsed.oncontextmenu = function (e) { e.preventDefault(); } editor.dom.clearLastUsedBtn.onclick = editor.uifunctions.clearLastUsedBtn_click; editor.dom.lockMode.onchange = editor.uifunctions.lockMode_onchange; diff --git a/_server/editor_mappanel.js b/_server/editor_mappanel.js index e84a600d..f6c7687c 100644 --- a/_server/editor_mappanel.js +++ b/_server/editor_mappanel.js @@ -792,21 +792,33 @@ editor_mappanel_wrapper = function (editor) { var index = x + core.__SIZE__ * y; if (index >= editor.uivalues.lastUsed.length) return; var lastUsed = editor.uivalues.lastUsed.sort(function (a, b) { + if ((a.istop || 0) != (b.istop || 0)) return (b.istop || 0) - (a.istop || 0); return (b[editor.uivalues.lastUsedType] || 0) - (a[editor.uivalues.lastUsedType] || 0); }); + + if (e.button == 2) { + lastUsed[index].istop = lastUsed[index].istop ? 0 : 1; + printf("已"+(lastUsed[index].istop ? '置顶' : '取消置顶')+"该图块"); + editor.config.set('lastUsed', editor.uivalues.lastUsed); + editor.updateLastUsedMap(); + return false; + } var one = Object.assign({}, lastUsed[index]); delete one['recent']; delete one['frequent']; + delete one['istop']; editor.setSelectBoxFromInfo(one); - return; + return false; } editor.uifunctions.clearLastUsedBtn_click = function () { if (editor.isMobile) return; - - editor.uivalues.lastUsed = []; - editor.config.set('lastUsed', []); - editor.updateLastUsedMap(); + + if (confirm("你确定要清理全部最近使用图块么?\n所有最近使用和最常使用图块(含置顶图块)都将被清除;此过程不可逆!")) { + editor.uivalues.lastUsed = []; + editor.config.set('lastUsed', []); + editor.updateLastUsedMap(); + } } ///////////////////////////////////////////////////////////////////////////// diff --git a/editor.html b/editor.html index fda967c7..c5dcf5b9 100644 --- a/editor.html +++ b/editor.html @@ -366,7 +366,7 @@
-

(Ctrl+滚轮放缩)

+

(Ctrl+滚轮放缩,右键置顶)

From 3c2e4850810b76b9d8e8c54c8e79f901801b2ae0 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Sun, 17 May 2020 23:50:44 +0800 Subject: [PATCH 16/16] =?UTF-8?q?=E4=BF=AE=E5=A4=8DchangeFloor=5Fs?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _server/MotaAction.g4 | 28 +++++++++++++++++----------- _server/editor_blockly.js | 4 ++-- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index a7dc1ce6..54c2834a 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -271,16 +271,19 @@ return code; //changeFloor 事件编辑器入口之一 changeFloor_m - : '楼梯, 传送门' BGNL? Newline Floor_List IdString? Stair_List 'x' Number ',' 'y' Number '朝向' DirectionEx_List '动画时间' IntString? '穿透性' IgnoreChangeFloor_List BEND + : '楼梯, 传送门' BGNL? Newline Floor_List IdString? Stair_List 'x' PosString? ',' 'y' PosString? '朝向' DirectionEx_List '动画时间' IntString? '穿透性' IgnoreChangeFloor_List BEND /* 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 -default : [null,"MTx",null,0,0,null,"",null] +default : [null,"MTx",null,"","",null,"",null] var toFloorId = IdString_0; if (Floor_List_0!='floorId') toFloorId = Floor_List_0; -var loc = ', "loc": ['+Number_0+', '+Number_1+']'; +var loc = ''; +if (PosString_0 && PosString_1) { + loc = ', "loc": ['+PosString_0+', '+PosString_1+']'; +} if (Stair_List_0===':now') loc = ''; else if (Stair_List_0!=='loc')loc = ', "stair": "'+Stair_List_0+'"'; if (DirectionEx_List_0 == 'null') DirectionEx_List_0 = ''; @@ -1189,7 +1192,7 @@ return code; */; changeFloor_s - : '楼层切换' Floor_List IdString? Stair_List 'x' Number ',' 'y' Number '朝向' DirectionEx_List '动画时间' IntString? Newline + : '楼层切换' Floor_List IdString? Stair_List 'x' PosString? ',' 'y' PosString? '朝向' DirectionEx_List '动画时间' IntString? Newline /* changeFloor_s @@ -1199,8 +1202,11 @@ default : [null,"",null,"","",null,"",null] colour : this.dataColor var toFloorId = IdString_0; if (Floor_List_0!='floorId') toFloorId = Floor_List_0; -toFloorId = toFloorId ? (', "floorId": ' + toFloorId) : ''; -var loc = ', "loc": ['+Number_0+', '+Number_1+']'; +toFloorId = toFloorId ? (', "floorId": "' + toFloorId +'"') : ''; +var loc = ''; +if (PosString_0 && PosString_1) { + loc = ', "loc": ['+PosString_0+', '+PosString_1+']'; +} if (Stair_List_0===':now') loc = ''; else if (Stair_List_0!=='loc')loc = ', "stair": "'+Stair_List_0+'"'; if (DirectionEx_List_0 == 'null') DirectionEx_List_0 = ''; @@ -2956,9 +2962,9 @@ ActionParser.prototype.parse = function (obj,type) { case 'changeFloor': if(!obj)obj={}; - if(!this.isset(obj.loc)) { - obj.loc=[0,0]; - if (!this.isset(obj.stair)) obj.stair=':now'; + if (!obj.loc) { + obj.loc = obj.loc || ['','']; + obj.stair = obj.stair || ':now'; } if (obj.floorId==':before'||obj.floorId==':next'||obj.floorId==':now') { obj.floorType=obj.floorId; @@ -3259,8 +3265,8 @@ ActionParser.prototype.parseAction = function() { data.floorType=data.floorId; delete data.floorId; } - return MotaActionBlocks['changeFloor_s'].xmlText([ - data.floorType||'floorId',data.floorId,data.stair||'loc',data.loc[0],data.loc[1],obj.direction, + this.next = MotaActionBlocks['changeFloor_s'].xmlText([ + data.floorType||'floorId',data.floorId,data.stair||'loc',data.loc[0],data.loc[1],data.direction, data.time, this.next]); break; case "changePos": // 直接更换勇士位置, 不切换楼层 diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index f3d74b07..df6ed146 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -850,9 +850,9 @@ function omitedcheckUpdateFunction(event) { // id: [x, y, floorId, forceFloor] var selectPointBlocks = { - "changeFloor_m": ["Number_0", "Number_1", "IdString_0", true], + "changeFloor_m": ["PosString_0", "PosString_1", "IdString_0", true], "jumpHero_s": ["PosString_0", "PosString_1"], - "changeFloor_s": ["Number_0", "Number_1", "IdString_0", true], + "changeFloor_s": ["PosString_0", "PosString_1", "IdString_0", true], "changePos_s": ["PosString_0", "PosString_1"], "battle_1_s": ["PosString_0", "PosString_1"], "openDoor_s": ["PosString_0", "PosString_1", "IdString_0"],