Move backgrounds outside of jar file

This commit is contained in:
2023-06-07 15:29:32 -04:00
parent 3b2305949c
commit 1babdb6808
4 changed files with 24 additions and 5 deletions

View File

@@ -6,9 +6,9 @@ import com.google.gson.JsonElement;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
@@ -50,11 +50,10 @@ public class Location {
}
public void loadBackground() {
URL backgroundURL = this.getClass().getResource("/backgrounds/" + id + ".png");
if (backgroundURL == null) backgroundURL = this.getClass().getResource("/backgrounds/default.png");
File backgroundFile = new File("./backgrounds/" + id + ".png");
if (!backgroundFile.exists()) backgroundFile = new File("./backgrounds/default.png");
try {
assert backgroundURL != null;
background = ImageIO.read(backgroundURL);
background = ImageIO.read(backgroundFile);
} catch (IOException e) {
e.printStackTrace();
}