aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsowgro <tpoke.ferrari@gmail.com>2024-09-22 01:13:11 -0400
committersowgro <tpoke.ferrari@gmail.com>2024-09-22 01:13:11 -0400
commit2b3d6eeb08fac367b2e2f4ed0528bfaeeedca686 (patch)
tree23cf821ce9ab536dfd44a74db26dba6ea4f9fb90 /src
parentda1b21264caf8fd42a1a809c538e2128435160f9 (diff)
downloadNPEhero-2b3d6eeb08fac367b2e2f4ed0528bfaeeedca686.tar.gz
NPEhero-2b3d6eeb08fac367b2e2f4ed0528bfaeeedca686.tar.bz2
NPEhero-2b3d6eeb08fac367b2e2f4ed0528bfaeeedca686.zip
Contain all gamedata in .npehero
Diffstat (limited to 'src')
-rwxr-xr-xsrc/main/java/net/sowgro/npehero/Driver.java13
-rwxr-xr-xsrc/main/java/net/sowgro/npehero/levelapi/Levels.java3
-rw-r--r--src/main/java/net/sowgro/npehero/main/Control.java4
-rwxr-xr-xsrc/main/java/net/sowgro/npehero/main/Settings.java3
-rwxr-xr-xsrc/main/resources/net/sowgro/npehero/style.css5
5 files changed, 22 insertions, 6 deletions
diff --git a/src/main/java/net/sowgro/npehero/Driver.java b/src/main/java/net/sowgro/npehero/Driver.java
index 89381aa..3be414c 100755
--- a/src/main/java/net/sowgro/npehero/Driver.java
+++ b/src/main/java/net/sowgro/npehero/Driver.java
@@ -17,6 +17,7 @@ import net.sowgro.npehero.levelapi.Levels;
import net.sowgro.npehero.main.*;
import net.sowgro.npehero.gui.MainMenu;
+import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Stack;
@@ -25,6 +26,7 @@ import java.util.Stack;
public class Driver extends Application
{
public static final Image MENU_BACKGROUND = new Image(Driver.class.getResource("mountains.png").toExternalForm());
+ public static final File BASE_DIR = new File(".npehero");
public static Stage primaryStage;
public static ScrollPane primaryPane = new ScrollPane();
@@ -88,6 +90,17 @@ public class Driver extends Application
primaryStage.show();
Stack<String> errors = new Stack<>();
+ System.out.println("Loading .npehero...");
+ try {
+ if (!BASE_DIR.exists() && !BASE_DIR.mkdir()) {
+ throw new IOException();
+ }
+ if (!BASE_DIR.isDirectory()) {
+ throw new IOException();
+ }
+ } catch (Exception e) {
+ errors.push("Failed to locate .npehero\n"+e);
+ }
System.out.println("Loading settings...");
try {
Settings.read();
diff --git a/src/main/java/net/sowgro/npehero/levelapi/Levels.java b/src/main/java/net/sowgro/npehero/levelapi/Levels.java
index 84d169c..f4cdc1d 100755
--- a/src/main/java/net/sowgro/npehero/levelapi/Levels.java
+++ b/src/main/java/net/sowgro/npehero/levelapi/Levels.java
@@ -11,6 +11,7 @@ import java.util.HashMap;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
+import net.sowgro.npehero.Driver;
/**
* Stores a list of all the levels
@@ -20,7 +21,7 @@ public class Levels {
public static final ObservableList<Level> list = FXCollections.observableArrayList();
public static final HashMap<String, Exception> problems = new HashMap<>();
- public static final File dir = new File("levels");
+ public static final File dir = new File(Driver.BASE_DIR, "levels");
/**
* Reads contents of the levels folder and creates a level form each subfolder
diff --git a/src/main/java/net/sowgro/npehero/main/Control.java b/src/main/java/net/sowgro/npehero/main/Control.java
index c842419..df6e3ef 100644
--- a/src/main/java/net/sowgro/npehero/main/Control.java
+++ b/src/main/java/net/sowgro/npehero/main/Control.java
@@ -5,6 +5,7 @@ import com.google.gson.GsonBuilder;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.input.KeyCode;
+import net.sowgro.npehero.Driver;
import java.io.*;
import java.util.*;
@@ -43,7 +44,7 @@ public enum Control {
LANE4,
};
- private static final File file = new File("controls.json");
+ private static final File file = new File(Driver.BASE_DIR, "controls.json");
private static final Gson json = new GsonBuilder().serializeNulls().setPrettyPrinting().create();
public static void writeToFile() throws IOException {
@@ -57,6 +58,7 @@ public enum Control {
}
public static void readFromFile() throws Exception {
+ @SuppressWarnings("unchecked")
Map<String, Object> data = json.fromJson(new FileReader(file), Map.class);
for (Control control : Control.values()) {
if (data.containsKey(control.toString())) {
diff --git a/src/main/java/net/sowgro/npehero/main/Settings.java b/src/main/java/net/sowgro/npehero/main/Settings.java
index 162f579..cee7680 100755
--- a/src/main/java/net/sowgro/npehero/main/Settings.java
+++ b/src/main/java/net/sowgro/npehero/main/Settings.java
@@ -11,6 +11,7 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleDoubleProperty;
+import net.sowgro.npehero.Driver;
public class Settings
{
@@ -20,7 +21,7 @@ public class Settings
public static SimpleDoubleProperty guiScale = new SimpleDoubleProperty(1);
private static final Gson jsonParser = new GsonBuilder().serializeNulls().setPrettyPrinting().create();
- private static final File jsonFile = new File("settings.json");
+ private static final File jsonFile = new File(Driver.BASE_DIR, "settings.json");
/**
* Reads json data from settings.json
diff --git a/src/main/resources/net/sowgro/npehero/style.css b/src/main/resources/net/sowgro/npehero/style.css
index e4d34f0..0697632 100755
--- a/src/main/resources/net/sowgro/npehero/style.css
+++ b/src/main/resources/net/sowgro/npehero/style.css
@@ -168,8 +168,7 @@ Slider:focused .thumb{
/* scroll bars */
-.scroll-bar:horizontal ,
-.scroll-bar:vertical{
+.scroll-bar:horizontal, .scroll-bar:vertical {
-fx-font-size: 10px;
-fx-background-color :transparent;
-fx-border-color :transparent;
@@ -177,7 +176,7 @@ Slider:focused .thumb{
-fx-border-radius :2.0em;
}
-.increment-button ,.decrement-button {
+.increment-button, .decrement-button {
-fx-background-color:transparent;
-fx-border-color:transparent;
}