Use lib.path.
This commit is contained in:
parent
3e25256914
commit
c2394b872a
222
game/game.js
222
game/game.js
|
@ -4022,11 +4022,11 @@
|
|||
show_characternamepinyin:{
|
||||
name:'显示武将名注解',
|
||||
intro:'在武将资料卡显示武将名及其注解、性别、势力、体力等信息',
|
||||
init:true,
|
||||
init:'showPinyin',
|
||||
unfrequent:true,
|
||||
item:{
|
||||
false:'不显示',
|
||||
true:'显示拼音',
|
||||
doNotShow:'不显示',
|
||||
showPinyin:'显示拼音',
|
||||
showCodeIdentifier:'显示代码ID'
|
||||
},
|
||||
visualMenu:(node,link,name)=>{
|
||||
|
@ -4062,41 +4062,17 @@
|
|||
show_skillnamepinyin:{
|
||||
name:'显示技能名注解',
|
||||
intro:'在武将资料卡显示技能名注解',
|
||||
init:true,
|
||||
unfrequent:true,
|
||||
item:{
|
||||
false:'不显示',
|
||||
true:'显示拼音',
|
||||
showCodeIdentifier:'显示代码ID'
|
||||
get init(){
|
||||
return lib.configMenu.view.config.show_characternamepinyin.init;
|
||||
},
|
||||
visualMenu:(node,link,name)=>{
|
||||
node.classList.add('button','character');
|
||||
const style=node.style;
|
||||
style.alignItems='center';
|
||||
style.animation='background-position-left-center-right-center-left-center 15s ease infinite';
|
||||
style.background='linear-gradient(-45deg, #EE7752, #E73C7E, #23A6D5, #23D5AB)';
|
||||
style.backgroundSize='400% 400%';
|
||||
style.display='flex';
|
||||
style.height='60px';
|
||||
style.justifyContent='center';
|
||||
style.width='150px';
|
||||
const firstChild=node.firstChild;
|
||||
firstChild.removeAttribute('class');
|
||||
firstChild.style.position='initial';
|
||||
if(link=='false') return;
|
||||
const ruby=document.createElement('ruby');
|
||||
ruby.textContent=name;
|
||||
const leftParenthesisRP=document.createElement('rp');
|
||||
leftParenthesisRP.textContent='(';
|
||||
ruby.appendChild(leftParenthesisRP);
|
||||
const rt=document.createElement('rt');
|
||||
rt.style.fontSize='smaller';
|
||||
rt.textContent=link=='showCodeIdentifier'?link:get.pinyin(name).join(' ');
|
||||
ruby.appendChild(rt);
|
||||
const rightParenthesisRP=document.createElement('rp');
|
||||
rightParenthesisRP.textContent=')';
|
||||
ruby.appendChild(rightParenthesisRP);
|
||||
firstChild.innerHTML=ruby.outerHTML;
|
||||
get unfrequent(){
|
||||
return lib.configMenu.view.config.show_characternamepinyin.unfrequent;
|
||||
},
|
||||
get item(){
|
||||
return lib.configMenu.view.config.show_characternamepinyin.item;
|
||||
},
|
||||
get visualMenu(){
|
||||
return lib.configMenu.view.config.show_characternamepinyin.visualMenu;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20027,7 +20003,7 @@
|
|||
}
|
||||
return this;
|
||||
},
|
||||
assgin(obj) {
|
||||
assign(obj) {
|
||||
if(lib.skill[skillName]!=skill) throw `This skill has been destroyed`;
|
||||
if(typeof obj=='object'&&obj!==null) Object.assign(skill,obj);
|
||||
return this;
|
||||
|
@ -34012,67 +33988,51 @@
|
|||
}
|
||||
return node;
|
||||
},
|
||||
changeLand:function(url,player){
|
||||
changeLand:(url,player)=>{
|
||||
game.addVideo('changeLand',player,url);
|
||||
if(url.indexOf('/')===-1){
|
||||
url='image/card/'+url;
|
||||
}
|
||||
if(url.indexOf('.png')==-1&&url.indexOf('.jpg')==-1){
|
||||
url+='.jpg';
|
||||
}
|
||||
var name=url.slice(url.lastIndexOf('/')+1,url.lastIndexOf('.'));
|
||||
var skill=name+'_skill';
|
||||
var node=ui.create.div('.background.upper.land');
|
||||
node.setBackgroundImage(url);
|
||||
node.destroy=function(){
|
||||
if (this.skill) {
|
||||
game.removeGlobalSkill(this.skill);
|
||||
if(this.system){
|
||||
this.system.remove();
|
||||
const parsedPath=lib.path.parse(url);
|
||||
delete parsedPath.base;
|
||||
if(!parsedPath.dir) parsedPath.dir='image/card';
|
||||
if(!parsedPath.ext) parsedPath.ext='.jpg';
|
||||
game.broadcastAll((formattedPath,name,skill,player)=>{
|
||||
const node=ui.create.div('.background.upper.land');
|
||||
node.setBackgroundImage(formattedPath);
|
||||
node.destroy=()=>{
|
||||
if (node.skill) {
|
||||
game.removeGlobalSkill(node.skill);
|
||||
if(node.system) node.system.remove();
|
||||
}
|
||||
node.classList.add('hidden');
|
||||
setTimeout(()=>node.remove(),3000);
|
||||
if(ui.land==node) ui.land=null;
|
||||
}
|
||||
this.classList.add('hidden');
|
||||
var node=this;
|
||||
setTimeout(function(){
|
||||
node.remove();
|
||||
},3000);
|
||||
if(ui.land==this){
|
||||
ui.land=null;
|
||||
if(ui.land){
|
||||
document.body.insertBefore(node,ui.land);
|
||||
ui.land.destroy();
|
||||
}
|
||||
}
|
||||
if(ui.land){
|
||||
document.body.insertBefore(node,ui.land);
|
||||
ui.land.destroy();
|
||||
}
|
||||
else{
|
||||
node.classList.add('hidden');
|
||||
document.body.insertBefore(node,ui.window);
|
||||
ui.refresh(node);
|
||||
node.classList.remove('hidden');
|
||||
}
|
||||
ui.land=node;
|
||||
if(name){
|
||||
else{
|
||||
node.classList.add('hidden');
|
||||
document.body.insertBefore(node,ui.window);
|
||||
ui.refresh(node);
|
||||
node.classList.remove('hidden');
|
||||
}
|
||||
ui.land=node;
|
||||
if(!name) return;
|
||||
node.name=name;
|
||||
node.skill=skill;
|
||||
if(player){
|
||||
node.player=player;
|
||||
player.addTempSkill('land_used');
|
||||
}
|
||||
node.system=ui.create.system(lib.translate[skill],null,true,true);
|
||||
lib.setPopped(node.system,function(){
|
||||
var uiintro=ui.create.dialog('hidden');
|
||||
var str='地图';
|
||||
if(player){
|
||||
str='来源:'+get.translation(player);
|
||||
}
|
||||
var caption=uiintro.addText(str);
|
||||
caption.style.margin='0';
|
||||
uiintro._place_text=uiintro.add('<div class="text">'+lib.translate[skill+'_info']+'</div>');
|
||||
uiintro.add(ui.create.div('.placeholder.slim'));
|
||||
return uiintro;
|
||||
lib.setPopped(node.system=ui.create.system(lib.translate[skill],null,true,true),()=>{
|
||||
const uiIntro=ui.create.dialog('hidden');
|
||||
uiIntro.addText(player?`来源:${get.translation(player)}`:'地图').style.margin='0';
|
||||
uiIntro._place_text=uiIntro.add(ui.create.div('.text',lib.translate[`${skill}_info`]));
|
||||
uiIntro.add(ui.create.div('.placeholder.slim'));
|
||||
return uiIntro;
|
||||
},200);
|
||||
game.addGlobalSkill(skill);
|
||||
}
|
||||
},lib.path.format(parsedPath),parsedPath.name,`${name}_skill`,player);
|
||||
},
|
||||
checkFileList:function(updates,proceed){
|
||||
var n=updates.length;
|
||||
|
@ -34547,7 +34507,7 @@
|
|||
audio.oncanplay=()=>Promise.resolve(audio.play()).catch(()=>void 0);
|
||||
new Promise((resolve,reject)=>{
|
||||
if(path.indexOf('db:')==0) game.getDB('file',path.slice(3)).then(octetStream=>resolve(get.objectURL(octetStream)),reject);
|
||||
else if(path.split('/').pop().split('.').length>1) resolve(`${lib.assetURL}audio/${path}`);
|
||||
else if(lib.path.extname(path)) resolve(`${lib.assetURL}audio/${path}`);
|
||||
else resolve(`${lib.assetURL}audio/${path}.mp3`);
|
||||
}).then(resolvedPath=>{
|
||||
audio.src=resolvedPath;
|
||||
|
@ -37173,28 +37133,24 @@
|
|||
(triggerevent||_status.event).next.push(next);
|
||||
return next;
|
||||
},
|
||||
addCharacter:function(name,info){
|
||||
var extname=(_status.extension||info.extension);
|
||||
var imgsrc;
|
||||
if(_status.evaluatingExtension){
|
||||
imgsrc='db:extension-'+extname+':'+name+'.jpg';
|
||||
}
|
||||
else{
|
||||
imgsrc='ext:'+extname+'/'+name+'.jpg';
|
||||
}
|
||||
const audiosrc='die:ext:'+extname+'/'+name+'.mp3';
|
||||
var character=[info.sex,info.group,info.hp,info.skills||[],[imgsrc,audiosrc]];
|
||||
if(info.tags){
|
||||
character[4]=character[4].concat(info.tags);
|
||||
}
|
||||
addCharacter:(name,information)=>{
|
||||
const extensionName=_status.extension||information.extension,character=[
|
||||
information.sex,
|
||||
information.group,
|
||||
information.hp,
|
||||
information.skills||[],
|
||||
[
|
||||
_status.evaluatingExtension?`db:extension-${extensionName}:${name}.jpg`:`ext:${extensionName}/${name}.jpg`,
|
||||
`die:ext:${extensionName}/${name}.mp3`
|
||||
]
|
||||
];
|
||||
if(information.tags) character[4]=character[4].concat(information.tags);
|
||||
lib.character[name]=character;
|
||||
var packname='mode_extension_'+extname;
|
||||
if(!lib.characterPack[packname]){
|
||||
lib.characterPack[packname]={};
|
||||
}
|
||||
lib.translate[name]=info.translate;
|
||||
lib.characterPack[packname][name]=character;
|
||||
lib.translate[packname+'_character_config']=extname;
|
||||
const packName=`mode_extension_${extensionName}`;
|
||||
if(!lib.characterPack[packName]) lib.characterPack[packName]={};
|
||||
lib.translate[name]=information.translate;
|
||||
lib.characterPack[packName][name]=character;
|
||||
lib.translate[`${packName}_character_config`]=extensionName;
|
||||
},
|
||||
addCharacterPack:(pack,packagename)=>{
|
||||
var extname=_status.extension||'扩展';
|
||||
|
@ -42835,29 +42791,19 @@
|
|||
var loadData=function(){
|
||||
var zip=new JSZip();
|
||||
zip.load(data);
|
||||
var images=[],audios=[],fonts=[],directories={},directorylist=[];
|
||||
for(var i in zip.files){
|
||||
var ext=i.slice(i.lastIndexOf('.')+1).toLowerCase();
|
||||
if(i.indexOf('audio/')==0&&(ext=='mp3'||ext=='ogg')){
|
||||
audios.push(i);
|
||||
var images=[],audios=[],fonts=[],directories={},directoryList=[];
|
||||
Object.keys(zip.files).forEach(file=>{
|
||||
const parsedPath=lib.path.parse(file),directory=parsedPath.dir,fileExtension=parsedPath.ext.toLowerCase();
|
||||
if(directory.indexOf('audio')==0&&(fileExtension=='.mp3'||fileExtension=='.ogg')) audios.push(file);
|
||||
else if(directory.indexOf('font')==0&&fileExtension=='.woff2') fonts.push(file);
|
||||
else if(directory.indexOf('image')==0&&(fileExtension=='.jpg'||fileExtension=='.png')) images.push(file);
|
||||
else return;
|
||||
if(!directories[directory]){
|
||||
directories[directory]=[];
|
||||
directoryList.push(directory);
|
||||
}
|
||||
else if(i.indexOf('font/')==0&&ext=='woff2'){
|
||||
fonts.push(i);
|
||||
}
|
||||
else if(i.indexOf('image/')==0&&(ext=='jpg'||ext=='png')){
|
||||
images.push(i);
|
||||
}
|
||||
else{
|
||||
continue;
|
||||
}
|
||||
var index=i.lastIndexOf('/');
|
||||
var str=i.slice(0,index);
|
||||
if(!directories[str]){
|
||||
directories[str]=[];
|
||||
directorylist.push(str);
|
||||
}
|
||||
directories[str].push(i.slice(index+1));
|
||||
}
|
||||
directories[directory].push(parsedPath.base);
|
||||
});
|
||||
if(audios.length||fonts.length||images.length){
|
||||
var str='';
|
||||
if(audios.length){
|
||||
|
@ -42896,13 +42842,13 @@
|
|||
assetLoaded();
|
||||
}
|
||||
};
|
||||
game.ensureDirectory(directorylist,writeFile);
|
||||
game.ensureDirectory(directoryList,writeFile);
|
||||
|
||||
}
|
||||
else{
|
||||
var getDirectory=function(){
|
||||
if(directorylist.length){
|
||||
var dir=directorylist.shift();
|
||||
if(directoryList.length){
|
||||
var dir=directoryList.shift();
|
||||
var filelist=directories[dir];
|
||||
window.resolveLocalFileSystemURL(lib.assetURL+dir,function(entry){
|
||||
var writeFile=function(){
|
||||
|
@ -42930,7 +42876,7 @@
|
|||
assetLoaded();
|
||||
}
|
||||
};
|
||||
game.ensureDirectory(directorylist,getDirectory);
|
||||
game.ensureDirectory(directoryList,getDirectory);
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
@ -54082,7 +54028,7 @@
|
|||
fav.classList.add('active');
|
||||
}
|
||||
const introduction=ui.create.div('.characterintro',uiintro),showCharacterNamePinyin=lib.config.show_characternamepinyin;
|
||||
if(showCharacterNamePinyin){
|
||||
if(showCharacterNamePinyin!='doNotShow'){
|
||||
const characterIntroTable=ui.create.div('.character-intro-table',introduction),span=document.createElement('span');
|
||||
span.style.fontWeight='bold';
|
||||
const nameInfo=get.character(name),exInfo=nameInfo[4],characterName=exInfo&&exInfo.includes('ruby')?lib.translate[name]:get.rawName(name);
|
||||
|
@ -54192,7 +54138,7 @@
|
|||
const link=this.link,skillName=get.translation(link);
|
||||
skillNameSpan.innerHTML=skillName;
|
||||
const showSkillNamePinyin=lib.config.show_skillnamepinyin;
|
||||
if(showSkillNamePinyin&&skillName!='阵亡'){
|
||||
if(showSkillNamePinyin!='doNotShow'&&skillName!='阵亡'){
|
||||
const ruby=document.createElement('ruby');
|
||||
ruby.appendChild(skillNameSpan);
|
||||
const leftParenthesisRP=document.createElement('rp');
|
||||
|
@ -54228,7 +54174,7 @@
|
|||
derivationNameSpanStyle.fontWeight='bold';
|
||||
const derivationName=get.translation(derivation);
|
||||
derivationNameSpan.innerHTML=derivationName;
|
||||
if(showSkillNamePinyin&&derivationName.length<=5&&derivation.indexOf('_faq')==-1){
|
||||
if(showSkillNamePinyin!='doNotShow'&&derivationName.length<=5&&derivation.indexOf('_faq')==-1){
|
||||
const ruby=document.createElement('ruby');
|
||||
ruby.appendChild(derivationNameSpan);
|
||||
const leftParenthesisRP=document.createElement('rp');
|
||||
|
|
Loading…
Reference in New Issue