author | peter1138 |
Mon, 06 Nov 2006 22:06:29 +0000 | |
changeset 5041 | 6e292440425f |
parent 5026 | c8b7148798ac |
child 5044 | 7e70387677e5 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#ifndef VIEWPORT_H |
4 |
#define VIEWPORT_H |
|
5 |
||
6 |
struct ViewPort { |
|
4344
5d0e40cd67b9
(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
|
7 |
int left,top; // screen coordinates for the viewport |
5d0e40cd67b9
(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
|
8 |
int width, height; // screen width/height for the viewport |
0 | 9 |
|
4344
5d0e40cd67b9
(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 virtual_left, virtual_top; // virtual coordinates |
5d0e40cd67b9
(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
|
11 |
int virtual_width, virtual_height; // these are just width << zoom, height << zoom |
0 | 12 |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
13 |
byte zoom; |
0 | 14 |
}; |
15 |
||
1990
90eb49e87b90
(svn r2496) -Fix: [1179933] When toggling build/remove via keyboard the selection wasn't correctly redrawn
tron
parents:
1977
diff
changeset
|
16 |
void SetSelectionRed(bool); |
90eb49e87b90
(svn r2496) -Fix: [1179933] When toggling build/remove via keyboard the selection wasn't correctly redrawn
tron
parents:
1977
diff
changeset
|
17 |
|
0 | 18 |
/* viewport.c */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
19 |
void AssignWindowViewport(Window *w, int x, int y, |
0 | 20 |
int width, int height, uint32 follow_flags, byte zoom); |
2116 | 21 |
ViewPort *IsPtInWindowViewport(const Window *w, int x, int y); |
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
22 |
Point GetTileBelowCursor(void); |
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
|
23 |
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
|
24 |
Point GetTileZoomCenterWindow(bool in, Window * w); |
0 | 25 |
void UpdateViewportPosition(Window *w); |
26 |
||
27 |
void OffsetGroundSprite(int x, int y); |
|
28 |
||
29 |
void DrawGroundSprite(uint32 image); |
|
849
c6223dbdb202
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
30 |
void DrawGroundSpriteAt(uint32 image, int32 x, int32 y, byte z); |
0 | 31 |
void AddSortableSpriteToDraw(uint32 image, int x, int y, int w, int h, byte dz, byte z); |
5026
c8b7148798ac
(svn r7067) Remove the unused parameter params_3 from AddStringToDraw()
tron
parents:
4799
diff
changeset
|
32 |
void *AddStringToDraw(int x, int y, StringID string, uint32 params_1, uint32 params_2); |
0 | 33 |
void AddChildSpriteScreen(uint32 image, int x, int y); |
34 |
||
35 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
36 |
void StartSpriteCombine(void); |
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
37 |
void EndSpriteCombine(void); |
0 | 38 |
|
2116 | 39 |
void HandleViewportClicked(const ViewPort *vp, int x, int y); |
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
40 |
void PlaceObject(void); |
0 | 41 |
void SetRedErrorSquare(TileIndex tile); |
42 |
void SetTileSelectSize(int w, int h); |
|
43 |
void SetTileSelectBigSize(int ox, int oy, int sx, int sy); |
|
44 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1863
diff
changeset
|
45 |
void VpStartPlaceSizing(TileIndex tile, int user); |
0 | 46 |
void VpSetPresizeRange(uint from, uint to); |
47 |
void VpSetPlaceSizingLimit(int limit); |
|
48 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
49 |
Vehicle *CheckMouseOverVehicle(void); |
0 | 50 |
|
51 |
enum { |
|
4344
5d0e40cd67b9
(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
|
52 |
VPM_X_OR_Y = 0, |
5d0e40cd67b9
(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
|
53 |
VPM_FIX_X = 1, |
5d0e40cd67b9
(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
|
54 |
VPM_FIX_Y = 2, |
5d0e40cd67b9
(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
|
55 |
VPM_RAILDIRS = 3, |
5d0e40cd67b9
(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
|
56 |
VPM_X_AND_Y = 4, |
0 | 57 |
VPM_X_AND_Y_LIMITED = 5, |
4344
5d0e40cd67b9
(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
|
58 |
VPM_SIGNALDIRS = 6 |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
59 |
}; |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
60 |
|
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
61 |
// viewport highlight mode (for highlighting tiles below cursor) |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
62 |
enum { |
4344
5d0e40cd67b9
(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
|
63 |
VHM_NONE = 0, // default |
5d0e40cd67b9
(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
|
64 |
VHM_RECT = 1, // rectangle (stations, depots, ...) |
5d0e40cd67b9
(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
|
65 |
VHM_POINT = 2, // point (lower land, raise land, level land, ...) |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
66 |
VHM_SPECIAL = 3, // special mode used for highlighting while dragging (and for tunnels/docks) |
4344
5d0e40cd67b9
(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
|
67 |
VHM_DRAG = 4, // dragging items in the depot windows |
5d0e40cd67b9
(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
|
68 |
VHM_RAIL = 5, // rail pieces |
0 | 69 |
}; |
70 |
||
71 |
void VpSelectTilesWithMethod(int x, int y, int method); |
|
72 |
||
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
73 |
// highlighting draw styles |
4799
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
74 |
typedef byte HighLightStyle; |
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
75 |
enum HighLightStyles { |
4344
5d0e40cd67b9
(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 |
HT_NONE = 0x00, |
5d0e40cd67b9
(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
|
77 |
HT_RECT = 0x80, |
5d0e40cd67b9
(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
|
78 |
HT_POINT = 0x40, |
5d0e40cd67b9
(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
|
79 |
HT_LINE = 0x20, /* used for autorail highlighting (longer streches) |
5d0e40cd67b9
(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
|
80 |
* (uses lower bits to indicate direction) */ |
5d0e40cd67b9
(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
|
81 |
HT_RAIL = 0x10, /* autorail (one piece) |
5d0e40cd67b9
(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
|
82 |
* (uses lower bits to indicate direction) */ |
4799
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
83 |
HT_DRAG_MASK = 0xF0, ///< masks the drag-type |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
84 |
|
1109
1bab892228cd
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1093
diff
changeset
|
85 |
/* lower bits (used with HT_LINE and HT_RAIL): |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
86 |
* (see ASCII art in autorail.h for a visual interpretation) */ |
4799
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
87 |
HT_DIR_X = 0, ///< X direction |
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
88 |
HT_DIR_Y = 1, ///< Y direction |
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
89 |
HT_DIR_HU = 2, ///< horizontal upper |
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
90 |
HT_DIR_HL = 3, ///< horizontal lower |
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
91 |
HT_DIR_VL = 4, ///< vertical left |
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
92 |
HT_DIR_VR = 5, ///< vertical right |
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4344
diff
changeset
|
93 |
HT_DIR_MASK = 0x7 ///< masks the drag-direction |
0 | 94 |
}; |
95 |
||
96 |
typedef struct TileHighlightData { |
|
97 |
Point size; |
|
98 |
Point outersize; |
|
99 |
Point pos; |
|
100 |
Point offs; |
|
101 |
||
102 |
Point new_pos; |
|
103 |
Point new_size; |
|
104 |
Point new_outersize; |
|
105 |
||
106 |
Point selend, selstart; |
|
107 |
||
108 |
byte dirty; |
|
109 |
byte sizelimit; |
|
110 |
||
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
111 |
byte drawstyle; // lower bits 0-3 are reserved for detailed highlight information information |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
112 |
byte new_drawstyle; // only used in UpdateTileSelection() to as a buffer to compare if there was a change between old and new |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
113 |
byte next_drawstyle; // queued, but not yet drawn style |
0 | 114 |
|
115 |
byte place_mode; |
|
116 |
bool make_square_red; |
|
873
46e892485be3
(svn r1354) Use WindowClass/WindowNumber to store/pass window class/number, not some arbitrary data types
tron
parents:
849
diff
changeset
|
117 |
WindowClass window_class; |
46e892485be3
(svn r1354) Use WindowClass/WindowNumber to store/pass window class/number, not some arbitrary data types
tron
parents:
849
diff
changeset
|
118 |
WindowNumber window_number; |
0 | 119 |
|
120 |
int userdata; |
|
121 |
TileIndex redsq; |
|
122 |
} TileHighlightData; |
|
123 |
||
124 |
||
125 |
// common button handler |
|
126 |
bool HandlePlacePushButton(Window *w, int widget, uint32 cursor, int mode, PlaceProc *placeproc); |
|
127 |
||
128 |
/* viewport.c */ |
|
771
837aa06c7461
(svn r1237) -Fix: Viewports crash when too many viewports are open. Their amount was not updated to reflect the updated windows amount (thx lefti)
darkvater
parents:
513
diff
changeset
|
129 |
// XXX - maximum viewports is maximum windows - 2 (main toolbar + status bar) |
837aa06c7461
(svn r1237) -Fix: Viewports crash when too many viewports are open. Their amount was not updated to reflect the updated windows amount (thx lefti)
darkvater
parents:
513
diff
changeset
|
130 |
VARDEF ViewPort _viewports[25 - 2]; |
0 | 131 |
VARDEF uint32 _active_viewports; |
132 |
||
133 |
VARDEF Point _tile_fract_coords; |
|
134 |
||
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1109
diff
changeset
|
135 |
extern TileHighlightData _thd; |
0 | 136 |
|
137 |
||
430 | 138 |
void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom); |
139 |
||
140 |
#endif /* VIEWPORT_H */ |