Compare commits
10 Commits
main
...
99719f5b79
| Author | SHA256 | Date | |
|---|---|---|---|
| 99719f5b79 | |||
| fe79c271fa | |||
| ddab82ec7f | |||
| 7974cbd0af | |||
| bdcbfece3b | |||
| 1960fa51a7 | |||
| 75d7e3e101 | |||
| f915f7bbba | |||
| 1136fd018d | |||
| 01da51665e |
1422
Excalidraw/Drawing 2026-03-03 16.04.17.excalidraw.md
Normal file
8086
Excalidraw/class-structure.excalidraw.md
Normal file
2
Excalidraw/class-structure.excalidraw.svg
Normal file
|
After Width: | Height: | Size: 4.6 MiB |
BIN
Raw Assets/player-frame-pressed.aseprite
Normal file
BIN
Raw Assets/player-frame.aseprite
Normal file
BIN
Raw Assets/prepared-item-frame.aseprite
Normal file
@@ -2,6 +2,7 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
|
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:fullBackupContent="true"
|
android:fullBackupContent="true"
|
||||||
@@ -14,7 +15,7 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name="com.iofferyoutea.WitchQueen.android.AndroidLauncher"
|
android:name="com.iofferyoutea.WitchQueen.android.AndroidLauncher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:screenOrientation="landscape"
|
android:screenOrientation="portrait"
|
||||||
android:configChanges="keyboard|keyboardHidden|navigation|orientation|screenSize|screenLayout"
|
android:configChanges="keyboard|keyboardHidden|navigation|orientation|screenSize|screenLayout"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class AndroidLauncher : AndroidApplication() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
initialize(Main(), AndroidApplicationConfiguration().apply {
|
initialize(Main(), AndroidApplicationConfiguration().apply {
|
||||||
// Configure your application here.
|
// Configure your application here.
|
||||||
useImmersiveMode = true // Recommended, but not required.
|
//useImmersiveMode = true // Recommended, but not required.
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
WitchQueen/assets/default_flipped.png
Normal file
|
After Width: | Height: | Size: 94 B |
BIN
WitchQueen/assets/grey-plus.png
Normal file
|
After Width: | Height: | Size: 108 B |
BIN
WitchQueen/assets/player-frame-down.png
Normal file
|
After Width: | Height: | Size: 197 B |
BIN
WitchQueen/assets/player-frame-up.png
Normal file
|
After Width: | Height: | Size: 216 B |
BIN
WitchQueen/assets/player-frame.png
Normal file
|
After Width: | Height: | Size: 211 B |
BIN
WitchQueen/assets/prepared-item-frame.png
Normal file
|
After Width: | Height: | Size: 154 B |
BIN
WitchQueen/assets/red-x.png
Normal file
|
After Width: | Height: | Size: 129 B |
BIN
WitchQueen/assets/transparent.png
Normal file
|
After Width: | Height: | Size: 81 B |
@@ -7,7 +7,6 @@ dependencies {
|
|||||||
api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
|
api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
|
||||||
api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
|
api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
|
||||||
api "com.badlogicgames.gdx:gdx:$gdxVersion"
|
api "com.badlogicgames.gdx:gdx:$gdxVersion"
|
||||||
api "com.github.kotcrab.vis-ui:vis-ui:$visUiVersion"
|
|
||||||
api "io.github.libktx:ktx-actors:$ktxVersion"
|
api "io.github.libktx:ktx-actors:$ktxVersion"
|
||||||
api "io.github.libktx:ktx-ai:$ktxVersion"
|
api "io.github.libktx:ktx-ai:$ktxVersion"
|
||||||
api "io.github.libktx:ktx-app:$ktxVersion"
|
api "io.github.libktx:ktx-app:$ktxVersion"
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.iofferyoutea.WitchQueen
|
||||||
|
|
||||||
|
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.TextButton
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
|
||||||
|
import ktx.assets.toInternalFile
|
||||||
|
|
||||||
|
open class Button(val upTexturePath: String, val downTexturePath: String, val fontPath: String, val defaultText: String = "New Button", val useDefaultFont: Boolean = true, val fontScale: Float = 1f) {
|
||||||
|
val buttonText = defaultText
|
||||||
|
val buttonUp = TextureRegionDrawable(Texture(upTexturePath))
|
||||||
|
val buttonDown = TextureRegionDrawable(Texture(downTexturePath))
|
||||||
|
val buttonFont = (if (useDefaultFont) BitmapFont() else BitmapFont(fontPath.toInternalFile())).apply { data.scale(fontScale) }
|
||||||
|
|
||||||
|
val buttonStyle = TextButtonStyle().apply { up = buttonUp; down = buttonDown; font = buttonFont }
|
||||||
|
|
||||||
|
val button = TextButton(defaultText, buttonStyle)
|
||||||
|
val container = Container<TextButton>(button)
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.iofferyoutea.WitchQueen
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx
|
||||||
|
import com.badlogic.gdx.Net
|
||||||
|
|
||||||
|
class Lobby {
|
||||||
|
//val localServers: MutableSetOf<String> = setOf<String>() <-- HashSet?
|
||||||
|
|
||||||
|
//val localPlayer: Player = <-- Should be local player. Has all their items etc.
|
||||||
|
//val lobby: MutableList<Player> = listOf<Player>(localPlayer) <-- Limit to lobby size (2)?
|
||||||
|
|
||||||
|
val serverSocket = Gdx.net.newServerSocket(
|
||||||
|
Net.Protocol.TCP,
|
||||||
|
"127.0.0.1",
|
||||||
|
2864,
|
||||||
|
null
|
||||||
|
)
|
||||||
|
|
||||||
|
val clientSocket = Gdx.net.newClientSocket(
|
||||||
|
Net.Protocol.TCP,
|
||||||
|
"127.0.0.1", // <- This should be other servers address
|
||||||
|
2864, // <- This should be other servers port
|
||||||
|
null
|
||||||
|
)
|
||||||
|
|
||||||
|
val inputStream = clientSocket.inputStream
|
||||||
|
|
||||||
|
private fun findLocalServer() {
|
||||||
|
Gdx.app.log("Lobby", "Finding local server...")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun replayHasLocalServer(remoteAddress: String, remotePort: Int) {
|
||||||
|
Gdx.app.log("Lobby", "Pinged by another client. Informing that we have an open lobby...")
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun connectToServer(ip: String, port: Int) { // String is the ideal type for ip because v6 uses letters too?
|
||||||
|
Gdx.app.log("Lobby", "Connecting to $ip on port $port...")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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,13 +11,19 @@ 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()
|
||||||
|
|
||||||
addScreen(FirstScreen())
|
// addScreen(FirstScreen())
|
||||||
setScreen<FirstScreen>()
|
// setScreen<FirstScreen>()
|
||||||
|
addScreen(MainMenu())
|
||||||
|
setScreen<MainMenu>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,243 @@
|
|||||||
|
package com.iofferyoutea.WitchQueen
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx
|
||||||
|
import com.badlogic.gdx.graphics.Texture
|
||||||
|
import com.badlogic.gdx.graphics.g2d.Batch
|
||||||
|
import com.badlogic.gdx.graphics.g2d.BitmapFont
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
|
import com.badlogic.gdx.graphics.g3d.ModelCache
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.InputEvent
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.Stage
|
||||||
|
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.ImageButton
|
||||||
|
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.utils.ClickListener
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
|
||||||
|
import com.badlogic.gdx.utils.Logger
|
||||||
|
import com.badlogic.gdx.utils.Scaling
|
||||||
|
import com.badlogic.gdx.utils.viewport.ScreenViewport
|
||||||
|
import com.badlogic.gdx.utils.viewport.StretchViewport
|
||||||
|
import com.badlogic.gdx.utils.viewport.Viewport
|
||||||
|
import ktx.actors.centerPosition
|
||||||
|
import ktx.actors.setPosition
|
||||||
|
import ktx.actors.stage
|
||||||
|
import ktx.app.KtxScreen
|
||||||
|
import ktx.app.clearScreen
|
||||||
|
import javax.swing.text.View
|
||||||
|
|
||||||
|
class MainMenu : KtxScreen {
|
||||||
|
val myTable = Table().apply {
|
||||||
|
debug = true
|
||||||
|
setFillParent(true)
|
||||||
|
}
|
||||||
|
val myStage = Stage().apply {
|
||||||
|
Gdx.input.inputProcessor = this
|
||||||
|
addActor(myTable)
|
||||||
|
// We need this to get the size of the table later
|
||||||
|
//myTable.setSize(viewport.screenWidth.toFloat(), viewport.screenHeight.toFloat())
|
||||||
|
}
|
||||||
|
|
||||||
|
//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)
|
||||||
|
}
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
//endregion
|
||||||
|
//region Player Buttons
|
||||||
|
// Local Player
|
||||||
|
// Remote Player
|
||||||
|
val remotePlayerButton = PlayerButton().apply {
|
||||||
|
myTable.row()
|
||||||
|
myTable.add(this.playerGroup)
|
||||||
|
myTable.getCell<HorizontalGroup>(this.playerGroup) // You've got to size the sub actors!
|
||||||
|
}
|
||||||
|
|
||||||
|
//region Play Buttons
|
||||||
|
val casualButtonStyle = TextButton.TextButtonStyle(
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default_flipped.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
BitmapFont()
|
||||||
|
)
|
||||||
|
val casualButton = TextButton("Casual", casualButtonStyle)
|
||||||
|
|
||||||
|
val competitiveButtonStyle = TextButton.TextButtonStyle(
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
TextureRegionDrawable(Texture("default.png")),
|
||||||
|
BitmapFont()
|
||||||
|
)
|
||||||
|
val competitiveButton = TextButton("Competitive", competitiveButtonStyle)
|
||||||
|
|
||||||
|
// We need to wrap the play buttons in a group so they only take up 1 column
|
||||||
|
val playButtonGroup = HorizontalGroup().apply {
|
||||||
|
addActor(casualButton)
|
||||||
|
addActor(competitiveButton)
|
||||||
|
myTable.row()
|
||||||
|
myTable.add(this)
|
||||||
|
myTable.getCell<HorizontalGroup>(this)
|
||||||
|
}
|
||||||
|
//endregion
|
||||||
|
|
||||||
|
private fun update(delta: Float) {
|
||||||
|
if (casualButton.isPressed) {
|
||||||
|
Gdx.app.log("MainMenu", "Casual Button Pressed!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun render(delta: Float) {
|
||||||
|
clearScreen(0.3f, 0.3f, 0.3f)
|
||||||
|
|
||||||
|
myStage.act(delta)
|
||||||
|
myStage.draw()
|
||||||
|
|
||||||
|
update(delta)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
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.Button
|
||||||
|
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.Image
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
|
||||||
|
import ktx.assets.toInternalFile
|
||||||
|
|
||||||
|
class PlayerTableButton(val playerIconPath: String = "default.png", val newPlayerName: String = "PLAYER"):
|
||||||
|
Table() {
|
||||||
|
val playerIcon = Image(Texture(playerIconPath))
|
||||||
|
val playerNameStyle = Label.LabelStyle(BitmapFont("default.fnt".toInternalFile()), Color.WHITE)
|
||||||
|
val playerName = Label(newPlayerName, playerNameStyle)
|
||||||
|
// Change preparedItems and kickButton into actual buttons
|
||||||
|
var preparedItems: MutableList<Image> = mutableListOf( // We should use libGDX scene2d.ui List?
|
||||||
|
Image(Texture("prepared-item-frame.png")),
|
||||||
|
Image(Texture("prepared-item-frame.png")),
|
||||||
|
Image(Texture("prepared-item-frame.png")),
|
||||||
|
Image(Texture("prepared-item-frame.png"))
|
||||||
|
)
|
||||||
|
val preparedItemsGroup = HorizontalGroup().apply {
|
||||||
|
for (item in preparedItems) addActor(item)
|
||||||
|
}
|
||||||
|
val kickButton = Image(Texture("red-x.png"))
|
||||||
|
|
||||||
|
// Sub-table for Player/Items stack - Use VerticalGroup instead
|
||||||
|
// val playerPlusItemsStack = Table().apply {
|
||||||
|
// add(playerName)
|
||||||
|
// row()
|
||||||
|
// for (item in preparedItems) add(item)
|
||||||
|
// }
|
||||||
|
val playerLabelPlusItemsGroup = VerticalGroup().apply {
|
||||||
|
addActor(playerName)
|
||||||
|
addActor(preparedItemsGroup)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sub-table for the contents of the PlayerTableButton - Use HorizontalGroup instead
|
||||||
|
// val subTable = Table().apply {
|
||||||
|
// add(playerName, playerPlusItemsStack, kickButton)
|
||||||
|
// }
|
||||||
|
val componentCollection = HorizontalGroup().apply {
|
||||||
|
addActor(playerIcon)
|
||||||
|
addActor(playerLabelPlusItemsGroup)
|
||||||
|
addActor(kickButton)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Base Button stuff
|
||||||
|
val buttonUp = TextureRegionDrawable(Texture("transparent.png"))
|
||||||
|
val buttonDown = TextureRegionDrawable(Texture("transparent.png"))
|
||||||
|
val buttonChecked = TextureRegionDrawable(Texture("transparent.png"))
|
||||||
|
|
||||||
|
val buttonStyle = ButtonStyle().apply { up = buttonUp; down = buttonDown; checked = buttonChecked }
|
||||||
|
|
||||||
|
val button = Button(componentCollection, buttonStyle)
|
||||||
|
|
||||||
|
val container = Container<HorizontalGroup>(componentCollection)
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package com.iofferyoutea.WitchQueen
|
||||||
|
|
||||||
|
class PlayerTablePlaceholderButton {
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||