Optimize the double group related code.

This commit is contained in:
Tipx-L 2023-08-26 01:22:04 -07:00
parent 3f607d3017
commit 495a971cdc
3 changed files with 76 additions and 102 deletions

View File

@ -7082,40 +7082,32 @@
this.classList.remove('removing'); this.classList.remove('removing');
return this; return this;
}; };
HTMLDivElement.prototype.setBackground=function(name,type,ext,subfolder){ Object.defineProperty(HTMLDivElement.prototype,'setBackground',{
configurable:true,
enumerable:false,
writable:true,
value:function(name,type,ext,subfolder){
if(!name) return; if(!name) return;
var src; let src;
if(ext=='noskin'){ if(ext=='noskin') ext='.jpg';
ext='.jpg';
}
ext=ext||'.jpg'; ext=ext||'.jpg';
subfolder=subfolder||'default' subfolder=subfolder||'default';
if(type){ if(type){
var dbimage=null,extimage=null,modeimage=null; let dbimage=null,extimage=null,modeimage=null,nameinfo,gzbool=false;
var nameinfo; const mode=get.mode();
var gzbool=false;
var mode=get.mode();
if(type=='character'){ if(type=='character'){
if(lib.characterPack['mode_'+mode]&&lib.characterPack['mode_'+mode][name]){ if(lib.characterPack[`mode_${mode}`]&&lib.characterPack[`mode_${mode}`][name]) if(mode=='guozhan'){
if(mode=='guozhan'){
nameinfo=lib.character[name]; nameinfo=lib.character[name];
if(name.indexOf('gz_shibing')==0){ if(name.indexOf('gz_shibing')==0) name=name.slice(3,11);
name=name.slice(3,11);
}
else{ else{
if(lib.config.mode_config.guozhan.guozhanSkin&&lib.character[name]&&lib.character[name][4].contains('gzskin')) gzbool=true; if(lib.config.mode_config.guozhan.guozhanSkin&&lib.character[name]&&lib.character[name][4].contains('gzskin')) gzbool=true;
name=name.slice(3); name=name.slice(3);
} }
} }
else{ else modeimage=mode;
modeimage=mode; else if(lib.character[name]) nameinfo=lib.character[name];
}
}
else if(lib.character[name]){
nameinfo=lib.character[name];
}
else if(lib.config.show_extensionimage){ else if(lib.config.show_extensionimage){
var pack=Object.keys(lib.characterPack).find(pack => Object.keys(lib.characterPack[pack]).contains(name)); const pack=Object.keys(lib.characterPack).find(pack=>Object.keys(lib.characterPack[pack]).contains(name));
if(pack) nameinfo=lib.characterPack[pack][name]; if(pack) nameinfo=lib.characterPack[pack][name];
} }
else if(name.indexOf('::')!=-1){ else if(name.indexOf('::')!=-1){
@ -7124,51 +7116,41 @@
name=name[1]; name=name[1];
} }
} }
if(!modeimage&&nameinfo&&nameinfo[4]){ if(!modeimage&&nameinfo&&nameinfo[4]) for(const value of nameinfo[4]){
for(var i=0;i<nameinfo[4].length;i++){ if(value.indexOf('ext:')==0){
if(nameinfo[4][i].indexOf('ext:')==0){ extimage=value;
extimage=nameinfo[4][i];break; break;
} }
else if(nameinfo[4][i].indexOf('db:')==0){ else if(value.indexOf('db:')==0){
dbimage=nameinfo[4][i];break; dbimage=value;
break;
} }
else if(nameinfo[4][i].indexOf('mode:')==0){ else if(value.indexOf('mode:')==0){
modeimage=nameinfo[4][i].slice(5);break; modeimage=value.slice(5);
break;
} }
else if(nameinfo[4][i].indexOf('character:')==0){ else if(value.indexOf('character:')==0){
name=nameinfo[4][i].slice(10);break; name=value.slice(10);
break;
} }
} }
} if(extimage) src=extimage.replace(/ext:/,'extension/');
if(extimage){
src=extimage.replace(/ext:/,'extension/');
}
else if(dbimage){ else if(dbimage){
this.setBackgroundDB(dbimage.slice(3)); this.setBackgroundDB(dbimage.slice(3));
return this; return this;
} }
else if(modeimage){ else if(modeimage) src=`image/mode/${modeimage}/character/${name}${ext}`;
src='image/mode/'+modeimage+'/character/'+name+ext; else if(type=='character'&&lib.config.skin[name]&&arguments[2]!='noskin') src=`image/skin/${name}/${lib.config.skin[name]}${ext}`;
} else if(type=='character') src=`image/character/${gzbool?'gz_':''}${name}${ext}`;
else if(type=='character'&&lib.config.skin[name]&&arguments[2]!='noskin'){ else src=`image/${type}/${subfolder}/${name}${ext}`;
src='image/skin/'+name+'/'+lib.config.skin[name]+ext;
}
else{
if(type=='character'){
src='image/character/'+(gzbool?'gz_':'')+name+ext;
}
else{
src='image/'+type+'/'+subfolder+'/'+name+ext;
}
}
}
else{
src='image/'+name+ext;
} }
else src=`image/${name}${ext}`;
this.setBackgroundImage(src); this.setBackgroundImage(src);
this.style.backgroundSize="cover"; this.style.backgroundPositionX='center';
this.style.backgroundSize='cover';
return this; return this;
}; }
});
HTMLDivElement.prototype.setBackgroundDB=function(img){ HTMLDivElement.prototype.setBackgroundDB=function(img){
var node=this; var node=this;
game.getDB('image',img,function(src){ game.getDB('image',img,function(src){
@ -47855,14 +47837,8 @@
node.node.group.style.display='none'; node.node.group.style.display='none';
} }
node.classList.add('newstyle'); node.classList.add('newstyle');
if(double&&double.length){
node.node.name.dataset.nature=get.groupnature(double[0]);
node.node.group.dataset.nature=get.groupnature(double[double.length==2?1:0]);
}
else{
node.node.name.dataset.nature=get.groupnature(get.bordergroup(infoitem)); node.node.name.dataset.nature=get.groupnature(get.bordergroup(infoitem));
node.node.group.dataset.nature=get.groupnature(get.bordergroup(infoitem),'raw'); node.node.group.dataset.nature=get.groupnature(get.bordergroup(infoitem),'raw');
}
ui.create.div(node.node.hp); ui.create.div(node.node.hp);
var hp=get.infoHp(infoitem[2]),maxHp=get.infoMaxHp(infoitem[2]),hujia=get.infoHujia(infoitem[2]); var hp=get.infoHp(infoitem[2]),maxHp=get.infoMaxHp(infoitem[2]),hujia=get.infoHujia(infoitem[2]);
var str=get.numStr(hp); var str=get.numStr(hp);
@ -47920,18 +47896,12 @@
} }
if(infoitem[1]){ if(infoitem[1]){
if(double){ if(double){
var str='<div>'; node.node.group.innerHTML=double.reduce((previousValue,currentValue)=>`${previousValue}<div data-nature="${get.groupnature(currentValue)}">${get.translation(currentValue)}</div>`,'');
if(double.length==2){ if(double.length>4) if(new Set([5,6,9]).has(double.length)) node.node.group.style.height='48px';
for(var i of double){ else node.node.group.style.height='64px';
str+=get.translation(i);
} }
} else node.node.group.innerHTML=`<div>${get.translation(infoitem[1])}</div>`;
else str+=get.translation(double[0]); node.node.group.style.backgroundColor=get.translation(`${get.bordergroup(infoitem)}Color`);
str+='</div>';
node.node.group.innerHTML=str;
}
else node.node.group.innerHTML='<div>'+get.translation(infoitem[1])+'</div>';
node.node.group.style.backgroundColor=get.translation(get.bordergroup(infoitem)+'Color');
} }
else{ else{
node.node.group.style.display='none'; node.node.group.style.display='none';

View File

@ -1970,8 +1970,12 @@ div:not(.handcards)>.card>.info>span,
left: 0; left: 0;
} }
.button.character>.identity { .button.character>.identity {
top: -6px; align-items: flex-end;
display: flex;
flex-direction: column;
flex-wrap: wrap-reverse;
left: 72px; left: 72px;
top: -6px;
} }
.button.character.newstyle>.identity{ .button.character.newstyle>.identity{
/*display: none;*/ /*display: none;*/
@ -1979,8 +1983,8 @@ div:not(.handcards)>.card>.info>span,
background: none !important; background: none !important;
/*box-shadow: none;*/ /*box-shadow: none;*/
left: auto; left: auto;
right: 3px; right: 6px;
top: 3px; top: 5px;
/*font-size: 20px;*/ /*font-size: 20px;*/
} }
.button.newstyle>.name{ .button.newstyle>.name{
@ -2768,11 +2772,11 @@ div:not(.handcards)>.card>.info>span,
} }
.identity { .identity {
text-align: center; text-align: center;
width: 22px;
height: 22px;
} }
.identity>div { .identity>div {
line-height: 16px;
position: relative; position: relative;
text-align: right;
top: 2px; top: 2px;
} }
@ -3833,19 +3837,19 @@ div:hover>.intro {
} }
.player .identity { .player .identity {
align-items: flex-end;
border: none; border: none;
width: 24px;
height: 24px;
border-radius: 100%; border-radius: 100%;
display: inline-flex; display: flex;
flex-direction: column;
transition: all 0.2s; transition: all 0.2s;
} }
.player .identity>div { .player .identity>div {
margin: auto;
position: relative; position: relative;
font-family: 'huangcao','xinwei'; font-family: 'huangcao','xinwei';
font-size: 24px; font-size: 24px;
line-height: 24px;
top: 0; top: 0;
} }
.player .identity.animate { .player .identity.animate {

View File

@ -320,8 +320,8 @@
} }
.player .identity{ .player .identity{
top: -8px; right: -6px;
left: 132px; top: -5px;
} }
.player.minskin .identity{ .player.minskin .identity{
left:102px; left:102px;