Merge pull request #734 from nofficalfs/Dev-Fix-NoPictureCharacter
fix: remove new image to check character avatar.
This commit is contained in:
commit
281d957deb
31
game/game.js
31
game/game.js
|
@ -8794,29 +8794,14 @@ new Promise(resolve=>{
|
||||||
this.setBackgroundImage(src);
|
this.setBackgroundImage(src);
|
||||||
this.style.backgroundPositionX='center';
|
this.style.backgroundPositionX='center';
|
||||||
this.style.backgroundSize='cover';
|
this.style.backgroundSize='cover';
|
||||||
if(type=='character'){
|
if (type === 'character') {
|
||||||
new Promise((_,reject)=>{
|
const nameinfo = get.character(name);
|
||||||
const image=new Image();
|
const sex = nameinfo ? nameinfo[0] : 'male';
|
||||||
image.src=`${lib.assetURL}${src}`;
|
this.style.backgroundImage = [
|
||||||
image.onerror=reject;
|
this.style.backgroundImage,
|
||||||
}).catch(()=>new Promise((_,reject)=>{
|
`url("${lib.assetURL}image/character/default_silhouette_${sex}${ext}")`,
|
||||||
const nameinfo=get.character(name);
|
`url("${lib.assetURL}image/character/default_silhouette_male${ext}")`,
|
||||||
if(!nameinfo) reject('noinfo');
|
].join(",");
|
||||||
const sex=nameinfo[0];
|
|
||||||
src=`image/character/default_silhouette_${sex}${ext}`;
|
|
||||||
const image=new Image();
|
|
||||||
image.src=`${lib.assetURL}${src}`;
|
|
||||||
image.onload=()=>this.setBackgroundImage(src);
|
|
||||||
image.onerror=()=>reject(`sex:${sex}`);
|
|
||||||
})).catch(reason=>{
|
|
||||||
let sex;
|
|
||||||
if(reason=='noinfo') sex='male';
|
|
||||||
else sex=reason.slice(4);
|
|
||||||
src=`image/character/default_silhouette_${sex=='female'?'female':'male'}${ext}`;
|
|
||||||
const image=new Image();
|
|
||||||
image.src=`${lib.assetURL}${src}`;
|
|
||||||
image.onload=()=>this.setBackgroundImage(src);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue