author | truelight |
Thu, 24 Mar 2005 14:43:40 +0000 | |
changeset 1540 | 6eef12dab5bf |
parent 1109 | ecb98f43ba2c |
child 1863 | 74a8379bb868 |
permissions | -rw-r--r-- |
0 | 1 |
#ifndef VIEWPORT_H |
2 |
#define VIEWPORT_H |
|
3 |
||
4 |
struct ViewPort { |
|
5 |
int left,top; // screen coordinates for the viewport |
|
6 |
int width, height; // screen width/height for the viewport |
|
7 |
||
8 |
int virtual_left, virtual_top; // virtual coordinates |
|
9 |
int virtual_width, virtual_height; // these are just width << zoom, height << zoom |
|
10 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
11 |
byte zoom; |
0 | 12 |
}; |
13 |
||
14 |
/* viewport.c */ |
|
15 |
Point MapXYZToViewport(ViewPort *vp, uint x, uint y, uint z); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
16 |
void AssignWindowViewport(Window *w, int x, int y, |
0 | 17 |
int width, int height, uint32 follow_flags, byte zoom); |
18 |
void SetViewportPosition(Window *w, int x, int y); |
|
19 |
ViewPort *IsPtInWindowViewport(Window *w, int x, int y); |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
20 |
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
|
21 |
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
|
22 |
Point GetTileZoomCenterWindow(bool in, Window * w); |
0 | 23 |
void UpdateViewportPosition(Window *w); |
24 |
||
25 |
void OffsetGroundSprite(int x, int y); |
|
26 |
||
27 |
void DrawGroundSprite(uint32 image); |
|
849
c3407041774f
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
28 |
void DrawGroundSpriteAt(uint32 image, int32 x, int32 y, byte z); |
0 | 29 |
void AddSortableSpriteToDraw(uint32 image, int x, int y, int w, int h, byte dz, byte z); |
835
f6a341f541d7
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
771
diff
changeset
|
30 |
void *AddStringToDraw(int x, int y, StringID string, uint32 params_1, uint32 params_2, uint32 params_3); |
0 | 31 |
void AddChildSpriteScreen(uint32 image, int x, int y); |
32 |
||
33 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
34 |
void StartSpriteCombine(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
35 |
void EndSpriteCombine(void); |
0 | 36 |
|
37 |
void HandleViewportClicked(ViewPort *vp, int x, int y); |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
38 |
void PlaceObject(void); |
0 | 39 |
void SetRedErrorSquare(TileIndex tile); |
40 |
void SetTileSelectSize(int w, int h); |
|
41 |
void SetTileSelectBigSize(int ox, int oy, int sx, int sy); |
|
42 |
||
43 |
void VpStartPlaceSizing(uint tile, int user); |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
44 |
void VpStartPreSizing(void); |
0 | 45 |
void VpSetPresizeRange(uint from, uint to); |
46 |
void VpSetPlaceSizingLimit(int limit); |
|
47 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1070
diff
changeset
|
48 |
Vehicle *CheckMouseOverVehicle(void); |
0 | 49 |
|
50 |
enum { |
|
51 |
VPM_X_OR_Y = 0, |
|
52 |
VPM_FIX_X = 1, |
|
53 |
VPM_FIX_Y = 2, |
|
54 |
VPM_RAILDIRS = 3, |
|
55 |
VPM_X_AND_Y = 4, |
|
56 |
VPM_X_AND_Y_LIMITED = 5, |
|
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
57 |
VPM_SIGNALDIRS = 6 |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
58 |
}; |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
59 |
|
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
60 |
// viewport highlight mode (for highlighting tiles below cursor) |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
61 |
enum { |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
62 |
VHM_NONE = 0, // default |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
63 |
VHM_RECT = 1, // rectangle (stations, depots, ...) |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
64 |
VHM_POINT = 2, // point (lower land, raise land, level land, ...) |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
65 |
VHM_SPECIAL = 3, // special mode used for highlighting while dragging (and for tunnels/docks) |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
66 |
VHM_DRAG = 4, // dragging items in the depot windows |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
67 |
VHM_RAIL = 5, // rail pieces |
0 | 68 |
}; |
69 |
||
70 |
void VpSelectTilesWithMethod(int x, int y, int method); |
|
71 |
||
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
72 |
// highlighting draw styles |
0 | 73 |
enum { |
74 |
HT_NONE = 0, |
|
75 |
HT_RECT = 0x80, |
|
76 |
HT_POINT = 0x40, |
|
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
77 |
HT_LINE = 0x20, /* used for autorail highlighting (longer streches) |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
78 |
* (uses lower bits to indicate direction) */ |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
79 |
HT_RAIL = 0x10, /* autorail (one piece) |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
80 |
* (uses lower bits to indicate direction) */ |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
81 |
|
1109
ecb98f43ba2c
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1093
diff
changeset
|
82 |
/* lower bits (used with HT_LINE and HT_RAIL): |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
83 |
* (see ASCII art in autorail.h for a visual interpretation) */ |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
84 |
HT_DIR_X = 0, // X direction |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
85 |
HT_DIR_Y = 1, // Y direction |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
86 |
HT_DIR_HU = 2, // horizontal upper |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
87 |
HT_DIR_HL = 3, // horizontal lower |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
88 |
HT_DIR_VL = 4, // vertical left |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
89 |
HT_DIR_VR = 5, // vertical right |
0 | 90 |
}; |
91 |
||
92 |
typedef struct TileHighlightData { |
|
93 |
Point size; |
|
94 |
Point outersize; |
|
95 |
Point pos; |
|
96 |
Point offs; |
|
97 |
||
98 |
Point new_pos; |
|
99 |
Point new_size; |
|
100 |
Point new_outersize; |
|
101 |
||
102 |
Point selend, selstart; |
|
103 |
||
104 |
byte dirty; |
|
105 |
byte sizelimit; |
|
106 |
||
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
107 |
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
|
108 |
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
|
109 |
byte next_drawstyle; // queued, but not yet drawn style |
0 | 110 |
|
111 |
byte place_mode; |
|
112 |
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
|
113 |
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
|
114 |
WindowNumber window_number; |
0 | 115 |
|
116 |
int userdata; |
|
117 |
TileIndex redsq; |
|
118 |
} TileHighlightData; |
|
119 |
||
120 |
||
121 |
// common button handler |
|
122 |
bool HandlePlacePushButton(Window *w, int widget, uint32 cursor, int mode, PlaceProc *placeproc); |
|
123 |
||
124 |
/* viewport.c */ |
|
771
f08bcce4c58a
(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
|
125 |
// XXX - maximum viewports is maximum windows - 2 (main toolbar + status bar) |
f08bcce4c58a
(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
|
126 |
VARDEF ViewPort _viewports[25 - 2]; |
0 | 127 |
VARDEF TileHighlightData _thd; |
128 |
VARDEF uint32 _active_viewports; |
|
129 |
||
130 |
VARDEF Point _tile_fract_coords; |
|
131 |
||
132 |
extern TileHighlightData * const _thd_ptr; |
|
133 |
||
134 |
||
430 | 135 |
void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom); |
136 |
||
137 |
#endif /* VIEWPORT_H */ |