Skip to content

Commit 9f73711

Browse files
author
Benjamin Yap
committed
Add config file loading to LWJGLResourceManager
1 parent 92d5d9e commit 9f73711

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/com/bwyap/enginedriver/resource/Resource.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020
* @author bwyap
2121
*
2222
*/
23-
public class Resource {
24-
25-
public static final String RESOURCE_JSON = "/com/bwyap/engine/resource/resources.json";
23+
public class Resource {
2624

2725

2826
public static final String IN_ROOT = "/com/bwyap/enginedriver/";

src/com/bwyap/lwjgl/engine/resource/LWJGLResourceManager.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.io.IOException;
55

66
import com.bwyap.engine.resource.ResourceManagerBase;
7+
import com.bwyap.enginedriver.resource.jsonwrapper.Settings;
78
import com.bwyap.lwjgl.engine.gui.nanovg.NVGFont;
89
import com.bwyap.lwjgl.engine.gui.nanovg.NVGTexture;
910
import com.bwyap.lwjgl.engine.render3d.LWJGLTexture;
@@ -21,10 +22,15 @@
2122
*/
2223
public class LWJGLResourceManager extends ResourceManagerBase {
2324

25+
public static final String RESOURCE_JSON = "/com/bwyap/engine/resource/resources.json";
26+
2427

2528
private static LWJGLResourceManager instance;
2629

2730

31+
private Settings settings;
32+
33+
2834
/**
2935
* Get the resource manager instance
3036
* @return
@@ -76,6 +82,15 @@ public void loadDependentResources() throws Exception {
7682
}
7783

7884

85+
/**
86+
* Get the settings object
87+
* @return
88+
*/
89+
public Settings settings() {
90+
return settings;
91+
}
92+
93+
7994
/*
8095
* ===============
8196
* PRIVATE METHODS
@@ -92,8 +107,12 @@ private void loadFolders() {
92107

93108

94109
private void loadConfig() {
95-
//TODO
96-
//
110+
File configFile = new File(lib.getConfig().get("config_file"));
111+
settings = new Settings(ResourceLoader.loadJSON(configFile));
112+
if (!settings.isValid()) {
113+
ResourceLoader.copyFileFromJar(configFile, null);
114+
settings = new Settings(ResourceLoader.loadJSON(configFile));
115+
}
97116
}
98117

99118

0 commit comments

Comments
 (0)