Start reorganising for multiple games
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"code.ur.gs/lupine/ordoor/internal/config"
|
||||
"code.ur.gs/lupine/ordoor/internal/data"
|
||||
"code.ur.gs/lupine/ordoor/internal/fonts"
|
||||
"code.ur.gs/lupine/ordoor/internal/idx"
|
||||
@@ -16,29 +17,38 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
gamePath = flag.String("game-path", "./orig", "Path to a WH40K: Chaos Gate installation")
|
||||
skipObj = flag.Bool("skip-obj", true, "Skip loading .obj files")
|
||||
configFile = flag.String("config", "config.toml", "Config file")
|
||||
engine = flag.String("engine", "", "Override engine to use")
|
||||
|
||||
skipObj = flag.Bool("skip-obj", true, "Skip loading .obj files")
|
||||
)
|
||||
|
||||
// FIXME: all these paths are hardcoded with Chaos Gate in mind
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
loadData()
|
||||
cfg, err := config.Load(*configFile, *engine)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to load config: %v", err)
|
||||
}
|
||||
engine := cfg.DefaultEngine()
|
||||
gamePath := engine.DataDir
|
||||
|
||||
loadData(filepath.Join(gamePath, "Data"))
|
||||
|
||||
if !*skipObj {
|
||||
loadObj()
|
||||
loadObj(filepath.Join(gamePath, "Obj"))
|
||||
}
|
||||
|
||||
loadMapsFrom("Maps")
|
||||
loadMapsFrom("MultiMaps")
|
||||
loadSets()
|
||||
loadMenus()
|
||||
loadFonts()
|
||||
loadIdx()
|
||||
loadMapsFrom(filepath.Join(gamePath, "Maps"))
|
||||
loadMapsFrom(filepath.Join(gamePath, "MultiMaps"))
|
||||
loadSets(filepath.Join(gamePath, "Sets"))
|
||||
loadMenus(filepath.Join(gamePath, "Menu"))
|
||||
loadFonts(filepath.Join(gamePath, "Fonts"))
|
||||
loadIdx(filepath.Join(gamePath, "Idx", "WarHammer.idx"))
|
||||
}
|
||||
|
||||
func loadData() {
|
||||
dataPath := filepath.Join(*gamePath, "Data")
|
||||
func loadData(dataPath string) {
|
||||
accountingPath := filepath.Join(dataPath, "Accounting.dat")
|
||||
aniObDefPath := filepath.Join(dataPath, "AniObDef.dat")
|
||||
genericDataPath := filepath.Join(dataPath, "GenericData.dat")
|
||||
@@ -84,9 +94,7 @@ func loadData() {
|
||||
ha.Print()
|
||||
}
|
||||
|
||||
func loadObj() {
|
||||
objDataPath := filepath.Join(*gamePath, "Obj")
|
||||
|
||||
func loadObj(objDataPath string) {
|
||||
// TODO: Obj/cpiece.rec isn't loaded by this. Do we need it? How do we know?
|
||||
log.Printf("Loading %s...", objDataPath)
|
||||
objects, err := data.LoadObjects(objDataPath)
|
||||
@@ -116,8 +124,7 @@ func loadObj() {
|
||||
}
|
||||
}
|
||||
|
||||
func loadMapsFrom(part string) {
|
||||
mapsPath := filepath.Join(*gamePath, part)
|
||||
func loadMapsFrom(mapsPath string) {
|
||||
log.Printf("Loading maps from %s", mapsPath)
|
||||
|
||||
gameMaps, err := maps.LoadGameMaps(mapsPath)
|
||||
@@ -140,8 +147,7 @@ func loadMapsFrom(part string) {
|
||||
}
|
||||
}
|
||||
|
||||
func loadSets() {
|
||||
setsPath := filepath.Join(*gamePath, "Sets")
|
||||
func loadSets(setsPath string) {
|
||||
log.Printf("Loading sets from %s", setsPath)
|
||||
|
||||
mapSets, err := sets.LoadSets(setsPath)
|
||||
@@ -157,8 +163,8 @@ func loadSets() {
|
||||
}
|
||||
}
|
||||
|
||||
func loadMenus() {
|
||||
menusPath := filepath.Join(*gamePath, "Menu")
|
||||
func loadMenus(menusPath string) {
|
||||
log.Printf("Loading menus from %s", menusPath)
|
||||
|
||||
menus, err := menus.LoadMenus(menusPath)
|
||||
if err != nil {
|
||||
@@ -187,8 +193,8 @@ func displayRecord(record *menus.Record, depth int) {
|
||||
fmt.Printf("%s* %s\n", strings.Repeat(" ", depth), content)
|
||||
}
|
||||
|
||||
func loadFonts() {
|
||||
fontsPath := filepath.Join(*gamePath, "Fonts")
|
||||
func loadFonts(fontsPath string) {
|
||||
log.Printf("Loading fonts from %s", fontsPath)
|
||||
|
||||
fonts, err := fonts.LoadFonts(fontsPath)
|
||||
if err != nil {
|
||||
@@ -200,8 +206,9 @@ func loadFonts() {
|
||||
}
|
||||
}
|
||||
|
||||
func loadIdx() {
|
||||
idxPath := filepath.Join(*gamePath, "Idx", "WarHammer.idx")
|
||||
func loadIdx(idxPath string) {
|
||||
log.Printf("Loading idx from %s", idxPath)
|
||||
|
||||
idx, err := idx.Load(idxPath)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to parse %s as idx: %v", idxPath, err)
|
||||
|
Reference in New Issue
Block a user