Doc: Prepare for 14.0-RC2 release (#12248)
[openttd-github.git] / src / viewport_type.h
blob234edadc7cdbe96fc306403d428add7d62bdec36
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
8 /** @file viewport_type.h Types related to viewports. */
10 #ifndef VIEWPORT_TYPE_H
11 #define VIEWPORT_TYPE_H
13 #include "zoom_type.h"
14 #include "strings_type.h"
15 #include "table/strings.h"
17 class LinkGraphOverlay;
19 /**
20 * Data structure for viewport, display of a part of the world
22 struct Viewport {
23 int left; ///< Screen coordinate left edge of the viewport
24 int top; ///< Screen coordinate top edge of the viewport
25 int width; ///< Screen width of the viewport
26 int height; ///< Screen height of the viewport
28 int virtual_left; ///< Virtual left coordinate
29 int virtual_top; ///< Virtual top coordinate
30 int virtual_width; ///< width << zoom
31 int virtual_height; ///< height << zoom
33 ZoomLevel zoom; ///< The zoom level of the viewport.
34 std::shared_ptr<LinkGraphOverlay> overlay;
37 /** Location information about a sign as seen on the viewport */
38 struct ViewportSign {
39 int32_t center; ///< The center position of the sign
40 int32_t top; ///< The top of the sign
41 uint16_t width_normal; ///< The width when not zoomed out (normal font)
42 uint16_t width_small; ///< The width when zoomed out (small font)
44 void UpdatePosition(int center, int top, StringID str, StringID str_small = STR_NULL);
45 void MarkDirty(ZoomLevel maxzoom = ZOOM_LVL_MAX) const;
48 /** Specialised ViewportSign that tracks whether it is valid for entering into a Kdtree */
49 struct TrackedViewportSign : ViewportSign {
50 bool kdtree_valid; ///< Are the sign data valid for use with the _viewport_sign_kdtree?
52 /**
53 * Update the position of the viewport sign.
54 * Note that this function hides the base class function.
56 void UpdatePosition(int center, int top, StringID str, StringID str_small = STR_NULL)
58 this->kdtree_valid = true;
59 this->ViewportSign::UpdatePosition(center, top, str, str_small);
63 TrackedViewportSign() : kdtree_valid{ false }
68 /**
69 * Directions of zooming.
70 * @see DoZoomInOutWindow
72 enum ZoomStateChange {
73 ZOOM_IN = 0, ///< Zoom in (get more detailed view).
74 ZOOM_OUT = 1, ///< Zoom out (get helicopter view).
75 ZOOM_NONE = 2, ///< Hack, used to update the button status.
78 /**
79 * Some values for constructing bounding boxes (BB). The Z positions under bridges are:
80 * z=0..5 Everything that can be built under low bridges.
81 * z=6 reserved, currently unused.
82 * z=7 Z separator between bridge/tunnel and the things under/above it.
84 static const uint BB_HEIGHT_UNDER_BRIDGE = 6; ///< Everything that can be built under low bridges, must not exceed this Z height.
85 static const uint BB_Z_SEPARATOR = 7; ///< Separates the bridge/tunnel from the things under/above it.
87 /** Viewport place method (type of highlighted area and placed objects) */
88 enum ViewportPlaceMethod {
89 VPM_X_OR_Y = 0, ///< drag in X or Y direction
90 VPM_FIX_X = 1, ///< drag only in X axis
91 VPM_FIX_Y = 2, ///< drag only in Y axis
92 VPM_X_AND_Y = 3, ///< area of land in X and Y directions
93 VPM_X_AND_Y_LIMITED = 4, ///< area of land of limited size
94 VPM_FIX_HORIZONTAL = 5, ///< drag only in horizontal direction
95 VPM_FIX_VERTICAL = 6, ///< drag only in vertical direction
96 VPM_X_LIMITED = 7, ///< Drag only in X axis with limited size
97 VPM_Y_LIMITED = 8, ///< Drag only in Y axis with limited size
98 VPM_RAILDIRS = 0x40, ///< all rail directions
99 VPM_SIGNALDIRS = 0x80, ///< similar to VMP_RAILDIRS, but with different cursor
101 DECLARE_ENUM_AS_BIT_SET(ViewportPlaceMethod)
104 * Drag and drop selection process, or, what to do with an area of land when
105 * you've selected it.
107 enum ViewportDragDropSelectionProcess {
108 DDSP_DEMOLISH_AREA, ///< Clear area
109 DDSP_RAISE_AND_LEVEL_AREA, ///< Raise / level area
110 DDSP_LOWER_AND_LEVEL_AREA, ///< Lower / level area
111 DDSP_LEVEL_AREA, ///< Level area
112 DDSP_CREATE_DESERT, ///< Fill area with desert
113 DDSP_CREATE_ROCKS, ///< Fill area with rocks
114 DDSP_CREATE_WATER, ///< Create a canal
115 DDSP_CREATE_RIVER, ///< Create rivers
116 DDSP_PLANT_TREES, ///< Plant trees
117 DDSP_BUILD_BRIDGE, ///< Bridge placement
118 DDSP_BUILD_OBJECT, ///< Build an object
120 /* Rail specific actions */
121 DDSP_PLACE_RAIL, ///< Rail placement
122 DDSP_BUILD_SIGNALS, ///< Signal placement
123 DDSP_BUILD_STATION, ///< Station placement
124 DDSP_REMOVE_STATION, ///< Station removal
125 DDSP_CONVERT_RAIL, ///< Rail conversion
127 /* Road specific actions */
128 DDSP_PLACE_ROAD_X_DIR, ///< Road placement (X axis)
129 DDSP_PLACE_ROAD_Y_DIR, ///< Road placement (Y axis)
130 DDSP_PLACE_AUTOROAD, ///< Road placement (auto)
131 DDSP_BUILD_BUSSTOP, ///< Road stop placement (buses)
132 DDSP_BUILD_TRUCKSTOP, ///< Road stop placement (trucks)
133 DDSP_REMOVE_BUSSTOP, ///< Road stop removal (buses)
134 DDSP_REMOVE_TRUCKSTOP, ///< Road stop removal (trucks)
135 DDSP_CONVERT_ROAD, ///< Road conversion
140 * Target of the viewport scrolling GS method
142 enum ViewportScrollTarget : byte {
143 VST_EVERYONE, ///< All players
144 VST_COMPANY, ///< All players in specific company
145 VST_CLIENT, ///< Single player
148 #endif /* VIEWPORT_TYPE_H */