Adjustments following kind discussion with LunarJetman on IRC
This commit is contained in:
@@ -12,7 +12,7 @@ type WH40K struct {
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
WH40K `toml:"wh40k"`
|
||||
WH40K `toml:"ordoor"`
|
||||
}
|
||||
|
||||
func Load(filename string) (*Config, error) {
|
||||
|
@@ -1,8 +1,8 @@
|
||||
// package wh40k implements the full WH40K.EXE functionality, and is used from
|
||||
// cmd/wh40k/main.go
|
||||
// package ordoor implements the full WH40K.EXE functionality, and is used from
|
||||
// cmd/ordoor/main.go
|
||||
//
|
||||
// Entrypoint is Run()
|
||||
package wh40k
|
||||
package ordoor
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"code.ur.gs/lupine/ordoor/internal/config"
|
||||
)
|
||||
|
||||
type WH40K struct {
|
||||
type Ordoor struct {
|
||||
Config *config.Config
|
||||
}
|
||||
|
||||
@@ -20,12 +20,12 @@ func Run(configFile string) error {
|
||||
return fmt.Errorf("Couldn't load config file: %v", err)
|
||||
}
|
||||
|
||||
wh40k := &WH40K{
|
||||
ordoor := &Ordoor{
|
||||
Config: cfg,
|
||||
}
|
||||
|
||||
wh40k.PlaySkippableVideo("LOGOS")
|
||||
wh40k.PlaySkippableVideo("movie1")
|
||||
ordoor.PlaySkippableVideo("LOGOS")
|
||||
ordoor.PlaySkippableVideo("movie1")
|
||||
|
||||
// TODO: load main interface
|
||||
|
35
internal/ordoor/videos.go
Normal file
35
internal/ordoor/videos.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package ordoor
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func (o *Ordoor) PlayVideo(name string, skippable bool) {
|
||||
filename := o.Config.DataFile("SMK/" + name + ".smk")
|
||||
|
||||
if len(o.Config.VideoPlayer) == 0 {
|
||||
log.Printf("Video player not configured, skipping video %v", filename)
|
||||
return
|
||||
}
|
||||
|
||||
argc := o.Config.VideoPlayer[0]
|
||||
argv := append(o.Config.VideoPlayer[1:])
|
||||
if skippable {
|
||||
argv = append(argv, "--input-conf=skippable.mpv.conf")
|
||||
}
|
||||
|
||||
argv = append(argv, filename)
|
||||
|
||||
if err := exec.Command(argc, argv...).Run(); err != nil {
|
||||
log.Printf("Error playing video %v: %v", filename, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (o *Ordoor) PlayUnskippableVideo(name string) {
|
||||
o.PlayVideo(name, false)
|
||||
}
|
||||
|
||||
func (o *Ordoor) PlaySkippableVideo(name string) {
|
||||
o.PlayVideo(name, true)
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
package wh40k
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func (w *WH40K) PlayVideo(name string, skippable bool) {
|
||||
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:])
|
||||
if skippable {
|
||||
argv = append(argv, "--input-conf=skippable.mpv.conf")
|
||||
}
|
||||
|
||||
argv = append(argv, 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)
|
||||
}
|
Reference in New Issue
Block a user