author | KUDr |
Fri, 20 Apr 2007 19:43:06 +0000 | |
changeset 6513 | 454347ca3dfb |
parent 6423 | 8e10e79e0fd1 |
child 6624 | 880e29b1f25e |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6423
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6248
diff
changeset
|
3 |
/** @file viewport.h */ |
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6248
diff
changeset
|
4 |
|
0 | 5 |
#ifndef VIEWPORT_H |
6 |
#define VIEWPORT_H |
|
7 |
||
8 |
struct ViewPort { |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
9 |
int left,top; // screen coordinates for the viewport |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
10 |
int width, height; // screen width/height for the viewport |
0 | 11 |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
12 |
int virtual_left, virtual_top; // virtual coordinates |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
13 |
int virtual_width, virtual_height; // these are just width << zoom, height << zoom |
0 | 14 |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
15 |
byte zoom; |
0 | 16 |
}; |
17 |
||
1990
efb67f977138
(svn r2496) -Fix: [1179933] When toggling build/remove via keyboard the selection wasn't correctly redrawn
tron
parents:
1977
diff
changeset
|
18 |
void SetSelectionRed(bool); |
efb67f977138
(svn r2496) -Fix: [1179933] When toggling build/remove via keyboard the selection wasn't correctly redrawn
tron
parents:
1977
diff
changeset
|
19 |
|
6423
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6248
diff
changeset
|
20 |
/* viewport.cpp */ |
6247 | 21 |
void InitViewports(); |
5122
3aa375cb5e8e
(svn r7202) -Codechange: Move _viewports and _active_viewports local to viewport.c and have them
Darkvater
parents:
5046
diff
changeset
|
22 |
void DeleteWindowViewport(Window *w); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
23 |
void AssignWindowViewport(Window *w, int x, int y, |
0 | 24 |
int width, int height, uint32 follow_flags, byte zoom); |
2116 | 25 |
ViewPort *IsPtInWindowViewport(const Window *w, int x, int y); |
6247 | 26 |
Point GetTileBelowCursor(); |
5044
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5026
diff
changeset
|
27 |
void UpdateViewportPosition(Window *w); |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5026
diff
changeset
|
28 |
|
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5026
diff
changeset
|
29 |
enum { |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5026
diff
changeset
|
30 |
ZOOM_IN = 0, |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5026
diff
changeset
|
31 |
ZOOM_OUT = 1, |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5026
diff
changeset
|
32 |
ZOOM_NONE = 2, // hack, used to update the button status |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5026
diff
changeset
|
33 |
}; |
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5026
diff
changeset
|
34 |
|
e4e5bcdd79c6
(svn r7093) -Codechange: Move DoZoomInOutWindow declaration to viewport.h and rewrite the function
Darkvater
parents:
5026
diff
changeset
|
35 |
bool DoZoomInOutWindow(int how, Window *w); |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
133
diff
changeset
|
36 |
void ZoomInOrOutToCursorWindow(bool in, Window * w); |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
133
diff
changeset
|
37 |
Point GetTileZoomCenterWindow(bool in, Window * w); |
5045
846098142ffe
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5044
diff
changeset
|
38 |
void HandleZoomMessage(Window *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out); |
0 | 39 |
|
5046
d2c53a73b580
(svn r7095) -Codechange: Move MaxZoomIn function to viewport.h and change it to MaxZoomInOut
Darkvater
parents:
5045
diff
changeset
|
40 |
static inline void MaxZoomInOut(int how, Window *w) |
d2c53a73b580
(svn r7095) -Codechange: Move MaxZoomIn function to viewport.h and change it to MaxZoomInOut
Darkvater
parents:
5045
diff
changeset
|
41 |
{ |
d2c53a73b580
(svn r7095) -Codechange: Move MaxZoomIn function to viewport.h and change it to MaxZoomInOut
Darkvater
parents:
5045
diff
changeset
|
42 |
while (DoZoomInOutWindow(how, w) ) {}; |
d2c53a73b580
(svn r7095) -Codechange: Move MaxZoomIn function to viewport.h and change it to MaxZoomInOut
Darkvater
parents:
5045
diff
changeset
|
43 |
} |
d2c53a73b580
(svn r7095) -Codechange: Move MaxZoomIn function to viewport.h and change it to MaxZoomInOut
Darkvater
parents:
5045
diff
changeset
|
44 |
|
0 | 45 |
void OffsetGroundSprite(int x, int y); |
46 |
||
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
47 |
void DrawGroundSprite(SpriteID image, SpriteID pal); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
48 |
void DrawGroundSpriteAt(SpriteID image, SpriteID pal, int32 x, int32 y, byte z); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
49 |
void AddSortableSpriteToDraw(SpriteID image, SpriteID pal, int x, int y, int w, int h, byte dz, byte z); |
5026
d589561bc43d
(svn r7067) Remove the unused parameter params_3 from AddStringToDraw()
tron
parents:
4799
diff
changeset
|
50 |
void *AddStringToDraw(int x, int y, StringID string, uint32 params_1, uint32 params_2); |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
51 |
void AddChildSpriteScreen(SpriteID image, SpriteID pal, int x, int y); |
0 | 52 |
|
53 |
||
6247 | 54 |
void StartSpriteCombine(); |
55 |
void EndSpriteCombine(); |
|
0 | 56 |
|
2116 | 57 |
void HandleViewportClicked(const ViewPort *vp, int x, int y); |
6247 | 58 |
void PlaceObject(); |
0 | 59 |
void SetRedErrorSquare(TileIndex tile); |
60 |
void SetTileSelectSize(int w, int h); |
|
61 |
void SetTileSelectBigSize(int ox, int oy, int sx, int sy); |
|
62 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1863
diff
changeset
|
63 |
void VpStartPlaceSizing(TileIndex tile, int user); |
0 | 64 |
void VpSetPresizeRange(uint from, uint to); |
65 |
void VpSetPlaceSizingLimit(int limit); |
|
66 |
||
6247 | 67 |
Vehicle *CheckMouseOverVehicle(); |
0 | 68 |
|
69 |
enum { |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
70 |
VPM_X_OR_Y = 0, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
71 |
VPM_FIX_X = 1, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
72 |
VPM_FIX_Y = 2, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
73 |
VPM_RAILDIRS = 3, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
74 |
VPM_X_AND_Y = 4, |
0 | 75 |
VPM_X_AND_Y_LIMITED = 5, |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
76 |
VPM_SIGNALDIRS = 6 |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
77 |
}; |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
78 |
|
6423
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6248
diff
changeset
|
79 |
/* viewport highlight mode (for highlighting tiles below cursor) */ |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
80 |
enum { |
6423
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6248
diff
changeset
|
81 |
VHM_NONE = 0, ///< default |
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6248
diff
changeset
|
82 |
VHM_RECT = 1, ///< rectangle (stations, depots, ...) |
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6248
diff
changeset
|
83 |
VHM_POINT = 2, ///< point (lower land, raise land, level land, ...) |
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6248
diff
changeset
|
84 |
VHM_SPECIAL = 3, ///< special mode used for highlighting while dragging (and for tunnels/docks) |
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6248
diff
changeset
|
85 |
VHM_DRAG = 4, ///< dragging items in the depot windows |
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6248
diff
changeset
|
86 |
VHM_RAIL = 5, ///< rail pieces |
0 | 87 |
}; |
88 |
||
89 |
void VpSelectTilesWithMethod(int x, int y, int method); |
|
90 |
||
6423
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6248
diff
changeset
|
91 |
/* highlighting draw styles */ |
4799
20311e38bedf
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
92 |
typedef byte HighLightStyle; |
20311e38bedf
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
93 |
enum HighLightStyles { |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
94 |
HT_NONE = 0x00, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
95 |
HT_RECT = 0x80, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
2817
diff
changeset
|
96 |
HT_POINT = 0x40, |
6423
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6248
diff
changeset
|
97 |
HT_LINE = 0x20, ///< used for autorail highlighting (longer streches) |
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6248
diff
changeset
|
98 |
///< (uses lower bits to indicate direction) |
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6248
diff
changeset
|
99 |
HT_RAIL = 0x10, ///< autorail (one piece) |
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6248
diff
changeset
|
100 |
///< (uses lower bits to indicate direction) |
4799
20311e38bedf
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
101 |
HT_DRAG_MASK = 0xF0, ///< masks the drag-type |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
102 |
|
1109
ecb98f43ba2c
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1093
diff
changeset
|
103 |
/* lower bits (used with HT_LINE and HT_RAIL): |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
104 |
* (see ASCII art in autorail.h for a visual interpretation) */ |
4799
20311e38bedf
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
105 |
HT_DIR_X = 0, ///< X direction |
20311e38bedf
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
106 |
HT_DIR_Y = 1, ///< Y direction |
20311e38bedf
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
107 |
HT_DIR_HU = 2, ///< horizontal upper |
20311e38bedf
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
108 |
HT_DIR_HL = 3, ///< horizontal lower |
20311e38bedf
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
109 |
HT_DIR_VL = 4, ///< vertical left |
20311e38bedf
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
110 |
HT_DIR_VR = 5, ///< vertical right |
20311e38bedf
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
111 |
HT_DIR_MASK = 0x7 ///< masks the drag-direction |
0 | 112 |
}; |
113 |
||
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
114 |
struct TileHighlightData { |
0 | 115 |
Point size; |
116 |
Point outersize; |
|
117 |
Point pos; |
|
118 |
Point offs; |
|
119 |
||
120 |
Point new_pos; |
|
121 |
Point new_size; |
|
122 |
Point new_outersize; |
|
123 |
||
124 |
Point selend, selstart; |
|
125 |
||
126 |
byte dirty; |
|
127 |
byte sizelimit; |
|
128 |
||
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
129 |
byte drawstyle; // lower bits 0-3 are reserved for detailed highlight information information |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
130 |
byte new_drawstyle; // only used in UpdateTileSelection() to as a buffer to compare if there was a change between old and new |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
131 |
byte next_drawstyle; // queued, but not yet drawn style |
0 | 132 |
|
133 |
byte place_mode; |
|
134 |
bool make_square_red; |
|
873
732553f5b169
(svn r1354) Use WindowClass/WindowNumber to store/pass window class/number, not some arbitrary data types
tron
parents:
849
diff
changeset
|
135 |
WindowClass window_class; |
732553f5b169
(svn r1354) Use WindowClass/WindowNumber to store/pass window class/number, not some arbitrary data types
tron
parents:
849
diff
changeset
|
136 |
WindowNumber window_number; |
0 | 137 |
|
138 |
int userdata; |
|
139 |
TileIndex redsq; |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
140 |
}; |
0 | 141 |
|
142 |
||
6423
8e10e79e0fd1
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6248
diff
changeset
|
143 |
/* common button handler */ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5475
diff
changeset
|
144 |
bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, int mode, PlaceProc *placeproc); |
0 | 145 |
|
146 |
VARDEF Point _tile_fract_coords; |
|
147 |
||
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1109
diff
changeset
|
148 |
extern TileHighlightData _thd; |
0 | 149 |
|
150 |
||
430 | 151 |
void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom); |
152 |
||
153 |
#endif /* VIEWPORT_H */ |