OpenTTD Source: src/viewport_type.h Source File

OpenTTD Source 1.11.0-RC1

viewport_type.h
Go to the documentation of this file.
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 */
7
10 #ifndef VIEWPORT_TYPE_H
11 #define VIEWPORT_TYPE_H
12
13 #include "zoom_type.h"
14 #include "strings_type.h"
15 #include "table/strings.h"
16
17 class LinkGraphOverlay;
18
22 struct Viewport {
23 int left;
24 int top;
25 int width;
26 int height;
27
28 int virtual_left;
29 int virtual_top;
30 int virtual_width;
31 int virtual_height;
32
33 ZoomLevel zoom;
34 LinkGraphOverlay *overlay;
35 };
36
38 enum ViewportSignMargin {
39 VPSM_LEFT = 1,
40 VPSM_RIGHT = 1,
41 VPSM_TOP = 1,
42 VPSM_BOTTOM = 1,
43 };
44
46 struct ViewportSign {
47 int32 center;
48 int32 top;
49 uint16 width_normal;
50 uint16 width_small;
51
52 void UpdatePosition(int center, int top, StringID str, StringID str_small = STR_NULL);
53 void MarkDirty(ZoomLevel maxzoom = ZOOM_LVL_MAX) const;
54 };
55
57 struct TrackedViewportSign : ViewportSign {
58 bool kdtree_valid;
59
64 void UpdatePosition(int center, int top, StringID str, StringID str_small = STR_NULL)
65 {
66 this->kdtree_valid = true;
67 this->ViewportSign::UpdatePosition(center, top, str, str_small);
68 }
69
70
71 TrackedViewportSign() : kdtree_valid{ false }
72 {
73 }
74 };
75
80 enum ZoomStateChange {
81 ZOOM_IN = 0,
82 ZOOM_OUT = 1,
83 ZOOM_NONE = 2,
84 };
85
92 static const uint BB_HEIGHT_UNDER_BRIDGE = 6;
93 static const uint BB_Z_SEPARATOR = 7;
94
96 enum ViewportPlaceMethod {
97 VPM_X_OR_Y = 0,
98 VPM_FIX_X = 1,
99 VPM_FIX_Y = 2,
100 VPM_X_AND_Y = 3,
101 VPM_X_AND_Y_LIMITED = 4,
102 VPM_FIX_HORIZONTAL = 5,
103 VPM_FIX_VERTICAL = 6,
104 VPM_X_LIMITED = 7,
105 VPM_Y_LIMITED = 8,
106 VPM_RAILDIRS = 0x40,
107 VPM_SIGNALDIRS = 0x80,
108 };
109 DECLARE_ENUM_AS_BIT_SET(ViewportPlaceMethod)
110
111
115 enum ViewportDragDropSelectionProcess {
116 DDSP_DEMOLISH_AREA,
117 DDSP_RAISE_AND_LEVEL_AREA,
118 DDSP_LOWER_AND_LEVEL_AREA,
119 DDSP_LEVEL_AREA,
120 DDSP_CREATE_DESERT,
121 DDSP_CREATE_ROCKS,
122 DDSP_CREATE_WATER,
123 DDSP_CREATE_RIVER,
124 DDSP_PLANT_TREES,
125 DDSP_BUILD_BRIDGE,
126
127 /* Rail specific actions */
128 DDSP_PLACE_RAIL,
129 DDSP_BUILD_SIGNALS,
130 DDSP_BUILD_STATION,
131 DDSP_REMOVE_STATION,
132 DDSP_CONVERT_RAIL,
133
134 /* Road specific actions */
135 DDSP_PLACE_ROAD_X_DIR,
136 DDSP_PLACE_ROAD_Y_DIR,
137 DDSP_PLACE_AUTOROAD,
138 DDSP_BUILD_BUSSTOP,
139 DDSP_BUILD_TRUCKSTOP,
140 DDSP_REMOVE_BUSSTOP,
141 DDSP_REMOVE_TRUCKSTOP,
142 DDSP_CONVERT_ROAD,
143 };
144
145
149 enum ViewportScrollTarget {
150 VST_EVERYONE,
151 VST_COMPANY,
152 VST_CLIENT,
153 };
154
155 #endif /* VIEWPORT_TYPE_H */
DDSP_DEMOLISH_AREA
@ DDSP_DEMOLISH_AREA
Clear area.
Definition: viewport_type.h:116
DDSP_CONVERT_RAIL
@ DDSP_CONVERT_RAIL
Rail conversion.
Definition: viewport_type.h:132
DDSP_PLACE_ROAD_Y_DIR
@ DDSP_PLACE_ROAD_Y_DIR
Road placement (Y axis)
Definition: viewport_type.h:136
VPM_FIX_VERTICAL
@ VPM_FIX_VERTICAL
drag only in vertical direction
Definition: viewport_type.h:103
BB_Z_SEPARATOR
static const uint BB_Z_SEPARATOR
Separates the bridge/tunnel from the things under/above it.
Definition: viewport_type.h:93
ZOOM_OUT
@ ZOOM_OUT
Zoom out (get helicopter view).
Definition: viewport_type.h:82
DDSP_CREATE_ROCKS
@ DDSP_CREATE_ROCKS
Fill area with rocks.
Definition: viewport_type.h:121
DDSP_BUILD_STATION
@ DDSP_BUILD_STATION
Station placement.
Definition: viewport_type.h:130
ViewportDragDropSelectionProcess
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
Definition: viewport_type.h:115
DDSP_LEVEL_AREA
@ DDSP_LEVEL_AREA
Level area.
Definition: viewport_type.h:119
Viewport::width
int width
Screen width of the viewport.
Definition: viewport_type.h:25
DDSP_REMOVE_BUSSTOP
@ DDSP_REMOVE_BUSSTOP
Road stop removal (buses)
Definition: viewport_type.h:140
Viewport::height
int height
Screen height of the viewport.
Definition: viewport_type.h:26
ZOOM_NONE
@ ZOOM_NONE
Hack, used to update the button status.
Definition: viewport_type.h:83
VST_EVERYONE
@ VST_EVERYONE
All players.
Definition: viewport_type.h:150
Viewport::top
int top
Screen coordinate top edge of the viewport.
Definition: viewport_type.h:24
DDSP_BUILD_BUSSTOP
@ DDSP_BUILD_BUSSTOP
Road stop placement (buses)
Definition: viewport_type.h:138
VPSM_TOP
@ VPSM_TOP
Top margin.
Definition: viewport_type.h:41
BB_HEIGHT_UNDER_BRIDGE
static const uint BB_HEIGHT_UNDER_BRIDGE
Some values for constructing bounding boxes (BB).
Definition: viewport_type.h:92
ViewportSign::center
int32 center
The center position of the sign.
Definition: viewport_type.h:47
ZoomLevel
ZoomLevel
All zoom levels we know.
Definition: zoom_type.h:21
VPM_FIX_Y
@ VPM_FIX_Y
drag only in Y axis
Definition: viewport_type.h:99
ZOOM_LVL_MAX
@ ZOOM_LVL_MAX
Maximum zoom level.
Definition: zoom_type.h:48
ViewportSign::top
int32 top
The top of the sign.
Definition: viewport_type.h:48
VPSM_LEFT
@ VPSM_LEFT
Left margin.
Definition: viewport_type.h:39
ViewportPlaceMethod
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Definition: viewport_type.h:96
DDSP_CREATE_WATER
@ DDSP_CREATE_WATER
Create a canal.
Definition: viewport_type.h:122
strings_type.h
Viewport::virtual_top
int virtual_top
Virtual top coordinate.
Definition: viewport_type.h:29
ViewportSign
Location information about a sign as seen on the viewport.
Definition: viewport_type.h:46
DDSP_CREATE_RIVER
@ DDSP_CREATE_RIVER
Create rivers.
Definition: viewport_type.h:123
VPM_RAILDIRS
@ VPM_RAILDIRS
all rail directions
Definition: viewport_type.h:106
DDSP_PLACE_ROAD_X_DIR
@ DDSP_PLACE_ROAD_X_DIR
Road placement (X axis)
Definition: viewport_type.h:135
ZOOM_IN
@ ZOOM_IN
Zoom in (get more detailed view).
Definition: viewport_type.h:81
LinkGraphOverlay
Handles drawing of links into some window.
Definition: linkgraph_gui.h:37
Viewport
Data structure for viewport, display of a part of the world.
Definition: viewport_type.h:22
DDSP_PLACE_RAIL
@ DDSP_PLACE_RAIL
Rail placement.
Definition: viewport_type.h:128
VPM_FIX_X
@ VPM_FIX_X
drag only in X axis
Definition: viewport_type.h:98
Viewport::virtual_left
int virtual_left
Virtual left coordinate.
Definition: viewport_type.h:28
TrackedViewportSign
Specialised ViewportSign that tracks whether it is valid for entering into a Kdtree.
Definition: viewport_type.h:57
Viewport::left
int left
Screen coordinate left edge of the viewport.
Definition: viewport_type.h:23
ViewportSign::MarkDirty
void MarkDirty(ZoomLevel maxzoom=ZOOM_LVL_MAX) const
Mark the sign dirty in all viewports.
Definition: viewport.cpp:1466
ViewportSign::width_small
uint16 width_small
The width when zoomed out (small font)
Definition: viewport_type.h:50
DDSP_REMOVE_TRUCKSTOP
@ DDSP_REMOVE_TRUCKSTOP
Road stop removal (trucks)
Definition: viewport_type.h:141
ViewportSign::width_normal
uint16 width_normal
The width when not zoomed out (normal font)
Definition: viewport_type.h:49
DDSP_PLACE_AUTOROAD
@ DDSP_PLACE_AUTOROAD
Road placement (auto)
Definition: viewport_type.h:137
DDSP_BUILD_BRIDGE
@ DDSP_BUILD_BRIDGE
Bridge placement.
Definition: viewport_type.h:125
DDSP_LOWER_AND_LEVEL_AREA
@ DDSP_LOWER_AND_LEVEL_AREA
Lower / level area.
Definition: viewport_type.h:118
Viewport::virtual_width
int virtual_width
width << zoom
Definition: viewport_type.h:30
ViewportSignMargin
ViewportSignMargin
Margins for the viewport sign.
Definition: viewport_type.h:38
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
TrackedViewportSign::UpdatePosition
void UpdatePosition(int center, int top, StringID str, StringID str_small=STR_NULL)
Update the position of the viewport sign.
Definition: viewport_type.h:64
VPM_Y_LIMITED
@ VPM_Y_LIMITED
Drag only in Y axis with limited size.
Definition: viewport_type.h:105
ViewportSign::UpdatePosition
void UpdatePosition(int center, int top, StringID str, StringID str_small=STR_NULL)
Update the position of the viewport sign.
Definition: viewport.cpp:1439
DDSP_RAISE_AND_LEVEL_AREA
@ DDSP_RAISE_AND_LEVEL_AREA
Raise / level area.
Definition: viewport_type.h:117
TrackedViewportSign::kdtree_valid
bool kdtree_valid
Are the sign data valid for use with the _viewport_sign_kdtree?
Definition: viewport_type.h:58
VPM_FIX_HORIZONTAL
@ VPM_FIX_HORIZONTAL
drag only in horizontal direction
Definition: viewport_type.h:102
VPM_X_AND_Y
@ VPM_X_AND_Y
area of land in X and Y directions
Definition: viewport_type.h:100
DDSP_CONVERT_ROAD
@ DDSP_CONVERT_ROAD
Road conversion.
Definition: viewport_type.h:142
DECLARE_ENUM_AS_BIT_SET
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Definition: company_manager_face.h:29
VPSM_RIGHT
@ VPSM_RIGHT
Right margin.
Definition: viewport_type.h:40
DDSP_BUILD_SIGNALS
@ DDSP_BUILD_SIGNALS
Signal placement.
Definition: viewport_type.h:129
VPM_X_LIMITED
@ VPM_X_LIMITED
Drag only in X axis with limited size.
Definition: viewport_type.h:104
Viewport::zoom
ZoomLevel zoom
The zoom level of the viewport.
Definition: viewport_type.h:33
VPSM_BOTTOM
@ VPSM_BOTTOM
Bottom margin.
Definition: viewport_type.h:42
zoom_type.h
VST_CLIENT
@ VST_CLIENT
Single player.
Definition: viewport_type.h:152
DDSP_PLANT_TREES
@ DDSP_PLANT_TREES
Plant trees.
Definition: viewport_type.h:124
Viewport::virtual_height
int virtual_height
height << zoom
Definition: viewport_type.h:31
VPM_X_AND_Y_LIMITED
@ VPM_X_AND_Y_LIMITED
area of land of limited size
Definition: viewport_type.h:101
VST_COMPANY
@ VST_COMPANY
All players in specific company.
Definition: viewport_type.h:151
DDSP_REMOVE_STATION
@ DDSP_REMOVE_STATION
Station removal.
Definition: viewport_type.h:131
VPM_X_OR_Y
@ VPM_X_OR_Y
drag in X or Y direction
Definition: viewport_type.h:97
VPM_SIGNALDIRS
@ VPM_SIGNALDIRS
similar to VMP_RAILDIRS, but with different cursor
Definition: viewport_type.h:107
ZoomStateChange
ZoomStateChange
Directions of zooming.
Definition: viewport_type.h:80
DDSP_BUILD_TRUCKSTOP
@ DDSP_BUILD_TRUCKSTOP
Road stop placement (trucks)
Definition: viewport_type.h:139
ViewportScrollTarget
ViewportScrollTarget
Target of the viewport scrolling GS method.
Definition: viewport_type.h:149
DDSP_CREATE_DESERT
@ DDSP_CREATE_DESERT
Fill area with desert.
Definition: viewport_type.h:120