-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathloading.go
45 lines (40 loc) · 1018 Bytes
/
loading.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package oak
import (
"io/fs"
"github.com/oakmound/oak/v4/audio"
"github.com/oakmound/oak/v4/dlog"
"github.com/oakmound/oak/v4/fileutil"
"github.com/oakmound/oak/v4/render"
"golang.org/x/sync/errgroup"
)
func (w *Window) loadAssets(imageDir, audioDir string) {
var eg errgroup.Group
eg.Go(func() error {
err := render.BlankBatchLoad(imageDir, w.config.BatchLoadOptions.MaxImageFileSize)
if err != nil {
return err
}
dlog.Verb("Done Loading Images")
return nil
})
eg.Go(func() error {
var err error
if w.config.BatchLoadOptions.BlankOutAudio {
err = audio.BlankBatchLoad(audioDir)
} else {
err = audio.BatchLoad(audioDir)
}
dlog.Verb("Done Loading Audio")
return err
})
dlog.ErrorCheck(eg.Wait())
}
func (w *Window) endLoad() {
dlog.Verb("Done Loading")
w.NextScene()
}
// SetFS updates all calls oak or oak's subpackages will make to read from the given filesystem.
// By default, this is set to os.DirFS(".")
func SetFS(filesystem fs.FS) {
fileutil.FS = filesystem
}