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