Files
ordoor/cmd/view-menu/main.go
Nick Thomas cfa56a0e12 Implement the main menu for the ordoor binary
In this commit, we also remove code that doesn't properly belong in
view-menu
2020-03-22 19:12:44 +00:00

49 lines
895 B
Go

package main
import (
"flag"
"log"
"os"
"code.ur.gs/lupine/ordoor/internal/assetstore"
"code.ur.gs/lupine/ordoor/internal/ui"
)
var (
gamePath = flag.String("game-path", "./orig", "Path to a WH40K: Chaos Gate installation")
menuName = flag.String("menu", "", "Name of a menu, e.g. Main")
)
func main() {
flag.Parse()
if *gamePath == "" || *menuName == "" {
flag.Usage()
os.Exit(1)
}
assets, err := assetstore.New(*gamePath)
if err != nil {
log.Fatal(err)
}
menu, err := assets.Menu(*menuName)
if err != nil {
log.Fatalf("Couldn't load menu %s: %v", *menuName, err)
}
iface, err := ui.NewInterface(menu)
if err != nil {
log.Fatalf("Couldn't initialize interface: %v", err)
}
win, err := ui.NewWindow(iface, "View Menu: "+*menuName)
if err != nil {
log.Fatal("Couldn't create window: %v", err)
}
if err := win.Run(); err != nil {
log.Fatal(err)
}
}