diff --git a/libs/actions.js b/libs/actions.js index a7f3823f..b8d65cb4 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -884,9 +884,9 @@ actions.prototype.onStatusBarClick = function (e) { return this.doRegisteredAction('onStatusBarClick', px, py); } -actions.prototype._sys_onStatusBarClick = function (px, py) { +actions.prototype._sys_onStatusBarClick = function (px, py, vertical) { if (this.actionsdata.onStatusBarClick) - return this.actionsdata.onStatusBarClick(px, py); + return this.actionsdata.onStatusBarClick(px, py, vertical); } /////////////////// 在某个界面时的按键点击效果 /////////////////// diff --git a/libs/control.js b/libs/control.js index 92d3eb87..7a1b46a6 100644 --- a/libs/control.js +++ b/libs/control.js @@ -31,12 +31,15 @@ control.prototype._init = function () { this.registerReplayAction("item", this._replayAction_item); this.registerReplayAction("equip", this._replayAction_equip); this.registerReplayAction("unEquip", this._replayAction_unEquip); + this.registerReplayAction("saveEquip", this._replayAction_saveEquip); + this.registerReplayAction("loadEquip", this._replayAction_loadEquip); this.registerReplayAction("fly", this._replayAction_fly); this.registerReplayAction("shop", this._replayAction_shop); this.registerReplayAction("turn", this._replayAction_turn); this.registerReplayAction("getNext", this._replayAction_getNext); this.registerReplayAction("moveDirectly", this._replayAction_moveDirectly); this.registerReplayAction("key", this._replayAction_key); + this.registerReplayAction("click", this._replayAction_click); // --- 注册系统的resize this.registerResize("gameGroup", this._resize_gameGroup); this.registerResize("canvas", this._resize_canvas); @@ -1672,6 +1675,20 @@ control.prototype._replayAction_unEquip = function (action) { return true; } +control.prototype._replayAction_saveEquip = function (action) { + if (action.indexOf('saveEquip:')!=0) return false; + core.quickSaveEquip(parseInt(action.substring(10))); + core.replay(); + return true; +} + +control.prototype._replayAction_loadEquip = function (action) { + if (action.indexOf('loadEquip:')!=0) return false; + core.quickLoadEquip(parseInt(action.substring(10))); + core.replay(); + return true; +} + control.prototype._replayAction_fly = function (action) { if (action.indexOf("fly:")!=0) return false; var floorId=action.substring(4); @@ -1757,6 +1774,15 @@ control.prototype._replayAction_key = function (action) { return true; } +control.prototype._replayAction_click = function (action) { + if (action.indexOf("click:") != 0) return false; + var p = action.split(":"); + if (p.length != 4) return false; + core.actions.doRegisteredAction("onStatusBarClick", parseInt(p[2]), parseInt(p[3]), parseInt(p[1])); + core.replay(); + return true; +} + // ------ 存读档相关 ------ // ////// 自动存档 ////// diff --git a/libs/items.js b/libs/items.js index dba4d97d..39c171ed 100644 --- a/libs/items.js +++ b/libs/items.js @@ -349,6 +349,7 @@ items.prototype.quickSaveEquip = function (index) { var saveEquips = core.getFlag("saveEquips", []); saveEquips[index] = core.clone(core.status.hero.equipment); core.setFlag("saveEquips", saveEquips); + core.status.route.push("saveEquip:"+index); core.drawTip("已保存" + index + "号套装"); } @@ -366,6 +367,7 @@ items.prototype.quickLoadEquip = function (index) { if (v && !this.canEquip(v, true)) return; } + core.status.route.push("loadEquip:"+index); core.setFlag("__quickLoadEquip__", true); // 快速换装 var toEquip = []; @@ -377,7 +379,6 @@ items.prototype.quickLoadEquip = function (index) { toEquip.push(to || null); if (now) { this.unloadEquip(i); - core.status.route.push("unEquip:" + i); } } } @@ -385,7 +386,6 @@ items.prototype.quickLoadEquip = function (index) { var to = toEquip[i]; if (to) { this.loadEquip(to); - core.status.route.push("equip:" + to); } } core.removeFlag("__quickLoadEquip__"); diff --git a/libs/utils.js b/libs/utils.js index 13d26f10..a1e22203 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -514,6 +514,10 @@ utils.prototype._encodeRoute_encodeOne = function (t) { return "u" + t.substring(8); else if (t.indexOf('equip:') == 0) return "e" + this._encodeRoute_id2number(t.substring(6)) + ":"; + else if (t.indexOf('saveEquip:') == 0) + return "s" + t.substring(10); + else if (t.indexOf('loadEquip:') == 0) + return "l" + t.substring(10); else if (t.indexOf('fly:') == 0) return "F" + t.substring(4) + ":"; else if (t == 'choices:none') @@ -540,6 +544,8 @@ utils.prototype._encodeRoute_encodeOne = function (t) { return "M" + t.substring(5); else if (t.indexOf('key:') == 0) return 'K' + t.substring(4); + else if (t.indexOf('click:') == 0) + return 'k' + t.substring(6); else if (t.indexOf('random:') == 0) return 'X' + t.substring(7); return '('+t+')'; @@ -623,6 +629,12 @@ utils.prototype._decodeRoute_decodeOne = function (decodeObj, c) { case "e": decodeObj.ans.push("equip:" + this._decodeRoute_number2id(nxt)); break; + case "s": + decodeObj.ans.push("saveEquip:" + nxt); + break; + case "l": + decodeObj.ans.push("loadEquip:" + nxt); + break; case "F": decodeObj.ans.push("fly:" + nxt); break; @@ -663,6 +675,13 @@ utils.prototype._decodeRoute_decodeOne = function (decodeObj, c) { case "K": decodeObj.ans.push("key:" + nxt); break; + case "k": + ++decodeObj.index; + var px = this._decodeRoute_getNumber(decodeObj); + ++decodeObj.index; + var py = this._decodeRoute_getNumber(decodeObj); + decodeObj.ans.push("click:"+nxt+":"+px+":"+py); + break; case "X": decodeObj.ans.push("random:" + nxt); break; diff --git a/project/functions.js b/project/functions.js index 3322ac01..cbf4675f 100644 --- a/project/functions.js +++ b/project/functions.js @@ -928,13 +928,20 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } }, - "onStatusBarClick": function (px, py) { + "onStatusBarClick": function (px, py, vertical) { // 点击状态栏时触发的事件,仅在自绘状态栏开启时生效 // px和py为点击的像素坐标 + // vertical为录像播放过程中的横竖屏信息 // // 横屏模式下状态栏的画布大小是 129*416 // 竖屏模式下状态栏的画布大小是 416*(32*rows+9) 其中rows为状态栏行数,即全塔属性中statusCanvasRowsOnMobile值 - // 可以使用 core.domStyle.isVertical 来判定当前是否是竖屏模式 + // 可以使用 _isVertical() 来判定当前是否是竖屏模式 + + // 判定当前是否是竖屏模式。录像播放过程中可能会记录当时的横竖屏信息以覆盖。 + var _isVertical = function () { + if (core.isReplaying() && vertical != null) return vertical; + return core.domStyle.isVertical; + } // 如果正在执行事件,则忽略 if (core.status.lockControl) return; @@ -942,8 +949,54 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = if (core.isMoving()) return; // 判定px和py来执行自己的脚本内容.... 注意横竖屏 - // 这里是直接打出点击坐标的例子。 - // console.log("onStatusBarClick:", px, py); + // console.log("onStatusBarClick: ", px, py, _isVertical()); + + // 样例一:点击某个区域后使用一个道具 + /* + if (core.hasItem("pickaxe")) { + if (_isVertical()) { + // 竖屏模式下 + if (px >= 200 && px <= 250 && py >= 50 && py <= 100) { + core.useItem("pickaxe"); + } + } else { + // 横屏模式下 + if (px >= 50 && px <= 100 && py >= 200 && py <= 250) { + core.useItem("pickaxe"); + } + } + } + */ + + // 样例二:点击某个区域后执行一段公共事件或脚本 + /* + if (core.hasFlag("xxx")) { + if (_isVertical()) { + // 竖屏模式下 + if (px >= 200 && px <= 250 && py >= 50 && py <= 100) { + // 记录点击坐标。这里的1代表此时是竖屏! + core.status.route.push("click:1:" + px + ":" + py); + + // 可以插入公共事件 / 普通事件 / 执行一段脚本(如打开自绘UI或增减flag) + core.insertCommonEvent("道具商店"); + // core.insertAction(["一段事件"]); + // core.openItemShop("shop1"); + } + } else { + // 横屏模式下 + if (px >= 50 && px <= 100 && py >= 200 && py <= 250) { + // 记录点击坐标。这里的0代表此时是横屏! + core.status.route.push("click:0:" + px + ":" + py); + + // 可以插入公共事件 / 普通事件 / 执行一段脚本(如打开自绘UI或增减flag) + core.insertCommonEvent("道具商店"); + // core.insertAction(["一段事件"]); + // core.openItemShop("shop1"); + } + } + } + */ + } }, "control": {