diff options
author | Aidan Ross <aross02@fairport.org> | 2023-05-25 10:27:55 -0400 |
---|---|---|
committer | Aidan Ross <aross02@fairport.org> | 2023-05-25 10:27:55 -0400 |
commit | 414d5128c379916a50a015210e6d7caced1825f5 (patch) | |
tree | ec0db6e4c2dfa9067ea330b4bdbfeafda94f0851 /src/main/Level.java | |
parent | 389520ddc5064c21dcb0e9317366078ce1c88b65 (diff) | |
parent | 1d0890cf11f88e274beddf9fbc132fb80c2f054c (diff) | |
download | NPEhero-414d5128c379916a50a015210e6d7caced1825f5.tar.gz NPEhero-414d5128c379916a50a015210e6d7caced1825f5.tar.bz2 NPEhero-414d5128c379916a50a015210e6d7caced1825f5.zip |
Merge branch 'main' of https://gitlab.sowgro.net/guitarheros/guitarhero
Diffstat (limited to 'src/main/Level.java')
-rw-r--r-- | src/main/Level.java | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/src/main/Level.java b/src/main/Level.java index d492c88..ee60d47 100644 --- a/src/main/Level.java +++ b/src/main/Level.java @@ -7,6 +7,15 @@ import javafx.beans.property.SimpleStringProperty; import javafx.scene.image.Image; import javafx.scene.paint.Color; +import java.io.FileWriter; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; + +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; + public class Level { public Image preview; //optional @@ -16,7 +25,9 @@ public class Level public ArrayList<Difficulty> diffList = new ArrayList<Difficulty>(); public Image background; //optional - public Color[] colors; //optional, have default colors + public Color[] colors = new Color[5];//optional, have default colors + + private JSONObject levelStuff; public void setColors(Color... newColors) { @@ -24,10 +35,33 @@ public class Level } //all below is required for table view - public Level(String title, String artist) + public Level() throws ParseException { - this.title = new SimpleStringProperty(title); - this.artist = new SimpleStringProperty(artist); + JSONParser jsonParser = new JSONParser(); //parser to read the file + + try(FileReader reader = new FileReader(".json")) + { + Object obj = jsonParser.parse(reader); + + levelStuff = (JSONObject)(obj); //converts read object to a JSONObject + + title = (SimpleStringProperty)(levelStuff.get("title")); + artist = (SimpleStringProperty)(levelStuff.get("title")); + desc = (String)(levelStuff.get("title")); + + if(( levelStuff).containsKey("color1")) + { + + } + } + catch (FileNotFoundException e) + { + e.printStackTrace(); + } + catch (IOException e) + { + e.printStackTrace(); + } } public String getTitle() { |