OpenTTD Source 20241224-master-gf74b0cf984
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
18
22struct Viewport {
23 int left;
24 int top;
25 int width;
26 int height;
27
32
34 std::shared_ptr<LinkGraphOverlay> overlay;
35};
36
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
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
81
88static const uint BB_HEIGHT_UNDER_BRIDGE = 6;
89static const uint BB_Z_SEPARATOR = 7;
90
106
107
143
144
153
154#endif /* VIEWPORT_TYPE_H */
Handles drawing of links into some window.
#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
void MarkDirty(ZoomLevel maxzoom=ZOOM_LVL_MAX) const
Mark the sign dirty in all viewports.
Types related to strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Specialised ViewportSign that tracks whether it is valid for entering into a Kdtree.
void UpdatePosition(int center, int top, StringID str, StringID str_small=STR_NULL)
Update the position of the viewport sign.
bool kdtree_valid
Are the sign data valid for use with the _viewport_sign_kdtree?
Location information about a sign as seen on the viewport.
int32_t center
The center position of the sign.
uint16_t width_small
The width when zoomed out (small font)
uint16_t width_normal
The width when not zoomed out (normal font)
void UpdatePosition(int center, int top, StringID str, StringID str_small=STR_NULL)
Update the position of the viewport sign.
int32_t top
The top of the sign.
Data structure for viewport, display of a part of the world.
int top
Screen coordinate top edge of the viewport.
int width
Screen width of the viewport.
ZoomLevel zoom
The zoom level of the viewport.
int virtual_top
Virtual top coordinate.
int virtual_left
Virtual left coordinate.
int virtual_width
width << zoom
int left
Screen coordinate left edge of the viewport.
int height
Screen height of the viewport.
int virtual_height
height << zoom
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).
static const uint BB_Z_SEPARATOR
Separates the bridge/tunnel from the things under/above it.
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.
@ ZOOM_IN
Zoom in (get more detailed view).
@ ZOOM_NONE
Hack, used to update the button status.
@ ZOOM_OUT
Zoom out (get helicopter view).
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
@ VPM_FIX_Y
drag only in Y axis
@ VPM_Y_LIMITED
Drag only in Y axis with limited size.
@ VPM_X_AND_Y_LIMITED
area of land of limited size
@ VPM_FIX_VERTICAL
drag only in vertical direction
@ VPM_X_LIMITED
Drag only in X axis with limited size.
@ VPM_X_AND_Y
area of land in X and Y directions
@ VPM_FIX_HORIZONTAL
drag only in horizontal direction
@ VPM_FIX_X
drag only in X axis
@ VPM_SIGNALDIRS
similar to VMP_RAILDIRS, but with different cursor
@ VPM_X_OR_Y
drag in X or Y direction
@ 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