Start implementing what we learnt from the ui-test branch

This commit is contained in:
2026-03-18 09:28:00 +00:00
parent 1cc46a94fe
commit afe82dbd2a

View File

@@ -10,6 +10,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
import com.sun.org.apache.bcel.internal.generic.CASTORE
import ktx.app.KtxScreen
import ktx.app.clearScreen
import org.w3c.dom.Text
@@ -52,26 +53,40 @@ class MainMenu : KtxScreen {
val casualButton = TextButton("Casual", defaultTextButtonStyle)
//endregion
val everythingVerticalGroup = VerticalGroup().apply {
addActor(lobbyContainer)
addActor(casualButton)
table.add(this)
Gdx.app.log("MainMenu", stage.width.toString())
//Gdx.app.log("MainMenu", table.width.toString())
}
// val everythingVerticalGroup = VerticalGroup().apply {
// addActor(lobbyContainer)
// addActor(casualButton)
// table.add(this)
// Gdx.app.log("MainMenu", stage.width.toString())
// //Gdx.app.log("MainMenu", table.width.toString())
// }
private fun update(delta: Float) {
if (hostButton.isPressed) {
Gdx.app.log("MainMenu", "Host button pressed")
Gdx.app.log("MainMenu", "table width is ${table.width}")
}
if (joinButton.isPressed) {
Gdx.app.log("MainMenu", "Join button pressed")
}
if (casualButton.isPressed) {
Gdx.app.log("MainMenu", "Casual button pressed")
Gdx.app.log("MainMenu", "New Button Size: ${table.width * 0.4f}, ${table.width * 0.2f}")
}
}
override fun show() {
table.validate() // THIS IS EXTREMELY IMPORTANT!! WE NEED TO MAKE SURE THE TABLE HAS A SIZE WHEN WE REFERENCE IT'S WIDTH/HEIGHT!!
table.setFillParent(true)
table.add(casualButton)
table.getCell<TextButton>(casualButton).size(table.width * 0.4f, table.width * 0.2f)
//table.getCell<TextButton>(casualButton).width(table.width * 0.8f).height(((table.width * 0.8f) * 9f) / 32f)
//table.getCell<VerticalGroup>(everythingVerticalGroup).size(table.width * 0.8f, ((table.width * 0.8f) * 9f) / 32f)
}
override fun render(delta: Float) {
clearScreen(0f,0f, 0f)
@@ -83,7 +98,7 @@ class MainMenu : KtxScreen {
override fun resize(width: Int, height: Int) {
Gdx.app.log("MainMenu", "resize called! New width: $width, new height $height")
everythingVerticalGroup.setSize(width.toFloat(), height.toFloat())
//everythingVerticalGroup.setSize(width.toFloat(), height.toFloat())
}
override fun dispose() {