This commit is contained in:
libccy 2016-06-04 09:59:50 +08:00
parent b9366e6f49
commit b9a1272f2f
5 changed files with 141 additions and 72 deletions

View File

@ -4704,7 +4704,7 @@
game.modPhaseDraw(player,event.num); game.modPhaseDraw(player,event.num);
} }
else{ else{
if((get.config('first_less')||_status.connectMode)&&game.phaseNumber==1&&_status.first_less){ if((get.config('first_less')||_status.connectMode||_status.first_less_forced)&&game.phaseNumber==1&&_status.first_less){
event.num--; event.num--;
} }
if(event.num>0){ if(event.num>0){
@ -13080,6 +13080,44 @@
var game={ var game={
online:false, online:false,
onlineID:null, onlineID:null,
checkFileList:function(updates,proceed){
var n=updates.length;
for(var i=0;i<updates.length;i++){
if(lib.node&&lib.node.fs){
lib.node.fs.access(__dirname+'/'+updates[i],(function(entry){
return function(err){
if(err){
n--;
if(n==0){
proceed();
}
}
else{
n--;
updates.remove(entry);
if(n==0){
proceed();
}
}
}
}(updates[i])));
}
else{
resolveLocalFileSystemURL(lib.assetURL+updates[i],function(entry){
n--;
updates.remove(entry.toURL().slice(lib.assetURL.length));
if(n==0){
proceed();
}
},function(){
n--;
if(n==0){
proceed();
}
});
}
}
},
replaceHandcards:function(){ replaceHandcards:function(){
var next=game.createEvent('replaceHandcards'); var next=game.createEvent('replaceHandcards');
if(Array.isArray(arguments[0])){ if(Array.isArray(arguments[0])){
@ -14064,10 +14102,10 @@
} }
game.print(current); game.print(current);
game.download(current,current2,function(){ game.download(current,current2,function(){
if(onsuccess) onsuccess(); if(onsuccess) onsuccess(list.length);
download(); download();
},function(){ },function(){
if(onerror) onerror(); if(onerror) onerror(list.length);
download(); download();
}); });
} }
@ -20941,11 +20979,12 @@
importextensionexpanded=!importextensionexpanded; importextensionexpanded=!importextensionexpanded;
}); });
importExtension=ui.create.div('.new_character.export.import',page); importExtension=ui.create.div('.new_character.export.import',page);
importExtension.style.float='left';
importExtension.style.marginLeft='5px'; importExtension.style.marginLeft='5px';
importExtension.style.marginTop='5px'; importExtension.style.marginTop='5px';
importExtension.style.marginBottom='5px'; importExtension.style.marginBottom='5px';
importExtension.style.display='none'; importExtension.style.display='none';
importExtension.style.width='100%';
importExtension.style.textAlign='left';
ui.create.div('','<input type="file" accept="application/zip" style="width:153px"><button>确定</button>',importExtension); ui.create.div('','<input type="file" accept="application/zip" style="width:153px"><button>确定</button>',importExtension);
var reloadnode=ui.create.div('.config.toggle','重新启动',page,game.reload); var reloadnode=ui.create.div('.config.toggle','重新启动',page,game.reload);
@ -20996,7 +21035,7 @@
this.classList.add('active'); this.classList.add('active');
} }
}; };
var importExtensionf=function(extname,extversion,onsuccess,onerror){ var importExtensionf=function(extname,extversion,noasset,onsuccess,onerror){
try{ try{
if(lib.config.all.plays.contains(extname)){ if(lib.config.all.plays.contains(extname)){
throw('err'); throw('err');
@ -21011,20 +21050,20 @@
if(deletegame) delete window.game; if(deletegame) delete window.game;
_status.importingExtension=false; _status.importingExtension=false;
if(!game.importedPack) throw('err'); if(!game.importedPack) throw('err');
if(lib.config.extensions.contains(extname)){
game.removeExtension(extname,true);
}
lib.config.extensions.add(extname);
game.saveConfig('extensions',lib.config.extensions);
game.saveConfig('extension_'+extname+'_enable',true);
if(extversion){ if(extversion){
game.saveConfig('extension_'+extname+'_version',extversion); game.saveConfig('extension_'+extname+'_version',extversion);
} }
game.saveConfig('extension_'+extname+'_noasset',noasset);
if(!lib.config.extensions.contains(extname)){
lib.config.extensions.add(extname);
game.saveConfig('extensions',lib.config.extensions);
game.saveConfig('extension_'+extname+'_enable',true);
for(var i in game.importedPack.config){ for(var i in game.importedPack.config){
if(game.importedPack.config[i]&&game.importedPack.config[i].hasOwnProperty('init')){ if(game.importedPack.config[i]&&game.importedPack.config[i].hasOwnProperty('init')){
game.saveConfig('extension_'+extname+'_'+i,game.importedPack.config[i].init); game.saveConfig('extension_'+extname+'_'+i,game.importedPack.config[i].init);
} }
} }
}
delete game.importedPack; delete game.importedPack;
onsuccess(); onsuccess();
},function(){ },function(){
@ -21039,28 +21078,53 @@
} }
}; };
var downloadExtension=function(e){ var downloadExtension=function(e){
if((this.innerHTML!='下载扩展'&&this.innerHTML!='更新扩展')||!window.JSZip) return; if((this.innerHTML!='下载扩展'&&this.innerHTML!='更新扩展'&&this.innerHTML!='更新素材')||!window.JSZip) return;
if(e){ if(e){
e.stopPropagation(); e.stopPropagation();
} }
node.updated=true; node.updated=true;
this.innerHTML='正在下载';
if(lib.updateURL[lib.updateURL.length-1]!='/'){
lib.updateURL+='/';
}
var that=this; var that=this;
var list=['web/'+this.link+'/extension.js']; var list=[];
var noasset=false;
if(this.files.length){
if(!lib.config.no_extension_asset||this.innerHTML=='更新素材'){
for(var i=0;i<this.files.length;i++){ for(var i=0;i<this.files.length;i++){
list.push('web/'+this.link+'/'+this.files[i]); list.push('web/'+this.link+'/'+this.files[i]);
} }
game.multiDownload(list,null,function(){ }
else{
noasset=true;
}
}
this.classList.add('button-downloading');
this.innerHTML='<span>正在下载</span><div>正在下载</div>';
var progress=ui.create.div('.button-progress',this);
list.push('web/'+this.link+'/extension.js');
game.checkFileList(list,function(){
game.multiDownload(list,function(num){
var length=100*(list.length-num)/list.length;
progress.style.width=length+'%';
if(length<10){
var width=8-progress.offsetWidth;
progress.style.transition='all 0s';
progress.style.height='calc(100% - '+width/2+'px)';
progress.style.top=width/4+'px';
}
else{
progress.style.transition='';
progress.style.height='';
progress.style.top='';
}
},function(){
that.innerHTML='下载失败'; that.innerHTML='下载失败';
},function(){ },function(){
if(that.innerHTML=='下载失败') return; if(that.innerHTML=='下载失败') return;
importExtensionf(that.name,that.version,function(){ progress.style.width='100%';
that.innerHTML='安装成功'; importExtensionf(that.name,that.version,noasset,function(){
that.classList.remove('active'); that.childNodes[0].innerHTML='安装成功';
that.classList.add('highlight'); that.childNodes[1].innerHTML='安装成功';
// that.classList.remove('active');
// that.classList.add('highlight');
reloadnode.style.display=''; reloadnode.style.display='';
},function(){ },function(){
that.innerHTML='安装失败'; that.innerHTML='安装失败';
@ -21068,6 +21132,7 @@
},function(str){ },function(str){
return 'extension/'+that.name+'/'+str.slice(str.lastIndexOf('/')+1); return 'extension/'+that.name+'/'+str.slice(str.lastIndexOf('/')+1);
}); });
});
}; };
node.update=function(){ node.update=function(){
@ -21090,6 +21155,16 @@
script.remove(); script.remove();
var list=window.noname_extension_list; var list=window.noname_extension_list;
delete window.noname_extension_list; delete window.noname_extension_list;
var cfgnode=createConfig({
name:'不下载素材',
init:lib.config.no_extension_asset,
onclick:function(bool){
game.saveConfig('no_extension_asset',bool);
}
});
cfgnode.classList.add('loading');
cfgnode.style.marginBottom='10px';
page.appendChild(cfgnode);
for(var i in list){ for(var i in list){
var node=ui.create.div('.videonode.menubutton.extension.large',page,clickExtension); var node=ui.create.div('.videonode.menubutton.extension.large',page,clickExtension);
ui.create.div('.caption',list[i].name,node); ui.create.div('.caption',list[i].name,node);
@ -21102,6 +21177,10 @@
download.innerHTML='更新扩展'; download.innerHTML='更新扩展';
download.classList.add('highlight'); download.classList.add('highlight');
} }
else if(lib.config['extension_'+list[i].name+'_noasset']){
download.innerHTML='更新素材';
download.classList.add('highlight');
}
else{ else{
download.classList.add('transparent2'); download.classList.add('transparent2');
download.classList.remove('active'); download.classList.remove('active');
@ -21370,7 +21449,6 @@
} }
} }
} }
var n=updates.length;
if(!ui.arena.classList.contains('menupaused')){ if(!ui.arena.classList.contains('menupaused')){
ui.click.configMenu(); ui.click.configMenu();
ui.click.menuTab('帮助'); ui.click.menuTab('帮助');
@ -21413,41 +21491,7 @@
setTimeout(finish,500); setTimeout(finish,500);
}); });
}; };
for(var i=0;i<updates.length;i++){ game.checkFileList(updates,proceed);
if(lib.node&&lib.node.fs){
lib.node.fs.access(__dirname+'/'+updates[i],(function(entry){
return function(err){
if(err){
n--;
if(n==0){
proceed();
}
}
else{
n--;
updates.remove(entry);
if(n==0){
proceed();
}
}
}
}(updates[i])));
}
else{
resolveLocalFileSystemURL(lib.assetURL+updates[i],function(entry){
n--;
updates.remove(entry.toURL().slice(lib.assetURL.length));
if(n==0){
proceed();
}
},function(){
n--;
if(n==0){
proceed();
}
});
}
}
},function(){ },function(){
alert('连接失败'); alert('连接失败');
button2.disabled=false; button2.disabled=false;

View File

@ -2,15 +2,18 @@ window.noname_update={
version:'1.8.13', version:'1.8.13',
changeLog:[ changeLog:[
'修bug', '修bug',
'扩展下载改进'
], ],
files:{ files:{
global:[ global:[
'game/game.js', 'game/game.js',
'character/hearth.js', 'character/hearth.js',
'card/mingzhong.js', 'card/mingzhong.js',
'mode/versus.js',
'layout/default/menu.css', 'layout/default/menu.css',
'layout/mobile/equip.css', 'layout/mobile/equip.css',
], ],
'1.8.12.1':[], '1.8.12.1':[],
'1.8.13':[]
} }
} }

View File

@ -685,6 +685,24 @@
.videonode.starred>.video_star{ .videonode.starred>.video_star{
opacity: 1 opacity: 1
} }
.loading{ .button-downloading>.button-progress{
pointer-events: none; width: 0;
border-radius: 4px;
background: linear-gradient(rgb(29,206,68),rgb(1,148,46));
z-index: 1;
}
.button-downloading>div:not(.button-progress){
width: 100% !important;
z-index: 2;
}
.button-downloading>span{
opacity: 0;
}
.button-downloading>div{
height: 100%;
margin: 0 !important;
padding: 0 !important;
position: absolute !important;
left: 0 !important;
top:0;
} }

View File

@ -199,6 +199,7 @@ mode.versus={
else{ else{
if(_status.mode=='two'){ if(_status.mode=='two'){
_status.first_less=true; _status.first_less=true;
_status.first_less_forced=true;
var firstChoose=_status.firstAct; var firstChoose=_status.firstAct;
game.gameDraw(firstChoose); game.gameDraw(firstChoose);
if(get.config('replace_handcard_two')){ if(get.config('replace_handcard_two')){

View File

@ -24,6 +24,9 @@ html{
border-radius: 4px; border-radius: 4px;
} }
.button-downloading>.button-progress{
background: rgba(77,224,100,0.45);
}
.menu.main>.menu-tab>div:not(.active):not(*:hover), .menu.main>.menu-tab>div:not(.active):not(*:hover),
.menu.main>.menu-tab>.disabled{ .menu.main>.menu-tab>.disabled{