we make da view

This commit is contained in:
nelle 2023-10-28 13:37:01 -06:00
parent 3fc6ecd4ae
commit 4a85861f0b
10 changed files with 97 additions and 32 deletions

View file

@ -38,7 +38,7 @@ dependencies {
tasks {
named<ShadowJar>("shadowJar") {
archiveBaseName.set("zircon.skeleton.kotlin")
archiveBaseName.set("potroge")
mergeServiceFiles()
manifest {
attributes(mapOf("Main-Class" to "com.example.MainKt"))

View file

@ -9,5 +9,5 @@ mockito_version=1.10.19
assertj_version=3.6.2
slf4j_version=1.7.25
group=com.example.zircon.skeleton
version=1.2.0
group=group.ouroboros.potrogue
version=0.1.0-DEV

0
gradlew vendored Normal file → Executable file
View file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

View file

@ -1 +1 @@
rootProject.name = "zircon.skeleton.kotlin"
rootProject.name = "potrogue"

View file

@ -1,28 +0,0 @@
package com.example
import org.hexworks.zircon.api.CP437TilesetResources
import org.hexworks.zircon.api.ColorThemes
import org.hexworks.zircon.api.Components
import org.hexworks.zircon.api.SwingApplications
import org.hexworks.zircon.api.application.AppConfig
import org.hexworks.zircon.api.extensions.toScreen
fun main(args: Array<String>) {
val tileGrid = SwingApplications.startTileGrid(
AppConfig.newBuilder()
.withSize(60, 30)
.withDefaultTileset(CP437TilesetResources.rexPaint16x16())
.build()
)
val screen = tileGrid.toScreen()
screen.addComponent(
Components.label()
.withText("Hello, Zircon!")
.withPosition(23, 10)
)
screen.display()
screen.theme = ColorThemes.arc()
}

View file

@ -0,0 +1,49 @@
package group.ouroboros.potrogue
import org.hexworks.zircon.api.ColorThemes
import org.hexworks.zircon.api.Components
import org.hexworks.zircon.api.SwingApplications
import org.hexworks.zircon.api.application.AppConfig
import org.hexworks.zircon.api.component.ComponentAlignment
import org.hexworks.zircon.api.screen.Screen
//Important Values
public val GAME_ID = "potrogue";
public val GAME_VER = "0.1.0-DEV";
fun main(args: Array<String>) {
//Start the tilegrid and screen
val grid = SwingApplications.startTileGrid(
AppConfig.newBuilder()
.withTitle("$GAME_ID | $GAME_VER")
.build()
)
val screen = Screen.create(grid)
//TODO
//Create Custom Color Theme
/*
val potCol = ColorThemeBuilder.newBuilder()
.withName("potcolor")
.withAccentColor(TileColor.transparent())
.withPrimaryForegroundColor(TileColor.transparent())
.withSecondaryForegroundColor(TileColor.transparent())
.withPrimaryBackgroundColor(TileColor.transparent())
.withSecondaryBackgroundColor(TileColor.transparent())
.build())
*/
//Add a component to the screen, in this case a header, which is centered.
screen.addComponent(
Components.header()
.withText("Hello, from $GAME_ID v$GAME_VER!")
.withAlignmentWithin(screen, ComponentAlignment.CENTER)
)
//Set color theme (will make our own later if we can figure out how
screen.theme = ColorThemes.cyberpunk()
//Show the screen
screen.display()
}

View file

@ -0,0 +1,44 @@
package group.ouroboros.potrogue.view
import group.ouroboros.potrogue.GAME_ID
import org.hexworks.zircon.api.ColorThemes
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
import org.hexworks.zircon.api.grid.TileGrid
import org.hexworks.zircon.api.view.base.BaseView
class StartView (
private val grid: TileGrid
) : BaseView(grid, ColorThemes.arc()) {
init {
val msg = "Welcome to $GAME_ID."
// 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.CENTER)
.build() // finally we build the component
val startButton = Components.button()
// we align the button to the bottom center of our header
.withAlignmentAround(header, ComponentAlignment.BOTTOM_CENTER)
// its text is "Start!"
.withText("Start!")
// we want a box and some shadow around it
.withDecorations(box(), shadow())
.build()
// We can add multiple components at once
screen.addComponents(header, startButton)
}
}