loop: Simplify update

This commit is contained in:
Hajime Hoshi 2016-09-01 22:21:58 +09:00
parent 068bc55ded
commit b95d714eed

View File

@ -126,20 +126,17 @@ func Run(g GraphicsContext, width, height int, scale float64, title string, fps
}
func (c *runContext) update(g GraphicsContext) error {
for {
e, err := ui.CurrentUI().Update()
if err != nil {
return err
}
switch e := e.(type) {
case ui.NopEvent:
return nil
case ui.ScreenSizeEvent:
if err := g.SetSize(e.Width, e.Height, e.ActualScale); err != nil {
return err
}
e.Done <- struct{}{}
continue
case ui.CloseEvent:
return regularTermination{}
case ui.RenderEvent:
@ -147,11 +144,10 @@ func (c *runContext) update(g GraphicsContext) error {
return err
}
e.Done <- struct{}{}
return nil
default:
panic("not reach")
}
}
return nil
}
func (c *runContext) render(g GraphicsContext) error {