OpenTTD Source  20241120-master-g6d3adc6169
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  std::shared_ptr<LinkGraphOverlay> overlay;
35 };
36 
38 struct ViewportSign {
39  int32_t center;
40  int32_t top;
41  uint16_t width_normal;
42  uint16_t width_small;
43 
44  auto operator<=>(const ViewportSign &) const = default;
45 
46  void UpdatePosition(int center, int top, StringID str, StringID str_small = STR_NULL);
47  void MarkDirty(ZoomLevel maxzoom = ZOOM_LVL_MAX) const;
48 };
49 
52  bool kdtree_valid;
53 
54  auto operator<=>(const TrackedViewportSign &) const = default;
55 
60  void UpdatePosition(int center, int top, StringID str, StringID str_small = STR_NULL)
61  {
62  this->kdtree_valid = true;
63  this->ViewportSign::UpdatePosition(center, top, str, str_small);
64  }
65 
66 
68  {
69  }
70 };
71 
77  ZOOM_IN = 0,
78  ZOOM_OUT = 1,
79  ZOOM_NONE = 2,
80 };
81 
88 static const uint BB_HEIGHT_UNDER_BRIDGE = 6;
89 static const uint BB_Z_SEPARATOR = 7;
90 
93  VPM_X_OR_Y = 0,
94  VPM_FIX_X = 1,
95  VPM_FIX_Y = 2,
102  VPM_RAILDIRS = 0x40,
103  VPM_SIGNALDIRS = 0x80,
104 };
106 
107 
123 
124  /* Rail specific actions */
130 
131  /* Road specific actions */
142 };
143 
144 
148 enum ViewportScrollTarget : uint8_t {
152 };
153 
154 #endif /* VIEWPORT_TYPE_H */
Handles drawing of links into some window.
Definition: linkgraph_gui.h:41
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
void MarkDirty(ZoomLevel maxzoom=ZOOM_LVL_MAX) const
Mark the sign dirty in all viewports.
Definition: viewport.cpp:1491
Types related to strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
Specialised ViewportSign that tracks whether it is valid for entering into a Kdtree.
Definition: viewport_type.h:51
void UpdatePosition(int center, int top, StringID str, StringID str_small=STR_NULL)
Update the position of the viewport sign.
Definition: viewport_type.h:60
bool kdtree_valid
Are the sign data valid for use with the _viewport_sign_kdtree?
Definition: viewport_type.h:52
Location information about a sign as seen on the viewport.
Definition: viewport_type.h:38
int32_t center
The center position of the sign.
Definition: viewport_type.h:39
uint16_t width_small
The width when zoomed out (small font)
Definition: viewport_type.h:42
uint16_t width_normal
The width when not zoomed out (normal font)
Definition: viewport_type.h:41
void UpdatePosition(int center, int top, StringID str, StringID str_small=STR_NULL)
Update the position of the viewport sign.
Definition: viewport.cpp:1466
int32_t top
The top of the sign.
Definition: viewport_type.h:40
Data structure for viewport, display of a part of the world.
Definition: viewport_type.h:22
int top
Screen coordinate top edge of the viewport.
Definition: viewport_type.h:24
int width
Screen width of the viewport.
Definition: viewport_type.h:25
ZoomLevel zoom
The zoom level of the viewport.
Definition: viewport_type.h:33
int virtual_top
Virtual top coordinate.
Definition: viewport_type.h:29
int virtual_left
Virtual left coordinate.
Definition: viewport_type.h:28
int virtual_width
width << zoom
Definition: viewport_type.h:30
int left
Screen coordinate left edge of the viewport.
Definition: viewport_type.h:23
int height
Screen height of the viewport.
Definition: viewport_type.h:26
int virtual_height
height << zoom
Definition: viewport_type.h:31
ViewportScrollTarget
Target of the viewport scrolling GS method.
@ VST_EVERYONE
All players.
@ VST_COMPANY
All players in specific company.
@ VST_CLIENT
Single player.
static const uint BB_HEIGHT_UNDER_BRIDGE
Some values for constructing bounding boxes (BB).
Definition: viewport_type.h:88
static const uint BB_Z_SEPARATOR
Separates the bridge/tunnel from the things under/above it.
Definition: viewport_type.h:89
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
@ DDSP_PLACE_ROAD_Y_DIR
Road placement (Y axis)
@ DDSP_CREATE_DESERT
Fill area with desert.
@ DDSP_BUILD_BUSSTOP
Road stop placement (buses)
@ DDSP_REMOVE_BUSSTOP
Road stop removal (buses)
@ DDSP_REMOVE_ROAD_WAYPOINT
Road stop removal (waypoint)
@ DDSP_LOWER_AND_LEVEL_AREA
Lower / level area.
@ DDSP_CONVERT_RAIL
Rail conversion.
@ DDSP_DEMOLISH_AREA
Clear area.
@ DDSP_BUILD_SIGNALS
Signal placement.
@ DDSP_BUILD_TRUCKSTOP
Road stop placement (trucks)
@ DDSP_REMOVE_STATION
Station removal.
@ DDSP_CREATE_ROCKS
Fill area with rocks.
@ DDSP_REMOVE_TRUCKSTOP
Road stop removal (trucks)
@ DDSP_RAISE_AND_LEVEL_AREA
Raise / level area.
@ DDSP_LEVEL_AREA
Level area.
@ DDSP_BUILD_STATION
Station placement.
@ DDSP_CREATE_WATER
Create a canal.
@ DDSP_PLANT_TREES
Plant trees.
@ DDSP_PLACE_AUTOROAD
Road placement (auto)
@ DDSP_BUILD_ROAD_WAYPOINT
Road stop placement (waypoint)
@ DDSP_CREATE_RIVER
Create rivers.
@ DDSP_BUILD_OBJECT
Build an object.
@ DDSP_PLACE_ROAD_X_DIR
Road placement (X axis)
@ DDSP_BUILD_BRIDGE
Bridge placement.
@ DDSP_PLACE_RAIL
Rail placement.
@ DDSP_CONVERT_ROAD
Road conversion.
ZoomStateChange
Directions of zooming.
Definition: viewport_type.h:76
@ ZOOM_IN
Zoom in (get more detailed view).
Definition: viewport_type.h:77
@ ZOOM_NONE
Hack, used to update the button status.
Definition: viewport_type.h:79
@ ZOOM_OUT
Zoom out (get helicopter view).
Definition: viewport_type.h:78
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Definition: viewport_type.h:92
@ VPM_FIX_Y
drag only in Y axis
Definition: viewport_type.h:95
@ VPM_Y_LIMITED
Drag only in Y axis with limited size.
@ VPM_X_AND_Y_LIMITED
area of land of limited size
Definition: viewport_type.h:97
@ VPM_FIX_VERTICAL
drag only in vertical direction
Definition: viewport_type.h:99
@ VPM_X_LIMITED
Drag only in X axis with limited size.
@ VPM_X_AND_Y
area of land in X and Y directions
Definition: viewport_type.h:96
@ VPM_FIX_HORIZONTAL
drag only in horizontal direction
Definition: viewport_type.h:98
@ VPM_FIX_X
drag only in X axis
Definition: viewport_type.h:94
@ VPM_SIGNALDIRS
similar to VMP_RAILDIRS, but with different cursor
@ VPM_X_OR_Y
drag in X or Y direction
Definition: viewport_type.h:93
@ VPM_RAILDIRS
all rail directions
Types related to zooming in and out.
ZoomLevel
All zoom levels we know.
Definition: zoom_type.h:16
@ ZOOM_LVL_MAX
Maximum zoom level.
Definition: zoom_type.h:42