diff options
author | sowgro <tpoke.ferrari@gmail.com> | 2023-06-01 11:38:04 -0400 |
---|---|---|
committer | sowgro <tpoke.ferrari@gmail.com> | 2023-06-01 11:38:04 -0400 |
commit | 48bfed142f7175809a43037fb695b6fcdc4146b1 (patch) | |
tree | e489132ad42bd7049b9854f6d6ed74673c796f43 /src/main/Difficulty.java | |
parent | 6c216a309838bf1cbeb19070ce180c0170ccd3c9 (diff) | |
download | NPEhero-48bfed142f7175809a43037fb695b6fcdc4146b1.tar.gz NPEhero-48bfed142f7175809a43037fb695b6fcdc4146b1.tar.bz2 NPEhero-48bfed142f7175809a43037fb695b6fcdc4146b1.zip |
finish gui level editor
Diffstat (limited to 'src/main/Difficulty.java')
-rw-r--r-- | src/main/Difficulty.java | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/main/Difficulty.java b/src/main/Difficulty.java index 2c74956..c5dfca3 100644 --- a/src/main/Difficulty.java +++ b/src/main/Difficulty.java @@ -17,7 +17,7 @@ import javafx.collections.ObservableList; public class Difficulty { public File thisDir; - public String title; + public String title = "Unnamed"; private ObservableList<LeaderboardEntry> leaderboard = FXCollections.observableArrayList(); public File notes; public int bpm; @@ -28,7 +28,6 @@ public class Difficulty public Difficulty(File file) { thisDir = file; - readData(); } public void readData() @@ -37,7 +36,7 @@ public class Difficulty { if (cur.getName().equals("metadata.json")) { - parseMetadata(cur); + parseMetadata(); } if (cur.getName().equals("leaderboard.json")) { @@ -55,8 +54,9 @@ public class Difficulty } - public void parseMetadata(File file) + public void parseMetadata() { + File file = new File(thisDir, "metadata.json"); JSONParser jsonParser = new JSONParser(); //parser to read the file try(FileReader reader = new FileReader(file)) @@ -139,7 +139,23 @@ public class Difficulty return title; } - public void writeMetadata() { - + public void writeMetadata() + { + FileWriter fileWriter; + try + { + File file = new File(thisDir, "metadata.json"); + fileWriter = new FileWriter(file); + JSONObject obj = new JSONObject(); + obj.put("title", title); + obj.put("bpm", bpm); + obj.put("numBeats", numBeats); + obj.writeJSONString(fileWriter); + fileWriter.flush(); + } + catch (IOException e) + { + e.printStackTrace(); + } } } |