mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
@@ -60,6 +60,21 @@ public class FSkin {
|
||||
});
|
||||
})), null, false, true));
|
||||
}
|
||||
private static boolean isValidDirectory(FileHandle fileHandle) {
|
||||
if (fileHandle == null)
|
||||
return false;
|
||||
if (!fileHandle.exists())
|
||||
return false;
|
||||
if (!fileHandle.isDirectory())
|
||||
return false;
|
||||
String[] lists = fileHandle.file().list();
|
||||
if (lists == null)
|
||||
return false;
|
||||
return lists.length > 0;
|
||||
}
|
||||
private static void useFallbackDir() {
|
||||
preferredDir = GuiBase.isAndroid() ? Gdx.files.internal("fallback_skin") : Gdx.files.classpath("fallback_skin");
|
||||
}
|
||||
public static void loadLight(String skinName, final SplashScreen splashScreen,FileHandle prefDir) {
|
||||
preferredDir = prefDir;
|
||||
loadLight(skinName,splashScreen);
|
||||
@@ -83,11 +98,13 @@ public class FSkin {
|
||||
final FileHandle dir = Gdx.files.absolute(ForgeConstants.CACHE_SKINS_DIR);
|
||||
if(preferredDir == null)
|
||||
{
|
||||
if (!dir.exists() || !dir.isDirectory()) {
|
||||
//if skins directory doesn't exist, point to internal assets/skin directory instead for the sake of the splash screen
|
||||
preferredDir = GuiBase.isAndroid() ? Gdx.files.internal("fallback_skin") : Gdx.files.classpath("fallback_skin");
|
||||
}
|
||||
else {
|
||||
if (!isValidDirectory(dir)) {
|
||||
final FileHandle def = Gdx.files.absolute(ForgeConstants.DEFAULT_SKINS_DIR);
|
||||
if (def.exists() && def.isDirectory()) //if default skin exists
|
||||
preferredDir = def;
|
||||
else //if skins directory doesn't exist, point to internal assets/skin directory instead for the sake of the splash screen
|
||||
useFallbackDir();
|
||||
} else {
|
||||
if (splashScreen != null) {
|
||||
if (allSkins == null) { //initialize
|
||||
allSkins = new Array<>();
|
||||
@@ -107,6 +124,10 @@ public class FSkin {
|
||||
}
|
||||
}
|
||||
}
|
||||
//check preferredDir
|
||||
if (!isValidDirectory(preferredDir)) {
|
||||
useFallbackDir();
|
||||
}
|
||||
|
||||
|
||||
FSkinTexture.BG_TEXTURE.load(); //load background texture early for splash screen
|
||||
|
||||
Reference in New Issue
Block a user