wip
This commit is contained in:
15
PBMap.pb
15
PBMap.pb
@@ -1047,7 +1047,7 @@ Module PBMap
|
|||||||
EndSelect
|
EndSelect
|
||||||
If PBMap\Zoom > PBMap\ZoomMax : PBMap\Zoom = PBMap\ZoomMax : EndIf
|
If PBMap\Zoom > PBMap\ZoomMax : PBMap\Zoom = PBMap\ZoomMax : EndIf
|
||||||
If PBMap\Zoom < PBMap\ZoomMin : PBMap\Zoom = PBMap\ZoomMin : EndIf
|
If PBMap\Zoom < PBMap\ZoomMin : PBMap\Zoom = PBMap\ZoomMin : EndIf
|
||||||
LatLon2XY(@PBMap\TargetLocation, @PBMap\Drawing)
|
LatLon2XY(@PBMap\TargetLocation, @PBMap\Drawing\Position)
|
||||||
;Convert X, Y in tile.decimal into real pixels
|
;Convert X, Y in tile.decimal into real pixels
|
||||||
PBMap\Position\X = PBMap\Drawing\Position\x * PBMap\TileSize
|
PBMap\Position\X = PBMap\Drawing\Position\x * PBMap\TileSize
|
||||||
PBMap\Position\Y = PBMap\Drawing\Position\y * PBMap\TileSize
|
PBMap\Position\Y = PBMap\Drawing\Position\y * PBMap\TileSize
|
||||||
@@ -1077,6 +1077,7 @@ Module PBMap
|
|||||||
Procedure SetZoomOnPosition(x, y, zoom)
|
Procedure SetZoomOnPosition(x, y, zoom)
|
||||||
Protected MouseX.d, MouseY.d
|
Protected MouseX.d, MouseY.d
|
||||||
Protected OldPx.d, OldPy.d, OldMx.d, OldMy.d
|
Protected OldPx.d, OldPy.d, OldMx.d, OldMy.d
|
||||||
|
Protected MapWidth = Pow(2, PBMap\Zoom) * PBMap\TileSize
|
||||||
;Fast and dirty code
|
;Fast and dirty code
|
||||||
OldPx = PBMap\Position\x : OldPy = PBMap\Position\y
|
OldPx = PBMap\Position\x : OldPy = PBMap\Position\y
|
||||||
OldMx = OldPx + GadgetWidth(PBMap\Gadget) / 2 - x
|
OldMx = OldPx + GadgetWidth(PBMap\Gadget) / 2 - x
|
||||||
@@ -1085,11 +1086,15 @@ Module PBMap
|
|||||||
If PBMap\Zoom > PBMap\ZoomMax : PBMap\Zoom = PBMap\ZoomMax : EndIf
|
If PBMap\Zoom > PBMap\ZoomMax : PBMap\Zoom = PBMap\ZoomMax : EndIf
|
||||||
If PBMap\Zoom < PBMap\ZoomMin : PBMap\Zoom = PBMap\ZoomMin : EndIf
|
If PBMap\Zoom < PBMap\ZoomMin : PBMap\Zoom = PBMap\ZoomMin : EndIf
|
||||||
;Centered Zoom
|
;Centered Zoom
|
||||||
LatLon2XY(@PBMap\TargetLocation, @PBMap\Drawing)
|
LatLon2XY(@PBMap\TargetLocation, @PBMap\Drawing\Position)
|
||||||
;Convert X, Y in tile.decimal into real pixels
|
;Convert X, Y in tile.decimal into real pixels
|
||||||
MouseX = PBMap\Drawing\Position\x * PBMap\TileSize + GadgetWidth(PBMap\Gadget) / 2 - x
|
MouseX = PBMap\Drawing\Position\x * PBMap\TileSize + GadgetWidth(PBMap\Gadget) / 2 - x
|
||||||
MouseY = PBMap\Drawing\Position\y * PBMap\TileSize + GadgetHeight(PBMap\Gadget) / 2 - y
|
MouseY = PBMap\Drawing\Position\y * PBMap\TileSize + GadgetHeight(PBMap\Gadget) / 2 - y
|
||||||
|
If MouseX > MapWidth
|
||||||
|
Debug "kaboum"
|
||||||
|
EndIf
|
||||||
Debug "------" ;TODO bug when zoom near the wrap
|
Debug "------" ;TODO bug when zoom near the wrap
|
||||||
|
Debug "Mx : " +StrD(MouseX)
|
||||||
Debug PBMap\Position\x
|
Debug PBMap\Position\x
|
||||||
;Cross-multiply to get the new center
|
;Cross-multiply to get the new center
|
||||||
PBMap\Position\x = (OldPx * MouseX) / OldMx
|
PBMap\Position\x = (OldPx * MouseX) / OldMx
|
||||||
@@ -1386,8 +1391,8 @@ CompilerIf #PB_Compiler_IsMainFile
|
|||||||
|
|
||||||
CompilerEndIf
|
CompilerEndIf
|
||||||
; IDE Options = PureBasic 5.50 (Windows - x64)
|
; IDE Options = PureBasic 5.50 (Windows - x64)
|
||||||
; CursorPosition = 427
|
; CursorPosition = 1094
|
||||||
; FirstLine = 410
|
; FirstLine = 1076
|
||||||
; Folding = ----------
|
; Folding = ----------
|
||||||
; EnableThread
|
; EnableThread
|
||||||
; EnableXP
|
; EnableXP
|
||||||
|
Reference in New Issue
Block a user