mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
Switch from Gdx.files.local to Gdx.files.absolute
Ensure directories created for data and cache
This commit is contained in:
@@ -73,7 +73,7 @@ public class FSkin {
|
||||
FSkinTexture.BG_TEXTURE.load(preferredDir, ForgeConstants.DEFAULT_SKINS_DIR); //load background texture early for splash screen
|
||||
|
||||
if (splashScreen != null) {
|
||||
final FileHandle f = Gdx.files.local(preferredDir + "bg_splash.png");
|
||||
final FileHandle f = Gdx.files.absolute(preferredDir + "bg_splash.png");
|
||||
if (!f.exists()) {
|
||||
if (!skinName.equals("default")) {
|
||||
FSkin.loadLight("default", splashScreen);
|
||||
@@ -135,12 +135,12 @@ public class FSkin {
|
||||
|
||||
// Grab and test various sprite files.
|
||||
String defaultDir = ForgeConstants.DEFAULT_SKINS_DIR;
|
||||
final FileHandle f1 = Gdx.files.local(defaultDir + SourceFile.ICONS.getFilename());
|
||||
final FileHandle f2 = Gdx.files.local(preferredDir + SourceFile.ICONS.getFilename());
|
||||
final FileHandle f3 = Gdx.files.local(defaultDir + SourceFile.FOILS.getFilename());
|
||||
final FileHandle f4 = Gdx.files.local(defaultDir + ForgeConstants.SPRITE_AVATARS_FILE);
|
||||
final FileHandle f5 = Gdx.files.local(preferredDir + ForgeConstants.SPRITE_AVATARS_FILE);
|
||||
final FileHandle f6 = Gdx.files.local(defaultDir + SourceFile.OLD_FOILS.getFilename());
|
||||
final FileHandle f1 = Gdx.files.absolute(defaultDir + SourceFile.ICONS.getFilename());
|
||||
final FileHandle f2 = Gdx.files.absolute(preferredDir + SourceFile.ICONS.getFilename());
|
||||
final FileHandle f3 = Gdx.files.absolute(defaultDir + SourceFile.FOILS.getFilename());
|
||||
final FileHandle f4 = Gdx.files.absolute(defaultDir + ForgeConstants.SPRITE_AVATARS_FILE);
|
||||
final FileHandle f5 = Gdx.files.absolute(preferredDir + ForgeConstants.SPRITE_AVATARS_FILE);
|
||||
final FileHandle f6 = Gdx.files.absolute(defaultDir + SourceFile.OLD_FOILS.getFilename());
|
||||
|
||||
try {
|
||||
textures.put(f1.path(), new Texture(f1));
|
||||
@@ -299,7 +299,7 @@ public class FSkin {
|
||||
public static ArrayList<String> getSkinDirectoryNames() {
|
||||
final ArrayList<String> mySkins = new ArrayList<String>();
|
||||
|
||||
final FileHandle dir = Gdx.files.local(ForgeConstants.SKINS_DIR);
|
||||
final FileHandle dir = Gdx.files.absolute(ForgeConstants.SKINS_DIR);
|
||||
if (!dir.exists() || !dir.isDirectory()) {
|
||||
System.err.println("FSkin > can't find skins directory!");
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class FSkinFont {
|
||||
String dir = FSkin.getDir();
|
||||
|
||||
//generate .fnt and .png files from .ttf if needed
|
||||
FileHandle ttfFile = Gdx.files.local(dir + TTF_FILE);
|
||||
FileHandle ttfFile = Gdx.files.absolute(dir + TTF_FILE);
|
||||
if (ttfFile.exists()) {
|
||||
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(ttfFile);
|
||||
font = generator.generateFont(size);
|
||||
|
||||
@@ -256,7 +256,7 @@ public enum FSkinImage implements FImage {
|
||||
String preferredFile = preferredDir + filename;
|
||||
Texture texture = textures.get(preferredFile);
|
||||
if (texture == null) {
|
||||
FileHandle file = Gdx.files.local(preferredFile);
|
||||
FileHandle file = Gdx.files.absolute(preferredFile);
|
||||
if (file.exists()) {
|
||||
try {
|
||||
texture = new Texture(file);
|
||||
@@ -328,7 +328,7 @@ public enum FSkinImage implements FImage {
|
||||
String defaultFile = defaultDir + filename;
|
||||
texture = textures.get(defaultFile);
|
||||
if (texture == null) {
|
||||
FileHandle file = Gdx.files.local(defaultFile);
|
||||
FileHandle file = Gdx.files.absolute(defaultFile);
|
||||
if (file.exists()) {
|
||||
try {
|
||||
texture = new Texture(file);
|
||||
|
||||
@@ -22,7 +22,7 @@ public enum FSkinTexture implements FImage {
|
||||
|
||||
public void load(String preferredDir, String defaultDir) {
|
||||
String preferredFile = preferredDir + filename;
|
||||
FileHandle file = Gdx.files.local(preferredFile);
|
||||
FileHandle file = Gdx.files.absolute(preferredFile);
|
||||
if (file.exists()) {
|
||||
try {
|
||||
texture = new Texture(file);
|
||||
@@ -35,7 +35,7 @@ public enum FSkinTexture implements FImage {
|
||||
if (texture == null) {
|
||||
//use default file if can't use preferred file
|
||||
String defaultFile = defaultDir + filename;
|
||||
file = Gdx.files.local(defaultFile);
|
||||
file = Gdx.files.absolute(defaultFile);
|
||||
if (file.exists()) {
|
||||
try {
|
||||
texture = new Texture(file);
|
||||
@@ -43,6 +43,7 @@ public enum FSkinTexture implements FImage {
|
||||
catch (final Exception e) {
|
||||
System.err.println("Failed to load skin file: " + defaultFile);
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ImageCache {
|
||||
static {
|
||||
Texture defImage = null;
|
||||
try {
|
||||
defImage = new Texture(Gdx.files.local(ForgeConstants.NO_CARD_FILE));
|
||||
defImage = new Texture(Gdx.files.absolute(ForgeConstants.NO_CARD_FILE));
|
||||
} catch (Exception ex) {
|
||||
System.err.println("could not load default card image");
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user