@shimotsuki/core 2.0.8 → 2.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1455 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1,1455 @@
|
|
|
1
|
-
import t from"text-encoding";import{AudioSource as e,_decorator as i,AudioClip as s,error as o,Node as n,director as r,log as a,sys as c,Component as l,Prefab as h,instantiate as p,isValid as d,Layers as u,view as _,Widget as m,v3 as f,tween as g,Enum as y,game as v,UITransform as E,UIOpacity as C,Tween as b,Label as S,BlockInputEvents as T,Button as w,Director as O,warn as A,assetManager as k,Asset as I,resources as x,Game as N,SpriteFrame as M,Sprite as D,AsyncDelegate as R}from"cc";import{PREVIEW as F,DEBUG as U}from"cc/env";import{makeObservable as P,observable as L,autorun as B,reaction as H}from"@shimotsuki/mobx";import G from"crypto-es";import{clone as $}from"@bufbuild/protobuf";import{SocketConnectStatus as j}from"pitayaclient";import{SocialGameClient as K}from"sgc";import{EventEmitter as V}from"eventemitter3";import"core-js/es/array/index.js";console.log("===== TextEncoding Polyfil 开始加载 ====="),void 0===globalThis.TextEncoder&&(globalThis.TextEncoder=t.TextEncoder,globalThis.TextDecoder=t.TextDecoder),console.log("===== TextEncoding Polyfil 已加载 =====");class W extends e{cat;initAudio(t){return this.cat=t,this}}const{ccclass:Q,menu:J}=i;class X extends W{effects=new Map;load(t){return new Promise(((e,i)=>{this.cat.res.load(t,s,((s,o)=>{if(s)return i(s);this.effects.set(t,o),this.playOneShot(o,this.volume),e(o)}))}))}release(){for(let t in this.effects)this.cat.res.release(t);this.effects.clear()}}const{ccclass:q,menu:z}=i;class Z extends W{onComplete=null;_progress=0;_url=null;_isPlay=!1;get progress(){return this.duration>0&&(this._progress=this.currentTime/this.duration),this._progress}set progress(t){this._progress=t,this.currentTime=t*this.duration}load(t,e){this.cat.res.load(t,s,((i,s)=>{i&&o(i),this.playing&&(this._isPlay=!1,this.stop(),this.cat.res.release(this._url)),this.playOnAwake=!1,this.enabled=!0,this.clip=s,this._url=t,e&&e()}))}update(t){this.currentTime>0&&(this._isPlay=!0),this._isPlay&&0==this.playing&&(this._isPlay=!1,this.enabled=!1,this.onComplete&&this.onComplete())}release(){this._url&&(this.cat.res.release(this._url),this._url=null)}}class Y{cat;constructor(t){this.cat=t}}var tt;!function(t){t.MUSIC_ON="AudioEventConstant/MUSIC_ON",t.MUSIC_OFF="AudioEventConstant/MUSIC_OFF",t.EFFECT_ON="AudioEventConstant/EFFECT_ON",t.EFFECT_OFF="AudioEventConstant/EFFECT_OFF",t.PAUSE_AUDIO="AudioEventConstant/PAUSE_AUDIO",t.RESUME_AUDIO="AudioEventConstant/RESUME_AUDIO"}(tt||(tt={}));class et extends Y{local_data={};music;effect;_volume_music=1;_volume_effect=1;_switch_music=!0;_switch_effect=!0;local_store_key="game_audio";extra={};constructor(t){super(t),this.local_store_key=this.cat.audio_local_store_key;var e=new n("UIAudioManager");r.addPersistRootNode(e);var i=new n("UIMusic");i.parent=e,this.music=i.addComponent(Z).initAudio(t);var s=new n("UIEffect");s.parent=e,this.effect=s.addComponent(X).initAudio(t),this.load()}setMusicComplete(t=null){this.music.onComplete=t}playMusic(t,e){this.music.loop=!0,t&&this.music.load(t,(()=>{this._switch_music&&this.music?.play(),e&&e()}))}stopMusic(){0!=this.music.state&&this.music?.stop()}pauseMusic(){1==this.music.state&&this.music?.pause()}resumeMusic(){[0,2].includes(this.music.state)&&this.music?.play()}get progressMusic(){return this.music.progress}set progressMusic(t){this.music.progress=t}get volumeMusic(){return this._volume_music}set volumeMusic(t){this._volume_music=t,this.music.volume=t}get switchMusic(){return this._switch_music}set switchMusic(t){if(a("设置背景音乐开关值",t,this._switch_music),t==this._switch_music)return;this._switch_music=t,t?this.resumeMusic():this.pauseMusic();const e=t?tt.MUSIC_ON:tt.MUSIC_OFF;this.cat.event.emit(e),this.save()}async playEffect(t){this._switch_effect&&t&&await this.effect.load(t).then((()=>{this.effect.play()}))}stopEffect(){this.effect?.stop()}get volumeEffect(){return this._volume_effect}set volumeEffect(t){this._volume_effect=t,this.effect.volume=t}get switchEffect(){return this._switch_effect}set switchEffect(t){if(t==this._switch_effect)return;this._switch_effect=t,t?this.effect?.play():this.effect?.stop();const e=t?tt.EFFECT_ON:tt.EFFECT_OFF;this.cat.event.emit(e),this.save()}resumeAll(){this.switchMusic&&this.music?.play(),this.switchEffect&&this.effect?.play()}pauseAll(){this.music?.pause(),this.effect?.pause()}stopAll(){this.music?.stop(),this.effect?.stop()}save(){this.local_data.volume_music=this._volume_music,this.local_data.volume_effect=this._volume_effect,this.local_data.switch_music=this._switch_music,this.local_data.switch_effect=this._switch_effect,this.local_data.extra=this.extra;let t=JSON.stringify(this.local_data);return this.cat.storage.set(this.local_store_key,t),this}load(){try{let t=this.cat.storage.get(this.local_store_key);this.local_data=JSON.parse(t),this._volume_music=this.local_data.volume_music,this._volume_effect=this.local_data.volume_effect,this._switch_music=this.local_data.switch_music,this._switch_effect=this.local_data.switch_effect,this.extra=this.local_data.extra}catch(t){this.local_data={},this._volume_music=.6,this._volume_effect=1,this._switch_music=!0,this._switch_effect=!0,this.extra={}}this.music&&(this.music.volume=this._volume_music),this.effect&&(this.effect.volume=this._volume_effect)}}class it extends Y{_key=null;_iv=null;_id="";init(t,e){this.cat.util.encryptUtil.initCrypto(t,e),this._key=this.cat.util.encryptUtil.md5(t),this._iv=this.cat.util.encryptUtil.md5(e)}setUser(t){this._id=t}set(t,e){if(null!=(t=`${t}_${this._id}`)){if(F||(t=this.cat.util.encryptUtil.md5(t)),null==e)return console.warn("存储的值为空,则直接移除该存储"),void this.remove(t);if("function"!=typeof e){if("object"==typeof e)try{e=JSON.stringify(e)}catch(t){return void console.error(`解析失败,str = ${e}`)}else"number"==typeof e&&(e+="");F||null==this._key||null==this._iv||(e=this.cat.util.encryptUtil.aesEncrypt(`${e}`,this._key,this._iv)),c.localStorage.setItem(t,e)}else console.error("储存的值不能为方法")}else console.error("存储的key不能为空")}get(t,e){if(null==t)return console.error("存储的key不能为空"),null;t=`${t}_${this._id}`,F||(t=this.cat.util.encryptUtil.md5(t));let i=c.localStorage.getItem(t);return null==i||""===i||F||null==this._key||null==this._iv||(i=this.cat.util.encryptUtil.aesDecrypt(i,this._key,this._iv)),null===i?e:i}getNumber(t,e=0){var i=this.get(t);return Number(i)||e}getBoolean(t){var e=this.get(t);return Boolean(e)||!1}getJson(t,e){var i=this.get(t);return i&&JSON.parse(i)||e}remove(t){null!=t?(t=`${t}_${this._id}`,F||(t=this.cat.util.encryptUtil.md5(t)),c.localStorage.removeItem(t)):console.error("存储的key不能为空")}clear(){c.localStorage.clear()}}function st(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(r=(n<3?o(r):n>3?o(e,i,r):o(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}function ot(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}"function"==typeof SuppressedError&&SuppressedError;class nt extends l{props={};data={};autorunDisposers=[];reactionDisposers=[];eventEmitter=[];hook={destroyed:()=>{},started:()=>{}};initUI(){}__preload(){this.initUI(),this.onAutoObserver()}constructor(){super(),P(this,{props:L,data:L})}onAutoObserver(){}addAutorun(t){return(Array.isArray(t)?t:[t]).forEach((t=>{const e=B(t);this.autorunDisposers.push(e)})),this}addReaction(t,e,i){const s=H(t,e,i);return this.reactionDisposers.push(s),this}addAudoListener(t){return this.eventEmitter.includes(t)||t===de.event||this.eventEmitter.push(t),t}_onPreDestroy(){this.autorunDisposers.forEach((t=>{t()})),this.reactionDisposers.forEach((t=>{t()})),this.autorunDisposers=[],this.reactionDisposers=[],super._onPreDestroy()}onDisable(){this.onHide(),this.deleteAllEventByEmitter(de.event),this.eventEmitter.forEach((t=>{this.deleteAllEventByEmitter(t)})),this.eventEmitter=[],this.removeListener()}deleteAllEventByEmitter(t){const e=t._events;for(const i in e){let s=e[i];Array.isArray(s)||(s=[s]),s.forEach((e=>{e.context===this&&t.off(i,e.fn,this)}))}}onEnable(){this.onShow(),this.addListener(),this.onEventListener()}onEventListener(){}addListener(){}removeListener(){}addToParent(t,e){let i=t instanceof h?p(t):t instanceof l?t.node:t;return this.setOptions(e),i.addChild(this.node),this}setOptions(t){if(t)for(let e in t)switch(e){case"hook":t.hook&&(this.hook=t.hook);break;case"props":null!==t.props&&"object"==typeof t.props&&(this.props=t.props);break;case"data":null!==t.data&&"object"==typeof t.data&&(this.data=t.data)}}setUpdateData(t){return t&&Object.assign(this.data,t),this}setUpdateProps(t){return this.props,t&&Object.assign(this.props,t),this}removeAndDestroy(){d(this?.node)&&(this.node.removeFromParent(),this.node.destroy())}setPosition(t){return this.node.setPosition(t),this}setScale(t){return this.node.setScale(t),this}setAngle(t){return this.node.angle=t,this}setRotation(t){return this.node.setRotation(t),this}setRotationFromEuler(t){return this.node.setRotationFromEuler(t),this}onShow(){}onHide(){}setNodeAndChildrenLayer(t){return rt(this.node,t),this}}const rt=(t,e)=>{t.layer="string"==typeof e?2**u.nameToLayer(e):e,t?.children.forEach((t=>{rt(t,e)}))};class at extends nt{lastEnterDirection="center";screen;isClosing=!1;root;constructor(){super(),this._init()}_init(){this.root=this.node,this.screen=_.getVisibleSize()}async showTween({isMotion:t=!0,direction:e="center",duration:i=.1,isBounce:s=!0,bounceDuration:o=.05}){if(this.lastEnterDirection=e,t){const t=this.node.getComponent(m);let o,n;t&&(t.updateAlignment(),t.enabled=!1),f(1.1,1.1,1),"center"==e?(o=f(.01,.01,.01),n=f(1,1,1)):(o="left"==e?f(-this.screen.width,0,0):"right"==e?f(this.screen.width,0,0):f(0,"top"==e?this.screen.height:-this.screen.height,0),n=f(0,0,0)),await this.handle(e,i,o,n,s),t&&(t.enabled=!0)}}async hideTween({isMotion:t=!0,direction:e,duration:i=.1}){if(e=e||this.lastEnterDirection,!this.isClosing){if(this.isClosing=!0,g(this.node).removeSelf(),t){const t=this.node.getComponent(m);let s,o;t&&(t.enabled=!1),"center"==e?(s=this.node.scale,o=f(0,0,0)):(o="left"==e?f(-this.screen.width,0,0):"right"==e?f(this.screen.width,0,0):f(0,"top"==e?this.screen.height:-this.screen.height,0),s=this.node.getPosition()),await this.handle(e,i,s,o,!1)}this.removeAndDestroy()}}async handle(t,e,i,s,o){"center"==t?this.node.setScale(i):this.node.setPosition(i),await this.deftween(e,{["center"==t?"scale":"position"]:s},o)}deftween(t,e,i,s){return new Promise(((i,s)=>{g(this.node).to(t,e).call((()=>{i()})).start()}))}}const{ccclass:ct,property:lt}=i;var ht;!function(t){t[t.EFFECT=0]="EFFECT",t[t.BGM=1]="BGM"}(ht||(ht={}));class pt extends nt{type=ht.EFFECT;clip=null;loop=!1;volume=1;playOnAwake=!1;audioSource=new e;onEnable(){super.onEnable(),this.clip&&(this.audioSource.clip=this.clip),this.audioSource.loop=this.loop,this.audioSource.volume=this.volume,this.audioSource.playOnAwake=this.playOnAwake,de.event.on(tt.EFFECT_ON,this.onPlayEffectHandler,this).on(tt.EFFECT_OFF,this.onStopEffectHandler,this).on(tt.MUSIC_ON,this.onPlayMusicHandler,this).on(tt.MUSIC_OFF,this.onStopMusicHandler,this)}__preload(){super.__preload();const{volumeEffect:t,volumeMusic:e}=de.audio;this.audioSource.volume=this.type===ht.BGM?e:t}start(){}stopAudio(){this.audioSource.stop()}playAudio(){const{switchEffect:t,switchMusic:e}=de.audio;this.audioSource.playing||!(this.type===ht.BGM?e:t)||v._paused||this.audioSource.play()}onPlayEffectHandler(){}onStopEffectHandler(){this.stopAudio()}onPlayMusicHandler(){}onStopMusicHandler(){this.stopAudio()}_onPreDestroy(){this.onStopMusicHandler(),super._onPreDestroy()}}st([lt({tooltip:"类型:\n EFFECT 音效\n BGM 音乐",type:y(ht)}),ot("design:type",Object)],pt.prototype,"type",void 0),st([lt({tooltip:"音源",type:s}),ot("design:type",Object)],pt.prototype,"clip",void 0),st([lt({tooltip:"循环"}),ot("design:type",Object)],pt.prototype,"loop",void 0),st([lt({tooltip:"音量"}),ot("design:type",Object)],pt.prototype,"volume",void 0),st([lt({tooltip:"是否启用自动播放"}),ot("design:type",Object)],pt.prototype,"playOnAwake",void 0);const{ccclass:dt,property:ut}=i;class _t extends at{type=ht.EFFECT;clip=null;loop=!1;volume=1;playOnAwake=!1;audioSource=new e;onEnable(){super.onEnable(),de.event.on(tt.EFFECT_ON,this.onPlayEffectHandler,this).on(tt.EFFECT_OFF,this.onStopEffectHandler,this).on(tt.MUSIC_ON,this.onPlayMusicHandler,this).on(tt.MUSIC_OFF,this.onStopMusicHandler,this)}__preload(){this.clip&&(this.audioSource.clip=this.clip),this.audioSource.loop=this.loop,this.audioSource.volume=this.volume,this.audioSource.playOnAwake=this.playOnAwake,super.__preload();const{volumeEffect:t,volumeMusic:e}=de.audio;this.audioSource.volume=this.type===ht.BGM?e:t}stopAudio(){this.audioSource.stop()}playAudio(){const{switchEffect:t,switchMusic:e}=de.audio;this.audioSource.playing||!(this.type===ht.BGM?e:t)||v._paused||this.audioSource.play()}onPlayEffectHandler(){}onStopEffectHandler(){this.stopAudio()}onPlayMusicHandler(){}onStopMusicHandler(){this.stopAudio()}_onPreDestroy(){this.onStopMusicHandler(),super._onPreDestroy()}}st([ut({tooltip:"类型:\n EFFECT 音效\n BGM 音乐",type:y(ht)}),ot("design:type",Object)],_t.prototype,"type",void 0),st([ut({tooltip:"音源",type:s}),ot("design:type",Object)],_t.prototype,"clip",void 0),st([ut({tooltip:"循环"}),ot("design:type",Object)],_t.prototype,"loop",void 0),st([ut({tooltip:"音量"}),ot("design:type",Object)],_t.prototype,"volume",void 0),st([ut({tooltip:"是否启用自动播放"}),ot("design:type",Object)],_t.prototype,"playOnAwake",void 0);const{ccclass:mt,property:ft,menu:gt}=i;var yt;!function(t){t[t.FIXED=0]="FIXED",t[t.SLIDE=1]="SLIDE"}(yt||(yt={}));let vt=class extends nt{fixed_node;slide_node;fixed_label;slide_label;onLoad(){this.fixed_node.active=this.slide_node.active=!1}start(){this.show()}async show(){return new Promise((async(t,e)=>{const{title:i,type:s,fixed_time:o}=this.props;if(s==yt.FIXED){this.fixed_node.active=!0,this.fixed_label.string=`${i}`,this.fixed_label.updateRenderData(!0);const e=this.fixed_label.node.getComponent(E).height;e-this.fixed_node.getComponent(E).height>0&&(this.fixed_node.getComponent(E).height=e+100),this.scheduleOnce((()=>{this.node.destroy(),t()}),o)}else{this.slide_node.active=!0,this.slide_label.string=`${i}`,this.slide_label.updateRenderData(!0);const e=this.slide_label.node.getComponent(E).width;this.slide_node.getComponent(E).width-e<100&&(this.slide_node.getComponent(E).width=e+100),this.playAnim(this.node).then((()=>{t()}))}}))}playAnim(t){return new Promise(((e,i)=>{const s=this.node.getComponent(C),o=g(s).delay(1.2).to(.5,{opacity:0}).call((()=>{b.stopAllByTarget(t),this.node.destroy(),e()}));g(t).by(.5,{position:f(0,400,0)}).call((()=>{o.start()})).start()}))}onDestroy(){b.stopAllByTarget(this.node),this.unscheduleAllCallbacks()}};var Et;st([ft({type:n,tooltip:"固定节点"}),ot("design:type",n)],vt.prototype,"fixed_node",void 0),st([ft({type:n,tooltip:"滑动节点"}),ot("design:type",n)],vt.prototype,"slide_node",void 0),st([ft({type:S,tooltip:"固定标签节点"}),ot("design:type",S)],vt.prototype,"fixed_label",void 0),st([ft({type:S,tooltip:"滑动标签节点"}),ot("design:type",S)],vt.prototype,"slide_label",void 0),vt=st([mt("CoreToast"),gt("CATCORE/CoreToast")],vt),function(t){t.EVENT_SHOW="GlobalEventConstant/EVENT_SHOW",t.EVENT_HIDE="GlobalEventConstant/EVENT_HIDE",t.GAME_RESIZE="GlobalEventConstant/GAME_RESIZE",t.EVENT_CLOSE="GlobalEventConstant/EVENT_CLOSE",t.ONLINE="GlobalEventConstant/ONLINE",t.OFFLINE="GlobalEventConstant/OFFLINE",t.ROOT_MASK_UPDATE="GlobalEventConstant/ROOT_MASK_UPDATE",t.ROOT_MASK_CHANGE="GlobalEventConstant/ROOT_MASK_CHANGE"}(Et||(Et={}));const{ccclass:Ct,property:bt,menu:St}=i;let Tt=class extends at{scene_mask_node;ui_container;gui=null;onLoad(){this.setSceneMaskActive(!1)}get scene_mask(){return this.scene_mask_node.getComponent(Jt)}get brother(){return this.ui_container.children||[]}get tweenChildren(){return this.scene_mask.tween.children}onEventListener(){de.event.on(Et.ROOT_MASK_CHANGE,this.uiMaskChanged,this)}addMask(){const t=this.brother[this.brother.length-1];t&&this.scene_mask.node.setSiblingIndex(t.getSiblingIndex()),this.blockMaskSiblingIndexChanged()}subMask(){const t=this.brother[this.brother.length-2];t&&this.scene_mask.node.setSiblingIndex(t.getSiblingIndex()),this.blockMaskSiblingIndexChanged()}blockMaskSiblingIndexChanged(){this.tweenChildren.length>1||this.brother.length>1?this.show():this.hide()}addNodeToTween(t){return d(this)&&this.scene_mask&&this.scene_mask.tween.addChild(t),this}show(){this.setSceneMaskActive(!0)}hide(){this.setSceneMaskActive(!1)}setGui(t){return this.gui=t,this}uiMaskChanged(){this.blockMaskSiblingIndexChanged()}setSceneMaskActive(t){this.scene_mask.node.active=t}};st([bt({type:n}),ot("design:type",n)],Tt.prototype,"scene_mask_node",void 0),st([bt({type:n}),ot("design:type",n)],Tt.prototype,"ui_container",void 0),Tt=st([Ct("CoreUIContainer"),St("CATCORE/CoreUIContainer")],Tt);class wt extends at{onEnable(){super.onEnable(),this.updateMask()}onDisable(){super.onDisable(),this.updateMask()}updateMask(){de.event.emit(Et.ROOT_MASK_UPDATE)}}const{ccclass:Ot,property:At,menu:kt}=i;let It=class extends wt{title;loadingTween;loading_rotate=0;onAutoObserver(){this.addAutorun([()=>{this.props?.title&&(this.title.string=`${this.props?.title}`),this.title.node.active=!!this.props?.title?.length},()=>{this.getComponent(T).enabled=!!this.props?.mask}])}update(t){this.loading_rotate+=220*t,this.loadingTween.setRotationFromEuler(0,0,-this.loading_rotate%360),this.loading_rotate>360&&(this.loading_rotate-=360)}};st([At({type:S,tooltip:"标题"}),ot("design:type",S)],It.prototype,"title",void 0),st([At({type:n,tooltip:"动画"}),ot("design:type",n)],It.prototype,"loadingTween",void 0),It=st([Ot("CoreShowLoading"),kt("CATCORE/CoreShowLoading")],It);const{ccclass:xt,property:Nt,menu:Mt}=i;var Dt;!function(t){t.RECONNECTED="重连成功",t.RECONNECTING="正在重连",t.MAX_RECONNECT="重连次数超出限制,请检查网络",t.RECONNECTED_ERROR="重连失败,请检查网络",t.CONNECT_PARAM_ERROR="游戏参数错误,请重新加载",t.KICK="账号已下线",t.OFFLINE="网络已断开",t.ONLINE="网络已连接",t.GAME_ERROR="连接游戏服错误"}(Dt||(Dt={}));let Rt=class extends wt{common_prompt_text;btn_confirm;is_close=!1;props={content:null};initUI(){this.btn_confirm.node.active=!1}onLoad(){this.btn_confirm.node.on(w.EventType.CLICK,this.onConfirmHandler,this),this.addAutorun([()=>{this.common_prompt_text.string=this.props.content??""}])}onDestroy(){this.unscheduleAllCallbacks()}updateProps(t){this.updatePromptText(t,t==Dt.RECONNECTING)}updatePromptText(t,e=!1){if(this.unscheduleAllCallbacks(),this.props.content=t,a("更新提示文案:",t),e){let e=0;const i=()=>{e=(e+1)%4,this.common_prompt_text.string=t+["","·","··","···"][e]};this.schedule(i,.5)}}onConfirmHandler(){this.is_close=!0,de.gui.hideReconnect()}};st([Nt({type:S,tooltip:"通用提示文本"}),ot("design:type",S)],Rt.prototype,"common_prompt_text",void 0),st([Nt({type:w,tooltip:"确定按钮"}),ot("design:type",w)],Rt.prototype,"btn_confirm",void 0),Rt=st([xt("CoreReconnection"),Mt("CATCORE/CoreReconnection")],Rt);const{ccclass:Ft,property:Ut,menu:Pt}=i;let Lt=class extends wt{text;btn_confirm;onLoad(){this.btn_confirm.node.on(w.EventType.CLICK,this.onConfrimHandler,this)}start(){this.props&&this.updateProps(this.props)}onConfrimHandler(){this.props?.confrim?.(),de.gui.hideNotice()}updateProps(t){this.text.string=`${t.text}`}};st([Ut({type:S,tooltip:"提示文本"}),ot("design:type",S)],Lt.prototype,"text",void 0),st([Ut({type:w,tooltip:"确定按钮"}),ot("design:type",w)],Lt.prototype,"btn_confirm",void 0),Lt=st([Ft("CoreNotice"),Pt("CATCORE/CoreNotice")],Lt);class Bt extends nt{isReload}const{ccclass:Ht,property:Gt,menu:$t}=i;var jt;!function(t){t[t.UI=0]="UI",t[t.LOADING=1]="LOADING",t[t.TOAST=2]="TOAST",t[t.RECONNECTTION=3]="RECONNECTTION",t[t.NOTICE=4]="NOTICE"}(jt||(jt={}));let Kt=class extends nt{reconnection_ui_prefab;toast_ui_prefab;loading_ui_prefab;notice_ui_prefab;ui_prefab;root_ui;root_toast;root_mask;cat;ui_container_component;reconnection_ui_component;notice_ui_component;loading_ui_component;toast_ui_component;currentScene;onEventListener(){this.cat.event.on(Et.ROOT_MASK_UPDATE,this.onRootUpdate,this)}init(t){this.cat=t;const e=r.getScene();return a("init scene"),e&&this.changeScene(e),this}start(){this.onRootUpdate()}toastQueue=[];isScheduling=!1;minInterval=.2;showToast(t){this.toastQueue.push(t),this.isScheduling||this.processQueueWithInterval()}processQueueWithInterval(){if(0===this.toastQueue.length)return void(this.isScheduling=!1);this.isScheduling=!0;const t=this.toastQueue.shift(),e=()=>{p(this.toast_ui_prefab).getComponent(vt).addToParent(this.root_toast,{props:t}),this.scheduleOnce((()=>{this.processQueueWithInterval()}),this.minInterval)};0===this.root_toast.children.length?e():this.scheduleOnce(e,this.minInterval)}hideToast(){return this.root_toast&&this.root_toast.children.forEach((t=>{t.getComponent(vt)?.removeAndDestroy()})),this.toastQueue=[],this.unschedule(this.processQueueWithInterval),this.isScheduling=!1,this}showLoading({title:t="",mask:e=!0,black:i=!0}={}){if(a("showLoading",t),this.loading_ui_component)this.loading_ui_component.setOptions({props:{title:t,mask:e,black:i}});else{const s=p(this.loading_ui_prefab);this.loading_ui_component=s.getComponent(It).addToParent(this.root_ui,{props:{title:t,mask:e,black:i}})}return this}hideLoading(){return this.loading_ui_component?.removeAndDestroy(),this.loading_ui_component=null,this}showReconnect(t){if(this.reconnection_ui_component)this.reconnection_ui_component.setUpdateProps({content:t});else{const e=p(this.reconnection_ui_prefab);this.reconnection_ui_component=e.getComponent(Rt).addToParent(this.root_ui,{props:{content:t}})}return this}hideReconnect(){return this.reconnection_ui_component?.removeAndDestroy(),this.reconnection_ui_component=null,this}showNotice(t){const e=p(this.notice_ui_prefab);return this.notice_ui_component=e.getComponent(Lt).addToParent(this.root_ui,{props:t}),this}hideNotice(){return this.notice_ui_component?.removeAndDestroy(),this}loadScene(t,e,i){a("加载场景",t,e,i);let s={},o=i??!1;return"boolean"==typeof e?o=e:s=e??{},a("当前场景",r.getScene()?.uuid,r.getScene()?.name),r.once(O.EVENT_BEFORE_SCENE_LAUNCH,(t=>{a("Director.EVENT_BEFORE_SCENE_LAUNCH",t),this.changeScene(t,s,o)})),r.loadScene(t),this}resetScene(t=""){return t=t||this.currentScene,this.loadScene(t)}cleanScene(){this.resetScene().hideLoading().hideNotice().hideReconnect().hideToast()}changeScene(t,e,i){this.currentScene=t.name,this.createUILayer(t);const s=t.getComponentInChildren(Bt);s&&(s.isReload=i??!1),s?.setOptions(e)}createUILayer(t){this.ui_container_component?.removeAndDestroy(),this.ui_container_component=null;const e=p(this.ui_prefab);this.ui_container_component=e.getComponent(Tt).setGui(this).addToParent(t)}reloadScene(){this.loadScene(this.currentScene,!0)}async closeUI(t,e){const{component:i}=this.findUIBaseLayer(t,!1);i&&(i.setOptions({...e?.hook??{},...e?.props??{}}),await i.hideTween(e||{}),this.ui_container_component?.subMask())}async openUI(t,e){const{rootNode:i,component:s}=this.findUIBaseLayer(t,!0);i.getComponent(at),s?.setOptions(e),i&&this.ui_container_component?.addNodeToTween(i).addMask(),s&&await s.showTween(e||{}),this.ui_container_component?.ui_container&&s?.addToParent(this.ui_container_component.ui_container)}findUIBaseLayer(t,e){let i,s=null;if(t instanceof n){i=t;const e=t.components.filter((t=>t instanceof at));if(!e.length)return o(`${t.name}节点未找到继承自BaseLayer的组件`),{rootNode:i,component:s};1==e.length?s=e[0]:A(`${t.name}节点存在多个继承自BaseLayer的组件`)}else if(i=t.node,s=t,e){for(;i.parent;)i=i.parent;s.root=i}else i=t.root;return{rootNode:i,component:s}}onRootUpdate(){const t=this.root_ui.children.findLastIndex((t=>t.active&&t!=this.root_mask));if(this.root_mask.active=-1!=t,t>-1){const e=this.root_ui.children[t];this.root_mask.setSiblingIndex(e.getSiblingIndex()-1)}this.cat.event.emit(Et.ROOT_MASK_CHANGE)}};st([Gt({type:h,tooltip:"断线重连UI预制体"}),ot("design:type",h)],Kt.prototype,"reconnection_ui_prefab",void 0),st([Gt({type:h,tooltip:"提示UI预制体"}),ot("design:type",h)],Kt.prototype,"toast_ui_prefab",void 0),st([Gt({type:h,tooltip:"加载UI预制体"}),ot("design:type",h)],Kt.prototype,"loading_ui_prefab",void 0),st([Gt({type:h,tooltip:"公告UI预制体"}),ot("design:type",h)],Kt.prototype,"notice_ui_prefab",void 0),st([Gt({type:h,tooltip:"UI层预制体"}),ot("design:type",h)],Kt.prototype,"ui_prefab",void 0),st([Gt({type:n,tooltip:"root-UI层"}),ot("design:type",n)],Kt.prototype,"root_ui",void 0),st([Gt({type:n,tooltip:"root-组件层"}),ot("design:type",n)],Kt.prototype,"root_toast",void 0),st([Gt({type:n,tooltip:"root-mask"}),ot("design:type",n)],Kt.prototype,"root_mask",void 0),Kt=st([Ht("Gui"),$t("CATCORE/Gui")],Kt);const{ccclass:Vt,property:Wt,menu:Qt}=i;let Jt=class extends nt{tween};var Xt;st([Wt({type:n,tooltip:"动画节点"}),ot("design:type",n)],Jt.prototype,"tween",void 0),Jt=st([Vt("CoreBlackMask"),Qt("CATCORE/CoreBlackMask")],Jt),function(t){t.Root="prefabs/root",t.Toast="prefabs/toast",t.BlackMask="prefabs/black-mask",t.Loading="prefabs/loading",t.Notice="prefabs/notice",t.Reconnection="prefabs/reconnection"}(Xt||(Xt={}));class qt extends Y{gui;#t="resources";getGuiPrefabByType=(t,e)=>new Promise(((i,s)=>{a(t,`${e}`),this.cat.res.load(t,e,((t,e)=>{t?s(t):i(e)}))}));async init(){this.#t=this.cat.gui_bundle_name;const t=await this.getGuiPrefabByType(this.#t,Xt.Root),e=p(t);return this.gui=e.getComponent(Kt).init(this.cat),r.addPersistRootNode(e),this}}class zt{get=(t,e,i="resources")=>k.getBundle(i).get(t,e);isAssetType=t=>"function"==typeof t&&t.prototype instanceof I;async load(...t){let e=null,i=null,s=null;"string"==typeof t[0]&&"string"==typeof t[1]&&(e=t.shift());let o=t.shift();this.isAssetType(t[0])&&(i=t.shift()),2==t.length&&(s=t.shift());const n=t.shift();let r=x;if(e&&"resources"!=e){k.bundles.has(e)||await this.loadBundle(e);let t=k.bundles.get(e);t&&(r=t)}s&&n?r.load(o,i,s,n):n?r.load(o,i,n):r.load(o,i)}async loadDir(...t){let e=null,i=null,s=null,o=null;"string"==typeof t[0]&&"string"==typeof t[1]&&(e=t.shift());let n=t.shift();this.isAssetType(t[0])&&(i=t.shift()),2==t.length&&(s=t.shift()),o=t.shift();let r=x;if(e&&"resources"!=e){k.bundles.has(e)||await this.loadBundle(e);let t=k.bundles.get(e);t&&(r=t)}s&&o?r.loadDir(n,i,s,o):o?r.loadDir(n,i,o):r.loadDir(n,i)}loadRemote(t,...e){var i,s=null;2==e.length&&(s=e.shift()),i=e.shift(),k.loadRemote(t,{ext:".png",...s},i)}loadBundle=(t,e)=>new Promise(((i,s)=>{const o=(t,e)=>{if(t)return s(t);i(e)};e?k.loadBundle(t,{version:e},o):k.loadBundle(t,o)}));releasePrefabtDepsRecursively=t=>{var e=k.assets.get(t);(k.releaseAsset(e),e instanceof h)&&k.dependUtil.getDepsRecursively(t).forEach((t=>{k.assets.get(t).decRef()}))};release=(t,e="resources")=>{var i=k.getBundle(e);if(i){var s=i.get(t);s&&this.releasePrefabtDepsRecursively(s._uuid)}};releaseDir=(t,e="resources")=>{var i=k.getBundle(e),s=i?.getDirWithPath(t);s?.map((t=>{this.releasePrefabtDepsRecursively(t.uuid)})),!t&&"resources"!=e&&i&&k.removeBundle(i)};dump=()=>{k.assets.forEach(((t,e)=>{a(k.assets.get(e))})),a(`当前资源总数:${k.assets.count}`)}}let Zt=null;const Yt={stringify:t=>{const e={ct:t.ciphertext.toString(G.enc.Base64)};return t.iv&&(e.iv=t.iv.toString()),t.salt&&(e.s=t.salt.toString()),JSON.stringify(e)},parse:t=>{const e=JSON.parse(t),i=G.lib.CipherParams.create({ciphertext:G.enc.Base64.parse(e.ct)});return e.iv&&(i.iv=G.enc.Hex.parse(e.iv)),e.s&&(i.salt=G.enc.Hex.parse(e.s)),i}};var te=Object.freeze({__proto__:null,JsonFormatter:Yt,aesDecrypt:(t,e,i)=>G.AES.decrypt(t,e,{iv:Zt,format:Yt}).toString(G.enc.Utf8),aesEncrypt:(t,e,i)=>G.AES.encrypt(t,e,{iv:Zt,format:Yt}).toString(),initCrypto:(t,e)=>{Zt=G.enc.Hex.parse(e)},md5:t=>G.MD5(t).toString()});class ee extends Y{encryptUtil=te}class ie extends K{logBlackList=[];ignore=t=>this.logBlackList.includes(t);constructor(t,e,i,s){super(e,i,s,t)}destroy(){this.disconnect(!0),de.socialGameClient.unregister(this)}async GameRequest(t,e,i,s){return new Promise(((o,n)=>{super.GameRequest(t,e,i,s).then((e=>{U&&a(`%c ws服务端消息 %c [Response][${new Date}] %c ${t} %c`,"background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#3d7daa ; padding: 1px; color: #fff","background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",$(i,e)),o(e)}),(t=>{de.gui.showToast({title:t.msg}),n(t)}))}))}subscribe(t,e,i){return super.subscribe(t,e,(s=>{U&&!this.ignore(t)&&a(`%c ws服务端消息:[${new Date}] %c ${t} %c`,"background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#410083 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",$(e,s)),de.event.emit(t,$(e,s)),i?.(s)})),this}}class se extends Y{managedClients=new Map;isGlobalOnline=!0;isInBackground=!1;get activeClients(){return Array.from(this.managedClients).map((([t,e])=>e)).filter((t=>t.socket))}constructor(t){super(t),this.initGlobalListeners()}createWebSocket(t,e,i,s){if(this.managedClients.has(t)){this.managedClients.get(t).destroy(),a(`清理旧的 ${t} 客户端`)}const o=new ie(t,i,s,Object.assign({reconnectMaxAttempts:1/0},{...e,isAutoConnect:!1}));return this.register(o),o}register(t){t.on("reconnected",this.handleSingleReconnect),this.managedClients.set(t.name,t)}unregister(t){t.off("reconnected",this.handleSingleReconnect),this.managedClients.delete(t.name)}initGlobalListeners(){this.cat.event.on(Et.ONLINE,(()=>this.handleGlobalStateChange("online")),this).on(Et.OFFLINE,(()=>this.handleGlobalStateChange("offline")),this),v.on(N.EVENT_SHOW,(()=>this.handleGlobalStateChange("show"))),v.on(N.EVENT_HIDE,(()=>this.handleGlobalStateChange("hide")))}handleGlobalStateChange(t){switch(t){case"online":this.isGlobalOnline=!0,this.triggerReconnectAll();break;case"offline":this.isGlobalOnline=!1,this.disconnectAll(!0);break;case"show":this.isInBackground=!1,this.triggerReconnectAll();break;case"hide":this.isInBackground=!0,this.disconnectAll(!0)}}async triggerReconnectAll(){if(!this.isGlobalOnline||this.isInBackground)return;if(0===this.managedClients.size)return void a("没有任何WS需要重连");de.gui.showLoading({title:"正在重连"}),await Promise.allSettled(this.activeClients.map((async t=>{try{await t.reconnectPromise()}catch(e){o(`${t.name}服重连失败`,e),de.gui.showToast({title:`${t.name}服重连失败`})}try{await t.connectRequest()}catch(e){o(`${t.name}服登录错误`,e),de.gui.showToast({title:`登录${t.name}服错误`})}})));const t=this.activeClients.filter((t=>t.socketConnectStatus!==j.CONNECTED));t.length>0&&(console.error("部分WS重连失败:",t.map((t=>t))),setTimeout((()=>{this.triggerReconnectAll()}),2e3))}disconnectAll(t){this.managedClients.forEach((e=>{a("断开连接",e.name,t,e.socket),e.disconnect(t)}))}handleSingleReconnect=()=>{this.activeClients.every((t=>t.socketConnectStatus===j.CONNECTED))&&(a("单个WS重连成功回调===",this.managedClients),de.gui.hideLoading().reloadScene())}}const{ccclass:oe,property:ne,menu:re}=i;let ae=class extends at{default_title=null;title;prompt_content_str;prompt_content_spriteFrame;btn_confirm;confirm_spriteFrame;btn_cancel;cancel_spriteFrame;btn_close;isConfirm=!1;props={title:this.default_title,content:null,confirmCB:()=>{},cancelCB:()=>{},style:null};onLoad(){this.btn_cancel.node.on(w.EventType.CLICK,this.onCancelHandler,this),this.btn_confirm.node.on(w.EventType.CLICK,this.onConfirmHandler,this),this.btn_close.node.on(w.EventType.CLICK,this.onCloseHandler,this),this.addAutorun([()=>{this.title.spriteFrame=this.props?.title||this.default_title},()=>{this.props.content instanceof M?this.prompt_content_spriteFrame.spriteFrame=this.props.content:"string"==typeof this.props.content?this.prompt_content_str.string=this.props.content:console.error("未知类型的【UIModal】内容")},()=>{null===this.props?.style?.confirm?this.btn_confirm.node.active=!1:(this.btn_confirm.node.active=!0,this.btn_confirm.getComponent(D).spriteFrame=this.props.style?.confirm||this.confirm_spriteFrame),null===this.props?.style?.cancel?this.btn_cancel.node.active=!1:(this.btn_cancel.node.active=!0,this.btn_cancel.getComponent(D).spriteFrame=this.props.style?.cancel||this.cancel_spriteFrame)}])}close(){this.props.cancelCB?.(),de.gui.closeUI(this)}onCancelHandler(){this.close()}onConfirmHandler(){this.props.confirmCB?.()}onDestroy(){this.isConfirm&&this.props.onDestroy?.()}onCloseHandler(){this.close()}};var ce;st([ne({type:M,tooltip:"默认标题"}),ot("design:type",M)],ae.prototype,"default_title",void 0),st([ne({type:D,tooltip:"标题节点"}),ot("design:type",D)],ae.prototype,"title",void 0),st([ne({type:S,tooltip:"字符串内容按钮"}),ot("design:type",S)],ae.prototype,"prompt_content_str",void 0),st([ne({type:D,tooltip:"图片精灵内容按钮"}),ot("design:type",D)],ae.prototype,"prompt_content_spriteFrame",void 0),st([ne({type:w,tooltip:"确认按钮"}),ot("design:type",w)],ae.prototype,"btn_confirm",void 0),st([ne({type:M,tooltip:"确认按钮精灵图"}),ot("design:type",M)],ae.prototype,"confirm_spriteFrame",void 0),st([ne({type:w,tooltip:"取消按钮"}),ot("design:type",w)],ae.prototype,"btn_cancel",void 0),st([ne({type:M,tooltip:"取消按钮精灵图"}),ot("design:type",M)],ae.prototype,"cancel_spriteFrame",void 0),st([ne({type:w,tooltip:"关闭按钮"}),ot("design:type",w)],ae.prototype,"btn_close",void 0),ae=st([oe("CoreUIModal"),re("CATCORE/CoreUIModal")],ae),function(t){t[t.Delay=0]="Delay",t[t.Interval=1]="Interval"}(ce||(ce={}));class le{tag;type;callback;remainingTime;executionTime=0;initialTime;constructor(t,e,i,s){this.tag=t,this.type=e,this.remainingTime=i,this.initialTime=i,this.callback=s}}class he extends Y{timers=new Map;lastUpdateTime=Date.now();constructor(t){super(t),t.event.on(Et.EVENT_HIDE,this.onHandleAppBackground,this),t.event.on(Et.EVENT_SHOW,this.onHandleAppForeground,this),setInterval(this.update.bind(this),1e3)}onHandleAppBackground(){this.lastUpdateTime=Date.now()}onHandleAppForeground(){const t=Date.now(),e=t-this.lastUpdateTime;a("elapsedTime",e);for(const t of this.timers.values())t.remainingTime>0&&(t.remainingTime-=e,t.executionTime+=e);this.lastUpdateTime=t}registerInterval(t,e,i){if(this.has(t))return o(`${t}定时器已存在,请勿重复注册`);const s=new le(t,ce.Interval,e,i);this.timers.set(t,s)}registerDelay(t,e,i){if(this.has(t))return o(`${t}延时器已存在,请勿重复注册`);const s=new le(t,ce.Delay,e,i);this.timers.set(t,s)}unregister(t){this.has(t)&&this.timers.delete(t)}has(t){return this.timers.has(t)}update(){const t=[];for(const[e,i]of this.timers.entries())i.remainingTime-=1e3,i.remainingTime<=0&&(i.type===ce.Interval&&(i.executionTime+=i.initialTime),i.callback(i.executionTime),i.type===ce.Interval?i.remainingTime=i.initialTime:t.push(e));for(const e of t)this.timers.delete(e)}}class pe{static#e;static get instance(){return this.#e||(this.#e=new pe),this.#e}onAppInitDelegate=new R;audio;event;gui;storage;res;util;socialGameClient;gui_bundle_name="";audio_local_store_key="";setConfig=({gui_bundleName:t="resources",audio_local_store_key:e="game_audio"}={})=>(this.gui_bundle_name=t,this.audio_local_store_key=e,this);async boot(){this.res=new zt,this.util=new ee(this),this.storage=new it(this),this.event=new V,this.audio=new et(this),this.socialGameClient=new se(this),this.gui=(await new qt(this).init()).gui}}const de=pe.instance;v.onPostProjectInitDelegate.add((async()=>{console.time("[Init App]"),await de.boot(),await de.onAppInitDelegate.dispatch(),console.timeEnd("[Init App]")}));export{tt as AudioEventConstant,et as AudioManager,pt as AudioSourceBaseComponent,_t as AudioSourceUILayer,ht as AudioTypeEnum,nt as BaseComponent,Y as BaseManager,Xt as BasePrefab,Jt as CoreBlackMask,Lt as CoreNotice,Rt as CoreReconnection,It as CoreShowLoading,vt as CoreToast,Tt as CoreUIContainer,ae as CoreUIModal,ee as CoreUtil,Et as GlobalEventConstant,Kt as Gui,qt as GuiManager,jt as LayerType,pe as Manager,Dt as ReconnectPrompt,wt as RootUILayer,Bt as SceneLayer,he as TimerManager,yt as ToastType,at as UILayer,ie as WrapperSocialGameClient,de as cat};
|
|
1
|
+
import t from 'text-encoding';
|
|
2
|
+
console.log('===== TextEncoding Polyfil 开始加载 ====='),
|
|
3
|
+
void 0 === globalThis.TextEncoder && ((globalThis.TextEncoder = t.TextEncoder), (globalThis.TextDecoder = t.TextDecoder)),
|
|
4
|
+
console.log('===== TextEncoding Polyfil 已加载 =====');
|
|
5
|
+
import {
|
|
6
|
+
AudioSource as e,
|
|
7
|
+
_decorator as i,
|
|
8
|
+
AudioClip as s,
|
|
9
|
+
error as o,
|
|
10
|
+
Node as n,
|
|
11
|
+
director as r,
|
|
12
|
+
log as a,
|
|
13
|
+
sys as c,
|
|
14
|
+
Component as l,
|
|
15
|
+
Prefab as h,
|
|
16
|
+
instantiate as p,
|
|
17
|
+
isValid as d,
|
|
18
|
+
Layers as u,
|
|
19
|
+
view as _,
|
|
20
|
+
Widget as m,
|
|
21
|
+
v3 as f,
|
|
22
|
+
tween as g,
|
|
23
|
+
Enum as y,
|
|
24
|
+
game as v,
|
|
25
|
+
UITransform as E,
|
|
26
|
+
UIOpacity as C,
|
|
27
|
+
Tween as b,
|
|
28
|
+
Label as S,
|
|
29
|
+
BlockInputEvents as T,
|
|
30
|
+
Button as w,
|
|
31
|
+
Director as O,
|
|
32
|
+
warn as A,
|
|
33
|
+
assetManager as k,
|
|
34
|
+
Asset as I,
|
|
35
|
+
resources as x,
|
|
36
|
+
Game as N,
|
|
37
|
+
SpriteFrame as M,
|
|
38
|
+
Sprite as D,
|
|
39
|
+
AsyncDelegate as R,
|
|
40
|
+
} from 'cc';
|
|
41
|
+
import { PREVIEW as F, DEBUG as U } from 'cc/env';
|
|
42
|
+
import { makeObservable as P, observable as L, autorun as B, reaction as H } from '@shimotsuki/mobx';
|
|
43
|
+
import G from 'crypto-es';
|
|
44
|
+
import { clone as $ } from '@bufbuild/protobuf';
|
|
45
|
+
import { SocketConnectStatus as j } from 'pitayaclient';
|
|
46
|
+
import { SocialGameClient as K } from 'sgc';
|
|
47
|
+
import { EventEmitter as V } from 'eventemitter3';
|
|
48
|
+
import 'core-js/es/array/index.js';
|
|
49
|
+
class W extends e {
|
|
50
|
+
cat;
|
|
51
|
+
initAudio(t) {
|
|
52
|
+
return (this.cat = t), this;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const { ccclass: Q, menu: J } = i;
|
|
56
|
+
class X extends W {
|
|
57
|
+
effects = new Map();
|
|
58
|
+
load(t) {
|
|
59
|
+
return new Promise((e, i) => {
|
|
60
|
+
this.cat.res.load(t, s, (s, o) => {
|
|
61
|
+
if (s) return i(s);
|
|
62
|
+
this.effects.set(t, o), this.playOneShot(o, this.volume), e(o);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
release() {
|
|
67
|
+
for (let t in this.effects) this.cat.res.release(t);
|
|
68
|
+
this.effects.clear();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const { ccclass: q, menu: z } = i;
|
|
72
|
+
class Z extends W {
|
|
73
|
+
onComplete = null;
|
|
74
|
+
_progress = 0;
|
|
75
|
+
_url = null;
|
|
76
|
+
_isPlay = !1;
|
|
77
|
+
get progress() {
|
|
78
|
+
return this.duration > 0 && (this._progress = this.currentTime / this.duration), this._progress;
|
|
79
|
+
}
|
|
80
|
+
set progress(t) {
|
|
81
|
+
(this._progress = t), (this.currentTime = t * this.duration);
|
|
82
|
+
}
|
|
83
|
+
load(t, e) {
|
|
84
|
+
this.cat.res.load(t, s, (i, s) => {
|
|
85
|
+
i && o(i),
|
|
86
|
+
this.playing && ((this._isPlay = !1), this.stop(), this.cat.res.release(this._url)),
|
|
87
|
+
(this.playOnAwake = !1),
|
|
88
|
+
(this.enabled = !0),
|
|
89
|
+
(this.clip = s),
|
|
90
|
+
(this._url = t),
|
|
91
|
+
e && e();
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
update(t) {
|
|
95
|
+
this.currentTime > 0 && (this._isPlay = !0),
|
|
96
|
+
this._isPlay && 0 == this.playing && ((this._isPlay = !1), (this.enabled = !1), this.onComplete && this.onComplete());
|
|
97
|
+
}
|
|
98
|
+
release() {
|
|
99
|
+
this._url && (this.cat.res.release(this._url), (this._url = null));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
class Y {
|
|
103
|
+
cat;
|
|
104
|
+
constructor(t) {
|
|
105
|
+
this.cat = t;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
var tt;
|
|
109
|
+
!(function (t) {
|
|
110
|
+
(t.MUSIC_ON = 'AudioEventConstant/MUSIC_ON'),
|
|
111
|
+
(t.MUSIC_OFF = 'AudioEventConstant/MUSIC_OFF'),
|
|
112
|
+
(t.EFFECT_ON = 'AudioEventConstant/EFFECT_ON'),
|
|
113
|
+
(t.EFFECT_OFF = 'AudioEventConstant/EFFECT_OFF'),
|
|
114
|
+
(t.PAUSE_AUDIO = 'AudioEventConstant/PAUSE_AUDIO'),
|
|
115
|
+
(t.RESUME_AUDIO = 'AudioEventConstant/RESUME_AUDIO');
|
|
116
|
+
})(tt || (tt = {}));
|
|
117
|
+
class et extends Y {
|
|
118
|
+
local_data = {};
|
|
119
|
+
music;
|
|
120
|
+
effect;
|
|
121
|
+
_volume_music = 1;
|
|
122
|
+
_volume_effect = 1;
|
|
123
|
+
_switch_music = !0;
|
|
124
|
+
_switch_effect = !0;
|
|
125
|
+
local_store_key = 'game_audio';
|
|
126
|
+
extra = {};
|
|
127
|
+
constructor(t) {
|
|
128
|
+
super(t), (this.local_store_key = this.cat.audio_local_store_key);
|
|
129
|
+
var e = new n('UIAudioManager');
|
|
130
|
+
r.addPersistRootNode(e);
|
|
131
|
+
var i = new n('UIMusic');
|
|
132
|
+
(i.parent = e), (this.music = i.addComponent(Z).initAudio(t));
|
|
133
|
+
var s = new n('UIEffect');
|
|
134
|
+
(s.parent = e), (this.effect = s.addComponent(X).initAudio(t)), this.load();
|
|
135
|
+
}
|
|
136
|
+
setMusicComplete(t = null) {
|
|
137
|
+
this.music.onComplete = t;
|
|
138
|
+
}
|
|
139
|
+
playMusic(t, e) {
|
|
140
|
+
(this.music.loop = !0),
|
|
141
|
+
t &&
|
|
142
|
+
this.music.load(t, () => {
|
|
143
|
+
this._switch_music && this.music?.play(), e && e();
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
stopMusic() {
|
|
147
|
+
0 != this.music.state && this.music?.stop();
|
|
148
|
+
}
|
|
149
|
+
pauseMusic() {
|
|
150
|
+
1 == this.music.state && this.music?.pause();
|
|
151
|
+
}
|
|
152
|
+
resumeMusic() {
|
|
153
|
+
[0, 2].includes(this.music.state) && this.music?.play();
|
|
154
|
+
}
|
|
155
|
+
get progressMusic() {
|
|
156
|
+
return this.music.progress;
|
|
157
|
+
}
|
|
158
|
+
set progressMusic(t) {
|
|
159
|
+
this.music.progress = t;
|
|
160
|
+
}
|
|
161
|
+
get volumeMusic() {
|
|
162
|
+
return this._volume_music;
|
|
163
|
+
}
|
|
164
|
+
set volumeMusic(t) {
|
|
165
|
+
(this._volume_music = t), (this.music.volume = t);
|
|
166
|
+
}
|
|
167
|
+
get switchMusic() {
|
|
168
|
+
return this._switch_music;
|
|
169
|
+
}
|
|
170
|
+
set switchMusic(t) {
|
|
171
|
+
if ((a('设置背景音乐开关值', t, this._switch_music), t == this._switch_music)) return;
|
|
172
|
+
(this._switch_music = t), t ? this.resumeMusic() : this.pauseMusic();
|
|
173
|
+
const e = t ? tt.MUSIC_ON : tt.MUSIC_OFF;
|
|
174
|
+
this.cat.event.emit(e), this.save();
|
|
175
|
+
}
|
|
176
|
+
async playEffect(t) {
|
|
177
|
+
this._switch_effect &&
|
|
178
|
+
t &&
|
|
179
|
+
(await this.effect.load(t).then(() => {
|
|
180
|
+
this.effect.play();
|
|
181
|
+
}));
|
|
182
|
+
}
|
|
183
|
+
stopEffect() {
|
|
184
|
+
this.effect?.stop();
|
|
185
|
+
}
|
|
186
|
+
get volumeEffect() {
|
|
187
|
+
return this._volume_effect;
|
|
188
|
+
}
|
|
189
|
+
set volumeEffect(t) {
|
|
190
|
+
(this._volume_effect = t), (this.effect.volume = t);
|
|
191
|
+
}
|
|
192
|
+
get switchEffect() {
|
|
193
|
+
return this._switch_effect;
|
|
194
|
+
}
|
|
195
|
+
set switchEffect(t) {
|
|
196
|
+
if (t == this._switch_effect) return;
|
|
197
|
+
(this._switch_effect = t), t ? this.effect?.play() : this.effect?.stop();
|
|
198
|
+
const e = t ? tt.EFFECT_ON : tt.EFFECT_OFF;
|
|
199
|
+
this.cat.event.emit(e), this.save();
|
|
200
|
+
}
|
|
201
|
+
resumeAll() {
|
|
202
|
+
this.switchMusic && this.music?.play(), this.switchEffect && this.effect?.play();
|
|
203
|
+
}
|
|
204
|
+
pauseAll() {
|
|
205
|
+
this.music?.pause(), this.effect?.pause();
|
|
206
|
+
}
|
|
207
|
+
stopAll() {
|
|
208
|
+
this.music?.stop(), this.effect?.stop();
|
|
209
|
+
}
|
|
210
|
+
save() {
|
|
211
|
+
(this.local_data.volume_music = this._volume_music),
|
|
212
|
+
(this.local_data.volume_effect = this._volume_effect),
|
|
213
|
+
(this.local_data.switch_music = this._switch_music),
|
|
214
|
+
(this.local_data.switch_effect = this._switch_effect),
|
|
215
|
+
(this.local_data.extra = this.extra);
|
|
216
|
+
let t = JSON.stringify(this.local_data);
|
|
217
|
+
return this.cat.storage.set(this.local_store_key, t), this;
|
|
218
|
+
}
|
|
219
|
+
load() {
|
|
220
|
+
try {
|
|
221
|
+
let t = this.cat.storage.get(this.local_store_key);
|
|
222
|
+
(this.local_data = JSON.parse(t)),
|
|
223
|
+
(this._volume_music = this.local_data.volume_music),
|
|
224
|
+
(this._volume_effect = this.local_data.volume_effect),
|
|
225
|
+
(this._switch_music = this.local_data.switch_music),
|
|
226
|
+
(this._switch_effect = this.local_data.switch_effect),
|
|
227
|
+
(this.extra = this.local_data.extra);
|
|
228
|
+
} catch (t) {
|
|
229
|
+
(this.local_data = {}),
|
|
230
|
+
(this._volume_music = 0.6),
|
|
231
|
+
(this._volume_effect = 1),
|
|
232
|
+
(this._switch_music = !0),
|
|
233
|
+
(this._switch_effect = !0),
|
|
234
|
+
(this.extra = {});
|
|
235
|
+
}
|
|
236
|
+
this.music && (this.music.volume = this._volume_music), this.effect && (this.effect.volume = this._volume_effect);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
class it extends Y {
|
|
240
|
+
_key = null;
|
|
241
|
+
_iv = null;
|
|
242
|
+
_id = '';
|
|
243
|
+
init(t, e) {
|
|
244
|
+
this.cat.util.encryptUtil.initCrypto(t, e), (this._key = this.cat.util.encryptUtil.md5(t)), (this._iv = this.cat.util.encryptUtil.md5(e));
|
|
245
|
+
}
|
|
246
|
+
setUser(t) {
|
|
247
|
+
this._id = t;
|
|
248
|
+
}
|
|
249
|
+
set(t, e) {
|
|
250
|
+
if (null != (t = `${t}_${this._id}`)) {
|
|
251
|
+
if ((F || (t = this.cat.util.encryptUtil.md5(t)), null == e)) return console.warn('存储的值为空,则直接移除该存储'), void this.remove(t);
|
|
252
|
+
if ('function' != typeof e) {
|
|
253
|
+
if ('object' == typeof e)
|
|
254
|
+
try {
|
|
255
|
+
e = JSON.stringify(e);
|
|
256
|
+
} catch (t) {
|
|
257
|
+
return void console.error(`解析失败,str = ${e}`);
|
|
258
|
+
}
|
|
259
|
+
else 'number' == typeof e && (e += '');
|
|
260
|
+
F || null == this._key || null == this._iv || (e = this.cat.util.encryptUtil.aesEncrypt(`${e}`, this._key, this._iv)),
|
|
261
|
+
c.localStorage.setItem(t, e);
|
|
262
|
+
} else console.error('储存的值不能为方法');
|
|
263
|
+
} else console.error('存储的key不能为空');
|
|
264
|
+
}
|
|
265
|
+
get(t, e) {
|
|
266
|
+
if (null == t) return console.error('存储的key不能为空'), null;
|
|
267
|
+
(t = `${t}_${this._id}`), F || (t = this.cat.util.encryptUtil.md5(t));
|
|
268
|
+
let i = c.localStorage.getItem(t);
|
|
269
|
+
return (
|
|
270
|
+
null == i || '' === i || F || null == this._key || null == this._iv || (i = this.cat.util.encryptUtil.aesDecrypt(i, this._key, this._iv)),
|
|
271
|
+
null === i ? e : i
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
getNumber(t, e = 0) {
|
|
275
|
+
var i = this.get(t);
|
|
276
|
+
return Number(i) || e;
|
|
277
|
+
}
|
|
278
|
+
getBoolean(t) {
|
|
279
|
+
var e = this.get(t);
|
|
280
|
+
return Boolean(e) || !1;
|
|
281
|
+
}
|
|
282
|
+
getJson(t, e) {
|
|
283
|
+
var i = this.get(t);
|
|
284
|
+
return (i && JSON.parse(i)) || e;
|
|
285
|
+
}
|
|
286
|
+
remove(t) {
|
|
287
|
+
null != t ? ((t = `${t}_${this._id}`), F || (t = this.cat.util.encryptUtil.md5(t)), c.localStorage.removeItem(t)) : console.error('存储的key不能为空');
|
|
288
|
+
}
|
|
289
|
+
clear() {
|
|
290
|
+
c.localStorage.clear();
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
function st(t, e, i, s) {
|
|
294
|
+
var o,
|
|
295
|
+
n = arguments.length,
|
|
296
|
+
r = n < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s;
|
|
297
|
+
if ('object' == typeof Reflect && 'function' == typeof Reflect.decorate) r = Reflect.decorate(t, e, i, s);
|
|
298
|
+
else for (var a = t.length - 1; a >= 0; a--) (o = t[a]) && (r = (n < 3 ? o(r) : n > 3 ? o(e, i, r) : o(e, i)) || r);
|
|
299
|
+
return n > 3 && r && Object.defineProperty(e, i, r), r;
|
|
300
|
+
}
|
|
301
|
+
function ot(t, e) {
|
|
302
|
+
if ('object' == typeof Reflect && 'function' == typeof Reflect.metadata) return Reflect.metadata(t, e);
|
|
303
|
+
}
|
|
304
|
+
'function' == typeof SuppressedError && SuppressedError;
|
|
305
|
+
class nt extends l {
|
|
306
|
+
props = {};
|
|
307
|
+
data = {};
|
|
308
|
+
autorunDisposers = [];
|
|
309
|
+
reactionDisposers = [];
|
|
310
|
+
eventEmitter = [];
|
|
311
|
+
hook = { destroyed: () => {}, started: () => {} };
|
|
312
|
+
initUI() {}
|
|
313
|
+
__preload() {
|
|
314
|
+
this.initUI(), this.onAutoObserver();
|
|
315
|
+
}
|
|
316
|
+
constructor() {
|
|
317
|
+
super(), P(this, { props: L, data: L });
|
|
318
|
+
}
|
|
319
|
+
onAutoObserver() {}
|
|
320
|
+
addAutorun(t) {
|
|
321
|
+
return (
|
|
322
|
+
(Array.isArray(t) ? t : [t]).forEach(t => {
|
|
323
|
+
const e = B(t);
|
|
324
|
+
this.autorunDisposers.push(e);
|
|
325
|
+
}),
|
|
326
|
+
this
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
addReaction(t, e, i) {
|
|
330
|
+
const s = H(t, e, i);
|
|
331
|
+
return this.reactionDisposers.push(s), this;
|
|
332
|
+
}
|
|
333
|
+
addAudoListener(t) {
|
|
334
|
+
return this.eventEmitter.includes(t) || t === de.event || this.eventEmitter.push(t), t;
|
|
335
|
+
}
|
|
336
|
+
_onPreDestroy() {
|
|
337
|
+
this.autorunDisposers.forEach(t => {
|
|
338
|
+
t();
|
|
339
|
+
}),
|
|
340
|
+
this.reactionDisposers.forEach(t => {
|
|
341
|
+
t();
|
|
342
|
+
}),
|
|
343
|
+
(this.autorunDisposers = []),
|
|
344
|
+
(this.reactionDisposers = []),
|
|
345
|
+
super._onPreDestroy();
|
|
346
|
+
}
|
|
347
|
+
onDisable() {
|
|
348
|
+
this.onHide(),
|
|
349
|
+
this.deleteAllEventByEmitter(de.event),
|
|
350
|
+
this.eventEmitter.forEach(t => {
|
|
351
|
+
this.deleteAllEventByEmitter(t);
|
|
352
|
+
}),
|
|
353
|
+
(this.eventEmitter = []),
|
|
354
|
+
this.removeListener();
|
|
355
|
+
}
|
|
356
|
+
deleteAllEventByEmitter(t) {
|
|
357
|
+
const e = t._events;
|
|
358
|
+
for (const i in e) {
|
|
359
|
+
let s = e[i];
|
|
360
|
+
Array.isArray(s) || (s = [s]),
|
|
361
|
+
s.forEach(e => {
|
|
362
|
+
e.context === this && t.off(i, e.fn, this);
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
onEnable() {
|
|
367
|
+
this.onShow(), this.addListener(), this.onEventListener();
|
|
368
|
+
}
|
|
369
|
+
onEventListener() {}
|
|
370
|
+
addListener() {}
|
|
371
|
+
removeListener() {}
|
|
372
|
+
addToParent(t, e) {
|
|
373
|
+
let i = t instanceof h ? p(t) : t instanceof l ? t.node : t;
|
|
374
|
+
return this.setOptions(e), i.addChild(this.node), this;
|
|
375
|
+
}
|
|
376
|
+
setOptions(t) {
|
|
377
|
+
if (t)
|
|
378
|
+
for (let e in t)
|
|
379
|
+
switch (e) {
|
|
380
|
+
case 'hook':
|
|
381
|
+
t.hook && (this.hook = t.hook);
|
|
382
|
+
break;
|
|
383
|
+
case 'props':
|
|
384
|
+
null !== t.props && 'object' == typeof t.props && (this.props = t.props);
|
|
385
|
+
break;
|
|
386
|
+
case 'data':
|
|
387
|
+
null !== t.data && 'object' == typeof t.data && (this.data = t.data);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
setUpdateData(t) {
|
|
391
|
+
return t && Object.assign(this.data, t), this;
|
|
392
|
+
}
|
|
393
|
+
setUpdateProps(t) {
|
|
394
|
+
return this.props, t && Object.assign(this.props, t), this;
|
|
395
|
+
}
|
|
396
|
+
removeAndDestroy() {
|
|
397
|
+
d(this?.node) && (this.node.removeFromParent(), this.node.destroy());
|
|
398
|
+
}
|
|
399
|
+
setPosition(t) {
|
|
400
|
+
return this.node.setPosition(t), this;
|
|
401
|
+
}
|
|
402
|
+
setScale(t) {
|
|
403
|
+
return this.node.setScale(t), this;
|
|
404
|
+
}
|
|
405
|
+
setAngle(t) {
|
|
406
|
+
return (this.node.angle = t), this;
|
|
407
|
+
}
|
|
408
|
+
setRotation(t) {
|
|
409
|
+
return this.node.setRotation(t), this;
|
|
410
|
+
}
|
|
411
|
+
setRotationFromEuler(t) {
|
|
412
|
+
return this.node.setRotationFromEuler(t), this;
|
|
413
|
+
}
|
|
414
|
+
onShow() {}
|
|
415
|
+
onHide() {}
|
|
416
|
+
setNodeAndChildrenLayer(t) {
|
|
417
|
+
return rt(this.node, t), this;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
const rt = (t, e) => {
|
|
421
|
+
(t.layer = 'string' == typeof e ? 2 ** u.nameToLayer(e) : e),
|
|
422
|
+
t?.children.forEach(t => {
|
|
423
|
+
rt(t, e);
|
|
424
|
+
});
|
|
425
|
+
};
|
|
426
|
+
class at extends nt {
|
|
427
|
+
lastEnterDirection = 'center';
|
|
428
|
+
screen;
|
|
429
|
+
isClosing = !1;
|
|
430
|
+
root;
|
|
431
|
+
constructor() {
|
|
432
|
+
super(), this._init();
|
|
433
|
+
}
|
|
434
|
+
_init() {
|
|
435
|
+
(this.root = this.node), (this.screen = _.getVisibleSize());
|
|
436
|
+
}
|
|
437
|
+
async showTween({ isMotion: t = !0, direction: e = 'center', duration: i = 0.1, isBounce: s = !0, bounceDuration: o = 0.05 }) {
|
|
438
|
+
if (((this.lastEnterDirection = e), t)) {
|
|
439
|
+
const t = this.node.getComponent(m);
|
|
440
|
+
let o, n;
|
|
441
|
+
t && (t.updateAlignment(), (t.enabled = !1)),
|
|
442
|
+
f(1.1, 1.1, 1),
|
|
443
|
+
'center' == e
|
|
444
|
+
? ((o = f(0.01, 0.01, 0.01)), (n = f(1, 1, 1)))
|
|
445
|
+
: ((o =
|
|
446
|
+
'left' == e
|
|
447
|
+
? f(-this.screen.width, 0, 0)
|
|
448
|
+
: 'right' == e
|
|
449
|
+
? f(this.screen.width, 0, 0)
|
|
450
|
+
: f(0, 'top' == e ? this.screen.height : -this.screen.height, 0)),
|
|
451
|
+
(n = f(0, 0, 0))),
|
|
452
|
+
await this.handle(e, i, o, n, s),
|
|
453
|
+
t && (t.enabled = !0);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
async hideTween({ isMotion: t = !0, direction: e, duration: i = 0.1 }) {
|
|
457
|
+
if (((e = e || this.lastEnterDirection), !this.isClosing)) {
|
|
458
|
+
if (((this.isClosing = !0), g(this.node).removeSelf(), t)) {
|
|
459
|
+
const t = this.node.getComponent(m);
|
|
460
|
+
let s, o;
|
|
461
|
+
t && (t.enabled = !1),
|
|
462
|
+
'center' == e
|
|
463
|
+
? ((s = this.node.scale), (o = f(0, 0, 0)))
|
|
464
|
+
: ((o =
|
|
465
|
+
'left' == e
|
|
466
|
+
? f(-this.screen.width, 0, 0)
|
|
467
|
+
: 'right' == e
|
|
468
|
+
? f(this.screen.width, 0, 0)
|
|
469
|
+
: f(0, 'top' == e ? this.screen.height : -this.screen.height, 0)),
|
|
470
|
+
(s = this.node.getPosition())),
|
|
471
|
+
await this.handle(e, i, s, o, !1);
|
|
472
|
+
}
|
|
473
|
+
this.removeAndDestroy();
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
async handle(t, e, i, s, o) {
|
|
477
|
+
'center' == t ? this.node.setScale(i) : this.node.setPosition(i), await this.deftween(e, { ['center' == t ? 'scale' : 'position']: s }, o);
|
|
478
|
+
}
|
|
479
|
+
deftween(t, e, i, s) {
|
|
480
|
+
return new Promise((i, s) => {
|
|
481
|
+
g(this.node)
|
|
482
|
+
.to(t, e)
|
|
483
|
+
.call(() => {
|
|
484
|
+
i();
|
|
485
|
+
})
|
|
486
|
+
.start();
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
const { ccclass: ct, property: lt } = i;
|
|
491
|
+
var ht;
|
|
492
|
+
!(function (t) {
|
|
493
|
+
(t[(t.EFFECT = 0)] = 'EFFECT'), (t[(t.BGM = 1)] = 'BGM');
|
|
494
|
+
})(ht || (ht = {}));
|
|
495
|
+
class pt extends nt {
|
|
496
|
+
type = ht.EFFECT;
|
|
497
|
+
clip = null;
|
|
498
|
+
loop = !1;
|
|
499
|
+
volume = 1;
|
|
500
|
+
playOnAwake = !1;
|
|
501
|
+
audioSource = new e();
|
|
502
|
+
onEnable() {
|
|
503
|
+
super.onEnable(),
|
|
504
|
+
this.clip && (this.audioSource.clip = this.clip),
|
|
505
|
+
(this.audioSource.loop = this.loop),
|
|
506
|
+
(this.audioSource.volume = this.volume),
|
|
507
|
+
(this.audioSource.playOnAwake = this.playOnAwake),
|
|
508
|
+
de.event
|
|
509
|
+
.on(tt.EFFECT_ON, this.onPlayEffectHandler, this)
|
|
510
|
+
.on(tt.EFFECT_OFF, this.onStopEffectHandler, this)
|
|
511
|
+
.on(tt.MUSIC_ON, this.onPlayMusicHandler, this)
|
|
512
|
+
.on(tt.MUSIC_OFF, this.onStopMusicHandler, this);
|
|
513
|
+
}
|
|
514
|
+
__preload() {
|
|
515
|
+
super.__preload();
|
|
516
|
+
const { volumeEffect: t, volumeMusic: e } = de.audio;
|
|
517
|
+
this.audioSource.volume = this.type === ht.BGM ? e : t;
|
|
518
|
+
}
|
|
519
|
+
start() {}
|
|
520
|
+
stopAudio() {
|
|
521
|
+
this.audioSource.stop();
|
|
522
|
+
}
|
|
523
|
+
playAudio() {
|
|
524
|
+
const { switchEffect: t, switchMusic: e } = de.audio;
|
|
525
|
+
this.audioSource.playing || !(this.type === ht.BGM ? e : t) || v._paused || this.audioSource.play();
|
|
526
|
+
}
|
|
527
|
+
onPlayEffectHandler() {}
|
|
528
|
+
onStopEffectHandler() {
|
|
529
|
+
this.stopAudio();
|
|
530
|
+
}
|
|
531
|
+
onPlayMusicHandler() {}
|
|
532
|
+
onStopMusicHandler() {
|
|
533
|
+
this.stopAudio();
|
|
534
|
+
}
|
|
535
|
+
_onPreDestroy() {
|
|
536
|
+
this.onStopMusicHandler(), super._onPreDestroy();
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
st([lt({ tooltip: '类型:\n EFFECT 音效\n BGM 音乐', type: y(ht) }), ot('design:type', Object)], pt.prototype, 'type', void 0),
|
|
540
|
+
st([lt({ tooltip: '音源', type: s }), ot('design:type', Object)], pt.prototype, 'clip', void 0),
|
|
541
|
+
st([lt({ tooltip: '循环' }), ot('design:type', Object)], pt.prototype, 'loop', void 0),
|
|
542
|
+
st([lt({ tooltip: '音量' }), ot('design:type', Object)], pt.prototype, 'volume', void 0),
|
|
543
|
+
st([lt({ tooltip: '是否启用自动播放' }), ot('design:type', Object)], pt.prototype, 'playOnAwake', void 0);
|
|
544
|
+
const { ccclass: dt, property: ut } = i;
|
|
545
|
+
class _t extends at {
|
|
546
|
+
type = ht.EFFECT;
|
|
547
|
+
clip = null;
|
|
548
|
+
loop = !1;
|
|
549
|
+
volume = 1;
|
|
550
|
+
playOnAwake = !1;
|
|
551
|
+
audioSource = new e();
|
|
552
|
+
onEnable() {
|
|
553
|
+
super.onEnable(),
|
|
554
|
+
de.event
|
|
555
|
+
.on(tt.EFFECT_ON, this.onPlayEffectHandler, this)
|
|
556
|
+
.on(tt.EFFECT_OFF, this.onStopEffectHandler, this)
|
|
557
|
+
.on(tt.MUSIC_ON, this.onPlayMusicHandler, this)
|
|
558
|
+
.on(tt.MUSIC_OFF, this.onStopMusicHandler, this);
|
|
559
|
+
}
|
|
560
|
+
__preload() {
|
|
561
|
+
this.clip && (this.audioSource.clip = this.clip),
|
|
562
|
+
(this.audioSource.loop = this.loop),
|
|
563
|
+
(this.audioSource.volume = this.volume),
|
|
564
|
+
(this.audioSource.playOnAwake = this.playOnAwake),
|
|
565
|
+
super.__preload();
|
|
566
|
+
const { volumeEffect: t, volumeMusic: e } = de.audio;
|
|
567
|
+
this.audioSource.volume = this.type === ht.BGM ? e : t;
|
|
568
|
+
}
|
|
569
|
+
stopAudio() {
|
|
570
|
+
this.audioSource.stop();
|
|
571
|
+
}
|
|
572
|
+
playAudio() {
|
|
573
|
+
const { switchEffect: t, switchMusic: e } = de.audio;
|
|
574
|
+
this.audioSource.playing || !(this.type === ht.BGM ? e : t) || v._paused || this.audioSource.play();
|
|
575
|
+
}
|
|
576
|
+
onPlayEffectHandler() {}
|
|
577
|
+
onStopEffectHandler() {
|
|
578
|
+
this.stopAudio();
|
|
579
|
+
}
|
|
580
|
+
onPlayMusicHandler() {}
|
|
581
|
+
onStopMusicHandler() {
|
|
582
|
+
this.stopAudio();
|
|
583
|
+
}
|
|
584
|
+
_onPreDestroy() {
|
|
585
|
+
this.onStopMusicHandler(), super._onPreDestroy();
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
st([ut({ tooltip: '类型:\n EFFECT 音效\n BGM 音乐', type: y(ht) }), ot('design:type', Object)], _t.prototype, 'type', void 0),
|
|
589
|
+
st([ut({ tooltip: '音源', type: s }), ot('design:type', Object)], _t.prototype, 'clip', void 0),
|
|
590
|
+
st([ut({ tooltip: '循环' }), ot('design:type', Object)], _t.prototype, 'loop', void 0),
|
|
591
|
+
st([ut({ tooltip: '音量' }), ot('design:type', Object)], _t.prototype, 'volume', void 0),
|
|
592
|
+
st([ut({ tooltip: '是否启用自动播放' }), ot('design:type', Object)], _t.prototype, 'playOnAwake', void 0);
|
|
593
|
+
const { ccclass: mt, property: ft, menu: gt } = i;
|
|
594
|
+
var yt;
|
|
595
|
+
!(function (t) {
|
|
596
|
+
(t[(t.FIXED = 0)] = 'FIXED'), (t[(t.SLIDE = 1)] = 'SLIDE');
|
|
597
|
+
})(yt || (yt = {}));
|
|
598
|
+
let vt = class extends nt {
|
|
599
|
+
fixed_node;
|
|
600
|
+
slide_node;
|
|
601
|
+
fixed_label;
|
|
602
|
+
slide_label;
|
|
603
|
+
onLoad() {
|
|
604
|
+
this.fixed_node.active = this.slide_node.active = !1;
|
|
605
|
+
}
|
|
606
|
+
start() {
|
|
607
|
+
this.show();
|
|
608
|
+
}
|
|
609
|
+
async show() {
|
|
610
|
+
return new Promise(async (t, e) => {
|
|
611
|
+
const { title: i, type: s, fixed_time: o } = this.props;
|
|
612
|
+
if (s == yt.FIXED) {
|
|
613
|
+
(this.fixed_node.active = !0), (this.fixed_label.string = `${i}`), this.fixed_label.updateRenderData(!0);
|
|
614
|
+
const e = this.fixed_label.node.getComponent(E).height;
|
|
615
|
+
e - this.fixed_node.getComponent(E).height > 0 && (this.fixed_node.getComponent(E).height = e + 100),
|
|
616
|
+
this.scheduleOnce(() => {
|
|
617
|
+
this.node.destroy(), t();
|
|
618
|
+
}, o);
|
|
619
|
+
} else {
|
|
620
|
+
(this.slide_node.active = !0), (this.slide_label.string = `${i}`), this.slide_label.updateRenderData(!0);
|
|
621
|
+
const e = this.slide_label.node.getComponent(E).width;
|
|
622
|
+
this.slide_node.getComponent(E).width - e < 100 && (this.slide_node.getComponent(E).width = e + 100),
|
|
623
|
+
this.playAnim(this.node).then(() => {
|
|
624
|
+
t();
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
playAnim(t) {
|
|
630
|
+
return new Promise((e, i) => {
|
|
631
|
+
const s = this.node.getComponent(C),
|
|
632
|
+
o = g(s)
|
|
633
|
+
.delay(1.2)
|
|
634
|
+
.to(0.5, { opacity: 0 })
|
|
635
|
+
.call(() => {
|
|
636
|
+
b.stopAllByTarget(t), this.node.destroy(), e();
|
|
637
|
+
});
|
|
638
|
+
g(t)
|
|
639
|
+
.by(0.5, { position: f(0, 400, 0) })
|
|
640
|
+
.call(() => {
|
|
641
|
+
o.start();
|
|
642
|
+
})
|
|
643
|
+
.start();
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
onDestroy() {
|
|
647
|
+
b.stopAllByTarget(this.node), this.unscheduleAllCallbacks();
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
var Et;
|
|
651
|
+
st([ft({ type: n, tooltip: '固定节点' }), ot('design:type', n)], vt.prototype, 'fixed_node', void 0),
|
|
652
|
+
st([ft({ type: n, tooltip: '滑动节点' }), ot('design:type', n)], vt.prototype, 'slide_node', void 0),
|
|
653
|
+
st([ft({ type: S, tooltip: '固定标签节点' }), ot('design:type', S)], vt.prototype, 'fixed_label', void 0),
|
|
654
|
+
st([ft({ type: S, tooltip: '滑动标签节点' }), ot('design:type', S)], vt.prototype, 'slide_label', void 0),
|
|
655
|
+
(vt = st([mt('CoreToast'), gt('CATCORE/CoreToast')], vt)),
|
|
656
|
+
(function (t) {
|
|
657
|
+
(t.EVENT_SHOW = 'GlobalEventConstant/EVENT_SHOW'),
|
|
658
|
+
(t.EVENT_HIDE = 'GlobalEventConstant/EVENT_HIDE'),
|
|
659
|
+
(t.GAME_RESIZE = 'GlobalEventConstant/GAME_RESIZE'),
|
|
660
|
+
(t.EVENT_CLOSE = 'GlobalEventConstant/EVENT_CLOSE'),
|
|
661
|
+
(t.ONLINE = 'GlobalEventConstant/ONLINE'),
|
|
662
|
+
(t.OFFLINE = 'GlobalEventConstant/OFFLINE'),
|
|
663
|
+
(t.ROOT_MASK_UPDATE = 'GlobalEventConstant/ROOT_MASK_UPDATE'),
|
|
664
|
+
(t.ROOT_MASK_CHANGE = 'GlobalEventConstant/ROOT_MASK_CHANGE');
|
|
665
|
+
})(Et || (Et = {}));
|
|
666
|
+
const { ccclass: Ct, property: bt, menu: St } = i;
|
|
667
|
+
let Tt = class extends at {
|
|
668
|
+
scene_mask_node;
|
|
669
|
+
ui_container;
|
|
670
|
+
gui = null;
|
|
671
|
+
onLoad() {
|
|
672
|
+
this.setSceneMaskActive(!1);
|
|
673
|
+
}
|
|
674
|
+
get scene_mask() {
|
|
675
|
+
return this.scene_mask_node.getComponent(Jt);
|
|
676
|
+
}
|
|
677
|
+
get brother() {
|
|
678
|
+
return this.ui_container.children || [];
|
|
679
|
+
}
|
|
680
|
+
get tweenChildren() {
|
|
681
|
+
return this.scene_mask.tween.children;
|
|
682
|
+
}
|
|
683
|
+
onEventListener() {
|
|
684
|
+
de.event.on(Et.ROOT_MASK_CHANGE, this.uiMaskChanged, this);
|
|
685
|
+
}
|
|
686
|
+
addMask() {
|
|
687
|
+
const t = this.brother[this.brother.length - 1];
|
|
688
|
+
t && this.scene_mask.node.setSiblingIndex(t.getSiblingIndex()), this.blockMaskSiblingIndexChanged();
|
|
689
|
+
}
|
|
690
|
+
subMask() {
|
|
691
|
+
const t = this.brother[this.brother.length - 2];
|
|
692
|
+
t && this.scene_mask.node.setSiblingIndex(t.getSiblingIndex()), this.blockMaskSiblingIndexChanged();
|
|
693
|
+
}
|
|
694
|
+
blockMaskSiblingIndexChanged() {
|
|
695
|
+
this.tweenChildren.length > 1 || this.brother.length > 1 ? this.show() : this.hide();
|
|
696
|
+
}
|
|
697
|
+
addNodeToTween(t) {
|
|
698
|
+
return d(this) && this.scene_mask && this.scene_mask.tween.addChild(t), this;
|
|
699
|
+
}
|
|
700
|
+
show() {
|
|
701
|
+
this.setSceneMaskActive(!0);
|
|
702
|
+
}
|
|
703
|
+
hide() {
|
|
704
|
+
this.setSceneMaskActive(!1);
|
|
705
|
+
}
|
|
706
|
+
setGui(t) {
|
|
707
|
+
return (this.gui = t), this;
|
|
708
|
+
}
|
|
709
|
+
uiMaskChanged() {
|
|
710
|
+
this.blockMaskSiblingIndexChanged();
|
|
711
|
+
}
|
|
712
|
+
setSceneMaskActive(t) {
|
|
713
|
+
this.scene_mask.node.active = t;
|
|
714
|
+
}
|
|
715
|
+
};
|
|
716
|
+
st([bt({ type: n }), ot('design:type', n)], Tt.prototype, 'scene_mask_node', void 0),
|
|
717
|
+
st([bt({ type: n }), ot('design:type', n)], Tt.prototype, 'ui_container', void 0),
|
|
718
|
+
(Tt = st([Ct('CoreUIContainer'), St('CATCORE/CoreUIContainer')], Tt));
|
|
719
|
+
class wt extends at {
|
|
720
|
+
onEnable() {
|
|
721
|
+
super.onEnable(), this.updateMask();
|
|
722
|
+
}
|
|
723
|
+
onDisable() {
|
|
724
|
+
super.onDisable(), this.updateMask();
|
|
725
|
+
}
|
|
726
|
+
updateMask() {
|
|
727
|
+
de.event.emit(Et.ROOT_MASK_UPDATE);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
const { ccclass: Ot, property: At, menu: kt } = i;
|
|
731
|
+
let It = class extends wt {
|
|
732
|
+
title;
|
|
733
|
+
loadingTween;
|
|
734
|
+
loading_rotate = 0;
|
|
735
|
+
onAutoObserver() {
|
|
736
|
+
this.addAutorun([
|
|
737
|
+
() => {
|
|
738
|
+
this.props?.title && (this.title.string = `${this.props?.title}`), (this.title.node.active = !!this.props?.title?.length);
|
|
739
|
+
},
|
|
740
|
+
() => {
|
|
741
|
+
this.getComponent(T).enabled = !!this.props?.mask;
|
|
742
|
+
},
|
|
743
|
+
]);
|
|
744
|
+
}
|
|
745
|
+
update(t) {
|
|
746
|
+
(this.loading_rotate += 220 * t),
|
|
747
|
+
this.loadingTween.setRotationFromEuler(0, 0, -this.loading_rotate % 360),
|
|
748
|
+
this.loading_rotate > 360 && (this.loading_rotate -= 360);
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
st([At({ type: S, tooltip: '标题' }), ot('design:type', S)], It.prototype, 'title', void 0),
|
|
752
|
+
st([At({ type: n, tooltip: '动画' }), ot('design:type', n)], It.prototype, 'loadingTween', void 0),
|
|
753
|
+
(It = st([Ot('CoreShowLoading'), kt('CATCORE/CoreShowLoading')], It));
|
|
754
|
+
const { ccclass: xt, property: Nt, menu: Mt } = i;
|
|
755
|
+
var Dt;
|
|
756
|
+
!(function (t) {
|
|
757
|
+
(t.RECONNECTED = '重连成功'),
|
|
758
|
+
(t.RECONNECTING = '正在重连'),
|
|
759
|
+
(t.MAX_RECONNECT = '重连次数超出限制,请检查网络'),
|
|
760
|
+
(t.RECONNECTED_ERROR = '重连失败,请检查网络'),
|
|
761
|
+
(t.CONNECT_PARAM_ERROR = '游戏参数错误,请重新加载'),
|
|
762
|
+
(t.KICK = '账号已下线'),
|
|
763
|
+
(t.OFFLINE = '网络已断开'),
|
|
764
|
+
(t.ONLINE = '网络已连接'),
|
|
765
|
+
(t.GAME_ERROR = '连接游戏服错误');
|
|
766
|
+
})(Dt || (Dt = {}));
|
|
767
|
+
let Rt = class extends wt {
|
|
768
|
+
common_prompt_text;
|
|
769
|
+
btn_confirm;
|
|
770
|
+
is_close = !1;
|
|
771
|
+
props = { content: null };
|
|
772
|
+
initUI() {
|
|
773
|
+
this.btn_confirm.node.active = !1;
|
|
774
|
+
}
|
|
775
|
+
onLoad() {
|
|
776
|
+
this.btn_confirm.node.on(w.EventType.CLICK, this.onConfirmHandler, this),
|
|
777
|
+
this.addAutorun([
|
|
778
|
+
() => {
|
|
779
|
+
this.common_prompt_text.string = this.props.content ?? '';
|
|
780
|
+
},
|
|
781
|
+
]);
|
|
782
|
+
}
|
|
783
|
+
onDestroy() {
|
|
784
|
+
this.unscheduleAllCallbacks();
|
|
785
|
+
}
|
|
786
|
+
updateProps(t) {
|
|
787
|
+
this.updatePromptText(t, t == Dt.RECONNECTING);
|
|
788
|
+
}
|
|
789
|
+
updatePromptText(t, e = !1) {
|
|
790
|
+
if ((this.unscheduleAllCallbacks(), (this.props.content = t), a('更新提示文案:', t), e)) {
|
|
791
|
+
let e = 0;
|
|
792
|
+
const i = () => {
|
|
793
|
+
(e = (e + 1) % 4), (this.common_prompt_text.string = t + ['', '·', '··', '···'][e]);
|
|
794
|
+
};
|
|
795
|
+
this.schedule(i, 0.5);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
onConfirmHandler() {
|
|
799
|
+
(this.is_close = !0), de.gui.hideReconnect();
|
|
800
|
+
}
|
|
801
|
+
};
|
|
802
|
+
st([Nt({ type: S, tooltip: '通用提示文本' }), ot('design:type', S)], Rt.prototype, 'common_prompt_text', void 0),
|
|
803
|
+
st([Nt({ type: w, tooltip: '确定按钮' }), ot('design:type', w)], Rt.prototype, 'btn_confirm', void 0),
|
|
804
|
+
(Rt = st([xt('CoreReconnection'), Mt('CATCORE/CoreReconnection')], Rt));
|
|
805
|
+
const { ccclass: Ft, property: Ut, menu: Pt } = i;
|
|
806
|
+
let Lt = class extends wt {
|
|
807
|
+
text;
|
|
808
|
+
btn_confirm;
|
|
809
|
+
onLoad() {
|
|
810
|
+
this.btn_confirm.node.on(w.EventType.CLICK, this.onConfrimHandler, this);
|
|
811
|
+
}
|
|
812
|
+
start() {
|
|
813
|
+
this.props && this.updateProps(this.props);
|
|
814
|
+
}
|
|
815
|
+
onConfrimHandler() {
|
|
816
|
+
this.props?.confrim?.(), de.gui.hideNotice();
|
|
817
|
+
}
|
|
818
|
+
updateProps(t) {
|
|
819
|
+
this.text.string = `${t.text}`;
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
st([Ut({ type: S, tooltip: '提示文本' }), ot('design:type', S)], Lt.prototype, 'text', void 0),
|
|
823
|
+
st([Ut({ type: w, tooltip: '确定按钮' }), ot('design:type', w)], Lt.prototype, 'btn_confirm', void 0),
|
|
824
|
+
(Lt = st([Ft('CoreNotice'), Pt('CATCORE/CoreNotice')], Lt));
|
|
825
|
+
class Bt extends nt {
|
|
826
|
+
isReload;
|
|
827
|
+
}
|
|
828
|
+
const { ccclass: Ht, property: Gt, menu: $t } = i;
|
|
829
|
+
var jt;
|
|
830
|
+
!(function (t) {
|
|
831
|
+
(t[(t.UI = 0)] = 'UI'),
|
|
832
|
+
(t[(t.LOADING = 1)] = 'LOADING'),
|
|
833
|
+
(t[(t.TOAST = 2)] = 'TOAST'),
|
|
834
|
+
(t[(t.RECONNECTTION = 3)] = 'RECONNECTTION'),
|
|
835
|
+
(t[(t.NOTICE = 4)] = 'NOTICE');
|
|
836
|
+
})(jt || (jt = {}));
|
|
837
|
+
let Kt = class extends nt {
|
|
838
|
+
reconnection_ui_prefab;
|
|
839
|
+
toast_ui_prefab;
|
|
840
|
+
loading_ui_prefab;
|
|
841
|
+
notice_ui_prefab;
|
|
842
|
+
ui_prefab;
|
|
843
|
+
root_ui;
|
|
844
|
+
root_toast;
|
|
845
|
+
root_mask;
|
|
846
|
+
cat;
|
|
847
|
+
ui_container_component;
|
|
848
|
+
reconnection_ui_component;
|
|
849
|
+
notice_ui_component;
|
|
850
|
+
loading_ui_component;
|
|
851
|
+
toast_ui_component;
|
|
852
|
+
currentScene;
|
|
853
|
+
onEventListener() {
|
|
854
|
+
this.cat.event.on(Et.ROOT_MASK_UPDATE, this.onRootUpdate, this);
|
|
855
|
+
}
|
|
856
|
+
init(t) {
|
|
857
|
+
this.cat = t;
|
|
858
|
+
const e = r.getScene();
|
|
859
|
+
return a('init scene'), e && this.changeScene(e), this;
|
|
860
|
+
}
|
|
861
|
+
start() {
|
|
862
|
+
this.onRootUpdate();
|
|
863
|
+
}
|
|
864
|
+
toastQueue = [];
|
|
865
|
+
isScheduling = !1;
|
|
866
|
+
minInterval = 0.2;
|
|
867
|
+
showToast(t) {
|
|
868
|
+
this.toastQueue.push(t), this.isScheduling || this.processQueueWithInterval();
|
|
869
|
+
}
|
|
870
|
+
processQueueWithInterval() {
|
|
871
|
+
if (0 === this.toastQueue.length) return void (this.isScheduling = !1);
|
|
872
|
+
this.isScheduling = !0;
|
|
873
|
+
const t = this.toastQueue.shift(),
|
|
874
|
+
e = () => {
|
|
875
|
+
p(this.toast_ui_prefab).getComponent(vt).addToParent(this.root_toast, { props: t }),
|
|
876
|
+
this.scheduleOnce(() => {
|
|
877
|
+
this.processQueueWithInterval();
|
|
878
|
+
}, this.minInterval);
|
|
879
|
+
};
|
|
880
|
+
0 === this.root_toast.children.length ? e() : this.scheduleOnce(e, this.minInterval);
|
|
881
|
+
}
|
|
882
|
+
hideToast() {
|
|
883
|
+
return (
|
|
884
|
+
this.root_toast &&
|
|
885
|
+
this.root_toast.children.forEach(t => {
|
|
886
|
+
t.getComponent(vt)?.removeAndDestroy();
|
|
887
|
+
}),
|
|
888
|
+
(this.toastQueue = []),
|
|
889
|
+
this.unschedule(this.processQueueWithInterval),
|
|
890
|
+
(this.isScheduling = !1),
|
|
891
|
+
this
|
|
892
|
+
);
|
|
893
|
+
}
|
|
894
|
+
showLoading({ title: t = '', mask: e = !0, black: i = !0 } = {}) {
|
|
895
|
+
if ((a('showLoading', t), this.loading_ui_component)) this.loading_ui_component.setOptions({ props: { title: t, mask: e, black: i } });
|
|
896
|
+
else {
|
|
897
|
+
const s = p(this.loading_ui_prefab);
|
|
898
|
+
this.loading_ui_component = s.getComponent(It).addToParent(this.root_ui, { props: { title: t, mask: e, black: i } });
|
|
899
|
+
}
|
|
900
|
+
return this;
|
|
901
|
+
}
|
|
902
|
+
hideLoading() {
|
|
903
|
+
return this.loading_ui_component?.removeAndDestroy(), (this.loading_ui_component = null), this;
|
|
904
|
+
}
|
|
905
|
+
showReconnect(t) {
|
|
906
|
+
if (this.reconnection_ui_component) this.reconnection_ui_component.setUpdateProps({ content: t });
|
|
907
|
+
else {
|
|
908
|
+
const e = p(this.reconnection_ui_prefab);
|
|
909
|
+
this.reconnection_ui_component = e.getComponent(Rt).addToParent(this.root_ui, { props: { content: t } });
|
|
910
|
+
}
|
|
911
|
+
return this;
|
|
912
|
+
}
|
|
913
|
+
hideReconnect() {
|
|
914
|
+
return this.reconnection_ui_component?.removeAndDestroy(), (this.reconnection_ui_component = null), this;
|
|
915
|
+
}
|
|
916
|
+
showNotice(t) {
|
|
917
|
+
const e = p(this.notice_ui_prefab);
|
|
918
|
+
return (this.notice_ui_component = e.getComponent(Lt).addToParent(this.root_ui, { props: t })), this;
|
|
919
|
+
}
|
|
920
|
+
hideNotice() {
|
|
921
|
+
return this.notice_ui_component?.removeAndDestroy(), this;
|
|
922
|
+
}
|
|
923
|
+
loadScene(t, e, i) {
|
|
924
|
+
a('加载场景', t, e, i);
|
|
925
|
+
let s = {},
|
|
926
|
+
o = i ?? !1;
|
|
927
|
+
return (
|
|
928
|
+
'boolean' == typeof e ? (o = e) : (s = e ?? {}),
|
|
929
|
+
a('当前场景', r.getScene()?.uuid, r.getScene()?.name),
|
|
930
|
+
r.once(O.EVENT_BEFORE_SCENE_LAUNCH, t => {
|
|
931
|
+
a('Director.EVENT_BEFORE_SCENE_LAUNCH', t), this.changeScene(t, s, o);
|
|
932
|
+
}),
|
|
933
|
+
r.loadScene(t),
|
|
934
|
+
this
|
|
935
|
+
);
|
|
936
|
+
}
|
|
937
|
+
resetScene(t = '') {
|
|
938
|
+
return (t = t || this.currentScene), this.loadScene(t);
|
|
939
|
+
}
|
|
940
|
+
cleanScene() {
|
|
941
|
+
this.resetScene().hideLoading().hideNotice().hideReconnect().hideToast();
|
|
942
|
+
}
|
|
943
|
+
changeScene(t, e, i) {
|
|
944
|
+
(this.currentScene = t.name), this.createUILayer(t);
|
|
945
|
+
const s = t.getComponentInChildren(Bt);
|
|
946
|
+
s && (s.isReload = i ?? !1), s?.setOptions(e);
|
|
947
|
+
}
|
|
948
|
+
createUILayer(t) {
|
|
949
|
+
this.ui_container_component?.removeAndDestroy(), (this.ui_container_component = null);
|
|
950
|
+
const e = p(this.ui_prefab);
|
|
951
|
+
this.ui_container_component = e.getComponent(Tt).setGui(this).addToParent(t);
|
|
952
|
+
}
|
|
953
|
+
reloadScene() {
|
|
954
|
+
this.loadScene(this.currentScene, !0);
|
|
955
|
+
}
|
|
956
|
+
async closeUI(t, e) {
|
|
957
|
+
const { component: i } = this.findUIBaseLayer(t, !1);
|
|
958
|
+
i && (i.setOptions({ ...(e?.hook ?? {}), ...(e?.props ?? {}) }), await i.hideTween(e || {}), this.ui_container_component?.subMask());
|
|
959
|
+
}
|
|
960
|
+
async openUI(t, e) {
|
|
961
|
+
const { rootNode: i, component: s } = this.findUIBaseLayer(t, !0);
|
|
962
|
+
i.getComponent(at),
|
|
963
|
+
s?.setOptions(e),
|
|
964
|
+
i && this.ui_container_component?.addNodeToTween(i).addMask(),
|
|
965
|
+
s && (await s.showTween(e || {})),
|
|
966
|
+
this.ui_container_component?.ui_container && s?.addToParent(this.ui_container_component.ui_container);
|
|
967
|
+
}
|
|
968
|
+
findUIBaseLayer(t, e) {
|
|
969
|
+
let i,
|
|
970
|
+
s = null;
|
|
971
|
+
if (t instanceof n) {
|
|
972
|
+
i = t;
|
|
973
|
+
const e = t.components.filter(t => t instanceof at);
|
|
974
|
+
if (!e.length) return o(`${t.name}节点未找到继承自BaseLayer的组件`), { rootNode: i, component: s };
|
|
975
|
+
1 == e.length ? (s = e[0]) : A(`${t.name}节点存在多个继承自BaseLayer的组件`);
|
|
976
|
+
} else if (((i = t.node), (s = t), e)) {
|
|
977
|
+
for (; i.parent; ) i = i.parent;
|
|
978
|
+
s.root = i;
|
|
979
|
+
} else i = t.root;
|
|
980
|
+
return { rootNode: i, component: s };
|
|
981
|
+
}
|
|
982
|
+
onRootUpdate() {
|
|
983
|
+
const t = this.root_ui.children.findLastIndex(t => t.active && t != this.root_mask);
|
|
984
|
+
if (((this.root_mask.active = -1 != t), t > -1)) {
|
|
985
|
+
const e = this.root_ui.children[t];
|
|
986
|
+
this.root_mask.setSiblingIndex(e.getSiblingIndex() - 1);
|
|
987
|
+
}
|
|
988
|
+
this.cat.event.emit(Et.ROOT_MASK_CHANGE);
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
st([Gt({ type: h, tooltip: '断线重连UI预制体' }), ot('design:type', h)], Kt.prototype, 'reconnection_ui_prefab', void 0),
|
|
992
|
+
st([Gt({ type: h, tooltip: '提示UI预制体' }), ot('design:type', h)], Kt.prototype, 'toast_ui_prefab', void 0),
|
|
993
|
+
st([Gt({ type: h, tooltip: '加载UI预制体' }), ot('design:type', h)], Kt.prototype, 'loading_ui_prefab', void 0),
|
|
994
|
+
st([Gt({ type: h, tooltip: '公告UI预制体' }), ot('design:type', h)], Kt.prototype, 'notice_ui_prefab', void 0),
|
|
995
|
+
st([Gt({ type: h, tooltip: 'UI层预制体' }), ot('design:type', h)], Kt.prototype, 'ui_prefab', void 0),
|
|
996
|
+
st([Gt({ type: n, tooltip: 'root-UI层' }), ot('design:type', n)], Kt.prototype, 'root_ui', void 0),
|
|
997
|
+
st([Gt({ type: n, tooltip: 'root-组件层' }), ot('design:type', n)], Kt.prototype, 'root_toast', void 0),
|
|
998
|
+
st([Gt({ type: n, tooltip: 'root-mask' }), ot('design:type', n)], Kt.prototype, 'root_mask', void 0),
|
|
999
|
+
(Kt = st([Ht('Gui'), $t('CATCORE/Gui')], Kt));
|
|
1000
|
+
const { ccclass: Vt, property: Wt, menu: Qt } = i;
|
|
1001
|
+
let Jt = class extends nt {
|
|
1002
|
+
tween;
|
|
1003
|
+
};
|
|
1004
|
+
var Xt;
|
|
1005
|
+
st([Wt({ type: n, tooltip: '动画节点' }), ot('design:type', n)], Jt.prototype, 'tween', void 0),
|
|
1006
|
+
(Jt = st([Vt('CoreBlackMask'), Qt('CATCORE/CoreBlackMask')], Jt)),
|
|
1007
|
+
(function (t) {
|
|
1008
|
+
(t.Root = 'prefabs/root'),
|
|
1009
|
+
(t.Toast = 'prefabs/toast'),
|
|
1010
|
+
(t.BlackMask = 'prefabs/black-mask'),
|
|
1011
|
+
(t.Loading = 'prefabs/loading'),
|
|
1012
|
+
(t.Notice = 'prefabs/notice'),
|
|
1013
|
+
(t.Reconnection = 'prefabs/reconnection');
|
|
1014
|
+
})(Xt || (Xt = {}));
|
|
1015
|
+
class qt extends Y {
|
|
1016
|
+
gui;
|
|
1017
|
+
#t = 'resources';
|
|
1018
|
+
getGuiPrefabByType = (t, e) =>
|
|
1019
|
+
new Promise((i, s) => {
|
|
1020
|
+
a(t, `${e}`),
|
|
1021
|
+
this.cat.res.load(t, e, (t, e) => {
|
|
1022
|
+
t ? s(t) : i(e);
|
|
1023
|
+
});
|
|
1024
|
+
});
|
|
1025
|
+
async init() {
|
|
1026
|
+
this.#t = this.cat.gui_bundle_name;
|
|
1027
|
+
const t = await this.getGuiPrefabByType(this.#t, Xt.Root),
|
|
1028
|
+
e = p(t);
|
|
1029
|
+
return (this.gui = e.getComponent(Kt).init(this.cat)), r.addPersistRootNode(e), this;
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
class zt {
|
|
1033
|
+
get = (t, e, i = 'resources') => k.getBundle(i).get(t, e);
|
|
1034
|
+
isAssetType = t => 'function' == typeof t && t.prototype instanceof I;
|
|
1035
|
+
async load(...t) {
|
|
1036
|
+
let e = null,
|
|
1037
|
+
i = null,
|
|
1038
|
+
s = null;
|
|
1039
|
+
'string' == typeof t[0] && 'string' == typeof t[1] && (e = t.shift());
|
|
1040
|
+
let o = t.shift();
|
|
1041
|
+
this.isAssetType(t[0]) && (i = t.shift()), 2 == t.length && (s = t.shift());
|
|
1042
|
+
const n = t.shift();
|
|
1043
|
+
let r = x;
|
|
1044
|
+
if (e && 'resources' != e) {
|
|
1045
|
+
k.bundles.has(e) || (await this.loadBundle(e));
|
|
1046
|
+
let t = k.bundles.get(e);
|
|
1047
|
+
t && (r = t);
|
|
1048
|
+
}
|
|
1049
|
+
s && n ? r.load(o, i, s, n) : n ? r.load(o, i, n) : r.load(o, i);
|
|
1050
|
+
}
|
|
1051
|
+
async loadDir(...t) {
|
|
1052
|
+
let e = null,
|
|
1053
|
+
i = null,
|
|
1054
|
+
s = null,
|
|
1055
|
+
o = null;
|
|
1056
|
+
'string' == typeof t[0] && 'string' == typeof t[1] && (e = t.shift());
|
|
1057
|
+
let n = t.shift();
|
|
1058
|
+
this.isAssetType(t[0]) && (i = t.shift()), 2 == t.length && (s = t.shift()), (o = t.shift());
|
|
1059
|
+
let r = x;
|
|
1060
|
+
if (e && 'resources' != e) {
|
|
1061
|
+
k.bundles.has(e) || (await this.loadBundle(e));
|
|
1062
|
+
let t = k.bundles.get(e);
|
|
1063
|
+
t && (r = t);
|
|
1064
|
+
}
|
|
1065
|
+
s && o ? r.loadDir(n, i, s, o) : o ? r.loadDir(n, i, o) : r.loadDir(n, i);
|
|
1066
|
+
}
|
|
1067
|
+
loadRemote(t, ...e) {
|
|
1068
|
+
var i,
|
|
1069
|
+
s = null;
|
|
1070
|
+
2 == e.length && (s = e.shift()), (i = e.shift()), k.loadRemote(t, { ext: '.png', ...s }, i);
|
|
1071
|
+
}
|
|
1072
|
+
loadBundle = (t, e) =>
|
|
1073
|
+
new Promise((i, s) => {
|
|
1074
|
+
const o = (t, e) => {
|
|
1075
|
+
if (t) return s(t);
|
|
1076
|
+
i(e);
|
|
1077
|
+
};
|
|
1078
|
+
e ? k.loadBundle(t, { version: e }, o) : k.loadBundle(t, o);
|
|
1079
|
+
});
|
|
1080
|
+
releasePrefabtDepsRecursively = t => {
|
|
1081
|
+
var e = k.assets.get(t);
|
|
1082
|
+
(k.releaseAsset(e), e instanceof h) &&
|
|
1083
|
+
k.dependUtil.getDepsRecursively(t).forEach(t => {
|
|
1084
|
+
k.assets.get(t).decRef();
|
|
1085
|
+
});
|
|
1086
|
+
};
|
|
1087
|
+
release = (t, e = 'resources') => {
|
|
1088
|
+
var i = k.getBundle(e);
|
|
1089
|
+
if (i) {
|
|
1090
|
+
var s = i.get(t);
|
|
1091
|
+
s && this.releasePrefabtDepsRecursively(s._uuid);
|
|
1092
|
+
}
|
|
1093
|
+
};
|
|
1094
|
+
releaseDir = (t, e = 'resources') => {
|
|
1095
|
+
var i = k.getBundle(e),
|
|
1096
|
+
s = i?.getDirWithPath(t);
|
|
1097
|
+
s?.map(t => {
|
|
1098
|
+
this.releasePrefabtDepsRecursively(t.uuid);
|
|
1099
|
+
}),
|
|
1100
|
+
!t && 'resources' != e && i && k.removeBundle(i);
|
|
1101
|
+
};
|
|
1102
|
+
dump = () => {
|
|
1103
|
+
k.assets.forEach((t, e) => {
|
|
1104
|
+
a(k.assets.get(e));
|
|
1105
|
+
}),
|
|
1106
|
+
a(`当前资源总数:${k.assets.count}`);
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
let Zt = null;
|
|
1110
|
+
const Yt = {
|
|
1111
|
+
stringify: t => {
|
|
1112
|
+
const e = { ct: t.ciphertext.toString(G.enc.Base64) };
|
|
1113
|
+
return t.iv && (e.iv = t.iv.toString()), t.salt && (e.s = t.salt.toString()), JSON.stringify(e);
|
|
1114
|
+
},
|
|
1115
|
+
parse: t => {
|
|
1116
|
+
const e = JSON.parse(t),
|
|
1117
|
+
i = G.lib.CipherParams.create({ ciphertext: G.enc.Base64.parse(e.ct) });
|
|
1118
|
+
return e.iv && (i.iv = G.enc.Hex.parse(e.iv)), e.s && (i.salt = G.enc.Hex.parse(e.s)), i;
|
|
1119
|
+
},
|
|
1120
|
+
};
|
|
1121
|
+
var te = Object.freeze({
|
|
1122
|
+
__proto__: null,
|
|
1123
|
+
JsonFormatter: Yt,
|
|
1124
|
+
aesDecrypt: (t, e, i) => G.AES.decrypt(t, e, { iv: Zt, format: Yt }).toString(G.enc.Utf8),
|
|
1125
|
+
aesEncrypt: (t, e, i) => G.AES.encrypt(t, e, { iv: Zt, format: Yt }).toString(),
|
|
1126
|
+
initCrypto: (t, e) => {
|
|
1127
|
+
Zt = G.enc.Hex.parse(e);
|
|
1128
|
+
},
|
|
1129
|
+
md5: t => G.MD5(t).toString(),
|
|
1130
|
+
});
|
|
1131
|
+
class ee extends Y {
|
|
1132
|
+
encryptUtil = te;
|
|
1133
|
+
}
|
|
1134
|
+
class ie extends K {
|
|
1135
|
+
logBlackList = [];
|
|
1136
|
+
ignore = t => this.logBlackList.includes(t);
|
|
1137
|
+
constructor(t, e, i, s) {
|
|
1138
|
+
super(e, i, s, t);
|
|
1139
|
+
}
|
|
1140
|
+
destroy() {
|
|
1141
|
+
this.disconnect(!0), de.socialGameClient.unregister(this);
|
|
1142
|
+
}
|
|
1143
|
+
async GameRequest(t, e, i, s) {
|
|
1144
|
+
return new Promise((o, n) => {
|
|
1145
|
+
super.GameRequest(t, e, i, s).then(
|
|
1146
|
+
e => {
|
|
1147
|
+
U &&
|
|
1148
|
+
a(
|
|
1149
|
+
`%c ws服务端消息 %c [Response][${new Date()}] %c ${t} %c`,
|
|
1150
|
+
'background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff',
|
|
1151
|
+
'background:#3d7daa ; padding: 1px; color: #fff',
|
|
1152
|
+
'background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff',
|
|
1153
|
+
'background:transparent',
|
|
1154
|
+
$(i, e)
|
|
1155
|
+
),
|
|
1156
|
+
o(e);
|
|
1157
|
+
},
|
|
1158
|
+
t => {
|
|
1159
|
+
de.gui.showToast({ title: t.msg }), n(t);
|
|
1160
|
+
}
|
|
1161
|
+
);
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1164
|
+
subscribe(t, e, i) {
|
|
1165
|
+
return (
|
|
1166
|
+
super.subscribe(t, e, s => {
|
|
1167
|
+
U &&
|
|
1168
|
+
!this.ignore(t) &&
|
|
1169
|
+
a(
|
|
1170
|
+
`%c ws服务端消息:[${new Date()}] %c ${t} %c`,
|
|
1171
|
+
'background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff',
|
|
1172
|
+
'background:#410083 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff',
|
|
1173
|
+
'background:transparent',
|
|
1174
|
+
$(e, s)
|
|
1175
|
+
),
|
|
1176
|
+
de.event.emit(t, $(e, s)),
|
|
1177
|
+
i?.(s);
|
|
1178
|
+
}),
|
|
1179
|
+
this
|
|
1180
|
+
);
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
class se extends Y {
|
|
1184
|
+
managedClients = new Map();
|
|
1185
|
+
isGlobalOnline = !0;
|
|
1186
|
+
isInBackground = !1;
|
|
1187
|
+
get activeClients() {
|
|
1188
|
+
return Array.from(this.managedClients)
|
|
1189
|
+
.map(([t, e]) => e)
|
|
1190
|
+
.filter(t => t.socket);
|
|
1191
|
+
}
|
|
1192
|
+
constructor(t) {
|
|
1193
|
+
super(t), this.initGlobalListeners();
|
|
1194
|
+
}
|
|
1195
|
+
createWebSocket(t, e, i, s) {
|
|
1196
|
+
if (this.managedClients.has(t)) {
|
|
1197
|
+
this.managedClients.get(t).destroy(), a(`清理旧的 ${t} 客户端`);
|
|
1198
|
+
}
|
|
1199
|
+
const o = new ie(t, i, s, Object.assign({ reconnectMaxAttempts: 1 / 0 }, { ...e, isAutoConnect: !1 }));
|
|
1200
|
+
return this.register(o), o;
|
|
1201
|
+
}
|
|
1202
|
+
register(t) {
|
|
1203
|
+
t.on('reconnected', this.handleSingleReconnect), this.managedClients.set(t.name, t);
|
|
1204
|
+
}
|
|
1205
|
+
unregister(t) {
|
|
1206
|
+
t.off('reconnected', this.handleSingleReconnect), this.managedClients.delete(t.name);
|
|
1207
|
+
}
|
|
1208
|
+
initGlobalListeners() {
|
|
1209
|
+
this.cat.event.on(Et.ONLINE, () => this.handleGlobalStateChange('online'), this).on(Et.OFFLINE, () => this.handleGlobalStateChange('offline'), this),
|
|
1210
|
+
v.on(N.EVENT_SHOW, () => this.handleGlobalStateChange('show')),
|
|
1211
|
+
v.on(N.EVENT_HIDE, () => this.handleGlobalStateChange('hide'));
|
|
1212
|
+
}
|
|
1213
|
+
handleGlobalStateChange(t) {
|
|
1214
|
+
switch (t) {
|
|
1215
|
+
case 'online':
|
|
1216
|
+
(this.isGlobalOnline = !0), this.triggerReconnectAll();
|
|
1217
|
+
break;
|
|
1218
|
+
case 'offline':
|
|
1219
|
+
(this.isGlobalOnline = !1), this.disconnectAll(!0);
|
|
1220
|
+
break;
|
|
1221
|
+
case 'show':
|
|
1222
|
+
(this.isInBackground = !1), this.triggerReconnectAll();
|
|
1223
|
+
break;
|
|
1224
|
+
case 'hide':
|
|
1225
|
+
(this.isInBackground = !0), this.disconnectAll(!0);
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
async triggerReconnectAll() {
|
|
1229
|
+
if (!this.isGlobalOnline || this.isInBackground) return;
|
|
1230
|
+
if (0 === this.managedClients.size) return void a('没有任何WS需要重连');
|
|
1231
|
+
de.gui.showLoading({ title: '正在重连' }),
|
|
1232
|
+
await Promise.allSettled(
|
|
1233
|
+
this.activeClients.map(async t => {
|
|
1234
|
+
try {
|
|
1235
|
+
await t.reconnectPromise();
|
|
1236
|
+
} catch (e) {
|
|
1237
|
+
o(`${t.name}服重连失败`, e), de.gui.showToast({ title: `${t.name}服重连失败` });
|
|
1238
|
+
}
|
|
1239
|
+
try {
|
|
1240
|
+
await t.connectRequest();
|
|
1241
|
+
} catch (e) {
|
|
1242
|
+
o(`${t.name}服登录错误`, e), de.gui.showToast({ title: `登录${t.name}服错误` });
|
|
1243
|
+
}
|
|
1244
|
+
})
|
|
1245
|
+
);
|
|
1246
|
+
const t = this.activeClients.filter(t => t.socketConnectStatus !== j.CONNECTED);
|
|
1247
|
+
t.length > 0 &&
|
|
1248
|
+
(console.error(
|
|
1249
|
+
'部分WS重连失败:',
|
|
1250
|
+
t.map(t => t)
|
|
1251
|
+
),
|
|
1252
|
+
setTimeout(() => {
|
|
1253
|
+
this.triggerReconnectAll();
|
|
1254
|
+
}, 2e3));
|
|
1255
|
+
}
|
|
1256
|
+
disconnectAll(t) {
|
|
1257
|
+
this.managedClients.forEach(e => {
|
|
1258
|
+
a('断开连接', e.name, t, e.socket), e.disconnect(t);
|
|
1259
|
+
});
|
|
1260
|
+
}
|
|
1261
|
+
handleSingleReconnect = () => {
|
|
1262
|
+
this.activeClients.every(t => t.socketConnectStatus === j.CONNECTED) &&
|
|
1263
|
+
(a('单个WS重连成功回调===', this.managedClients), de.gui.hideLoading().reloadScene());
|
|
1264
|
+
};
|
|
1265
|
+
}
|
|
1266
|
+
const { ccclass: oe, property: ne, menu: re } = i;
|
|
1267
|
+
let ae = class extends at {
|
|
1268
|
+
default_title = null;
|
|
1269
|
+
title;
|
|
1270
|
+
prompt_content_str;
|
|
1271
|
+
prompt_content_spriteFrame;
|
|
1272
|
+
btn_confirm;
|
|
1273
|
+
confirm_spriteFrame;
|
|
1274
|
+
btn_cancel;
|
|
1275
|
+
cancel_spriteFrame;
|
|
1276
|
+
btn_close;
|
|
1277
|
+
isConfirm = !1;
|
|
1278
|
+
props = { title: this.default_title, content: null, confirmCB: () => {}, cancelCB: () => {}, style: null };
|
|
1279
|
+
onLoad() {
|
|
1280
|
+
this.btn_cancel.node.on(w.EventType.CLICK, this.onCancelHandler, this),
|
|
1281
|
+
this.btn_confirm.node.on(w.EventType.CLICK, this.onConfirmHandler, this),
|
|
1282
|
+
this.btn_close.node.on(w.EventType.CLICK, this.onCloseHandler, this),
|
|
1283
|
+
this.addAutorun([
|
|
1284
|
+
() => {
|
|
1285
|
+
this.title.spriteFrame = this.props?.title || this.default_title;
|
|
1286
|
+
},
|
|
1287
|
+
() => {
|
|
1288
|
+
this.props.content instanceof M
|
|
1289
|
+
? (this.prompt_content_spriteFrame.spriteFrame = this.props.content)
|
|
1290
|
+
: 'string' == typeof this.props.content
|
|
1291
|
+
? (this.prompt_content_str.string = this.props.content)
|
|
1292
|
+
: console.error('未知类型的【UIModal】内容');
|
|
1293
|
+
},
|
|
1294
|
+
() => {
|
|
1295
|
+
null === this.props?.style?.confirm
|
|
1296
|
+
? (this.btn_confirm.node.active = !1)
|
|
1297
|
+
: ((this.btn_confirm.node.active = !0),
|
|
1298
|
+
(this.btn_confirm.getComponent(D).spriteFrame = this.props.style?.confirm || this.confirm_spriteFrame)),
|
|
1299
|
+
null === this.props?.style?.cancel
|
|
1300
|
+
? (this.btn_cancel.node.active = !1)
|
|
1301
|
+
: ((this.btn_cancel.node.active = !0),
|
|
1302
|
+
(this.btn_cancel.getComponent(D).spriteFrame = this.props.style?.cancel || this.cancel_spriteFrame));
|
|
1303
|
+
},
|
|
1304
|
+
]);
|
|
1305
|
+
}
|
|
1306
|
+
close() {
|
|
1307
|
+
this.props.cancelCB?.(), de.gui.closeUI(this);
|
|
1308
|
+
}
|
|
1309
|
+
onCancelHandler() {
|
|
1310
|
+
this.close();
|
|
1311
|
+
}
|
|
1312
|
+
onConfirmHandler() {
|
|
1313
|
+
this.props.confirmCB?.();
|
|
1314
|
+
}
|
|
1315
|
+
onDestroy() {
|
|
1316
|
+
this.isConfirm && this.props.onDestroy?.();
|
|
1317
|
+
}
|
|
1318
|
+
onCloseHandler() {
|
|
1319
|
+
this.close();
|
|
1320
|
+
}
|
|
1321
|
+
};
|
|
1322
|
+
var ce;
|
|
1323
|
+
st([ne({ type: M, tooltip: '默认标题' }), ot('design:type', M)], ae.prototype, 'default_title', void 0),
|
|
1324
|
+
st([ne({ type: D, tooltip: '标题节点' }), ot('design:type', D)], ae.prototype, 'title', void 0),
|
|
1325
|
+
st([ne({ type: S, tooltip: '字符串内容按钮' }), ot('design:type', S)], ae.prototype, 'prompt_content_str', void 0),
|
|
1326
|
+
st([ne({ type: D, tooltip: '图片精灵内容按钮' }), ot('design:type', D)], ae.prototype, 'prompt_content_spriteFrame', void 0),
|
|
1327
|
+
st([ne({ type: w, tooltip: '确认按钮' }), ot('design:type', w)], ae.prototype, 'btn_confirm', void 0),
|
|
1328
|
+
st([ne({ type: M, tooltip: '确认按钮精灵图' }), ot('design:type', M)], ae.prototype, 'confirm_spriteFrame', void 0),
|
|
1329
|
+
st([ne({ type: w, tooltip: '取消按钮' }), ot('design:type', w)], ae.prototype, 'btn_cancel', void 0),
|
|
1330
|
+
st([ne({ type: M, tooltip: '取消按钮精灵图' }), ot('design:type', M)], ae.prototype, 'cancel_spriteFrame', void 0),
|
|
1331
|
+
st([ne({ type: w, tooltip: '关闭按钮' }), ot('design:type', w)], ae.prototype, 'btn_close', void 0),
|
|
1332
|
+
(ae = st([oe('CoreUIModal'), re('CATCORE/CoreUIModal')], ae)),
|
|
1333
|
+
(function (t) {
|
|
1334
|
+
(t[(t.Delay = 0)] = 'Delay'), (t[(t.Interval = 1)] = 'Interval');
|
|
1335
|
+
})(ce || (ce = {}));
|
|
1336
|
+
class le {
|
|
1337
|
+
tag;
|
|
1338
|
+
type;
|
|
1339
|
+
callback;
|
|
1340
|
+
remainingTime;
|
|
1341
|
+
executionTime = 0;
|
|
1342
|
+
initialTime;
|
|
1343
|
+
constructor(t, e, i, s) {
|
|
1344
|
+
(this.tag = t), (this.type = e), (this.remainingTime = i), (this.initialTime = i), (this.callback = s);
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
class he extends Y {
|
|
1348
|
+
timers = new Map();
|
|
1349
|
+
lastUpdateTime = Date.now();
|
|
1350
|
+
constructor(t) {
|
|
1351
|
+
super(t),
|
|
1352
|
+
t.event.on(Et.EVENT_HIDE, this.onHandleAppBackground, this),
|
|
1353
|
+
t.event.on(Et.EVENT_SHOW, this.onHandleAppForeground, this),
|
|
1354
|
+
setInterval(this.update.bind(this), 1e3);
|
|
1355
|
+
}
|
|
1356
|
+
onHandleAppBackground() {
|
|
1357
|
+
this.lastUpdateTime = Date.now();
|
|
1358
|
+
}
|
|
1359
|
+
onHandleAppForeground() {
|
|
1360
|
+
const t = Date.now(),
|
|
1361
|
+
e = t - this.lastUpdateTime;
|
|
1362
|
+
a('elapsedTime', e);
|
|
1363
|
+
for (const t of this.timers.values()) t.remainingTime > 0 && ((t.remainingTime -= e), (t.executionTime += e));
|
|
1364
|
+
this.lastUpdateTime = t;
|
|
1365
|
+
}
|
|
1366
|
+
registerInterval(t, e, i) {
|
|
1367
|
+
if (this.has(t)) return o(`${t}定时器已存在,请勿重复注册`);
|
|
1368
|
+
const s = new le(t, ce.Interval, e, i);
|
|
1369
|
+
this.timers.set(t, s);
|
|
1370
|
+
}
|
|
1371
|
+
registerDelay(t, e, i) {
|
|
1372
|
+
if (this.has(t)) return o(`${t}延时器已存在,请勿重复注册`);
|
|
1373
|
+
const s = new le(t, ce.Delay, e, i);
|
|
1374
|
+
this.timers.set(t, s);
|
|
1375
|
+
}
|
|
1376
|
+
unregister(t) {
|
|
1377
|
+
this.has(t) && this.timers.delete(t);
|
|
1378
|
+
}
|
|
1379
|
+
has(t) {
|
|
1380
|
+
return this.timers.has(t);
|
|
1381
|
+
}
|
|
1382
|
+
update() {
|
|
1383
|
+
const t = [];
|
|
1384
|
+
for (const [e, i] of this.timers.entries())
|
|
1385
|
+
(i.remainingTime -= 1e3),
|
|
1386
|
+
i.remainingTime <= 0 &&
|
|
1387
|
+
(i.type === ce.Interval && (i.executionTime += i.initialTime),
|
|
1388
|
+
i.callback(i.executionTime),
|
|
1389
|
+
i.type === ce.Interval ? (i.remainingTime = i.initialTime) : t.push(e));
|
|
1390
|
+
for (const e of t) this.timers.delete(e);
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
class pe {
|
|
1394
|
+
static #e;
|
|
1395
|
+
static get instance() {
|
|
1396
|
+
return this.#e || (this.#e = new pe()), this.#e;
|
|
1397
|
+
}
|
|
1398
|
+
onAppInitDelegate = new R();
|
|
1399
|
+
audio;
|
|
1400
|
+
event;
|
|
1401
|
+
gui;
|
|
1402
|
+
storage;
|
|
1403
|
+
res;
|
|
1404
|
+
util;
|
|
1405
|
+
socialGameClient;
|
|
1406
|
+
gui_bundle_name = '';
|
|
1407
|
+
audio_local_store_key = '';
|
|
1408
|
+
setConfig = ({ gui_bundleName: t = 'resources', audio_local_store_key: e = 'game_audio' } = {}) => (
|
|
1409
|
+
(this.gui_bundle_name = t), (this.audio_local_store_key = e), this
|
|
1410
|
+
);
|
|
1411
|
+
async boot() {
|
|
1412
|
+
(this.res = new zt()),
|
|
1413
|
+
(this.util = new ee(this)),
|
|
1414
|
+
(this.storage = new it(this)),
|
|
1415
|
+
(this.event = new V()),
|
|
1416
|
+
(this.audio = new et(this)),
|
|
1417
|
+
(this.socialGameClient = new se(this)),
|
|
1418
|
+
(this.gui = (await new qt(this).init()).gui);
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
const de = pe.instance;
|
|
1422
|
+
v.onPostProjectInitDelegate.add(async () => {
|
|
1423
|
+
console.time('[Init App]'), await de.boot(), await de.onAppInitDelegate.dispatch(), console.timeEnd('[Init App]');
|
|
1424
|
+
});
|
|
1425
|
+
export {
|
|
1426
|
+
tt as AudioEventConstant,
|
|
1427
|
+
et as AudioManager,
|
|
1428
|
+
pt as AudioSourceBaseComponent,
|
|
1429
|
+
_t as AudioSourceUILayer,
|
|
1430
|
+
ht as AudioTypeEnum,
|
|
1431
|
+
nt as BaseComponent,
|
|
1432
|
+
Y as BaseManager,
|
|
1433
|
+
Xt as BasePrefab,
|
|
1434
|
+
Jt as CoreBlackMask,
|
|
1435
|
+
Lt as CoreNotice,
|
|
1436
|
+
Rt as CoreReconnection,
|
|
1437
|
+
It as CoreShowLoading,
|
|
1438
|
+
vt as CoreToast,
|
|
1439
|
+
Tt as CoreUIContainer,
|
|
1440
|
+
ae as CoreUIModal,
|
|
1441
|
+
ee as CoreUtil,
|
|
1442
|
+
Et as GlobalEventConstant,
|
|
1443
|
+
Kt as Gui,
|
|
1444
|
+
qt as GuiManager,
|
|
1445
|
+
jt as LayerType,
|
|
1446
|
+
pe as Manager,
|
|
1447
|
+
Dt as ReconnectPrompt,
|
|
1448
|
+
wt as RootUILayer,
|
|
1449
|
+
Bt as SceneLayer,
|
|
1450
|
+
he as TimerManager,
|
|
1451
|
+
yt as ToastType,
|
|
1452
|
+
at as UILayer,
|
|
1453
|
+
ie as WrapperSocialGameClient,
|
|
1454
|
+
de as cat,
|
|
1455
|
+
};
|