Skip to content

Commit

Permalink
Fix executable relative asset loading regression
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-holmes committed Mar 20, 2018
1 parent 73abfdf commit a1e3672
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Changelog
---------
* 2.0.5
* Fix regression in loading assets relative to executable.
* 2.0.4
* UI
* Change the load screen
Expand Down
6 changes: 4 additions & 2 deletions game/intro.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type IntroScreen struct {
func (intro *IntroScreen) setInitialFont() {
fonts := intro.fonts

configuredFontPath, err := filepath.Abs(path.Join(AssetRoot, Font))
configuredFontPath, err := filepath.Abs(Font)
if err != nil {
log.Panicln("Your file system is broken", err)
}
Expand Down Expand Up @@ -198,9 +198,11 @@ func getAvailableFonts() *availableFonts {
}
}

return &availableFonts{
available := &availableFonts{
fonts: fontNames,
}

return available
}

func (intro *IntroScreen) maybeLoadSplash() {
Expand Down
7 changes: 4 additions & 3 deletions game/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ func main() {

var AssetRoot string

var DefaultFontPath string

var NoVSync = true
var Seed int64
var Font string
var FontW int
var FontH int

var DefaultFontPath string = path.Join(AssetRoot, "assets", "font", "cp437_12x12.png")

func GameSeed() int64 {
if Seed == -1 {
return time.Now().UnixNano()
Expand All @@ -153,13 +153,14 @@ func init() {
AssetRoot = ""
} else {
AssetRoot = filepath.Dir(AssetRoot)
log.Printf("Loading assets from %s", AssetRoot)
}
DefaultFontPath = path.Join(AssetRoot, "assets", "font", "cp437_12x12.png")

flag.BoolVar(&NoVSync, "no-vsync", false, "disable vsync")
flag.Int64Var(&Seed, "seed", -1, "Provide a seed for launching the game")
flag.StringVar(&Font, "font-path", DefaultFontPath, "Set font relative file path")
flag.IntVar(&FontW, "font-width", 12, "pixel width per character")
flag.IntVar(&FontH, "font-height", 12, "pixel height per character")
log.Println("DefaultFontPath", DefaultFontPath)
flag.Parse()
}

0 comments on commit a1e3672

Please sign in to comment.