title remocon: menu UI with no child should be displayed now

This commit is contained in:
minjaesong
2018-09-15 01:08:10 +09:00
parent 6d4ac92133
commit 69eb2d7a3b
17 changed files with 146 additions and 96 deletions

View File

@@ -1,5 +1,7 @@
package net.torvald.terrarum.modulebasegame
import net.torvald.terrarum.AppLoader.IS_DEVELOPMENT_BUILD
import net.torvald.terrarum.AppLoader.printdbg
import net.torvald.terrarum.Point2d
import net.torvald.terrarum.ModMgr
import net.torvald.terrarum.ModuleEntryPoint
@@ -26,7 +28,7 @@ class EntryPoint : ModuleEntryPoint() {
// load customised item loader //
/////////////////////////////////
println("[ModuleBaseGame.EntryPoint] recording item ID ")
printdbg(this, "recording item ID ")
// blocks.csvs are loaded by ModMgr beforehand
// block items (blocks and walls are the same thing basically)
@@ -45,7 +47,8 @@ class EntryPoint : ModuleEntryPoint() {
override val material = Material(0,0,0,0,0,0,0,0,0,0.0)
init {
print("$originalID ")
if (IS_DEVELOPMENT_BUILD)
print("$originalID ")
}
override fun primaryUse(delta: Float): Boolean {

View File

@@ -26,6 +26,7 @@ import java.util.concurrent.locks.ReentrantLock
import net.torvald.random.HQRNG
import net.torvald.terrarum.*
import net.torvald.terrarum.AppLoader.printdbg
import net.torvald.terrarum.modulebasegame.console.AVTracker
import net.torvald.terrarum.modulebasegame.console.ActorsList
import net.torvald.terrarum.console.Authenticator
@@ -193,7 +194,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
*/
private fun enter(gameSaveData: GameSaveData) {
if (gameInitialised) {
println("[Ingame] loaded successfully.")
printdbg(this, "loaded successfully.")
}
else {
LoadScreen.addMessage("Loading world from save")
@@ -221,7 +222,7 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
*/
private fun enter(worldParams: NewWorldParameters) {
if (gameInitialised) {
println("[Ingame] loaded successfully.")
printdbg(this, "loaded successfully.")
}
else {
LoadScreen.addMessage("${Terrarum.NAME} version ${AppLoader.getVERSION_STRING()}")

View File

@@ -5,6 +5,8 @@ import com.badlogic.gdx.Input
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.AppLoader.printdbg
import net.torvald.terrarum.AppLoader.printdbgerr
import net.torvald.terrarum.Second
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.ui.UICanvas
@@ -22,6 +24,7 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode<String>) : UICanvas() {
private var remoConTray: UIRemoConElement // this remocon is dynamically generated
private var currentRemoConContents = treeRepresentation
private var currentlySelectedRemoConItem = treeRepresentation.data
override var width: Int
get() = remoConWidth // somehow NOT making this constant causes a weird issue
@@ -41,12 +44,17 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode<String>) : UICanvas() {
val splittedNodeName = node.data?.split(yamlSep)
if (splittedNodeName?.size == 2) {
val attachedClass = loadClass(splittedNodeName[1])
try {
val attachedClass = loadClass(splittedNodeName[1])
attachedClass.posX = 0
attachedClass.posY = 0
attachedClass.posX = 0
attachedClass.posY = 0
screens.add((node.data ?: "(null)") to attachedClass)
screens.add((node.data ?: "(null)") to attachedClass)
}
catch (e: java.lang.ClassNotFoundException) {
printdbgerr(this, "class '${splittedNodeName[1]}' was not found, skipping")
}
}
}
}
@@ -85,6 +93,7 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode<String>) : UICanvas() {
remoConTray.consume()
currentRemoConContents = currentRemoConContents.parent!!
currentlySelectedRemoConItem = currentRemoConContents.data
remoConTray = generateNewRemoCon(currentRemoConContents)
}
else {
@@ -98,12 +107,17 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode<String>) : UICanvas() {
if (currentRemoConContents.children.size > selectedIndex ?: 0x7FFFFFFF) {
val newCurrentRemoConContents = currentRemoConContents.children[selectedIndex!!]
// only go deeper if that node has child to navigate
if (currentRemoConContents.children[selectedIndex!!].children.size != 0) {
remoConTray.consume()
currentRemoConContents = currentRemoConContents.children[selectedIndex!!]
remoConTray = generateNewRemoCon(currentRemoConContents)
remoConTray = generateNewRemoCon(newCurrentRemoConContents)
currentRemoConContents = newCurrentRemoConContents
}
currentlySelectedRemoConItem = newCurrentRemoConContents.data
}
else {
throw RuntimeException("Index: $selectedIndex, Size: ${currentRemoConContents.children.size}")
@@ -112,23 +126,32 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode<String>) : UICanvas() {
// do something with the actual selection
println(currentRemoConContents.data)
//printdbg(this, "$currentlySelectedRemoConItem")
screens.forEach {
if (currentRemoConContents.data == it.first) {
//printdbg(this, "> ${it.first}")
if (currentlySelectedRemoConItem == it.first) {
it.second.setAsOpen()
//printdbg(this, ">> ding - ${it.second.javaClass.canonicalName}")
}
else {
it.second.setAsClose()
}
it.second.update(delta) // update is required anyway
// but this is not updateUI, so whenever the UI is completely hidden,
// underlying handler will block any update until the UI is open again
}
}
screens.forEach {
it.second.update(delta) // update is required anyway
// but this is not updateUI, so whenever the UI is completely hidden,
// underlying handler will block any update until the UI is open again
}
if (!Gdx.input.isButtonPressed(Input.Buttons.LEFT)) {
mouseActionAvailable = true
}
@@ -138,9 +161,7 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode<String>) : UICanvas() {
remoConTray.render(batch, camera)
screens.forEach {
if (currentRemoConContents.data == it.first) {
it.second.render(batch, camera) // again, underlying handler will block unnecessary renders
}
it.second.render(batch, camera) // again, underlying handler will block unnecessary renders
}
}
@@ -166,9 +187,7 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode<String>) : UICanvas() {
override fun mouseMoved(screenX: Int, screenY: Int): Boolean {
screens.forEach {
if (currentRemoConContents.data == it.first) {
it.second.mouseMoved(screenX, screenY) // again, underlying handler will block unnecessary renders
}
it.second.mouseMoved(screenX, screenY) // again, underlying handler will block unnecessary renders
}
return true
@@ -176,9 +195,7 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode<String>) : UICanvas() {
override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean {
screens.forEach {
if (currentRemoConContents.data == it.first) {
it.second.touchDragged(screenX, screenY, pointer) // again, underlying handler will block unnecessary renders
}
it.second.touchDragged(screenX, screenY, pointer) // again, underlying handler will block unnecessary renders
}
return true
@@ -186,9 +203,7 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode<String>) : UICanvas() {
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
screens.forEach {
if (currentRemoConContents.data == it.first) {
it.second.touchDown(screenX, screenY, pointer, button) // again, underlying handler will block unnecessary renders
}
it.second.touchDown(screenX, screenY, pointer, button) // again, underlying handler will block unnecessary renders
}
return true
@@ -196,9 +211,7 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode<String>) : UICanvas() {
override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
screens.forEach {
if (currentRemoConContents.data == it.first) {
it.second.touchUp(screenX, screenY, pointer, button) // again, underlying handler will block unnecessary renders
}
it.second.touchUp(screenX, screenY, pointer, button) // again, underlying handler will block unnecessary renders
}
return true
@@ -206,9 +219,7 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode<String>) : UICanvas() {
override fun scrolled(amount: Int): Boolean {
screens.forEach {
if (currentRemoConContents.data == it.first) {
it.second.scrolled(amount) // again, underlying handler will block unnecessary renders
}
it.second.scrolled(amount) // again, underlying handler will block unnecessary renders
}
return true
@@ -216,9 +227,7 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode<String>) : UICanvas() {
override fun keyDown(keycode: Int): Boolean {
screens.forEach {
if (currentRemoConContents.data == it.first) {
it.second.keyDown(keycode) // again, underlying handler will block unnecessary renders
}
it.second.keyDown(keycode) // again, underlying handler will block unnecessary renders
}
return true
@@ -226,9 +235,7 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode<String>) : UICanvas() {
override fun keyUp(keycode: Int): Boolean {
screens.forEach {
if (currentRemoConContents.data == it.first) {
it.second.keyUp(keycode) // again, underlying handler will block unnecessary renders
}
it.second.keyUp(keycode) // again, underlying handler will block unnecessary renders
}
return true
@@ -236,9 +243,7 @@ open class UIRemoCon(treeRepresentation: QNDTreeNode<String>) : UICanvas() {
override fun keyTyped(character: Char): Boolean {
screens.forEach {
if (currentRemoConContents.data == it.first) {
it.second.keyTyped(character) // again, underlying handler will block unnecessary renders
}
it.second.keyTyped(character) // again, underlying handler will block unnecessary renders
}
return true

View File

@@ -59,7 +59,8 @@ class UITitleLanguage : UICanvas() {
override fun updateUI(delta: Float) {
textArea.update(delta)
println("should be printing indefinitely")
//AppLoader.printdbg(this, "should be printing indefinitely")
}
override fun renderUI(batch: SpriteBatch, camera: Camera) {

View File

@@ -3,6 +3,7 @@ package net.torvald.terrarum.modulebasegame.ui
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.AppLoader
import net.torvald.terrarum.CreditSingleton
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.Second
@@ -10,7 +11,7 @@ import net.torvald.terrarum.ui.UICanvas
import net.torvald.terrarum.ui.UIItemTextArea
import net.torvald.terrarum.ui.UIItemTextButtonList
open class UITitleWallOfText(text: List<String>) : UICanvas() {
open class UITitleWallOfText(private val text: List<String>) : UICanvas() {
override var openCloseTime: Second = 0f
@@ -37,6 +38,8 @@ open class UITitleWallOfText(text: List<String>) : UICanvas() {
override fun renderUI(batch: SpriteBatch, camera: Camera) {
batch.color = Color.WHITE
textArea.render(batch, camera)
//AppLoader.printdbg(this, "Rendering texts of length ${text.size}")
}
override fun doOpening(delta: Float) {