handle no script being passed

This commit is contained in:
filifa 2024-09-02 22:49:29 -05:00
parent 87394e7263
commit ee984f7d72
1 changed files with 6 additions and 7 deletions

View File

@ -50,10 +50,6 @@ type script struct {
} }
func (m *milkDropWindow) loadScript(scriptPath string) error { func (m *milkDropWindow) loadScript(scriptPath string) error {
if scriptPath == "" {
return errors.New("no script given")
}
f, err := os.Open(scriptPath) f, err := os.Open(scriptPath)
if err != nil { if err != nil {
return err return err
@ -92,10 +88,13 @@ func (m *milkDropWindow) prevPreset() {
func newMilkDropWindow(width, height int32, scriptPath string) (*milkDropWindow, error) { func newMilkDropWindow(width, height int32, scriptPath string) (*milkDropWindow, error) {
var m milkDropWindow var m milkDropWindow
var err error
err := m.loadScript(scriptPath) if scriptPath != "" {
if err != nil { err = m.loadScript(scriptPath)
return nil, err if err != nil {
return nil, err
}
} }
m.window, err = sdl.CreateWindow("milkbucket", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED, width, height, sdl.WINDOW_OPENGL|sdl.WINDOW_RESIZABLE) m.window, err = sdl.CreateWindow("milkbucket", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED, width, height, sdl.WINDOW_OPENGL|sdl.WINDOW_RESIZABLE)