This commit is contained in:
libccy 2017-04-13 18:30:07 +08:00
parent ee11385b4c
commit 7d64a6af24
1 changed files with 98 additions and 42 deletions

View File

@ -676,15 +676,7 @@
else{ else{
lib.init.layout(layout); lib.init.layout(layout);
} }
if(lib.config.image_background&&lib.config.image_background!='default'&&lib.config.image_background.indexOf('custom_')!=0){ lib.init.background();
localStorage.setItem(lib.configprefix+'background',lib.config.image_background);
}
else if(lib.config.image_background=='default'&&lib.config.theme=='simple'){
localStorage.setItem(lib.configprefix+'background','shengshi_bg');
}
else{
localStorage.removeItem(lib.configprefix+'background');
}
} }
}, },
// fewplayer:{ // fewplayer:{
@ -884,7 +876,7 @@
node.remove(); node.remove();
menu.updateBr(); menu.updateBr();
if(!lib.config.prompt_hidebg){ if(!lib.config.prompt_hidebg){
alert('隐藏的背景可通过选项-其它-重置隐藏扩展恢复'); alert('隐藏的背景可通过选项-其它-重置隐藏内容恢复');
game.saveConfig('prompt_hidebg',true); game.saveConfig('prompt_hidebg',true);
} }
lib.config.hiddenBackgroundPack.add(background); lib.config.hiddenBackgroundPack.add(background);
@ -921,15 +913,7 @@
} }
var animate=lib.config.image_background=='default'; var animate=lib.config.image_background=='default';
game.saveConfig('image_background',background); game.saveConfig('image_background',background);
if(lib.config.image_background&&lib.config.image_background!='default'&&lib.config.image_background.indexOf('custom_')!=0){ lib.init.background();
localStorage.setItem(lib.configprefix+'background',lib.config.image_background);
}
else if(lib.config.image_background=='default'&&lib.config.theme=='simple'){
localStorage.setItem(lib.configprefix+'background','shengshi_bg');
}
else{
localStorage.removeItem(lib.configprefix+'background');
}
ui.background.delete(); ui.background.delete();
ui.background=ui.create.div('.background'); ui.background=ui.create.div('.background');
@ -3155,7 +3139,7 @@
clear:true clear:true
}, },
reset_hiddenpack:{ reset_hiddenpack:{
name:'重置隐藏扩展', name:'重置隐藏内容',
onclick:function(){ onclick:function(){
if(this.innerHTML!='已重置'){ if(this.innerHTML!='已重置'){
this.innerHTML='已重置' this.innerHTML='已重置'
@ -3166,7 +3150,7 @@
game.saveConfig('hiddenBackgroundPack',[]); game.saveConfig('hiddenBackgroundPack',[]);
var that=this; var that=this;
setTimeout(function(){ setTimeout(function(){
that.innerHTML='重置隐藏扩展'; that.innerHTML='重置隐藏内容';
setTimeout(function(){ setTimeout(function(){
if(confirm('是否重新启动使改变生效?')){ if(confirm('是否重新启动使改变生效?')){
game.reload(); game.reload();
@ -3209,13 +3193,30 @@
export_data:{ export_data:{
name:'导出游戏设置', name:'导出游戏设置',
onclick:function(){ onclick:function(){
var data={}; var data;
for(var i in localStorage){ var export_data=function(data){
if(i.indexOf(lib.configprefix)==0){ game.export(lib.init.encode(JSON.stringify(data)),'无名杀 - 数据 - '+(new Date()).toLocaleString());
data[i]=localStorage[i];
}
} }
game.export(lib.init.encode(JSON.stringify(data)),'无名杀 - 数据 - '+(new Date()).toLocaleString()); if(!lib.db){
data={};
for(var i in localStorage){
if(i.indexOf(lib.configprefix)==0){
data[i]=localStorage[i];
}
}
export_data(data);
}
else{
game.getDB('config',null,function(data1){
game.getDB('data',null,function(data2){
export_data({
config:data1,
data:data2
});
});
});
}
}, },
clear:true clear:true
}, },
@ -7606,6 +7607,17 @@
},100); },100);
},500); },500);
}, },
background:function(){
if(lib.config.image_background&&lib.config.image_background!='default'&&lib.config.image_background.indexOf('custom_')!=0){
localStorage.setItem(lib.configprefix+'background',lib.config.image_background);
}
else if(lib.config.image_background=='default'&&lib.config.theme=='simple'){
localStorage.setItem(lib.configprefix+'background','shengshi_bg');
}
else{
localStorage.removeItem(lib.configprefix+'background');
}
},
parsex:function(func){ parsex:function(func){
var k; var k;
var str='('; var str='(';
@ -7795,6 +7807,7 @@
game.saveConfig(mode[i]+'_bannedcards',bannedcards); game.saveConfig(mode[i]+'_bannedcards',bannedcards);
} }
game.saveConfig('change_skin',false); game.saveConfig('change_skin',false);
game.saveConfig('show_splash','off');
game.saveConfig('show_favourite',false); game.saveConfig('show_favourite',false);
// game.saveConfig('characters',lib.config.all.characters); // game.saveConfig('characters',lib.config.all.characters);
// game.saveConfig('cards',lib.config.all.cards); // game.saveConfig('cards',lib.config.all.cards);
@ -22173,7 +22186,19 @@
localStorage.removeItem(lib.configprefix+'playbackmode'); localStorage.removeItem(lib.configprefix+'playbackmode');
} }
localStorage.setItem('show_splash_off',true); localStorage.setItem('show_splash_off',true);
window.location.reload(); if(lib.status.reload){
_status.waitingToReload=true;
}
else{
window.location.reload();
}
},
reload2:function(){
lib.status.reload--;
if(_status.waitingToReload&&lib.status.reload==0){
window.location.reload();
delete _status.waitingToReload;
}
}, },
exit:function(){ exit:function(){
if(lib.device=='ios'){ if(lib.device=='ios'){
@ -25788,10 +25813,14 @@
}, },
putDB:function(type,id,item,callback){ putDB:function(type,id,item,callback){
if(!lib.db) return item; if(!lib.db) return item;
lib.status.reload++;
var put=lib.db.transaction([type],'readwrite').objectStore(type).put(item,id); var put=lib.db.transaction([type],'readwrite').objectStore(type).put(item,id);
if(callback){ put.onsuccess=function(){
put.onsuccess=callback; if(callback){
} callback.apply(this,arguments);
}
game.reload2();
};
}, },
getDB:function(type,id,callback){ getDB:function(type,id,callback){
if(!lib.db){ if(!lib.db){
@ -25824,17 +25853,27 @@
callback(false); callback(false);
return; return;
} }
lib.status.reload++;
if(arguments.length==1){ if(arguments.length==1){
game.getDB(type,null,function(obj){ game.getDB(type,null,function(obj){
var store=lib.db.transaction([type],'readwrite').objectStore(type); var store=lib.db.transaction([type],'readwrite').objectStore(type);
for(var id in obj){ for(var id in obj){
store.delete(id); lib.status.reload++;
} }
for(var id in obj){
store.delete(id).onsuccess=game.reload2;
}
game.reload2();
}); });
} }
else{ else{
var store=lib.db.transaction([type],'readwrite').objectStore(type); var store=lib.db.transaction([type],'readwrite').objectStore(type);
store.delete(id).onsuccess=callback; store.delete(id).onsuccess=function(){
if(callback){
callback.apply(this,arguments);
}
game.reload2();
};
} }
}, },
save:function(key,value,mode){ save:function(key,value,mode){
@ -27215,7 +27254,7 @@
this.innerHTML='此模式将在重启后隐藏'; this.innerHTML='此模式将在重启后隐藏';
lib.config.hiddenModePack.add(mode); lib.config.hiddenModePack.add(mode);
if(!lib.config.prompt_hidepack){ if(!lib.config.prompt_hidepack){
alert('隐藏的扩展包可通过选项-其它-重置隐藏扩展恢复'); alert('隐藏的扩展包可通过选项-其它-重置隐藏内容恢复');
game.saveConfig('prompt_hidepack',true); game.saveConfig('prompt_hidepack',true);
} }
} }
@ -27634,13 +27673,11 @@
if(!data) return; if(!data) return;
try{ try{
data=JSON.parse(lib.init.decode(data)); data=JSON.parse(lib.init.decode(data));
var noname_inited=localStorage.getItem('noname_inited'); if(!data||typeof data!='object'){
localStorage.clear(); throw('err');
if(noname_inited){
localStorage.setItem('noname_inited',noname_inited);
} }
for(var i in data){ if(lib.db&&(!data.config||!data.data)){
localStorage.setItem(i,data[i]); throw('err');
} }
} }
catch(e){ catch(e){
@ -27649,6 +27686,25 @@
return; return;
} }
alert('导入成功'); alert('导入成功');
if(!lib.db){
var noname_inited=localStorage.getItem('noname_inited');
localStorage.clear();
if(noname_inited){
localStorage.setItem('noname_inited',noname_inited);
}
for(var i in data){
localStorage.setItem(i,data[i]);
}
}
else{
for(var i in data.config){
game.putDB('config',i,data.config[i]);
}
for(var i in data.data){
game.putDB('data',i,data.data[i]);
}
}
lib.init.background();
game.reload(); game.reload();
}; };
fileReader.readAsText(fileToLoad, "UTF-8"); fileReader.readAsText(fileToLoad, "UTF-8");
@ -28536,7 +28592,7 @@
this.innerHTML='武将包将在重启后隐藏'; this.innerHTML='武将包将在重启后隐藏';
lib.config.hiddenCharacterPack.add(mode); lib.config.hiddenCharacterPack.add(mode);
if(!lib.config.prompt_hidepack){ if(!lib.config.prompt_hidepack){
alert('隐藏的扩展包可通过选项-其它-重置隐藏扩展恢复'); alert('隐藏的扩展包可通过选项-其它-重置隐藏内容恢复');
game.saveConfig('prompt_hidepack',true); game.saveConfig('prompt_hidepack',true);
} }
} }
@ -28841,7 +28897,7 @@
this.innerHTML='卡牌包将在重启后隐藏'; this.innerHTML='卡牌包将在重启后隐藏';
lib.config.hiddenCardPack.add(mode); lib.config.hiddenCardPack.add(mode);
if(!lib.config.prompt_hidepack){ if(!lib.config.prompt_hidepack){
alert('隐藏的扩展包可通过选项-其它-重置隐藏扩展恢复'); alert('隐藏的扩展包可通过选项-其它-重置隐藏内容恢复');
game.saveConfig('prompt_hidepack',true); game.saveConfig('prompt_hidepack',true);
} }
} }