Beginnings of a WH40K.EXE implementation
So far, we just play the opening credits on an external video player. I want to start loading and displaying the menus next. Perhaps I can get the entire non-gameplay flow working?
This commit is contained in:
36
internal/wh40k/videos.go
Normal file
36
internal/wh40k/videos.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package wh40k
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func (w *WH40K) PlayVideo(name string, skippable bool) {
|
||||
// TODO: allow the video to be skipped by pressing the ESC key or so. For
|
||||
// now, skip unconditionally
|
||||
if skippable {
|
||||
log.Printf("TODO: Make videos conditionally skippable")
|
||||
return
|
||||
}
|
||||
|
||||
filename := w.Config.DataFile("SMK/" + name + ".smk")
|
||||
|
||||
if len(w.Config.VideoPlayer) == 0 {
|
||||
log.Printf("Video player not configured, skipping video %v", filename)
|
||||
return
|
||||
}
|
||||
|
||||
argc := w.Config.VideoPlayer[0]
|
||||
argv := append(w.Config.VideoPlayer[1:], filename)
|
||||
if err := exec.Command(argc, argv...).Run(); err != nil {
|
||||
log.Printf("Error playing video %v: %v", filename, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (w *WH40K) PlayUnskippableVideo(name string) {
|
||||
w.PlayVideo(name, false)
|
||||
}
|
||||
|
||||
func (w *WH40K) PlaySkippableVideo(name string) {
|
||||
w.PlayVideo(name, true)
|
||||
}
|
30
internal/wh40k/wh40k.go
Normal file
30
internal/wh40k/wh40k.go
Normal file
@@ -0,0 +1,30 @@
|
||||
// package wh40k implements the full WH40K.EXE functionality, and is used from
|
||||
// cmd/wh40k/main.go
|
||||
//
|
||||
// Entrypoint is Run()
|
||||
package wh40k
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"ur.gs/ordoor/internal/config"
|
||||
)
|
||||
|
||||
type WH40K struct {
|
||||
Config *config.Config
|
||||
}
|
||||
|
||||
func Run(configFile string) error {
|
||||
cfg, err := config.Load(configFile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Couldn't load config file: %v", err)
|
||||
}
|
||||
|
||||
wh40k := &WH40K{
|
||||
Config: cfg,
|
||||
}
|
||||
|
||||
wh40k.PlayUnskippableVideo("LOGOS")
|
||||
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user