OpenTTD: src/viewport_func.h Source File

OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

viewport_func.h
Go to the documentation of this file.
1 /* $Id: viewport_func.h 27161 2015-02-22 14:42:34Z frosch $ */
2
3 /*
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/>.
8 */
9
12 #ifndef VIEWPORT_FUNC_H
13 #define VIEWPORT_FUNC_H
14
15 #include "gfx_type.h"
16 #include "viewport_type.h"
17 #include "window_type.h"
18 #include "tile_type.h"
19 #include "station_type.h"
20
21 static const int TILE_HEIGHT_STEP = 50;
22
23 void SetSelectionRed(bool);
24
25 void DeleteWindowViewport(Window *w);
26 void InitializeWindowViewport(Window *w, int x, int y, int width, int height, uint32 follow_flags, ZoomLevel zoom);
27 ViewPort *IsPtInWindowViewport(const Window *w, int x, int y);
28 Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y, bool clamp_to_map = true);
29 Point GetTileBelowCursor();
30 void UpdateViewportPosition(Window *w);
31
32 void MarkAllViewportsDirty(int left, int top, int right, int bottom);
33
34 bool DoZoomInOutWindow(ZoomStateChange how, Window *w);
35 void ZoomInOrOutToCursorWindow(bool in, Window * w);
36 Point GetTileZoomCenterWindow(bool in, Window * w);
37 void HandleZoomMessage(Window *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out);
38
45 static inline void MaxZoomInOut(ZoomStateChange how, Window *w)
46 {
47 while (DoZoomInOutWindow(how, w)) {};
48 }
49
50 void OffsetGroundSprite(int x, int y);
51
52 void DrawGroundSprite(SpriteID image, PaletteID pal, const SubSprite *sub = NULL, int extra_offs_x = 0, int extra_offs_y = 0);
53 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);
54 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);
55 void AddChildSpriteScreen(SpriteID image, PaletteID pal, int x, int y, bool transparent = false, const SubSprite *sub = NULL, bool scale = true);
56 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
58
59 void StartSpriteCombine();
60 void EndSpriteCombine();
61
62 bool HandleViewportClicked(const ViewPort *vp, int x, int y);
63 void SetRedErrorSquare(TileIndex tile);
64 void SetTileSelectSize(int w, int h);
65 void SetTileSelectBigSize(int ox, int oy, int sx, int sy);
66
67 void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom);
68
69 bool ScrollWindowToTile(TileIndex tile, Window *w, bool instant = false);
70 bool ScrollWindowTo(int x, int y, int z, Window *w, bool instant = false);
71
72 void RebuildViewportOverlay(Window *w);
73
74 bool ScrollMainWindowToTile(TileIndex tile, bool instant = false);
75 bool ScrollMainWindowTo(int x, int y, int z = -1, bool instant = false);
76
77 void UpdateAllVirtCoords();
78
79 extern Point _tile_fract_coords;
80
81 void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset = 0);
82
83 void MarkTileDirtyByTileOutsideMap(int x, int y);
84
85 Point GetViewportStationMiddle(const ViewPort *vp, const Station *st);
86
87 #endif /* VIEWPORT_FUNC_H */