Final commit before we start the MainMenu file from scratch again

This commit is contained in:
2026-03-20 11:30:52 +00:00
parent afe82dbd2a
commit 5aba0fc70a

View File

@@ -5,6 +5,7 @@ import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.BitmapFont import com.badlogic.gdx.graphics.g2d.BitmapFont
import com.badlogic.gdx.scenes.scene2d.Actor import com.badlogic.gdx.scenes.scene2d.Actor
import com.badlogic.gdx.scenes.scene2d.Stage 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.Container
import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.scenes.scene2d.ui.TextButton 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. // Start off only showing Host and Join button. When selected show menu for that option.
// Host is normal lobby // Host is normal lobby
// Join will bring up menu with games on local network // Join will bring up menu with games on local network
val hostButton = TextButton("Host", defaultTextButtonStyle) val hostButton = TextButton("Host", defaultTextButtonStyle).apply {
val joinButton = TextButton("Join", defaultTextButtonStyle) //setFillParent(true)
val hostOrJoinVerticalGroup = VerticalGroup().apply { }
addActor(hostButton) val joinButton = TextButton("Join", defaultTextButtonStyle).apply {
addActor(joinButton) //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<Actor>(hostOrJoinVerticalGroup)
//region Play //region Play
val casualButton = TextButton("Casual", defaultTextButtonStyle) val casualButton = TextButton("Casual", defaultTextButtonStyle)
//endregion //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) { private fun update(delta: Float) {
if (hostButton.isPressed) { if (hostButton.isPressed) {
Gdx.app.log("MainMenu", "Host button pressed") Gdx.app.log("MainMenu", "Host button pressed")
@@ -76,15 +72,25 @@ class MainMenu : KtxScreen {
} }
override fun show() { 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.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<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) //table.getCell<VerticalGroup>(hostOrJoinVerticalGroup).size(table.width * 0.4f, table.width * 0.2f)
hostOrJoinTable.needsLayout()
for (cell in com.badlogic.gdx.utils.Array.ArrayIterator<Cell<Actor>>(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<TextButton>(casualButton)
} }
override fun render(delta: Float) { override fun render(delta: Float) {