author | tron |
Sun, 17 Jul 2005 20:14:58 +0000 | |
changeset 2116 | 23031555ff54 |
parent 1990 | efb67f977138 |
child 2186 | db48cf29b983 |
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 |
||
1990
efb67f977138
(svn r2496) -Fix: [1179933] When toggling build/remove via keyboard the selection wasn't correctly redrawn
tron
parents:
1977
diff
changeset
|
14 |
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
|
15 |
|
0 | 16 |
/* viewport.c */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
17 |
void AssignWindowViewport(Window *w, int x, int y, |
0 | 18 |
int width, int height, uint32 follow_flags, byte zoom); |
19 |
void SetViewportPosition(Window *w, int x, int y); |
|
2116 | 20 |
ViewPort *IsPtInWindowViewport(const 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
|
21 |
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
|
22 |
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
|
23 |
Point GetTileZoomCenterWindow(bool in, Window * w); |
0 | 24 |
void UpdateViewportPosition(Window *w); |
25 |
||
26 |
void OffsetGroundSprite(int x, int y); |
|
27 |
||
28 |
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
|
29 |
void DrawGroundSpriteAt(uint32 image, int32 x, int32 y, byte z); |
0 | 30 |
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
|
31 |
void *AddStringToDraw(int x, int y, StringID string, uint32 params_1, uint32 params_2, uint32 params_3); |
0 | 32 |
void AddChildSpriteScreen(uint32 image, int x, int y); |
33 |
||
34 |
||
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
|
35 |
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
|
36 |
void EndSpriteCombine(void); |
0 | 37 |
|
2116 | 38 |
void HandleViewportClicked(const 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
|
39 |
void PlaceObject(void); |
0 | 40 |
void SetRedErrorSquare(TileIndex tile); |
41 |
void SetTileSelectSize(int w, int h); |
|
42 |
void SetTileSelectBigSize(int ox, int oy, int sx, int sy); |
|
43 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1863
diff
changeset
|
44 |
void VpStartPlaceSizing(TileIndex 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
|
45 |
void VpStartPreSizing(void); |
0 | 46 |
void VpSetPresizeRange(uint from, uint to); |
47 |
void VpSetPlaceSizingLimit(int limit); |
|
48 |
||
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
|
49 |
Vehicle *CheckMouseOverVehicle(void); |
0 | 50 |
|
51 |
enum { |
|
52 |
VPM_X_OR_Y = 0, |
|
53 |
VPM_FIX_X = 1, |
|
54 |
VPM_FIX_Y = 2, |
|
55 |
VPM_RAILDIRS = 3, |
|
56 |
VPM_X_AND_Y = 4, |
|
57 |
VPM_X_AND_Y_LIMITED = 5, |
|
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
58 |
VPM_SIGNALDIRS = 6 |
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 |
|
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
61 |
// viewport highlight mode (for highlighting tiles below cursor) |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
62 |
enum { |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
63 |
VHM_NONE = 0, // default |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
64 |
VHM_RECT = 1, // rectangle (stations, depots, ...) |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
65 |
VHM_POINT = 2, // point (lower land, raise land, level land, ...) |
bd31ed783fd3
(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) |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
67 |
VHM_DRAG = 4, // dragging items in the depot windows |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
68 |
VHM_RAIL = 5, // rail pieces |
0 | 69 |
}; |
70 |
||
71 |
void VpSelectTilesWithMethod(int x, int y, int method); |
|
72 |
||
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
73 |
// highlighting draw styles |
0 | 74 |
enum { |
75 |
HT_NONE = 0, |
|
76 |
HT_RECT = 0x80, |
|
77 |
HT_POINT = 0x40, |
|
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
78 |
HT_LINE = 0x20, /* used for autorail highlighting (longer streches) |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
79 |
* (uses lower bits to indicate direction) */ |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
80 |
HT_RAIL = 0x10, /* autorail (one piece) |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
81 |
* (uses lower bits to indicate direction) */ |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
82 |
|
1109
ecb98f43ba2c
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1093
diff
changeset
|
83 |
/* lower bits (used with HT_LINE and HT_RAIL): |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
84 |
* (see ASCII art in autorail.h for a visual interpretation) */ |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
85 |
HT_DIR_X = 0, // X direction |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
86 |
HT_DIR_Y = 1, // Y direction |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
87 |
HT_DIR_HU = 2, // horizontal upper |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
88 |
HT_DIR_HL = 3, // horizontal lower |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
89 |
HT_DIR_VL = 4, // vertical left |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
90 |
HT_DIR_VR = 5, // vertical right |
0 | 91 |
}; |
92 |
||
93 |
typedef struct TileHighlightData { |
|
94 |
Point size; |
|
95 |
Point outersize; |
|
96 |
Point pos; |
|
97 |
Point offs; |
|
98 |
||
99 |
Point new_pos; |
|
100 |
Point new_size; |
|
101 |
Point new_outersize; |
|
102 |
||
103 |
Point selend, selstart; |
|
104 |
||
105 |
byte dirty; |
|
106 |
byte sizelimit; |
|
107 |
||
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
873
diff
changeset
|
108 |
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
|
109 |
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
|
110 |
byte next_drawstyle; // queued, but not yet drawn style |
0 | 111 |
|
112 |
byte place_mode; |
|
113 |
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
|
114 |
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
|
115 |
WindowNumber window_number; |
0 | 116 |
|
117 |
int userdata; |
|
118 |
TileIndex redsq; |
|
119 |
} TileHighlightData; |
|
120 |
||
121 |
||
122 |
// common button handler |
|
123 |
bool HandlePlacePushButton(Window *w, int widget, uint32 cursor, int mode, PlaceProc *placeproc); |
|
124 |
||
125 |
/* 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
|
126 |
// 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
|
127 |
VARDEF ViewPort _viewports[25 - 2]; |
0 | 128 |
VARDEF uint32 _active_viewports; |
129 |
||
130 |
VARDEF Point _tile_fract_coords; |
|
131 |
||
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1109
diff
changeset
|
132 |
extern TileHighlightData _thd; |
0 | 133 |
|
134 |
||
430 | 135 |
void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom); |
136 |
||
137 |
#endif /* VIEWPORT_H */ |