OpenTTD Source  13.2.1
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 
32 
34  LinkGraphOverlay *overlay;
35 };
36 
38 struct ViewportSign {
39  int32 center;
40  int32 top;
41  uint16 width_normal;
42  uint16 width_small;
43 
44  void UpdatePosition(int center, int top, StringID str, StringID str_small = STR_NULL);
45  void MarkDirty(ZoomLevel maxzoom = ZOOM_LVL_MAX) const;
46 };
47 
50  bool kdtree_valid;
51 
56  void UpdatePosition(int center, int top, StringID str, StringID str_small = STR_NULL)
57  {
58  this->kdtree_valid = true;
59  this->ViewportSign::UpdatePosition(center, top, str, str_small);
60  }
61 
62 
64  {
65  }
66 };
67 
73  ZOOM_IN = 0,
74  ZOOM_OUT = 1,
75  ZOOM_NONE = 2,
76 };
77 
84 static const uint BB_HEIGHT_UNDER_BRIDGE = 6;
85 static const uint BB_Z_SEPARATOR = 7;
86 
89  VPM_X_OR_Y = 0,
90  VPM_FIX_X = 1,
91  VPM_FIX_Y = 2,
98  VPM_RAILDIRS = 0x40,
99  VPM_SIGNALDIRS = 0x80,
100 };
102 
103 
119 
120  /* Rail specific actions */
126 
127  /* Road specific actions */
136 };
137 
138 
142 enum ViewportScrollTarget : byte {
146 };
147 
148 #endif /* VIEWPORT_TYPE_H */
DDSP_DEMOLISH_AREA
@ DDSP_DEMOLISH_AREA
Clear area.
Definition: viewport_type.h:108
DDSP_CONVERT_RAIL
@ DDSP_CONVERT_RAIL
Rail conversion.
Definition: viewport_type.h:125
DDSP_PLACE_ROAD_Y_DIR
@ DDSP_PLACE_ROAD_Y_DIR
Road placement (Y axis)
Definition: viewport_type.h:129
VST_CLIENT
@ VST_CLIENT
Single player.
Definition: viewport_type.h:145
VPM_FIX_VERTICAL
@ VPM_FIX_VERTICAL
drag only in vertical direction
Definition: viewport_type.h:95
BB_Z_SEPARATOR
static const uint BB_Z_SEPARATOR
Separates the bridge/tunnel from the things under/above it.
Definition: viewport_type.h:85
ZOOM_OUT
@ ZOOM_OUT
Zoom out (get helicopter view).
Definition: viewport_type.h:74
DDSP_CREATE_ROCKS
@ DDSP_CREATE_ROCKS
Fill area with rocks.
Definition: viewport_type.h:113
DDSP_BUILD_STATION
@ DDSP_BUILD_STATION
Station placement.
Definition: viewport_type.h:123
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:107
DDSP_LEVEL_AREA
@ DDSP_LEVEL_AREA
Level area.
Definition: viewport_type.h:111
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:133
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:75
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:131
BB_HEIGHT_UNDER_BRIDGE
static const uint BB_HEIGHT_UNDER_BRIDGE
Some values for constructing bounding boxes (BB).
Definition: viewport_type.h:84
ViewportSign::center
int32 center
The center position of the sign.
Definition: viewport_type.h:39
ZoomLevel
ZoomLevel
All zoom levels we know.
Definition: zoom_type.h:19
VST_COMPANY
@ VST_COMPANY
All players in specific company.
Definition: viewport_type.h:144
VPM_FIX_Y
@ VPM_FIX_Y
drag only in Y axis
Definition: viewport_type.h:91
ZOOM_LVL_MAX
@ ZOOM_LVL_MAX
Maximum zoom level.
Definition: zoom_type.h:46
ViewportSign::top
int32 top
The top of the sign.
Definition: viewport_type.h:40
ViewportPlaceMethod
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Definition: viewport_type.h:88
DDSP_CREATE_WATER
@ DDSP_CREATE_WATER
Create a canal.
Definition: viewport_type.h:114
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:38
DDSP_CREATE_RIVER
@ DDSP_CREATE_RIVER
Create rivers.
Definition: viewport_type.h:115
VPM_RAILDIRS
@ VPM_RAILDIRS
all rail directions
Definition: viewport_type.h:98
DDSP_PLACE_ROAD_X_DIR
@ DDSP_PLACE_ROAD_X_DIR
Road placement (X axis)
Definition: viewport_type.h:128
ZOOM_IN
@ ZOOM_IN
Zoom in (get more detailed view).
Definition: viewport_type.h:73
LinkGraphOverlay
Handles drawing of links into some window.
Definition: linkgraph_gui.h:43
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:121
VPM_FIX_X
@ VPM_FIX_X
drag only in X axis
Definition: viewport_type.h:90
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:49
Viewport::left
int left
Screen coordinate left edge of the viewport.
Definition: viewport_type.h:23
DDSP_BUILD_OBJECT
@ DDSP_BUILD_OBJECT
Build an object.
Definition: viewport_type.h:118
ViewportSign::MarkDirty
void MarkDirty(ZoomLevel maxzoom=ZOOM_LVL_MAX) const
Mark the sign dirty in all viewports.
Definition: viewport.cpp:1478
ViewportSign::width_small
uint16 width_small
The width when zoomed out (small font)
Definition: viewport_type.h:42
DDSP_REMOVE_TRUCKSTOP
@ DDSP_REMOVE_TRUCKSTOP
Road stop removal (trucks)
Definition: viewport_type.h:134
ViewportSign::width_normal
uint16 width_normal
The width when not zoomed out (normal font)
Definition: viewport_type.h:41
DDSP_PLACE_AUTOROAD
@ DDSP_PLACE_AUTOROAD
Road placement (auto)
Definition: viewport_type.h:130
DDSP_BUILD_BRIDGE
@ DDSP_BUILD_BRIDGE
Bridge placement.
Definition: viewport_type.h:117
DDSP_LOWER_AND_LEVEL_AREA
@ DDSP_LOWER_AND_LEVEL_AREA
Lower / level area.
Definition: viewport_type.h:110
Viewport::virtual_width
int virtual_width
width << zoom
Definition: viewport_type.h:30
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:56
VPM_Y_LIMITED
@ VPM_Y_LIMITED
Drag only in Y axis with limited size.
Definition: viewport_type.h:97
ViewportScrollTarget
ViewportScrollTarget
Target of the viewport scrolling GS method.
Definition: viewport_type.h:142
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:1451
DDSP_RAISE_AND_LEVEL_AREA
@ DDSP_RAISE_AND_LEVEL_AREA
Raise / level area.
Definition: viewport_type.h:109
TrackedViewportSign::kdtree_valid
bool kdtree_valid
Are the sign data valid for use with the _viewport_sign_kdtree?
Definition: viewport_type.h:50
VPM_FIX_HORIZONTAL
@ VPM_FIX_HORIZONTAL
drag only in horizontal direction
Definition: viewport_type.h:94
VPM_X_AND_Y
@ VPM_X_AND_Y
area of land in X and Y directions
Definition: viewport_type.h:92
DDSP_CONVERT_ROAD
@ DDSP_CONVERT_ROAD
Road conversion.
Definition: viewport_type.h:135
DECLARE_ENUM_AS_BIT_SET
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Definition: company_manager_face.h:29
DDSP_BUILD_SIGNALS
@ DDSP_BUILD_SIGNALS
Signal placement.
Definition: viewport_type.h:122
VPM_X_LIMITED
@ VPM_X_LIMITED
Drag only in X axis with limited size.
Definition: viewport_type.h:96
Viewport::zoom
ZoomLevel zoom
The zoom level of the viewport.
Definition: viewport_type.h:33
VST_EVERYONE
@ VST_EVERYONE
All players.
Definition: viewport_type.h:143
zoom_type.h
DDSP_PLANT_TREES
@ DDSP_PLANT_TREES
Plant trees.
Definition: viewport_type.h:116
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:93
DDSP_REMOVE_STATION
@ DDSP_REMOVE_STATION
Station removal.
Definition: viewport_type.h:124
VPM_X_OR_Y
@ VPM_X_OR_Y
drag in X or Y direction
Definition: viewport_type.h:89
VPM_SIGNALDIRS
@ VPM_SIGNALDIRS
similar to VMP_RAILDIRS, but with different cursor
Definition: viewport_type.h:99
ZoomStateChange
ZoomStateChange
Directions of zooming.
Definition: viewport_type.h:72
DDSP_BUILD_TRUCKSTOP
@ DDSP_BUILD_TRUCKSTOP
Road stop placement (trucks)
Definition: viewport_type.h:132
DDSP_CREATE_DESERT
@ DDSP_CREATE_DESERT
Fill area with desert.
Definition: viewport_type.h:112