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 } func (screen *titleScreen) handleKeyPress(event termbox.Event) int { 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 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, " ") } 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() }