Noah Petherbridge
3d08291bc5
* Load SDL2 fonts from go-bindata storage so we don't have to ship external font files on disk. * Dedupe names of doodads so we don't show double on the front-end (go-bindata bundled doodads + those on local filesystem) * Use go-bindata for accessing wallpaper images. * Better flashed messages walking you through the Link Tool. * Stylize the title screen (MainScene) by rendering a live example level as the background wallpaper, with mobile doodads in motion.
36 lines
764 B
Go
36 lines
764 B
Go
package uix
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"git.kirsle.net/apps/doodle/pkg/shmem"
|
|
)
|
|
|
|
// LinkStart initializes the Link tool.
|
|
func (w *Canvas) LinkStart() {
|
|
w.Tool = LinkTool
|
|
w.linkFirst = nil
|
|
}
|
|
|
|
// LinkAdd adds an actor to be linked in the Link tool.
|
|
func (w *Canvas) LinkAdd(a *Actor) error {
|
|
if w.linkFirst == nil {
|
|
// First click, hold onto this actor.
|
|
w.linkFirst = a
|
|
shmem.Flash("Doodad '%s' selected, click the next Doodad to link it to",
|
|
a.Doodad.Title,
|
|
)
|
|
} else {
|
|
// Second click, call the OnLinkActors handler with the two actors.
|
|
if w.OnLinkActors != nil {
|
|
w.OnLinkActors(w.linkFirst, a)
|
|
} else {
|
|
return errors.New("Canvas.LinkAdd: no OnLinkActors handler is ready")
|
|
}
|
|
|
|
// Reset the link state.
|
|
w.linkFirst = nil
|
|
}
|
|
return nil
|
|
}
|