OpenTTD Source 20250205-master-gfd85ab1e2c
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 "core/enum_type.hpp"
14#include "zoom_type.h"
15#include "strings_type.h"
16#include "table/strings.h"
17
19
21enum class ViewportStringFlag : uint8_t {
22 Small,
23 Shadow,
27};
29
33struct Viewport {
34 int left;
35 int top;
36 int width;
37 int height;
38
43
45 std::shared_ptr<LinkGraphOverlay> overlay;
46};
47
50 int32_t center;
51 int32_t top;
52 uint16_t width_normal;
53 uint16_t width_small;
54
55 auto operator<=>(const ViewportSign &) const = default;
56
57 void UpdatePosition(int center, int top, StringID str, StringID str_small = STR_NULL);
58 void MarkDirty(ZoomLevel maxzoom = ZOOM_LVL_MAX) const;
59};
60
64
65 auto operator<=>(const TrackedViewportSign &) const = default;
66
71 void UpdatePosition(int center, int top, StringID str, StringID str_small = STR_NULL)
72 {
73 this->kdtree_valid = true;
74 this->ViewportSign::UpdatePosition(center, top, str, str_small);
75 }
76
77
79 {
80 }
81};
82
87enum ZoomStateChange : uint8_t {
88 ZOOM_IN = 0,
91};
92
99static const uint BB_HEIGHT_UNDER_BRIDGE = 6;
100static const uint BB_Z_SEPARATOR = 7;
101
117
118
154
155
164
165#endif /* VIEWPORT_TYPE_H */
Handles drawing of links into some window.
Type (helpers) for enums.
#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:68
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).
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
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).
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.
ViewportStringFlag
Flags to control how Viewport Strings are rendered.
@ ColourRect
Draw a colour rect around the sign.
@ Small
Draw using the small font.
@ Shadow
Draw an extra text shadow. Should only be used with ViewportStringFlag::Small, as normal font already...
@ TransparentRect
Draw a transparent rect around the sign.
@ TextColour
Draw text in colour.
static const uint BB_Z_SEPARATOR
Separates the bridge/tunnel from the things under/above it.
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