Skip to content

Commit

Permalink
Don't download assets if preload assets is true
Browse files Browse the repository at this point in the history
  • Loading branch information
xpenatan committed Jul 27, 2024
1 parent 66c9690 commit 082ac2a
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -34,12 +36,17 @@ class AssetLoadingTaskEmu implements AsyncTask<Void> {

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;
}

/**
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 082ac2a

Please sign in to comment.