// Update implements gruid.Model.Update for Replay. It considers mouse message
// coordinates to be absolute in its grid. If a gruid.MsgInit is passed to
// Update, the replay will behave as if it is the main model of an application,
// and send a gruid.Quit() command on a quit request.
Update implements gruid.Model.Update for Replay. It considers mouse message
coordinates to be absolute in its grid. If a gruid.MsgInit is passed to
Update, the replay will behave as if it is the main model of an application,
and send a gruid.Quit() command on a quit request.
// Update implements gruid . Model . Update for Replay . It considers mouse message // coordinates to be absolute in its grid . If a gruid . MsgInit is passed to // Update the replay will behave as if it is the main model of an application // and send a gruid . Quit () command on a quit request .
func (rep *Replay) Update(msg gruid.Msg) gruid.Effect {
	rep.action = replayNone
	if rep.help {
		return rep.updateHelp(msg)
	}
	switch msg := msg.(type) {
	case gruid.MsgInit:
		rep.init = true
		rep.decodeNext()
		return rep.tick()
	case gruid.MsgKeyDown:
		eff := rep.updateMsgKeyDown(msg)
		if eff != nil {
			return eff
		}
	case gruid.MsgMouse:
		rep.updateMsgMouse(msg)
	case msgTick:
		if rep.auto && rep.fidx == int(msg) {
			rep.action = replayNext
		}
	}
	rep.handleAction()
	rep.draw()
	if !rep.auto || rep.fidx > len(rep.frames)-1 || rep.action == replayNone {
		return nil
	}
	return rep.tick()
}
func ( rep * Replay ) Update ( msg gruid . Msg ) gruid . Effect { rep . action = replayNone if rep . help { return rep . updateHelp ( msg ) } switch msg := msg . ( type ) { case gruid . MsgInit : rep . init = true rep . decodeNext ( ) return rep . tick ( ) case gruid . MsgKeyDown : eff := rep . updateMsgKeyDown ( msg ) if eff != nil { return eff } case gruid . MsgMouse : rep . updateMsgMouse ( msg ) case msgTick : if rep . auto && rep . fidx == int ( msg ) { rep . action = replayNext } } rep . handleAction ( ) rep . draw ( ) if ! rep . auto || rep . fidx > len ( rep . frames ) - 1 || rep . action == replayNone { return nil } return rep . tick ( ) }
Update implements gruid.Model.Update for Replay.
Update implements gruid . Model . Update for Replay .