Merge pull request #444 from Orz-zrO/master

修改后的代码 CC
This commit is contained in:
Zhang Chen 2020-03-11 20:57:46 +08:00 committed by GitHub
commit 1975ea543f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 53 additions and 12 deletions

View File

@ -1604,9 +1604,15 @@ control.prototype.autosave = function (removeLast) {
if (core.saves.autosave.data == null) { if (core.saves.autosave.data == null) {
core.saves.autosave.data = []; 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) { if (core.saves.autosave.data.length > core.saves.autosave.max) {
core.saves.autosave.data.shift(); if(core.saves.autosave.now<core.saves.autosave.max/2) core.saves.autosave.data.pop();
else
{
core.saves.autosave.data.shift();
core.saves.autosave.now=core.saves.autosave.now-1;
}
} }
core.saves.autosave.updated = true; core.saves.autosave.updated = true;
core.saves.ids[0] = true; core.saves.ids[0] = true;
@ -1625,7 +1631,7 @@ control.prototype.checkAutosave = function () {
if (autosave.data == null || !autosave.updated || !autosave.storage) return; if (autosave.data == null || !autosave.updated || !autosave.storage) return;
autosave.updated = false; autosave.updated = false;
if (autosave.data.length >= 1) { if (autosave.data.length >= 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) { switch (type) {
case 'save': this._doSL_save(id); break; case 'save': this._doSL_save(id); break;
case 'load': this._doSL_load(id, this._doSL_load_afterGet); 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 'replayLoad': this._doSL_load(id, this._doSL_replayLoad_afterGet); break;
case 'replayRemain': this._doSL_load(id, this._doSL_replayRemain_afterGet); break; case 'replayRemain': this._doSL_load(id, this._doSL_replayRemain_afterGet); break;
} }
@ -1666,9 +1673,17 @@ control.prototype._doSL_save = function (id) {
control.prototype._doSL_load = function (id, callback) { control.prototype._doSL_load = function (id, callback) {
if (id == 'autoSave' && core.saves.autosave.data != null) { if (id == 'autoSave' && core.saves.autosave.data != null) {
var data = core.saves.autosave.data.pop(); core.saves.autosave.now=core.saves.autosave.now-1;
if (core.saves.autosave.data.length == 0) { var data = core.saves.autosave.data.splice(core.saves.autosave.now,1)[0];
core.saves.autosave.data.push(core.clone(data)); 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(core.clone(data));
core.saves.autosave.now=core.saves.autosave.now+1;
} }
callback(id, data); callback(id, data);
} }
@ -1679,6 +1694,7 @@ control.prototype._doSL_load = function (id, callback) {
if (!(core.saves.autosave.data instanceof Array)) { if (!(core.saves.autosave.data instanceof Array)) {
core.saves.autosave.data = [core.saves.autosave.data]; core.saves.autosave.data = [core.saves.autosave.data];
} }
core.saves.autosave.now=core.saves.autosave.data.length;
return core.control._doSL_load(id, callback); return core.control._doSL_load(id, callback);
} }
callback(id, data); callback(id, data);
@ -1690,6 +1706,15 @@ control.prototype._doSL_load = function (id, callback) {
return; 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) { control.prototype._doSL_load_afterGet = function (id, data) {
if (!data) return alert("无效的存档"); if (!data) return alert("无效的存档");
var _replay = function () { var _replay = function () {
@ -1868,6 +1893,7 @@ control.prototype.getSave = function (index, callback) {
if (!(core.saves.autosave.data instanceof Array)) { if (!(core.saves.autosave.data instanceof Array)) {
core.saves.autosave.data = [core.saves.autosave.data]; 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);
}, function(err) { }, function(err) {

View File

@ -107,7 +107,8 @@ function core() {
"time": 0, "time": 0,
"updated": false, "updated": false,
"storage": true, // 是否把自动存档写入文件a "storage": true, // 是否把自动存档写入文件a
"max": 10, // 自动存档最大回退数 "max": 20, // 自动存档最大回退数
"now": 0,
}, },
"favorite": [], "favorite": [],
"favoriteName": {} "favoriteName": {}

View File

@ -2504,7 +2504,7 @@ ui.prototype._drawSLPanel_loadSave = function(page, callback) {
core.getSaves(ids, function (data) { core.getSaves(ids, function (data) {
for (var i = 1; i < ids.length; ++i) for (var i = 1; i < ids.length; ++i)
core.status.event.ui[i] = data[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][core.saves.autosave.now-1];
callback(); callback();
}); });
} }

View File

@ -120,8 +120,10 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// ---------- 此时还没有进行切换当前floorId还是原来的 ---------- // // ---------- 此时还没有进行切换当前floorId还是原来的 ---------- //
var currentId = core.status.floorId || null; // 获得当前的floorId可能为null var currentId = core.status.floorId || null; // 获得当前的floorId可能为null
if (!core.hasFlag("__leaveLoc__")) core.setFlag("__leaveLoc__", {}); if (!fromLoad) {
if (currentId != null) core.getFlag("__leaveLoc__")[currentId] = core.status.hero.loc; if (!core.hasFlag("__leaveLoc__")) core.setFlag("__leaveLoc__", {});
if (currentId != null) core.getFlag("__leaveLoc__")[currentId] = core.status.hero.loc;
}
// 可以对currentId进行判定比如删除某些自定义图层等 // 可以对currentId进行判定比如删除某些自定义图层等
// if (currentId == 'MT0') { // if (currentId == 'MT0') {
@ -809,6 +811,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
case 65: // A读取自动存档回退 case 65: // A读取自动存档回退
core.doSL("autoSave", "load"); core.doSL("autoSave", "load");
break; break;
case 87: // W撤销回退
core.doSL("autoSave", "reload");
break;
case 83: // S存档 case 83: // S存档
core.save(true); core.save(true);
break; break;
@ -905,19 +910,25 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
} }
} }
break; break;
case 53: // 5读取自动存档回退方便手机版操作
core.doSL("autoSave", "load");
break;
case 54: // 6撤销回退方便手机版操作
core.doSL("autoSave", "reload");
break;
case 55: // 快捷键7绑定为轻按方便手机版操作 case 55: // 快捷键7绑定为轻按方便手机版操作
core.getNextItem(); core.getNextItem();
break; break;
case 118: // F7开启debug模式 case 118: // F7开启debug模式
core.debug(); core.debug();
break; break;
case 87: // W开启技能“二倍斩” /*case 87: // W开启技能二倍斩
// 检测是否拥有“二倍斩”这个技能道具 // 检测是否拥有“二倍斩”这个技能道具
if (core.hasItem('skill1')) { if (core.hasItem('skill1')) {
core.status.route.push("key:87"); core.status.route.push("key:87");
core.useItem('skill1', true); core.useItem('skill1', true);
} }
break; break;*/
// 在这里可以任意新增或编辑已有的快捷键内容 // 在这里可以任意新增或编辑已有的快捷键内容
/* /*
case 0: // 使用该按键的keyCode case 0: // 使用该按键的keyCode

3
回退优化说明.txt Normal file
View File

@ -0,0 +1,3 @@
原先的版本中A键可以回到之前的自动存档状态
现在A和W可以在最近的若干状态来回滚动
为了方便手机 默认56两个数字键是同样功能 可在按键设置中自己修改