Start implementing what we learnt from the ui-test branch
This commit is contained in:
@@ -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.TextButton
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup
|
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
|
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
|
||||||
|
import com.sun.org.apache.bcel.internal.generic.CASTORE
|
||||||
import ktx.app.KtxScreen
|
import ktx.app.KtxScreen
|
||||||
import ktx.app.clearScreen
|
import ktx.app.clearScreen
|
||||||
import org.w3c.dom.Text
|
import org.w3c.dom.Text
|
||||||
@@ -52,26 +53,40 @@ class MainMenu : KtxScreen {
|
|||||||
val casualButton = TextButton("Casual", defaultTextButtonStyle)
|
val casualButton = TextButton("Casual", defaultTextButtonStyle)
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
val everythingVerticalGroup = VerticalGroup().apply {
|
// val everythingVerticalGroup = VerticalGroup().apply {
|
||||||
addActor(lobbyContainer)
|
// addActor(lobbyContainer)
|
||||||
addActor(casualButton)
|
// addActor(casualButton)
|
||||||
table.add(this)
|
// table.add(this)
|
||||||
Gdx.app.log("MainMenu", stage.width.toString())
|
// Gdx.app.log("MainMenu", stage.width.toString())
|
||||||
//Gdx.app.log("MainMenu", table.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")
|
||||||
|
Gdx.app.log("MainMenu", "table width is ${table.width}")
|
||||||
}
|
}
|
||||||
if (joinButton.isPressed) {
|
if (joinButton.isPressed) {
|
||||||
Gdx.app.log("MainMenu", "Join button pressed")
|
Gdx.app.log("MainMenu", "Join button pressed")
|
||||||
}
|
}
|
||||||
if (casualButton.isPressed) {
|
if (casualButton.isPressed) {
|
||||||
Gdx.app.log("MainMenu", "Casual button pressed")
|
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) {
|
override fun render(delta: Float) {
|
||||||
clearScreen(0f,0f, 0f)
|
clearScreen(0f,0f, 0f)
|
||||||
|
|
||||||
@@ -83,7 +98,7 @@ class MainMenu : KtxScreen {
|
|||||||
|
|
||||||
override fun resize(width: Int, height: Int) {
|
override fun resize(width: Int, height: Int) {
|
||||||
Gdx.app.log("MainMenu", "resize called! New width: $width, new height $height")
|
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() {
|
override fun dispose() {
|
||||||
|
|||||||
Reference in New Issue
Block a user