From c9ba70fa9c24f332a527330c5967908680490c70 Mon Sep 17 00:00:00 2001 From: oc Date: Sat, 10 Mar 2018 01:09:07 +0800 Subject: [PATCH] Replay use full name --- libs/actions.js | 4 ++-- libs/control.js | 9 +++++++-- libs/events.js | 5 +++-- libs/utils.js | 49 ++++++++++++++++++++++++++----------------------- 4 files changed, 38 insertions(+), 29 deletions(-) diff --git a/libs/actions.js b/libs/actions.js index aca775d9..e93d5238 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -185,8 +185,8 @@ actions.prototype.keyDown = function(keyCode) { } ////// 根据放开键的code来执行一系列操作 ////// -actions.prototype.keyUp = function(keyCode) { - if (core.isset(core.status.replay)&&core.status.replay.replaying) return; +actions.prototype.keyUp = function(keyCode, fromReplay) { + if (!fromReplay&&core.isset(core.status.replay)&&core.status.replay.replaying) return; if (core.status.lockControl) { core.status.holdingKeys = []; diff --git a/libs/control.js b/libs/control.js index 8e7a992e..ba257bbe 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1485,7 +1485,7 @@ control.prototype.replay = function () { core.events.openShop(shopId, false); var shopInterval = setInterval(function () { - if (!core.events.clickShop(6, topIndex+core.status.event.selection)) { + if (!core.actions.clickShop(6, topIndex+core.status.event.selection)) { clearInterval(shopInterval); core.stopReplay(); core.drawTip("录像文件出错"); @@ -1493,7 +1493,7 @@ control.prototype.replay = function () { } if (selections.length==0) { clearInterval(shopInterval); - core.events.clickShop(6, topIndex+choices.length); + core.actions.clickShop(6, topIndex+choices.length); core.replay(); return; } @@ -1535,6 +1535,11 @@ control.prototype.replay = function () { return; } } + else if (action.indexOf('key:')==0) { + core.actions.keyUp(parseInt(action.substring(4)), true); + core.replay(); + return; + } core.stopReplay(); core.insertAction("录像文件出错"); diff --git a/libs/events.js b/libs/events.js index 91a81d5a..58dae299 100644 --- a/libs/events.js +++ b/libs/events.js @@ -224,9 +224,10 @@ events.prototype.doAction = function() { // 事件处理完毕 if (core.status.event.data.list.length==0) { + var callback = core.status.event.data.callback; core.ui.closePanel(); - if (core.isset(core.status.event.data.callback)) - core.status.event.data.callback(); + if (core.isset(callback)) + callback(); core.replay(); return; } diff --git a/libs/utils.js b/libs/utils.js index 5ad4a9de..56929077 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -158,8 +158,6 @@ utils.prototype.encodeRoute = function (route) { var ans=""; var lastMove = "", cnt=0; - var items=Object.keys(core.material.items).sort(); - var shops=Object.keys(core.initStatus.shops).sort(); route.forEach(function (t) { if (t=='up' || t=='down' || t=='left' || t=='right') { if (t!=lastMove && cnt>0) { @@ -177,15 +175,13 @@ utils.prototype.encodeRoute = function (route) { cnt=0; } if (t.indexOf('item:')==0) - ans+="I"+items.indexOf(t.substring(5)); + ans+="I"+t.substring(5)+":"; else if (t.indexOf('fly:')==0) - ans+="F"+core.floorIds.indexOf(t.substring(4)); + ans+="F"+t.substring(4)+":"; else if (t.indexOf('choices:')==0) ans+="C"+t.substring(8); - else if (t.indexOf('shop:')==0) { - var sp=t.substring(5).split(":"); - ans+="S"+shops.indexOf(sp[0])+":"+sp[1]; - } + else if (t.indexOf('shop:')==0) + ans+="S"+t.substring(5); else if (t=='turn') ans+='T'; else if (t=='getNext') @@ -194,9 +190,10 @@ utils.prototype.encodeRoute = function (route) { ans+="P"+t.substring(6); else if (t=='no') ans+='N'; - else if (t.indexOf('move:')==0) { + else if (t.indexOf('move:')==0) ans+="M"+t.substring(5); - } + else if (t=='key:') + ans+='K'+t.substring(4); } }); if (cnt>0) { @@ -221,27 +218,33 @@ utils.prototype.decodeRoute = function (route) { if (num.length==0) num="1"; return core.isset(noparse)?num:parseInt(num); } + var getString = function () { + var str=""; + while (index