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.Gdx
|
||||||
import com.badlogic.gdx.graphics.Texture
|
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.Stage
|
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.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.Value
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
|
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
|
||||||
import ktx.app.KtxScreen
|
import ktx.app.KtxScreen
|
||||||
import ktx.app.clearScreen
|
import ktx.app.clearScreen
|
||||||
import org.w3c.dom.Text
|
|
||||||
|
|
||||||
class MainMenu : KtxScreen {
|
class MainMenu : KtxScreen {
|
||||||
val table = Table().apply {
|
val stage = Stage()
|
||||||
debug = true
|
|
||||||
setFillParent(true)
|
|
||||||
}
|
|
||||||
val stage = Stage().apply {
|
|
||||||
Gdx.input.inputProcessor = this
|
|
||||||
addActor(table)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default
|
val table = Table()
|
||||||
|
var tableWidthPadAmount = 0.8f
|
||||||
|
var tableHeightPadAmount = 0.8f
|
||||||
|
|
||||||
|
//region Buttons
|
||||||
val defaultButtonTrd = TextureRegionDrawable(Texture("default.png"))
|
val defaultButtonTrd = TextureRegionDrawable(Texture("default.png"))
|
||||||
val flippedDefaultButtonTrd = TextureRegionDrawable(Texture("default_flipped.png"))
|
val flippedDefaultButtonTrd = TextureRegionDrawable(Texture("default_flipped.png"))
|
||||||
val defaultTextButtonStyle = TextButton.TextButtonStyle (
|
val defaultTextButtonStyle = TextButton.TextButtonStyle (
|
||||||
defaultButtonTrd,
|
defaultButtonTrd,
|
||||||
flippedDefaultButtonTrd,
|
flippedDefaultButtonTrd,
|
||||||
defaultButtonTrd,
|
defaultButtonTrd,
|
||||||
BitmapFont()
|
BitmapFont()
|
||||||
)
|
)
|
||||||
|
val defaultButton = TextButton("Default Button", defaultTextButtonStyle)
|
||||||
// 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)
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
val everythingVerticalGroup = VerticalGroup().apply {
|
override fun show() {
|
||||||
addActor(lobbyContainer)
|
// Stage Setup
|
||||||
addActor(casualButton)
|
Gdx.input.inputProcessor = stage
|
||||||
table.add(this)
|
stage.addActor(table)
|
||||||
Gdx.app.log("MainMenu", stage.width.toString())
|
|
||||||
//Gdx.app.log("MainMenu", table.width.toString())
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun update(delta: Float) {
|
// Table Setup
|
||||||
if (hostButton.isPressed) {
|
table.debug = true
|
||||||
Gdx.app.log("MainMenu", "Host button pressed")
|
table.setPosition(
|
||||||
}
|
stage.width * ((1 - tableWidthPadAmount) / 2),
|
||||||
if (joinButton.isPressed) {
|
stage.height * ((1 - tableHeightPadAmount) / 2)
|
||||||
Gdx.app.log("MainMenu", "Join button pressed")
|
) // This centres the table
|
||||||
}
|
table.setSize(stage.width * tableWidthPadAmount, stage.height * tableHeightPadAmount)
|
||||||
if (casualButton.isPressed) {
|
|
||||||
Gdx.app.log("MainMenu", "Casual button pressed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
table.add(defaultButton).growX().height(Value.percentWidth(9f / 32f, table)) // We use a FreeTypeFontGenerator to do font sizing maybe?
|
||||||
|
}
|
||||||
override fun render(delta: Float) {
|
override fun render(delta: Float) {
|
||||||
clearScreen(0f,0f, 0f)
|
clearScreen(0f, 0f, 0f)
|
||||||
|
|
||||||
update(delta)
|
|
||||||
|
|
||||||
stage.act(delta)
|
stage.act(delta)
|
||||||
stage.draw()
|
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() {
|
override fun dispose() {
|
||||||
stage.dispose()
|
stage.dispose()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user