Comment
This commit is contained in:
parent
32698d48ee
commit
e801c88584
1 changed files with 7 additions and 5 deletions
|
@ -17,10 +17,12 @@ class Config {
|
||||||
val prop = Properties()
|
val prop = Properties()
|
||||||
var fileExists = file.exists()
|
var fileExists = file.exists()
|
||||||
init {
|
init {
|
||||||
//Config Stage
|
//Check if config file exists, if it does, load it
|
||||||
if(fileExists){
|
if(fileExists){
|
||||||
FileInputStream(file).use { prop.load(it) }
|
FileInputStream(file).use { prop.load(it) }
|
||||||
}
|
}
|
||||||
|
//Otherwise create necesssary directories
|
||||||
|
//TODO: Check for directories individually as well?
|
||||||
else{
|
else{
|
||||||
Files.createDirectories(Paths.get("./run"))
|
Files.createDirectories(Paths.get("./run"))
|
||||||
Files.createDirectories(Paths.get("./run/tiles"))
|
Files.createDirectories(Paths.get("./run/tiles"))
|
||||||
|
@ -29,6 +31,7 @@ class Config {
|
||||||
FileInputStream(file).use { prop.load(it) }
|
FileInputStream(file).use { prop.load(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Load config file, and set default properties
|
||||||
FileInputStream(file).use {
|
FileInputStream(file).use {
|
||||||
prop.load(it)
|
prop.load(it)
|
||||||
prop.setProperty("WINDOW_WIDTH", "80")
|
prop.setProperty("WINDOW_WIDTH", "80")
|
||||||
|
@ -37,12 +40,12 @@ class Config {
|
||||||
prop.setProperty("SIDEBAR_WIDTH", "18")
|
prop.setProperty("SIDEBAR_WIDTH", "18")
|
||||||
prop.setProperty("LOG_AREA_HEIGHT", "12")
|
prop.setProperty("LOG_AREA_HEIGHT", "12")
|
||||||
|
|
||||||
|
//Adds comments
|
||||||
val out: OutputStream = FileOutputStream(file)
|
val out: OutputStream = FileOutputStream(file)
|
||||||
prop.store(out, "some comment")
|
prop.store(out, "PotRogue Configuartion File, restart game if changed value.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//SET ALL PROPERTIES
|
//Convert values from the config file to in-code variables, so we can use them later, also make them public.
|
||||||
val WINDOW_WIDTH: Int = (prop.getProperty("WINDOW_WIDTH")).toInt()
|
val WINDOW_WIDTH: Int = (prop.getProperty("WINDOW_WIDTH")).toInt()
|
||||||
|
|
||||||
val WINDOW_HEIGHT: Int = (prop.getProperty("WINDOW_HEIGHT")).toInt()
|
val WINDOW_HEIGHT: Int = (prop.getProperty("WINDOW_HEIGHT")).toInt()
|
||||||
|
@ -52,5 +55,4 @@ class Config {
|
||||||
val SIDEBAR_WIDTH: Int = (prop.getProperty("SIDEBAR_WIDTH")).toInt()
|
val SIDEBAR_WIDTH: Int = (prop.getProperty("SIDEBAR_WIDTH")).toInt()
|
||||||
|
|
||||||
val LOG_AREA_HEIGHT: Int = (prop.getProperty("LOG_AREA_HEIGHT")).toInt()
|
val LOG_AREA_HEIGHT: Int = (prop.getProperty("LOG_AREA_HEIGHT")).toInt()
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue