diff --git a/src/main/kotlin/group/ouroboros/potrogue/view/LoseView.kt b/src/main/kotlin/group/ouroboros/potrogue/view/LoseView.kt index 8022144..a62171b 100644 --- a/src/main/kotlin/group/ouroboros/potrogue/view/LoseView.kt +++ b/src/main/kotlin/group/ouroboros/potrogue/view/LoseView.kt @@ -12,31 +12,37 @@ import kotlin.system.exitProcess class LoseView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) { init { + //Title val header = Components.header() .withText("Game Over") .withAlignmentWithin(screen, ComponentAlignment.CENTER) .build() + //Reset Button val restartButton = Components.button() .withAlignmentAround(header, ComponentAlignment.BOTTOM_LEFT) .withText("Restart") .withDecorations(box()) .build() + //Quit Button val exitButton = Components.button() .withAlignmentAround(header, ComponentAlignment.BOTTOM_RIGHT) .withText("Quit") .withDecorations(box()) .build() + //On Reset Button activated, move back to PlayView restartButton.onActivated { replaceWith(PlayView(grid)) } + //On Quit BUtton activated, exit program exitButton.onActivated { exitProcess(0) } + //Bake the cake screen.addComponents(header, restartButton, exitButton) } } \ No newline at end of file diff --git a/src/main/kotlin/group/ouroboros/potrogue/view/PlayView.kt b/src/main/kotlin/group/ouroboros/potrogue/view/PlayView.kt index be400f6..a5deba2 100644 --- a/src/main/kotlin/group/ouroboros/potrogue/view/PlayView.kt +++ b/src/main/kotlin/group/ouroboros/potrogue/view/PlayView.kt @@ -11,6 +11,7 @@ import org.hexworks.zircon.api.view.base.BaseView class PlayView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) { init { + //Create Lose Button val loseButton = Components.button() // constants like LEFT_CENTER can also be imported for brevity .withAlignmentWithin(screen, LEFT_CENTER) @@ -18,16 +19,20 @@ class PlayView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) { .withDecorations(box(), shadow()) .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) } } \ 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 fd59917..c2abedf 100644 --- a/src/main/kotlin/group/ouroboros/potrogue/view/StartView.kt +++ b/src/main/kotlin/group/ouroboros/potrogue/view/StartView.kt @@ -2,7 +2,6 @@ package group.ouroboros.potrogue.view import group.ouroboros.potrogue.GAME_ID import group.ouroboros.potrogue.GAME_THEME -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 @@ -45,6 +44,7 @@ class StartView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) { } // We can add multiple components at once + //Bake The Cake screen.addComponents(header, startButton) } } \ No newline at end of file diff --git a/src/main/kotlin/group/ouroboros/potrogue/view/WinView.kt b/src/main/kotlin/group/ouroboros/potrogue/view/WinView.kt index 917bfd6..6ed819d 100644 --- a/src/main/kotlin/group/ouroboros/potrogue/view/WinView.kt +++ b/src/main/kotlin/group/ouroboros/potrogue/view/WinView.kt @@ -13,31 +13,38 @@ import kotlin.system.exitProcess class WinView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) { init { + //Title val header = Components.header() .withText("You won!") .withAlignmentWithin(screen, ComponentAlignment.CENTER) .build() + //Create Reset Button val restartButton = Components.button() .withAlignmentAround(header, ComponentAlignment.BOTTOM_LEFT) .withText("Restart") .withDecorations(box()) .build() + + //Create Quit Button val exitButton = Components.button() .withAlignmentAround(header, ComponentAlignment.BOTTOM_RIGHT) .withText("Quit") .withDecorations(box()) .build() + //On Reset Button activated, move back to PlayView restartButton.onActivated { replaceWith(PlayView(grid)) } + //On Quit Button activated, exit program exitButton.onActivated { exitProcess(0) } + //Bake The Cake screen.addComponents(header, restartButton, exitButton) } } \ No newline at end of file