replay from save
This commit is contained in:
parent
e6ccdf75ed
commit
75e5c8538e
@ -106,7 +106,7 @@ actions.prototype.keyDown = function(keyCode) {
|
||||
this.keyDownToolbox(keyCode);
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id=='save' || core.status.event.id=='load') {
|
||||
if (core.status.event.id=='save' || core.status.event.id=='load' || core.status.event.id=='replayLoad') {
|
||||
this.keyDownSL(keyCode);
|
||||
return;
|
||||
}
|
||||
@ -138,6 +138,9 @@ actions.prototype.keyDown = function(keyCode) {
|
||||
this.keyDownCursor(keyCode);
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id=='replay') {
|
||||
this.keyDownReplay(keyCode);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(!core.status.played) {
|
||||
@ -237,7 +240,7 @@ actions.prototype.keyUp = function(keyCode, fromReplay) {
|
||||
this.keyUpToolbox(keyCode);
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id=='save' || core.status.event.id=='load') {
|
||||
if (core.status.event.id=='save' || core.status.event.id=='load' || core.status.event.id=='replayLoad') {
|
||||
this.keyUpSL(keyCode);
|
||||
return;
|
||||
}
|
||||
@ -269,6 +272,10 @@ actions.prototype.keyUp = function(keyCode, fromReplay) {
|
||||
this.keyUpCursor(keyCode);
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id=='replay') {
|
||||
this.keyUpReplay(keyCode);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -325,19 +332,8 @@ actions.prototype.keyUp = function(keyCode, fromReplay) {
|
||||
core.ui.drawHelp();
|
||||
break;
|
||||
case 82: // R
|
||||
if (core.status.heroStop) {
|
||||
core.ui.drawConfirmBox("确定要回放录像吗?", function () {
|
||||
core.ui.closePanel();
|
||||
var hard=core.status.hard, route=core.clone(core.status.route);
|
||||
core.resetStatus(core.firstData.hero, hard, core.firstData.floorId, null, core.initStatus.maps);
|
||||
core.events.setInitData(hard);
|
||||
core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() {
|
||||
core.startReplay(route);
|
||||
}, true);
|
||||
}, function () {
|
||||
core.ui.closePanel();
|
||||
});
|
||||
}
|
||||
if (core.status.heroStop)
|
||||
core.ui.drawReplay();
|
||||
break;
|
||||
case 33: case 34: // PAGEUP/PAGEDOWN
|
||||
if (core.status.heroStop) {
|
||||
@ -606,7 +602,7 @@ actions.prototype.onclick = function (x, y, stepPostfix) {
|
||||
}
|
||||
|
||||
// 存读档
|
||||
if (core.status.event.id == 'save' || core.status.event.id == 'load') {
|
||||
if (core.status.event.id == 'save' || core.status.event.id == 'load' || core.status.event.id=='replayLoad') {
|
||||
this.clickSL(x,y);
|
||||
return;
|
||||
}
|
||||
@ -664,6 +660,11 @@ actions.prototype.onclick = function (x, y, stepPostfix) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (core.status.event.id == 'replay') {
|
||||
this.clickReplay(x,y);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
////// 滑动鼠标滚轮时的操作 //////
|
||||
@ -1902,6 +1903,68 @@ actions.prototype.keyUpStorageRemove = function (keycode) {
|
||||
}
|
||||
}
|
||||
|
||||
////// 回放选择界面时的点击操作 //////
|
||||
actions.prototype.clickReplay = function (x, y) {
|
||||
if (x<5 || x>7) return;
|
||||
var choices = core.status.event.ui.choices;
|
||||
|
||||
var topIndex = 6 - parseInt((choices.length - 1) / 2);
|
||||
|
||||
if (y>=topIndex && y<topIndex+choices.length) {
|
||||
var selection = y - topIndex;
|
||||
switch (selection) {
|
||||
case 0:
|
||||
{
|
||||
core.ui.closePanel();
|
||||
var hard=core.status.hard, route=core.clone(core.status.route);
|
||||
core.resetStatus(core.firstData.hero, hard, core.firstData.floorId, null, core.initStatus.maps);
|
||||
core.events.setInitData(hard);
|
||||
core.changeFloor(core.status.floorId, null, core.firstData.hero.loc, null, function() {
|
||||
core.startReplay(route);
|
||||
}, true);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
core.status.event.id = 'replayLoad';
|
||||
core.status.event.selection = null;
|
||||
var saveIndex = core.status.saveIndex;
|
||||
var page=parseInt((saveIndex-1)/5), offset=saveIndex-5*page;
|
||||
core.ui.drawSLPanel(10*page+offset);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
core.ui.closePanel();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////// 回放选择界面时,按下某个键的操作 //////
|
||||
actions.prototype.keyDownReplay = function (keycode) {
|
||||
if (keycode==38) {
|
||||
core.status.event.selection--;
|
||||
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
|
||||
}
|
||||
if (keycode==40) {
|
||||
core.status.event.selection++;
|
||||
core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices);
|
||||
}
|
||||
}
|
||||
|
||||
////// 回放选择界面时,放开某个键的操作 //////
|
||||
actions.prototype.keyUpReplay = function (keycode) {
|
||||
if (keycode==27 || keycode==88) {
|
||||
core.ui.closePanel();
|
||||
return;
|
||||
}
|
||||
var choices = core.status.event.ui.choices;
|
||||
if (keycode==13 || keycode==32 || keycode==67) {
|
||||
var topIndex = 6 - parseInt((choices.length - 1) / 2);
|
||||
this.clickReplay(6, topIndex+core.status.event.selection);
|
||||
}
|
||||
}
|
||||
|
||||
////// “虚拟键盘”界面时的点击操作 //////
|
||||
actions.prototype.clickKeyBoard = function (x, y) {
|
||||
if (y==3 && x>=1 && x<=11) {
|
||||
|
||||
@ -1815,6 +1815,30 @@ control.prototype.doSL = function (id, type) {
|
||||
});
|
||||
return;
|
||||
}
|
||||
else if (type == 'replayLoad') {
|
||||
var data = core.getLocalStorage(id=='autoSave'?id:"save"+id, null);
|
||||
if (!core.isset(data)) {
|
||||
core.drawTip("无效的存档");
|
||||
return;
|
||||
}
|
||||
if (data.version != core.firstData.version) {
|
||||
core.drawTip("存档版本不匹配");
|
||||
return;
|
||||
}
|
||||
if (data.hard != core.status.hard) {
|
||||
core.drawTip("游戏难度不匹配!");
|
||||
return;
|
||||
}
|
||||
var route = core.subarray(core.status.route, core.decodeRoute(data.route));
|
||||
if (!core.isset(route)) {
|
||||
core.drawTip("无法从此存档回放录像");
|
||||
return;
|
||||
}
|
||||
core.loadData(data, function () {
|
||||
core.startReplay(route);
|
||||
core.drawTip("回退到存档节点");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
////// 同步存档到服务器 //////
|
||||
|
||||
@ -1067,6 +1067,11 @@ core.prototype.isset = function (val) {
|
||||
return core.utils.isset(val);
|
||||
}
|
||||
|
||||
////// 获得子数组 //////
|
||||
core.prototype.subarray = function (a, b) {
|
||||
return core.utils.subarray(a, b);
|
||||
}
|
||||
|
||||
////// 读取一个本地文件内容 //////
|
||||
core.prototype.readFile = function (success, error, readType) {
|
||||
core.utils.readFile(success, error, readType);
|
||||
|
||||
18
libs/ui.js
18
libs/ui.js
@ -1132,6 +1132,14 @@ ui.prototype.drawStorageRemove = function () {
|
||||
]);
|
||||
}
|
||||
|
||||
ui.prototype.drawReplay = function () {
|
||||
core.lockControl();
|
||||
core.status.event.id = 'replay';
|
||||
this.drawChoices(null, [
|
||||
"从头回放录像", "从存档开始回放", "返回游戏"
|
||||
]);
|
||||
}
|
||||
|
||||
////// 绘制分页 //////
|
||||
ui.prototype.drawPagination = function (page, totalPage) {
|
||||
|
||||
@ -1577,7 +1585,7 @@ ui.prototype.drawSLPanel = function(index) {
|
||||
var strokeColor = '#FFD700';
|
||||
if (core.status.event.selection) strokeColor = '#FF6A6A';
|
||||
|
||||
var name=core.status.event.id=='save'?"存档":"读档";
|
||||
var name=core.status.event.id=='save'?"存档":core.status.event.id=='load'?"读档":core.status.event.id=='replayLoad'?"回放":"";
|
||||
for (var i=0;i<6;i++) {
|
||||
var id=5*page+i;
|
||||
var data=core.getLocalStorage(i==0?"autoSave":"save"+id, null);
|
||||
@ -1608,9 +1616,11 @@ ui.prototype.drawSLPanel = function(index) {
|
||||
}
|
||||
this.drawPagination(page+1, 30);
|
||||
|
||||
if (core.status.event.selection)
|
||||
core.setFillStyle('ui', '#FF6A6A');
|
||||
core.fillText('ui', '删除模式', 48, 403);
|
||||
if (core.status.event.id == 'save' || core.status.event.id=='load') {
|
||||
if (core.status.event.selection)
|
||||
core.setFillStyle('ui', '#FF6A6A');
|
||||
core.fillText('ui', '删除模式', 48, 403);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -300,6 +300,17 @@ utils.prototype.isset = function (val) {
|
||||
return true
|
||||
}
|
||||
|
||||
////// 获得子数组 //////
|
||||
utils.prototype.subarray = function (a, b) {
|
||||
if (!core.isset(a) || !core.isset(b) || !(a instanceof Array) || !(b instanceof Array) || a.length<b.length)
|
||||
return null;
|
||||
var na = core.clone(a), nb=core.clone(b);
|
||||
while (nb.length>0) {
|
||||
if (na.shift() != nb.shift()) return null;
|
||||
}
|
||||
return na;
|
||||
}
|
||||
|
||||
////// 读取一个本地文件内容 //////
|
||||
utils.prototype.readFile = function (success, error, readType) {
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user