Optimize game.showChangeLog.

(cherry picked from commit 62fdfe7fa2c58da1c9afcd82bf5b2f4931952f2b)
This commit is contained in:
Tipx-L 2023-08-24 08:20:34 -07:00
parent 3d4f04860b
commit 61cedb172b
1 changed files with 55 additions and 84 deletions

View File

@ -38286,95 +38286,66 @@
} }
} }
}, },
showChangeLog:function(){ showChangeLog:()=>{
if(lib.version!=lib.config.version||_status.extensionChangeLog){ if(lib.version==lib.config.version&&!_status.extensionChangeLog) return;
var ul=document.createElement('ul'); const ul=document.createElement('ul');
ul.style.textAlign='left'; ul.style.textAlign='left';
var caption; const caption=lib.version==lib.config.version?'扩展更新':`${lib.version}更新内容`;
var players=null,cards=null; let players=null,cards=null;
if(lib.version!=lib.config.version){ if(lib.version!=lib.config.version) lib.changeLog.forEach(value=>{
for(var i=0;i<lib.changeLog.length;i++){ if(value.indexOf('players://')==0) try{
if(lib.changeLog[i].indexOf('players://')==0){ players=JSON.parse(value.slice(10)).filter(value=>lib.character[value]);
try{
players=JSON.parse(lib.changeLog[i].slice(10));
} }
catch(e){ catch(e){
players=null; players=null;
} }
} else if(value.indexOf('cards://')==0) try{
else if(lib.changeLog[i].indexOf('cards://')==0){ cards=JSON.parse(value.slice(8)).filter(value=>lib.card[value]);
try{
cards=JSON.parse(lib.changeLog[i].slice(8));
} }
catch(e){ catch(e){
cards=null; cards=null;
} }
}
else{ else{
var li=document.createElement('li'); const li=document.createElement('li');
li.innerHTML=lib.changeLog[i]; li.innerHTML=value;
ul.appendChild(li); ul.appendChild(li);
} }
} });
caption=lib.version+'更新内容';
}
else{
caption='扩展更新';
}
game.saveConfig('version',lib.version); game.saveConfig('version',lib.version);
for(var i in _status.extensionChangeLog){ if(_status.extensionChangeLog) Object.keys(_status.extensionChangeLog).forEach(value=>{
var li=document.createElement('li'); const li=document.createElement('li');
li.innerHTML=i+''+_status.extensionChangeLog[i]; li.innerHTML=`${value}${_status.extensionChangeLog[value]}`;
ul.appendChild(li); ul.appendChild(li);
} });
var dialog=ui.create.dialog(caption,'hidden'); const dialog=ui.create.dialog(caption,'hidden'),lic=ui.create.div(dialog.content);
var lic=ui.create.div(dialog.content);
lic.style.display='block'; lic.style.display='block';
ul.style.display='inline-block'; ul.style.display='inline-block';
ul.style.marginLeft='-40px'; ul.style.marginLeft='-40px';
lic.appendChild(ul); lic.appendChild(ul);
if(players){ if(players&&players.length){
for(var i=0;i<players.length;i++){
if(!lib.character[players[i]]){
players.splice(i--,1);
}
}
if(players.length){
dialog.addSmall([players,'character']); dialog.addSmall([players,'character']);
dialog.classList.add('forcebutton'); dialog.classList.add('forcebutton');
dialog.classList.add('withbg'); dialog.classList.add('withbg');
} }
} if(cards&&cards.length){
if(cards){ dialog.addSmall([cards.map(value=>[get.translation(get.type(value)),'',value]),'vcard']);
for(var i=0;i<cards.length;i++){
if(!lib.card[cards[i]]){
cards.splice(i--,1);
}
}
if(cards.length){
for(var i=0;i<cards.length;i++){
cards[i]=[get.translation(get.type(cards[i])),'',cards[i]]
}
dialog.addSmall([cards,'vcard']);
dialog.classList.add('forcebutton'); dialog.classList.add('forcebutton');
dialog.classList.add('withbg'); dialog.classList.add('withbg');
} }
}
dialog.open(); dialog.open();
var hidden=false; let hidden=false;
if(!ui.auto.classList.contains('hidden')){ if(!ui.auto.classList.contains('hidden')){
ui.auto.hide(); ui.auto.hide();
hidden=true; hidden=true;
} }
game.pause(); game.pause();
var control=ui.create.control('确定',function(){ const control=ui.create.control('确定',()=>{
dialog.close(); dialog.close();
control.close(); control.close();
if(hidden) ui.auto.show(); if(hidden) ui.auto.show();
game.resume(); game.resume();
}); });
lib.init.onfree(); lib.init.onfree();
}
}, },
showExtensionChangeLog:(str,extname)=>{ showExtensionChangeLog:(str,extname)=>{
extname=extname||_status.extension; extname=extname||_status.extension;