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
16 #include "viewport_type.h"
17 #include "window_type.h"
18 #include "tile_type.h"
20 static const int TILE_HEIGHT_STEP
= 50; ///< One Z unit tile height difference is displayed as 50m.
22 void SetSelectionRed(bool);
24 void DeleteWindowViewport(Window
*w
);
25 void InitializeWindowViewport(Window
*w
, int x
, int y
, int width
, int height
, uint32 follow_flags
, ZoomLevel zoom
);
26 ViewPort
*IsPtInWindowViewport(const Window
*w
, int x
, int y
);
27 Point
GetTileBelowCursor();
28 void UpdateViewportPosition(Window
*w
);
30 void MarkAllViewportsDirty(int left
, int top
, int right
, int bottom
);
32 bool DoZoomInOutWindow(ZoomStateChange how
, Window
*w
);
33 void ZoomInOrOutToCursorWindow(bool in
, Window
* w
);
34 Point
GetTileZoomCenterWindow(bool in
, Window
* w
);
35 void HandleZoomMessage(Window
*w
, const ViewPort
*vp
, byte widget_zoom_in
, byte widget_zoom_out
);
38 * Zoom a viewport as far as possible in the given direction.
39 * @param how Zooming direction.
40 * @param w Window owning the viewport.
41 * @pre \a how should not be #ZOOM_NONE.
43 static inline void MaxZoomInOut(ZoomStateChange how
, Window
*w
)
45 while (DoZoomInOutWindow(how
, w
)) {};
48 void OffsetGroundSprite(int x
, int y
);
50 void DrawGroundSprite(SpriteID image
, PaletteID pal
, const SubSprite
*sub
= NULL
, int extra_offs_x
= 0, int extra_offs_y
= 0);
51 void DrawGroundSpriteAt(SpriteID image
, PaletteID pal
, int32 x
, int32 y
, int z
, const SubSprite
*sub
= NULL
, int extra_offs_x
= 0, int extra_offs_y
= 0);
52 void AddSortableSpriteToDraw(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
);
53 void AddChildSpriteScreen(SpriteID image
, PaletteID pal
, int x
, int y
, bool transparent
= false, const SubSprite
*sub
= NULL
);
54 void ViewportAddString(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
);
57 void StartSpriteCombine();
58 void EndSpriteCombine();
60 bool HandleViewportClicked(const ViewPort
*vp
, int x
, int y
);
61 void SetRedErrorSquare(TileIndex tile
);
62 void SetTileSelectSize(int w
, int h
);
63 void SetTileSelectBigSize(int ox
, int oy
, int sx
, int sy
);
65 void ViewportDoDraw(const ViewPort
*vp
, int left
, int top
, int right
, int bottom
);
67 bool ScrollWindowToTile(TileIndex tile
, Window
*w
, bool instant
= false);
68 bool ScrollWindowTo(int x
, int y
, int z
, Window
*w
, bool instant
= false);
70 bool ScrollMainWindowToTile(TileIndex tile
, bool instant
= false);
71 bool ScrollMainWindowTo(int x
, int y
, int z
= -1, bool instant
= false);
73 void UpdateAllVirtCoords();
75 extern Point _tile_fract_coords
;
77 void MarkTileDirtyByTile(TileIndex tile
);
79 #endif /* VIEWPORT_FUNC_H */