diff --git a/pom.xml b/pom.xml index 8ae8de8..9f837af 100644 --- a/pom.xml +++ b/pom.xml @@ -20,6 +20,11 @@ javafx-fxml 17 + + org.yaml + snakeyaml + 1.33 + diff --git a/src/main/java/net/metaunix/App.java b/src/main/java/net/metaunix/App.java index bf1aadf..cece57a 100644 --- a/src/main/java/net/metaunix/App.java +++ b/src/main/java/net/metaunix/App.java @@ -9,6 +9,8 @@ import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.stage.Stage; +import net.metaunix.Config; + /** * JavaFX App @@ -22,6 +24,9 @@ public class App extends Application { var label = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + "."); + Config cfg = new Config("default.yaml"); + System.out.println(cfg.get("library_path")); + Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("views/main.fxml")); var scene = new Scene(root, 640, 480); stage.setTitle("Acorn Music Player"); diff --git a/src/main/java/net/metaunix/Config.java b/src/main/java/net/metaunix/Config.java new file mode 100644 index 0000000..e813737 --- /dev/null +++ b/src/main/java/net/metaunix/Config.java @@ -0,0 +1,23 @@ +package net.metaunix; + +import java.io.InputStream; +import java.util.Map; +import org.yaml.snakeyaml.Yaml; + +public class Config { + + private Map cfg; + + public Config(String configPath) { + Yaml yaml = new Yaml(); + InputStream inputStream = this.getClass() + .getClassLoader() + .getResourceAsStream(configPath); + this.cfg = yaml.load(inputStream); + } + + public Object get(String key) { + return this.cfg.get(key); + } + +} diff --git a/src/main/resources/default.yaml b/src/main/resources/default.yaml new file mode 100644 index 0000000..d2e0043 --- /dev/null +++ b/src/main/resources/default.yaml @@ -0,0 +1 @@ +library_path: "~/Music"