Noah Petherbridge
a06787411d
* pkg/plus/dpp is the main plugin bridge, and defines nothing but an interface that defines the Doodle++ surface area (referring to internal game types such as doodad.Doodad or level.Level), but not their implementations. * dpp.Driver (an interface) is the main API that other parts of the game will call, for example "dpp.Driver.IsLevelSigned()" * plus_dpp.go and plus_foss.go provide the dpp.Driver implementation for their build; with plus_dpp.go generally forwarding function calls directly to the proprietary dpp package and plus_foss.go generally returning false/errors. * The bootstrap package simply assigns the above stub function to dpp.Driver * pkg/plus/bootstrap is a package directly imported by main (in the doodle and doodad programs) and it works around circular dependency issues: this package simply assigns dpp.Driver to the DPP or FOSS version. Miscellaneous fixes: * File->Open in the editor and PlayScene will use the new Open Level window instead of loading the legacy GotoLoadMenu scene. * Deprecated legacy scenes: d.GotoLoadMenu() and d.GotoPlayMenu(). * The doodle-admin program depends on the private dpp package, so can not be compiled in FOSS mode.
67 lines
2.1 KiB
Go
67 lines
2.1 KiB
Go
package doodle
|
|
|
|
// XXX REFACTOR XXX
|
|
// This function only uses EditorUI and not Doodle and is a candidate for
|
|
// refactor into a subpackage if EditorUI itself can ever be decoupled.
|
|
|
|
import (
|
|
"git.kirsle.net/SketchyMaze/doodle/pkg/balance"
|
|
"git.kirsle.net/SketchyMaze/doodle/pkg/doodads"
|
|
"git.kirsle.net/SketchyMaze/doodle/pkg/level"
|
|
"git.kirsle.net/SketchyMaze/doodle/pkg/log"
|
|
"git.kirsle.net/SketchyMaze/doodle/pkg/plus/dpp"
|
|
"git.kirsle.net/SketchyMaze/doodle/pkg/uix"
|
|
"git.kirsle.net/go/render"
|
|
)
|
|
|
|
// DraggableActor is a Doodad being dragged from the Doodad palette.
|
|
type DraggableActor struct {
|
|
canvas *uix.Canvas
|
|
doodad *doodads.Doodad // if a new one from the palette
|
|
actor *level.Actor // if a level actor
|
|
}
|
|
|
|
// Teardown the DraggableActor and free its textures.
|
|
func (da *DraggableActor) Teardown() {
|
|
log.Debug("Teardown DraggableActor")
|
|
da.canvas.Destroy()
|
|
}
|
|
|
|
// startDragActor begins the drag event for a Doodad onto a level.
|
|
// actor may be nil (if you drag a new doodad from the palette) or otherwise
|
|
// is an existing actor from the level.
|
|
func (u *EditorUI) startDragActor(doodad *doodads.Doodad, actor *level.Actor) {
|
|
u.Supervisor.DragStart()
|
|
|
|
if doodad == nil {
|
|
if actor != nil {
|
|
obj, err := dpp.Driver.LoadFromEmbeddable(actor.Filename, u.Scene.Level, false)
|
|
if err != nil {
|
|
log.Error("startDragExistingActor: actor doodad name %s not found: %s", actor.Filename, err)
|
|
return
|
|
}
|
|
doodad = obj
|
|
} else {
|
|
panic("EditorUI.startDragActor: doodad AND/OR actor is required, but neither were given")
|
|
}
|
|
}
|
|
|
|
// Size and scale this doodad according to the zoom level.
|
|
size := doodad.Size
|
|
size.W = u.Canvas.ZoomMultiply(size.W)
|
|
size.H = u.Canvas.ZoomMultiply(size.H)
|
|
|
|
// Create the canvas to render on the mouse cursor.
|
|
drawing := uix.NewCanvas(doodad.Layers[0].Chunker.Size, false)
|
|
drawing.LoadDoodad(doodad)
|
|
drawing.Resize(size)
|
|
drawing.Zoom = u.Canvas.Zoom
|
|
drawing.SetBackground(render.RGBA(0, 0, 1, 0)) // TODO: invisible becomes white
|
|
drawing.MaskColor = balance.DragColor // blueprint effect
|
|
u.DraggableActor = &DraggableActor{
|
|
canvas: drawing,
|
|
doodad: doodad,
|
|
actor: actor,
|
|
}
|
|
}
|