Skip to content

Commit

Permalink
Update Config.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacocococo authored Jul 28, 2020
1 parent 3ce8cd3 commit f27d229
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/com/jacoco/mcdata/files/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;

import com.jacoco.mcdata.DarkMode;
import com.jacoco.mcdata.Gui;
import com.jacoco.mcdata.Strings;

Expand All @@ -36,30 +35,36 @@ public Config() throws Exception {
if(exists == false) {
sources = Files.createDirectories(sourcesPath);
ExportPath.exportDirPath = Paths.get(sourcesPath+"\\Export");
export = sourcesPath+"\\Export";
ExportPath.exportDir = Files.createDirectories(ExportPath.exportDirPath);
setupConfig();

new Gui(254, 254, 254, 0, 0, 0, Strings.light);
Gui.ep.setText(ExportPath.exportDir.toString());
System.out.println(ExportPath.exportDir.toString());
} else {

Object obj = new JSONParser().parse(new FileReader(cfg));

JSONObject jo = (JSONObject) obj;

String mode = jo.get("mode").toString();


try{
export = jo.get("Export Path").toString();
} catch (NullPointerException e) {
export = sourcesPath+"\\Export";
}

switch(mode) {

// set color ints and label Strings when Config.json has "Light Mode"
case Strings.light : DarkMode.setValues(254, 254, 254, 0, 0, 0, Strings.light);
case Strings.light : new Gui(254, 254, 254, 0, 0, 0, Strings.light);
break;

// set color ints and label Strings when Config.json has "Dark Mode"
case Strings.dark : DarkMode.setValues(0, 0, 50, 254, 254, 254, Strings.dark);
case Strings.dark : new Gui(0, 0, 50, 254, 254, 254, Strings.dark);
break;
}

export = jo.get("Export Path").toString();
ExportPath.exportDirPath = Paths.get(export);
Gui.ep.setText(export);
}
}

Expand All @@ -70,7 +75,6 @@ public static void setupConfig() throws Exception {
JSONObject jo = new JSONObject();

jo.put("mode", Strings.light);

jo.put("Export Path", ExportPath.exportDirPath.toString());

PrintWriter pw = new PrintWriter(sourcesPath+"\\"+Strings.config);
Expand Down

0 comments on commit f27d229

Please sign in to comment.