Compare commits
3 Commits
ui-test
...
witch-quee
| Author | SHA256 | Date | |
|---|---|---|---|
| 858971d1db | |||
| 5aba0fc70a | |||
| afe82dbd2a |
@@ -3,89 +3,55 @@ package com.iofferyoutea.WitchQueen
|
||||
import com.badlogic.gdx.Gdx
|
||||
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.Container
|
||||
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.ui.Value
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
|
||||
import ktx.app.KtxScreen
|
||||
import ktx.app.clearScreen
|
||||
import org.w3c.dom.Text
|
||||
|
||||
class MainMenu : KtxScreen {
|
||||
val table = Table().apply {
|
||||
debug = true
|
||||
setFillParent(true)
|
||||
}
|
||||
val stage = Stage().apply {
|
||||
Gdx.input.inputProcessor = this
|
||||
addActor(table)
|
||||
}
|
||||
val stage = Stage()
|
||||
|
||||
// Default
|
||||
val table = Table()
|
||||
var tableWidthPadAmount = 0.8f
|
||||
var tableHeightPadAmount = 0.8f
|
||||
|
||||
//region Buttons
|
||||
val defaultButtonTrd = TextureRegionDrawable(Texture("default.png"))
|
||||
val flippedDefaultButtonTrd = TextureRegionDrawable(Texture("default_flipped.png"))
|
||||
val defaultTextButtonStyle = TextButton.TextButtonStyle (
|
||||
defaultButtonTrd,
|
||||
flippedDefaultButtonTrd,
|
||||
defaultButtonTrd,
|
||||
BitmapFont()
|
||||
defaultButtonTrd,
|
||||
flippedDefaultButtonTrd,
|
||||
defaultButtonTrd,
|
||||
BitmapFont()
|
||||
)
|
||||
|
||||
// Map
|
||||
|
||||
// Lobby
|
||||
// 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 lobbyContainer = Container<Actor>(hostOrJoinVerticalGroup)
|
||||
|
||||
//region Play
|
||||
val casualButton = TextButton("Casual", defaultTextButtonStyle)
|
||||
val defaultButton = TextButton("Default Button", 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())
|
||||
}
|
||||
override fun show() {
|
||||
// Stage Setup
|
||||
Gdx.input.inputProcessor = stage
|
||||
stage.addActor(table)
|
||||
|
||||
private fun update(delta: Float) {
|
||||
if (hostButton.isPressed) {
|
||||
Gdx.app.log("MainMenu", "Host button pressed")
|
||||
}
|
||||
if (joinButton.isPressed) {
|
||||
Gdx.app.log("MainMenu", "Join button pressed")
|
||||
}
|
||||
if (casualButton.isPressed) {
|
||||
Gdx.app.log("MainMenu", "Casual button pressed")
|
||||
}
|
||||
}
|
||||
// Table Setup
|
||||
table.debug = true
|
||||
table.setPosition(
|
||||
stage.width * ((1 - tableWidthPadAmount) / 2),
|
||||
stage.height * ((1 - tableHeightPadAmount) / 2)
|
||||
) // This centres the table
|
||||
table.setSize(stage.width * tableWidthPadAmount, stage.height * tableHeightPadAmount)
|
||||
|
||||
table.add(defaultButton).growX().height(Value.percentWidth(9f / 32f, table)) // We use a FreeTypeFontGenerator to do font sizing maybe?
|
||||
}
|
||||
override fun render(delta: Float) {
|
||||
clearScreen(0f,0f, 0f)
|
||||
|
||||
update(delta)
|
||||
clearScreen(0f, 0f, 0f)
|
||||
|
||||
stage.act(delta)
|
||||
stage.draw()
|
||||
}
|
||||
|
||||
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())
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
stage.dispose()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user