From 4fec362b32801648da47340a127908643ef9cb5d Mon Sep 17 00:00:00 2001 From: darkvater Date: Fri, 3 Sep 2004 19:59:05 +0000 Subject: (svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel) --- viewport.c | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) (limited to 'viewport.c') diff --git a/viewport.c b/viewport.c index a1d6614ed..60a637671 100644 --- a/viewport.c +++ b/viewport.c @@ -312,19 +312,23 @@ Point GetTileBelowCursor() return GetTileFromScreenXY(_cursor.pos.x, _cursor.pos.y); } -Point GetTileZoomCenter(bool in) + +Point GetTileZoomCenterWindow(bool in, Window * w) { int x, y; - + ViewPort * vp; + + vp = w->viewport; + if (in) { - x = (_cursor.pos.x >> 1) + (_screen.width >> 2); - y = (_cursor.pos.y >> 1) + (_screen.height >> 2); + x = ( (_cursor.pos.x - vp->left ) >> 1) + (vp->width >> 2); + y = ( (_cursor.pos.y - vp->top ) >> 1) + (vp->height >> 2); } else { - x = _screen.width - _cursor.pos.x; - y = _screen.height - _cursor.pos.y; + x = vp->width - (_cursor.pos.x - vp->left); + y = vp->height - (_cursor.pos.y - vp->top); } - return GetTileFromScreenXY(x, y); + return GetTileFromScreenXY(x+vp->left, y+vp->top); } void DrawGroundSpriteAt(uint32 image, int16 x, int16 y, byte z) @@ -1708,6 +1712,32 @@ void PlaceObject() } } + +/* scrolls the viewport in a window to a given location */ +bool ScrollWindowTo(int x , int y, Window * w) +{ + Point pt; + + pt = MapXYZToViewport(w->viewport, x, y, GetSlopeZ(x, y)); + WP(w,vp_d).follow_vehicle = -1; + + if (WP(w,vp_d).scrollpos_x == pt.x && + WP(w,vp_d).scrollpos_y == pt.y) + return false; + + WP(w,vp_d).scrollpos_x = pt.x; + WP(w,vp_d).scrollpos_y = pt.y; + return true; +} + +/* scrolls the viewport in a window to a given tile */ +bool ScrollWindowToTile(TileIndex tile, Window * w) +{ + return ScrollWindowTo(GET_TILE_X(tile)*16+8, GET_TILE_Y(tile)*16+8, w); +} + + + bool ScrollMainWindowTo(int x, int y) { Window *w = FindWindowById(WC_MAIN_WINDOW, 0); -- cgit v1.2.3-54-g00ecf