OpenTTD Source: src/tilehighlight_type.h Source File

OpenTTD Source 15.0-RC2

tilehighlight_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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef TILEHIGHLIGHT_TYPE_H
11#define TILEHIGHLIGHT_TYPE_H
12
13#include "core/geometry_type.hpp"
14#include "window_type.h"
15#include "tile_type.h"
16#include "viewport_type.h"
17
19 enum HighLightStyle : uint16_t {
20 HT_NONE = 0x000,
21 HT_RECT = 0x010,
22 HT_POINT = 0x020,
23 HT_SPECIAL = 0x030,
24 HT_DRAG = 0x040,
25 HT_LINE = 0x008,
26 HT_RAIL = 0x080,
27 HT_VEHICLE = 0x100,
28 HT_DIAGONAL = 0x200,
29 HT_DRAG_MASK = 0x0F8,
30
31 /* lower bits (used with HT_LINE and HT_RAIL):
32 * (see ASCII art in table/autorail.h for a visual interpretation) */
33 HT_DIR_X = 0,
34 HT_DIR_Y = 1,
35 HT_DIR_HU = 2,
36 HT_DIR_HL = 3,
37 HT_DIR_VL = 4,
38 HT_DIR_VR = 5,
39 HT_DIR_END,
40 HT_DIR_MASK = 0x7,
41};
42 DECLARE_ENUM_AS_BIT_SET(HighLightStyle)
43
44
45
46struct TileHighlightData {
47 Point pos;
48 Point size;
49 Point offs;
50 Point outersize;
51 bool diagonal;
52
53 bool freeze;
54
55 Point new_pos;
56 Point new_size;
57 Point new_outersize;
58 uint8_t dirty;
59
60 Point selstart;
61 Point selend;
62 uint8_t sizelimit;
63
64 HighLightStyle drawstyle;
65 HighLightStyle next_drawstyle;
66
67 HighLightStyle place_mode;
68 WindowClass window_class;
69 WindowNumber window_number;
70
71 bool make_square_red;
72 TileIndex redsq;
73
74 ViewportPlaceMethod select_method;
75 ViewportDragDropSelectionProcess select_proc;
76
77 void Reset();
78
79 bool IsDraggingDiagonal();
80 Window *GetCallbackWnd();
81};
82
83#endif /* TILEHIGHLIGHT_TYPE_H */
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:119
geometry_type.hpp
All geometry types in OpenTTD.
Coord2D< int >
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
TileHighlightData
Metadata about the current highlighting.
Definition tilehighlight_type.h:46
TileHighlightData::redsq
TileIndex redsq
The tile that has to get a red selection.
Definition tilehighlight_type.h:72
TileHighlightData::new_pos
Point new_pos
New value for pos; used to determine whether to redraw the selection.
Definition tilehighlight_type.h:55
TileHighlightData::make_square_red
bool make_square_red
Whether to give a tile a red selection.
Definition tilehighlight_type.h:71
TileHighlightData::select_proc
ViewportDragDropSelectionProcess select_proc
The procedure that has to be called when the selection is done.
Definition tilehighlight_type.h:75
TileHighlightData::selstart
Point selstart
The location where the dragging started.
Definition tilehighlight_type.h:60
TileHighlightData::new_outersize
Point new_outersize
New value for outersize; used to determine whether to redraw the selection.
Definition tilehighlight_type.h:57
TileHighlightData::drawstyle
HighLightStyle drawstyle
Lower bits 0-3 are reserved for detailed highlight information.
Definition tilehighlight_type.h:64
TileHighlightData::place_mode
HighLightStyle place_mode
Method which is used to place the selection.
Definition tilehighlight_type.h:67
TileHighlightData::window_class
WindowClass window_class
The WindowClass of the window that is responsible for the selection mode.
Definition tilehighlight_type.h:68
TileHighlightData::dirty
uint8_t dirty
Whether the build station window needs to redraw due to the changed selection.
Definition tilehighlight_type.h:58
TileHighlightData::offs
Point offs
Offset, in tile "units", for the blue coverage area from the selected area's northern tile.
Definition tilehighlight_type.h:49
TileHighlightData::size
Point size
Size, in tile "units", of the white/red selection area.
Definition tilehighlight_type.h:48
TileHighlightData::sizelimit
uint8_t sizelimit
Whether the selection is limited in length, and what the maximum length is.
Definition tilehighlight_type.h:62
TileHighlightData::pos
Point pos
Location, in tile "units", of the northern tile of the selected area.
Definition tilehighlight_type.h:47
TileHighlightData::outersize
Point outersize
Size, in tile "units", of the blue coverage area excluding the side of the selected area.
Definition tilehighlight_type.h:50
TileHighlightData::diagonal
bool diagonal
Whether the dragged area is a 45 degrees rotated rectangle.
Definition tilehighlight_type.h:51
TileHighlightData::selend
Point selend
The location where the drag currently ends.
Definition tilehighlight_type.h:61
TileHighlightData::new_size
Point new_size
New value for size; used to determine whether to redraw the selection.
Definition tilehighlight_type.h:56
TileHighlightData::freeze
bool freeze
Freeze highlight in place.
Definition tilehighlight_type.h:53
TileHighlightData::next_drawstyle
HighLightStyle next_drawstyle
Queued, but not yet drawn style.
Definition tilehighlight_type.h:65
TileHighlightData::select_method
ViewportPlaceMethod select_method
The method which governs how tiles are selected.
Definition tilehighlight_type.h:74
TileHighlightData::window_number
WindowNumber window_number
The WindowNumber of the window that is responsible for the selection mode.
Definition tilehighlight_type.h:69
WindowNumber
Number to differentiate different windows of the same class.
Definition window_type.h:760
Window
Data structure for an opened window.
Definition window_gui.h:274
tile_type.h
Types related to tiles.
HighLightStyle
HighLightStyle
Highlighting draw styles.
Definition tilehighlight_type.h:19
HT_LINE
@ HT_LINE
used for autorail highlighting (longer stretches), lower bits: direction
Definition tilehighlight_type.h:25
HT_DIR_HL
@ HT_DIR_HL
horizontal lower
Definition tilehighlight_type.h:36
HT_DIR_HU
@ HT_DIR_HU
horizontal upper
Definition tilehighlight_type.h:35
HT_DRAG
@ HT_DRAG
dragging items in the depot windows
Definition tilehighlight_type.h:24
HT_NONE
@ HT_NONE
default
Definition tilehighlight_type.h:20
HT_DIR_X
@ HT_DIR_X
X direction.
Definition tilehighlight_type.h:33
HT_DIAGONAL
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
Definition tilehighlight_type.h:28
HT_POINT
@ HT_POINT
point (lower land, raise land, level land, ...)
Definition tilehighlight_type.h:22
HT_RECT
@ HT_RECT
rectangle (stations, depots, ...)
Definition tilehighlight_type.h:21
HT_DIR_MASK
@ HT_DIR_MASK
masks the drag-direction
Definition tilehighlight_type.h:40
HT_RAIL
@ HT_RAIL
autorail (one piece), lower bits: direction
Definition tilehighlight_type.h:26
HT_DIR_END
@ HT_DIR_END
end marker
Definition tilehighlight_type.h:39
HT_DRAG_MASK
@ HT_DRAG_MASK
Mask for the tile drag-type modes.
Definition tilehighlight_type.h:29
HT_DIR_VL
@ HT_DIR_VL
vertical left
Definition tilehighlight_type.h:37
HT_VEHICLE
@ HT_VEHICLE
vehicle is accepted as target as well (bitmask)
Definition tilehighlight_type.h:27
HT_DIR_VR
@ HT_DIR_VR
vertical right
Definition tilehighlight_type.h:38
HT_SPECIAL
@ HT_SPECIAL
special mode used for highlighting while dragging (and for tunnels/docks)
Definition tilehighlight_type.h:23
HT_DIR_Y
@ HT_DIR_Y
Y direction.
Definition tilehighlight_type.h:34
viewport_type.h
Types related to viewports.
ViewportPlaceMethod
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Definition viewport_type.h:96
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:115
window_type.h
Types related to windows.
WindowClass
WindowClass
Window classes.
Definition window_type.h:49