We do a little commenting
Signed-off-by: LimePotato <bm01@limepot.xyz>
This commit is contained in:
parent
7294110d34
commit
381183af75
4 changed files with 19 additions and 1 deletions
|
@ -12,31 +12,37 @@ import kotlin.system.exitProcess
|
||||||
class LoseView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
|
class LoseView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
//Title
|
||||||
val header = Components.header()
|
val header = Components.header()
|
||||||
.withText("Game Over")
|
.withText("Game Over")
|
||||||
.withAlignmentWithin(screen, ComponentAlignment.CENTER)
|
.withAlignmentWithin(screen, ComponentAlignment.CENTER)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
//Reset Button
|
||||||
val restartButton = Components.button()
|
val restartButton = Components.button()
|
||||||
.withAlignmentAround(header, ComponentAlignment.BOTTOM_LEFT)
|
.withAlignmentAround(header, ComponentAlignment.BOTTOM_LEFT)
|
||||||
.withText("Restart")
|
.withText("Restart")
|
||||||
.withDecorations(box())
|
.withDecorations(box())
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
//Quit Button
|
||||||
val exitButton = Components.button()
|
val exitButton = Components.button()
|
||||||
.withAlignmentAround(header, ComponentAlignment.BOTTOM_RIGHT)
|
.withAlignmentAround(header, ComponentAlignment.BOTTOM_RIGHT)
|
||||||
.withText("Quit")
|
.withText("Quit")
|
||||||
.withDecorations(box())
|
.withDecorations(box())
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
//On Reset Button activated, move back to PlayView
|
||||||
restartButton.onActivated {
|
restartButton.onActivated {
|
||||||
replaceWith(PlayView(grid))
|
replaceWith(PlayView(grid))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//On Quit BUtton activated, exit program
|
||||||
exitButton.onActivated {
|
exitButton.onActivated {
|
||||||
exitProcess(0)
|
exitProcess(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Bake the cake
|
||||||
screen.addComponents(header, restartButton, exitButton)
|
screen.addComponents(header, restartButton, exitButton)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,6 +11,7 @@ import org.hexworks.zircon.api.view.base.BaseView
|
||||||
|
|
||||||
class PlayView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
|
class PlayView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
|
||||||
init {
|
init {
|
||||||
|
//Create Lose Button
|
||||||
val loseButton = Components.button()
|
val loseButton = Components.button()
|
||||||
// constants like LEFT_CENTER can also be imported for brevity
|
// constants like LEFT_CENTER can also be imported for brevity
|
||||||
.withAlignmentWithin(screen, LEFT_CENTER)
|
.withAlignmentWithin(screen, LEFT_CENTER)
|
||||||
|
@ -18,16 +19,20 @@ class PlayView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
|
||||||
.withDecorations(box(), shadow())
|
.withDecorations(box(), shadow())
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
//Create Win BUtton
|
||||||
val winButton = Components.button()
|
val winButton = Components.button()
|
||||||
.withAlignmentWithin(screen, RIGHT_CENTER)
|
.withAlignmentWithin(screen, RIGHT_CENTER)
|
||||||
.withText("Win!")
|
.withText("Win!")
|
||||||
.withDecorations(box(), shadow())
|
.withDecorations(box(), shadow())
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
//On Win Button activated, move to WinView
|
||||||
winButton.onActivated { replaceWith(WinView(grid)) }
|
winButton.onActivated { replaceWith(WinView(grid)) }
|
||||||
|
//On Lose Button activated, move to LoseView
|
||||||
loseButton.onActivated { replaceWith(LoseView(grid)) }
|
loseButton.onActivated { replaceWith(LoseView(grid)) }
|
||||||
|
|
||||||
// multiple components can be added once
|
// multiple components can be added once
|
||||||
|
// Bake The Cake
|
||||||
screen.addComponents(loseButton, winButton)
|
screen.addComponents(loseButton, winButton)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,7 +2,6 @@ package group.ouroboros.potrogue.view
|
||||||
|
|
||||||
import group.ouroboros.potrogue.GAME_ID
|
import group.ouroboros.potrogue.GAME_ID
|
||||||
import group.ouroboros.potrogue.GAME_THEME
|
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.box
|
||||||
import org.hexworks.zircon.api.ComponentDecorations.shadow
|
import org.hexworks.zircon.api.ComponentDecorations.shadow
|
||||||
import org.hexworks.zircon.api.Components
|
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
|
// We can add multiple components at once
|
||||||
|
//Bake The Cake
|
||||||
screen.addComponents(header, startButton)
|
screen.addComponents(header, startButton)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -13,31 +13,38 @@ import kotlin.system.exitProcess
|
||||||
class WinView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
|
class WinView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
//Title
|
||||||
val header = Components.header()
|
val header = Components.header()
|
||||||
.withText("You won!")
|
.withText("You won!")
|
||||||
.withAlignmentWithin(screen, ComponentAlignment.CENTER)
|
.withAlignmentWithin(screen, ComponentAlignment.CENTER)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
//Create Reset Button
|
||||||
val restartButton = Components.button()
|
val restartButton = Components.button()
|
||||||
.withAlignmentAround(header, ComponentAlignment.BOTTOM_LEFT)
|
.withAlignmentAround(header, ComponentAlignment.BOTTOM_LEFT)
|
||||||
.withText("Restart")
|
.withText("Restart")
|
||||||
.withDecorations(box())
|
.withDecorations(box())
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
|
||||||
|
//Create Quit Button
|
||||||
val exitButton = Components.button()
|
val exitButton = Components.button()
|
||||||
.withAlignmentAround(header, ComponentAlignment.BOTTOM_RIGHT)
|
.withAlignmentAround(header, ComponentAlignment.BOTTOM_RIGHT)
|
||||||
.withText("Quit")
|
.withText("Quit")
|
||||||
.withDecorations(box())
|
.withDecorations(box())
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
//On Reset Button activated, move back to PlayView
|
||||||
restartButton.onActivated {
|
restartButton.onActivated {
|
||||||
replaceWith(PlayView(grid))
|
replaceWith(PlayView(grid))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//On Quit Button activated, exit program
|
||||||
exitButton.onActivated {
|
exitButton.onActivated {
|
||||||
exitProcess(0)
|
exitProcess(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Bake The Cake
|
||||||
screen.addComponents(header, restartButton, exitButton)
|
screen.addComponents(header, restartButton, exitButton)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue