Optimize the double group related code.
This commit is contained in:
parent
3f607d3017
commit
495a971cdc
152
game/game.js
152
game/game.js
|
@ -7082,93 +7082,75 @@
|
|||
this.classList.remove('removing');
|
||||
return this;
|
||||
};
|
||||
HTMLDivElement.prototype.setBackground=function(name,type,ext,subfolder){
|
||||
if(!name) return;
|
||||
var src;
|
||||
if(ext=='noskin'){
|
||||
ext='.jpg';
|
||||
}
|
||||
ext=ext||'.jpg';
|
||||
subfolder=subfolder||'default'
|
||||
if(type){
|
||||
var dbimage=null,extimage=null,modeimage=null;
|
||||
var nameinfo;
|
||||
var gzbool=false;
|
||||
var mode=get.mode();
|
||||
if(type=='character'){
|
||||
if(lib.characterPack['mode_'+mode]&&lib.characterPack['mode_'+mode][name]){
|
||||
if(mode=='guozhan'){
|
||||
Object.defineProperty(HTMLDivElement.prototype,'setBackground',{
|
||||
configurable:true,
|
||||
enumerable:false,
|
||||
writable:true,
|
||||
value:function(name,type,ext,subfolder){
|
||||
if(!name) return;
|
||||
let src;
|
||||
if(ext=='noskin') ext='.jpg';
|
||||
ext=ext||'.jpg';
|
||||
subfolder=subfolder||'default';
|
||||
if(type){
|
||||
let dbimage=null,extimage=null,modeimage=null,nameinfo,gzbool=false;
|
||||
const mode=get.mode();
|
||||
if(type=='character'){
|
||||
if(lib.characterPack[`mode_${mode}`]&&lib.characterPack[`mode_${mode}`][name]) if(mode=='guozhan'){
|
||||
nameinfo=lib.character[name];
|
||||
if(name.indexOf('gz_shibing')==0){
|
||||
name=name.slice(3,11);
|
||||
}
|
||||
if(name.indexOf('gz_shibing')==0) name=name.slice(3,11);
|
||||
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);
|
||||
}
|
||||
}
|
||||
else{
|
||||
modeimage=mode;
|
||||
else modeimage=mode;
|
||||
else if(lib.character[name]) nameinfo=lib.character[name];
|
||||
else if(lib.config.show_extensionimage){
|
||||
const pack=Object.keys(lib.characterPack).find(pack=>Object.keys(lib.characterPack[pack]).contains(name));
|
||||
if(pack) nameinfo=lib.characterPack[pack][name];
|
||||
}
|
||||
else if(name.indexOf('::')!=-1){
|
||||
name=name.split('::');
|
||||
modeimage=name[0];
|
||||
name=name[1];
|
||||
}
|
||||
}
|
||||
else if(lib.character[name]){
|
||||
nameinfo=lib.character[name];
|
||||
}
|
||||
else if(lib.config.show_extensionimage){
|
||||
var pack=Object.keys(lib.characterPack).find(pack => Object.keys(lib.characterPack[pack]).contains(name));
|
||||
if(pack) nameinfo=lib.characterPack[pack][name];
|
||||
}
|
||||
else if(name.indexOf('::')!=-1){
|
||||
name=name.split('::');
|
||||
modeimage=name[0];
|
||||
name=name[1];
|
||||
}
|
||||
}
|
||||
if(!modeimage&&nameinfo&&nameinfo[4]){
|
||||
for(var i=0;i<nameinfo[4].length;i++){
|
||||
if(nameinfo[4][i].indexOf('ext:')==0){
|
||||
extimage=nameinfo[4][i];break;
|
||||
if(!modeimage&&nameinfo&&nameinfo[4]) for(const value of nameinfo[4]){
|
||||
if(value.indexOf('ext:')==0){
|
||||
extimage=value;
|
||||
break;
|
||||
}
|
||||
else if(nameinfo[4][i].indexOf('db:')==0){
|
||||
dbimage=nameinfo[4][i];break;
|
||||
else if(value.indexOf('db:')==0){
|
||||
dbimage=value;
|
||||
break;
|
||||
}
|
||||
else if(nameinfo[4][i].indexOf('mode:')==0){
|
||||
modeimage=nameinfo[4][i].slice(5);break;
|
||||
else if(value.indexOf('mode:')==0){
|
||||
modeimage=value.slice(5);
|
||||
break;
|
||||
}
|
||||
else if(nameinfo[4][i].indexOf('character:')==0){
|
||||
name=nameinfo[4][i].slice(10);break;
|
||||
else if(value.indexOf('character:')==0){
|
||||
name=value.slice(10);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(extimage){
|
||||
src=extimage.replace(/ext:/,'extension/');
|
||||
}
|
||||
else if(dbimage){
|
||||
this.setBackgroundDB(dbimage.slice(3));
|
||||
return this;
|
||||
}
|
||||
else if(modeimage){
|
||||
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{
|
||||
src='image/'+type+'/'+subfolder+'/'+name+ext;
|
||||
if(extimage) src=extimage.replace(/ext:/,'extension/');
|
||||
else if(dbimage){
|
||||
this.setBackgroundDB(dbimage.slice(3));
|
||||
return this;
|
||||
}
|
||||
else if(modeimage) 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 src=`image/${type}/${subfolder}/${name}${ext}`;
|
||||
}
|
||||
else src=`image/${name}${ext}`;
|
||||
this.setBackgroundImage(src);
|
||||
this.style.backgroundPositionX='center';
|
||||
this.style.backgroundSize='cover';
|
||||
return this;
|
||||
}
|
||||
else{
|
||||
src='image/'+name+ext;
|
||||
}
|
||||
this.setBackgroundImage(src);
|
||||
this.style.backgroundSize="cover";
|
||||
return this;
|
||||
};
|
||||
});
|
||||
HTMLDivElement.prototype.setBackgroundDB=function(img){
|
||||
var node=this;
|
||||
game.getDB('image',img,function(src){
|
||||
|
@ -47855,14 +47837,8 @@
|
|||
node.node.group.style.display='none';
|
||||
}
|
||||
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.group.dataset.nature=get.groupnature(get.bordergroup(infoitem),'raw');
|
||||
}
|
||||
node.node.name.dataset.nature=get.groupnature(get.bordergroup(infoitem));
|
||||
node.node.group.dataset.nature=get.groupnature(get.bordergroup(infoitem),'raw');
|
||||
ui.create.div(node.node.hp);
|
||||
var hp=get.infoHp(infoitem[2]),maxHp=get.infoMaxHp(infoitem[2]),hujia=get.infoHujia(infoitem[2]);
|
||||
var str=get.numStr(hp);
|
||||
|
@ -47920,18 +47896,12 @@
|
|||
}
|
||||
if(infoitem[1]){
|
||||
if(double){
|
||||
var str='<div>';
|
||||
if(double.length==2){
|
||||
for(var i of double){
|
||||
str+=get.translation(i);
|
||||
}
|
||||
}
|
||||
else str+=get.translation(double[0]);
|
||||
str+='</div>';
|
||||
node.node.group.innerHTML=str;
|
||||
node.node.group.innerHTML=double.reduce((previousValue,currentValue)=>`${previousValue}<div data-nature="${get.groupnature(currentValue)}">${get.translation(currentValue)}</div>`,'');
|
||||
if(double.length>4) if(new Set([5,6,9]).has(double.length)) node.node.group.style.height='48px';
|
||||
else node.node.group.style.height='64px';
|
||||
}
|
||||
else node.node.group.innerHTML='<div>'+get.translation(infoitem[1])+'</div>';
|
||||
node.node.group.style.backgroundColor=get.translation(get.bordergroup(infoitem)+'Color');
|
||||
else node.node.group.innerHTML=`<div>${get.translation(infoitem[1])}</div>`;
|
||||
node.node.group.style.backgroundColor=get.translation(`${get.bordergroup(infoitem)}Color`);
|
||||
}
|
||||
else{
|
||||
node.node.group.style.display='none';
|
||||
|
|
|
@ -1970,8 +1970,12 @@ div:not(.handcards)>.card>.info>span,
|
|||
left: 0;
|
||||
}
|
||||
.button.character>.identity {
|
||||
top: -6px;
|
||||
align-items: flex-end;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: wrap-reverse;
|
||||
left: 72px;
|
||||
top: -6px;
|
||||
}
|
||||
.button.character.newstyle>.identity{
|
||||
/*display: none;*/
|
||||
|
@ -1979,8 +1983,8 @@ div:not(.handcards)>.card>.info>span,
|
|||
background: none !important;
|
||||
/*box-shadow: none;*/
|
||||
left: auto;
|
||||
right: 3px;
|
||||
top: 3px;
|
||||
right: 6px;
|
||||
top: 5px;
|
||||
/*font-size: 20px;*/
|
||||
}
|
||||
.button.newstyle>.name{
|
||||
|
@ -2768,11 +2772,11 @@ div:not(.handcards)>.card>.info>span,
|
|||
}
|
||||
.identity {
|
||||
text-align: center;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
}
|
||||
.identity>div {
|
||||
line-height: 16px;
|
||||
position: relative;
|
||||
text-align: right;
|
||||
top: 2px;
|
||||
}
|
||||
|
||||
|
@ -3833,19 +3837,19 @@ div:hover>.intro {
|
|||
}
|
||||
|
||||
.player .identity {
|
||||
align-items: flex-end;
|
||||
border: none;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border-radius: 100%;
|
||||
display: inline-flex;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.player .identity>div {
|
||||
margin: auto;
|
||||
position: relative;
|
||||
font-family: 'huangcao','xinwei';
|
||||
font-size: 24px;
|
||||
line-height: 24px;
|
||||
top: 0;
|
||||
}
|
||||
.player .identity.animate {
|
||||
|
|
|
@ -320,8 +320,8 @@
|
|||
}
|
||||
|
||||
.player .identity{
|
||||
top: -8px;
|
||||
left: 132px;
|
||||
right: -6px;
|
||||
top: -5px;
|
||||
}
|
||||
.player.minskin .identity{
|
||||
left:102px;
|
||||
|
|
Loading…
Reference in New Issue