Final commit before we start the MainMenu file from scratch again
This commit is contained in:
@@ -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<Actor>(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<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) {
|
||||
|
||||
Reference in New Issue
Block a user