mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 02:24:05 +09:00
resize screen really needs full game restart...
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.ui
|
package net.torvald.terrarum.modulebasegame.ui
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
import com.badlogic.gdx.graphics.Camera
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
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
|
||||||
@@ -13,6 +12,7 @@ import net.torvald.terrarum.Yaml
|
|||||||
import net.torvald.terrarum.gamecontroller.TerrarumKeyboardEvent
|
import net.torvald.terrarum.gamecontroller.TerrarumKeyboardEvent
|
||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.modulebasegame.TitleScreen
|
import net.torvald.terrarum.modulebasegame.TitleScreen
|
||||||
|
import net.torvald.terrarum.serialise.TryResize
|
||||||
import net.torvald.terrarum.serialise.WriteConfig
|
import net.torvald.terrarum.serialise.WriteConfig
|
||||||
import net.torvald.terrarum.ui.Toolkit
|
import net.torvald.terrarum.ui.Toolkit
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
@@ -81,7 +81,10 @@ open class UIRemoCon(val parent: TitleScreen, val treeRoot: QNDTreeNode<String>)
|
|||||||
|
|
||||||
private fun generateNewRemoCon(node: QNDTreeNode<String>): UIRemoConElement {
|
private fun generateNewRemoCon(node: QNDTreeNode<String>): UIRemoConElement {
|
||||||
val labels = Array(node.children.size) { node.children[it].data?.split(yamlSep)?.get(0)?.split(tagSep)?.get(0) ?: "(null)" }
|
val labels = Array(node.children.size) { node.children[it].data?.split(yamlSep)?.get(0)?.split(tagSep)?.get(0) ?: "(null)" }
|
||||||
val tags = Array(node.children.size) { arrayOf(node.children[it].data?.split(yamlSep)?.get(0)?.split(tagSep)?.getOrNull(1) ?: "") }
|
val tags = Array(node.children.size) { node.children[it].data?.split(yamlSep)?.get(0)?.split(tagSep).let {
|
||||||
|
if (it.isNullOrEmpty() || it.size < 2) emptyArray<String>()
|
||||||
|
else it.subList(1, it.size).toTypedArray()
|
||||||
|
} }
|
||||||
currentRemoConLabelCount = labels.size
|
currentRemoConLabelCount = labels.size
|
||||||
return UIRemoConElement(this, labels, tags)
|
return UIRemoConElement(this, labels, tags)
|
||||||
}
|
}
|
||||||
@@ -112,7 +115,9 @@ open class UIRemoCon(val parent: TitleScreen, val treeRoot: QNDTreeNode<String>)
|
|||||||
}
|
}
|
||||||
else if (it.textfun() == Lang["MENU_LABEL_RETURN"]) {
|
else if (it.textfun() == Lang["MENU_LABEL_RETURN"]) {
|
||||||
val tag = it.tags
|
val tag = it.tags
|
||||||
|
if (tag.contains("RESIZEIFNEEDED")) TryResize.pre()
|
||||||
if (tag.contains("WRITETOCONFIG")) WriteConfig()
|
if (tag.contains("WRITETOCONFIG")) WriteConfig()
|
||||||
|
if (tag.contains("RESIZEIFNEEDED")) TryResize()
|
||||||
|
|
||||||
if (IS_DEVELOPMENT_BUILD) print("[UIRemoCon] Returning from ${currentRemoConContents.data}")
|
if (IS_DEVELOPMENT_BUILD) print("[UIRemoCon] Returning from ${currentRemoConContents.data}")
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ object UITitleRemoConYaml {
|
|||||||
- MENU_LABEL_LANGUAGE : net.torvald.terrarum.modulebasegame.ui.UITitleLanguage
|
- MENU_LABEL_LANGUAGE : net.torvald.terrarum.modulebasegame.ui.UITitleLanguage
|
||||||
- CREDITS_GAME : net.torvald.terrarum.ModOptionsHost
|
- CREDITS_GAME : net.torvald.terrarum.ModOptionsHost
|
||||||
- GAME_GENRE_MISC : net.torvald.terrarum.modulebasegame.ui.UIPerformanceControlPanel
|
- GAME_GENRE_MISC : net.torvald.terrarum.modulebasegame.ui.UIPerformanceControlPanel
|
||||||
- MENU_LABEL_RETURN+WRITETOCONFIG
|
- MENU_LABEL_RETURN+WRITETOCONFIG+RESIZEIFNEEDED
|
||||||
- MENU_MODULES : net.torvald.terrarum.modulebasegame.ui.UITitleModules
|
- MENU_MODULES : net.torvald.terrarum.modulebasegame.ui.UITitleModules
|
||||||
- MENU_LABEL_RETURN
|
- MENU_LABEL_RETURN
|
||||||
- MENU_LABEL_CREDITS
|
- MENU_LABEL_CREDITS
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.badlogic.gdx.utils.JsonValue
|
|||||||
import com.badlogic.gdx.utils.JsonWriter
|
import com.badlogic.gdx.utils.JsonWriter
|
||||||
import net.torvald.terrarum.App
|
import net.torvald.terrarum.App
|
||||||
import net.torvald.terrarum.KVHashMap
|
import net.torvald.terrarum.KVHashMap
|
||||||
|
import net.torvald.terrarum.Principii
|
||||||
import net.torvald.terrarum.utils.JsonFetcher
|
import net.torvald.terrarum.utils.JsonFetcher
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,4 +67,41 @@ object WriteConfig {
|
|||||||
writer.close()
|
writer.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 2024-02-17.
|
||||||
|
*/
|
||||||
|
object TryResize {
|
||||||
|
private val gameConfig = KVHashMap()
|
||||||
|
|
||||||
|
private var doResize = false
|
||||||
|
|
||||||
|
fun pre() {
|
||||||
|
// read from disk and build config from it
|
||||||
|
val oldJsonMap = JsonFetcher.invoke(App.configDir)
|
||||||
|
// make config
|
||||||
|
var entry: JsonValue? = oldJsonMap.child
|
||||||
|
while (entry != null) {
|
||||||
|
setToGameConfigForced(entry, null)
|
||||||
|
entry = entry.next
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// check for discrepancy
|
||||||
|
listOf("screenwidth", "screenheight").forEach {
|
||||||
|
if (gameConfig.getAsInt(it) != App.getConfigInt(it))
|
||||||
|
doResize = doResize or true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setToGameConfigForced(value: JsonValue, modName: String?) {
|
||||||
|
gameConfig[if ((modName == null)) value.name else modName + ":" + value.name] =
|
||||||
|
if (value.isArray) value.asDoubleArray() else if (value.isDouble) value.asDouble() else if (value.isBoolean) value.asBoolean() else if (value.isLong) value.asInt() else value.asString()
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun invoke() {
|
||||||
|
// it just wouldn't work, the only way to make it work will be calling game restart from the launcher
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user