From 32698d48eebd24231afd1e592d183545636add3b Mon Sep 17 00:00:00 2001 From: LimePotato Date: Mon, 30 Oct 2023 01:48:19 -0600 Subject: [PATCH] Convert to config system :3 --- .../ouroboros/potrogue/data/config/Config.kt | 9 ++++++++ .../potrogue/data/config/GameConfig.kt | 22 +++++-------------- .../group/ouroboros/potrogue/view/PlayView.kt | 5 ++--- .../ouroboros/potrogue/world/GameBuilder.kt | 10 +++------ 4 files changed, 19 insertions(+), 27 deletions(-) diff --git a/src/main/kotlin/group/ouroboros/potrogue/data/config/Config.kt b/src/main/kotlin/group/ouroboros/potrogue/data/config/Config.kt index 12fd632..bb682e6 100644 --- a/src/main/kotlin/group/ouroboros/potrogue/data/config/Config.kt +++ b/src/main/kotlin/group/ouroboros/potrogue/data/config/Config.kt @@ -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() + } \ No newline at end of file diff --git a/src/main/kotlin/group/ouroboros/potrogue/data/config/GameConfig.kt b/src/main/kotlin/group/ouroboros/potrogue/data/config/GameConfig.kt index d91541a..3dd36fb 100644 --- a/src/main/kotlin/group/ouroboros/potrogue/data/config/GameConfig.kt +++ b/src/main/kotlin/group/ouroboros/potrogue/data/config/GameConfig.kt @@ -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() diff --git a/src/main/kotlin/group/ouroboros/potrogue/view/PlayView.kt b/src/main/kotlin/group/ouroboros/potrogue/view/PlayView.kt index 9db43a2..a4a5b42 100644 --- a/src/main/kotlin/group/ouroboros/potrogue/view/PlayView.kt +++ b/src/main/kotlin/group/ouroboros/potrogue/view/PlayView.kt @@ -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() diff --git a/src/main/kotlin/group/ouroboros/potrogue/world/GameBuilder.kt b/src/main/kotlin/group/ouroboros/potrogue/world/GameBuilder.kt index 8aa121a..c7da2cc 100644 --- a/src/main/kotlin/group/ouroboros/potrogue/world/GameBuilder.kt +++ b/src/main/kotlin/group/ouroboros/potrogue/world/GameBuilder.kt @@ -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