mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-14 20:44:05 +09:00
super rudimentary mod config
This commit is contained in:
0
assets/mods/basegame/configplan.csv
Normal file
0
assets/mods/basegame/configplan.csv
Normal file
|
|
@@ -15,6 +15,7 @@ import net.torvald.terrarum.gameitems.ItemID
|
|||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.itemproperties.MaterialCodex
|
import net.torvald.terrarum.itemproperties.MaterialCodex
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
|
import net.torvald.terrarum.serialise.Common
|
||||||
import net.torvald.terrarum.utils.CSVFetcher
|
import net.torvald.terrarum.utils.CSVFetcher
|
||||||
import net.torvald.terrarum.utils.JsonFetcher
|
import net.torvald.terrarum.utils.JsonFetcher
|
||||||
import net.torvald.terrarum.utils.forEachSiblings
|
import net.torvald.terrarum.utils.forEachSiblings
|
||||||
@@ -67,8 +68,10 @@ object ModMgr {
|
|||||||
val version: String,
|
val version: String,
|
||||||
val jar: String,
|
val jar: String,
|
||||||
val dependencies: Array<String>,
|
val dependencies: Array<String>,
|
||||||
val isInternal: Boolean
|
val isInternal: Boolean,
|
||||||
|
val configPlan: List<String>
|
||||||
) {
|
) {
|
||||||
|
|
||||||
override fun toString() =
|
override fun toString() =
|
||||||
"\tModule #$order -- $properName | $version | $author\n" +
|
"\tModule #$order -- $properName | $version | $author\n" +
|
||||||
"\t$description | $releaseDate\n" +
|
"\t$description | $releaseDate\n" +
|
||||||
@@ -192,7 +195,14 @@ object ModMgr {
|
|||||||
val dependency = modMetadata.getProperty("dependency").split(Regex(""";[ ]*""")).filter { it.isNotEmpty() }.toTypedArray()
|
val dependency = modMetadata.getProperty("dependency").split(Regex(""";[ ]*""")).filter { it.isNotEmpty() }.toTypedArray()
|
||||||
val isDir = FileSystems.getDefault().getPath("$modDir/$moduleName").toFile().isDirectory
|
val isDir = FileSystems.getDefault().getPath("$modDir/$moduleName").toFile().isDirectory
|
||||||
|
|
||||||
module = ModuleMetadata(index, isDir, getGdxFile("$modDir/$moduleName/icon.png"), properName, description, descTranslations, author, packageName, entryPoint, releaseDate, version, jar, dependency, isInternal)
|
val configPlan = ArrayList<String>()
|
||||||
|
File("$modDirInternal/$moduleName/configplan.csv").let {
|
||||||
|
if (it.exists() && it.isFile) {
|
||||||
|
configPlan.addAll(it.readLines(Common.CHARSET).filter { it.isNotBlank() })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module = ModuleMetadata(index, isDir, getGdxFile("$modDir/$moduleName/icon.png"), properName, description, descTranslations, author, packageName, entryPoint, releaseDate, version, jar, dependency, isInternal, configPlan)
|
||||||
|
|
||||||
val versionNumeral = version.split('.')
|
val versionNumeral = version.split('.')
|
||||||
val versionNumber = versionNumeral.toVersionNumber()
|
val versionNumber = versionNumeral.toVersionNumber()
|
||||||
|
|||||||
@@ -1,10 +1,16 @@
|
|||||||
package net.torvald.terrarum
|
package net.torvald.terrarum
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Camera
|
import com.badlogic.gdx.graphics.Camera
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.graphics.OrthographicCamera
|
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
|
import net.torvald.terrarum.langpack.Lang
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.ControlPanelCommon
|
||||||
|
import net.torvald.terrarum.modulebasegame.ui.ControlPanelOptions
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIRemoCon
|
import net.torvald.terrarum.modulebasegame.ui.UIRemoCon
|
||||||
|
import net.torvald.terrarum.ui.Toolkit
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
|
import net.torvald.unicode.TIMES
|
||||||
|
|
||||||
class ModOptionsHost(val remoCon: UIRemoCon) : UICanvas() {
|
class ModOptionsHost(val remoCon: UIRemoCon) : UICanvas() {
|
||||||
init {
|
init {
|
||||||
@@ -17,10 +23,46 @@ class ModOptionsHost(val remoCon: UIRemoCon) : UICanvas() {
|
|||||||
override var width = App.scr.width - UIRemoCon.remoConWidth - moduleAreaHMargin
|
override var width = App.scr.width - UIRemoCon.remoConWidth - moduleAreaHMargin
|
||||||
override var height = App.scr.height - moduleAreaHMargin * 2
|
override var height = App.scr.height - moduleAreaHMargin * 2
|
||||||
|
|
||||||
|
init {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private var currentlySelectedModule = "basegame"
|
||||||
|
|
||||||
|
override fun show() {
|
||||||
|
super.show()
|
||||||
|
|
||||||
|
makeConfig(currentlySelectedModule)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun makeConfig(modname: String) {
|
||||||
|
val mod = ModMgr.moduleInfo[modname]!!
|
||||||
|
if (mod.configPlan.isEmpty()) return
|
||||||
|
|
||||||
|
val modOptions: ControlPanelOptions = mod.configPlan.map {
|
||||||
|
val options = it.split("->")
|
||||||
|
val labelfun = if (options[1].startsWith("Lang:")) {
|
||||||
|
{ Lang[options[1].substringAfter(":")] }
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
{ options[1] }
|
||||||
|
}
|
||||||
|
arrayOf("$modname:${options[0]}", labelfun, options[2])
|
||||||
|
}.toTypedArray()
|
||||||
|
|
||||||
|
ControlPanelCommon.register(this, width, "basegame.modcontrolpanel.$modname", modOptions)
|
||||||
|
}
|
||||||
|
|
||||||
override fun updateUI(delta: Float) {
|
override fun updateUI(delta: Float) {
|
||||||
|
uiItems.forEach { it.update(delta) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
|
override fun renderUI(batch: SpriteBatch, camera: OrthographicCamera) {
|
||||||
|
// TODO draw currently editing mod name
|
||||||
|
|
||||||
|
ControlPanelCommon.render("basegame.modcontrolpanel.$currentlySelectedModule", width, batch)
|
||||||
|
uiItems.forEach { it.render(batch, camera) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
|
|||||||
Reference in New Issue
Block a user