优化ui.create.cardTempName,变为两个参数

This commit is contained in:
shijian 2023-09-12 19:53:20 +08:00
parent 8fbd74bcb1
commit 4459785dfa
1 changed files with 25 additions and 18 deletions

View File

@ -37424,15 +37424,7 @@
var cardname=get.name(cards[i]); var cardname=get.name(cards[i]);
var cardnature=get.nature(cards[i]); var cardnature=get.nature(cards[i]);
if(cards[i].name!=cardname||((cardnature||cards[i].nature)&&cards[i].nature!=cardnature)){ if(cards[i].name!=cardname||((cardnature||cards[i].nature)&&cards[i].nature!=cardnature)){
var tempname=get.translation(cardname); var node=ui.create.cardTempName(cards[i]);
var datasetNature='fire';
if(cardname=='sha'){
if(cardnature) tempname=get.translation(cardnature)+tempname;
if(cardnature=='thunder') datasetNature='thunder';
if(cardnature=='kami') datasetNature='kami';
if(cardnature=='ice') datasetNature='ice';
}
var node=ui.create.cardTempName(cards[i],tempname,datasetNature);
var cardtempnameConfig=lib.config.cardtempname; var cardtempnameConfig=lib.config.cardtempname;
if(cardtempnameConfig!=='default') node.classList.remove('vertical'); if(cardtempnameConfig!=='default') node.classList.remove('vertical');
} }
@ -39748,14 +39740,29 @@
void window.getComputedStyle(node, null).getPropertyValue("opacity"); void window.getComputedStyle(node, null).getPropertyValue("opacity");
}, },
create:{ create:{
cardTempName:function(card,tempName,nature){ cardTempName:function(card,applyNode){
const node=card._tempName||ui.create.div('.tempname',card); const getApplyNode=applyNode||card;
card._tempName=node; const cardName=get.name(card);
const tempname=get.translation(tempName); const cardNature=get.nature(card);
if(lib.config.cardtempname=='default') card._tempName.classList.add('vertical'); let tempname=get.translation(cardName);
card._tempName.dataset.nature=nature||'wood'; const node=getApplyNode._tempName||ui.create.div('.tempname',getApplyNode);
card._tempName.innerHTML=lib.config.cardtempname=='default'?get.verticalStr(tempname):tempname; getApplyNode._tempName=node;
card._tempName.tempname=tempname; let datasetNature='fire';
if(get.position(card)=='j'&&card.viewAs&&card.viewAs!=card.name) {
datasetNature = 'wood';
tempname=get.translation(card.viewAs);
}else{
if(cardName=='sha'){
if(cardNature) tempname=get.translation(cardNature)+tempname;
if(cardNature=='thunder') datasetNature='thunder';
if(cardNature=='kami') datasetNature='kami';
if(cardNature=='ice') datasetNature='ice';
}
}
if(lib.config.cardtempname=='default') getApplyNode._tempName.classList.add('vertical');
getApplyNode._tempName.dataset.nature=datasetNature;
getApplyNode._tempName.innerHTML=lib.config.cardtempname=='default'?get.verticalStr(tempname):tempname;
getApplyNode._tempName.tempname=tempname;
return node; return node;
}, },
connectRooms:function(list){ connectRooms:function(list){
@ -49056,7 +49063,7 @@
lib.setIntro(node); lib.setIntro(node);
} }
if(get.position(item)=='j'&&item.viewAs&&item.viewAs!=item.name&&lib.config.cardtempname!='off'){ if(get.position(item)=='j'&&item.viewAs&&item.viewAs!=item.name&&lib.config.cardtempname!='off'){
ui.create.cardTempName(node,item.viewAs,'wood'); ui.create.cardTempName(item,node);
} }
break; break;