Noah Petherbridge
87416f9740
* On the Doodads tab is the Link button to enter the Link Tool. * Click Link, then click the 1st doodad on the level, then click the 2nd doodad to complete the link. * The actors struct in the Level holds the link IDs for each actor.
29 lines
632 B
Go
29 lines
632 B
Go
package uix
|
|
|
|
import "errors"
|
|
|
|
// 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
|
|
} else {
|
|
// Second click, call the OnLinkActors handler with the two actors.
|
|
if w.OnLinkActors != nil {
|
|
w.OnLinkActors(w.linkFirst.Actor, a.Actor)
|
|
} else {
|
|
return errors.New("Canvas.LinkAdd: no OnLinkActors handler is ready")
|
|
}
|
|
|
|
// Reset the link state.
|
|
w.linkFirst = nil
|
|
}
|
|
return nil
|
|
}
|