-
Notifications
You must be signed in to change notification settings - Fork 294
Expand file tree
/
Copy pathConfig.java
More file actions
75 lines (61 loc) · 2.04 KB
/
Config.java
File metadata and controls
75 lines (61 loc) · 2.04 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package net.vulkanmod.config;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import net.vulkanmod.config.video.VideoModeManager;
import net.vulkanmod.config.video.VideoModeSet;
import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
public class Config {
public VideoModeSet.VideoMode videoMode = VideoModeManager.getFirstAvailable().getVideoMode();
public int windowMode = 0;
public int targetMonitor = 0;
public int advCulling = 2;
public boolean indirectDraw = true;
public boolean uniqueOpaqueLayer = true;
public boolean entityCulling = true;
public int device = -1;
public int ambientOcclusion = 1;
public int frameQueueSize = 2;
public int builderThreads = 0;
public boolean backFaceCulling = true;
public boolean textureAnimations = true;
public void write() {
if(!Files.exists(CONFIG_PATH.getParent())) {
try {
Files.createDirectories(CONFIG_PATH);
} catch (IOException e) {
e.printStackTrace();
}
}
try {
Files.write(CONFIG_PATH, Collections.singleton(GSON.toJson(this)));
} catch (IOException e) {
e.printStackTrace();
}
}
private static Path CONFIG_PATH;
private static final Gson GSON = new GsonBuilder()
.setPrettyPrinting()
.excludeFieldsWithModifiers(Modifier.PRIVATE)
.create();
public static Config load(Path path) {
Config config;
Config.CONFIG_PATH = path;
if (Files.exists(path)) {
try (FileReader fileReader = new FileReader(path.toFile())) {
config = GSON.fromJson(fileReader, Config.class);
}
catch (IOException exception) {
throw new RuntimeException(exception.getMessage());
}
}
else {
config = null;
}
return config;
}
}