Fix incorrect tile and trackdir in reserve through program execution
[openttd-joker.git] / src / viewport_func.h
blob5462be0b4b754afd81eb07a67a5a02e70c7160dd
1 /* $Id$ */
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 */
10 /** @file viewport_func.h Functions related to (drawing on) viewports. */
12 #ifndef VIEWPORT_FUNC_H
13 #define VIEWPORT_FUNC_H
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 #include "tile_cmd.h"
21 #include "vehicle_base.h"
23 static const int TILE_HEIGHT_STEP = 50; ///< One Z unit tile height difference is displayed as 50m.
25 void SetSelectionRed(bool);
27 void DeleteWindowViewport(Window *w);
28 void InitializeWindowViewport(Window *w, int x, int y, int width, int height, uint32 follow_flags, ZoomLevel zoom);
29 ViewPort *IsPtInWindowViewport(const Window *w, int x, int y);
30 Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y, bool clamp_to_map = true);
31 Point GetTileBelowCursor();
32 void UpdateViewportPosition(Window *w);
34 void MarkAllViewportsDirty(int left, int top, int right, int bottom, const ZoomLevel mark_dirty_if_zoomlevel_is_below = ZOOM_LVL_END);
35 void MarkAllViewportMapsDirty(int left, int top, int right, int bottom);
36 void MarkAllRouteStepsDirty(const Vehicle *veh);
37 void MarkTileLineDirty(const TileIndex from_tile, const TileIndex to_tile);
38 void MarkAllRoutePathsDirty(const Vehicle *veh);
39 void CheckMarkDirtyFocusedRoutePaths(const Vehicle *veh);
41 bool DoZoomInOutWindow(ZoomStateChange how, Window *w);
42 void ZoomInOrOutToCursorWindow(bool in, Window * w);
43 Point GetTileZoomCenterWindow(bool in, Window * w);
44 void HandleZoomMessage(Window *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out);
46 /**
47 * Zoom a viewport as far as possible in the given direction.
48 * @param how Zooming direction.
49 * @param w Window owning the viewport.
50 * @pre \a how should not be #ZOOM_NONE.
52 static inline void MaxZoomInOut(ZoomStateChange how, Window *w)
54 while (DoZoomInOutWindow(how, w)) {};
57 void OffsetGroundSprite(int x, int y);
59 void DrawGroundSprite(SpriteID image, PaletteID pal, const SubSprite *sub = NULL, int extra_offs_x = 0, int extra_offs_y = 0);
60 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);
61 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);
62 void AddChildSpriteScreen(SpriteID image, PaletteID pal, int x, int y, bool transparent = false, const SubSprite *sub = NULL, bool scale = true);
63 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);
66 void StartSpriteCombine();
67 void EndSpriteCombine();
69 bool HandleViewportDoubleClicked(Window *w, int x, int y);
70 bool HandleViewportClicked(const ViewPort *vp, int x, int y, bool double_click);
71 void HandleViewportToolTip(Window *w, int x, int y);
72 void SetRedErrorSquare(TileIndex tile);
73 void SetTileSelectSize(int w, int h);
74 void SetTileSelectBigSize(int ox, int oy, int sx, int sy);
76 void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom);
78 bool ScrollWindowToTile(TileIndex tile, Window *w, bool instant = false);
79 bool ScrollWindowTo(int x, int y, int z, Window *w, bool instant = false);
81 void RebuildViewportOverlay(Window *w);
83 bool ScrollMainWindowToTile(TileIndex tile, bool instant = false);
84 bool ScrollMainWindowTo(int x, int y, int z = -1, bool instant = false);
86 void UpdateAllVirtCoords();
88 extern Point _tile_fract_coords;
90 void MarkTileDirtyByTile(const TileIndex tile, const ZoomLevel mark_dirty_if_zoomlevel_is_below = ZOOM_LVL_END, int bridge_level_offset = 0);
92 void MarkTileDirtyByTileOutsideMap(int x, int y);
93 ViewportMapType ChangeRenderMode(const ViewPort *vp, bool down);
95 void MarkBridgeTilesDirtyByTile(TileIndex tile_start, TileIndex tile_end);
97 Point GetViewportStationMiddle(const ViewPort *vp, const Station *st);
99 void ShowTooltipForTile(Window *w, const TileIndex tile);
101 void ViewportMapClearTunnelCache();
102 void ViewportMapInvalidateTunnelCacheByTile(const TileIndex tile);
104 void DrawOverlay(const TileInfo *ti, TileType tt);
106 #endif /* VIEWPORT_FUNC_H */