From afe82dbd2a2e8b341839e557fbbf9bd75a943e482e03c22265d80097fb9d0327 Mon Sep 17 00:00:00 2001 From: snap Date: Wed, 18 Mar 2026 09:28:00 +0000 Subject: [PATCH] Start implementing what we learnt from the ui-test branch --- .../com/iofferyoutea/WitchQueen/MainMenu.kt | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/WitchQueen/core/src/main/kotlin/com/iofferyoutea/WitchQueen/MainMenu.kt b/WitchQueen/core/src/main/kotlin/com/iofferyoutea/WitchQueen/MainMenu.kt index c631b1b..9aa8f70 100644 --- a/WitchQueen/core/src/main/kotlin/com/iofferyoutea/WitchQueen/MainMenu.kt +++ b/WitchQueen/core/src/main/kotlin/com/iofferyoutea/WitchQueen/MainMenu.kt @@ -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(casualButton).size(table.width * 0.4f, table.width * 0.2f) + //table.getCell(casualButton).width(table.width * 0.8f).height(((table.width * 0.8f) * 9f) / 32f) + + //table.getCell(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() {