2016-01-06 18:24:08 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nsf/termbox-go"
|
|
|
|
"gogs.bullercodeworks.com/brian/termbox-util"
|
|
|
|
)
|
|
|
|
|
|
|
|
type command struct {
|
|
|
|
key string
|
|
|
|
description string
|
|
|
|
}
|
|
|
|
|
|
|
|
type titleScreen struct {
|
|
|
|
titleArt *termboxUtil.ASCIIArt
|
|
|
|
menu *termboxUtil.Menu
|
|
|
|
initialized bool
|
|
|
|
}
|
|
|
|
|
2016-01-07 04:04:42 +00:00
|
|
|
func (screen *titleScreen) handleKeyPress(event termbox.Event) int {
|
2016-01-06 18:24:08 +00:00
|
|
|
if screen.menu.HandleKeyPress(event) {
|
|
|
|
if screen.menu.IsDone() {
|
|
|
|
selOpt := screen.menu.GetSelectedOption()
|
|
|
|
if selOpt.GetText() == "Exit" {
|
|
|
|
return exitScreenIndex
|
|
|
|
} else if selOpt.GetText() == "New Game" {
|
|
|
|
screen.initialized = false
|
|
|
|
return mainScreenIndex
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return titleScreenIndex
|
|
|
|
}
|
|
|
|
|
|
|
|
func (screen *titleScreen) performLayout(style style) {
|
|
|
|
if !screen.initialized {
|
|
|
|
var tmplt []string
|
2016-01-08 21:44:35 +00:00
|
|
|
if ScreenWidth >= 87 {
|
|
|
|
tmplt = append(tmplt, " ________ .__ __________ __ __ .__ ")
|
|
|
|
tmplt = append(tmplt, " / _____/ ____ ______ | |__ ___________ \\______ _____ _/ |__/ |_| | ____ ")
|
|
|
|
tmplt = append(tmplt, "/ \\ ___ / _ \\\\____ \\| | \\_/ __ \\_ __ \\ | | _\\__ \\\\ __\\ __| | _/ __ \\ ")
|
|
|
|
tmplt = append(tmplt, "\\ \\_\\ ( <_> | |_> | Y \\ ___/| | \\/ | | \\/ __ \\| | | | | |_\\ ___/ ")
|
|
|
|
tmplt = append(tmplt, " \\______ /\\____/| __/|___| /\\___ |__| |______ (____ |__| |__| |____/\\___ >")
|
|
|
|
tmplt = append(tmplt, " \\/ |__| \\/ \\/ \\/ \\/ \\/ ")
|
|
|
|
} else {
|
|
|
|
tmplt = append(tmplt, " ")
|
|
|
|
tmplt = append(tmplt, " ")
|
|
|
|
tmplt = append(tmplt, " Gopher Battle ")
|
|
|
|
tmplt = append(tmplt, " ")
|
|
|
|
tmplt = append(tmplt, " ")
|
|
|
|
tmplt = append(tmplt, " ")
|
|
|
|
}
|
2016-01-06 18:24:08 +00:00
|
|
|
|
|
|
|
defaultFg := style.defaultFg
|
|
|
|
defaultBg := style.defaultBg
|
|
|
|
screen.titleArt = termboxUtil.CreateASCIIArt(tmplt, 0, 0, defaultFg, defaultBg)
|
|
|
|
w, h := termbox.Size()
|
|
|
|
screen.titleArt.Align(termboxUtil.AlignCenter, w)
|
|
|
|
|
|
|
|
menuX := w/2 - 10
|
|
|
|
menuY := h/2 - 5
|
|
|
|
|
|
|
|
screen.menu = termboxUtil.CreateMenu("",
|
|
|
|
[]string{"New Game", "Continue", "Exit"},
|
|
|
|
menuX, menuY, 20, 10, defaultFg, defaultBg,
|
|
|
|
)
|
|
|
|
// TODO: Check if we have a suspended game
|
|
|
|
screen.menu.SetOptionDisabled(1)
|
|
|
|
screen.menu.SetBordered(true)
|
|
|
|
screen.menu.EnableVimMode()
|
|
|
|
screen.initialized = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (screen *titleScreen) update() {}
|
|
|
|
|
|
|
|
func (screen *titleScreen) drawScreen(style style) {
|
|
|
|
screen.titleArt.Draw()
|
|
|
|
screen.menu.Draw()
|
|
|
|
}
|