Convert to config system :3

This commit is contained in:
nelle 2023-10-30 01:48:19 -06:00
parent 4f44bc1125
commit 32698d48ee
4 changed files with 19 additions and 27 deletions

View file

@ -44,4 +44,13 @@ class Config {
}
//SET ALL PROPERTIES
val WINDOW_WIDTH: Int = (prop.getProperty("WINDOW_WIDTH")).toInt()
val WINDOW_HEIGHT: Int = (prop.getProperty("WINDOW_HEIGHT")).toInt()
val DUNGEON_LEVELS: Int = (prop.getProperty("DUNGEON_LEVELS")).toInt()
val SIDEBAR_WIDTH: Int = (prop.getProperty("SIDEBAR_WIDTH")).toInt()
val LOG_AREA_HEIGHT: Int = (prop.getProperty("LOG_AREA_HEIGHT")).toInt()
}

View file

@ -8,32 +8,20 @@ import org.hexworks.zircon.api.application.AppConfig
import org.hexworks.zircon.api.data.Size3D
object GameConfig {
// game
const val DUNGEON_LEVELS = 2
// look & feel
var TILESET = CP437TilesetResources.rogueYun16x16()
val THEME = ColorThemes.cyberpunk()
const val SIDEBAR_WIDTH = 18
const val LOG_AREA_HEIGHT = 12
// sizing
const val BORDERLESS_WINDOW_WIDTH = 120
const val BORDERLESS_WINDOW_HEIGHT = 65
//const val WINDOW_WIDTH = 80
const val WINDOW_HEIGHT = 50
val WORLD_SIZE = Size3D.create(Config().WINDOW_WIDTH * 3, WINDOW_HEIGHT * 3 , DUNGEON_LEVELS)
val WORLD_SIZE = Size3D.create(Config().WINDOW_WIDTH * 3, Config().WINDOW_HEIGHT * 3 , Config().DUNGEON_LEVELS)
val GAME_AREA_SIZE = Size3D.create(
xLength = Config().WINDOW_WIDTH - SIDEBAR_WIDTH,
yLength = WINDOW_HEIGHT - LOG_AREA_HEIGHT,
zLength = DUNGEON_LEVELS
xLength = Config().WINDOW_WIDTH - Config().SIDEBAR_WIDTH,
yLength = Config().WINDOW_HEIGHT - Config().LOG_AREA_HEIGHT,
zLength = Config().DUNGEON_LEVELS
)
fun buildAppConfig() = AppConfig.newBuilder()
.withDefaultTileset(TILESET)
.withSize(Config().WINDOW_WIDTH, WINDOW_HEIGHT)
.withSize(Config().WINDOW_WIDTH, Config().WINDOW_HEIGHT)
.withTitle("$GAME_ID | $GAME_VER")
.withIcon("assets/icon.png")
.build()

View file

@ -3,7 +3,6 @@ package group.ouroboros.potrogue.view
import group.ouroboros.potrogue.builders.GameTileRepository
import group.ouroboros.potrogue.data.config.Config
import group.ouroboros.potrogue.data.config.GameConfig
import group.ouroboros.potrogue.data.config.GameConfig.LOG_AREA_HEIGHT
import group.ouroboros.potrogue.world.Game
import group.ouroboros.potrogue.world.GameBuilder
import org.hexworks.cobalt.databinding.api.extension.toProperty
@ -22,14 +21,14 @@ class PlayView (private val grid: TileGrid, private val game: Game = GameBuilder
init {
//Create Sidebar
val sidebar = Components.panel()
.withSize(GameConfig.SIDEBAR_WIDTH, GameConfig.WINDOW_HEIGHT - LOG_AREA_HEIGHT)
.withSize(Config().SIDEBAR_WIDTH, Config().WINDOW_HEIGHT - Config().LOG_AREA_HEIGHT)
.withDecorations(box())
.build()
//Create area for logging
val logArea = Components.logArea()
.withDecorations(box(title = "Log"))
.withSize(Config().WINDOW_WIDTH, LOG_AREA_HEIGHT)
.withSize(Config().WINDOW_WIDTH, Config().LOG_AREA_HEIGHT)
.withAlignmentWithin(screen, ComponentAlignment.BOTTOM_RIGHT)
.build()

View file

@ -3,10 +3,6 @@ package group.ouroboros.potrogue.world
import group.ouroboros.potrogue.builders.EntityFactory
import group.ouroboros.potrogue.builders.WorldBuilder
import group.ouroboros.potrogue.data.config.Config
import group.ouroboros.potrogue.data.config.GameConfig
import group.ouroboros.potrogue.data.config.GameConfig.LOG_AREA_HEIGHT
import group.ouroboros.potrogue.data.config.GameConfig.SIDEBAR_WIDTH
import group.ouroboros.potrogue.data.config.GameConfig.WINDOW_HEIGHT
import group.ouroboros.potrogue.data.config.GameConfig.WORLD_SIZE
import group.ouroboros.potrogue.entity.attributes.types.Player
import group.ouroboros.potrogue.extensions.GameEntity
@ -18,8 +14,8 @@ class GameBuilder (val worldSize: Size3D) {
// We define the visible size which is our viewport of the world
private val visibleSize = Size3D.create(
xLength = Config().WINDOW_WIDTH - SIDEBAR_WIDTH,
yLength = WINDOW_HEIGHT - LOG_AREA_HEIGHT,
xLength = Config().WINDOW_WIDTH - Config().SIDEBAR_WIDTH,
yLength = Config().WINDOW_HEIGHT - Config().LOG_AREA_HEIGHT,
zLength = 1
)
@ -52,7 +48,7 @@ class GameBuilder (val worldSize: Size3D) {
// We immediately add the player to the World which takes an offset and a size as a parameter
player,
// offset determines the position where the search for empty positions will start. Here we specify that the top level will be searched starting at (0, 0)
offset = Position3D.create(0, 0, GameConfig.DUNGEON_LEVELS - 1),
offset = Position3D.create(0, 0, Config().DUNGEON_LEVELS - 1),
size = world.visibleSize.copy(zLength = 0)
) // And we also determine that we should search only the throughout the viewport. This ensures that the player will be visible on the screen when we start the game
return player