From 082ac2a0a5dfe4b554725b3c87f2ade0a9b81fd4 Mon Sep 17 00:00:00 2001 From: Natan Date: Sat, 27 Jul 2024 14:16:01 -0300 Subject: [PATCH] Don't download assets if preload assets is true --- .../emu/com/badlogic/gdx/assets/AssetLoadingTaskEmu.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backends/backend-teavm/emu/com/badlogic/gdx/assets/AssetLoadingTaskEmu.java b/backends/backend-teavm/emu/com/badlogic/gdx/assets/AssetLoadingTaskEmu.java index b7cd4261..154efb30 100644 --- a/backends/backend-teavm/emu/com/badlogic/gdx/assets/AssetLoadingTaskEmu.java +++ b/backends/backend-teavm/emu/com/badlogic/gdx/assets/AssetLoadingTaskEmu.java @@ -1,6 +1,7 @@ package com.badlogic.gdx.assets; import com.badlogic.gdx.Files; +import com.badlogic.gdx.Gdx; import com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader; import com.badlogic.gdx.assets.loaders.SynchronousAssetLoader; import com.badlogic.gdx.files.FileHandle; @@ -11,6 +12,7 @@ import com.badlogic.gdx.utils.async.AsyncExecutor; import com.badlogic.gdx.utils.async.AsyncResult; import com.badlogic.gdx.utils.async.AsyncTask; +import com.github.xpenatan.gdx.backends.teavm.TeaApplication; import com.github.xpenatan.gdx.backends.teavm.gen.Emulate; import com.github.xpenatan.gdx.backends.teavm.assetloader.AssetType; import com.github.xpenatan.gdx.backends.teavm.assetloader.AssetLoader; @@ -34,12 +36,17 @@ class AssetLoadingTaskEmu implements AsyncTask { int count = 0; + private boolean preloadAssets = true; + public AssetLoadingTaskEmu(AssetManager manager, AssetDescriptor assetDesc, com.badlogic.gdx.assets.loaders.AssetLoader loader, AsyncExecutor threadPool) { this.manager = manager; this.assetDesc = assetDesc; this.loader = loader; this.executor = threadPool; startTime = manager.log.getLevel() == Logger.DEBUG ? TimeUtils.nanoTime() : 0; + + TeaApplication app = (TeaApplication)Gdx.app; + preloadAssets = app.getConfig().preloadAssets; } /** @@ -83,7 +90,7 @@ public boolean update() { FileHandle fileHandle = resolve(loader, assetDesc); String path = fileHandle.path(); Files.FileType type = fileHandle.type(); - if(!assetLoader.isAssetLoaded(type, path)) { + if(!preloadAssets && !assetLoader.isAssetLoaded(type, path)) { if(!assetLoader.isAssetInQueue(path)) { count++; if(count == 2) {