aboutsummaryrefslogtreecommitdiff
path: root/src/main/SettingsController.java
blob: 2e2d988fcd8df0fcc152ae37bfe7a10b8a1403c4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main;

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;

import javafx.beans.property.SimpleIntegerProperty;

public class SettingsController 
{
	public SimpleIntegerProperty effectsVol = new SimpleIntegerProperty(0);
	public SimpleIntegerProperty musicVol = new SimpleIntegerProperty(0);
	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.set((int) settings.get("effectsVol"));
			musicVol.set((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();
		}
				
	}
	
}