Файловый менеджер - Редактировать - /home/newsgini/news74.in/MrDino/ResourceLoader.js
Назад
var gdjs;(function(u){const g=new u.Logger("ResourceLoader"),c=new u.Logger("ResourceLoader - debug").enable(!1),L=(i,e,s)=>{if(i.startsWith("data:")||i.startsWith("blob:"))return i;const r=i.indexOf("?")===-1?"?":"&";return i+r+e+"="+s},_=i=>i.startsWith("https://project-resources.gdevelop.io/")||i.startsWith("https://project-resources-dev.gdevelop.io/"),h=20,w=5,p=3;class M{constructor(e){this.isFinished=!1;this.sceneName=e,this.onProgressCallbacks=new Array,this.onFinishCallbacks=new Array}registerCallback(e,s){if(this.isFinished){e();return}this.onFinishCallbacks.push(e),s&&this.onProgressCallbacks.push(s)}onProgress(e,s){for(const r of this.onProgressCallbacks)r(e,s)}onFinish(){this.isFinished=!0;for(const e of this.onFinishCallbacks)e()}}class v{constructor(e,s,r,n){this._sceneLoadingStates=new Map;this._sceneToLoadQueue=new Array;this._spineAtlasManager=null;this._spineManager=null;this.currentLoadingSceneName="";this.currentSceneLoadingProgress=0;this._isLoadingInForeground=!0;this._runtimeGame=e,this._resources=new Map,this._globalResources=r,this.setResources(s,r,n),this._imageManager=new u.ImageManager(this),this._soundManager=new u.SoundManager(this),this._fontManager=new u.FontManager(this),this._jsonManager=new u.JsonManager(this),this._bitmapFontManager=new u.BitmapFontManager(this,this._imageManager),this._model3DManager=new u.Model3DManager(this),u.SpineAtlasManager&&u.SpineManager&&(this._spineAtlasManager=new u.SpineAtlasManager(this,this._imageManager),this._spineManager=new u.SpineManager(this,this._spineAtlasManager));const t=[this._imageManager,this._soundManager,this._fontManager,this._jsonManager,this._bitmapFontManager,this._model3DManager];this._spineAtlasManager&&t.push(this._spineAtlasManager),this._spineManager&&t.push(this._spineManager),this._resourceManagersMap=new Map;for(const a of t)for(const o of a.getResourceKinds())this._resourceManagersMap.set(o,a)}getRuntimeGame(){return this._runtimeGame}setResources(e,s,r){this._globalResources=s,this._sceneLoadingStates.clear();for(const n of r)this._sceneLoadingStates.set(n.name,{resourceNames:n.usedResources.map(t=>t.name),status:"not-loaded"});this._sceneToLoadQueue.length=0;for(let n=r.length-1;n>=0;n--){const t=r[n],a=t.resourcesPreloading||"inherit";(a==="inherit"?this._runtimeGame.getSceneResourcesPreloading():a)==="at-startup"&&this._sceneToLoadQueue.push(new M(t.name))}this._resources.clear();for(const n of e)!n.file||this._resources.set(n.name,n)}async loadAllResources(e){let s=0;await m([...this._resources.values()],h,p,async r=>{await this._loadResource(r),await this._processResource(r),s++,e(s,this._resources.size)});for(const r of this._sceneLoadingStates.values())r.status="ready"}async loadGlobalAndFirstSceneResources(e,s){const r=this._sceneLoadingStates.get(e);if(!r){g.warn(`Can't load resource for unknown scene: "`+e+'".');return}let n=0;const t=[...this._globalResources,...r.resourceNames];await m(t,h,p,async a=>{const o=this._resources.get(a);if(!o){g.warn('Unable to find resource "'+a+'".');return}await this._loadResource(o),await this._processResource(o),n++,s(n,t.length)}),r.status="ready"}async loadAllSceneInBackground(){if(!this.currentLoadingSceneName){for(c.log("Loading all scene resources, in background.");this._sceneToLoadQueue.length>0;){c.log(`Still resources of ${this._sceneToLoadQueue.length} scene(s) to load: ${this._sceneToLoadQueue.map(s=>s.sceneName).join(", ")}`);const e=this._sceneToLoadQueue[this._sceneToLoadQueue.length-1];e!==void 0&&(this.currentLoadingSceneName=e.sceneName,this.areSceneAssetsLoaded(e.sceneName)?this._sceneToLoadQueue.pop():(c.log(`Loading (but not processing) resources for scene ${e.sceneName}.`),await this._doLoadSceneResources(e.sceneName,async(s,r)=>e.onProgress(s,r)),c.log(`Done loading (but not processing) resources for scene ${e.sceneName}.`),this._sceneToLoadQueue.splice(this._sceneToLoadQueue.findIndex(s=>s===e),1),e.onFinish()))}c.log("Scene resources loading finished."),this.currentLoadingSceneName=""}}async _doLoadSceneResources(e,s){const r=this._sceneLoadingStates.get(e);if(!r){g.warn(`Can't load resource for unknown scene: "`+e+'".');return}let n=0;await m(r.resourceNames,this._isLoadingInForeground?h:w,p,async t=>{const a=this._resources.get(t);if(!a){g.warn('Unable to find resource "'+t+'".');return}await this._loadResource(a),n++,this.currentSceneLoadingProgress=n/r.resourceNames.length,s&&await s(n,r.resourceNames.length)}),r.status="loaded"}async _loadResource(e){const s=this._resourceManagersMap.get(e.kind);if(!s){g.warn('Unknown resource kind: "'+e.kind+'" for: "'+e.name+'".');return}await s.loadResource(e.name)}async loadAndProcessSceneResources(e,s){if(this.areSceneAssetsReady(e))return;await this.loadSceneResources(e,s);const r=this._sceneLoadingStates.get(e);if(!r){g.warn(`Can't load resource for unknown scene: "`+e+'".');return}let n=0;for(const t of r.resourceNames){const a=this._resources.get(t);if(!a){g.warn('Unable to find resource "'+t+'".');continue}await this._processResource(a),n++,s&&await s(n,r.resourceNames.length)}r.status="ready"}async loadSceneResources(e,s){c.log(`Prioritization of loading of resources for scene ${e} was requested.`),this._isLoadingInForeground=!0;const r=this._prioritizeScene(e);return new Promise((n,t)=>{if(!r){this._isLoadingInForeground=!1,c.log(`Loading of resources for scene ${e} was immediately resolved.`),n();return}r.registerCallback(()=>{c.log(`Loading of resources for scene ${e} just finished.`),this._isLoadingInForeground=!1,n()},s)})}dispose(){for(const e of this._resourceManagersMap.values())e.dispose()}unloadSceneResources({unloadedSceneName:e,newSceneName:s}){if(!e)return;c.log(`Unloading of resources for scene ${e} was requested.`);const r=this._getResourcesByKindOnlyUsedInUnloadedScene({unloadedSceneName:e,newSceneName:s});for(const[t,a]of this._resourceManagersMap){const o=r.get(t);o&&(c.log(`Unloading of resources of kind ${t} for scene ${e}: `,o.map(d=>d.name).join(", ")),a.unloadResourcesList(o))}c.log(`Unloading of resources for scene ${e} finished.`);const n=this._sceneLoadingStates.get(e);n&&(n.status="not-loaded")}_prioritizeScene(e){const s=this._sceneLoadingStates.get(e);if(!s)return null;if(s.status==="loaded"||s.status==="ready")return c.log(`Scene ${e} is already loaded. Skipping prioritization.`),null;const r=this._sceneToLoadQueue.findIndex(t=>t.sceneName===e);let n;return r!==-1?(n=this._sceneToLoadQueue[r],this._sceneToLoadQueue.splice(r,1),this._sceneToLoadQueue.push(n)):(n=new M(e),this._sceneToLoadQueue.push(n)),this.loadAllSceneInBackground(),n}async _processResource(e){const s=this._resourceManagersMap.get(e.kind);if(!s){g.warn('Unknown resource kind: "'+e.kind+'" for: "'+e.name+'".');return}await s.processResource(e.name)}getSceneLoadingProgress(e){return e===this.currentLoadingSceneName?this.currentSceneLoadingProgress:this.areSceneAssetsLoaded(e)?1:0}areSceneAssetsLoaded(e){const s=this._sceneLoadingStates.get(e);return s?s.status==="loaded"||s.status==="ready":!1}areSceneAssetsReady(e){const s=this._sceneLoadingStates.get(e);return s?s.status==="ready":!1}getResource(e){return this._resources.get(e)||null}getFullUrl(e){const{gdevelopResourceToken:s}=this._runtimeGame._options;return!s||!_(e)?e:L(e,"gd_resource_token",encodeURIComponent(s))}checkIfCredentialsRequired(e){return this._runtimeGame._options.gdevelopResourceToken?!1:!!_(e)}getSoundManager(){return this._soundManager}getImageManager(){return this._imageManager}getFontManager(){return this._fontManager}getBitmapFontManager(){return this._bitmapFontManager}getJsonManager(){return this._jsonManager}getModel3DManager(){return this._model3DManager}getSpineManager(){return this._spineManager}getSpineAtlasManager(){return this._spineAtlasManager}injectMockResourceManagerForTesting(e,s){this._resourceManagersMap.set(e,s)}_getResourcesByKindOnlyUsedInUnloadedScene({unloadedSceneName:e,newSceneName:s}){const r=this._sceneLoadingStates.get(e);if(!r)return new Map;const n=new Set(r.resourceNames);for(const[a,o]of this._sceneLoadingStates.entries())a!==e&&(a===s||o.status==="loaded"||o.status==="ready")&&o.resourceNames.forEach(d=>{n.delete(d)});const t=new Map;return n.forEach(a=>{const o=this._resources.get(a);if(!o)return;const d=o.kind,l=t.get(d);l?l.push(o):t.set(d,[o])}),t}}u.ResourceLoader=v;const S=(i,e,s)=>{const r=[],n=[];let t=0,a=0;return new Promise((o,d)=>{const l=()=>{if(i.length===0){o({results:r,errors:n});return}for(;t<e&&a<i.length;){const R=i[a++];t++,s(R).then(f=>r.push(f)).catch(f=>n.push({item:R,error:f})).finally(()=>{t--,a===i.length&&t===0?o({results:r,errors:n}):l()})}};l()})},m=async(i,e,s,r)=>{const n=await S(i,e,r);n.errors.length!==0&&g.warn("Some assets couldn't be downloaded. Trying again now.");for(let t=1;t<s&&n.errors.length!==0;t++){const a=await S(i,e,r);n.results.push.apply(n.results,a.results),n.errors=a.errors}return n}})(gdjs||(gdjs={})); //# sourceMappingURL=ResourceLoader.js.map
| ver. 1.6 |
Github
|
.
| PHP 8.1.31 | Генерация страницы: 5.28 |
proxy
|
phpinfo
|
Настройка