tis100e/screen_about.go

82 lines
2.0 KiB
Go

package main
import (
"fmt"
"github.com/nsf/termbox-go"
"gogs.bullercodeworks.com/brian/termbox-util"
)
type Command struct {
key string
description string
}
type AboutScreen int
func drawCommandsAtPoint(commands []Command, x int, y int, style Style) {
x_pos, y_pos := x, y
for index, cmd := range commands {
termbox_util.DrawStringAtPoint(fmt.Sprintf("%6s", cmd.key), x_pos, y_pos, style.default_fg, style.default_bg)
termbox_util.DrawStringAtPoint(cmd.description, x_pos+8, y_pos, style.default_fg, style.default_bg)
y_pos++
if index > 2 && index%2 == 1 {
y_pos++
}
}
}
func (screen *AboutScreen) handleKeyEvent(event termbox.Event) int {
return MAIN_SCREEN_INDEX
}
func (screen *AboutScreen) performLayout() {}
func (screen *AboutScreen) drawScreen(style Style) {
default_fg := style.default_fg
default_bg := style.default_bg
width, height := termbox.Size()
template := [...]string{
" ______________________ ____ ",
" /_ __/ _/ ___< / __ \\/ __ \\___ ",
" / / / / \\__ \\/ / / / / / / / _ \\",
" / / _/ / ___/ / / /_/ / /_/ / __/",
"/_/ /___//____/_/\\____/\\____/\\___/ ",
" ",
}
first_line := template[0]
start_x := (width - len(first_line)) / 2
start_y := ((height - 2*len(template)) / 2) - 2
x_pos, y_pos := start_x, start_y
if height < 15 {
start_y = 0
y_pos = 0
}
for _, line := range template {
x_pos = start_x
for _, runeValue := range line {
bg := default_bg
displayRune := ' '
if runeValue != ' ' {
displayRune = runeValue
termbox.SetCell(x_pos, y_pos, displayRune, default_fg, bg)
}
x_pos++
}
y_pos++
}
commands1 := [...]Command{
{"Ctrl+←", "Move to Node Left"},
{"Ctrl+↓", "Move to Node Down"},
{"Ctrl+↑", "Move to Node Up"},
{"Ctrl+→", "Move to Node Right"},
}
x_pos = start_x
y_pos++
drawCommandsAtPoint(commands1[:], x_pos, y_pos+1, style)
exit_txt := "Press any key to return to emulator"
termbox_util.DrawStringAtPoint(exit_txt, (width-len(exit_txt))/2, height-1, style.title_fg, style.title_bg)
}