mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
refactor FSkin Texture loading
- this should clear up unused texture - fix startup on empty res/skins folder
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package forge.assets;
|
||||
|
||||
import com.badlogic.gdx.assets.AssetManager;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
@@ -521,20 +520,18 @@ public enum FSkinImage implements FImage {
|
||||
FSkin.getImages().put(skinProp, this);
|
||||
}
|
||||
|
||||
public void load(AssetManager manager, Pixmap preferredIcons) {
|
||||
public void load(Pixmap preferredIcons) {
|
||||
String filename = sourceFile.getFilename();
|
||||
FileHandle preferredFile = FSkin.getSkinFile(filename);
|
||||
Texture texture = manager.get(preferredFile.path(), Texture.class, false);
|
||||
Texture texture = Forge.getAssets().getTexture(preferredFile, false);
|
||||
if (texture == null) {
|
||||
if (preferredFile.exists()) {
|
||||
try {
|
||||
manager.load(preferredFile.path(), Texture.class, Forge.getAssets().getTextureFilter());
|
||||
manager.finishLoadingAsset(preferredFile.path());
|
||||
texture = manager.get(preferredFile.path(), Texture.class);
|
||||
texture = Forge.getAssets().getTexture(preferredFile, false);
|
||||
}
|
||||
catch (final Exception e) {
|
||||
System.err.println("Failed to load skin file: " + preferredFile);
|
||||
e.printStackTrace();
|
||||
//e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -597,17 +594,15 @@ public enum FSkinImage implements FImage {
|
||||
|
||||
//use default file if can't use preferred file
|
||||
FileHandle defaultFile = FSkin.getDefaultSkinFile(filename);
|
||||
texture = manager.get(defaultFile.path(), Texture.class, false);
|
||||
texture = Forge.getAssets().getTexture(defaultFile, false);
|
||||
if (texture == null) {
|
||||
if (defaultFile.exists()) {
|
||||
try {
|
||||
manager.load(defaultFile.path(), Texture.class, Forge.getAssets().getTextureFilter());
|
||||
manager.finishLoadingAsset(defaultFile.path());
|
||||
texture = manager.get(defaultFile.path(), Texture.class);
|
||||
texture = Forge.getAssets().getTexture(defaultFile, false);
|
||||
}
|
||||
catch (final Exception e) {
|
||||
System.err.println("Failed to load skin file: " + defaultFile);
|
||||
e.printStackTrace();
|
||||
//e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user