refactor the path/filename combining stuff
This commit is contained in:
parent
9aaf622a14
commit
ff8016d53c
16
src/main/java/ca/blarg/gdx/assets/AssetLoadingUtils.java
Normal file
16
src/main/java/ca/blarg/gdx/assets/AssetLoadingUtils.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
package ca.blarg.gdx.assets;
|
||||
|
||||
import ca.blarg.gdx.Strings;
|
||||
import ca.blarg.gdx.io.FileHelpers;
|
||||
|
||||
public class AssetLoadingUtils {
|
||||
public static String addPathIfNone(String filename, String path) {
|
||||
if (Strings.isNullOrEmpty(filename))
|
||||
return filename;
|
||||
|
||||
if (FileHelpers.hasPath(filename))
|
||||
return filename;
|
||||
else
|
||||
return FileHelpers.combine(path, filename);
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package ca.blarg.gdx.assets.textureatlas;
|
||||
|
||||
import ca.blarg.gdx.assets.AssetLoadingException;
|
||||
import ca.blarg.gdx.assets.AssetLoadingUtils;
|
||||
import ca.blarg.gdx.graphics.atlas.CustomGridTextureAtlas;
|
||||
import ca.blarg.gdx.graphics.atlas.TextureAtlas;
|
||||
import ca.blarg.gdx.io.FileHelpers;
|
||||
import com.badlogic.gdx.assets.AssetManager;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
|
@ -14,8 +14,7 @@ class TextureAtlasJsonLoader {
|
|||
Json json = new Json();
|
||||
JsonTextureAtlas definition = json.fromJson(JsonTextureAtlas.class, file);
|
||||
|
||||
if (!FileHelpers.hasPath(definition.texture))
|
||||
definition.texture = FileHelpers.combine(file.parent().path(), definition.texture);
|
||||
definition.texture = AssetLoadingUtils.addPathIfNone(definition.texture, file.parent().path());
|
||||
|
||||
return definition;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue