First pass at displaying Menu files
This commit is contained in:
@@ -5,25 +5,32 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"ur.gs/ordoor/internal/data"
|
||||
"ur.gs/ordoor/internal/maps"
|
||||
"ur.gs/ordoor/internal/menus"
|
||||
"ur.gs/ordoor/internal/sets"
|
||||
)
|
||||
|
||||
var (
|
||||
gamePath = flag.String("game-path", "./orig", "Path to a WH40K: Chaos Gate installation")
|
||||
skipObj = flag.Bool("skip-obj", true, "Skip loading .obj files")
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
loadData()
|
||||
loadObj()
|
||||
|
||||
if !*skipObj {
|
||||
loadObj()
|
||||
}
|
||||
|
||||
loadMapsFrom("Maps")
|
||||
loadMapsFrom("MultiMaps")
|
||||
loadSets()
|
||||
loadMenus()
|
||||
}
|
||||
|
||||
func loadData() {
|
||||
@@ -128,3 +135,33 @@ func loadSets() {
|
||||
fmt.Printf(" * `%s`: center expected=%d actual=%d\n", key, mapSet.CenterCount, len(mapSet.CenterPalette))
|
||||
}
|
||||
}
|
||||
|
||||
func loadMenus() {
|
||||
menusPath := filepath.Join(*gamePath, "Menu")
|
||||
|
||||
menus, err := menus.LoadMenus(menusPath)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to parse %s/*.mnu as menus: %v", menusPath, err)
|
||||
}
|
||||
|
||||
for _, menu := range menus {
|
||||
fmt.Printf(" * `%s`: objects=%v fonts=%v\n", menu.Name, menu.ObjectFiles, menu.FontNames)
|
||||
for _, record := range menu.Records {
|
||||
displayRecord(record, 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func displayRecord(record *menus.Record, depth int) {
|
||||
content := fmt.Sprintf("id=%v type=%v sprite=%v", record.Id, record.Type, record.SpriteId)
|
||||
|
||||
if !record.Active {
|
||||
content = "(" + content + ")"
|
||||
}
|
||||
|
||||
fmt.Printf("%s* %s\n", strings.Repeat(" ", depth), content)
|
||||
|
||||
for _, child := range record.Children {
|
||||
displayRecord(child, depth+1)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user