From ba7eccbf5eef8186487ec357437302cf8279be72 Mon Sep 17 00:00:00 2001 From: oc Date: Mon, 27 May 2019 21:56:28 +0800 Subject: [PATCH] toolboxReplay --- _server/MotaAction.g4 | 12 +++++++----- _server/editor_file_unsorted.js | 16 +++++++++------- libs/actions.js | 30 +++++++++++++++++++++++++----- libs/control.js | 22 ++++++++++++++++++++++ libs/events.js | 2 +- 5 files changed, 64 insertions(+), 18 deletions(-) diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index d4adc924..291180ff 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -1851,20 +1851,22 @@ return code; autoSave_s - : '自动存档' + : '自动存档' '不提示' Bool Newline /* autoSave_s tooltip : autoSave: 自动存档 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=autoSave%ef%bc%9a%e8%87%aa%e5%8a%a8%e5%ad%98%e6%a1%a3 colour : this.soundColor -var code = '{"type": "autoSave"},\n'; +default : [false] +Bool_0 = Bool_0 ? (', "nohint": true') : ''; +var code = '{"type": "autoSave"'+Bool_0+'},\n'; return code; */; callLoad_s - : '呼出读档页面' + : '呼出读档页面' Newline /* callLoad_s @@ -1903,7 +1905,7 @@ return code; clearMap_1_s - : '清空画布' + : '清空画布' Newline /* clearMap_1_s tooltip : clearMap: 清除画布 @@ -3202,7 +3204,7 @@ ActionParser.prototype.parseAction = function() { break; case "autoSave": // 自动存档 this.next = MotaActionBlocks['autoSave_s'].xmlText([ - this.next]); + this.nohint, this.next]); break; case "callLoad": // 呼出读档界面 this.next = MotaActionBlocks['callLoad_s'].xmlText([ diff --git a/_server/editor_file_unsorted.js b/_server/editor_file_unsorted.js index 04c46d99..c6206fe9 100644 --- a/_server/editor_file_unsorted.js +++ b/_server/editor_file_unsorted.js @@ -15,13 +15,15 @@ editor_file = function (editor, callback) { var filename = 'project/floors/' + editor.currentFloorId + '.js'; var datastr = ['main.floors.', editor.currentFloorId, '=\n']; - for(var ii=0,name;name=['map','bgmap','fgmap'][ii];ii++){ - var mapArray=editor[name].map(function (v) { - return v.map(function (v) { - return v.idnum || v || 0 - }) - }); - editor.currentFloorData[name]=mapArray; + if (core.floorIds.indexOf(editor.currentFloorId) >= 0) { + for(var ii=0,name;name=['map','bgmap','fgmap'][ii];ii++){ + var mapArray=editor[name].map(function (v) { + return v.map(function (v) { + return v.idnum || v || 0 + }) + }); + editor.currentFloorData[name]=mapArray; + } } // format 更改实现方式以支持undefined删除 diff --git a/libs/actions.js b/libs/actions.js index b3885841..e4a79cb4 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -113,7 +113,8 @@ actions.prototype.doRegisteredAction = function (action) { actions.prototype._checkReplaying = function () { if (core.isReplaying() && core.status.event.id != 'save' - && (core.status.event.id || "").indexOf('book') != 0 && core.status.event.id != 'viewMaps') + && (core.status.event.id || "").indexOf('book') != 0 && core.status.event.id != 'viewMaps' + && core.status.event.id != 'toolbox' && core.status.event.id != 'equipbox') return true; return false; } @@ -170,6 +171,10 @@ actions.prototype._sys_onkeyUp_replay = function (e) { core.viewMapReplay(); else if (e.keyCode == 78) // N core.stepReplay(); + else if (e.keyCode == 84) // T + core.toolboxReplay(); + else if (e.keyCode == 81) // Q + core.equipboxReplay(); else if (e.keyCode >= 49 && e.keyCode <= 51) // 1-3 core.setReplaySpeed(e.keyCode - 48); else if (e.keyCode == 52) // 4 @@ -1317,7 +1322,10 @@ actions.prototype._clickToolbox = function (x, y) { // 装备栏 if (x >= this.LAST - 2 && y == 0) { core.ui.closePanel(); - core.openEquipbox(); + if (core.isReplaying()) + core.equipboxReplay(); + else + core.openEquipbox(); return; } if (x >= this.LAST - 2 && y == this.LAST) { @@ -1376,6 +1384,7 @@ actions.prototype._clickToolboxIndex = function (index) { if (select >= items.length) return; var itemId = items[select]; if (itemId == core.status.event.data.selectId) { + if (core.isReplaying()) return; core.events.tryUseItem(itemId); } else { @@ -1478,7 +1487,10 @@ actions.prototype._keyDownToolbox = function (keycode) { actions.prototype._keyUpToolbox = function (keycode) { if (keycode == 81) { core.ui.closePanel(); - core.openEquipbox(); + if (core.isReplaying()) + core.equipboxReplay(); + else + core.openEquipbox(); return; } if (keycode == 84 || keycode == 27 || keycode == 88) { @@ -1498,7 +1510,10 @@ actions.prototype._clickEquipbox = function (x, y) { // 道具栏 if (x >= this.LAST - 2 && y == 0) { core.ui.closePanel(); - core.openToolbox(); + if (core.isReplaying()) + core.toolboxReplay(); + else + core.openToolbox(); return; } // 返回 @@ -1547,6 +1562,7 @@ actions.prototype._clickEquipboxIndex = function (index) { if (index < this.LAST) { if (index >= core.status.globalAttribute.equipName.length) return; if (index == core.status.event.selection && core.status.hero.equipment[index]) { + if (core.isReplaying()) return; core.unloadEquip(index); core.status.route.push("unEquip:" + index); } @@ -1554,6 +1570,7 @@ actions.prototype._clickEquipboxIndex = function (index) { else { var equips = Object.keys(core.status.hero.items.equips || {}).sort(); if (index == core.status.event.selection) { + if (core.isReplaying()) return; var equipId = equips[index - this.LAST + (core.status.event.data.page - 1) * this.LAST]; core.loadEquip(equipId); core.status.route.push("equip:" + equipId); @@ -1645,7 +1662,10 @@ actions.prototype._keyUpEquipbox = function (keycode, altKey) { } if (keycode == 84) { core.ui.closePanel(); - core.openToolbox(); + if (core.isReplaying()) + core.toolboxReplay(); + else + core.openToolbox(); return; } if (keycode == 81 || keycode == 27 || keycode == 88) { diff --git a/libs/control.js b/libs/control.js index 4a9c8b84..6a9764a2 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1223,6 +1223,28 @@ control.prototype.viewMapReplay = function () { core.ui.drawMaps(); } +control.prototype.toolboxReplay = function () { + if (!core.isPlaying() || !core.isReplaying()) return; + if (!core.status.replay.pausing) return core.drawTip("请先暂停录像"); + if (core.isMoving() || core.status.replay.animate || core.status.event.id) + return core.drawTip("请等待当前事件的处理结束"); + + core.lockControl(); + core.status.event.id='toolbox'; + core.ui.drawToolbox(); +} + +control.prototype.equipboxReplay = function () { + if (!core.isPlaying() || !core.isReplaying()) return; + if (!core.status.replay.pausing) return core.drawTip("请先暂停录像"); + if (core.isMoving() || core.status.replay.animate || core.status.event.id) + return core.drawTip("请等待当前事件的处理结束"); + + core.lockControl(); + core.status.event.id='equipbox'; + core.ui.drawEquipbox(); +} + ////// 是否正在播放录像 ////// control.prototype.isReplaying = function () { return (core.status.replay||{}).replaying; diff --git a/libs/events.js b/libs/events.js index b196aa0e..2b070207 100644 --- a/libs/events.js +++ b/libs/events.js @@ -1603,7 +1603,7 @@ events.prototype._action_callSave = function (data, x, y, prefix) { events.prototype._action_autoSave = function (data, x, y, prefix) { core.autosave(); - core.drawTip("已自动存档"); + if (!data.nohint) core.drawTip("已自动存档"); core.doAction(); }