mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
pushing Return on World Selection will bring you to the Character Selection (and the implementation is quite dirty I might say)
This commit is contained in:
@@ -87,5 +87,5 @@ class IMEDictionary(private val filename: String) {
|
||||
|
||||
return if (out.isNotEmpty()) out.substring(1) else ""
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -18,14 +18,17 @@ import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.App.printdbg
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull.Companion.CELL_COL
|
||||
import net.torvald.terrarum.serialise.Common
|
||||
import net.torvald.terrarum.serialise.LoadSavegame
|
||||
import net.torvald.terrarum.serialise.ReadPlayer
|
||||
import net.torvald.terrarum.savegame.ByteArray64InputStream
|
||||
import net.torvald.terrarum.savegame.ByteArray64Reader
|
||||
import net.torvald.terrarum.savegame.DiskSkimmer
|
||||
import net.torvald.terrarum.savegame.EntryFile
|
||||
import net.torvald.terrarum.ui.*
|
||||
import net.torvald.terrarum.serialise.Common
|
||||
import net.torvald.terrarum.serialise.LoadSavegame
|
||||
import net.torvald.terrarum.serialise.ReadPlayer
|
||||
import net.torvald.terrarum.ui.Movement
|
||||
import net.torvald.terrarum.ui.Toolkit
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.ui.UIItem
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import java.time.Instant
|
||||
import java.time.format.DateTimeFormatter
|
||||
@@ -179,13 +182,33 @@ class UILoadDemoSavefiles(val remoCon: UIRemoCon) : UICanvas() {
|
||||
}
|
||||
|
||||
private fun getCells() = if (mode == 0) playerCells else worldCells
|
||||
private val menuTree = arrayOf(UITitleRemoConYaml.injectedMenuSingleCharSel, UITitleRemoConYaml.injectedMenuSingleWorldSel).map { Yaml(it).parse() }
|
||||
private var loadFired = 0
|
||||
private var oldMode = -1
|
||||
private val remoConParentNode = remoCon.currentRemoConContents
|
||||
|
||||
private val mode1Node = Yaml(UITitleRemoConYaml.injectedMenuSingleCharSel).parse()
|
||||
private val mode2Node = Yaml(UITitleRemoConYaml.injectedMenuSingleWorldSel).parse()
|
||||
|
||||
private val menus = listOf(mode1Node, mode2Node)
|
||||
|
||||
init {
|
||||
// this UI will NOT persist; the parent of the mode1Node must be set using an absolute value (e.g. treeRoot, not remoCon.currentRemoConContents)
|
||||
|
||||
//printdbg(this, "UILoadDemoSaveFiles called, from:")
|
||||
//printStackTrace(this)
|
||||
|
||||
mode1Node.parent = remoCon.treeRoot
|
||||
mode2Node.parent = mode1Node
|
||||
|
||||
mode1Node.data = "MENU_MODE_SINGLEPLAYER+NODISPOSE : net.torvald.terrarum.modulebasegame.ui.UILoadDemoSavefiles"
|
||||
mode2Node.data = "MENU_MODE_SINGLEPLAYER+NODISPOSE : net.torvald.terrarum.modulebasegame.ui.UILoadDemoSavefiles"
|
||||
|
||||
printdbg(this, "mode1Node parent: ${mode1Node.parent?.data}") // will be 'null' because the parent is the root node
|
||||
printdbg(this, "mode1Node data: ${mode1Node.data}")
|
||||
printdbg(this, "mode2Node data: ${mode2Node.data}")
|
||||
}
|
||||
|
||||
private fun modeChangedHandler(mode: Int) {
|
||||
remoCon.setNewRemoConContents(menuTree[mode], remoConParentNode)
|
||||
remoCon.setNewRemoConContents(menus[mode])
|
||||
}
|
||||
|
||||
override fun updateUI(delta: Float) {
|
||||
|
||||
@@ -17,13 +17,13 @@ import net.torvald.terrarum.ui.UIItemTextButtonList.Companion.DEFAULT_LINE_HEIGH
|
||||
/**
|
||||
* Created by minjaesong on 2018-08-29.
|
||||
*/
|
||||
open class UIRemoCon(val parent: TitleScreen, treeRepresentation: QNDTreeNode<String>) : UICanvas() {
|
||||
open class UIRemoCon(val parent: TitleScreen, val treeRoot: QNDTreeNode<String>) : UICanvas() {
|
||||
|
||||
override var openCloseTime = 0f
|
||||
|
||||
private var remoConTray: UIRemoConElement // this remocon is dynamically generated
|
||||
var currentRemoConContents = treeRepresentation; private set
|
||||
private var currentlySelectedRemoConItem = treeRepresentation.data
|
||||
var currentRemoConContents = treeRoot; private set
|
||||
private var currentlySelectedRemoConItem = treeRoot.data
|
||||
|
||||
override var width: Int
|
||||
get() = remoConWidth // somehow NOT making this constant causes a weird issue
|
||||
@@ -40,7 +40,7 @@ open class UIRemoCon(val parent: TitleScreen, treeRepresentation: QNDTreeNode<St
|
||||
init {
|
||||
remoConTray = generateNewRemoCon(currentRemoConContents)
|
||||
|
||||
registerUIclasses(treeRepresentation)
|
||||
registerUIclasses(treeRoot)
|
||||
}
|
||||
|
||||
private fun registerUIclasses(tree: QNDTreeNode<String>) {
|
||||
@@ -49,6 +49,7 @@ open class UIRemoCon(val parent: TitleScreen, treeRepresentation: QNDTreeNode<St
|
||||
|
||||
if (splittedNodeName?.size == 2 && node.data != null) {
|
||||
try {
|
||||
val tag = splittedNodeName[0].split(tagSep).getOrNull(1)
|
||||
val attachedClass = loadClass(splittedNodeName[1]) // check existence
|
||||
screenNames[node.data!!] = splittedNodeName[1] // actual loading will by dynamic as some UIs need to be re-initialised as they're called
|
||||
}
|
||||
@@ -100,6 +101,7 @@ open class UIRemoCon(val parent: TitleScreen, treeRepresentation: QNDTreeNode<St
|
||||
val tag = it.tags
|
||||
if (tag.contains("WRITETOCONFIG")) WriteConfig()
|
||||
|
||||
print("[UIRemoCon] Returning from ${currentRemoConContents.data}")
|
||||
|
||||
if (currentRemoConContents.parent != null) {
|
||||
remoConTray.consume()
|
||||
@@ -109,6 +111,8 @@ open class UIRemoCon(val parent: TitleScreen, treeRepresentation: QNDTreeNode<St
|
||||
remoConTray = generateNewRemoCon(currentRemoConContents)
|
||||
|
||||
parent.uiFakeBlurOverlay.setAsClose()
|
||||
|
||||
println(" to ${currentlySelectedRemoConItem}")
|
||||
}
|
||||
else {
|
||||
throw NullPointerException("No parent node to return")
|
||||
@@ -130,17 +134,7 @@ open class UIRemoCon(val parent: TitleScreen, treeRepresentation: QNDTreeNode<St
|
||||
|
||||
// do something with the actual selection
|
||||
//printdbg(this, "$currentlySelectedRemoConItem")
|
||||
openUI?.setAsClose()
|
||||
openUI?.dispose()
|
||||
|
||||
printdbg(this, "$currentlySelectedRemoConItem has screen: ${screenNames.containsKey(currentlySelectedRemoConItem)}")
|
||||
screenNames[currentlySelectedRemoConItem]?.let {
|
||||
val ui = loadClass(it)
|
||||
ui.setPosition(0,0)
|
||||
parent.uiFakeBlurOverlay.setAsOpen()
|
||||
ui.setAsOpen()
|
||||
openUI = ui
|
||||
}
|
||||
openUI(currentlySelectedRemoConItem)
|
||||
} }
|
||||
}
|
||||
|
||||
@@ -159,10 +153,13 @@ open class UIRemoCon(val parent: TitleScreen, treeRepresentation: QNDTreeNode<St
|
||||
|
||||
fun setNewRemoConContents(newCurrentRemoConContents: QNDTreeNode<String>, forceSetParent: QNDTreeNode<String>? = null) {
|
||||
|
||||
printdbg(this, "setting new remocon contents: ${newCurrentRemoConContents.data}")
|
||||
|
||||
if (forceSetParent != null) {
|
||||
newCurrentRemoConContents.parent = forceSetParent
|
||||
}
|
||||
|
||||
|
||||
// only go deeper if that node has child to navigate
|
||||
if (newCurrentRemoConContents.children.size != 0) {
|
||||
remoConTray.consume()
|
||||
@@ -175,6 +172,23 @@ open class UIRemoCon(val parent: TitleScreen, treeRepresentation: QNDTreeNode<St
|
||||
currentlySelectedRemoConItem = newCurrentRemoConContents.data
|
||||
}
|
||||
|
||||
fun openUI(menuString: String?) {
|
||||
openUI?.let {
|
||||
it.setAsClose()
|
||||
it.dispose()
|
||||
}
|
||||
|
||||
|
||||
printdbg(this, "$menuString has screen: ${screenNames.containsKey(menuString)}")
|
||||
screenNames[menuString]?.let {
|
||||
val ui = loadClass(it)
|
||||
ui.setPosition(0,0)
|
||||
parent.uiFakeBlurOverlay.setAsOpen()
|
||||
ui.setAsOpen()
|
||||
openUI = ui
|
||||
}
|
||||
}
|
||||
|
||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||
remoConTray.render(batch, camera)
|
||||
openUI?.render(batch, camera)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.torvald.terrarum.ui
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.utils.Disposable
|
||||
@@ -295,7 +294,7 @@ abstract class UICanvas(
|
||||
// end of handler func aliases
|
||||
|
||||
init {
|
||||
if (uiItems.isEmpty()) println("UICanvas '${this.javaClass.name}' has no UIItem registered, just so you know...")
|
||||
// if (uiItems.isEmpty()) println("UICanvas '${this.javaClass.name}' has no UIItem registered, just so you know...")
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
Reference in New Issue
Block a user