From 5aba0fc70aaf0305bc236e05bbeae6bafa7d26bfa43a2a7bb7d126abaf9ce7eb Mon Sep 17 00:00:00 2001 From: snap Date: Fri, 20 Mar 2026 11:30:52 +0000 Subject: [PATCH] Final commit before we start the MainMenu file from scratch again --- .../com/iofferyoutea/WitchQueen/MainMenu.kt | 44 +++++++++++-------- 1 file changed, 25 insertions(+), 19 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 9aa8f70..51379e0 100644 --- a/WitchQueen/core/src/main/kotlin/com/iofferyoutea/WitchQueen/MainMenu.kt +++ b/WitchQueen/core/src/main/kotlin/com/iofferyoutea/WitchQueen/MainMenu.kt @@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.graphics.g2d.BitmapFont import com.badlogic.gdx.scenes.scene2d.Actor import com.badlogic.gdx.scenes.scene2d.Stage +import com.badlogic.gdx.scenes.scene2d.ui.Cell import com.badlogic.gdx.scenes.scene2d.ui.Container import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.TextButton @@ -41,26 +42,21 @@ class MainMenu : KtxScreen { // Start off only showing Host and Join button. When selected show menu for that option. // Host is normal lobby // Join will bring up menu with games on local network - val hostButton = TextButton("Host", defaultTextButtonStyle) - val joinButton = TextButton("Join", defaultTextButtonStyle) - val hostOrJoinVerticalGroup = VerticalGroup().apply { - addActor(hostButton) - addActor(joinButton) + val hostButton = TextButton("Host", defaultTextButtonStyle).apply { + //setFillParent(true) + } + val joinButton = TextButton("Join", defaultTextButtonStyle).apply { + //setFillParent(true) + } + val hostOrJoinTable = Table().apply { // Move this into a Table instead of a Group! + add(hostButton).growX().row() + add(joinButton).growX() } - val lobbyContainer = Container(hostOrJoinVerticalGroup) //region Play 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()) -// } - private fun update(delta: Float) { if (hostButton.isPressed) { Gdx.app.log("MainMenu", "Host button pressed") @@ -76,15 +72,25 @@ class MainMenu : KtxScreen { } override fun show() { + table.setFillParent(true) 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) + //hostOrJoinVerticalGroup + // .size(table.width * 0.4f, table.width * 0.2f) - 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) + //table.getCell(hostOrJoinVerticalGroup).size(table.width * 0.4f, table.width * 0.2f) + + hostOrJoinTable.needsLayout() + for (cell in com.badlogic.gdx.utils.Array.ArrayIterator>(hostOrJoinTable.cells)) { + //cell.height(cell.actorWidth) + Gdx.app.log("MainMenu", cell.actorWidth.toString()) + Gdx.app.log("MainMenu", hostOrJoinTable.width.toString()) + } + + //table.row() + table.add(hostOrJoinTable).size(table.width * 0.4f, table.width * 0.2f) + //table.getCell(casualButton) } override fun render(delta: Float) {