4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
10 /** @file viewport_func.h Functions related to (drawing on) viewports. */
12 #ifndef VIEWPORT_FUNC_H
13 #define VIEWPORT_FUNC_H
15 #include "map/coord.h"
17 #include "viewport_type.h"
18 #include "window_type.h"
19 #include "station_type.h"
22 static const int TILE_HEIGHT_STEP
= 50; ///< One Z unit tile height difference is displayed as 50m.
24 void SetSelectionRed(bool);
26 void MarkTownAreaDirty (TownID town
);
28 void DeleteWindowViewport(Window
*w
);
29 void InitializeWindowViewport(Window
*w
, int x
, int y
, int width
, int height
, uint32 follow_flags
, ZoomLevel zoom
);
30 ViewPort
*IsPtInWindowViewport(const Window
*w
, int x
, int y
);
31 Point
GetTileBelowCursor();
32 void UpdateViewportPosition(Window
*w
);
34 void MarkAllViewportsDirty(int left
, int top
, int right
, int bottom
);
36 void DoZoomInOutViewport (struct ViewportData
*vp
, bool in
);
37 void ClampViewportZoom (struct ViewportData
*vp
);
38 void ZoomInOrOutToCursorWindow(bool in
, Window
* w
);
39 void HandleZoomMessage(Window
*w
, const ViewPort
*vp
, byte widget_zoom_in
, byte widget_zoom_out
);
41 void OffsetGroundSprite (struct ViewportDrawer
*vd
, int x
, int y
);
43 void DrawGroundSprite (const TileInfo
*ti
, SpriteID image
, PaletteID pal
, const SubSprite
*sub
= NULL
, int extra_offs_x
= 0, int extra_offs_y
= 0);
44 void DrawGroundSpriteAt (const TileInfo
*ti
, SpriteID image
, PaletteID pal
, int32 x
, int32 y
, int z
, const SubSprite
*sub
= NULL
, int extra_offs_x
= 0, int extra_offs_y
= 0);
45 void AddSortableSpriteToDraw (struct ViewportDrawer
*vd
, SpriteID image
, PaletteID pal
, int x
, int y
, int w
, int h
, int dz
, int z
, bool transparent
= false, int bb_offset_x
= 0, int bb_offset_y
= 0, int bb_offset_z
= 0, const SubSprite
*sub
= NULL
);
46 void AddChildSpriteScreen (struct ViewportDrawer
*vd
, SpriteID image
, PaletteID pal
, int x
, int y
, bool transparent
= false, const SubSprite
*sub
= NULL
, bool scale
= true);
47 void ViewportAddString (BlitArea
*area
, const DrawPixelInfo
*dpi
, ZoomLevel small_from
, const ViewportSign
*sign
, StringID string_normal
, StringID string_small
, StringID string_small_shadow
, uint64 params_1
, uint64 params_2
= 0, Colours colour
= INVALID_COLOUR
);
50 void StartSpriteCombine (struct ViewportDrawer
*vd
);
51 void EndSpriteCombine (struct ViewportDrawer
*vd
);
53 bool HandleViewportClicked(const ViewPort
*vp
, int x
, int y
);
54 void SetRedErrorSquare(TileIndex tile
);
55 void SetTileSelectSize(int w
, int h
);
56 void SetTileSelectBigSize(int ox
, int oy
, int sx
, int sy
);
58 void ViewportDoDraw (Blitter::Surface
*surface
, void *dst_ptr
,
59 const ViewPort
*vp
, int left
, int top
, int width
, int height
);
61 bool ScrollWindowToTile(TileIndex tile
, Window
*w
, bool instant
= false);
62 bool ScrollWindowTo(int x
, int y
, int z
, Window
*w
, bool instant
= false);
64 void RebuildViewportOverlay(Window
*w
);
66 bool ScrollMainWindowToTile(TileIndex tile
, bool instant
= false);
67 bool ScrollMainWindowTo(int x
, int y
, int z
= -1, bool instant
= false);
69 void UpdateAllVirtCoords();
71 extern Point _tile_fract_coords
;
73 void MarkTileDirtyByTile(TileIndex tile
);
74 void MarkBridgeTileDirtyByTile (TileIndex tile
, uint bridge_height
);
75 void MarkTileDirtyByTileOutsideMap(int x
, int y
);
77 int GetVirtualHeight (int x
, int y
);
79 Point
GetViewportStationMiddle(const ViewPort
*vp
, const Station
*st
);
81 bool IsViewportDrawerDetailed (const struct ViewportDrawer
*vd
);
83 #endif /* VIEWPORT_FUNC_H */