aboutsummaryrefslogtreecommitdiff
path: root/src/main/SettingsController.java
diff options
context:
space:
mode:
authorsowgro <tpoke.ferrari@gmail.com>2024-07-08 02:41:31 -0400
committersowgro <tpoke.ferrari@gmail.com>2024-07-08 02:41:31 -0400
commitee2229339429d50afa33e2f8b9c0ee0939766290 (patch)
treea5ee54bd23c24950e9b10815f3e87605906992d8 /src/main/SettingsController.java
parent9e1371424bdf4c31d756d686313730d4c61f7ac5 (diff)
downloadNPEhero-ee2229339429d50afa33e2f8b9c0ee0939766290.tar.gz
NPEhero-ee2229339429d50afa33e2f8b9c0ee0939766290.tar.bz2
NPEhero-ee2229339429d50afa33e2f8b9c0ee0939766290.zip
Change project structure, embed resources into jar and remove libraries from source control
Diffstat (limited to 'src/main/SettingsController.java')
-rw-r--r--src/main/SettingsController.java62
1 files changed, 0 insertions, 62 deletions
diff --git a/src/main/SettingsController.java b/src/main/SettingsController.java
deleted file mode 100644
index 3304dd4..0000000
--- a/src/main/SettingsController.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package main;
-
-import java.io.FileWriter;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-import javafx.beans.property.SimpleDoubleProperty;
-
-public class SettingsController
-{
- public SimpleDoubleProperty effectsVol = new SimpleDoubleProperty(1);
- public SimpleDoubleProperty musicVol = new SimpleDoubleProperty(1);
- private File file = new File("settings.json");
-
- public SettingsController()
- {
- read();
- }
-
- /**
- * reads json data from settings.json
- */
- public void read()
- {
- JSONParser jsonParser = new JSONParser(); //parser to read the file
- try(FileReader reader = new FileReader(file))
- {
- Object obj = jsonParser.parse(reader);
- JSONObject settings = new JSONObject();
- settings = (JSONObject)(obj); //converts read object to a JSONObject
-
- effectsVol.set(Double.parseDouble(settings.get("effectsVol")+""));
- musicVol.set(Double.parseDouble(settings.get("musicVol")+""));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- /**
- * writes json data to settings.json
- */
- public void write()
- {
- FileWriter fileWriter;
- try
- {
- fileWriter = new FileWriter(file);
- JSONObject obj = new JSONObject();
- obj.put("musicVol", musicVol.getValue());
- obj.put("effectsVol", effectsVol.getValue());
- obj.writeJSONString(fileWriter);
- fileWriter.flush();
- }
- catch (IOException e) {
- e.printStackTrace();
- }
- }
-}