diff options
| author | Zach Jordan <zxjordan5@gmail.com> | 2023-05-25 09:56:14 -0400 | 
|---|---|---|
| committer | Zach Jordan <zxjordan5@gmail.com> | 2023-05-25 09:56:14 -0400 | 
| commit | 9e0efb69279e86e7462fa3a4bdb8b9198cc29a9f (patch) | |
| tree | 074f1341931f4cc05b4e348f6296c2ff6097fe9a | |
| parent | f89d776c40eb49992b5d65ed8cfa111328e75208 (diff) | |
| download | NPEhero-9e0efb69279e86e7462fa3a4bdb8b9198cc29a9f.tar.gz NPEhero-9e0efb69279e86e7462fa3a4bdb8b9198cc29a9f.tar.bz2 NPEhero-9e0efb69279e86e7462fa3a4bdb8b9198cc29a9f.zip | |
metadata for test level and a json reader
| -rw-r--r-- | src/assets/levels/test level/metadata.json | 6 | ||||
| -rw-r--r-- | src/main/Level.java | 41 | 
2 files changed, 41 insertions, 6 deletions
| diff --git a/src/assets/levels/test level/metadata.json b/src/assets/levels/test level/metadata.json index 17f5611..ae1ddba 100644 --- a/src/assets/levels/test level/metadata.json +++ b/src/assets/levels/test level/metadata.json @@ -1,5 +1,5 @@  { -    "diff1": "Easy", -    "diff2": "Medium", -    "diff3": "Hard" +    "title": "testSong", +    "artist": "ed sheeran", +    "desc": "this is a test level. lalalala testing testing",  }
\ No newline at end of file diff --git a/src/main/Level.java b/src/main/Level.java index d492c88..2b367d3 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 @@ -18,16 +27,42 @@ public class Level      public Image background; //optional      public Color[] colors; //optional, have default colors +    private JSONObject levelStuff; +      public void setColors(Color... newColors)       {          colors = newColors;      }      //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")); + +             + + +			 +			 +		} +		catch (FileNotFoundException e)  +		{ +			e.printStackTrace(); +		}  +		catch (IOException e)  +		{ +			e.printStackTrace(); +		}      }      public String getTitle() { | 
