mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 12:04:06 +09:00
load ui to inject remoCon contents to implement its own submenus
This commit is contained in:
@@ -59,8 +59,8 @@ open class UIRemoCon(val parent: TitleScreen, treeRepresentation: QNDTreeNode<St
|
||||
|
||||
private fun loadClass(name: String): UICanvas {
|
||||
val newClass = Class.forName(name)
|
||||
val newClassConstructor = newClass.getConstructor(/* no args defined */)
|
||||
val newClassInstance = newClassConstructor.newInstance(/* no args defined */)
|
||||
val newClassConstructor = newClass.getConstructor(this.javaClass)
|
||||
val newClassInstance = newClassConstructor.newInstance(this)
|
||||
return newClassInstance as UICanvas
|
||||
}
|
||||
|
||||
@@ -118,18 +118,7 @@ open class UIRemoCon(val parent: TitleScreen, treeRepresentation: QNDTreeNode<St
|
||||
//currentRemoConContents.children.forEach { println("- ${it.data}") }
|
||||
|
||||
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()
|
||||
remoConTray = generateNewRemoCon(newCurrentRemoConContents)
|
||||
currentRemoConContents = newCurrentRemoConContents
|
||||
}
|
||||
|
||||
currentlySelectedRemoConItem = newCurrentRemoConContents.data
|
||||
setNewRemoConContents(currentRemoConContents.children[selectedIndex!!])
|
||||
}
|
||||
else {
|
||||
throw RuntimeException("Index: $selectedIndex, Size: ${currentRemoConContents.children.size}")
|
||||
@@ -165,6 +154,22 @@ open class UIRemoCon(val parent: TitleScreen, treeRepresentation: QNDTreeNode<St
|
||||
}
|
||||
}
|
||||
|
||||
fun setNewRemoConContents(newCurrentRemoConContents: QNDTreeNode<String>, forceSetParent: QNDTreeNode<String>? = null) {
|
||||
|
||||
if (forceSetParent != null) {
|
||||
newCurrentRemoConContents.parent = forceSetParent
|
||||
}
|
||||
|
||||
// only go deeper if that node has child to navigate
|
||||
if (newCurrentRemoConContents.children.size != 0) {
|
||||
remoConTray.consume()
|
||||
remoConTray = generateNewRemoCon(newCurrentRemoConContents)
|
||||
currentRemoConContents = newCurrentRemoConContents
|
||||
}
|
||||
|
||||
currentlySelectedRemoConItem = newCurrentRemoConContents.data
|
||||
}
|
||||
|
||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||
remoConTray.render(batch, camera)
|
||||
openUI?.render(batch, camera)
|
||||
|
||||
Reference in New Issue
Block a user