refactor preset loading
This commit is contained in:
parent
75ba1e8134
commit
4a9b17f4ed
30
cmd/root.go
30
cmd/root.go
|
@ -44,6 +44,22 @@ func (s *script) load(path string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func getPresets() []string {
|
||||
var presets []string
|
||||
|
||||
if preset != "" {
|
||||
presets = []string{preset}
|
||||
}
|
||||
|
||||
if scriptPath != "" {
|
||||
var s script
|
||||
s.load(scriptPath)
|
||||
presets = s.Presets
|
||||
}
|
||||
|
||||
return presets
|
||||
}
|
||||
|
||||
func handleWindowEvent(event *sdl.WindowEvent, m *milkDropWindow) {
|
||||
switch event.Event {
|
||||
case sdl.WINDOWEVENT_RESIZED:
|
||||
|
@ -84,24 +100,14 @@ func milkbucket(cmd *cobra.Command, args []string) {
|
|||
log.Fatal("nothing to read from stdin")
|
||||
}
|
||||
|
||||
var presets []string
|
||||
|
||||
if preset != "" {
|
||||
presets = []string{preset}
|
||||
}
|
||||
|
||||
if scriptPath != "" {
|
||||
var s script
|
||||
s.load(scriptPath)
|
||||
presets = s.Presets
|
||||
}
|
||||
|
||||
err = sdl.Init(sdl.INIT_VIDEO)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer sdl.Quit()
|
||||
|
||||
presets := getPresets()
|
||||
|
||||
m, err := newMilkDropWindow(800, 600, presets)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
Loading…
Reference in New Issue