From e5e57f59ee3a1a0b92b6e7723b4d148928ccf4c4 Mon Sep 17 00:00:00 2001 From: copcap Date: Sun, 19 Nov 2023 06:30:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A2=AB=E5=9B=9E=E6=BB=9A?= =?UTF-8?q?=E7=9A=84=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game/game.js | 57 +++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/game/game.js b/game/game.js index 1b642b754..e2f6bae5f 100644 --- a/game/game.js +++ b/game/game.js @@ -8656,36 +8656,33 @@ else src=`image/${type}/${subfolder}/${name}${ext}`; } else src=`image/${name}${ext}`; - new Promise((resolve,reject)=>{ - const image=new Image(); - image.src=`${lib.assetURL}${src}`; - image.onload=resolve; - if(type=='character') image.onerror=reject; - }).then(()=>{ - this.setBackgroundImage(src); - this.style.backgroundPositionX='center'; - this.style.backgroundSize='cover'; - }).catch(()=>new Promise((resolve,reject)=>{ - const nameinfo=get.character(name); - const sex=nameinfo[0]; - src=`image/character/default_silhouette_${sex}${ext}`; - const image=new Image(); - image.src=`${lib.assetURL}${src}`; - image.onload=()=>resolve(src); - image.onerror=reject; - }).catch(()=>new Promise((resolve,reject)=>{ - const nameinfo=get.character(name); - const sex=nameinfo[0]; - src=`image/character/default_silhouette_${sex=='female'?'female':'male'}${ext}`; - const image=new Image(); - image.src=`${lib.assetURL}${src}`; - image.onload=()=>resolve(src); - image.onerror=reject; - })).then((src)=>{ - this.setBackgroundImage(src); - this.style.backgroundPositionX='center'; - this.style.backgroundSize='cover'; - })); + this.setBackgroundImage(src); + this.style.backgroundPositionX='center'; + this.style.backgroundSize='cover'; + if(type=='character'){ + new Promise((_,reject)=>{ + const image=new Image(); + image.src=`${lib.assetURL}${src}`; + image.onerror=reject; + }).catch(()=>new Promise((_,reject)=>{ + const nameinfo=get.character(name); + if(!nameinfo) reject('noinfo'); + 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; } });