OpenTTD Source: src/viewport_type.h Source File

OpenTTD Source 15.0-beta1

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
17class 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 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
51 struct TrackedViewportSign : ViewportSign {
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
67 TrackedViewportSign() : kdtree_valid{ false }
68 {
69 }
70};
71
76 enum ZoomStateChange {
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
92 enum ViewportPlaceMethod {
93 VPM_X_OR_Y = 0,
94 VPM_FIX_X = 1,
95 VPM_FIX_Y = 2,
96 VPM_X_AND_Y = 3,
97 VPM_X_AND_Y_LIMITED = 4,
98 VPM_FIX_HORIZONTAL = 5,
99 VPM_FIX_VERTICAL = 6,
100 VPM_X_LIMITED = 7,
101 VPM_Y_LIMITED = 8,
102 VPM_RAILDIRS = 0x40,
103 VPM_SIGNALDIRS = 0x80,
104};
105 DECLARE_ENUM_AS_BIT_SET(ViewportPlaceMethod)
106
107
111enum ViewportDragDropSelectionProcess {
112 DDSP_DEMOLISH_AREA,
113 DDSP_RAISE_AND_LEVEL_AREA,
114 DDSP_LOWER_AND_LEVEL_AREA,
115 DDSP_LEVEL_AREA,
116 DDSP_CREATE_DESERT,
117 DDSP_CREATE_ROCKS,
118 DDSP_CREATE_WATER,
119 DDSP_CREATE_RIVER,
120 DDSP_PLANT_TREES,
121 DDSP_BUILD_BRIDGE,
122 DDSP_BUILD_OBJECT,
123
124 /* Rail specific actions */
125 DDSP_PLACE_RAIL,
126 DDSP_BUILD_SIGNALS,
127 DDSP_BUILD_STATION,
128 DDSP_REMOVE_STATION,
129 DDSP_CONVERT_RAIL,
130
131 /* Road specific actions */
132 DDSP_PLACE_ROAD_X_DIR,
133 DDSP_PLACE_ROAD_Y_DIR,
134 DDSP_PLACE_AUTOROAD,
135 DDSP_BUILD_ROAD_WAYPOINT,
136 DDSP_BUILD_BUSSTOP,
137 DDSP_BUILD_TRUCKSTOP,
138 DDSP_REMOVE_ROAD_WAYPOINT,
139 DDSP_REMOVE_BUSSTOP,
140 DDSP_REMOVE_TRUCKSTOP,
141 DDSP_CONVERT_ROAD,
142};
143
144
148 enum ViewportScrollTarget : uint8_t {
149 VST_EVERYONE,
150 VST_COMPANY,
151 VST_CLIENT,
152};
153
154#endif /* VIEWPORT_TYPE_H */
LinkGraphOverlay
Handles drawing of links into some window.
Definition linkgraph_gui.h:41
DECLARE_ENUM_AS_BIT_SET
#define DECLARE_ENUM_AS_BIT_SET(enum_type)
Operators to allow to work with enum as with type safe bit set in C++.
Definition enum_type.hpp:35
ViewportSign::MarkDirty
void MarkDirty(ZoomLevel maxzoom=ZOOM_LVL_MAX) const
Mark the sign dirty in all viewports.
Definition viewport.cpp:1491
strings_type.h
Types related to strings.
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition strings_type.h:16
TrackedViewportSign
Specialised ViewportSign that tracks whether it is valid for entering into a Kdtree.
Definition viewport_type.h:51
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:60
TrackedViewportSign::kdtree_valid
bool kdtree_valid
Are the sign data valid for use with the _viewport_sign_kdtree?
Definition viewport_type.h:52
ViewportSign
Location information about a sign as seen on the viewport.
Definition viewport_type.h:38
ViewportSign::center
int32_t center
The center position of the sign.
Definition viewport_type.h:39
ViewportSign::width_small
uint16_t width_small
The width when zoomed out (small font)
Definition viewport_type.h:42
ViewportSign::width_normal
uint16_t width_normal
The width when not zoomed out (normal font)
Definition viewport_type.h:41
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:1466
ViewportSign::top
int32_t top
The top of the sign.
Definition viewport_type.h:40
Viewport
Data structure for viewport, display of a part of the world.
Definition viewport_type.h:22
Viewport::top
int top
Screen coordinate top edge of the viewport.
Definition viewport_type.h:24
Viewport::width
int width
Screen width of the viewport.
Definition viewport_type.h:25
Viewport::zoom
ZoomLevel zoom
The zoom level of the viewport.
Definition viewport_type.h:33
Viewport::virtual_top
int virtual_top
Virtual top coordinate.
Definition viewport_type.h:29
Viewport::virtual_left
int virtual_left
Virtual left coordinate.
Definition viewport_type.h:28
Viewport::virtual_width
int virtual_width
width << zoom
Definition viewport_type.h:30
Viewport::left
int left
Screen coordinate left edge of the viewport.
Definition viewport_type.h:23
Viewport::height
int height
Screen height of the viewport.
Definition viewport_type.h:26
Viewport::virtual_height
int virtual_height
height << zoom
Definition viewport_type.h:31
ViewportScrollTarget
ViewportScrollTarget
Target of the viewport scrolling GS method.
Definition viewport_type.h:148
VST_EVERYONE
@ VST_EVERYONE
All players.
Definition viewport_type.h:149
VST_COMPANY
@ VST_COMPANY
All players in specific company.
Definition viewport_type.h:150
VST_CLIENT
@ VST_CLIENT
Single player.
Definition viewport_type.h:151
BB_HEIGHT_UNDER_BRIDGE
static const uint BB_HEIGHT_UNDER_BRIDGE
Some values for constructing bounding boxes (BB).
Definition viewport_type.h:88
BB_Z_SEPARATOR
static const uint BB_Z_SEPARATOR
Separates the bridge/tunnel from the things under/above it.
Definition viewport_type.h:89
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:111
DDSP_PLACE_ROAD_Y_DIR
@ DDSP_PLACE_ROAD_Y_DIR
Road placement (Y axis)
Definition viewport_type.h:133
DDSP_CREATE_DESERT
@ DDSP_CREATE_DESERT
Fill area with desert.
Definition viewport_type.h:116
DDSP_BUILD_BUSSTOP
@ DDSP_BUILD_BUSSTOP
Road stop placement (buses)
Definition viewport_type.h:136
DDSP_REMOVE_BUSSTOP
@ DDSP_REMOVE_BUSSTOP
Road stop removal (buses)
Definition viewport_type.h:139
DDSP_REMOVE_ROAD_WAYPOINT
@ DDSP_REMOVE_ROAD_WAYPOINT
Road stop removal (waypoint)
Definition viewport_type.h:138
DDSP_LOWER_AND_LEVEL_AREA
@ DDSP_LOWER_AND_LEVEL_AREA
Lower / level area.
Definition viewport_type.h:114
DDSP_CONVERT_RAIL
@ DDSP_CONVERT_RAIL
Rail conversion.
Definition viewport_type.h:129
DDSP_DEMOLISH_AREA
@ DDSP_DEMOLISH_AREA
Clear area.
Definition viewport_type.h:112
DDSP_BUILD_SIGNALS
@ DDSP_BUILD_SIGNALS
Signal placement.
Definition viewport_type.h:126
DDSP_BUILD_TRUCKSTOP
@ DDSP_BUILD_TRUCKSTOP
Road stop placement (trucks)
Definition viewport_type.h:137
DDSP_REMOVE_STATION
@ DDSP_REMOVE_STATION
Station removal.
Definition viewport_type.h:128
DDSP_CREATE_ROCKS
@ DDSP_CREATE_ROCKS
Fill area with rocks.
Definition viewport_type.h:117
DDSP_REMOVE_TRUCKSTOP
@ DDSP_REMOVE_TRUCKSTOP
Road stop removal (trucks)
Definition viewport_type.h:140
DDSP_RAISE_AND_LEVEL_AREA
@ DDSP_RAISE_AND_LEVEL_AREA
Raise / level area.
Definition viewport_type.h:113
DDSP_LEVEL_AREA
@ DDSP_LEVEL_AREA
Level area.
Definition viewport_type.h:115
DDSP_BUILD_STATION
@ DDSP_BUILD_STATION
Station placement.
Definition viewport_type.h:127
DDSP_CREATE_WATER
@ DDSP_CREATE_WATER
Create a canal.
Definition viewport_type.h:118
DDSP_PLANT_TREES
@ DDSP_PLANT_TREES
Plant trees.
Definition viewport_type.h:120
DDSP_PLACE_AUTOROAD
@ DDSP_PLACE_AUTOROAD
Road placement (auto)
Definition viewport_type.h:134
DDSP_BUILD_ROAD_WAYPOINT
@ DDSP_BUILD_ROAD_WAYPOINT
Road stop placement (waypoint)
Definition viewport_type.h:135
DDSP_CREATE_RIVER
@ DDSP_CREATE_RIVER
Create rivers.
Definition viewport_type.h:119
DDSP_BUILD_OBJECT
@ DDSP_BUILD_OBJECT
Build an object.
Definition viewport_type.h:122
DDSP_PLACE_ROAD_X_DIR
@ DDSP_PLACE_ROAD_X_DIR
Road placement (X axis)
Definition viewport_type.h:132
DDSP_BUILD_BRIDGE
@ DDSP_BUILD_BRIDGE
Bridge placement.
Definition viewport_type.h:121
DDSP_PLACE_RAIL
@ DDSP_PLACE_RAIL
Rail placement.
Definition viewport_type.h:125
DDSP_CONVERT_ROAD
@ DDSP_CONVERT_ROAD
Road conversion.
Definition viewport_type.h:141
ZoomStateChange
ZoomStateChange
Directions of zooming.
Definition viewport_type.h:76
ZOOM_IN
@ ZOOM_IN
Zoom in (get more detailed view).
Definition viewport_type.h:77
ZOOM_NONE
@ ZOOM_NONE
Hack, used to update the button status.
Definition viewport_type.h:79
ZOOM_OUT
@ ZOOM_OUT
Zoom out (get helicopter view).
Definition viewport_type.h:78
ViewportPlaceMethod
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Definition viewport_type.h:92
VPM_FIX_Y
@ VPM_FIX_Y
drag only in Y axis
Definition viewport_type.h:95
VPM_Y_LIMITED
@ VPM_Y_LIMITED
Drag only in Y axis with limited size.
Definition viewport_type.h:101
VPM_X_AND_Y_LIMITED
@ VPM_X_AND_Y_LIMITED
area of land of limited size
Definition viewport_type.h:97
VPM_FIX_VERTICAL
@ VPM_FIX_VERTICAL
drag only in vertical direction
Definition viewport_type.h:99
VPM_X_LIMITED
@ VPM_X_LIMITED
Drag only in X axis with limited size.
Definition viewport_type.h:100
VPM_X_AND_Y
@ VPM_X_AND_Y
area of land in X and Y directions
Definition viewport_type.h:96
VPM_FIX_HORIZONTAL
@ VPM_FIX_HORIZONTAL
drag only in horizontal direction
Definition viewport_type.h:98
VPM_FIX_X
@ VPM_FIX_X
drag only in X axis
Definition viewport_type.h:94
VPM_SIGNALDIRS
@ VPM_SIGNALDIRS
similar to VMP_RAILDIRS, but with different cursor
Definition viewport_type.h:103
VPM_X_OR_Y
@ VPM_X_OR_Y
drag in X or Y direction
Definition viewport_type.h:93
VPM_RAILDIRS
@ VPM_RAILDIRS
all rail directions
Definition viewport_type.h:102
zoom_type.h
Types related to zooming in and out.
ZoomLevel
ZoomLevel
All zoom levels we know.
Definition zoom_type.h:16
ZOOM_LVL_MAX
@ ZOOM_LVL_MAX
Maximum zoom level.
Definition zoom_type.h:42