This commit is contained in:
nelle 2023-10-29 14:23:14 -06:00
parent 8c51e43e79
commit 34f9b418ff

View file

@ -9,15 +9,13 @@ import java.nio.file.Path
import java.nio.file.Paths import java.nio.file.Paths
import java.util.* import java.util.*
val file = File("./run/conf.properties")
val prop = Properties()
//TODO: make them variables work :( //TODO: make them variables work :(
//init values
public val winW = prop.getProperty("winWidth")
//public val WINDOW_WIDTH = winW.toInt()
class Config { class Config {
val file = File("./run/potrogue.conf")
val prop = Properties()
var fileExists = file.exists() var fileExists = file.exists()
init { init {
//Config Stage //Config Stage
@ -26,13 +24,13 @@ class Config {
} }
else{ else{
Files.createDirectories(Paths.get("./run")) Files.createDirectories(Paths.get("./run"))
Files.createFile(Path.of("./run/conf.properties")) Files.createFile(Path.of("./run/potrogue.conf"))
FileInputStream(file).use { prop.load(it) } FileInputStream(file).use { prop.load(it) }
} }
FileInputStream(file).use { FileInputStream(file).use {
prop.load(it) prop.load(it)
prop.setProperty("winWidth", "80") prop.setProperty("WINDOW_WIDTH", "80")
prop.setProperty("WINDOW_HEIGHT", "50") prop.setProperty("WINDOW_HEIGHT", "50")
val out: OutputStream = FileOutputStream(file) val out: OutputStream = FileOutputStream(file)
@ -44,6 +42,4 @@ class Config {
.associateWith {prop.getProperty(it)} .associateWith {prop.getProperty(it)}
.forEach { println(it) } .forEach { println(it) }
} }
val winW = prop.getProperty("winWidth")
} }