Game Config and sidebar

Signed-off-by: LimePotato <bm01@limepot.xyz>
This commit is contained in:
nelle 2023-10-28 15:18:28 -06:00
parent 381183af75
commit 602787a181
6 changed files with 54 additions and 56 deletions

View file

@ -0,0 +1,36 @@
package group.ouroboros.potrogue
import org.hexworks.zircon.api.CP437TilesetResources
import org.hexworks.zircon.api.ColorThemes
import org.hexworks.zircon.api.application.AppConfig
import org.hexworks.zircon.api.data.Size3D
object GameConfig {
// game
const val DUNGEON_LEVELS = 2
// look & feel
val TILESET = CP437TilesetResources.rogueYun16x16()
val THEME = ColorThemes.cyberpunk()
const val SIDEBAR_WIDTH = 18
const val LOG_AREA_HEIGHT = 8
// sizing
const val WINDOW_WIDTH = 80
const val WINDOW_HEIGHT = 50
val WORLD_SIZE = Size3D.create(WINDOW_WIDTH, WINDOW_HEIGHT, DUNGEON_LEVELS)
val GAME_AREA_SIZE = Size3D.create(
xLength = WINDOW_WIDTH - SIDEBAR_WIDTH,
yLength = WINDOW_HEIGHT - LOG_AREA_HEIGHT,
zLength = DUNGEON_LEVELS
)
fun buildAppConfig() = AppConfig.newBuilder()
.withDefaultTileset(TILESET)
.withSize(WINDOW_WIDTH, WINDOW_HEIGHT)
.withTitle("$GAME_ID | $GAME_VER")
.build()
}

View file

@ -11,31 +11,8 @@ import org.hexworks.zircon.api.screen.Screen
//Important Values
public val GAME_ID = "potrogue";
public val GAME_VER = "0.1.0-DEV";
public val GAME_THEME = cyberpunk()
fun main(args: Array<String>) {
//Start the tilegrid and screen
val grid = SwingApplications.startTileGrid(
AppConfig.newBuilder()
.withTitle("$GAME_ID | $GAME_VER")
.withDefaultTileset(CP437TilesetResources.rogueYun16x16())
.build()
)
val screen = Screen.create(grid)
//TODO
//Create Custom Color Theme
/*
val GAME_THEME = ColorThemeBuilder.newBuilder()
.withName("potcolor")
.withAccentColor(TileColor.transparent())
.withPrimaryForegroundColor(TileColor.transparent())
.withSecondaryForegroundColor(TileColor.transparent())
.withPrimaryBackgroundColor(TileColor.transparent())
.withSecondaryBackgroundColor(TileColor.transparent())
.build())
*/
val grid = SwingApplications.startTileGrid(GameConfig.buildAppConfig())
StartView(grid).dock()
}

View file

@ -1,15 +1,16 @@
package group.ouroboros.potrogue.view
import group.ouroboros.potrogue.GAME_THEME
import group.ouroboros.potrogue.GameConfig
import org.hexworks.zircon.api.ComponentDecorations.box
import org.hexworks.zircon.api.Components
import org.hexworks.zircon.api.component.ColorTheme
import org.hexworks.zircon.api.component.ComponentAlignment
import org.hexworks.zircon.api.grid.TileGrid
import org.hexworks.zircon.api.view.base.BaseView
import kotlin.system.exitProcess
class LoseView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
class LoseView (private val grid: TileGrid, theme: ColorTheme = GameConfig.THEME) : BaseView(grid, theme) {
init {
//Title

View file

@ -1,38 +1,20 @@
package group.ouroboros.potrogue.view
import group.ouroboros.potrogue.GAME_THEME
import group.ouroboros.potrogue.GameConfig
import org.hexworks.zircon.api.ComponentDecorations.box
import org.hexworks.zircon.api.ComponentDecorations.shadow
import org.hexworks.zircon.api.Components
import org.hexworks.zircon.api.component.ComponentAlignment.LEFT_CENTER
import org.hexworks.zircon.api.component.ComponentAlignment.RIGHT_CENTER
import org.hexworks.zircon.api.component.ColorTheme
import org.hexworks.zircon.api.grid.TileGrid
import org.hexworks.zircon.api.view.base.BaseView
class PlayView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
class PlayView (private val grid: TileGrid, theme: ColorTheme = GameConfig.THEME) : BaseView(grid, theme) {
init {
//Create Lose Button
val loseButton = Components.button()
// constants like LEFT_CENTER can also be imported for brevity
.withAlignmentWithin(screen, LEFT_CENTER)
.withText("Lose!")
.withDecorations(box(), shadow())
val sidebar = Components.panel()
.withSize(GameConfig.SIDEBAR_WIDTH, GameConfig.WINDOW_HEIGHT)
.withDecorations(box())
.build()
//Create Win BUtton
val winButton = Components.button()
.withAlignmentWithin(screen, RIGHT_CENTER)
.withText("Win!")
.withDecorations(box(), shadow())
.build()
//On Win Button activated, move to WinView
winButton.onActivated { replaceWith(WinView(grid)) }
//On Lose Button activated, move to LoseView
loseButton.onActivated { replaceWith(LoseView(grid)) }
// multiple components can be added once
// Bake The Cake
screen.addComponents(loseButton, winButton)
screen.addComponent(sidebar)
}
}

View file

@ -1,15 +1,16 @@
package group.ouroboros.potrogue.view
import group.ouroboros.potrogue.GAME_ID
import group.ouroboros.potrogue.GAME_THEME
import group.ouroboros.potrogue.GameConfig
import org.hexworks.zircon.api.ComponentDecorations.box
import org.hexworks.zircon.api.ComponentDecorations.shadow
import org.hexworks.zircon.api.Components
import org.hexworks.zircon.api.component.ColorTheme
import org.hexworks.zircon.api.component.ComponentAlignment
import org.hexworks.zircon.api.grid.TileGrid
import org.hexworks.zircon.api.view.base.BaseView
class StartView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
class StartView (private val grid: TileGrid, theme: ColorTheme = GameConfig.THEME) : BaseView(grid, theme) {
init {
val msg = "Welcome to $GAME_ID."

View file

@ -1,16 +1,17 @@
package group.ouroboros.potrogue.view
import group.ouroboros.potrogue.GAME_THEME
import group.ouroboros.potrogue.GameConfig
import org.hexworks.zircon.api.ColorThemes
import org.hexworks.zircon.api.ComponentDecorations.box
import org.hexworks.zircon.api.Components
import org.hexworks.zircon.api.component.ColorTheme
import org.hexworks.zircon.api.component.ComponentAlignment
import org.hexworks.zircon.api.grid.TileGrid
import org.hexworks.zircon.api.view.base.BaseView
import kotlin.system.exitProcess
// For if winning.... obviously just a test.
class WinView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
class WinView (private val grid: TileGrid, theme: ColorTheme = GameConfig.THEME) : BaseView(grid, theme) {
init {
//Title