diff --git a/README.md b/README.md index b81aa04b..da2183a4 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,24 @@ HTML5 canvas制作的魔塔样板,支持全平台游戏! ## 更新说明 +### 2019.4.13 V2.6 + +* [x] 拆分整个项目,大幅重构代码,新增大量API +* [x] 重写文档,尤其是脚本和API列表 +* [x] 现在可以对编辑器的表格的结构进行配置 +* [x] 可以收藏和高亮存档 +* [x] 独立出来的插件编写 +* [x] 新增事件:关门、显示确认框、后置循环处理 +* [x] 剧情文本的绘制可以设置居中选项 +* [x] 选项框的绘制可以增加图标 +* [x] 增加公共事件版的全局商店 +* [x] 公共事件现在可以传入参数 +* [x] 重写滑冰事件,现在滑冰在背景层了 +* [x] 将输入框改成自定义实现,避免部分设备不支持 +* [x] 状态栏文字可以自动放缩 +* [x] 显示图片和对话框立绘可以裁剪图片 +* [x] 修复所有已知bug,大量细节优化 + ### 2019.2.19 V2.5.5 * [x] 现在编辑器修改地图后可以直接读档生效,无需再重置地图或回放录像 diff --git a/_docs/api.md b/_docs/api.md index 54e8b916..2f167244 100644 --- a/_docs/api.md +++ b/_docs/api.md @@ -1464,6 +1464,7 @@ posX, posY:素材在该素材图片上的位置;height:素材的高度;f core.searchBlock(id, floorId, showDisable) 搜索一个图块出现过的所有位置。id为图块ID,也可以传入图块的数字。 +id支持通配符搜索,比如"*Door"可以搜索所有的门,"unknownEvent*"可以所有所有的unknownEvent。 floorId为要搜索的楼层,可以是一个楼层ID,或者一个楼层数组。如果floorId不填则只搜索当前楼层。 showDisable如果为真,则对于禁用的图块也会返回。 此函数将返回一个数组,每一项为一个搜索到的结果: @@ -1997,6 +1998,10 @@ core.reverseDirection(direction) 翻转方向,即"up"转成"down", "left"转成"right"等。 +core.matchWildcard(pattern, string) +进行通配符的匹配判定,目前仅支持*(可匹配0或任意个字符)。比如"a*b*c"可以匹配"aa012bc"。 + + core.encodeBase64(str) / core.decodeBase64(str) 将字符串进行base64加密或解密。 diff --git a/_docs/event.md b/_docs/event.md index e5a2b7b9..c68f267c 100644 --- a/_docs/event.md +++ b/_docs/event.md @@ -655,8 +655,9 @@ revisit常常使用在一些商人之类的地方,当用户购买物品后不 ``` js [ {"type": "setBlock", "floorId": "MT1", "loc": [3,3], "number": 233}, // 将MT1层的(3,3)点变成数字233 - {"type": "setBlock", "loc": [2,1], "number": 121}, // 省略floorId则默认为本层 + {"type": "setBlock", "loc": [2,1],setVa "number": 121}, // 省略floorId则默认为本层 {"type": "setBlock", "number": 57}, // loc也可省略,默认为当前点 + {"type": "setBlock", "number": "yellowDoor"}, // 从V2.6开始也允许写图块ID ] ``` @@ -666,6 +667,8 @@ loc为可选的,表示要更改地图块的坐标。如果忽略此项,则 number为**要更改到的数字**,有关“数字”的定义详见参见[素材的机制](personalization#素材的机制)。 +从V2.6开始,number也允许写图块的ID,将自动转成对应的数字。 + 图块更改后: - 其启用/禁用状态不会发生任何改变。原来是启用还是启用,原来是禁用还是禁用。 @@ -1642,7 +1645,7 @@ default可选,如果为true则显示选择项时默认选中【确定】,否 yes和no均为必填项,即用户点击确认或取消后执行的事件。 -### while:循环处理 +### while:前置条件循环 从2.2.1样板开始,我们提供了循环处理(while事件)。 @@ -1678,6 +1681,12 @@ yes和no均为必填项,即用户点击确认或取消后执行的事件。 ] ``` +### dowhile:后置条件循环 + +`type:dowhile`可以制作一个后置条件循环。 + +其写法与参数和`type:while`完全一致,不过与其不同的是,会先执行一次事件列表,再对条件进行判定,就和C/C++中的 `do {...} while (...);` 语法一样。 + ### break:跳出循环 使用 `{"type": "break"}` 可以跳出当前循环。 diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index a8741045..4f38fe1e 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -327,6 +327,7 @@ action | if_1_s | switch_s | while_s + | dowhile_s | break_s | continue_s | input_s @@ -728,20 +729,20 @@ return code; */; setBlock_s - : '转变图块为' Int 'x' PosString? ',' 'y' PosString? '楼层' IdString? Newline + : '转变图块为' EvalString 'x' PosString? ',' 'y' PosString? '楼层' IdString? Newline /* setBlock_s tooltip : setBlock:设置某个图块,忽略坐标楼层则为当前事件 helpUrl : https://h5mota.com/games/template/docs/#/event?id=setblock%EF%BC%9A%E8%AE%BE%E7%BD%AE%E6%9F%90%E4%B8%AA%E5%9B%BE%E5%9D%97 colour : this.dataColor -default : [0,"","",""] +default : ["yellowDoor","","",""] var floorstr = ''; if (PosString_0 && PosString_1) { floorstr = ', "loc": ['+PosString_0+','+PosString_1+']'; } IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"'); -var code = '{"type": "setBlock", "number":'+Int_0+floorstr+IdString_0+'},\n'; +var code = '{"type": "setBlock", "number": "'+EvalString_0+'"'+floorstr+IdString_0+'},\n'; return code; */; @@ -870,20 +871,20 @@ return code; */; setBgFgBlock_s - : '转变图层块' Bg_Fg_List '为' Int 'x' PosString? ',' 'y' PosString? '楼层' IdString? Newline + : '转变图层块' Bg_Fg_List '为' EvalString 'x' PosString? ',' 'y' PosString? '楼层' IdString? Newline /* setBgFgBlock_s tooltip : setBgFgBlock:设置某个图层块,忽略坐标楼层则为当前点 helpUrl : https://h5mota.com/games/template/docs/#/event?id=setblock%EF%BC%9A%E8%AE%BE%E7%BD%AE%E6%9F%90%E4%B8%AA%E5%9B%BE%E5%9D%97 colour : this.dataColor -default : ["bg",0,"","",""] +default : ["bg","yellowDoor","","",""] var floorstr = ''; if (PosString_0 && PosString_1) { floorstr = ', "loc": ['+PosString_0+','+PosString_1+']'; } IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"'); -var code = '{"type": "setBgFgBlock", "name": "' + Bg_Fg_List_0 + '", "number":'+Int_0+floorstr+IdString_0+'},\n'; +var code = '{"type": "setBgFgBlock", "name": "' + Bg_Fg_List_0 + '", "number": "'+EvalString_0+'"'+floorstr+IdString_0+'},\n'; return code; */; @@ -1693,11 +1694,11 @@ return code; */; while_s - : '循环处理' ':' '当' expression '时' BGNL? Newline action+ BEND Newline + : '前置条件循环' ':' '当' expression '时' BGNL? Newline action+ BEND Newline /* while_s -tooltip : while:循环处理 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=while%EF%BC%9A%E5%BE%AA%E7%8E%AF%E5%A4%84%E7%90%86 +tooltip : while:前置条件循环 +helpUrl : https://h5mota.com/games/template/docs/#/event?id=while%ef%bc%9a%e5%89%8d%e7%bd%ae%e6%9d%a1%e4%bb%b6%e5%be%aa%e7%8e%af colour : this.eventColor var code = ['{"type": "while", "condition": "',expression_0,'",\n', '"data": [\n',action_0,'],\n', @@ -1705,6 +1706,19 @@ var code = ['{"type": "while", "condition": "',expression_0,'",\n', return code; */; +dowhile_s + : '后置条件循环' ':' BGNL? Newline action+ BEND '当' expression '时' Newline + +/* dowhile_s +tooltip : dowhile:后置条件循环 +helpUrl : https://h5mota.com/games/template/docs/#/event?id=dowhile%ef%bc%9a%e5%90%8e%e7%bd%ae%e6%9d%a1%e4%bb%b6%e5%be%aa%e7%8e%af +colour : this.eventColor +var code = ['{"type": "dowhile", "condition": "',expression_0,'",\n', + '"data": [\n',action_0,'],\n', +'},\n'].join(''); +return code; +*/; + break_s : '跳出循环' Newline @@ -2021,8 +2035,8 @@ Global_Value_List Global_Flag_List - : '显示当前楼层'|'显示勇士图标'|'显示当前等级'|'启用生命上限'|'显示魔力值'|'显示魔防值'|'显示金币值'|'显示经验值'|'允许等级提升'|'升级扣除模式'|'显示钥匙数量'|'显示破炸飞'|'显示毒衰咒'|'显示当前技能'|'楼梯边才能楼传'|'开启加点'|'开启负伤'|'仇恨怪战后扣减一半'|'夹击是否上整'|'循环计算临界'|'允许轻按'|'寻路算法不绕血瓶'|'允许走到将死领域'|'允许瞬间移动'|'允许查看禁用商店'|'阻激夹域后禁用快捷商店'|'检查控制台' - /*Global_Flag_List ['enableFloor','enableName','enableLv', 'enableHPMax', 'enableMana', 'enableMDef', 'enableMoney', 'enableExperience', 'enableLevelUp', 'levelUpLeftMode', 'enableKeys', 'enablePZF', 'enableDebuff', 'enableSkill', 'flyNearStair', 'enableAddPoint', 'enableNegativeDamage', 'hatredDecrease', 'betweenAttackCeil', 'useLoop', 'enableGentleClick', 'potionWhileRouting', 'canGoDeadZone', 'enableMoveDirectly', 'enableDisabledShop', 'disableShopOnDamage', 'checkConsole']*/; + : '显示当前楼层'|'显示勇士图标'|'显示当前等级'|'启用生命上限'|'显示魔力值'|'显示魔防值'|'显示金币值'|'显示经验值'|'允许等级提升'|'升级扣除模式'|'显示钥匙数量'|'显示破炸飞'|'显示毒衰咒'|'显示当前技能'|'楼梯边才能楼传'|'破墙镐四方向'|'炸弹四方向'|'冰冻徽章四方向'|'铁门不需要钥匙'|'开启加点'|'开启负伤'|'仇恨怪战后扣减一半'|'夹击是否上整'|'循环计算临界'|'允许轻按'|'寻路算法不绕血瓶'|'允许走到将死领域'|'允许瞬间移动'|'允许查看禁用商店'|'阻激夹域后禁用快捷商店'|'检查控制台' + /*Global_Flag_List ['enableFloor','enableName','enableLv', 'enableHPMax', 'enableMana', 'enableMDef', 'enableMoney', 'enableExperience', 'enableLevelUp', 'levelUpLeftMode', 'enableKeys', 'enablePZF', 'enableDebuff', 'enableSkill', 'flyNearStair', 'pickaxeFourDirections', 'bombFourDirections', 'snowFourDirections', 'steelDoorWithoutKey', 'enableAddPoint', 'enableNegativeDamage', 'hatredDecrease', 'betweenAttackCeil', 'useLoop', 'enableGentleClick', 'potionWhileRouting', 'canGoDeadZone', 'enableMoveDirectly', 'enableDisabledShop', 'disableShopOnDamage', 'checkConsole']*/; Colour : 'sdeirughvuiyasdeb'+ //为了被识别为复杂词法规则 @@ -2639,13 +2653,20 @@ ActionParser.prototype.parseAction = function() { this.next = MotaActionBlocks['choices_s'].xmlText([ this.isset(data.text)?this.EvalString(data.text):null,'','',text_choices,this.next]); break; - case "while": // 循环处理 + case "while": // 前置条件循环处理 this.next = MotaActionBlocks['while_s'].xmlText([ // MotaActionBlocks['evalString_e'].xmlText([data.condition]), this.tryToUseEvFlag_e('evalString_e', [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.next]); + break; case "break": // 跳出循环 this.next = MotaActionBlocks['break_s'].xmlText([ this.next]); diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 2a641312..90bf5962 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -68,6 +68,7 @@ editor_blockly = function () { MotaActionBlocks['tip_s'].xmlText(), MotaActionBlocks['win_s'].xmlText(), MotaActionBlocks['lose_s'].xmlText(), + MotaActionBlocks['confirm_s'].xmlText(), MotaActionBlocks['choices_s'].xmlText([ '选择剑或者盾','流浪者','man',MotaActionBlocks['choicesContext'].xmlText([ '剑','','',null,MotaActionFunctions.actionParser.parseList([{"type": "openDoor", "loc": [3,3]}]), @@ -76,7 +77,6 @@ editor_blockly = function () { ]) ]) ]), - MotaActionBlocks['confirm_s'].xmlText(), ], '数据相关':[ MotaActionBlocks['setValue_s'].xmlText([ @@ -118,6 +118,7 @@ editor_blockly = function () { {"case": "default", "action": [{"type": "comment", "text": "当没有符合的值的场合执行default事件"}]}, ]}), MotaActionBlocks['while_s'].xmlText(), + MotaActionBlocks['dowhile_s'].xmlText(), MotaActionBlocks['break_s'].xmlText(), MotaActionBlocks['continue_s'].xmlText(), MotaActionBlocks['revisit_s'].xmlText(), diff --git a/_server/table/data.comment.js b/_server/table/data.comment.js index 026ab732..8389ffd6 100644 --- a/_server/table/data.comment.js +++ b/_server/table/data.comment.js @@ -536,6 +536,12 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "_bool": "bool", "_data": "如果此项为true,则视为钥匙盒,红黄蓝钥匙+1;若为false,则视为大黄门钥匙" }, + "steelDoorWithoutKey": { + "_left": true, + "_type": "checkbox", + "_bool": "bool", + "_data": "铁门是否不需要钥匙开启。如果此项为true,则无需钥匙也可以开铁门。" + }, "equipment": { "_leaf": true, "_type": "checkbox", @@ -548,6 +554,12 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "_bool": "bool", "_data": "状态栏的装备按钮。若此项为true则将状态栏中的楼层转换器按钮换为装备栏按钮" }, + "iconInEquipbox": { + "_leaf": true, + "_type": "checkbox", + "_bool": "bool", + "_data": "在装备栏中的属性变化,是否绘制图标;如果此项开启,则会绘制图标而不是文字" + }, "enableAddPoint": { "_leaf": true, "_type": "checkbox", diff --git a/editor-mobile.html b/editor-mobile.html index e77a286f..0e4fde1f 100644 --- a/editor-mobile.html +++ b/editor-mobile.html @@ -120,7 +120,7 @@
- +
diff --git a/editor.html b/editor.html index 58ea0a1c..75b7856a 100644 --- a/editor.html +++ b/editor.html @@ -116,7 +116,7 @@
- +
diff --git a/libs/actions.js b/libs/actions.js index c4388106..e64fb01e 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -777,7 +777,7 @@ actions.prototype._sys_longClick = function (x, y, fromEvent) { // 数字键快速选择选项 actions.prototype._selectChoices = function (length, keycode, callback) { - var topIndex = this.HSIZE - parseInt((length - 1) / 2); + var topIndex = this.HSIZE - parseInt((length - 1) / 2) + (core.status.event.ui.offset || 0); if (keycode == 13 || keycode == 32 || keycode == 67) { callback.apply(this, [this.HSIZE, topIndex + core.status.event.selection]); } @@ -883,7 +883,7 @@ actions.prototype._clickAction = function (x, y) { var choices = data.choices; if (choices.length == 0) return; if (x >= this.CHOICES_LEFT && x <= this.CHOICES_RIGHT) { - var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2); + var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0); if (y >= topIndex && y < topIndex + choices.length) { // 选择 core.status.route.push("choices:" + (y - topIndex)); @@ -1207,7 +1207,7 @@ actions.prototype._clickShop = function (x, y) { var shop = core.status.event.data.shop; var choices = shop.choices; if (x >= this.CHOICES_LEFT && x <= this.CHOICES_RIGHT) { - var topIndex = this.HSIZE - parseInt(choices.length / 2); + var topIndex = this.HSIZE - parseInt(choices.length / 2) + (core.status.event.ui.offset || 0); if (y >= topIndex && y < topIndex + choices.length) { return core.events._useShop(shop, y - topIndex); } @@ -1237,7 +1237,7 @@ actions.prototype._clickQuickShop = function (x, y) { }); if (x >= this.CHOICES_LEFT && x <= this.CHOICES_RIGHT) { - var topIndex = this.HSIZE - parseInt(keys.length / 2); + var topIndex = this.HSIZE - parseInt(keys.length / 2) + (core.status.event.ui.offset || 0); if (y >= topIndex && y < topIndex + keys.length) { var reason = core.events.canUseQuickShop(keys[y - topIndex]); if (!core.flags.enableDisabledShop && reason) { @@ -1830,7 +1830,7 @@ actions.prototype._keyUpSL = function (keycode) { actions.prototype._clickSwitchs = function (x, y) { if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) return; var choices = core.status.event.ui.choices; - var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2); + var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0); if (y >= topIndex && y < topIndex + choices.length) { var selection = y - topIndex; core.status.event.selection = selection; @@ -1927,7 +1927,7 @@ actions.prototype._keyUpSwitchs = function (keycode) { actions.prototype._clickSettings = function (x, y) { if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) return; var choices = core.status.event.ui.choices; - var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2); + var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0); if (y >= topIndex && y < topIndex + choices.length) { var selection = y - topIndex; core.status.event.selection = selection; @@ -1978,7 +1978,7 @@ actions.prototype._keyUpSettings = function (keycode) { actions.prototype._clickSyncSave = function (x, y) { if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) return; var choices = core.status.event.ui.choices; - var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2); + var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0); if (y >= topIndex && y < topIndex + choices.length) { var selection = y - topIndex; core.status.event.selection = selection; @@ -2061,7 +2061,7 @@ actions.prototype._clickSyncSelect = function (x, y) { if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) return; var choices = core.status.event.ui.choices; - var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2); + var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0); if (y >= topIndex && y < topIndex + choices.length) { var selection = y - topIndex; core.status.event.selection = selection; @@ -2095,7 +2095,7 @@ actions.prototype._clickLocalSaveSelect = function (x, y) { if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) return; var choices = core.status.event.ui.choices; - var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2); + var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0); if (y >= topIndex && y < topIndex + choices.length) { var selection = y - topIndex; @@ -2135,7 +2135,7 @@ actions.prototype._clickStorageRemove = function (x, y) { if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) return; var choices = core.status.event.ui.choices; - var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2); + var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0); if (y >= topIndex && y < topIndex + choices.length) { var selection = y - topIndex; @@ -2224,7 +2224,7 @@ actions.prototype._clickReplay = function (x, y) { if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) return; var choices = core.status.event.ui.choices; - var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2); + var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0); if (y >= topIndex && y < topIndex + choices.length) { var selection = y - topIndex; @@ -2278,7 +2278,7 @@ actions.prototype._clickGameInfo = function (x, y) { if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) return; var choices = core.status.event.ui.choices; - var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2); + var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0); if (y >= topIndex && y < topIndex + choices.length) { var selection = y - topIndex; diff --git a/libs/control.js b/libs/control.js index 93b9bff4..674b163a 100644 --- a/libs/control.js +++ b/libs/control.js @@ -798,8 +798,8 @@ control.prototype._drawHero_getDrawObjs = function (direction, x, y, status, off }); (core.status.hero.followers||[]).forEach(function (t) { drawObjs.push({ - "img": t.img, - "height": t.img.height/4, + "img": core.material.images.images[t.name], + "height": core.material.images.images[t.name].height/4, "heroIcon": heroIconArr[t.direction], "posx": 32*t.x - core.bigmap.offsetX + (t.stop?0:core.utils.scan[t.direction].x*offset), "posy": 32*t.y - core.bigmap.offsetY + (t.stop?0:core.utils.scan[t.direction].y*offset), @@ -1882,6 +1882,15 @@ control.prototype.getHeroLoc = function (name) { return core.status.hero.loc[name]; } +////// 获得某个属性的中文名 ////// +control.prototype.getStatusName = function (name) { + var map = { + name: "名称", lv: "等级", hpmax: "生命上限", hp: "生命", manamax: "魔力上限", mana: "魔力", + atk: "攻击", def: "防御", mdef: "魔防", money: "金币", exp: "经验", experience: "经验", steps: "步数" + }; + return map[name] || name; +} + ////// 获得某个等级的名称 ////// control.prototype.getLvName = function (lv) { if (!core.status.hero) return null; diff --git a/libs/events.js b/libs/events.js index 341bdcc8..07ede640 100644 --- a/libs/events.js +++ b/libs/events.js @@ -70,7 +70,7 @@ events.prototype._startGame_start = function (hard, seed, route, callback) { events.prototype._startGame_afterStart = function (nowLoc, callback) { core.ui.closePanel(); - core.showStatusBar(); + this._startGame_statusBar(); core.dom.musicBtn.style.display = 'none'; core.changeFloor(core.firstData.floorId, null, nowLoc, null, function () { // 插入一个空事件避免直接回放录像出错 @@ -80,6 +80,14 @@ events.prototype._startGame_afterStart = function (nowLoc, callback) { this._startGame_upload(); } +// 开始游戏时是否显示状态栏 +events.prototype._startGame_statusBar = function () { + if (core.flags.startUsingCanvas) + core.hideStatusBar(); + else + core.showStatusBar(); +} + events.prototype._startGame_upload = function () { // Upload var formData = new FormData(); @@ -382,6 +390,9 @@ events.prototype._openDoor_check = function (id, x, y, needKey) { return false; } + if (id == 'steelDoor' && core.flags.steelDoorWithoutKey) + needKey = false; + if (needKey && id.endsWith("Door")) { var key = id.replace("Door", "Key"); if (!core.hasItem(key)) { @@ -773,6 +784,8 @@ events.prototype.startEvents = function (list, x, y, callback) { events.prototype.doAction = function () { // 清空boxAnimate和UI层 core.clearUI(); + clearInterval(core.status.event.interval); + core.status.event.interval = null; // 判定是否执行完毕 if (this._doAction_finishEvents()) return; // 当前点坐标和前缀 @@ -1405,6 +1418,13 @@ events.prototype._action_while = function (data, x, y, prefix) { core.doAction(); } +events.prototype._action_dowhile = function (data, x, y, prefix) { + core.unshift(core.status.event.data.list, + {"todo": core.clone(data.data), "total": core.clone(data.data), "condition": data.condition} + ); + core.doAction(); +} + events.prototype._action_break = function (data, x, y, prefix) { core.status.event.data.list.shift(); core.doAction(); @@ -1715,7 +1735,7 @@ events.prototype.follow = function (name) { core.status.hero.followers = core.status.hero.followers || []; if (core.material.images.images[name] && core.material.images.images[name].width == 128) { - core.status.hero.followers.push({"name": name, "img": core.material.images.images[name]}); + core.status.hero.followers.push({"name": name}); core.gatherFollowers(); core.clearMap('hero'); core.drawHero(); diff --git a/libs/maps.js b/libs/maps.js index f03bfe60..52b540b4 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -977,10 +977,10 @@ maps.prototype._drawAutotileAnimate = function (block, animate) { if (block.name) { if (block.name == 'bg') core.drawImage('bg', core.material.groundCanvas.canvas, 32 * x, 32 * y); - this.drawAutotile(cv, core.status.autotileAnimateObjs[block.name+"map"], block, 32, 0, 0, animate); + this._drawAutotile(cv, core.status.autotileAnimateObjs[block.name+"map"], block, 32, 0, 0, animate); } else { - this.drawAutotile(cv, core.status.autotileAnimateObjs.map, block, 32, 0, 0, animate); + this._drawAutotile(cv, core.status.autotileAnimateObjs.map, block, 32, 0, 0, animate); } } @@ -1239,8 +1239,9 @@ maps.prototype.searchBlock = function (id, floorId, showDisable) { } for (var i = 0; i < core.status.maps[floorId].blocks.length; ++i) { var block = core.status.maps[floorId].blocks[i]; - if (block.event.id == id && (showDisable || !block.disable)) + if ((showDisable || !block.disable) && core.matchWildcard(id, block.event.id)) { result.push({floorId: floorId, index: i, block: block, x: block.x, y: block.y}); + } } return result; } @@ -1425,7 +1426,10 @@ maps.prototype.setBlock = function (number, x, y, floorId) { floorId = floorId || core.status.floorId; if (!floorId || number == null || x == null || y == null) return; if (x < 0 || x >= core.floors[floorId].width || y < 0 || y >= core.floors[floorId].height) return; - if (typeof number == 'string') number = core.getNumberById(number); + if (typeof number == 'string') { + if (/^\d+$/.test(number)) number = parseInt(number); + else number = core.getNumberById(number); + } var originBlock = core.getBlock(x, y, floorId, true); var block = this.initBlock(x, y, number, true, core.floors[floorId]); @@ -1479,6 +1483,10 @@ maps.prototype.setBgFgBlock = function (name, number, x, y, floorId) { if (!floorId || number == null || x == null || y == null) return; if (x < 0 || x >= core.floors[floorId].width || y < 0 || y >= core.floors[floorId].height) return; if (name != 'bg' && name != 'fg') return; + if (typeof number == 'string') { + if (/^\d+$/.test(number)) number = parseInt(number); + else number = core.getNumberById(number); + } var vFlag = "__" + name + "Value__" + floorId + "_" + x + "_" + y; core.setFlag(vFlag, number); diff --git a/libs/ui.js b/libs/ui.js index 2c310153..5425c2ad 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -261,8 +261,6 @@ ui.prototype.closePanel = function () { } ui.prototype.clearUI = function () { - clearInterval(core.status.event.interval); - core.status.event.interval = null; core.status.boxAnimateObjs = []; if (core.dymCanvas._selector) core.deleteCanvas("_selector"); core.clearMap('ui'); @@ -557,6 +555,9 @@ ui.prototype._calTextBoxWidth = function (ctx, content, min_width, max_width, fo ////// 处理 \i[xxx] 的问题 ui.prototype._getDrawableIconInfo = function (id) { + if (id && id.indexOf('flag:') === 0) { + id = core.getFlag(id.substring(5), id); + } var image = null, icon = null; ["terrains","animates","items","npcs","enemys"].forEach(function (v) { if (core.material.icons[v][id] != null) { @@ -770,8 +771,8 @@ ui.prototype.drawTextBox = function(content, showAll) { var textAttribute = core.status.textAttribute; var titleInfo = this._getTitleAndIcon(content); var posInfo = this._getPosition(titleInfo.content); - if (!posInfo.position) posInfo.position = textAttribute.position; if (posInfo.position != 'up' && posInfo.position != 'down') posInfo.px = posInfo.py = null; + if (!posInfo.position) posInfo.position = textAttribute.position; content = this._drawTextBox_drawImages(posInfo.content); // Step 2: 计算对话框的矩形位置 @@ -972,6 +973,7 @@ ui.prototype.drawChoices = function(content, choices) { var titleInfo = this._getTitleAndIcon(content); var hPos = this._drawChoices_getHorizontalPosition(titleInfo, choices); var vPos = this._drawChoices_getVerticalPosition(titleInfo, choices, hPos); + core.status.event.ui.offset = vPos.offset; var isWindowSkin = this.drawBackground(hPos.left, vPos.top, hPos.right, vPos.bottom); this._drawChoices_drawTitle(titleInfo, hPos, vPos); @@ -1000,14 +1002,22 @@ ui.prototype._drawChoices_getVerticalPosition = function (titleInfo, choices, hP var length = choices.length; var height = 32 * (length + 2), bottom = this.HPIXEL + height / 2; if (length % 2 == 0) bottom += 16; + var offset = 0; var choice_top = bottom - height + 56; if (titleInfo.content) { + var headHeight = 0; var realContent = this._getRealContent(titleInfo.content); var lines = core.splitLines('ui', realContent, hPos.validWidth, this._buildFont(15, true)); - if (titleInfo.title) height += 25; - height += lines.length * 20; + if (titleInfo.title) headHeight += 25; + headHeight += lines.length * 20; + height += headHeight; + if (bottom - height <= 32) { + offset = Math.floor(headHeight / 64); + bottom += 32 * offset; + choice_top += 32 * offset; + } } - return {top: bottom - height, height: height, bottom: bottom, choice_top: choice_top }; + return {top: bottom - height, height: height, bottom: bottom, choice_top: choice_top, offset: offset }; } ui.prototype._drawChoices_drawTitle = function (titleInfo, hPos, vPos) { @@ -1958,7 +1968,7 @@ ui.prototype._drawEquipbox_description = function (info, max_height) { this._drawEquipbox_drawStatusChanged(info, curr, equip, equipType); } -ui.prototype._drawEquipbox_drawStatusChanged = function (info, y, equip, equipType) { +ui.prototype._drawEquipbox_getStatusChanged = function (info, equip, equipType) { var compare, differentMode = null; if (info.index < this.LAST) compare = core.compareEquipment(null, info.selectId); else { @@ -1975,18 +1985,25 @@ ui.prototype._drawEquipbox_drawStatusChanged = function (info, y, equip, equipTy core.fillText('ui', differentMode, 10, y, '#CCCCCC', this._buildFont(14, false)); return; } + return compare; +} + +ui.prototype._drawEquipbox_drawStatusChanged = function (info, y, equip, equipType) { + var compare = this._drawEquipbox_getStatusChanged(info, equip, equipType); + if (compare == null) return; var drawOffset = 10; // --- 变化值... core.setFont('ui', this._buildFont(14, true)); for (var name in compare) { var img = core.statusBar.icons[name]; - if (img) { // 绘制图标 + var text = core.getStatusName(name); + if (img && core.flags.iconInEquipbox) { // 绘制图标 core.drawImage('ui', img, 0, 0, 32, 32, drawOffset, y - 13, 16, 16); drawOffset += 20; } else { // 绘制文字 - core.fillText('ui', name + " ", drawOffset, y, '#CCCCCC'); - drawOffset += core.calWidth('ui', name + " "); + core.fillText('ui', text + " ", drawOffset, y, '#CCCCCC'); + drawOffset += core.calWidth('ui', text + " "); } var nowValue = core.getStatus(name) * core.getBuff(name), newValue = (nowValue + compare[name]) * core.getBuff(name); if (equip.equip.percentage) { @@ -2004,13 +2021,14 @@ ui.prototype._drawEquipbox_drawStatusChanged = function (info, y, equip, equipTy } ui.prototype._drawEquipbox_drawEquiped = function (info, line) { - core.setTextAlign('ui', 'right'); + core.setTextAlign('ui', 'center'); var per_line = this.HSIZE - 3, width = Math.floor(this.PIXEL / (per_line + 0.25)); // 当前装备 for (var i = 0; i < info.equipLength ; i++) { var equipId = info.equipEquipment[i] || null; - var offset_text = width * (i % per_line) + 56; + // var offset_text = width * (i % per_line) + 56; var offset_image = width * (i % per_line) + width * 2 / 3; + var offset_text = offset_image - (width - 32) / 2; var y = line + 54 * Math.floor(i / per_line) + 19; if (equipId) { var icon = core.material.icons.items[equipId]; diff --git a/libs/utils.js b/libs/utils.js index d491197e..9da86c95 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -624,6 +624,12 @@ utils.prototype.reverseDirection = function (direction) { return {"left":"right","right":"left","down":"up","up":"down"}[direction] || direction; } +utils.prototype.matchWildcard = function (pattern, string) { + return new RegExp('^' + pattern.split(/\*+/).map(function (s) { + return s.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&'); + }).join('.*') + '$').test(string); +} + ////// Base64加密 ////// utils.prototype.encodeBase64 = function (str) { return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p1) { diff --git a/project/data.js b/project/data.js index ba2c9d99..e6c64c99 100644 --- a/project/data.js +++ b/project/data.js @@ -387,8 +387,10 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "bombFourDirections": false, "snowFourDirections": false, "bigKeyIsBox": false, + "steelDoorWithoutKey": false, "equipment": false, "equipboxButton": false, + "iconInEquipbox": false, "enableAddPoint": false, "enableNegativeDamage": false, "hatredDecrease": true, diff --git a/更新说明.txt b/更新说明.txt index 4bf78891..ec9833e3 100644 --- a/更新说明.txt +++ b/更新说明.txt @@ -1,4 +1,24 @@ -HTML5魔塔样板V2.5.5 +HTML5魔塔样板V2.6 + +拆分整个项目,大幅重构代码,新增大量API +重写文档,尤其是脚本和API列表 +现在可以对编辑器的表格的结构进行配置 +可以收藏和高亮存档 +独立出来的插件编写 +新增事件:关门、显示确认框、后置循环处理 +剧情文本的绘制可以设置居中选项 +选项框的绘制可以增加图标 +增加公共事件版的全局商店 +公共事件现在可以传入参数 +重写滑冰事件,现在滑冰在背景层了 +将输入框改成自定义实现,避免部分设备不支持 +状态栏文字可以自动放缩 +显示图片和对话框立绘可以裁剪图片 +修复所有已知bug,大量细节优化 + +----------------------------------------------------------------------- + +HTML5魔塔样板V2.5.5 现在编辑器修改地图后可以直接读档生效,无需再重置地图或回放录像 存档方式优化,大幅降低单个存档的占用空间