2009-08-21 22:21:05 +02:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2008-01-09 10:45:45 +01:00
|
|
|
/** @file viewport_type.h Types related to viewports. */
|
2007-04-04 06:08:47 +02:00
|
|
|
|
2008-01-09 10:45:45 +01:00
|
|
|
#ifndef VIEWPORT_TYPE_H
|
|
|
|
#define VIEWPORT_TYPE_H
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2007-12-23 11:56:02 +01:00
|
|
|
#include "zoom_type.h"
|
2009-07-07 18:51:20 +02:00
|
|
|
#include "strings_type.h"
|
2015-04-25 13:58:19 +02:00
|
|
|
#include "table/strings.h"
|
2007-05-15 16:08:39 +02:00
|
|
|
|
2013-05-19 16:49:25 +02:00
|
|
|
class LinkGraphOverlay;
|
|
|
|
|
2008-04-07 22:28:58 +02:00
|
|
|
/**
|
|
|
|
* Data structure for viewport, display of a part of the world
|
|
|
|
*/
|
2020-06-29 03:38:29 +02:00
|
|
|
struct Viewport {
|
2019-09-29 22:27:32 +02:00
|
|
|
int left; ///< Screen coordinate left edge of the viewport
|
2008-04-07 22:28:58 +02:00
|
|
|
int top; ///< Screen coordinate top edge of the viewport
|
|
|
|
int width; ///< Screen width of the viewport
|
|
|
|
int height; ///< Screen height of the viewport
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2008-04-07 22:28:58 +02:00
|
|
|
int virtual_left; ///< Virtual left coordinate
|
|
|
|
int virtual_top; ///< Virtual top coordinate
|
|
|
|
int virtual_width; ///< width << zoom
|
|
|
|
int virtual_height; ///< height << zoom
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2011-05-01 21:14:12 +02:00
|
|
|
ZoomLevel zoom; ///< The zoom level of the viewport.
|
2023-03-31 17:06:36 +02:00
|
|
|
std::shared_ptr<LinkGraphOverlay> overlay;
|
2004-08-09 19:04:08 +02:00
|
|
|
};
|
|
|
|
|
2009-07-08 10:50:20 +02:00
|
|
|
/** Location information about a sign as seen on the viewport */
|
2008-05-07 15:18:33 +02:00
|
|
|
struct ViewportSign {
|
2023-05-08 19:01:06 +02:00
|
|
|
int32_t center; ///< The center position of the sign
|
|
|
|
int32_t top; ///< The top of the sign
|
|
|
|
uint16_t width_normal; ///< The width when not zoomed out (normal font)
|
|
|
|
uint16_t width_small; ///< The width when zoomed out (small font)
|
2009-07-07 18:51:20 +02:00
|
|
|
|
2024-04-16 21:57:12 +02:00
|
|
|
auto operator<=>(const ViewportSign &) const = default;
|
|
|
|
|
2015-04-25 13:58:19 +02:00
|
|
|
void UpdatePosition(int center, int top, StringID str, StringID str_small = STR_NULL);
|
2012-03-25 21:30:05 +02:00
|
|
|
void MarkDirty(ZoomLevel maxzoom = ZOOM_LVL_MAX) const;
|
2008-05-07 15:18:33 +02:00
|
|
|
};
|
|
|
|
|
2019-12-01 23:17:33 +01:00
|
|
|
/** Specialised ViewportSign that tracks whether it is valid for entering into a Kdtree */
|
|
|
|
struct TrackedViewportSign : ViewportSign {
|
|
|
|
bool kdtree_valid; ///< Are the sign data valid for use with the _viewport_sign_kdtree?
|
|
|
|
|
2024-04-16 21:57:12 +02:00
|
|
|
auto operator<=>(const TrackedViewportSign &) const = default;
|
|
|
|
|
2019-12-01 23:17:33 +01:00
|
|
|
/**
|
|
|
|
* Update the position of the viewport sign.
|
|
|
|
* Note that this function hides the base class function.
|
|
|
|
*/
|
|
|
|
void UpdatePosition(int center, int top, StringID str, StringID str_small = STR_NULL)
|
|
|
|
{
|
|
|
|
this->kdtree_valid = true;
|
|
|
|
this->ViewportSign::UpdatePosition(center, top, str, str_small);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TrackedViewportSign() : kdtree_valid{ false }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-10-23 20:28:20 +02:00
|
|
|
/**
|
|
|
|
* Directions of zooming.
|
|
|
|
* @see DoZoomInOutWindow
|
|
|
|
*/
|
2010-05-13 10:56:01 +02:00
|
|
|
enum ZoomStateChange {
|
2010-10-23 20:28:20 +02:00
|
|
|
ZOOM_IN = 0, ///< Zoom in (get more detailed view).
|
|
|
|
ZOOM_OUT = 1, ///< Zoom out (get helicopter view).
|
|
|
|
ZOOM_NONE = 2, ///< Hack, used to update the button status.
|
2006-11-07 14:01:36 +01:00
|
|
|
};
|
|
|
|
|
2007-09-19 18:36:42 +02:00
|
|
|
/**
|
|
|
|
* Some values for constructing bounding boxes (BB). The Z positions under bridges are:
|
|
|
|
* z=0..5 Everything that can be built under low bridges.
|
|
|
|
* z=6 reserved, currently unused.
|
|
|
|
* z=7 Z separator between bridge/tunnel and the things under/above it.
|
|
|
|
*/
|
2010-05-13 11:44:44 +02:00
|
|
|
static const uint BB_HEIGHT_UNDER_BRIDGE = 6; ///< Everything that can be built under low bridges, must not exceed this Z height.
|
|
|
|
static const uint BB_Z_SEPARATOR = 7; ///< Separates the bridge/tunnel from the things under/above it.
|
2007-09-19 18:36:42 +02:00
|
|
|
|
2007-11-15 19:21:59 +01:00
|
|
|
/** Viewport place method (type of highlighted area and placed objects) */
|
|
|
|
enum ViewportPlaceMethod {
|
2009-04-19 23:26:06 +02:00
|
|
|
VPM_X_OR_Y = 0, ///< drag in X or Y direction
|
|
|
|
VPM_FIX_X = 1, ///< drag only in X axis
|
|
|
|
VPM_FIX_Y = 2, ///< drag only in Y axis
|
|
|
|
VPM_X_AND_Y = 3, ///< area of land in X and Y directions
|
|
|
|
VPM_X_AND_Y_LIMITED = 4, ///< area of land of limited size
|
|
|
|
VPM_FIX_HORIZONTAL = 5, ///< drag only in horizontal direction
|
|
|
|
VPM_FIX_VERTICAL = 6, ///< drag only in vertical direction
|
2010-02-02 00:13:15 +01:00
|
|
|
VPM_X_LIMITED = 7, ///< Drag only in X axis with limited size
|
|
|
|
VPM_Y_LIMITED = 8, ///< Drag only in Y axis with limited size
|
2009-04-19 23:26:06 +02:00
|
|
|
VPM_RAILDIRS = 0x40, ///< all rail directions
|
2013-01-08 23:46:42 +01:00
|
|
|
VPM_SIGNALDIRS = 0x80, ///< similar to VMP_RAILDIRS, but with different cursor
|
2005-01-19 21:55:23 +01:00
|
|
|
};
|
2010-03-23 23:25:43 +01:00
|
|
|
DECLARE_ENUM_AS_BIT_SET(ViewportPlaceMethod)
|
2005-01-19 21:55:23 +01:00
|
|
|
|
2010-08-01 21:22:34 +02:00
|
|
|
/**
|
|
|
|
* Drag and drop selection process, or, what to do with an area of land when
|
2010-08-01 21:44:49 +02:00
|
|
|
* you've selected it.
|
|
|
|
*/
|
2008-05-08 15:21:55 +02:00
|
|
|
enum ViewportDragDropSelectionProcess {
|
2010-01-31 23:37:20 +01:00
|
|
|
DDSP_DEMOLISH_AREA, ///< Clear area
|
|
|
|
DDSP_RAISE_AND_LEVEL_AREA, ///< Raise / level area
|
|
|
|
DDSP_LOWER_AND_LEVEL_AREA, ///< Lower / level area
|
|
|
|
DDSP_LEVEL_AREA, ///< Level area
|
|
|
|
DDSP_CREATE_DESERT, ///< Fill area with desert
|
|
|
|
DDSP_CREATE_ROCKS, ///< Fill area with rocks
|
|
|
|
DDSP_CREATE_WATER, ///< Create a canal
|
|
|
|
DDSP_CREATE_RIVER, ///< Create rivers
|
|
|
|
DDSP_PLANT_TREES, ///< Plant trees
|
|
|
|
DDSP_BUILD_BRIDGE, ///< Bridge placement
|
2022-02-03 01:24:52 +01:00
|
|
|
DDSP_BUILD_OBJECT, ///< Build an object
|
2008-05-08 15:21:55 +02:00
|
|
|
|
|
|
|
/* Rail specific actions */
|
2010-01-31 23:37:20 +01:00
|
|
|
DDSP_PLACE_RAIL, ///< Rail placement
|
|
|
|
DDSP_BUILD_SIGNALS, ///< Signal placement
|
|
|
|
DDSP_BUILD_STATION, ///< Station placement
|
|
|
|
DDSP_REMOVE_STATION, ///< Station removal
|
|
|
|
DDSP_CONVERT_RAIL, ///< Rail conversion
|
2008-05-08 15:21:55 +02:00
|
|
|
|
|
|
|
/* Road specific actions */
|
2010-01-31 23:37:20 +01:00
|
|
|
DDSP_PLACE_ROAD_X_DIR, ///< Road placement (X axis)
|
|
|
|
DDSP_PLACE_ROAD_Y_DIR, ///< Road placement (Y axis)
|
|
|
|
DDSP_PLACE_AUTOROAD, ///< Road placement (auto)
|
2024-04-23 20:17:21 +02:00
|
|
|
DDSP_BUILD_ROAD_WAYPOINT, ///< Road stop placement (waypoint)
|
2010-02-24 22:51:59 +01:00
|
|
|
DDSP_BUILD_BUSSTOP, ///< Road stop placement (buses)
|
|
|
|
DDSP_BUILD_TRUCKSTOP, ///< Road stop placement (trucks)
|
2024-04-23 20:17:21 +02:00
|
|
|
DDSP_REMOVE_ROAD_WAYPOINT, ///< Road stop removal (waypoint)
|
2010-02-24 22:53:16 +01:00
|
|
|
DDSP_REMOVE_BUSSTOP, ///< Road stop removal (buses)
|
|
|
|
DDSP_REMOVE_TRUCKSTOP, ///< Road stop removal (trucks)
|
2019-04-06 08:46:15 +02:00
|
|
|
DDSP_CONVERT_ROAD, ///< Road conversion
|
2008-05-08 15:21:55 +02:00
|
|
|
};
|
|
|
|
|
2018-04-24 19:19:01 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Target of the viewport scrolling GS method
|
|
|
|
*/
|
2024-03-16 23:59:32 +01:00
|
|
|
enum ViewportScrollTarget : uint8_t {
|
2018-04-24 19:19:01 +02:00
|
|
|
VST_EVERYONE, ///< All players
|
|
|
|
VST_COMPANY, ///< All players in specific company
|
|
|
|
VST_CLIENT, ///< Single player
|
|
|
|
};
|
|
|
|
|
2008-01-09 10:45:45 +01:00
|
|
|
#endif /* VIEWPORT_TYPE_H */
|