From 9a205a780dfd384b12963b93e7dd881687cc2b85 Mon Sep 17 00:00:00 2001 From: Orz-zrO <1627711948@qq.com> Date: Sun, 8 Mar 2020 22:56:53 +0800 Subject: [PATCH 01/10] Add files via upload --- libs/control.js | 61 ++++++++++++++++++++++++++++++++++++------------- libs/core.js | 3 ++- libs/ui.js | 4 ++-- 3 files changed, 49 insertions(+), 19 deletions(-) diff --git a/libs/control.js b/libs/control.js index b0f58cdf..333d5083 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1604,9 +1604,15 @@ control.prototype.autosave = function (removeLast) { if (core.saves.autosave.data == null) { core.saves.autosave.data = []; } - core.saves.autosave.data.push(core.saveData()); + core.saves.autosave.data.splice(core.saves.autosave.now,0,core.saveData()); + core.saves.autosave.now=core.saves.autosave.now+1; if (core.saves.autosave.data.length > core.saves.autosave.max) { - core.saves.autosave.data.shift(); + if(core.saves.autosave.now= 1) { - core.setLocalForage("autoSave", autosave.data[autosave.data.length - 1]); + core.setLocalForage("autoSave", autosave.data[autosave.now-1]); } } @@ -1634,6 +1640,7 @@ control.prototype.doSL = function (id, type) { switch (type) { case 'save': this._doSL_save(id); break; case 'load': this._doSL_load(id, this._doSL_load_afterGet); break; + case 'reload': this._doSL_reload(id, this._doSL_load_afterGet); break; case 'replayLoad': this._doSL_load(id, this._doSL_replayLoad_afterGet); break; case 'replayRemain': this._doSL_load(id, this._doSL_replayRemain_afterGet); break; } @@ -1666,11 +1673,22 @@ control.prototype._doSL_save = function (id) { control.prototype._doSL_load = function (id, callback) { if (id == 'autoSave' && core.saves.autosave.data != null) { - var data = core.saves.autosave.data.pop(); - if (core.saves.autosave.data.length == 0) { - core.saves.autosave.data.push(core.clone(data)); + if(core.saves.autosave.now>0) + { + core.saves.autosave.now=core.saves.autosave.now-1; + var data = core.saves.autosave.data.splice(core.saves.autosave.now,1)[0]; + if(core.status.played && !core.status.gameOver) + { + core.control.autosave(0); + core.saves.autosave.now=core.saves.autosave.now-1; + } + if(core.saves.autosave.now==0) + { + core.saves.autosave.data.unshift(data); + core.saves.autosave.now=core.saves.autosave.now+1; + } + callback(id, data); } - callback(id, data); } else { core.getLocalForage(id=='autoSave'?id:"save"+id, null, function(data) { @@ -1679,7 +1697,7 @@ control.prototype._doSL_load = function (id, callback) { if (!(core.saves.autosave.data instanceof Array)) { core.saves.autosave.data = [core.saves.autosave.data]; } - return core.control._doSL_load(id, callback); + return core.control._doSL_load(id, callback); } callback(id, data); }, function(err) { @@ -1690,6 +1708,15 @@ control.prototype._doSL_load = function (id, callback) { return; } +control.prototype._doSL_reload = function (id, callback) { + if (core.saves.autosave.data!=null&&core.saves.autosave.now < core.saves.autosave.data.length) { + var data = core.saves.autosave.data.splice(core.saves.autosave.now,1)[0]; + core.control.autosave(0); + callback(id, data); + } + return; +} + control.prototype._doSL_load_afterGet = function (id, data) { if (!data) return alert("无效的存档"); var _replay = function () { @@ -1860,7 +1887,7 @@ control.prototype.getSave = function (index, callback) { if (index == 0) { // --- 自动存档先从缓存中获取 if (core.saves.autosave.data != null) - callback(core.saves.autosave.data); + callback(core.saves.autosave.data,core.saves.autosave.now); else { core.getLocalForage("autoSave", null, function(data) { if (data != null) { @@ -1868,32 +1895,34 @@ control.prototype.getSave = function (index, callback) { if (!(core.saves.autosave.data instanceof Array)) { core.saves.autosave.data = [core.saves.autosave.data]; } + core.saves.autosave.now=core.saves.autosave.data.length; } - callback(core.saves.autosave.data); + callback(core.saves.autosave.data,-1); }, function(err) { main.log(err); - callback(null); + callback(null,-1); }); } return; } core.getLocalForage("save"+index, null, function(data) { - if (callback) callback(data); + if (callback) callback(data,-1); }, function(err) { main.log(err); - if (callback) callback(null); + if (callback) callback(null,-1); }); } control.prototype.getSaves = function (ids, callback) { if (!(ids instanceof Array)) return this.getSave(ids, callback); - var count = ids.length, data = {}; + var count = ids.length, data = {},flag=-1; for (var i = 0; i < ids.length; ++i) { (function (i) { - core.getSave(ids[i], function (result) { + core.getSave(ids[i], function (result,_flag) { data[i] = result; + if(_flag!=-1)flag=_flag; if (Object.keys(data).length == count) - callback(data); + callback(data,flag); }) })(i); } diff --git a/libs/core.js b/libs/core.js index f02616ac..f3097a12 100644 --- a/libs/core.js +++ b/libs/core.js @@ -107,7 +107,8 @@ function core() { "time": 0, "updated": false, "storage": true, // 是否把自动存档写入文件a - "max": 10, // 自动存档最大回退数 + "max": 20, // 自动存档最大回退数 + "now": 0, }, "favorite": [], "favoriteName": {} diff --git a/libs/ui.js b/libs/ui.js index 3a51a6a4..da2c1ee2 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -2501,10 +2501,10 @@ ui.prototype._drawSLPanel_loadSave = function(page, callback) { id = core.saves.favorite[id - 1]; // 因为favorite第一个不是自动存档 所以要偏移1 ids.push(id); } - core.getSaves(ids, function (data) { + core.getSaves(ids, function (data, flag) { for (var i = 1; i < ids.length; ++i) core.status.event.ui[i] = data[i]; - core.status.event.ui[0] = data[0] == null ? null : data[0][data[0].length-1]; + core.status.event.ui[0] = data[0] == null ? null : data[0][flag==-1?data[0].length-1:flag-1]; callback(); }); } From 0270775b4d3647a6f65b79d55bc56e6c5e88e834 Mon Sep 17 00:00:00 2001 From: Orz-zrO <1627711948@qq.com> Date: Sun, 8 Mar 2020 22:57:24 +0800 Subject: [PATCH 02/10] Add files via upload --- project/functions.js | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/project/functions.js b/project/functions.js index c771bb60..28a70be3 100644 --- a/project/functions.js +++ b/project/functions.js @@ -119,8 +119,10 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // ---------- 此时还没有进行切换,当前floorId还是原来的 ---------- // var currentId = core.status.floorId || null; // 获得当前的floorId,可能为null - if (!core.hasFlag("__leaveLoc__")) core.setFlag("__leaveLoc__", {}); - if (currentId != null) core.getFlag("__leaveLoc__")[currentId] = core.status.hero.loc; + if (!fromLoad) { + if (!core.hasFlag("__leaveLoc__")) core.setFlag("__leaveLoc__", {}); + if (currentId != null) core.getFlag("__leaveLoc__")[currentId] = core.status.hero.loc; + } // 可以对currentId进行判定,比如删除某些自定义图层等 // if (currentId == 'MT0') { @@ -808,6 +810,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = case 65: // A:读取自动存档(回退) core.doSL("autoSave", "load"); break; + case 87: // W:撤销回退 + core.doSL("autoSave", "reload"); + break; case 83: // S:存档 core.save(true); break; @@ -904,6 +909,12 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } } break; + case 53: // 5:读取自动存档(回退),方便手机版操作 + core.doSL("autoSave", "load"); + break; + case 54: // 6:撤销回退,方便手机版操作 + core.doSL("autoSave", "reload"); + break; case 55: // 快捷键7:绑定为轻按,方便手机版操作 core.getNextItem(); break; @@ -917,20 +928,20 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.useItem('skill1', true); } break; - // 在这里可以任意新增或编辑已有的快捷键内容 - /* - case 0: // 使用该按键的keyCode - // 还可以再判定altKey是否被按下,即 if (altKey) { ... + // 在这里可以任意新增或编辑已有的快捷键内容 + /* + case 0: // 使用该按键的keyCode + // 还可以再判定altKey是否被按下,即 if (altKey) { ... - // ... 在这里写你要执行脚本 - // **强烈建议所有新增的自定义快捷键均能给个对应的道具可点击,以方便手机端的行为** - if (core.hasItem('...')) { - core.status.route.push("key:0"); - core.useItem('...', true); // 增加true代表该使用道具不计入录像 - } + // ... 在这里写你要执行脚本 + // **强烈建议所有新增的自定义快捷键均能给个对应的道具可点击,以方便手机端的行为** + if (core.hasItem('...')) { + core.status.route.push("key:0"); + core.useItem('...', true); // 增加true代表该使用道具不计入录像 + } - break; - */ + break; + */ } }, From dee66113b3bba30dd00acc150bb5f248390967a3 Mon Sep 17 00:00:00 2001 From: Orz-zrO <1627711948@qq.com> Date: Sun, 8 Mar 2020 22:57:42 +0800 Subject: [PATCH 03/10] Add files via upload --- 回退优化说明.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 回退优化说明.txt diff --git a/回退优化说明.txt b/回退优化说明.txt new file mode 100644 index 00000000..ab7b147b --- /dev/null +++ b/回退优化说明.txt @@ -0,0 +1,3 @@ +原先的版本中A键可以回到之前的自动存档状态 +现在A和W可以在最近的若干状态来回滚动 +为了方便手机 默认56两个数字键是同样功能 可在按键设置中自己修改 \ No newline at end of file From cf32b4395d702db2c23b7c4c8d5d69c19a0cc425 Mon Sep 17 00:00:00 2001 From: Orz-zrO <1627711948@qq.com> Date: Sun, 8 Mar 2020 23:58:32 +0800 Subject: [PATCH 04/10] Add files via upload --- libs/control.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libs/control.js b/libs/control.js index 333d5083..e9221a9e 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1673,8 +1673,6 @@ control.prototype._doSL_save = function (id) { control.prototype._doSL_load = function (id, callback) { if (id == 'autoSave' && core.saves.autosave.data != null) { - if(core.saves.autosave.now>0) - { core.saves.autosave.now=core.saves.autosave.now-1; var data = core.saves.autosave.data.splice(core.saves.autosave.now,1)[0]; if(core.status.played && !core.status.gameOver) @@ -1684,11 +1682,10 @@ control.prototype._doSL_load = function (id, callback) { } if(core.saves.autosave.now==0) { - core.saves.autosave.data.unshift(data); + core.saves.autosave.data.unshift(core.clone(data)); core.saves.autosave.now=core.saves.autosave.now+1; } callback(id, data); - } } else { core.getLocalForage(id=='autoSave'?id:"save"+id, null, function(data) { From 56dd41bdecc5c4782fcdc425559016fe711a08cb Mon Sep 17 00:00:00 2001 From: Orz-zrO <1627711948@qq.com> Date: Mon, 9 Mar 2020 00:12:52 +0800 Subject: [PATCH 05/10] Add files via upload --- libs/control.js | 15 +++++++-------- libs/ui.js | 4 ++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/libs/control.js b/libs/control.js index e9221a9e..2834831c 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1884,7 +1884,7 @@ control.prototype.getSave = function (index, callback) { if (index == 0) { // --- 自动存档先从缓存中获取 if (core.saves.autosave.data != null) - callback(core.saves.autosave.data,core.saves.autosave.now); + callback(core.saves.autosave.data); else { core.getLocalForage("autoSave", null, function(data) { if (data != null) { @@ -1894,7 +1894,7 @@ control.prototype.getSave = function (index, callback) { } core.saves.autosave.now=core.saves.autosave.data.length; } - callback(core.saves.autosave.data,-1); + callback(core.saves.autosave.data); }, function(err) { main.log(err); callback(null,-1); @@ -1903,23 +1903,22 @@ control.prototype.getSave = function (index, callback) { return; } core.getLocalForage("save"+index, null, function(data) { - if (callback) callback(data,-1); + if (callback) callback(data); }, function(err) { main.log(err); - if (callback) callback(null,-1); + if (callback) callback(null); }); } control.prototype.getSaves = function (ids, callback) { if (!(ids instanceof Array)) return this.getSave(ids, callback); - var count = ids.length, data = {},flag=-1; + var count = ids.length, data = {}; for (var i = 0; i < ids.length; ++i) { (function (i) { - core.getSave(ids[i], function (result,_flag) { + core.getSave(ids[i], function (result) { data[i] = result; - if(_flag!=-1)flag=_flag; if (Object.keys(data).length == count) - callback(data,flag); + callback(data); }) })(i); } diff --git a/libs/ui.js b/libs/ui.js index da2c1ee2..8c11dd0b 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -2501,10 +2501,10 @@ ui.prototype._drawSLPanel_loadSave = function(page, callback) { id = core.saves.favorite[id - 1]; // 因为favorite第一个不是自动存档 所以要偏移1 ids.push(id); } - core.getSaves(ids, function (data, flag) { + core.getSaves(ids, function (data) { for (var i = 1; i < ids.length; ++i) core.status.event.ui[i] = data[i]; - core.status.event.ui[0] = data[0] == null ? null : data[0][flag==-1?data[0].length-1:flag-1]; + core.status.event.ui[0] = data[0] == null ? null : data[0][core.saves.autosave.now-1]; callback(); }); } From 71448349467b02e967b0c10b4ab12ce7a8e6a22f Mon Sep 17 00:00:00 2001 From: Orz-zrO <1627711948@qq.com> Date: Mon, 9 Mar 2020 00:15:27 +0800 Subject: [PATCH 06/10] Add files via upload --- libs/control.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/control.js b/libs/control.js index 2834831c..41eaca9b 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1897,7 +1897,7 @@ control.prototype.getSave = function (index, callback) { callback(core.saves.autosave.data); }, function(err) { main.log(err); - callback(null,-1); + callback(null); }); } return; From 336147a540bab820fced45663ba329e8fd9a61ae Mon Sep 17 00:00:00 2001 From: Orz-zrO <1627711948@qq.com> Date: Tue, 10 Mar 2020 11:26:31 +0800 Subject: [PATCH 07/10] Add files via upload --- libs/control.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/libs/control.js b/libs/control.js index 41eaca9b..c4d0e778 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1610,8 +1610,8 @@ control.prototype.autosave = function (removeLast) { if(core.saves.autosave.now Date: Tue, 10 Mar 2020 11:26:59 +0800 Subject: [PATCH 08/10] Add files via upload --- project/functions.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/project/functions.js b/project/functions.js index 28a70be3..56e89e5b 100644 --- a/project/functions.js +++ b/project/functions.js @@ -921,27 +921,27 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = case 118: // F7:开启debug模式 core.debug(); break; - case 87: // W:开启技能“二倍斩” + /*case 87: // W:开启技能“二倍斩” // 检测是否拥有“二倍斩”这个技能道具 if (core.hasItem('skill1')) { core.status.route.push("key:87"); core.useItem('skill1', true); } - break; - // 在这里可以任意新增或编辑已有的快捷键内容 - /* + break;*/ + // 在这里可以任意新增或编辑已有的快捷键内容 + /* case 0: // 使用该按键的keyCode - // 还可以再判定altKey是否被按下,即 if (altKey) { ... + // 还可以再判定altKey是否被按下,即 if (altKey) { ... - // ... 在这里写你要执行脚本 - // **强烈建议所有新增的自定义快捷键均能给个对应的道具可点击,以方便手机端的行为** - if (core.hasItem('...')) { - core.status.route.push("key:0"); - core.useItem('...', true); // 增加true代表该使用道具不计入录像 - } + // ... 在这里写你要执行脚本 + // **强烈建议所有新增的自定义快捷键均能给个对应的道具可点击,以方便手机端的行为** + if (core.hasItem('...')) { + core.status.route.push("key:0"); + core.useItem('...', true); // 增加true代表该使用道具不计入录像 + } - break; - */ + break; + */ } }, From 39f17acbbd1482e64fb7cb938334c9df217271be Mon Sep 17 00:00:00 2001 From: Orz-zrO <1627711948@qq.com> Date: Tue, 10 Mar 2020 11:29:43 +0800 Subject: [PATCH 09/10] Add files via upload --- project/functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/functions.js b/project/functions.js index 56e89e5b..5adf40c2 100644 --- a/project/functions.js +++ b/project/functions.js @@ -930,7 +930,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = break;*/ // 在这里可以任意新增或编辑已有的快捷键内容 /* - case 0: // 使用该按键的keyCode + case 0: // 使用该按键的keyCode // 还可以再判定altKey是否被按下,即 if (altKey) { ... // ... 在这里写你要执行脚本 From de5fd33448fa41808bcda3dffb8bb544bba07e9a Mon Sep 17 00:00:00 2001 From: Orz-zrO <1627711948@qq.com> Date: Tue, 10 Mar 2020 11:54:08 +0800 Subject: [PATCH 10/10] Add files via upload --- libs/control.js | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/control.js b/libs/control.js index c4d0e778..8ef614ae 100644 --- a/libs/control.js +++ b/libs/control.js @@ -1694,6 +1694,7 @@ control.prototype._doSL_load = function (id, callback) { if (!(core.saves.autosave.data instanceof Array)) { core.saves.autosave.data = [core.saves.autosave.data]; } + core.saves.autosave.now=core.saves.autosave.data.length; return core.control._doSL_load(id, callback); } callback(id, data);