50 lines
797 B
Go
50 lines
797 B
Go
package main
|
|
|
|
import (
|
|
"opslag.de/schobers/krampus19/alui"
|
|
)
|
|
|
|
type navigation struct {
|
|
game *game
|
|
curr scene
|
|
}
|
|
|
|
type scene interface {
|
|
alui.Control
|
|
|
|
Enter(ctx *Context) error
|
|
Leave()
|
|
}
|
|
|
|
func (n *navigation) ChangeSettings() {
|
|
n.switchTo(&changeSettings{})
|
|
}
|
|
|
|
func (n *navigation) PlayLevel(packID, levelID string) {
|
|
n.switchTo(&playLevel{packID: packID, levelID: levelID})
|
|
}
|
|
|
|
func (n *navigation) SelectLevel(packID string) {
|
|
n.switchTo(&levelSelect{packID: packID})
|
|
}
|
|
|
|
func (n *navigation) ShowMainMenu() {
|
|
n.switchTo(&mainMenu{})
|
|
}
|
|
|
|
func (n *navigation) Quit() {
|
|
n.switchTo(nil)
|
|
}
|
|
|
|
func (n *navigation) switchTo(s scene) {
|
|
if n.curr != nil {
|
|
n.curr.Leave()
|
|
}
|
|
n.curr = s
|
|
n.game.scene.Proxy = s
|
|
n.game.scene.Visible = s != nil
|
|
if n.curr != nil {
|
|
n.curr.Enter(n.game.ctx)
|
|
}
|
|
}
|