Re-create main menu buttons
This commit is contained in:
1422
Excalidraw/Drawing 2026-03-03 16.04.17.excalidraw.md
Normal file
1422
Excalidraw/Drawing 2026-03-03 16.04.17.excalidraw.md
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
|||||||
|
package com.iofferyoutea.WitchQueen
|
||||||
|
|
||||||
|
import ktx.app.KtxScreen
|
||||||
|
import ktx.app.clearScreen
|
||||||
|
|
||||||
|
class GameScreen(val players: List<Player>, val map: Map) : KtxScreen {
|
||||||
|
override fun render(delta: Float) {
|
||||||
|
super.render(delta)
|
||||||
|
clearScreen(0.15f, 0.15f, 0.3f)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.iofferyoutea.WitchQueen
|
package com.iofferyoutea.WitchQueen
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Game
|
||||||
import com.badlogic.gdx.graphics.Texture
|
import com.badlogic.gdx.graphics.Texture
|
||||||
import com.badlogic.gdx.graphics.Texture.TextureFilter.Linear
|
import com.badlogic.gdx.graphics.Texture.TextureFilter.Linear
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
@@ -10,8 +11,12 @@ import ktx.assets.disposeSafely
|
|||||||
import ktx.assets.toInternalFile
|
import ktx.assets.toInternalFile
|
||||||
import ktx.async.KtxAsync
|
import ktx.async.KtxAsync
|
||||||
import ktx.graphics.use
|
import ktx.graphics.use
|
||||||
|
import java.lang.ref.WeakReference
|
||||||
|
|
||||||
class Main : KtxGame<KtxScreen>() {
|
class Main : KtxGame<KtxScreen>() {
|
||||||
|
//val mainMenu = MainMenu()
|
||||||
|
//val screenManager = ScreenManager.apply { switchScreen(mainMenu) }
|
||||||
|
|
||||||
override fun create() {
|
override fun create() {
|
||||||
KtxAsync.initiate()
|
KtxAsync.initiate()
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,15 @@ 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.scenes.scene2d.InputEvent
|
import com.badlogic.gdx.scenes.scene2d.InputEvent
|
||||||
import com.badlogic.gdx.scenes.scene2d.Stage
|
import com.badlogic.gdx.scenes.scene2d.Stage
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Button.ButtonStyle
|
import com.badlogic.gdx.scenes.scene2d.ui.Button.ButtonStyle
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Container
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup
|
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton
|
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton
|
||||||
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.VerticalGroup
|
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener
|
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
|
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
|
||||||
@@ -20,119 +23,201 @@ import ktx.app.KtxScreen
|
|||||||
import ktx.app.clearScreen
|
import ktx.app.clearScreen
|
||||||
|
|
||||||
class MainMenu : KtxScreen {
|
class MainMenu : KtxScreen {
|
||||||
val viewport = ScreenViewport().apply {
|
val myTable = Table().apply {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
val table = Table().apply {
|
|
||||||
setFillParent(true)
|
|
||||||
debug = true
|
debug = true
|
||||||
|
setFillParent(true)
|
||||||
}
|
}
|
||||||
val stage = Stage(viewport).apply {
|
val myStage = Stage().apply {
|
||||||
Gdx.app.log("WitchQueen", "Width: " + viewport.screenWidth.toString() + " Height: " + viewport.screenHeight.toString())
|
addActor(myTable)
|
||||||
|
|
||||||
Gdx.input.inputProcessor = this
|
|
||||||
addActor(table)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map Selection Button
|
//region Map Button
|
||||||
|
val mapButtonStyle = ImageButton.ImageButtonStyle(
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png"))
|
||||||
|
)
|
||||||
|
val mapButton = ImageButton(mapButtonStyle).apply {
|
||||||
|
myTable.add(this)
|
||||||
|
myTable.getCell<ImageButton>(this).padBottom(myStage.viewport.screenHeight * 0.05f) // Figure out how to centre
|
||||||
|
}
|
||||||
|
//endregion
|
||||||
|
|
||||||
// Player Table
|
//region Player Buttons
|
||||||
// val inviteButton = Button(
|
// Local Player
|
||||||
// "default.png",
|
// Remote Player
|
||||||
// "default_flipped.png",
|
val remotePlayerButton = PlayerButton().apply {
|
||||||
// "",
|
myTable.row()
|
||||||
// "Invite Player",
|
myTable.add(this.playerGroup)
|
||||||
// true,
|
myTable.getCell<HorizontalGroup>(this.playerGroup).padBottom(myStage.viewport.screenHeight * 0.05f) // You've got to size the sub actors!
|
||||||
// 2f
|
}
|
||||||
// ).apply {
|
//endregion
|
||||||
// table.add(this.button).size(1024f, 512f)
|
|
||||||
// table.row()
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Invite Player Button
|
//region Play Buttons
|
||||||
val playerPlaceholderButtonUp = TextureRegionDrawable(Texture("player-frame-up.png"))
|
val casualButtonStyle = TextButton.TextButtonStyle(
|
||||||
val playerPlaceholderButtonDown = TextureRegionDrawable(Texture("player-frame-down.png"))
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
val playerPlaceholderButtonChecked = TextureRegionDrawable(Texture("player-frame-up.png"))
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
val playerPlaceholderButtonStyle = ImageButton.ImageButtonStyle()
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
.apply { up = playerPlaceholderButtonUp; down = playerPlaceholderButtonDown; checked = playerPlaceholderButtonChecked }
|
BitmapFont()
|
||||||
val playerPlaceholderButton = ImageButton(playerPlaceholderButtonStyle)
|
)
|
||||||
|
val casualButton = TextButton("Casual", casualButtonStyle).apply {
|
||||||
val player1TableButton = PlayerTableButton() // These should only be collections no t buttons?
|
myTable.row() // Start with a new row
|
||||||
val player2TableButton = PlayerTableButton() // Since the collection contains the buttons we need anyway?
|
myTable.add(this)
|
||||||
val playerTableButtonCollection = VerticalGroup().apply {
|
myTable.getCell<TextButton>(this)
|
||||||
addActor(player1TableButton.button)
|
|
||||||
addActor(playerPlaceholderButton)
|
|
||||||
table.add(this)
|
|
||||||
table.row()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Casual Button
|
val competitiveButtonStyle = TextButton.TextButtonStyle(
|
||||||
val casualButton = Button(
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
"default.png",
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
"default_flipped.png",
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
"",
|
BitmapFont()
|
||||||
"Casual",
|
)
|
||||||
true,
|
val competitiveButton = TextButton("Competitive", competitiveButtonStyle).apply {
|
||||||
2f
|
myTable.add(this)
|
||||||
).apply { // Could probably do this in Button. Just take in width and aspect ratio and padding?
|
myTable.getCell<TextButton>(this).padLeft(myStage.viewport.screenWidth * 0.1f)
|
||||||
container.width(viewport.screenWidth * 0.375f)
|
|
||||||
container.height(((viewport.screenWidth * 0.375f) * 3f) / 4) // container.width is 0. We need to work out the width again.
|
|
||||||
container.padLeft(viewport.screenWidth * 0.1f)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Competitive Button
|
|
||||||
val competitiveButton = Button(
|
|
||||||
"default.png",
|
|
||||||
"default_flipped.png",
|
|
||||||
"",
|
|
||||||
"Competitive",
|
|
||||||
true,
|
|
||||||
2f
|
|
||||||
).apply {
|
|
||||||
container.width(viewport.screenWidth * 0.375f)
|
|
||||||
container.height(((viewport.screenWidth * 0.375f) * 3f) / 4) // container.width is 0. We need to work out the width again.
|
|
||||||
container.padLeft(viewport.screenWidth * 0.05f)
|
|
||||||
}
|
|
||||||
|
|
||||||
val playButtonGroup = HorizontalGroup().apply {
|
|
||||||
addActor(casualButton.container)
|
|
||||||
addActor(competitiveButton.container)
|
|
||||||
|
|
||||||
table.add(this).width(viewport.screenWidth.toFloat())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Methods
|
|
||||||
private fun processInput() {
|
|
||||||
casualButton.button.addListener(object : ClickListener() {
|
|
||||||
override fun touchUp(
|
|
||||||
event: InputEvent?,
|
|
||||||
x: Float,
|
|
||||||
y: Float,
|
|
||||||
pointer: Int,
|
|
||||||
button: Int
|
|
||||||
) {
|
|
||||||
Gdx.app.log("My Project", "Clicked!")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun resize(width: Int, height: Int) {
|
|
||||||
super.resize(width, height)
|
|
||||||
stage.viewport.update(width, height, true)
|
|
||||||
}
|
}
|
||||||
|
//endregion
|
||||||
|
|
||||||
override fun render(delta: Float) {
|
override fun render(delta: Float) {
|
||||||
super.render(delta)
|
clearScreen(0.3f, 0.3f, 0.3f)
|
||||||
clearScreen(0f, 255f, 0f)
|
|
||||||
|
|
||||||
processInput()
|
myStage.act(delta)
|
||||||
|
myStage.draw()
|
||||||
stage.act(delta)
|
|
||||||
stage.draw()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
stage.dispose()
|
myStage.dispose()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//class MainMenu : KtxScreen {
|
||||||
|
// val viewport = ScreenViewport().apply {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// val table = Table().apply {
|
||||||
|
// setFillParent(true)
|
||||||
|
// debug = true
|
||||||
|
// }
|
||||||
|
// val stage = Stage(viewport).apply {
|
||||||
|
// Gdx.app.log("WitchQueen", "Width: " + viewport.screenWidth.toString() + " Height: " + viewport.screenHeight.toString())
|
||||||
|
//
|
||||||
|
// Gdx.input.inputProcessor = this
|
||||||
|
// addActor(table)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Map Selection Button
|
||||||
|
//
|
||||||
|
// // Player Table
|
||||||
|
//// val inviteButton = Button(
|
||||||
|
//// "default.png",
|
||||||
|
//// "default_flipped.png",
|
||||||
|
//// "",
|
||||||
|
//// "Invite Player",
|
||||||
|
//// true,
|
||||||
|
//// 2f
|
||||||
|
//// ).apply {
|
||||||
|
//// table.add(this.button).size(1024f, 512f)
|
||||||
|
//// table.row()
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
// // Invite Player Button
|
||||||
|
// val playerPlaceholderButtonUp = TextureRegionDrawable(Texture("player-frame-up.png"))
|
||||||
|
// val playerPlaceholderButtonDown = TextureRegionDrawable(Texture("player-frame-down.png"))
|
||||||
|
// val playerPlaceholderButtonChecked = TextureRegionDrawable(Texture("player-frame-up.png"))
|
||||||
|
// val playerPlaceholderButtonStyle = ImageButton.ImageButtonStyle()
|
||||||
|
// .apply { up = playerPlaceholderButtonUp; down = playerPlaceholderButtonDown; checked = playerPlaceholderButtonChecked }
|
||||||
|
// val playerPlaceholderButton = ImageButton(playerPlaceholderButtonStyle)
|
||||||
|
// val playerPlaceholderContainer = Container<ImageButton>(playerPlaceholderButton).apply {
|
||||||
|
// width(viewport.screenWidth * 0.8f)
|
||||||
|
// height(((viewport.screenWidth * 0.8f) * 9f) / 32f) // container.width is 0. We need to work out the width again.
|
||||||
|
// padLeft(0f)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// val player1TableButton = PlayerTableButton().apply { // These should only be collections no t buttons?
|
||||||
|
// container.width(viewport.screenWidth * 0.8f)
|
||||||
|
// container.height(500f)
|
||||||
|
// //container.height(((viewport.screenWidth * 0.8f) * 9f) / 32f) // container.width is 0. We need to work out the width again.
|
||||||
|
// container.padLeft(0f)
|
||||||
|
// }
|
||||||
|
// val player2TableButton = PlayerTableButton() // Since the collection contains the buttons we need anyway?
|
||||||
|
// val playerTableButtonCollection = VerticalGroup().apply {
|
||||||
|
// addActor(player1TableButton.container)
|
||||||
|
// addActor(playerPlaceholderContainer)
|
||||||
|
// table.add(this)
|
||||||
|
// table.row()
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Casual Button
|
||||||
|
// val casualButton = Button(
|
||||||
|
// "default.png",
|
||||||
|
// "default_flipped.png",
|
||||||
|
// "",
|
||||||
|
// "Casual",
|
||||||
|
// true,
|
||||||
|
// 2f
|
||||||
|
// ).apply { // Could probably do this in Button. Just take in width and aspect ratio and padding?
|
||||||
|
// container.width(viewport.screenWidth * 0.375f)
|
||||||
|
// container.height(((viewport.screenWidth * 0.375f) * 3f) / 4) // container.width is 0. We need to work out the width again.
|
||||||
|
// container.padLeft(viewport.screenWidth * 0.1f)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Competitive Button
|
||||||
|
// val competitiveButton = Button(
|
||||||
|
// "default.png",
|
||||||
|
// "default_flipped.png",
|
||||||
|
// "",
|
||||||
|
// "Competitive",
|
||||||
|
// true,
|
||||||
|
// 2f
|
||||||
|
// ).apply {
|
||||||
|
// container.width(viewport.screenWidth * 0.375f)
|
||||||
|
// container.height(((viewport.screenWidth * 0.375f) * 3f) / 4) // container.width is 0. We need to work out the width again.
|
||||||
|
// container.padLeft(viewport.screenWidth * 0.05f)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// val playButtonGroup = HorizontalGroup().apply {
|
||||||
|
// addActor(casualButton.container)
|
||||||
|
// addActor(competitiveButton.container)
|
||||||
|
//
|
||||||
|
// table.add(this).width(viewport.screenWidth.toFloat())
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Methods
|
||||||
|
// private fun processInput() {
|
||||||
|
// casualButton.button.addListener(object : ClickListener() {
|
||||||
|
// override fun touchUp(
|
||||||
|
// event: InputEvent?,
|
||||||
|
// x: Float,
|
||||||
|
// y: Float,
|
||||||
|
// pointer: Int,
|
||||||
|
// button: Int
|
||||||
|
// ) {
|
||||||
|
// Gdx.app.log("My Project", "Clicked!")
|
||||||
|
// //setScreen()
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// override fun resize(width: Int, height: Int) {
|
||||||
|
// super.resize(width, height)
|
||||||
|
// stage.viewport.update(width, height, true)
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// override fun render(delta: Float) {
|
||||||
|
// super.render(delta)
|
||||||
|
// clearScreen(0f, 255f, 0f)
|
||||||
|
//
|
||||||
|
// processInput()
|
||||||
|
//
|
||||||
|
// stage.act(delta)
|
||||||
|
// stage.draw()
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// override fun dispose() {
|
||||||
|
// stage.dispose()
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package com.iofferyoutea.WitchQueen
|
||||||
|
|
||||||
|
class Map {
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.iofferyoutea.WitchQueen
|
||||||
|
|
||||||
|
class Player {
|
||||||
|
val name = String()
|
||||||
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
package com.iofferyoutea.WitchQueen
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Color
|
||||||
|
import com.badlogic.gdx.graphics.Texture
|
||||||
|
import com.badlogic.gdx.graphics.g2d.BitmapFont
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Container
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
|
||||||
|
|
||||||
|
class PlayerButton {
|
||||||
|
enum class STATE { EMPTY, CONNECTING, FILLED }
|
||||||
|
|
||||||
|
// Player Profile
|
||||||
|
val profileButtonStyle = ImageButton.ImageButtonStyle(
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png"))
|
||||||
|
)
|
||||||
|
val profileButton = ImageButton(profileButtonStyle)
|
||||||
|
|
||||||
|
// Player Username
|
||||||
|
val usernameStyle = Label.LabelStyle(BitmapFont(), Color.BLACK)
|
||||||
|
val username = Label("default", usernameStyle)
|
||||||
|
|
||||||
|
//region Player Items
|
||||||
|
val item1ButtonStyle = ImageButton.ImageButtonStyle(
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png"))
|
||||||
|
)
|
||||||
|
val item1Button = ImageButton(item1ButtonStyle)
|
||||||
|
val item2ButtonStyle = ImageButton.ImageButtonStyle(
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png"))
|
||||||
|
)
|
||||||
|
val item2Button = ImageButton(item2ButtonStyle)
|
||||||
|
val item3ButtonStyle = ImageButton.ImageButtonStyle(
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png"))
|
||||||
|
)
|
||||||
|
val item3Button = ImageButton(item3ButtonStyle)
|
||||||
|
val item4ButtonStyle = ImageButton.ImageButtonStyle(
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png"))
|
||||||
|
)
|
||||||
|
val item4Button = ImageButton(item4ButtonStyle)
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
// Leave Lobby - Only shows for local player on local player's button
|
||||||
|
val leaveButtonStyle = ImageButton.ImageButtonStyle(
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png"))
|
||||||
|
)
|
||||||
|
val leaveButton = ImageButton(leaveButtonStyle)
|
||||||
|
|
||||||
|
// Kick Player - Only shows for local player on remote player's button
|
||||||
|
val kickButtonStyle = ImageButton.ImageButtonStyle(
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png"))
|
||||||
|
)
|
||||||
|
val kickButton = ImageButton(kickButtonStyle)
|
||||||
|
|
||||||
|
val itemGroup = HorizontalGroup().apply {
|
||||||
|
addActor(item1Button)
|
||||||
|
addActor(item2Button)
|
||||||
|
addActor(item3Button)
|
||||||
|
addActor(item4Button)
|
||||||
|
}
|
||||||
|
|
||||||
|
val nameAndItemGroup = VerticalGroup().apply {
|
||||||
|
addActor(username)
|
||||||
|
addActor(itemGroup)
|
||||||
|
}
|
||||||
|
|
||||||
|
val playerGroup = HorizontalGroup().apply {
|
||||||
|
addActor(profileButton)
|
||||||
|
addActor(nameAndItemGroup)
|
||||||
|
addActor(kickButton)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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.ui.Button
|
import com.badlogic.gdx.scenes.scene2d.ui.Button
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Button.ButtonStyle
|
import com.badlogic.gdx.scenes.scene2d.ui.Button.ButtonStyle
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Container
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup
|
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||||
@@ -59,4 +60,6 @@ class PlayerTableButton(val playerIconPath: String = "default.png", val newPlaye
|
|||||||
val buttonStyle = ButtonStyle().apply { up = buttonUp; down = buttonDown; checked = buttonChecked }
|
val buttonStyle = ButtonStyle().apply { up = buttonUp; down = buttonDown; checked = buttonChecked }
|
||||||
|
|
||||||
val button = Button(componentCollection, buttonStyle)
|
val button = Button(componentCollection, buttonStyle)
|
||||||
|
|
||||||
|
val container = Container<HorizontalGroup>(componentCollection)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.iofferyoutea.WitchQueen
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx
|
||||||
|
import kotlinx.coroutines.*
|
||||||
|
import ktx.app.KtxScreen
|
||||||
|
import java.lang.ref.WeakReference
|
||||||
|
|
||||||
|
object ScreenManager {
|
||||||
|
var currentScreen: WeakReference<KtxScreen>? = null
|
||||||
|
val screens: MutableSet<WeakReference<KtxScreen>> = mutableSetOf<WeakReference<KtxScreen>>() // Does this need to be mutable?
|
||||||
|
|
||||||
|
fun switchScreen(newScreen: WeakReference<KtxScreen>): Boolean {
|
||||||
|
if (!screens.contains(newScreen)) {
|
||||||
|
Gdx.app.log("ScreenManager", "newScreen not found in screens. Adding...")
|
||||||
|
screens.add(newScreen)
|
||||||
|
}
|
||||||
|
|
||||||
|
currentScreen = screens.find { it == newScreen }
|
||||||
|
|
||||||
|
return currentScreen != null
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user