From a3c83b1bcddb002e61f691ccade3545c7d7e5693 Mon Sep 17 00:00:00 2001 From: Zach Jordan Date: Tue, 23 May 2023 08:40:03 -0400 Subject: edited settings controller, now can read and write to file --- src/main/SettingsController.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/main/SettingsController.java') diff --git a/src/main/SettingsController.java b/src/main/SettingsController.java index 2e2d988..0dcf707 100644 --- a/src/main/SettingsController.java +++ b/src/main/SettingsController.java @@ -24,6 +24,19 @@ public class SettingsController public void saveAndWrite(int newEffVol, int newMusVol, boolean isFull) { + settings.put("musicVol", newMusVol); + settings.put("effectsVol", newEffVol); + settings.put("fullscreen", isFull); + + try (FileWriter file = new FileWriter("settings.json")) + { + //write the settings JSONObject instance to the file + file.write(settings.toJSONString()); + file.flush(); + + } catch (IOException e) { + e.printStackTrace(); + } } public void readFile() throws ParseException @@ -42,12 +55,10 @@ public class SettingsController } catch (FileNotFoundException e) { - // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { - // TODO Auto-generated catch block e.printStackTrace(); } -- cgit v1.2.3