From 1af074ab922e1317e792fb7f4ed2dbf6f1d8c16f Mon Sep 17 00:00:00 2001 From: LimePotato Date: Sun, 29 Oct 2023 02:30:51 -0600 Subject: [PATCH] Basic config screen --- .../ouroboros/potrogue/view/ConfigView.kt | 45 +++++++++++++++++++ .../ouroboros/potrogue/view/StartView.kt | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/main/kotlin/group/ouroboros/potrogue/view/ConfigView.kt diff --git a/src/main/kotlin/group/ouroboros/potrogue/view/ConfigView.kt b/src/main/kotlin/group/ouroboros/potrogue/view/ConfigView.kt new file mode 100644 index 0000000..53d7185 --- /dev/null +++ b/src/main/kotlin/group/ouroboros/potrogue/view/ConfigView.kt @@ -0,0 +1,45 @@ +package group.ouroboros.potrogue.view + +import group.ouroboros.potrogue.GameConfig +import org.hexworks.zircon.api.ComponentDecorations +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 ConfigView (private val grid: TileGrid, theme: ColorTheme = GameConfig.THEME) : BaseView(grid, theme) { + init { + val msg = "Pre-Game Configuration" + + // a text box can hold headers, paragraphs and list items + // `contentWidth = ` here is a so-called keyword parameter + // using them you can pass parameters not by their order + // but by their name. + // this might be familiar for Python programmers + val header = Components.textBox(contentWidth = msg.length) + // we add a header + .addHeader(msg) + // and a new line + .addNewLine() + // and align it to center + .withAlignmentWithin(screen, ComponentAlignment.TOP_CENTER) + .build() // finally we build the component + + //TODO: Options: world size, character tile (smiley, @, &), character customizations (class, looks, stats, start), + + val backButton = Components.button() + .withAlignmentWithin(screen, ComponentAlignment.BOTTOM_CENTER) + .withText("BACK") + .withDecorations(ComponentDecorations.box(), ComponentDecorations.shadow()) + .build() + + //Once the back button is activated go back to startView + backButton.onActivated { + replaceWith(StartView(grid)) + } + + // We can add multiple components at once + //Bake The Cake + screen.addComponents(header,backButton) + }} \ No newline at end of file diff --git a/src/main/kotlin/group/ouroboros/potrogue/view/StartView.kt b/src/main/kotlin/group/ouroboros/potrogue/view/StartView.kt index 6bf980c..1c7989c 100644 --- a/src/main/kotlin/group/ouroboros/potrogue/view/StartView.kt +++ b/src/main/kotlin/group/ouroboros/potrogue/view/StartView.kt @@ -57,7 +57,7 @@ class StartView (private val grid: TileGrid, theme: ColorTheme = GameConfig.THEM } configButton.onActivated { - TODO() + replaceWith(ConfigView(grid)) } exitButton.onActivated {