Source the palette name from data

This commit is contained in:
2020-06-01 01:24:44 +01:00
parent c1268e8d57
commit 3866ee07a8
8 changed files with 35 additions and 22 deletions

View File

@@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"
"image/color"
"log"
"path/filepath"
"strings"
@@ -13,6 +14,7 @@ import (
"code.ur.gs/lupine/ordoor/internal/idx"
"code.ur.gs/lupine/ordoor/internal/maps"
"code.ur.gs/lupine/ordoor/internal/menus"
"code.ur.gs/lupine/ordoor/internal/palettes"
"code.ur.gs/lupine/ordoor/internal/sets"
)
@@ -33,6 +35,10 @@ func main() {
}
engine := cfg.DefaultEngine()
gamePath := engine.DataDir
palette, ok := palettes.Get(engine.Palette)
if !ok {
log.Fatalf("Unknown palette name: %v", engine.Palette)
}
loadData(filepath.Join(gamePath, "Data"))
@@ -43,7 +49,7 @@ func main() {
loadMapsFrom(filepath.Join(gamePath, "Maps"))
loadMapsFrom(filepath.Join(gamePath, "MultiMaps"))
loadSets(filepath.Join(gamePath, "Sets"))
loadMenus(filepath.Join(gamePath, "Menu"))
loadMenus(filepath.Join(gamePath, "Menu"), palette)
loadFonts(filepath.Join(gamePath, "Fonts"))
loadIdx(filepath.Join(gamePath, "Idx", "WarHammer.idx"))
}
@@ -163,10 +169,10 @@ func loadSets(setsPath string) {
}
}
func loadMenus(menusPath string) {
func loadMenus(menusPath string, palette color.Palette) {
log.Printf("Loading menus from %s", menusPath)
menus, err := menus.LoadMenus(menusPath)
menus, err := menus.LoadMenus(menusPath, palette)
if err != nil {
log.Fatalf("Failed to parse %s/*.mnu as menus: %v", menusPath, err)
}