WIP Zoom hell

This commit is contained in:
Noah 2021-09-11 22:21:47 -07:00
parent 0a8bce708e
commit 731d142dd6
3 changed files with 16 additions and 8 deletions

View File

@ -300,6 +300,8 @@ func (w *Canvas) loopEditable(ev *event.State) error {
// See if any of the actors are below the mouse cursor. // See if any of the actors are below the mouse cursor.
var WP = w.WorldIndexAt(cursor) var WP = w.WorldIndexAt(cursor)
// log.Debug("ActorTool, cursor=%s WP=%s zoom=%d P=%s", cursor, WP, w.Zoom, ui.AbsolutePosition(w))
var deleteActors = []*level.Actor{} var deleteActors = []*level.Actor{}
for _, actor := range w.actors { for _, actor := range w.actors {
box := render.Rect{ box := render.Rect{

View File

@ -44,6 +44,10 @@ func (w *Canvas) Present(e render.Engine, p render.Point) {
// TODO: seems unstable as shit on Zoom In?? // TODO: seems unstable as shit on Zoom In??
Viewport.W = w.ZoomDivide(Viewport.W) Viewport.W = w.ZoomDivide(Viewport.W)
Viewport.H = w.ZoomDivide(Viewport.W) Viewport.H = w.ZoomDivide(Viewport.W)
if w.Zoom > 0 {
Viewport.X = w.ZoomDivide(w.chunks.Size)
Viewport.Y = w.ZoomDivide(w.chunks.Size)
}
} }
// Disappearing chunks issue: // Disappearing chunks issue:
@ -70,10 +74,9 @@ func (w *Canvas) Present(e render.Engine, p render.Point) {
// Grow the viewport's X and Y offsets back the other // Grow the viewport's X and Y offsets back the other
// way, so chunks sliding off the screen don't unload early. // way, so chunks sliding off the screen don't unload early.
// This kinda thing makes no difference at all? // This kinda thing makes no difference at all?
// var orig = render.NewPoint(Viewport.X, Viewport.Y) // var orig = Viewport
// Viewport.X -= 256 //w.ZoomMultiply(w.chunks.Size) // Viewport.X = w.ZoomDivide(w.chunks.Size)
// Viewport.Y -= 256 //w.ZoomMultiply(w.chunks.Size) // Viewport.Y = w.ZoomDivide(w.chunks.Size)
// log.Info("Viewport: %s was: %s", Viewport, orig)
} }
// Get the chunks in the viewport and cache their textures. // Get the chunks in the viewport and cache their textures.

View File

@ -87,14 +87,17 @@ func (w *Canvas) loopConstrainScroll() error {
mw = int(w.wallpaper.maxWidth) mw = int(w.wallpaper.maxWidth)
mh = int(w.wallpaper.maxHeight) mh = int(w.wallpaper.maxHeight)
Viewport = w.Viewport() Viewport = w.Viewport()
vw = w.ZoomDivide(Viewport.W)
vh = w.ZoomDivide(Viewport.H)
) )
if Viewport.W > mw {
delta := Viewport.W - mw if vw > mw {
delta := vw - mw
w.Scroll.X += delta w.Scroll.X += delta
capped = true capped = true
} }
if Viewport.H > mh { if vh > mh {
delta := Viewport.H - mh delta := vh - mh
w.Scroll.Y += delta w.Scroll.Y += delta
capped = true capped = true
} }