From f49a73c6af7445bb4ae92fcab87e13abba527048 Mon Sep 17 00:00:00 2001 From: sowgro Date: Sun, 21 May 2023 00:45:19 -0400 Subject: add ui scrollbars, game over menu, new font --- src/main/SettingsController.java | 61 +++++++++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 7 deletions(-) (limited to 'src/main/SettingsController.java') diff --git a/src/main/SettingsController.java b/src/main/SettingsController.java index 79fb560..66da588 100644 --- a/src/main/SettingsController.java +++ b/src/main/SettingsController.java @@ -1,7 +1,54 @@ -// coming soon -// needs to have getters and setters for: -// - sfx vol -// - music vol -// - full screen -// -// perhaps use public variables instead of getters and setters \ No newline at end of file +package gui; + +import java.util.Map; +import java.util.HashMap; +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.JSONArray; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; + +public class SettingsController +{ + private int effectsVol; + private int musicVol; + private boolean fullscreen; + private JSONObject settings; + + public void saveAndWrite(int newEffVol, int newMusVol, boolean isFull) + { + + } + + public void readFile() throws ParseException + { + JSONParser jsonParser = new JSONParser(); //parser to read the file + + try(FileReader reader = new FileReader("settings.json")) + { + Object obj = jsonParser.parse(reader); + + settings = (JSONObject)(obj); //converts read object to a JSONObject + + effectsVol = (int) settings.get("effectsVol"); + musicVol = (int) settings.get("musicVol"); + fullscreen = (boolean) settings.get("fullscreen"); + } + catch (FileNotFoundException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + catch (IOException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + +} -- cgit v1.2.3