mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-06 08:38:30 +09:00
NSMenu WIP
This commit is contained in:
@@ -8,6 +8,7 @@ import net.torvald.terrarum.IngameInstance
|
|||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
import net.torvald.terrarum.blockproperties.Block
|
import net.torvald.terrarum.blockproperties.Block
|
||||||
import net.torvald.terrarum.gameactors.*
|
import net.torvald.terrarum.gameactors.*
|
||||||
|
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||||
import net.torvald.terrarum.modulebasegame.ui.Notification
|
import net.torvald.terrarum.modulebasegame.ui.Notification
|
||||||
@@ -148,6 +149,8 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateGame(delta: Float) {
|
private fun updateGame(delta: Float) {
|
||||||
|
KeyToggler.update(false)
|
||||||
|
|
||||||
blockPointingCursor.update(delta)
|
blockPointingCursor.update(delta)
|
||||||
actorNowPlaying?.update(delta)
|
actorNowPlaying?.update(delta)
|
||||||
uiContainer.forEach { it.update(delta) }
|
uiContainer.forEach { it.update(delta) }
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class UITestPad1 : ScreenAdapter() {
|
|||||||
override fun show() {
|
override fun show() {
|
||||||
nsMenu = UINSMenu(
|
nsMenu = UINSMenu(
|
||||||
"Menu",
|
"Menu",
|
||||||
160,
|
96,
|
||||||
Yaml(treeStr)
|
Yaml(treeStr)
|
||||||
)
|
)
|
||||||
batch = SpriteBatch()
|
batch = SpriteBatch()
|
||||||
@@ -74,13 +74,15 @@ class UITestPad1 : ScreenAdapter() {
|
|||||||
|
|
||||||
resize(AppLoader.appConfig.width, AppLoader.appConfig.height)
|
resize(AppLoader.appConfig.width, AppLoader.appConfig.height)
|
||||||
|
|
||||||
nsMenu.setPosition(10, 10)
|
nsMenu.setPosition(0, 0)
|
||||||
nsMenu.setAsAlwaysVisible()
|
nsMenu.setAsAlwaysVisible()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val bgCol = Color(.62f,.79f,1f,1f)
|
val bgCol = Color(.62f,.79f,1f,1f)
|
||||||
|
|
||||||
|
var _dct = 0f
|
||||||
|
|
||||||
override fun render(delta: Float) {
|
override fun render(delta: Float) {
|
||||||
batch.inUse {
|
batch.inUse {
|
||||||
batch.color = bgCol
|
batch.color = bgCol
|
||||||
@@ -89,7 +91,8 @@ class UITestPad1 : ScreenAdapter() {
|
|||||||
nsMenu.render(batch, camera)
|
nsMenu.render(batch, camera)
|
||||||
}
|
}
|
||||||
|
|
||||||
//nsMenu.setPosition(20, 20) // FIXME the prolonged bug, "the entire screen is shifted!" is caused by these kind of operations
|
_dct = (_dct + delta*2) % 10f
|
||||||
|
//nsMenu.setPosition(_dct.toInt(), _dct.toInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun pause() {
|
override fun pause() {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class UINSMenu(
|
|||||||
|
|
||||||
|
|
||||||
val tree = treeRepresentation.parse()
|
val tree = treeRepresentation.parse()
|
||||||
override var width = minOf(minimumWidth, tree.getLevelData(1).map { Terrarum.fontGame.getWidth(it ?: "") }.max() ?: 0)
|
override var width = maxOf(minimumWidth, tree.getLevelData(1).map { Terrarum.fontGame.getWidth(it ?: "") }.max() ?: 0)
|
||||||
override var height = LINE_HEIGHT * (tree.children.size + 1)
|
override var height = LINE_HEIGHT * (tree.children.size + 1)
|
||||||
private val treeChildrenLabels = Array<String>(tree.children.size) {
|
private val treeChildrenLabels = Array<String>(tree.children.size) {
|
||||||
tree.children[it].toString() + if (tree.children[it].children.isNotEmpty()) " $CHILD_ARROW" else ""
|
tree.children[it].toString() + if (tree.children[it].children.isNotEmpty()) " $CHILD_ARROW" else ""
|
||||||
@@ -38,11 +38,14 @@ class UINSMenu(
|
|||||||
private val theRealList = UIItemTextButtonList(
|
private val theRealList = UIItemTextButtonList(
|
||||||
this,
|
this,
|
||||||
treeChildrenLabels,
|
treeChildrenLabels,
|
||||||
posX + TEXT_OFFSETX.toInt(), posY + LINE_HEIGHT,
|
posX, posY + LINE_HEIGHT,
|
||||||
width - (2 * TEXT_OFFSETX.toInt()), height - LINE_HEIGHT,
|
width, height - LINE_HEIGHT,
|
||||||
TEXT_OFFSETY.toInt(),
|
|
||||||
textAreaWidth = width - (2 * TEXT_OFFSETX.toInt()),
|
textAreaWidth = width - (2 * TEXT_OFFSETX.toInt()),
|
||||||
alignment = UIItemTextButton.Companion.Alignment.LEFT
|
alignment = UIItemTextButton.Companion.Alignment.LEFT,
|
||||||
|
activeBackCol = Color(0x242424_80),//Color(1f,0f,.75f,1f),
|
||||||
|
inactiveCol = Color(.94f,.94f,.94f,1f),
|
||||||
|
itemHitboxSize = LINE_HEIGHT
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
val selectedIndex: Int?
|
val selectedIndex: Int?
|
||||||
@@ -60,9 +63,10 @@ class UINSMenu(
|
|||||||
|
|
||||||
batch.color = titleTextCol
|
batch.color = titleTextCol
|
||||||
blendNormal(batch)
|
blendNormal(batch)
|
||||||
Terrarum.fontGame.draw(batch, title, posX + TEXT_OFFSETX, TEXT_OFFSETY)
|
Terrarum.fontGame.draw(batch, title, posX + TEXT_OFFSETX, posY + TEXT_OFFSETY)
|
||||||
|
|
||||||
// draw the list
|
// draw the list
|
||||||
|
batch.color = Color.WHITE
|
||||||
theRealList.render(batch, camera)
|
theRealList.render(batch, camera)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user