drawSL
This commit is contained in:
parent
a684b80ae8
commit
46aa0c8278
190
libs/actions.js
190
libs/actions.js
@ -1578,11 +1578,9 @@ actions.prototype._keyUpEquipbox = function (keycode, altKey) {
|
||||
}
|
||||
|
||||
////// 存读档界面时的点击操作 //////
|
||||
actions.prototype._clickSL = function (x, y, px, py) {
|
||||
actions.prototype._clickSL = function (x, y) {
|
||||
var page = core.status.event.data.page, offset = core.status.event.data.offset;
|
||||
var index = page*10 + offset;
|
||||
//var index = core.status.event.data;
|
||||
//var page = parseInt(index / 10), offset = index % 10;
|
||||
var index = page * 10 + offset;
|
||||
|
||||
// 上一页
|
||||
if ((x == this.HSIZE-2 || x == this.HSIZE-3) && y == this.LAST) {
|
||||
@ -1596,13 +1594,11 @@ actions.prototype._clickSL = function (x, y, px, py) {
|
||||
}
|
||||
// 返回
|
||||
if (x >= this.LAST-2 && y == this.LAST) {
|
||||
if (core.events.recoverEvents(core.status.event.interval)) {
|
||||
if (core.events.recoverEvents(core.status.event.interval))
|
||||
return;
|
||||
}
|
||||
core.ui.closePanel();
|
||||
if (!core.isPlaying()) {
|
||||
if (!core.isPlaying())
|
||||
core.showStartAnimate(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// 删除
|
||||
@ -1611,36 +1607,31 @@ actions.prototype._clickSL = function (x, y, px, py) {
|
||||
core.status.event.selection = !core.status.event.selection;
|
||||
core.ui.drawSLPanel(index);
|
||||
}
|
||||
else {// 显示收藏
|
||||
else { // 显示收藏
|
||||
core.status.event.data.mode = core.status.event.data.mode == 'all'?'fav':'all';
|
||||
core.saves.index = {};
|
||||
for(var i in core.saves.favorite){
|
||||
core.saves.index[i] = core.saves.favorite[i];
|
||||
if (core.status.event.data.mode == 'fav')
|
||||
core.ui.drawSLPanel(1, true);
|
||||
else {
|
||||
page = parseInt((core.saves.saveIndex-1)/5);
|
||||
offset = core.saves.saveIndex-5*page;
|
||||
core.ui.drawSLPanel(10*page + offset);
|
||||
}
|
||||
core.ui.drawSLPanel(index,true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// 收藏
|
||||
var fav = null;
|
||||
var centerX = parseInt(this.SIZE/2), leftX = 2, rightX = this.LAST-2;
|
||||
|
||||
// 三个关键坐标:
|
||||
var xLeft = parseInt(this.SIZE/3),xRight = parseInt(this.SIZE*2/3);
|
||||
var topY1 = 0, topY2 = parseInt(this.SIZE/2);
|
||||
|
||||
// 点存档名
|
||||
var xLeft = parseInt(this.SIZE/3), xRight = parseInt(this.SIZE*2/3);
|
||||
var topY1 = 0, topY2 = this.HSIZE;
|
||||
if(y==topY1){
|
||||
if (x >= xLeft && x < xRight) fav = 5 * page + 1;
|
||||
if (x >= xRight) fav = 5 * page + 2;
|
||||
if (x >= xLeft && x < xRight) return this._clickSL_favorite(page, 1);
|
||||
if (x >= xRight) return this._clickSL_favorite(page, 2);
|
||||
}
|
||||
if(y==topY2){
|
||||
if (x < xLeft) fav = 5 * page + 3;
|
||||
if (x >= xLeft && x < xRight) fav = 5 * page + 4;
|
||||
if (x >= xRight) fav = 5 * page + 5;
|
||||
}
|
||||
if (fav != null){
|
||||
this._keyDownFav(page,fav%5);
|
||||
if (x < xLeft) return this._clickSL_favorite(page, 3);
|
||||
if (x >= xLeft && x < xRight) return this._clickSL_favorite(page, 4);
|
||||
if (x >= xRight) return this._clickSL_favorite(page, 5);
|
||||
}
|
||||
|
||||
var id = null;
|
||||
var topSpan = parseInt(this.SIZE/7);
|
||||
if (y >= topY1 + topSpan && y <= topY1 + topSpan + 3) {
|
||||
@ -1655,30 +1646,52 @@ actions.prototype._clickSL = function (x, y, px, py) {
|
||||
}
|
||||
if (id != null) {
|
||||
if (core.status.event.selection) {
|
||||
if (id == 'autoSave') {
|
||||
if (id == 'autoSave')
|
||||
core.drawTip("无法删除自动存档!");
|
||||
}
|
||||
else {
|
||||
// core.removeLocalStorage("save"+id);
|
||||
core.removeLocalForage("save" + id, function () {
|
||||
var idx = core.saves.favorite.indexOf(id);
|
||||
core.saves.favorite.splice(idx,1);
|
||||
delete core.saves.favName[id];
|
||||
core.ui._drawSLPanel_saveFav(function(){
|
||||
core.ui._drawSLPanel_flushIndex();
|
||||
core.ui.drawSLPanel(index, true)});
|
||||
}, function () {
|
||||
core.drawTip("无法删除存档!");
|
||||
})
|
||||
core.removeSave(id, function () {
|
||||
core.ui.drawSLPanel(index, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(core.status.event.data.mode=='fav')id = core.saves.favIndex[id];
|
||||
if(core.status.event.data.mode == 'fav' && id != 'autoSave')
|
||||
id = core.saves.favorite[id - 1];
|
||||
core.doSL(id, core.status.event.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
actions.prototype._clickSL_favorite = function (page, offset) {
|
||||
if (offset == 0) return;
|
||||
var index = 5 * page + offset;
|
||||
if (core.status.event.data.mode == 'fav') { // 收藏模式下点击的下标直接对应favorite
|
||||
index = core.saves.favorite[index - 1];
|
||||
core.myprompt("请输入想要显示的存档名(长度不超过5字符)", null, function (value) {
|
||||
if(value && value.length <= 5){
|
||||
core.saves.favoriteName[index] = value;
|
||||
core.control._updateFavoriteSaves();
|
||||
core.drawSLPanel(10 * page + offset);
|
||||
} else if (value) {
|
||||
alert("无效的输入!");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var v = core.saves.favorite.indexOf(index);
|
||||
if (v >= 0) { // 已经处于收藏状态:取消收藏
|
||||
core.saves.favorite.splice(v, 1);
|
||||
delete core.saves.favoriteName[index];
|
||||
}
|
||||
else if (core.hasSave(index)) { // 存在存档则进行收藏
|
||||
core.saves.favorite.push(index);
|
||||
core.saves.favorite = core.saves.favorite.sort(function (a,b) {return a-b;}); // 保证有序
|
||||
core.drawTip("收藏成功!");
|
||||
}
|
||||
core.control._updateFavoriteSaves();
|
||||
core.ui.drawSLPanel(10 * page + offset);
|
||||
}
|
||||
}
|
||||
|
||||
////// 存读档界面时,按下某个键的操作 //////
|
||||
actions.prototype._keyDownSL = function (keycode) {
|
||||
|
||||
@ -1730,76 +1743,30 @@ actions.prototype._keyDownSL = function (keycode) {
|
||||
core.ui.drawSLPanel(10 * (page + 1) + offset);
|
||||
return;
|
||||
}
|
||||
if (keycode == 70){ // F
|
||||
this._keyDownFav(page,offset);
|
||||
}
|
||||
}
|
||||
actions.prototype._keyDownFav = function(page, offset){
|
||||
var fav = page*5+offset;
|
||||
var idx = fav;
|
||||
var index = page*10 + offset;
|
||||
if(core.status.event.data.mode=='fav'){//收藏模式下点击的下标直接对应favorite
|
||||
fav = core.saves.favIndex[idx];
|
||||
var dataIdx = index;
|
||||
core.myprompt("请输入想要显示的存档名(长度不超过5字符)", null, function (index) {
|
||||
if(index && index.length<=5 && index.length>0){
|
||||
core.saves.favName[fav]=index;
|
||||
core.ui._drawSLPanel_saveFav(function(){core.ui.drawSLPanel(dataIdx, false)});
|
||||
}else{
|
||||
alert("无效的输入!");
|
||||
}
|
||||
});
|
||||
}else{
|
||||
idx = core.saves.favorite.indexOf(fav);
|
||||
if(idx>=0){
|
||||
core.saves.favorite.splice(idx,1);
|
||||
delete core.saves.favName[fav];
|
||||
}else{
|
||||
if(core.hasSave(fav)){
|
||||
core.saves.favorite.push(fav);
|
||||
core.saves.favName[idx] = fav;//暂时的 收藏下标到名字的映射(实际存储的是收藏ID到名字的映射)
|
||||
}
|
||||
}
|
||||
core.ui._drawSLPanel_saveFav(function(){
|
||||
core.ui._drawSLPanel_flushIndex();
|
||||
core.ui.drawSLPanel(index, false)});
|
||||
}
|
||||
}
|
||||
|
||||
////// 存读档界面时,放开某个键的操作 //////
|
||||
actions.prototype._keyUpSL = function (keycode) {
|
||||
var page = core.status.event.data.page, offset = core.status.event.data.offset;
|
||||
var index = page*10 + offset;
|
||||
var index = page * 10 + offset;
|
||||
|
||||
if (keycode == 27 || keycode == 88 || (core.status.event.id == 'save' && keycode == 83) || (core.status.event.id == 'load' && keycode == 68)) {
|
||||
if (core.events.recoverEvents(core.status.event.interval)) {
|
||||
return;
|
||||
}
|
||||
core.ui.closePanel();
|
||||
if (!core.isPlaying()) {
|
||||
core.showStartAnimate(true);
|
||||
}
|
||||
if (keycode == 27 || keycode == 88 || (core.status.event.id == 'save' && keycode == 83)
|
||||
|| (core.status.event.id == 'load' && keycode == 68)) {
|
||||
this._clickSL(this.LAST, this.LAST);
|
||||
return;
|
||||
}
|
||||
if (keycode == 13 || keycode == 32 || keycode == 67) {
|
||||
if (offset == 0) {
|
||||
if (offset == 0)
|
||||
core.doSL("autoSave", core.status.event.id);
|
||||
}
|
||||
else {
|
||||
var id = 5 * page + offset;
|
||||
if(core.status.event.data.mode=='fav')id = core.saves.favIndex[id];
|
||||
if(core.status.event.data.mode == 'fav') id = core.saves.favorite[id - 1];
|
||||
core.doSL(id, core.status.event.id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (keycode == 69 && core.status.event.id != 'save') { // E 收藏切换
|
||||
core.status.event.data.mode = core.status.event.data.mode == 'all'?'fav':'all';
|
||||
core.saves.index = {};
|
||||
for(var i in core.saves.favorite){
|
||||
core.saves.index[i] = core.saves.favorite[i];
|
||||
}
|
||||
core.ui.drawSLPanel(core.saves.saveIndex,true);
|
||||
|
||||
this._clickSL(0, this.LAST);
|
||||
return;
|
||||
}
|
||||
if (keycode == 46) {
|
||||
@ -1807,19 +1774,16 @@ actions.prototype._keyUpSL = function (keycode) {
|
||||
core.drawTip("无法删除自动存档!");
|
||||
}
|
||||
else {
|
||||
core.removeLocalForage("save" + (5 * page + offset), function () {
|
||||
var id = 5 * page + offset;
|
||||
var idx = core.saves.favorite.indexOf(id);
|
||||
core.saves.favorite.splice(idx,1);
|
||||
delete core.saves.favName[id];
|
||||
core.ui._drawSLPanel_saveFav(function(){
|
||||
core.ui._drawSLPanel_flushIndex();
|
||||
core.ui.drawSLPanel(index, true)});
|
||||
}, function () {
|
||||
core.drawTip("无法删除存档!");
|
||||
})
|
||||
var id = 5 * page + offset;
|
||||
if(core.status.event.data.mode == 'fav') id = core.saves.favorite[id - 1];
|
||||
core.removeSave(id, function () {
|
||||
core.ui.drawSLPanel(index, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
if (keycode == 70 && core.status.event.data.mode == 'all') { // F
|
||||
this._clickSL_favorite(page, offset);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2098,7 +2062,7 @@ actions.prototype._clickLocalSaveSelect = function (x, y) {
|
||||
var selection = y - topIndex;
|
||||
core.status.event.selection = selection;
|
||||
if (selection < 2) {
|
||||
core.control.getSaves(selection == 0 ? null : core.saves.saveIndex, function (saves) {
|
||||
core.getAllSaves(selection == 0 ? null : core.saves.saveIndex, function (saves) {
|
||||
if (saves) {
|
||||
var content = {
|
||||
"name": core.firstData.name,
|
||||
@ -2154,9 +2118,12 @@ actions.prototype._clickStorageRemove_all = function () {
|
||||
core.saves.autosave.data = null;
|
||||
core.saves.autosave.updated = false;
|
||||
core.ui.closePanel();
|
||||
core.drawText("\t[操作成功]你的所有存档已被清空。");
|
||||
core.saves.saveIndex = 1;
|
||||
core.saves.favorite = [];
|
||||
core.saves.favoriteName = {};
|
||||
core.control._updateFavoriteSaves();
|
||||
core.removeLocalStorage('saveIndex');
|
||||
core.drawText("\t[操作成功]你的所有存档已被清空。");
|
||||
};
|
||||
if (core.platform.useLocalForage) {
|
||||
core.ui.drawWaiting("正在清空,请稍后...");
|
||||
@ -2175,9 +2142,12 @@ actions.prototype._clickStorageRemove_current = function () {
|
||||
core.saves.autosave.data = null;
|
||||
core.saves.autosave.updated = false;
|
||||
core.ui.closePanel();
|
||||
core.drawText("\t[操作成功]当前塔的存档已被清空。");
|
||||
core.saves.saveIndex = 1;
|
||||
core.saves.favorite = [];
|
||||
core.saves.favoriteName = {};
|
||||
core.control._updateFavoriteSaves();
|
||||
core.removeLocalStorage('saveIndex');
|
||||
core.drawText("\t[操作成功]当前塔的存档已被清空。");
|
||||
}
|
||||
if (core.platform.useLocalForage) {
|
||||
core.ui.drawWaiting("正在清空,请稍后...");
|
||||
|
||||
107
libs/control.js
107
libs/control.js
@ -1608,7 +1608,7 @@ control.prototype._doSL_replayLoad_afterGet = function (id, data) {
|
||||
////// 同步存档到服务器 //////
|
||||
control.prototype.syncSave = function (type) {
|
||||
core.ui.drawWaiting("正在同步,请稍后...");
|
||||
core.control.getSaves(type=='all'?null:core.saves.saveIndex, function (saves) {
|
||||
core.getAllSaves(type=='all'?null:core.saves.saveIndex, function (saves) {
|
||||
if (!saves) return core.drawText("没有要同步的存档");
|
||||
core.control._syncSave_http(type, saves);
|
||||
})
|
||||
@ -1702,32 +1702,54 @@ control.prototype.loadData = function (data, callback) {
|
||||
return this.controldata.loadData(data, callback);
|
||||
}
|
||||
|
||||
control.prototype.getSaves = function (index, callback) {
|
||||
if (index != null) {
|
||||
core.getLocalForage("save"+index, null, function(data) {
|
||||
if (callback) callback(data);
|
||||
}, function(err) {
|
||||
main.log(err);
|
||||
if (callback) callback(null);
|
||||
})
|
||||
control.prototype.getSave = function (index, callback) {
|
||||
if (index == 0) {
|
||||
// --- 自动存档先从缓存中获取
|
||||
if (core.saves.autosave.data != null)
|
||||
callback(core.clone(core.saves.autosave.data));
|
||||
else {
|
||||
core.getLocalForage("autoSave", null, function(data) {
|
||||
callback(data);
|
||||
}, function(err) {
|
||||
main.log(err);
|
||||
callback(null);
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
var ids = Object.keys(core.saves.ids).filter(function(x){return x!=0;})
|
||||
.sort(function(a,b) {return a-b;}), number = ids.length, saves = [];
|
||||
var load = function (index, callback) {
|
||||
if (index > number) {
|
||||
if (callback) callback(saves);
|
||||
return;
|
||||
}
|
||||
core.getLocalForage("save"+ids[index], null, function (data) {
|
||||
saves.push(data);
|
||||
load(index+1, callback);
|
||||
}, function(err) {
|
||||
main.log(err);
|
||||
load(index+1, callback);
|
||||
})
|
||||
core.getLocalForage("save"+index, null, function(data) {
|
||||
if (callback) callback(data);
|
||||
}, function(err) {
|
||||
main.log(err);
|
||||
if (callback) callback(null);
|
||||
});
|
||||
}
|
||||
|
||||
control.prototype.getSaves = function (ids, callback) {
|
||||
if (!(ids instanceof Array)) return this.getSave(ids, callback);
|
||||
var count = ids.length, data = {};
|
||||
for (var i = 0; i < ids.length; ++i) {
|
||||
(function (i) {
|
||||
core.getSave(ids[i], function (result) {
|
||||
data[i] = result;
|
||||
if (Object.keys(data).length == count)
|
||||
callback(data);
|
||||
})
|
||||
})(i);
|
||||
}
|
||||
load(0, callback);
|
||||
}
|
||||
|
||||
control.prototype.getAllSaves = function (id, callback) {
|
||||
if (id != null) return this.getSave(id, callback);
|
||||
var ids = Object.keys(core.saves.ids).filter(function(x){return x!=0;})
|
||||
.sort(function(a,b) {return a-b;}), saves = [];
|
||||
this.getSaves(ids, function (data) {
|
||||
for (var i = 0; i < ids.length; ++i) {
|
||||
if (data[i] != null)
|
||||
saves.push(data[i]);
|
||||
}
|
||||
callback(saves);
|
||||
});
|
||||
}
|
||||
|
||||
////// 获得所有存在存档的存档位 //////
|
||||
@ -1761,6 +1783,43 @@ control.prototype.hasSave = function (index) {
|
||||
return core.saves.ids[index] || false;
|
||||
}
|
||||
|
||||
////// 删除一个或多个存档
|
||||
control.prototype.removeSave = function (index, callback) {
|
||||
if (index == 0 || index == "autoSave") {
|
||||
index = "autoSave";
|
||||
core.removeLocalForage(index, function () {
|
||||
core.saves.autosave.data = null;
|
||||
core.saves.autosave.updated = false;
|
||||
if (callback) callback();
|
||||
});
|
||||
return;
|
||||
}
|
||||
core.removeLocalForage("save" + index, function () {
|
||||
core.saves.favorite = core.saves.favorite.filter(function (i) { return core.hasSave(i); });
|
||||
delete core.saves.favoriteName[index];
|
||||
core.control._updateFavoriteSaves();
|
||||
if (callback) callback();
|
||||
}, function () {
|
||||
core.drawTip("无法删除存档!");
|
||||
if (callback) callback();
|
||||
});
|
||||
}
|
||||
|
||||
////// 读取收藏信息
|
||||
control.prototype._loadFavoriteSaves = function () {
|
||||
core.saves.favorite = core.getLocalStorage("favorite", []);
|
||||
// --- 移除不存在的收藏
|
||||
core.saves.favorite = core.saves.favorite.filter(function (i) { return core.hasSave(i); });
|
||||
core.saves.favoriteName = core.getLocalStorage("favoriteName", {});
|
||||
}
|
||||
|
||||
control.prototype._updateFavoriteSaves = function () {
|
||||
core.setLocalStorage("favorite", core.saves.favorite);
|
||||
core.setLocalStorage("favoriteName", core.saves.favoriteName);
|
||||
}
|
||||
|
||||
////// 加载某个存档
|
||||
|
||||
// ------ 属性,状态,位置,buff,变量,锁定控制等 ------ //
|
||||
|
||||
////// 设置勇士属性 //////
|
||||
|
||||
@ -67,6 +67,7 @@ function core() {
|
||||
'isPC': true, // 是否是PC
|
||||
'isAndroid': false, // 是否是Android
|
||||
'isIOS': false, // 是否是iOS
|
||||
'string': 'PC',
|
||||
'isWeChat': false, // 是否是微信
|
||||
'isQQ': false, // 是否是QQ
|
||||
'isChrome': false, // 是否是Chrome
|
||||
@ -272,6 +273,7 @@ core.prototype._init_platform = function () {
|
||||
core.platform.isPC = false;
|
||||
}
|
||||
});
|
||||
core.platform.string = core.platform.isPC ? "PC" : core.platform.isAndroid ? "Android" : core.platform.isIOS ? "iOS" : "";
|
||||
core.platform.supportCopy = document.queryCommandSupported || document.queryCommandSupported("copy");
|
||||
var chrome = /Chrome\/(\d+)\./i.exec(navigator.userAgent);
|
||||
if (chrome && parseInt(chrome[1]) >= 50) core.platform.isChrome = true;
|
||||
|
||||
@ -89,7 +89,7 @@ events.prototype._startGame_upload = function () {
|
||||
formData.append('type', 'people');
|
||||
formData.append('name', core.firstData.name);
|
||||
formData.append('version', core.firstData.version);
|
||||
formData.append('platform', core.platform.isPC ? "PC" : core.platform.isAndroid ? "Android" : core.platform.isIOS ? "iOS" : "");
|
||||
formData.append('platform', core.platform.string);
|
||||
formData.append('hard', core.encodeBase64(core.status.hard));
|
||||
formData.append('hardCode', core.getFlag('hard', 0));
|
||||
formData.append('base64', 1);
|
||||
@ -171,7 +171,7 @@ events.prototype._gameOver_doUpload = function (username, ending, norank) {
|
||||
formData.append('type', 'score');
|
||||
formData.append('name', core.firstData.name);
|
||||
formData.append('version', core.firstData.version);
|
||||
formData.append('platform', core.platform.isPC ? "PC" : core.platform.isAndroid ? "Android" : core.platform.isIOS ? "iOS" : "");
|
||||
formData.append('platform', core.platform.string);
|
||||
formData.append('hard', core.encodeBase64(core.status.hard));
|
||||
formData.append('username', core.encodeBase64(username || ""));
|
||||
formData.append('ending', core.encodeBase64(ending));
|
||||
@ -2205,7 +2205,7 @@ events.prototype.uploadCurrent = function (username) {
|
||||
formData.append('type', 'score');
|
||||
formData.append('name', core.firstData.name);
|
||||
formData.append('version', core.firstData.version);
|
||||
formData.append('platform', core.platform.isPC ? "PC" : core.platform.isAndroid ? "Android" : core.platform.isIOS ? "iOS" : "");
|
||||
formData.append('platform', core.platform.string);
|
||||
formData.append('hard', core.encodeBase64(core.status.hard));
|
||||
formData.append('username', core.encodeBase64(username || "current"));
|
||||
formData.append('lv', core.status.hero.lv);
|
||||
|
||||
202
libs/ui.js
202
libs/ui.js
@ -2022,8 +2022,9 @@ ui.prototype.drawEquipbox = function(index) {
|
||||
|
||||
////// 绘制存档/读档界面 //////
|
||||
ui.prototype.drawSLPanel = function(index, refresh) {
|
||||
if (!core.isset(index)) index=1;
|
||||
if (index<0) index=0;
|
||||
core.control._loadFavoriteSaves();
|
||||
if (index == null) index = 1;
|
||||
if (index < 0) index = 0;
|
||||
|
||||
var page = parseInt(index/10), offset=index%10;
|
||||
var max_page = main.savePages || 30;
|
||||
@ -2031,53 +2032,35 @@ ui.prototype.drawSLPanel = function(index, refresh) {
|
||||
max_page = Math.ceil((core.saves.favorite||[]).length/5);
|
||||
if (page>=max_page) page=max_page - 1;
|
||||
if (offset>5) offset=5;
|
||||
index=10*page+offset;
|
||||
if (core.status.event.data && core.status.event.data.mode=='fav' && page == max_page - 1) {
|
||||
offset = Math.min(offset, (core.saves.favorite||[]).length - 5 * page);
|
||||
}
|
||||
|
||||
var last_page = -1;
|
||||
var mode = 'all';
|
||||
if (core.isset(core.status.event.data)) {
|
||||
//last_page = parseInt(core.status.event.data/10);
|
||||
if (core.status.event.data) {
|
||||
last_page = core.status.event.data.page;
|
||||
mode = core.status.event.data.mode;
|
||||
}
|
||||
|
||||
core.status.event.data={
|
||||
'page':page,
|
||||
'offset':offset,
|
||||
'mode':mode
|
||||
};
|
||||
if (!core.isset(core.status.event.ui))
|
||||
core.status.event.data={ 'page':page, 'offset':offset, 'mode':mode };
|
||||
core.status.event.ui = core.status.event.ui || [];
|
||||
if (refresh || page != last_page) {
|
||||
core.status.event.ui = [];
|
||||
|
||||
function drawAll() {
|
||||
core.ui._drawSLPanel_drawBg(page,max_page);
|
||||
core.ui._drawSLPanel_drawNRecords(6);
|
||||
this._drawSLPanel_loadSave(page, function () {
|
||||
core.ui._drawSLPanel_draw(page, max_page);
|
||||
});
|
||||
}
|
||||
if (refresh || page!=last_page) {
|
||||
core.status.event.ui = [];
|
||||
this._drawSLPanel_loadFav(
|
||||
function(){
|
||||
core.ui._drawSLPanel_loadSave(page, 0, drawAll);
|
||||
}
|
||||
);
|
||||
}
|
||||
else drawAll();
|
||||
else this._drawSLPanel_draw(page, max_page);
|
||||
}
|
||||
|
||||
// 存档读档的背景 页码
|
||||
ui.prototype._drawSLPanel_drawBg = function(page, max_page) {
|
||||
core.clearMap('ui');
|
||||
core.setAlpha('ui', 0.85);
|
||||
core.fillRect('ui', 0, 0, this.PIXEL, this.PIXEL, '#000000');//可改成背景图图
|
||||
core.setAlpha('ui', 1);
|
||||
var globalFont = (core.status.globalAttribute||core.initStatus.globalAttribute).font;
|
||||
|
||||
core.ui.drawPagination(page+1, max_page, null);
|
||||
ui.prototype._drawSLPanel_draw = function (page, max_page) {
|
||||
// --- 绘制背景
|
||||
this._drawSLPanel_drawBackground();
|
||||
// --- 绘制文字
|
||||
core.ui.drawPagination(page+1, max_page);
|
||||
core.setTextAlign('ui', 'center');
|
||||
// 退出
|
||||
//core.fillText('ui', '返回游戏', 370, 403,'#DDDDDD', 'bold 15px '+globalFont);
|
||||
var bottom = this.PIXEL-13;
|
||||
core.fillText('ui', '返回游戏', this.PIXEL-48, bottom,'#DDDDDD', 'bold 15px '+globalFont);
|
||||
core.fillText('ui', '返回游戏', this.PIXEL-48, bottom, '#DDDDDD', this._buildFont(15, true));
|
||||
|
||||
if (core.status.event.selection)
|
||||
core.setFillStyle('ui', '#FF6A6A');
|
||||
@ -2085,91 +2068,47 @@ ui.prototype._drawSLPanel_drawBg = function(page, max_page) {
|
||||
core.fillText('ui', '删除模式', 48, bottom);
|
||||
else{
|
||||
if(core.status.event.data.mode=='all'){
|
||||
core.fillText('ui', '[E]显示收藏', 48, bottom);
|
||||
core.fillText('ui', '[E]显示收藏', 52, bottom);
|
||||
}else{
|
||||
core.fillText('ui', '[E]显示全部', 48, bottom);
|
||||
core.fillText('ui', '[E]显示全部', 52, bottom);
|
||||
}
|
||||
}
|
||||
// --- 绘制记录
|
||||
this._drawSLPanel_drawRecords();
|
||||
}
|
||||
|
||||
ui.prototype._drawSLPanel_flushIndex = function(){
|
||||
core.saves.favIndex = {};
|
||||
for(var i in core.saves.favorite){
|
||||
core.saves.favIndex[parseInt(i)+1]=core.saves.favorite[i];
|
||||
ui.prototype._drawSLPanel_drawBackground = function() {
|
||||
core.clearMap('ui');
|
||||
core.setAlpha('ui', 0.85);
|
||||
core.fillRect('ui', 0, 0, this.PIXEL, this.PIXEL, '#000000');//可改成背景图图
|
||||
core.setAlpha('ui', 1);
|
||||
}
|
||||
|
||||
ui.prototype._drawSLPanel_loadSave = function(page, callback) {
|
||||
var ids = [0];
|
||||
for (var i = 1; i <= 5; ++i) {
|
||||
var id = 5 * page + i;
|
||||
if(core.status.event.data.mode=='fav')
|
||||
id = core.saves.favorite[id - 1]; // 因为favorite第一个不是自动存档 所以要偏移1
|
||||
ids.push(id);
|
||||
}
|
||||
}
|
||||
|
||||
// 读取收藏信息到core.saves.favorite中
|
||||
ui.prototype._drawSLPanel_loadFav = function(callback){
|
||||
if(!core.saves.favorite || !core.saves.favName){
|
||||
core.getLocalForage("favorite", null, function(data) {
|
||||
core.saves.favorite = data || [];
|
||||
core.ui._drawSLPanel_flushIndex();
|
||||
core.getLocalForage("favName", null, function(data) {
|
||||
core.saves.favName = data || {};
|
||||
callback();
|
||||
})});
|
||||
}else{
|
||||
core.getSaves(ids, function (data) {
|
||||
for (var i = 0; i < ids.length; ++i)
|
||||
core.status.event.ui[i] = data[i];
|
||||
core.saves.autosave.data = data[0];
|
||||
callback();
|
||||
}
|
||||
}
|
||||
// 写入收藏信息 | 收藏信息包括收藏id列表favorite、id到收藏名的映射favName
|
||||
ui.prototype._drawSLPanel_saveFav = function(callback){
|
||||
if(!core.saves.favorite){
|
||||
core.saves.favorite = [];
|
||||
core.saves.favName = {};
|
||||
}
|
||||
core.setLocalForage("favorite", core.saves.favorite,
|
||||
function(){
|
||||
core.setLocalForage("favName", core.saves.favName,callback)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// TODO:递归改并发 | 读取page页的i号存档数据到ui数组中
|
||||
ui.prototype._drawSLPanel_loadSave = function(page, i, callback) {
|
||||
if (i==6) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
if (i==0) {
|
||||
if (core.saves.autosave.data!=null) {
|
||||
core.status.event.ui[i] = core.saves.autosave.data;
|
||||
core.ui._drawSLPanel_loadSave(page, 1, callback);
|
||||
}
|
||||
else {
|
||||
core.getLocalForage("autoSave", null, function(data) {
|
||||
core.saves.autosave.data = data;
|
||||
core.status.event.ui[i]=data;
|
||||
core.ui._drawSLPanel_loadSave(page, i+1, callback);
|
||||
}, function(err) {main.log(err);});
|
||||
}
|
||||
}
|
||||
else {
|
||||
var id = 5*page+i;
|
||||
if(core.status.event.data.mode=='fav'){
|
||||
id = core.saves.favorite[id-1];//因为favorite第一个不是自动存档 所以要偏移1
|
||||
}
|
||||
core.getLocalForage("save"+id, null, function(data) {
|
||||
core.status.event.ui[i]=data;
|
||||
core.ui._drawSLPanel_loadSave(page, i+1, callback);
|
||||
}, function(err) {main.log(err);});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 在以x为中心轴 y为顶坐标 的位置绘制一条宽为size的记录 cho表示是否被选中 选中会加粗 highlight表示高亮标题 ✐
|
||||
ui.prototype._drawSLPanel_drawRecord = function(title, data, x, y, size, cho, highLight){
|
||||
var globalFont = (core.status.globalAttribute||core.initStatus.globalAttribute).font;
|
||||
var strokeColor = '#FFD700';
|
||||
if (core.status.event.selection) strokeColor = '#FF6A6A';
|
||||
if (!data || !data.floorId) highLight = false;
|
||||
|
||||
if (!core.isset(data) || !core.isset(data.floorId)) { //存在数据时才高亮
|
||||
highLight = false;
|
||||
}
|
||||
core.fillText('ui', title, x, y, highLight?'#FFD700':'#FFFFFF', this._buildFont(17,true));//"bold 17px "+globalFont);//名字
|
||||
|
||||
core.fillText('ui', title, x, y, highLight?'#FFD700':'#FFFFFF', this._buildFont(17, true));
|
||||
core.strokeRect('ui', x-size/2, y+15, size, size, cho?strokeColor:'#FFFFFF', cho?6:2);
|
||||
if (core.isset(data) && core.isset(data.floorId)) {
|
||||
if (data && data.floorId) {
|
||||
core.drawThumbnail(data.floorId, core.maps.loadMap(data.maps, data.floorId).blocks, {
|
||||
heroLoc: data.hero.loc, heroIcon: data.hero.flags.heroIcon, flags: data.hero.flags
|
||||
}, {
|
||||
@ -2177,45 +2116,36 @@ ui.prototype._drawSLPanel_drawRecord = function(title, data, x, y, size, cho, hi
|
||||
});
|
||||
var v = core.formatBigNumber(data.hero.hp,true)+"/"+core.formatBigNumber(data.hero.atk,true)+"/"+core.formatBigNumber(data.hero.def,true);
|
||||
var v2 = "/"+core.formatBigNumber(data.hero.mdef,true);
|
||||
if (v.length+v2.length<=21) v+=v2;
|
||||
core.fillText('ui', v, x, y+30+size, '#FFD700', this._buildFont(10));
|
||||
core.fillText('ui', core.formatDate(new Date(data.time)), x, y+43+size, data.hero.flags.__consoleOpened__?'#FF6A6A':'#FFFFFF', this._buildFont(10));//'10px '+globalFont);
|
||||
if (core.calWidth('ui', v + v2, this._buildFont(10, false)) <= size) v += v2;
|
||||
core.fillText('ui', v, x, y+30+size, '#FFD700');
|
||||
core.fillText('ui', core.formatDate(new Date(data.time)), x, y+43+size, data.hero.flags.__consoleOpened__?'#FF6A6A':'#FFFFFF');
|
||||
}
|
||||
else {
|
||||
core.fillRect('ui', x-size/2, y+15, size, size, '#333333', 2);
|
||||
core.fillText('ui', '空', x, parseInt(y+15+size/2), '#FFFFFF', this._buildFont(30,true));//'bold 30px '+globalFont);
|
||||
core.fillText('ui', '空', x, parseInt(y+15+size/2), '#FFFFFF', this._buildFont(30,true));
|
||||
}
|
||||
}
|
||||
|
||||
// 绘制n条记录到画板
|
||||
ui.prototype._drawSLPanel_drawNRecords = function (n)
|
||||
{
|
||||
var page = core.status.event.data.page;//Math.floor(core.status.event.data/10);
|
||||
var offset = core.status.event.data.offset;//core.status.event.data%10;
|
||||
var u = Math.floor(this.PIXEL/6), size = Math.floor(this.PIXEL/3-20);//118
|
||||
for (var i=0;i<n;i++){
|
||||
var name=core.status.event.id=='save'?"存档":core.status.event.id=='load'?"读档":core.status.event.id=='replayLoad'?"回放":"";
|
||||
ui.prototype._drawSLPanel_drawRecords = function (n) {
|
||||
var page = core.status.event.data.page;
|
||||
var offset = core.status.event.data.offset;
|
||||
var u = Math.floor(this.PIXEL/6), size = Math.floor(this.PIXEL/3-20);
|
||||
var name=core.status.event.id=='save'?"存档":core.status.event.id=='load'?"读档":core.status.event.id=='replayLoad'?"回放":"";
|
||||
|
||||
for (var i = 0; i < (n||6); i++){
|
||||
var data = core.status.event.ui[i];
|
||||
var id=5*page+i;
|
||||
var title = "";//name+id;
|
||||
var highLight = core.saves.favorite.indexOf(id)>=0 || core.status.event.data.mode=='fav';
|
||||
if(highLight)title = '★ ' + title
|
||||
else title = '☆ ' + title;
|
||||
var fid = id;
|
||||
if(core.status.event.data.mode=='fav' && i!=0){//收藏模式下显示修改符号以及自己标识的名字
|
||||
fid = core.saves.favIndex[id];
|
||||
if(!data && i>0){
|
||||
continue;
|
||||
}
|
||||
// name = core.saves.favName[fid] ? core.status.event.id=='save'?"S:":core.status.event.id=='load'?"L:":core.status.event.id=='replayLoad'?"re:":"" : name;
|
||||
title = name + (core.saves.favName[fid]||fid) + '✐';
|
||||
}else{
|
||||
// name = core.saves.favName[fid] ? core.status.event.id=='save'?"S:":core.status.event.id=='load'?"L:":core.status.event.id=='replayLoad'?"re:":"" : name;
|
||||
title += name + (core.saves.favName[fid]||fid);
|
||||
var id = 5 * page + i;
|
||||
var highLight = (i>0&&core.saves.favorite.indexOf(id)>=0) || core.status.event.data.mode=='fav';
|
||||
var title = (highLight?'★ ':'☆ ') + (core.saves.favoriteName[id] || (name + id));
|
||||
if (i != 0 && core.status.event.data.mode=='fav') {
|
||||
if (!data) break;
|
||||
var real_id = core.saves.favorite[id - 1];
|
||||
title = (core.saves.favoriteName[real_id] || (name + real_id)) + ' ✐';
|
||||
}
|
||||
|
||||
var charSize = 32;// 字体占用像素范围
|
||||
var topSpan = parseInt((this.PIXEL-charSize-2*(charSize*2 + size))/3);// Margin
|
||||
var yTop1 = topSpan+parseInt(charSize/2);//文字的中心
|
||||
var yTop1 = topSpan+parseInt(charSize/2) + 8;//文字的中心
|
||||
var yTop2 = yTop1+charSize*2+size+topSpan;
|
||||
if (i<3) {
|
||||
this._drawSLPanel_drawRecord(i==0?"自动存档":title, data, (2*i+1)*u, yTop1, size, i==offset, highLight);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user