TheMathemagicians/sevenkeys/ui/view.go

34 lines
822 B
Go

package ui
import (
"os"
"path/filepath"
"strings"
"github.com/lukesampson/figlet/figletlib"
)
func (m Model) View() string {
var ui string
if m.WindowWidth <= 0 {
return ui
}
// Get fonts for figlet
cwd, _ := os.Getwd()
fontsdir := filepath.Join(cwd, "fonts")
slantFont, _ := figletlib.GetFontByName(fontsdir, "slant")
termFont, _ := figletlib.GetFontByName(fontsdir, "term")
// Display splash screen
ui += figletlib.SprintMsg("SEVENKEYS", slantFont, m.WindowWidth, slantFont.Settings(), "center")
ui += figletlib.SprintMsg("the ultimate Magic: the Gathering trading card storage system", termFont, m.WindowWidth, termFont.Settings(), "center")
// Display help
ui += strings.Repeat("\n", m.WindowHeight-8) // TODO: Avoid hardcoding height somehow
ui += m.Help.View(DefaultKeyMap)
return ui
}