author | tron |
Sun, 23 Apr 2006 13:48:16 +0000 | |
changeset 3636 | a36cc46e754d |
parent 3609 | eaf20d1e9aec |
child 3645 | 7f950533d510 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1864
diff
changeset
|
4 |
#include "openttd.h" |
1299
39c06aba09aa
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1172
diff
changeset
|
5 |
#include "debug.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
6 |
#include "functions.h" |
2662
8b46824bd821
(svn r3204) Make handling of clicking on vehicles a bit less ugly by avoiding function declarations in .c files and unnecessary indirection
tron
parents:
2484
diff
changeset
|
7 |
#include "gui.h" |
1349
15979a2e9001
(svn r1853) Move spritecache function declarations into a header of their own and use SpriteID as parameter type where appropriate
tron
parents:
1309
diff
changeset
|
8 |
#include "spritecache.h" |
1309
4403a69da4f8
(svn r1813) Declare functions implemented in strings.c in their own shiny new header (though i think some of these function don't belong into strings.c)
tron
parents:
1299
diff
changeset
|
9 |
#include "strings.h" |
1363
775a7ee52369
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1349
diff
changeset
|
10 |
#include "table/sprites.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
500
diff
changeset
|
11 |
#include "table/strings.h" |
679
04ca2cd69420
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
657
diff
changeset
|
12 |
#include "map.h" |
0 | 13 |
#include "viewport.h" |
14 |
#include "window.h" |
|
15 |
#include "vehicle.h" |
|
16 |
#include "station.h" |
|
17 |
#include "gfx.h" |
|
18 |
#include "town.h" |
|
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
981
diff
changeset
|
19 |
#include "signs.h" |
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
20 |
#include "waypoint.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2125
diff
changeset
|
21 |
#include "variables.h" |
2676
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
2662
diff
changeset
|
22 |
#include "train.h" |
0 | 23 |
|
133
321532e90bc8
(svn r134) -Fix: [976583] parent_list was too small
truelight
parents:
58
diff
changeset
|
24 |
#define VIEWPORT_DRAW_MEM (65536 * 2) |
0 | 25 |
|
26 |
static bool _added_tile_sprite; |
|
27 |
static bool _offset_ground_sprites; |
|
28 |
||
29 |
typedef struct StringSpriteToDraw { |
|
30 |
uint16 string; |
|
31 |
uint16 color; |
|
32 |
struct StringSpriteToDraw *next; |
|
849
c3407041774f
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
33 |
int32 x; |
c3407041774f
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
34 |
int32 y; |
835
f6a341f541d7
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
679
diff
changeset
|
35 |
uint32 params[3]; |
0 | 36 |
uint16 width; |
37 |
} StringSpriteToDraw; |
|
38 |
||
39 |
typedef struct TileSpriteToDraw { |
|
40 |
uint32 image; |
|
41 |
struct TileSpriteToDraw *next; |
|
849
c3407041774f
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
42 |
int32 x; |
c3407041774f
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
43 |
int32 y; |
0 | 44 |
byte z; |
45 |
} TileSpriteToDraw; |
|
46 |
||
47 |
typedef struct ChildScreenSpriteToDraw { |
|
48 |
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
|
49 |
int32 x; |
c3407041774f
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
50 |
int32 y; |
0 | 51 |
struct ChildScreenSpriteToDraw *next; |
52 |
} ChildScreenSpriteToDraw; |
|
53 |
||
54 |
typedef struct ParentSpriteToDraw { |
|
55 |
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
|
56 |
int32 left; |
c3407041774f
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
57 |
int32 top; |
c3407041774f
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
58 |
int32 right; |
c3407041774f
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
59 |
int32 bottom; |
c3407041774f
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
60 |
int32 tile_x; |
c3407041774f
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
61 |
int32 tile_y; |
c3407041774f
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
62 |
int32 tile_right; |
c3407041774f
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
63 |
int32 tile_bottom; |
0 | 64 |
ChildScreenSpriteToDraw *child; |
65 |
byte unk16; |
|
66 |
byte tile_z; |
|
67 |
byte tile_z_bottom; |
|
68 |
} ParentSpriteToDraw; |
|
69 |
||
2109
545d8173eebe
(svn r2619) Fix: [viewport] Fix potential buffer overflow reported by Tron
ludde
parents:
2085
diff
changeset
|
70 |
// Quick hack to know how much memory to reserve when allocating from the spritelist |
545d8173eebe
(svn r2619) Fix: [viewport] Fix potential buffer overflow reported by Tron
ludde
parents:
2085
diff
changeset
|
71 |
// to prevent a buffer overflow. |
545d8173eebe
(svn r2619) Fix: [viewport] Fix potential buffer overflow reported by Tron
ludde
parents:
2085
diff
changeset
|
72 |
#define LARGEST_SPRITELIST_STRUCT ParentSpriteToDraw |
545d8173eebe
(svn r2619) Fix: [viewport] Fix potential buffer overflow reported by Tron
ludde
parents:
2085
diff
changeset
|
73 |
|
0 | 74 |
typedef struct ViewportDrawer { |
75 |
DrawPixelInfo dpi; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
76 |
|
2116 | 77 |
byte *spritelist_mem; |
78 |
const byte *eof_spritelist_mem; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
79 |
|
0 | 80 |
StringSpriteToDraw **last_string, *first_string; |
81 |
TileSpriteToDraw **last_tile, *first_tile; |
|
82 |
||
83 |
ChildScreenSpriteToDraw **last_child; |
|
84 |
||
85 |
ParentSpriteToDraw **parent_list; |
|
2116 | 86 |
ParentSpriteToDraw * const *eof_parent_list; |
0 | 87 |
|
88 |
byte combine_sprites; |
|
89 |
||
90 |
int offs_x, offs_y; // used when drawing ground sprites relative |
|
91 |
bool ground_child; |
|
92 |
} ViewportDrawer; |
|
93 |
||
94 |
static ViewportDrawer *_cur_vd; |
|
95 |
||
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
96 |
TileHighlightData _thd; |
0 | 97 |
static TileInfo *_cur_ti; |
98 |
||
99 |
||
2116 | 100 |
static Point MapXYZToViewport(const ViewPort *vp, uint x, uint y, uint z) |
0 | 101 |
{ |
102 |
Point p = RemapCoords(x, y, z); |
|
2116 | 103 |
p.x -= vp->virtual_width / 2; |
104 |
p.y -= vp->virtual_height / 2; |
|
0 | 105 |
return p; |
106 |
} |
|
107 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
108 |
void AssignWindowViewport(Window *w, int x, int y, |
0 | 109 |
int width, int height, uint32 follow_flags, byte zoom) |
110 |
{ |
|
111 |
ViewPort *vp; |
|
112 |
Point pt; |
|
113 |
uint32 bit; |
|
114 |
||
2116 | 115 |
for (vp = _viewports, bit = 1; ; vp++, bit <<= 1) { |
116 |
assert(vp != endof(_viewports)); |
|
117 |
if (vp->width == 0) break; |
|
0 | 118 |
} |
119 |
_active_viewports |= bit; |
|
120 |
||
121 |
vp->left = x + w->left; |
|
122 |
vp->top = y + w->top; |
|
123 |
vp->width = width; |
|
124 |
vp->height = height; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
125 |
|
0 | 126 |
vp->zoom = zoom; |
127 |
||
128 |
vp->virtual_width = width << zoom; |
|
129 |
vp->virtual_height = height << zoom; |
|
130 |
||
131 |
if (follow_flags & 0x80000000) { |
|
2116 | 132 |
const Vehicle *veh; |
133 |
||
134 |
WP(w, vp_d).follow_vehicle = (VehicleID)(follow_flags & 0xFFFF); |
|
135 |
veh = GetVehicle(WP(w, vp_d).follow_vehicle); |
|
0 | 136 |
pt = MapXYZToViewport(vp, veh->x_pos, veh->y_pos, veh->z_pos); |
137 |
} else { |
|
3421
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
138 |
uint x = TileX(follow_flags) * TILE_SIZE; |
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
139 |
uint y = TileY(follow_flags) * TILE_SIZE; |
2116 | 140 |
|
141 |
WP(w, vp_d).follow_vehicle = INVALID_VEHICLE; |
|
142 |
pt = MapXYZToViewport(vp, x, y, GetSlopeZ(x, y)); |
|
0 | 143 |
} |
144 |
||
2116 | 145 |
WP(w, vp_d).scrollpos_x = pt.x; |
146 |
WP(w, vp_d).scrollpos_y = pt.y; |
|
0 | 147 |
w->viewport = vp; |
148 |
vp->virtual_left = 0;//pt.x; |
|
149 |
vp->virtual_top = 0;//pt.y; |
|
150 |
} |
|
151 |
||
152 |
static Point _vp_move_offs; |
|
153 |
||
154 |
static void DoSetViewportPosition(Window *w, int left, int top, int width, int height) |
|
155 |
{ |
|
156 |
for (; w < _last_window; w++) { |
|
157 |
if (left + width > w->left && |
|
2116 | 158 |
w->left + w->width > left && |
0 | 159 |
top + height > w->top && |
2116 | 160 |
w->top + w->height > top) { |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
161 |
|
0 | 162 |
if (left < w->left) { |
163 |
DoSetViewportPosition(w, left, top, w->left - left, height); |
|
164 |
DoSetViewportPosition(w, left + (w->left - left), top, width - (w->left - left), height); |
|
165 |
return; |
|
166 |
} |
|
167 |
||
168 |
if (left + width > w->left + w->width) { |
|
169 |
DoSetViewportPosition(w, left, top, (w->left + w->width - left), height); |
|
170 |
DoSetViewportPosition(w, left + (w->left + w->width - left), top, width - (w->left + w->width - left) , height); |
|
171 |
return; |
|
172 |
} |
|
173 |
||
174 |
if (top < w->top) { |
|
175 |
DoSetViewportPosition(w, left, top, width, (w->top - top)); |
|
176 |
DoSetViewportPosition(w, left, top + (w->top - top), width, height - (w->top - top)); |
|
177 |
return; |
|
178 |
} |
|
179 |
||
180 |
if (top + height > w->top + w->height) { |
|
181 |
DoSetViewportPosition(w, left, top, width, (w->top + w->height - top)); |
|
182 |
DoSetViewportPosition(w, left, top + (w->top + w->height - top), width , height - (w->top + w->height - top)); |
|
183 |
return; |
|
184 |
} |
|
185 |
||
186 |
return; |
|
187 |
} |
|
188 |
} |
|
189 |
||
190 |
{ |
|
191 |
int xo = _vp_move_offs.x; |
|
192 |
int yo = _vp_move_offs.y; |
|
193 |
||
194 |
if (abs(xo) >= width || abs(yo) >= height) { |
|
195 |
/* fully_outside */ |
|
2116 | 196 |
RedrawScreenRect(left, top, left + width, top + height); |
0 | 197 |
return; |
198 |
} |
|
199 |
||
200 |
GfxScroll(left, top, width, height, xo, yo); |
|
201 |
||
202 |
if (xo > 0) { |
|
203 |
RedrawScreenRect(left, top, xo + left, top + height); |
|
204 |
left += xo; |
|
205 |
width -= xo; |
|
206 |
} else if (xo < 0) { |
|
207 |
RedrawScreenRect(left+width+xo, top, left+width, top + height); |
|
208 |
width += xo; |
|
209 |
} |
|
210 |
||
211 |
if (yo > 0) { |
|
212 |
RedrawScreenRect(left, top, width+left, top + yo); |
|
213 |
} else if (yo < 0) { |
|
214 |
RedrawScreenRect(left, top + height + yo, width+left, top + height); |
|
215 |
} |
|
216 |
} |
|
217 |
} |
|
218 |
||
2817 | 219 |
static void SetViewportPosition(Window* w, int x, int y) |
0 | 220 |
{ |
221 |
ViewPort *vp = w->viewport; |
|
222 |
int old_left = vp->virtual_left; |
|
223 |
int old_top = vp->virtual_top; |
|
224 |
int i; |
|
225 |
int left, top, width, height; |
|
226 |
||
227 |
vp->virtual_left = x; |
|
228 |
vp->virtual_top = y; |
|
229 |
||
230 |
old_left >>= vp->zoom; |
|
231 |
old_top >>= vp->zoom; |
|
232 |
x >>= vp->zoom; |
|
233 |
y >>= vp->zoom; |
|
234 |
||
235 |
old_left -= x; |
|
236 |
old_top -= y; |
|
237 |
||
2116 | 238 |
if (old_top == 0 && old_left == 0) return; |
0 | 239 |
|
240 |
_vp_move_offs.x = old_left; |
|
241 |
_vp_move_offs.y = old_top; |
|
242 |
||
243 |
left = vp->left; |
|
244 |
top = vp->top; |
|
245 |
width = vp->width; |
|
246 |
height = vp->height; |
|
247 |
||
248 |
if (left < 0) { |
|
249 |
width += left; |
|
250 |
left = 0; |
|
251 |
} |
|
252 |
||
2116 | 253 |
i = left + width - _screen.width; |
254 |
if (i >= 0) width -= i; |
|
0 | 255 |
|
256 |
if (width > 0) { |
|
257 |
if (top < 0) { |
|
258 |
height += top; |
|
259 |
top = 0; |
|
260 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
261 |
|
2116 | 262 |
i = top + height - _screen.height; |
263 |
if (i >= 0) height -= i; |
|
0 | 264 |
|
2116 | 265 |
if (height > 0) DoSetViewportPosition(w + 1, left, top, width, height); |
0 | 266 |
} |
267 |
} |
|
268 |
||
269 |
||
2116 | 270 |
ViewPort *IsPtInWindowViewport(const Window *w, int x, int y) |
0 | 271 |
{ |
272 |
ViewPort *vp = w->viewport; |
|
2116 | 273 |
|
0 | 274 |
if (vp != NULL && |
275 |
IS_INT_INSIDE(x, vp->left, vp->left + vp->width) && |
|
276 |
IS_INT_INSIDE(y, vp->top, vp->top + vp->height)) |
|
277 |
return vp; |
|
278 |
||
279 |
return NULL; |
|
280 |
} |
|
281 |
||
2116 | 282 |
static Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y) |
1095 | 283 |
{ |
0 | 284 |
int z; |
285 |
Point pt; |
|
286 |
int a,b; |
|
287 |
||
288 |
if ( (uint)(x -= vp->left) >= (uint)vp->width || |
|
289 |
(uint)(y -= vp->top) >= (uint)vp->height) { |
|
290 |
Point pt = {-1, -1}; |
|
291 |
return pt; |
|
292 |
} |
|
293 |
||
294 |
x = ((x << vp->zoom) + vp->virtual_left) >> 2; |
|
295 |
y = ((y << vp->zoom) + vp->virtual_top) >> 1; |
|
296 |
||
297 |
#if !defined(NEW_ROTATION) |
|
298 |
a = y-x; |
|
299 |
b = y+x; |
|
300 |
#else |
|
301 |
a = x+y; |
|
302 |
b = x-y; |
|
303 |
#endif |
|
304 |
z = GetSlopeZ(a, b) >> 1; |
|
305 |
z = GetSlopeZ(a+z, b+z) >> 1; |
|
306 |
z = GetSlopeZ(a+z, b+z) >> 1; |
|
307 |
z = GetSlopeZ(a+z, b+z) >> 1; |
|
308 |
z = GetSlopeZ(a+z, b+z) >> 1; |
|
309 |
||
310 |
pt.x = a+z; |
|
311 |
pt.y = b+z; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
312 |
|
3421
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
313 |
if ((uint)pt.x >= MapMaxX() * TILE_SIZE || (uint)pt.y >= MapMaxY() * TILE_SIZE) { |
0 | 314 |
pt.x = pt.y = -1; |
315 |
} |
|
316 |
||
317 |
return pt; |
|
318 |
} |
|
319 |
||
981
f74abee65b7b
(svn r1477) -Fix: finally zooming in/out always works. The problem was that the zoomed in/out coordinates were used for checking if the area was a zoomable viewport in the not zoomed in/out position. The chances were high that there was a window.
darkvater
parents:
979
diff
changeset
|
320 |
/* When used for zooming, check area below current coordinates (x,y) |
f74abee65b7b
(svn r1477) -Fix: finally zooming in/out always works. The problem was that the zoomed in/out coordinates were used for checking if the area was a zoomable viewport in the not zoomed in/out position. The chances were high that there was a window.
darkvater
parents:
979
diff
changeset
|
321 |
* and return the tile of the zoomed out/in position (zoom_x, zoom_y) |
f74abee65b7b
(svn r1477) -Fix: finally zooming in/out always works. The problem was that the zoomed in/out coordinates were used for checking if the area was a zoomable viewport in the not zoomed in/out position. The chances were high that there was a window.
darkvater
parents:
979
diff
changeset
|
322 |
* when you just want the tile, make x = zoom_x and y = zoom_y */ |
f74abee65b7b
(svn r1477) -Fix: finally zooming in/out always works. The problem was that the zoomed in/out coordinates were used for checking if the area was a zoomable viewport in the not zoomed in/out position. The chances were high that there was a window.
darkvater
parents:
979
diff
changeset
|
323 |
static Point GetTileFromScreenXY(int x, int y, int zoom_x, int zoom_y) |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
324 |
{ |
0 | 325 |
Window *w; |
326 |
ViewPort *vp; |
|
327 |
Point pt; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
328 |
|
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
329 |
if ( (w = FindWindowFromPt(x, y)) != NULL && |
0 | 330 |
(vp = IsPtInWindowViewport(w, x, y)) != NULL) |
981
f74abee65b7b
(svn r1477) -Fix: finally zooming in/out always works. The problem was that the zoomed in/out coordinates were used for checking if the area was a zoomable viewport in the not zoomed in/out position. The chances were high that there was a window.
darkvater
parents:
979
diff
changeset
|
331 |
return TranslateXYToTileCoord(vp, zoom_x, zoom_y); |
0 | 332 |
|
333 |
pt.y = pt.x = -1; |
|
334 |
return pt; |
|
335 |
} |
|
336 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1083
diff
changeset
|
337 |
Point GetTileBelowCursor(void) |
0 | 338 |
{ |
981
f74abee65b7b
(svn r1477) -Fix: finally zooming in/out always works. The problem was that the zoomed in/out coordinates were used for checking if the area was a zoomable viewport in the not zoomed in/out position. The chances were high that there was a window.
darkvater
parents:
979
diff
changeset
|
339 |
return GetTileFromScreenXY(_cursor.pos.x, _cursor.pos.y, _cursor.pos.x, _cursor.pos.y); |
0 | 340 |
} |
341 |
||
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:
137
diff
changeset
|
342 |
|
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:
137
diff
changeset
|
343 |
Point GetTileZoomCenterWindow(bool in, Window * w) |
0 | 344 |
{ |
345 |
int x, y; |
|
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:
137
diff
changeset
|
346 |
ViewPort * vp; |
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:
137
diff
changeset
|
347 |
|
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:
137
diff
changeset
|
348 |
vp = w->viewport; |
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:
137
diff
changeset
|
349 |
|
2026 | 350 |
if (in) { |
2116 | 351 |
x = ((_cursor.pos.x - vp->left) >> 1) + (vp->width >> 2); |
352 |
y = ((_cursor.pos.y - vp->top) >> 1) + (vp->height >> 2); |
|
353 |
} else { |
|
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:
137
diff
changeset
|
354 |
x = vp->width - (_cursor.pos.x - vp->left); |
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:
137
diff
changeset
|
355 |
y = vp->height - (_cursor.pos.y - vp->top); |
0 | 356 |
} |
981
f74abee65b7b
(svn r1477) -Fix: finally zooming in/out always works. The problem was that the zoomed in/out coordinates were used for checking if the area was a zoomable viewport in the not zoomed in/out position. The chances were high that there was a window.
darkvater
parents:
979
diff
changeset
|
357 |
/* Get the tile below the cursor and center on the zoomed-out center */ |
f74abee65b7b
(svn r1477) -Fix: finally zooming in/out always works. The problem was that the zoomed in/out coordinates were used for checking if the area was a zoomable viewport in the not zoomed in/out position. The chances were high that there was a window.
darkvater
parents:
979
diff
changeset
|
358 |
return GetTileFromScreenXY(_cursor.pos.x, _cursor.pos.y, x + vp->left, y + vp->top); |
0 | 359 |
} |
360 |
||
849
c3407041774f
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
361 |
void DrawGroundSpriteAt(uint32 image, int32 x, int32 y, byte z) |
0 | 362 |
{ |
363 |
ViewportDrawer *vd = _cur_vd; |
|
364 |
TileSpriteToDraw *ts; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
365 |
|
2187
a0e206ce9fbf
(svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar
parents:
2186
diff
changeset
|
366 |
assert((image & SPRITE_MASK) < MAX_SPRITES); |
0 | 367 |
|
2116 | 368 |
if (vd->spritelist_mem >= vd->eof_spritelist_mem) { |
2013
c83b52340eee
(svn r2521) -Codechange: Removed trailing "\n"s from DEBUG statements
celestar
parents:
1990
diff
changeset
|
369 |
DEBUG(misc, 0) ("Out of sprite mem"); |
0 | 370 |
return; |
371 |
} |
|
2116 | 372 |
ts = (TileSpriteToDraw*)vd->spritelist_mem; |
0 | 373 |
|
374 |
vd->spritelist_mem += sizeof(TileSpriteToDraw); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
375 |
|
0 | 376 |
ts->image = image; |
377 |
ts->next = NULL; |
|
378 |
ts->x = x; |
|
379 |
ts->y = y; |
|
380 |
ts->z = z; |
|
381 |
*vd->last_tile = ts; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
382 |
vd->last_tile = &ts->next; |
0 | 383 |
} |
384 |
||
385 |
void DrawGroundSprite(uint32 image) |
|
386 |
{ |
|
387 |
if (_offset_ground_sprites) { |
|
388 |
// offset ground sprite because of foundation? |
|
389 |
AddChildSpriteScreen(image, _cur_vd->offs_x, _cur_vd->offs_y); |
|
390 |
} else { |
|
1083
8e64dc3ed29f
(svn r1584) Fix: Highlighlighting tiles under bridges works again correctly for square selection tools.
dominik
parents:
1070
diff
changeset
|
391 |
_added_tile_sprite = true; |
0 | 392 |
DrawGroundSpriteAt(image, _cur_ti->x, _cur_ti->y, _cur_ti->z); |
393 |
} |
|
394 |
} |
|
395 |
||
396 |
||
397 |
void OffsetGroundSprite(int x, int y) |
|
398 |
{ |
|
399 |
_cur_vd->offs_x = x; |
|
400 |
_cur_vd->offs_y = y; |
|
401 |
_offset_ground_sprites = true; |
|
402 |
} |
|
403 |
||
404 |
static void AddCombinedSprite(uint32 image, int x, int y, byte z) |
|
405 |
{ |
|
2116 | 406 |
const ViewportDrawer *vd = _cur_vd; |
0 | 407 |
Point pt = RemapCoords(x, y, z); |
2319
fba7d61df04a
(svn r2845) Remove sprite size caching, it was unused
tron
parents:
2187
diff
changeset
|
408 |
const Sprite* spr = GetSprite(image & SPRITE_MASK); |
0 | 409 |
|
2319
fba7d61df04a
(svn r2845) Remove sprite size caching, it was unused
tron
parents:
2187
diff
changeset
|
410 |
if (pt.x + spr->x_offs >= vd->dpi.left + vd->dpi.width || |
fba7d61df04a
(svn r2845) Remove sprite size caching, it was unused
tron
parents:
2187
diff
changeset
|
411 |
pt.x + spr->x_offs + spr->width <= vd->dpi.left || |
fba7d61df04a
(svn r2845) Remove sprite size caching, it was unused
tron
parents:
2187
diff
changeset
|
412 |
pt.y + spr->y_offs >= vd->dpi.top + vd->dpi.height || |
fba7d61df04a
(svn r2845) Remove sprite size caching, it was unused
tron
parents:
2187
diff
changeset
|
413 |
pt.y + spr->y_offs + spr->height <= vd->dpi.top) |
0 | 414 |
return; |
415 |
||
2116 | 416 |
AddChildSpriteScreen(image, pt.x - vd->parent_list[-1]->left, pt.y - vd->parent_list[-1]->top); |
0 | 417 |
} |
418 |
||
419 |
||
420 |
void AddSortableSpriteToDraw(uint32 image, int x, int y, int w, int h, byte dz, byte z) |
|
421 |
{ |
|
422 |
ViewportDrawer *vd = _cur_vd; |
|
423 |
ParentSpriteToDraw *ps; |
|
2319
fba7d61df04a
(svn r2845) Remove sprite size caching, it was unused
tron
parents:
2187
diff
changeset
|
424 |
const Sprite* spr; |
0 | 425 |
Point pt; |
426 |
||
2187
a0e206ce9fbf
(svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar
parents:
2186
diff
changeset
|
427 |
assert((image & SPRITE_MASK) < MAX_SPRITES); |
0 | 428 |
|
429 |
if (vd->combine_sprites == 2) { |
|
430 |
AddCombinedSprite(image, x, y, z); |
|
431 |
return; |
|
432 |
} |
|
433 |
||
434 |
vd->last_child = NULL; |
|
435 |
||
2116 | 436 |
if (vd->spritelist_mem >= vd->eof_spritelist_mem) { |
2013
c83b52340eee
(svn r2521) -Codechange: Removed trailing "\n"s from DEBUG statements
celestar
parents:
1990
diff
changeset
|
437 |
DEBUG(misc, 0) ("Out of sprite mem"); |
0 | 438 |
return; |
439 |
} |
|
2116 | 440 |
ps = (ParentSpriteToDraw*)vd->spritelist_mem; |
441 |
||
133
321532e90bc8
(svn r134) -Fix: [976583] parent_list was too small
truelight
parents:
58
diff
changeset
|
442 |
if (vd->parent_list >= vd->eof_parent_list) { |
321532e90bc8
(svn r134) -Fix: [976583] parent_list was too small
truelight
parents:
58
diff
changeset
|
443 |
// This can happen rarely, mostly when you zoom out completely |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
444 |
// and have a lot of stuff that moves (and is added to the |
133
321532e90bc8
(svn r134) -Fix: [976583] parent_list was too small
truelight
parents:
58
diff
changeset
|
445 |
// sort-list, this function). To solve it, increase |
321532e90bc8
(svn r134) -Fix: [976583] parent_list was too small
truelight
parents:
58
diff
changeset
|
446 |
// parent_list somewhere below to a higher number. |
321532e90bc8
(svn r134) -Fix: [976583] parent_list was too small
truelight
parents:
58
diff
changeset
|
447 |
// This can not really hurt you, it just gives some black |
321532e90bc8
(svn r134) -Fix: [976583] parent_list was too small
truelight
parents:
58
diff
changeset
|
448 |
// spots on the screen ;) |
2013
c83b52340eee
(svn r2521) -Codechange: Removed trailing "\n"s from DEBUG statements
celestar
parents:
1990
diff
changeset
|
449 |
DEBUG(misc, 0) ("Out of sprite mem (parent_list)"); |
133
321532e90bc8
(svn r134) -Fix: [976583] parent_list was too small
truelight
parents:
58
diff
changeset
|
450 |
return; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
451 |
} |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
452 |
|
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
453 |
vd->spritelist_mem += sizeof(ParentSpriteToDraw); |
0 | 454 |
|
455 |
ps->image = image; |
|
456 |
ps->tile_x = x; |
|
457 |
ps->tile_right = x + w - 1; |
|
458 |
||
459 |
ps->tile_y = y; |
|
460 |
ps->tile_bottom = y + h - 1; |
|
461 |
||
462 |
ps->tile_z = z; |
|
463 |
ps->tile_z_bottom = z + dz - 1; |
|
464 |
||
465 |
pt = RemapCoords(x, y, z); |
|
466 |
||
2319
fba7d61df04a
(svn r2845) Remove sprite size caching, it was unused
tron
parents:
2187
diff
changeset
|
467 |
spr = GetSprite(image & SPRITE_MASK); |
fba7d61df04a
(svn r2845) Remove sprite size caching, it was unused
tron
parents:
2187
diff
changeset
|
468 |
if ((ps->left = (pt.x += spr->x_offs)) >= vd->dpi.left + vd->dpi.width || |
fba7d61df04a
(svn r2845) Remove sprite size caching, it was unused
tron
parents:
2187
diff
changeset
|
469 |
(ps->right = (pt.x + spr->width )) <= vd->dpi.left || |
fba7d61df04a
(svn r2845) Remove sprite size caching, it was unused
tron
parents:
2187
diff
changeset
|
470 |
(ps->top = (pt.y += spr->y_offs)) >= vd->dpi.top + vd->dpi.height || |
fba7d61df04a
(svn r2845) Remove sprite size caching, it was unused
tron
parents:
2187
diff
changeset
|
471 |
(ps->bottom = (pt.y + spr->height)) <= vd->dpi.top) { |
0 | 472 |
return; |
473 |
} |
|
474 |
||
475 |
ps->unk16 = 0; |
|
476 |
ps->child = NULL; |
|
477 |
vd->last_child = &ps->child; |
|
478 |
||
479 |
*vd->parent_list++ = ps; |
|
480 |
||
2116 | 481 |
if (vd->combine_sprites == 1) vd->combine_sprites = 2; |
0 | 482 |
} |
483 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1083
diff
changeset
|
484 |
void StartSpriteCombine(void) |
0 | 485 |
{ |
486 |
_cur_vd->combine_sprites = 1; |
|
487 |
} |
|
488 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1083
diff
changeset
|
489 |
void EndSpriteCombine(void) |
0 | 490 |
{ |
491 |
_cur_vd->combine_sprites = 0; |
|
492 |
} |
|
493 |
||
494 |
void AddChildSpriteScreen(uint32 image, int x, int y) |
|
495 |
{ |
|
496 |
ViewportDrawer *vd = _cur_vd; |
|
497 |
ChildScreenSpriteToDraw *cs; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
498 |
|
2187
a0e206ce9fbf
(svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar
parents:
2186
diff
changeset
|
499 |
assert((image & SPRITE_MASK) < MAX_SPRITES); |
0 | 500 |
|
2116 | 501 |
if (vd->spritelist_mem >= vd->eof_spritelist_mem) { |
2013
c83b52340eee
(svn r2521) -Codechange: Removed trailing "\n"s from DEBUG statements
celestar
parents:
1990
diff
changeset
|
502 |
DEBUG(misc, 0) ("Out of sprite mem"); |
0 | 503 |
return; |
504 |
} |
|
2116 | 505 |
cs = (ChildScreenSpriteToDraw*)vd->spritelist_mem; |
0 | 506 |
|
2116 | 507 |
if (vd->last_child == NULL) return; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
508 |
|
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
509 |
vd->spritelist_mem += sizeof(ChildScreenSpriteToDraw); |
0 | 510 |
|
511 |
*vd->last_child = cs; |
|
512 |
vd->last_child = &cs->next; |
|
513 |
||
514 |
cs->image = image; |
|
515 |
cs->x = x; |
|
516 |
cs->y = y; |
|
517 |
cs->next = NULL; |
|
518 |
} |
|
519 |
||
520 |
/* Returns a StringSpriteToDraw */ |
|
835
f6a341f541d7
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
679
diff
changeset
|
521 |
void *AddStringToDraw(int x, int y, StringID string, uint32 params_1, uint32 params_2, uint32 params_3) |
0 | 522 |
{ |
523 |
ViewportDrawer *vd = _cur_vd; |
|
524 |
StringSpriteToDraw *ss; |
|
525 |
||
2116 | 526 |
if (vd->spritelist_mem >= vd->eof_spritelist_mem) { |
2013
c83b52340eee
(svn r2521) -Codechange: Removed trailing "\n"s from DEBUG statements
celestar
parents:
1990
diff
changeset
|
527 |
DEBUG(misc, 0) ("Out of sprite mem"); |
0 | 528 |
return NULL; |
529 |
} |
|
2116 | 530 |
ss = (StringSpriteToDraw*)vd->spritelist_mem; |
0 | 531 |
|
532 |
vd->spritelist_mem += sizeof(StringSpriteToDraw); |
|
533 |
||
534 |
ss->string = string; |
|
535 |
ss->next = NULL; |
|
536 |
ss->x = x; |
|
537 |
ss->y = y; |
|
538 |
ss->params[0] = params_1; |
|
539 |
ss->params[1] = params_2; |
|
835
f6a341f541d7
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
679
diff
changeset
|
540 |
ss->params[2] = params_3; |
0 | 541 |
ss->width = 0; |
542 |
||
543 |
*vd->last_string = ss; |
|
544 |
vd->last_string = &ss->next; |
|
545 |
||
546 |
return ss; |
|
547 |
} |
|
548 |
||
549 |
static void DrawSelectionSprite(uint32 image, const TileInfo *ti) |
|
550 |
{ |
|
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
551 |
if (_added_tile_sprite && !(_thd.drawstyle & HT_LINE)) { // draw on real ground |
1083
8e64dc3ed29f
(svn r1584) Fix: Highlighlighting tiles under bridges works again correctly for square selection tools.
dominik
parents:
1070
diff
changeset
|
552 |
DrawGroundSpriteAt(image, ti->x, ti->y, ti->z + 7); |
8e64dc3ed29f
(svn r1584) Fix: Highlighlighting tiles under bridges works again correctly for square selection tools.
dominik
parents:
1070
diff
changeset
|
553 |
} else { // draw on top of foundation |
8e64dc3ed29f
(svn r1584) Fix: Highlighlighting tiles under bridges works again correctly for square selection tools.
dominik
parents:
1070
diff
changeset
|
554 |
AddSortableSpriteToDraw(image, ti->x, ti->y, 0x10, 0x10, 1, ti->z + 7); |
8e64dc3ed29f
(svn r1584) Fix: Highlighlighting tiles under bridges works again correctly for square selection tools.
dominik
parents:
1070
diff
changeset
|
555 |
} |
0 | 556 |
} |
557 |
||
558 |
static bool IsPartOfAutoLine(int px, int py) |
|
559 |
{ |
|
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
560 |
px -= _thd.selstart.x; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
561 |
py -= _thd.selstart.y; |
0 | 562 |
|
2952 | 563 |
switch (_thd.drawstyle) { |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
564 |
case HT_LINE | HT_DIR_X: return py == 0; // x direction |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
565 |
case HT_LINE | HT_DIR_Y: return px == 0; // y direction |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
566 |
case HT_LINE | HT_DIR_HU: return px == -py || px == -py - 16; // horizontal upper |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
567 |
case HT_LINE | HT_DIR_HL: return px == -py || px == -py + 16; // horizontal lower |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
568 |
case HT_LINE | HT_DIR_VL: return px == py || px == py + 16; // vertival left |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
569 |
case HT_LINE | HT_DIR_VR: return px == py || px == py - 16; // vertical right |
0 | 570 |
default: |
571 |
NOT_REACHED(); |
|
572 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
573 |
|
0 | 574 |
/* useless, but avoids compiler warning this way */ |
575 |
return 0; |
|
576 |
} |
|
577 |
||
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
578 |
// [direction][side] |
2710
44278abd3ef9
(svn r3254) - Fix: graphical glitch with autorail tool on a certain tile-type.
Darkvater
parents:
2676
diff
changeset
|
579 |
static const int _AutorailType[6][2] = { |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
580 |
{ HT_DIR_X, HT_DIR_X }, |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
581 |
{ HT_DIR_Y, HT_DIR_Y }, |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
582 |
{ HT_DIR_HU, HT_DIR_HL }, |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
583 |
{ HT_DIR_HL, HT_DIR_HU }, |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
584 |
{ HT_DIR_VL, HT_DIR_VR }, |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
585 |
{ HT_DIR_VR, HT_DIR_VL } |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
586 |
}; |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
587 |
|
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
588 |
#include "table/autorail.h" |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
589 |
|
0 | 590 |
static void DrawTileSelection(const TileInfo *ti) |
591 |
{ |
|
592 |
uint32 image; |
|
593 |
||
594 |
// Draw a red error square? |
|
3281
757d7da49445
(svn r3995) -Fix: Committed one file too much in 3992 (Thanks to Tron for pointing it out)
celestar
parents:
3279
diff
changeset
|
595 |
if (_thd.redsq != 0 && _thd.redsq == ti->tile) { |
1864
80e13d54b061
(svn r2370) Replace some magic numbers with symbolic names
tron
parents:
1863
diff
changeset
|
596 |
DrawSelectionSprite(PALETTE_TILE_RED_PULSATING | (SPR_SELECT_TILE + _tileh_to_sprite[ti->tileh]), ti); |
0 | 597 |
return; |
598 |
} |
|
599 |
||
600 |
// no selection active? |
|
2116 | 601 |
if (_thd.drawstyle == 0) return; |
0 | 602 |
|
603 |
// Inside the inner area? |
|
2116 | 604 |
if (IS_INSIDE_1D(ti->x, _thd.pos.x, _thd.size.x) && |
605 |
IS_INSIDE_1D(ti->y, _thd.pos.y, _thd.size.y)) { |
|
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
606 |
if (_thd.drawstyle & HT_RECT) { |
1864
80e13d54b061
(svn r2370) Replace some magic numbers with symbolic names
tron
parents:
1863
diff
changeset
|
607 |
image = SPR_SELECT_TILE + _tileh_to_sprite[ti->tileh]; |
80e13d54b061
(svn r2370) Replace some magic numbers with symbolic names
tron
parents:
1863
diff
changeset
|
608 |
if (_thd.make_square_red) image |= PALETTE_SEL_TILE_RED; |
0 | 609 |
DrawSelectionSprite(image, ti); |
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
610 |
} else if (_thd.drawstyle & HT_POINT) { |
0 | 611 |
// Figure out the Z coordinate for the single dot. |
612 |
byte z = ti->z; |
|
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3609
diff
changeset
|
613 |
if (ti->tileh & SLOPE_N) { |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
614 |
z += 8; |
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3609
diff
changeset
|
615 |
if (ti->tileh == SLOPE_STEEP_N) z += 8; |
0 | 616 |
} |
1864
80e13d54b061
(svn r2370) Replace some magic numbers with symbolic names
tron
parents:
1863
diff
changeset
|
617 |
DrawGroundSpriteAt(_cur_dpi->zoom != 2 ? SPR_DOT : SPR_DOT_SMALL, ti->x, ti->y, z); |
2116 | 618 |
} else if (_thd.drawstyle & HT_RAIL /*&& _thd.place_mode == VHM_RAIL*/) { |
619 |
// autorail highlight piece under cursor |
|
620 |
uint type = _thd.drawstyle & 0xF; |
|
621 |
assert(type <= 5); |
|
2710
44278abd3ef9
(svn r3254) - Fix: graphical glitch with autorail tool on a certain tile-type.
Darkvater
parents:
2676
diff
changeset
|
622 |
image = SPR_AUTORAIL_BASE + _AutorailTilehSprite[ti->tileh][_AutorailType[type][0]]; |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
623 |
|
1864
80e13d54b061
(svn r2370) Replace some magic numbers with symbolic names
tron
parents:
1863
diff
changeset
|
624 |
if (_thd.make_square_red) image |= PALETTE_SEL_TILE_RED; |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
625 |
DrawSelectionSprite(image, ti); |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
626 |
|
2116 | 627 |
} else if (IsPartOfAutoLine(ti->x, ti->y)) { |
628 |
// autorail highlighting long line |
|
629 |
int dir = _thd.drawstyle & ~0xF0; |
|
630 |
uint side; |
|
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
631 |
|
2116 | 632 |
if (dir < 2) { |
633 |
side = 0; |
|
634 |
} else { |
|
635 |
TileIndex start = TileVirtXY(_thd.selstart.x, _thd.selstart.y); |
|
636 |
int diffx = myabs(TileX(start) - TileX(ti->tile)); |
|
637 |
int diffy = myabs(TileY(start) - TileY(ti->tile)); |
|
638 |
side = myabs(diffx - diffy); |
|
639 |
} |
|
1109
ecb98f43ba2c
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1095
diff
changeset
|
640 |
|
2710
44278abd3ef9
(svn r3254) - Fix: graphical glitch with autorail tool on a certain tile-type.
Darkvater
parents:
2676
diff
changeset
|
641 |
image = SPR_AUTORAIL_BASE + _AutorailTilehSprite[ti->tileh][_AutorailType[dir][side]]; |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
642 |
|
2116 | 643 |
if (_thd.make_square_red) image |= PALETTE_SEL_TILE_RED; |
644 |
DrawSelectionSprite(image, ti); |
|
645 |
} |
|
0 | 646 |
return; |
647 |
} |
|
648 |
||
649 |
// Check if it's inside the outer area? |
|
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
650 |
if (_thd.outersize.x && |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
651 |
_thd.size.x < _thd.size.x + _thd.outersize.x && |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
652 |
IS_INSIDE_1D(ti->x, _thd.pos.x + _thd.offs.x, _thd.size.x + _thd.outersize.x) && |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
653 |
IS_INSIDE_1D(ti->y, _thd.pos.y + _thd.offs.y, _thd.size.y + _thd.outersize.y)) { |
0 | 654 |
// Draw a blue rect. |
1864
80e13d54b061
(svn r2370) Replace some magic numbers with symbolic names
tron
parents:
1863
diff
changeset
|
655 |
DrawSelectionSprite(PALETTE_SEL_TILE_BLUE | (SPR_SELECT_TILE + _tileh_to_sprite[ti->tileh]), ti); |
0 | 656 |
return; |
657 |
} |
|
658 |
} |
|
659 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1083
diff
changeset
|
660 |
static void ViewportAddLandscape(void) |
0 | 661 |
{ |
662 |
ViewportDrawer *vd = _cur_vd; |
|
663 |
int x, y, width, height; |
|
664 |
TileInfo ti; |
|
665 |
bool direction; |
|
666 |
||
667 |
_cur_ti = &ti; |
|
668 |
||
669 |
// Transform into tile coordinates and round to closest full tile |
|
670 |
#if !defined(NEW_ROTATION) |
|
671 |
x = ((vd->dpi.top >> 1) - (vd->dpi.left >> 2)) & ~0xF; |
|
672 |
y = ((vd->dpi.top >> 1) + (vd->dpi.left >> 2) - 0x10) & ~0xF; |
|
673 |
#else |
|
674 |
x = ((vd->dpi.top >> 1) + (vd->dpi.left >> 2) - 0x10) & ~0xF; |
|
675 |
y = ((vd->dpi.left >> 2) - (vd->dpi.top >> 1)) & ~0xF; |
|
676 |
#endif |
|
677 |
// determine size of area |
|
678 |
{ |
|
679 |
Point pt = RemapCoords(x, y, 241); |
|
680 |
width = (vd->dpi.left + vd->dpi.width - pt.x + 95) >> 6; |
|
681 |
height = (vd->dpi.top + vd->dpi.height - pt.y) >> 5 << 1; |
|
682 |
} |
|
683 |
||
684 |
assert(width > 0); |
|
685 |
assert(height > 0); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
686 |
|
0 | 687 |
direction = false; |
688 |
||
689 |
do { |
|
690 |
int width_cur = width; |
|
691 |
int x_cur = x; |
|
692 |
int y_cur = y; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
693 |
|
0 | 694 |
do { |
695 |
FindLandscapeHeight(&ti, x_cur, y_cur); |
|
696 |
#if !defined(NEW_ROTATION) |
|
697 |
y_cur += 0x10; |
|
698 |
x_cur -= 0x10; |
|
699 |
#else |
|
700 |
y_cur += 0x10; |
|
701 |
x_cur += 0x10; |
|
702 |
#endif |
|
703 |
_added_tile_sprite = false; |
|
704 |
_offset_ground_sprites = false; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
705 |
|
0 | 706 |
DrawTile(&ti); |
707 |
DrawTileSelection(&ti); |
|
708 |
} while (--width_cur); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
709 |
|
0 | 710 |
#if !defined(NEW_ROTATION) |
711 |
if ( (direction^=1) != 0) |
|
712 |
y += 0x10; |
|
713 |
else |
|
714 |
x += 0x10; |
|
715 |
#else |
|
716 |
if ( (direction^=1) != 0) |
|
717 |
x += 0x10; |
|
718 |
else |
|
719 |
y -= 0x10; |
|
720 |
#endif |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
721 |
} while (--height); |
0 | 722 |
} |
723 |
||
724 |
||
410 | 725 |
static void ViewportAddTownNames(DrawPixelInfo *dpi) |
0 | 726 |
{ |
727 |
Town *t; |
|
728 |
int left, top, right, bottom; |
|
729 |
||
730 |
if (!(_display_opt & DO_SHOW_TOWN_NAMES) || _game_mode == GM_MENU) |
|
731 |
return; |
|
732 |
||
733 |
left = dpi->left; |
|
734 |
top = dpi->top; |
|
735 |
right = left + dpi->width; |
|
736 |
bottom = top + dpi->height; |
|
737 |
||
738 |
if (dpi->zoom < 1) { |
|
739 |
FOR_ALL_TOWNS(t) { |
|
740 |
if (t->xy && |
|
741 |
bottom > t->sign.top && |
|
742 |
top < t->sign.top + 12 && |
|
743 |
right > t->sign.left && |
|
744 |
left < t->sign.left + t->sign.width_1) { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
745 |
|
2070
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2026
diff
changeset
|
746 |
AddStringToDraw(t->sign.left + 1, t->sign.top + 1, |
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2026
diff
changeset
|
747 |
_patches.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL, |
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2026
diff
changeset
|
748 |
t->index, t->population, 0); |
0 | 749 |
} |
750 |
} |
|
751 |
} else if (dpi->zoom == 1) { |
|
752 |
right += 2; |
|
753 |
bottom += 2; |
|
754 |
||
755 |
FOR_ALL_TOWNS(t) { |
|
756 |
if (t->xy && |
|
757 |
bottom > t->sign.top && |
|
758 |
top < t->sign.top + 24 && |
|
759 |
right > t->sign.left && |
|
760 |
left < t->sign.left + t->sign.width_1*2) { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
761 |
|
2070
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2026
diff
changeset
|
762 |
AddStringToDraw(t->sign.left + 1, t->sign.top + 1, |
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2026
diff
changeset
|
763 |
_patches.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL, |
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2026
diff
changeset
|
764 |
t->index, t->population, 0); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
765 |
} |
0 | 766 |
} |
767 |
} else { |
|
768 |
right += 4; |
|
769 |
bottom += 5; |
|
770 |
||
771 |
assert(dpi->zoom == 2); |
|
772 |
FOR_ALL_TOWNS(t) { |
|
773 |
if (t->xy && |
|
774 |
bottom > t->sign.top && |
|
775 |
top < t->sign.top + 24 && |
|
776 |
right > t->sign.left && |
|
777 |
left < t->sign.left + t->sign.width_2*4) { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
778 |
|
2070
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2026
diff
changeset
|
779 |
AddStringToDraw(t->sign.left + 5, t->sign.top + 1, STR_TOWN_LABEL_TINY_BLACK, t->index, 0, 0); |
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2026
diff
changeset
|
780 |
AddStringToDraw(t->sign.left + 1, t->sign.top - 3, STR_TOWN_LABEL_TINY_WHITE, t->index, 0, 0); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
781 |
} |
0 | 782 |
} |
783 |
} |
|
784 |
} |
|
785 |
||
410 | 786 |
static void ViewportAddStationNames(DrawPixelInfo *dpi) |
0 | 787 |
{ |
788 |
int left, top, right, bottom; |
|
789 |
Station *st; |
|
790 |
StringSpriteToDraw *sstd; |
|
791 |
||
792 |
if (!(_display_opt & DO_SHOW_STATION_NAMES) || _game_mode == GM_MENU) |
|
793 |
return; |
|
794 |
||
795 |
left = dpi->left; |
|
796 |
top = dpi->top; |
|
797 |
right = left + dpi->width; |
|
798 |
bottom = top + dpi->height; |
|
799 |
||
800 |
if (dpi->zoom < 1) { |
|
801 |
FOR_ALL_STATIONS(st) { |
|
802 |
if (st->xy && |
|
803 |
bottom > st->sign.top && |
|
804 |
top < st->sign.top + 12 && |
|
805 |
right > st->sign.left && |
|
806 |
left < st->sign.left + st->sign.width_1) { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
807 |
|
835
f6a341f541d7
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
679
diff
changeset
|
808 |
sstd=AddStringToDraw(st->sign.left + 1, st->sign.top + 1, STR_305C_0, st->index, st->facilities, 0); |
0 | 809 |
if (sstd != NULL) { |
810 |
sstd->color = (st->owner == OWNER_NONE || !st->facilities) ? 0xE : _player_colors[st->owner]; |
|
811 |
sstd->width = st->sign.width_1; |
|
812 |
} |
|
813 |
} |
|
814 |
} |
|
815 |
} else if (dpi->zoom == 1) { |
|
816 |
right += 2; |
|
817 |
bottom += 2; |
|
818 |
||
819 |
FOR_ALL_STATIONS(st) { |
|
820 |
if (st->xy && |
|
821 |
bottom > st->sign.top && |
|
822 |
top < st->sign.top + 24 && |
|
823 |
right > st->sign.left && |
|
824 |
left < st->sign.left + st->sign.width_1*2) { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
825 |
|
835
f6a341f541d7
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
679
diff
changeset
|
826 |
sstd=AddStringToDraw(st->sign.left + 1, st->sign.top + 1, STR_305C_0, st->index, st->facilities, 0); |
0 | 827 |
if (sstd != NULL) { |
828 |
sstd->color = (st->owner == OWNER_NONE || !st->facilities) ? 0xE : _player_colors[st->owner]; |
|
829 |
sstd->width = st->sign.width_1; |
|
830 |
} |
|
831 |
} |
|
832 |
} |
|
833 |
||
834 |
} else { |
|
835 |
assert(dpi->zoom == 2); |
|
836 |
||
837 |
right += 4; |
|
838 |
bottom += 5; |
|
839 |
||
840 |
FOR_ALL_STATIONS(st) { |
|
841 |
if (st->xy && |
|
842 |
bottom > st->sign.top && |
|
843 |
top < st->sign.top + 24 && |
|
844 |
right > st->sign.left && |
|
845 |
left < st->sign.left + st->sign.width_2*4) { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
846 |
|
1964
6f9acf485026
(svn r2470) - Fix: Display station signs correctly in smallest zoom level in transparent buildings or tranparant station signs mode. (Peter1138)
hackykid
parents:
1959
diff
changeset
|
847 |
sstd=AddStringToDraw(st->sign.left + 1, st->sign.top + 1, STR_STATION_SIGN_TINY, st->index, st->facilities, 0); |
0 | 848 |
if (sstd != NULL) { |
849 |
sstd->color = (st->owner == OWNER_NONE || !st->facilities) ? 0xE : _player_colors[st->owner]; |
|
850 |
sstd->width = st->sign.width_2 | 0x8000; |
|
851 |
} |
|
852 |
} |
|
853 |
} |
|
854 |
} |
|
855 |
} |
|
856 |
||
410 | 857 |
static void ViewportAddSigns(DrawPixelInfo *dpi) |
0 | 858 |
{ |
859 |
SignStruct *ss; |
|
860 |
int left, top, right, bottom; |
|
861 |
StringSpriteToDraw *sstd; |
|
862 |
||
863 |
if (!(_display_opt & DO_SHOW_SIGNS)) |
|
864 |
return; |
|
865 |
||
866 |
left = dpi->left; |
|
867 |
top = dpi->top; |
|
868 |
right = left + dpi->width; |
|
869 |
bottom = top + dpi->height; |
|
870 |
||
871 |
if (dpi->zoom < 1) { |
|
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
981
diff
changeset
|
872 |
FOR_ALL_SIGNS(ss) { |
0 | 873 |
if (ss->str && |
874 |
bottom > ss->sign.top && |
|
875 |
top < ss->sign.top + 12 && |
|
876 |
right > ss->sign.left && |
|
877 |
left < ss->sign.left + ss->sign.width_1) { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
878 |
|
835
f6a341f541d7
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
679
diff
changeset
|
879 |
sstd=AddStringToDraw(ss->sign.left + 1, ss->sign.top + 1, STR_2806, ss->str, 0, 0); |
0 | 880 |
if (sstd != NULL) { |
881 |
sstd->width = ss->sign.width_1; |
|
1165
8fa7d3e235c6
(svn r1667) - Feature: Signs are now shown in the color of the player who created them
dominik
parents:
1109
diff
changeset
|
882 |
sstd->color = (ss->owner==OWNER_NONE)?14:_player_colors[ss->owner]; |
0 | 883 |
} |
884 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
885 |
} |
0 | 886 |
} else if (dpi->zoom == 1) { |
887 |
right += 2; |
|
888 |
bottom += 2; |
|
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
981
diff
changeset
|
889 |
FOR_ALL_SIGNS(ss) { |
0 | 890 |
if (ss->str && |
891 |
bottom > ss->sign.top && |
|
892 |
top < ss->sign.top + 24 && |
|
893 |
right > ss->sign.left && |
|
894 |
left < ss->sign.left + ss->sign.width_1*2) { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
895 |
|
835
f6a341f541d7
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
679
diff
changeset
|
896 |
sstd=AddStringToDraw(ss->sign.left + 1, ss->sign.top + 1, STR_2806, ss->str, 0, 0); |
0 | 897 |
if (sstd != NULL) { |
898 |
sstd->width = ss->sign.width_1; |
|
1172
01e589b4a31f
(svn r1674) - Fix: Signs are now displayed in the correct color at all zoom levels
dominik
parents:
1165
diff
changeset
|
899 |
sstd->color = (ss->owner==OWNER_NONE)?14:_player_colors[ss->owner]; |
0 | 900 |
} |
901 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
902 |
} |
0 | 903 |
} else { |
904 |
right += 4; |
|
905 |
bottom += 5; |
|
906 |
||
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
981
diff
changeset
|
907 |
FOR_ALL_SIGNS(ss) { |
0 | 908 |
if (ss->str && |
909 |
bottom > ss->sign.top && |
|
910 |
top < ss->sign.top + 24 && |
|
911 |
right > ss->sign.left && |
|
912 |
left < ss->sign.left + ss->sign.width_2*4) { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
913 |
|
1172
01e589b4a31f
(svn r1674) - Fix: Signs are now displayed in the correct color at all zoom levels
dominik
parents:
1165
diff
changeset
|
914 |
sstd=AddStringToDraw(ss->sign.left + 1, ss->sign.top + 1, STR_2002, ss->str, 0, 0); |
0 | 915 |
if (sstd != NULL) { |
916 |
sstd->width = ss->sign.width_2 | 0x8000; |
|
1172
01e589b4a31f
(svn r1674) - Fix: Signs are now displayed in the correct color at all zoom levels
dominik
parents:
1165
diff
changeset
|
917 |
sstd->color = (ss->owner==OWNER_NONE)?14:_player_colors[ss->owner]; |
0 | 918 |
} |
919 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
920 |
} |
0 | 921 |
} |
922 |
} |
|
923 |
||
410 | 924 |
static void ViewportAddWaypoints(DrawPixelInfo *dpi) |
0 | 925 |
{ |
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
926 |
Waypoint *wp; |
0 | 927 |
|
928 |
int left, top, right, bottom; |
|
929 |
StringSpriteToDraw *sstd; |
|
930 |
||
395
788a9bba0889
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
193
diff
changeset
|
931 |
if (!(_display_opt & DO_WAYPOINTS)) |
0 | 932 |
return; |
933 |
||
934 |
left = dpi->left; |
|
935 |
top = dpi->top; |
|
936 |
right = left + dpi->width; |
|
937 |
bottom = top + dpi->height; |
|
938 |
||
939 |
if (dpi->zoom < 1) { |
|
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
940 |
FOR_ALL_WAYPOINTS(wp) { |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
941 |
if (wp->xy && |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
942 |
bottom > wp->sign.top && |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
943 |
top < wp->sign.top + 12 && |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
944 |
right > wp->sign.left && |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
945 |
left < wp->sign.left + wp->sign.width_1) { |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
946 |
|
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
947 |
sstd = AddStringToDraw(wp->sign.left + 1, wp->sign.top + 1, STR_WAYPOINT_VIEWPORT, wp->index, 0, 0); |
0 | 948 |
if (sstd != NULL) { |
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
949 |
sstd->width = wp->sign.width_1; |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
950 |
sstd->color = (wp->deleted ? 0xE : 11); |
0 | 951 |
} |
952 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
953 |
} |
0 | 954 |
} else if (dpi->zoom == 1) { |
955 |
right += 2; |
|
956 |
bottom += 2; |
|
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
957 |
FOR_ALL_WAYPOINTS(wp) { |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
958 |
if (wp->xy && |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
959 |
bottom > wp->sign.top && |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
960 |
top < wp->sign.top + 24 && |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
961 |
right > wp->sign.left && |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
962 |
left < wp->sign.left + wp->sign.width_1*2) { |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
963 |
|
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
964 |
sstd = AddStringToDraw(wp->sign.left + 1, wp->sign.top + 1, STR_WAYPOINT_VIEWPORT, wp->index, 0, 0); |
0 | 965 |
if (sstd != NULL) { |
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
966 |
sstd->width = wp->sign.width_1; |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
967 |
sstd->color = (wp->deleted ? 0xE : 11); |
0 | 968 |
} |
969 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
970 |
} |
0 | 971 |
} else { |
972 |
right += 4; |
|
973 |
bottom += 5; |
|
974 |
||
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
975 |
FOR_ALL_WAYPOINTS(wp) { |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
976 |
if (wp->xy && |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
977 |
bottom > wp->sign.top && |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
978 |
top < wp->sign.top + 24 && |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
979 |
right > wp->sign.left && |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
980 |
left < wp->sign.left + wp->sign.width_2*4) { |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
981 |
|
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
982 |
sstd = AddStringToDraw(wp->sign.left + 1, wp->sign.top + 1, STR_WAYPOINT_VIEWPORT_TINY, wp->index, 0, 0); |
0 | 983 |
if (sstd != NULL) { |
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
984 |
sstd->width = wp->sign.width_2 | 0x8000; |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
985 |
sstd->color = (wp->deleted ? 0xE : 11); |
0 | 986 |
} |
987 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
988 |
} |
0 | 989 |
} |
990 |
} |
|
991 |
||
992 |
void UpdateViewportSignPos(ViewportSign *sign, int left, int top, StringID str) |
|
993 |
{ |
|
994 |
char buffer[128]; |
|
2116 | 995 |
uint w; |
0 | 996 |
|
997 |
sign->top = top; |
|
998 |
||
999 |
GetString(buffer, str); |
|
1000 |
w = GetStringWidth(buffer) + 3; |
|
1001 |
sign->width_1 = w; |
|
2116 | 1002 |
sign->left = left - w / 2; |
0 | 1003 |
|
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
1004 |
// zoomed out version |
0 | 1005 |
_stringwidth_base = 0xE0; |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
1006 |
w = GetStringWidth(buffer) + 3; |
0 | 1007 |
_stringwidth_base = 0; |
1390
e7cdf3ce0fb6
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
1008 |
sign->width_2 = w; |
0 | 1009 |
} |
1010 |
||
1011 |
||
410 | 1012 |
static void ViewportDrawTileSprites(TileSpriteToDraw *ts) |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1013 |
{ |
0 | 1014 |
do { |
1015 |
Point pt = RemapCoords(ts->x, ts->y, ts->z); |
|
1016 |
DrawSprite(ts->image, pt.x, pt.y); |
|
2116 | 1017 |
ts = ts->next; |
1018 |
} while (ts != NULL); |
|
0 | 1019 |
} |
1020 |
||
2116 | 1021 |
static void ViewportSortParentSprites(ParentSpriteToDraw* psd[]) |
0 | 1022 |
{ |
2116 | 1023 |
while (*psd != NULL) { |
1024 |
ParentSpriteToDraw* ps = *psd; |
|
0 | 1025 |
|
1026 |
if (!(ps->unk16 & 1)) { |
|
2116 | 1027 |
ParentSpriteToDraw** psd2 = psd; |
1028 |
||
0 | 1029 |
ps->unk16 |= 1; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1030 |
|
2116 | 1031 |
while (*++psd2 != NULL) { |
1032 |
ParentSpriteToDraw* ps2 = *psd2; |
|
1934
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1033 |
bool mustswap = false; |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1034 |
|
2116 | 1035 |
if (ps2->unk16 & 1) continue; |
0 | 1036 |
|
1934
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1037 |
// Decide which sort order algorithm to use, based on whether the sprites have some overlapping area. |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1038 |
if (((ps2->tile_x > ps->tile_x && ps2->tile_x < ps->tile_right) || |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1039 |
(ps2->tile_right > ps->tile_x && ps2->tile_x < ps->tile_right)) && // overlap in X |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1040 |
((ps2->tile_y > ps->tile_y && ps2->tile_y < ps->tile_bottom) || |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1041 |
(ps2->tile_bottom > ps->tile_y && ps2->tile_y < ps->tile_bottom)) && // overlap in Y |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1042 |
((ps2->tile_z > ps->tile_z && ps2->tile_z < ps->tile_z_bottom) || |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1043 |
(ps2->tile_z_bottom > ps->tile_z && ps2->tile_z < ps->tile_z_bottom)) ) { // overlap in Z |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1044 |
// Sprites overlap. |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1045 |
// Use X+Y+Z as the sorting order, so sprites nearer the bottom of the screen, |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1046 |
// and with higher Z elevation, draw in front. |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1047 |
// Here X,Y,Z are the coordinates of the "center of mass" of the sprite, |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1048 |
// i.e. X=(left+right)/2, etc. |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1049 |
// However, since we only care about order, don't actually calculate the division / 2. |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1050 |
mustswap = ps->tile_x + ps->tile_right + ps->tile_y + ps->tile_bottom + ps->tile_z + ps->tile_z_bottom > |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1051 |
ps2->tile_x + ps2->tile_right + ps2->tile_y + ps2->tile_bottom + ps2->tile_z + ps2->tile_z_bottom; |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1052 |
} else { |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1053 |
// No overlap; use the original TTD sort algorithm. |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1054 |
mustswap = (ps->tile_right >= ps2->tile_x && |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1055 |
ps->tile_bottom >= ps2->tile_y && |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1056 |
ps->tile_z_bottom >= ps2->tile_z && |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1057 |
(ps->tile_x >= ps2->tile_right || |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1058 |
ps->tile_y >= ps2->tile_bottom || |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1059 |
ps->tile_z >= ps2->tile_z_bottom)); |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1060 |
} |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1061 |
if (mustswap) { |
b27bc12822cd
(svn r2440) - Fix: [newgrf] Fix the spritesorter to handle overlapping sprites properly, this fixes display problems with really short wagons. (algorithm by patchman, ported by therax)
hackykid
parents:
1932
diff
changeset
|
1062 |
// Swap the two sprites ps and ps2 using bubble-sort algorithm. |
2116 | 1063 |
ParentSpriteToDraw** psd3 = psd; |
1064 |
||
0 | 1065 |
do { |
2116 | 1066 |
ParentSpriteToDraw* temp = *psd3; |
0 | 1067 |
*psd3 = ps2; |
2116 | 1068 |
ps2 = temp; |
0 | 1069 |
|
1070 |
psd3++; |
|
1071 |
} while (psd3 <= psd2); |
|
1072 |
} |
|
1073 |
} |
|
1074 |
} else { |
|
1075 |
psd++; |
|
1076 |
} |
|
1077 |
} |
|
1078 |
} |
|
1079 |
||
2116 | 1080 |
static void ViewportDrawParentSprites(ParentSpriteToDraw *psd[]) |
0 | 1081 |
{ |
2116 | 1082 |
for (; *psd != NULL; psd++) { |
1083 |
const ParentSpriteToDraw* ps = *psd; |
|
1084 |
Point pt = RemapCoords(ps->tile_x, ps->tile_y, ps->tile_z); |
|
1085 |
const ChildScreenSpriteToDraw* cs; |
|
0 | 1086 |
|
1087 |
DrawSprite(ps->image, pt.x, pt.y); |
|
1088 |
||
2116 | 1089 |
for (cs = ps->child; cs != NULL; cs = cs->next) { |
0 | 1090 |
DrawSprite(cs->image, ps->left + cs->x, ps->top + cs->y); |
1091 |
} |
|
1092 |
} |
|
1093 |
} |
|
1094 |
||
2116 | 1095 |
static void ViewportDrawStrings(DrawPixelInfo *dpi, const StringSpriteToDraw *ss) |
0 | 1096 |
{ |
1097 |
DrawPixelInfo dp; |
|
1098 |
byte zoom; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1099 |
|
0 | 1100 |
_cur_dpi = &dp; |
1101 |
dp = *dpi; |
|
1102 |
||
2116 | 1103 |
zoom = dp.zoom; |
0 | 1104 |
dp.zoom = 0; |
1105 |
||
1106 |
dp.left >>= zoom; |
|
1107 |
dp.top >>= zoom; |
|
1108 |
dp.width >>= zoom; |
|
1109 |
dp.height >>= zoom; |
|
1110 |
||
1111 |
do { |
|
1112 |
if (ss->width != 0) { |
|
2116 | 1113 |
int x = (ss->x >> zoom) - 1; |
1114 |
int y = (ss->y >> zoom) - 1; |
|
1115 |
int bottom = y + 11; |
|
1116 |
int w = ss->width; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1117 |
|
0 | 1118 |
if (w & 0x8000) { |
1119 |
w &= ~0x8000; |
|
1120 |
y--; |
|
1121 |
bottom -= 6; |
|
1122 |
w -= 3; |
|
1123 |
} |
|
1124 |
||
2116 | 1125 |
/* Draw the rectangle if 'tranparent station signs' is off, |
1126 |
* or if we are drawing a general text sign (STR_2806) */ |
|
1127 |
if (!(_display_opt & DO_TRANS_SIGNS) || ss->string == STR_2806) |
|
1128 |
DrawFrameRect( |
|
1129 |
x, y, x + w, bottom, ss->color, |
|
1130 |
(_display_opt & DO_TRANS_BUILDINGS) ? FR_TRANSPARENT | FR_NOBORDER : 0 |
|
1131 |
); |
|
0 | 1132 |
} |
1133 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1134 |
SetDParam(0, ss->params[0]); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1135 |
SetDParam(1, ss->params[1]); |
835
f6a341f541d7
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
679
diff
changeset
|
1136 |
SetDParam(2, ss->params[2]); |
2116 | 1137 |
/* if we didn't draw a rectangle, or if transparant building is on, |
1138 |
* draw the text in the color the rectangle would have */ |
|
1139 |
if (( |
|
1140 |
(_display_opt & DO_TRANS_BUILDINGS) || |
|
1141 |
(_display_opt & DO_TRANS_SIGNS && ss->string != STR_2806) |
|
1142 |
) && ss->width != 0) { |
|
1143 |
/* Real colors need the IS_PALETTE_COLOR flag |
|
1144 |
* otherwise colors from _string_colormap are assumed. */ |
|
1145 |
DrawString( |
|
1146 |
ss->x >> zoom, (ss->y >> zoom) - (ss->width & 0x8000 ? 2 : 0), |
|
1147 |
ss->string, (_color_list[ss->color].window_color_bgb | IS_PALETTE_COLOR) |
|
1148 |
); |
|
0 | 1149 |
} else { |
2116 | 1150 |
DrawString( |
1151 |
ss->x >> zoom, (ss->y >> zoom) - (ss->width & 0x8000 ? 2 : 0), |
|
1152 |
ss->string, 16 |
|
1153 |
); |
|
0 | 1154 |
} |
2116 | 1155 |
|
1156 |
ss = ss->next; |
|
1157 |
} while (ss != NULL); |
|
0 | 1158 |
|
1159 |
_cur_dpi = dpi; |
|
1160 |
} |
|
1161 |
||
430 | 1162 |
void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom) |
0 | 1163 |
{ |
1164 |
ViewportDrawer vd; |
|
1165 |
int mask; |
|
2116 | 1166 |
int x; |
1167 |
int y; |
|
0 | 1168 |
DrawPixelInfo *old_dpi; |
1169 |
||
1170 |
byte mem[VIEWPORT_DRAW_MEM]; |
|
137
73f897e1bf4a
(svn r138) -Add: 64x64 stations are now nicely painted (increased size of
truelight
parents:
133
diff
changeset
|
1171 |
ParentSpriteToDraw *parent_list[6144]; |
0 | 1172 |
|
1173 |
_cur_vd = &vd; |
|
1174 |
||
1175 |
old_dpi = _cur_dpi; |
|
1176 |
_cur_dpi = &vd.dpi; |
|
1177 |
||
1178 |
vd.dpi.zoom = vp->zoom; |
|
1179 |
mask = (-1) << vp->zoom; |
|
1180 |
||
1181 |
vd.combine_sprites = 0; |
|
1182 |
vd.ground_child = 0; |
|
1183 |
||
1184 |
vd.dpi.width = (right - left) & mask; |
|
1185 |
vd.dpi.height = (bottom - top) & mask; |
|
1186 |
vd.dpi.left = left & mask; |
|
1187 |
vd.dpi.top = top & mask; |
|
1188 |
vd.dpi.pitch = old_dpi->pitch; |
|
1189 |
||
1190 |
x = ((vd.dpi.left - (vp->virtual_left&mask)) >> vp->zoom) + vp->left; |
|
1191 |
y = ((vd.dpi.top - (vp->virtual_top&mask)) >> vp->zoom) + vp->top; |
|
1192 |
||
1193 |
vd.dpi.dst_ptr = old_dpi->dst_ptr + x - old_dpi->left + (y - old_dpi->top) * old_dpi->pitch; |
|
1194 |
||
1195 |
vd.parent_list = parent_list; |
|
2116 | 1196 |
vd.eof_parent_list = endof(parent_list); |
0 | 1197 |
vd.spritelist_mem = mem; |
2116 | 1198 |
vd.eof_spritelist_mem = endof(mem) - sizeof(LARGEST_SPRITELIST_STRUCT); |
0 | 1199 |
vd.last_string = &vd.first_string; |
1200 |
vd.first_string = NULL; |
|
1201 |
vd.last_tile = &vd.first_tile; |
|
1202 |
vd.first_tile = NULL; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1203 |
|
0 | 1204 |
ViewportAddLandscape(); |
1205 |
#if !defined(NEW_ROTATION) |
|
1206 |
ViewportAddVehicles(&vd.dpi); |
|
1207 |
DrawTextEffects(&vd.dpi); |
|
1208 |
||
1209 |
ViewportAddTownNames(&vd.dpi); |
|
1210 |
ViewportAddStationNames(&vd.dpi); |
|
1211 |
ViewportAddSigns(&vd.dpi); |
|
395
788a9bba0889
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
193
diff
changeset
|
1212 |
ViewportAddWaypoints(&vd.dpi); |
0 | 1213 |
#endif |
1214 |
||
133
321532e90bc8
(svn r134) -Fix: [976583] parent_list was too small
truelight
parents:
58
diff
changeset
|
1215 |
// This assert should never happen (because the length of the parent_list |
321532e90bc8
(svn r134) -Fix: [976583] parent_list was too small
truelight
parents:
58
diff
changeset
|
1216 |
// is checked) |
979
11ea18598e16
(svn r1475) Fix some more signed/unsigned comparison warnings
tron
parents:
926
diff
changeset
|
1217 |
assert(vd.parent_list <= endof(parent_list)); |
133
321532e90bc8
(svn r134) -Fix: [976583] parent_list was too small
truelight
parents:
58
diff
changeset
|
1218 |
|
2116 | 1219 |
if (vd.first_tile != NULL) ViewportDrawTileSprites(vd.first_tile); |
0 | 1220 |
|
1221 |
/* null terminate parent sprite list */ |
|
1222 |
*vd.parent_list = NULL; |
|
1223 |
||
1224 |
ViewportSortParentSprites(parent_list); |
|
1225 |
ViewportDrawParentSprites(parent_list); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1226 |
|
2116 | 1227 |
if (vd.first_string != NULL) ViewportDrawStrings(&vd.dpi, vd.first_string); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1228 |
|
0 | 1229 |
_cur_dpi = old_dpi; |
1230 |
} |
|
1231 |
||
1232 |
// Make sure we don't draw a too big area at a time. |
|
1233 |
// If we do, the sprite memory will overflow. |
|
1234 |
static void ViewportDrawChk(ViewPort *vp, int left, int top, int right, int bottom) |
|
1235 |
{ |
|
1236 |
if (((bottom - top) * (right - left) << vp->zoom) > 180000) { |
|
1237 |
if ((bottom - top) > (right - left)) { |
|
1238 |
int t = (top + bottom) >> 1; |
|
1239 |
ViewportDrawChk(vp, left, top, right, t); |
|
1240 |
ViewportDrawChk(vp, left, t, right, bottom); |
|
1241 |
} else { |
|
1242 |
int t = (left + right) >> 1; |
|
1243 |
ViewportDrawChk(vp, left, top, t, bottom); |
|
1244 |
ViewportDrawChk(vp, t, top, right, bottom); |
|
1245 |
} |
|
1246 |
} else { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1247 |
ViewportDoDraw(vp, |
0 | 1248 |
((left - vp->left) << vp->zoom) + vp->virtual_left, |
1249 |
((top - vp->top) << vp->zoom) + vp->virtual_top, |
|
1250 |
((right - vp->left) << vp->zoom) + vp->virtual_left, |
|
1251 |
((bottom - vp->top) << vp->zoom) + vp->virtual_top |
|
1252 |
); |
|
1253 |
} |
|
1254 |
} |
|
1255 |
||
500
8e52f7797b48
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
497
diff
changeset
|
1256 |
static inline void ViewportDraw(ViewPort *vp, int left, int top, int right, int bottom) |
0 | 1257 |
{ |
2116 | 1258 |
if (right <= vp->left || bottom <= vp->top) return; |
0 | 1259 |
|
2116 | 1260 |
if (left >= vp->left + vp->width) return; |
0 | 1261 |
|
1262 |
if (left < vp->left) left = vp->left; |
|
2116 | 1263 |
if (right > vp->left + vp->width) right = vp->left + vp->width; |
0 | 1264 |
|
2116 | 1265 |
if (top >= vp->top + vp->height) return; |
0 | 1266 |
|
1267 |
if (top < vp->top) top = vp->top; |
|
2116 | 1268 |
if (bottom > vp->top + vp->height) bottom = vp->top + vp->height; |
0 | 1269 |
|
1270 |
ViewportDrawChk(vp, left, top, right, bottom); |
|
1271 |
} |
|
1272 |
||
2116 | 1273 |
void DrawWindowViewport(Window *w) |
1274 |
{ |
|
0 | 1275 |
DrawPixelInfo *dpi = _cur_dpi; |
1276 |
||
1277 |
dpi->left += w->left; |
|
1278 |
dpi->top += w->top; |
|
1279 |
||
1280 |
ViewportDraw(w->viewport, dpi->left, dpi->top, dpi->left + dpi->width, dpi->top + dpi->height); |
|
1281 |
||
1282 |
dpi->left -= w->left; |
|
1283 |
dpi->top -= w->top; |
|
1284 |
} |
|
1285 |
||
1286 |
void UpdateViewportPosition(Window *w) |
|
1287 |
{ |
|
2116 | 1288 |
const ViewPort *vp = w->viewport; |
0 | 1289 |
|
2116 | 1290 |
if (WP(w, vp_d).follow_vehicle != INVALID_VEHICLE) { |
1291 |
const Vehicle* veh = GetVehicle(WP(w,vp_d).follow_vehicle); |
|
1292 |
Point pt = MapXYZToViewport(vp, veh->x_pos, veh->y_pos, veh->z_pos); |
|
0 | 1293 |
|
1294 |
SetViewportPosition(w, pt.x, pt.y); |
|
1295 |
} else { |
|
632
6528428cbebb
(svn r1063) Improve scrolling limits a bit. You now can scroll further away from the map at the NW and NE edge.
tron
parents:
534
diff
changeset
|
1296 |
#if !defined(NEW_ROTATION) |
6528428cbebb
(svn r1063) Improve scrolling limits a bit. You now can scroll further away from the map at the NW and NE edge.
tron
parents:
534
diff
changeset
|
1297 |
int x; |
6528428cbebb
(svn r1063) Improve scrolling limits a bit. You now can scroll further away from the map at the NW and NE edge.
tron
parents:
534
diff
changeset
|
1298 |
int y; |
6528428cbebb
(svn r1063) Improve scrolling limits a bit. You now can scroll further away from the map at the NW and NE edge.
tron
parents:
534
diff
changeset
|
1299 |
int vx; |
6528428cbebb
(svn r1063) Improve scrolling limits a bit. You now can scroll further away from the map at the NW and NE edge.
tron
parents:
534
diff
changeset
|
1300 |
int vy; |
6528428cbebb
(svn r1063) Improve scrolling limits a bit. You now can scroll further away from the map at the NW and NE edge.
tron
parents:
534
diff
changeset
|
1301 |
|
6528428cbebb
(svn r1063) Improve scrolling limits a bit. You now can scroll further away from the map at the NW and NE edge.
tron
parents:
534
diff
changeset
|
1302 |
// Center of the viewport is hot spot |
6528428cbebb
(svn r1063) Improve scrolling limits a bit. You now can scroll further away from the map at the NW and NE edge.
tron
parents:
534
diff
changeset
|
1303 |
x = WP(w,vp_d).scrollpos_x + vp->virtual_width / 2; |
6528428cbebb
(svn r1063) Improve scrolling limits a bit. You now can scroll further away from the map at the NW and NE edge.
tron
parents:
534
diff
changeset
|
1304 |
y = WP(w,vp_d).scrollpos_y + vp->virtual_height / 2; |
6528428cbebb
(svn r1063) Improve scrolling limits a bit. You now can scroll further away from the map at the NW and NE edge.
tron
parents:
534
diff
changeset
|
1305 |
// Convert viewport coordinates to map coordinates |
6528428cbebb
(svn r1063) Improve scrolling limits a bit. You now can scroll further away from the map at the NW and NE edge.
tron
parents:
534
diff
changeset
|
1306 |
// Calculation is scaled by 4 to avoid rounding errors |
6528428cbebb
(svn r1063) Improve scrolling limits a bit. You now can scroll further away from the map at the NW and NE edge.
tron
parents:
534
diff
changeset
|
1307 |
vx = -x + y * 2; |
6528428cbebb
(svn r1063) Improve scrolling limits a bit. You now can scroll further away from the map at the NW and NE edge.
tron
parents:
534
diff
changeset
|
1308 |
vy = x + y * 2; |
6528428cbebb
(svn r1063) Improve scrolling limits a bit. You now can scroll further away from the map at the NW and NE edge.
tron
parents:
534
diff
changeset
|
1309 |
// clamp to size of map |
3421
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1310 |
vx = clamp(vx, 0 * 4, MapMaxX() * TILE_SIZE * 4); |
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1311 |
vy = clamp(vy, 0 * 4, MapMaxY() * TILE_SIZE * 4); |
632
6528428cbebb
(svn r1063) Improve scrolling limits a bit. You now can scroll further away from the map at the NW and NE edge.
tron
parents:
534
diff
changeset
|
1312 |
// Convert map coordinates to viewport coordinates |
6528428cbebb
(svn r1063) Improve scrolling limits a bit. You now can scroll further away from the map at the NW and NE edge.
tron
parents:
534
diff
changeset
|
1313 |
x = (-vx + vy) / 2; |
6528428cbebb
(svn r1063) Improve scrolling limits a bit. You now can scroll further away from the map at the NW and NE edge.
tron
parents:
534
diff
changeset
|
1314 |
y = ( vx + vy) / 4; |
6528428cbebb
(svn r1063) Improve scrolling limits a bit. You now can scroll further away from the map at the NW and NE edge.
tron
parents:
534
diff
changeset
|
1315 |
// Set position |
2116 | 1316 |
WP(w, vp_d).scrollpos_x = x - vp->virtual_width / 2; |
1317 |
WP(w, vp_d).scrollpos_y = y - vp->virtual_height / 2; |
|
632
6528428cbebb
(svn r1063) Improve scrolling limits a bit. You now can scroll further away from the map at the NW and NE edge.
tron
parents:
534
diff
changeset
|
1318 |
#else |
0 | 1319 |
int x,y,t; |
1320 |
int err; |
|
1321 |
||
1322 |
x = WP(w,vp_d).scrollpos_x >> 2; |
|
1323 |
y = WP(w,vp_d).scrollpos_y >> 1; |
|
1324 |
||
1325 |
t = x; |
|
1326 |
x = x + y; |
|
1327 |
y = x - y; |
|
1328 |
err= 0; |
|
1329 |
||
1330 |
if (err != 0) { |
|
1331 |
/* coordinate remap */ |
|
1332 |
Point pt = RemapCoords(x, y, 0); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1333 |
t = (-1) << vp->zoom; |
0 | 1334 |
WP(w,vp_d).scrollpos_x = pt.x & t; |
1335 |
WP(w,vp_d).scrollpos_y = pt.y & t; |
|
1336 |
} |
|
632
6528428cbebb
(svn r1063) Improve scrolling limits a bit. You now can scroll further away from the map at the NW and NE edge.
tron
parents:
534
diff
changeset
|
1337 |
#endif |
6528428cbebb
(svn r1063) Improve scrolling limits a bit. You now can scroll further away from the map at the NW and NE edge.
tron
parents:
534
diff
changeset
|
1338 |
|
2116 | 1339 |
SetViewportPosition(w, WP(w, vp_d).scrollpos_x, WP(w, vp_d).scrollpos_y); |
0 | 1340 |
} |
1341 |
} |
|
1342 |
||
2116 | 1343 |
static void MarkViewportDirty(const ViewPort *vp, int left, int top, int right, int bottom) |
0 | 1344 |
{ |
2116 | 1345 |
right -= vp->virtual_left; |
1346 |
if (right <= 0) return; |
|
0 | 1347 |
|
2116 | 1348 |
bottom -= vp->virtual_top; |
1349 |
if (bottom <= 0) return; |
|
0 | 1350 |
|
2116 | 1351 |
left = max(0, left - vp->virtual_left); |
0 | 1352 |
|
2116 | 1353 |
if (left >= vp->virtual_width) return; |
0 | 1354 |
|
2116 | 1355 |
top = max(0, top - vp->virtual_top); |
1356 |
||
1357 |
if (top >= vp->virtual_height) return; |
|
0 | 1358 |
|
1359 |
SetDirtyBlocks( |
|
1360 |
(left >> vp->zoom) + vp->left, |
|
1361 |
(top >> vp->zoom) + vp->top, |
|
1362 |
(right >> vp->zoom) + vp->left, |
|
1363 |
(bottom >> vp->zoom) + vp->top |
|
1364 |
); |
|
1365 |
} |
|
1366 |
||
1367 |
void MarkAllViewportsDirty(int left, int top, int right, int bottom) |
|
1368 |
{ |
|
2116 | 1369 |
const ViewPort *vp = _viewports; |
0 | 1370 |
uint32 act = _active_viewports; |
1371 |
do { |
|
1372 |
if (act & 1) { |
|
1373 |
assert(vp->width != 0); |
|
1374 |
MarkViewportDirty(vp, left, top, right, bottom); |
|
1375 |
} |
|
1376 |
} while (vp++,act>>=1); |
|
1377 |
} |
|
1378 |
||
2116 | 1379 |
void MarkTileDirtyByTile(TileIndex tile) |
1380 |
{ |
|
3421
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1381 |
Point pt = RemapCoords(TileX(tile) * TILE_SIZE, TileY(tile) * TILE_SIZE, GetTileZ(tile)); |
0 | 1382 |
MarkAllViewportsDirty( |
1383 |
pt.x - 31, |
|
1384 |
pt.y - 122, |
|
1385 |
pt.x - 31 + 67, |
|
1386 |
pt.y - 122 + 154 |
|
1387 |
); |
|
1388 |
} |
|
1389 |
||
1390 |
void MarkTileDirty(int x, int y) |
|
1391 |
{ |
|
2116 | 1392 |
uint z = 0; |
0 | 1393 |
Point pt; |
2116 | 1394 |
|
3421
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1395 |
if (IS_INT_INSIDE(x, 0, MapSizeX() * TILE_SIZE) && |
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1396 |
IS_INT_INSIDE(y, 0, MapSizeY() * TILE_SIZE)) |
1980
6c5917cfcb78
(svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY
tron
parents:
1977
diff
changeset
|
1397 |
z = GetTileZ(TileVirtXY(x, y)); |
0 | 1398 |
pt = RemapCoords(x, y, z); |
1399 |
||
1400 |
MarkAllViewportsDirty( |
|
1401 |
pt.x - 31, |
|
1402 |
pt.y - 122, |
|
1403 |
pt.x - 31 + 67, |
|
1404 |
pt.y - 122 + 154 |
|
1405 |
); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1406 |
} |
0 | 1407 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1083
diff
changeset
|
1408 |
static void SetSelectionTilesDirty(void) |
0 | 1409 |
{ |
1410 |
int y_size, x_size; |
|
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1411 |
int x = _thd.pos.x; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1412 |
int y = _thd.pos.y; |
0 | 1413 |
|
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1414 |
x_size = _thd.size.x; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1415 |
y_size = _thd.size.y; |
0 | 1416 |
|
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1417 |
if (_thd.outersize.x) { |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1418 |
x_size += _thd.outersize.x; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1419 |
x += _thd.offs.x; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1420 |
y_size += _thd.outersize.y; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1421 |
y += _thd.offs.y; |
0 | 1422 |
} |
1423 |
||
1424 |
assert(x_size > 0); |
|
1425 |
assert(y_size > 0); |
|
1426 |
||
1427 |
x_size += x; |
|
1428 |
y_size += y; |
|
1429 |
||
1430 |
do { |
|
1431 |
int y_bk = y; |
|
1432 |
do { |
|
1433 |
MarkTileDirty(x, y); |
|
3421
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1434 |
} while ( (y += TILE_SIZE) != y_size); |
0 | 1435 |
y = y_bk; |
3421
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1436 |
} while ( (x += TILE_SIZE) != x_size); |
0 | 1437 |
} |
1438 |
||
1439 |
||
1990
efb67f977138
(svn r2496) -Fix: [1179933] When toggling build/remove via keyboard the selection wasn't correctly redrawn
tron
parents:
1980
diff
changeset
|
1440 |
void SetSelectionRed(bool b) |
efb67f977138
(svn r2496) -Fix: [1179933] When toggling build/remove via keyboard the selection wasn't correctly redrawn
tron
parents:
1980
diff
changeset
|
1441 |
{ |
efb67f977138
(svn r2496) -Fix: [1179933] When toggling build/remove via keyboard the selection wasn't correctly redrawn
tron
parents:
1980
diff
changeset
|
1442 |
_thd.make_square_red = b; |
efb67f977138
(svn r2496) -Fix: [1179933] When toggling build/remove via keyboard the selection wasn't correctly redrawn
tron
parents:
1980
diff
changeset
|
1443 |
SetSelectionTilesDirty(); |
efb67f977138
(svn r2496) -Fix: [1179933] When toggling build/remove via keyboard the selection wasn't correctly redrawn
tron
parents:
1980
diff
changeset
|
1444 |
} |
efb67f977138
(svn r2496) -Fix: [1179933] When toggling build/remove via keyboard the selection wasn't correctly redrawn
tron
parents:
1980
diff
changeset
|
1445 |
|
efb67f977138
(svn r2496) -Fix: [1179933] When toggling build/remove via keyboard the selection wasn't correctly redrawn
tron
parents:
1980
diff
changeset
|
1446 |
|
2116 | 1447 |
static bool CheckClickOnTown(const ViewPort *vp, int x, int y) |
0 | 1448 |
{ |
2116 | 1449 |
const Town *t; |
0 | 1450 |
|
2116 | 1451 |
if (!(_display_opt & DO_SHOW_TOWN_NAMES)) return false; |
0 | 1452 |
|
1453 |
if (vp->zoom < 1) { |
|
1454 |
x = x - vp->left + vp->virtual_left; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1455 |
y = y - vp->top + vp->virtual_top; |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1456 |
|
0 | 1457 |
FOR_ALL_TOWNS(t) { |
1458 |
if (t->xy && |
|
1459 |
y >= t->sign.top && |
|
1460 |
y < t->sign.top + 12 && |
|
1461 |
x >= t->sign.left && |
|
1462 |
x < t->sign.left + t->sign.width_1) { |
|
1463 |
ShowTownViewWindow(t->index); |
|
1464 |
return true; |
|
1465 |
} |
|
1466 |
} |
|
1467 |
} else if (vp->zoom == 1) { |
|
1468 |
x = (x - vp->left + 1) * 2 + vp->virtual_left; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1469 |
y = (y - vp->top + 1) * 2 + vp->virtual_top; |
0 | 1470 |
FOR_ALL_TOWNS(t) { |
1471 |
if (t->xy && |
|
1472 |
y >= t->sign.top && |
|
1473 |
y < t->sign.top + 24 && |
|
1474 |
x >= t->sign.left && |
|
1475 |
x < t->sign.left + t->sign.width_1 * 2) { |
|
1476 |
ShowTownViewWindow(t->index); |
|
1477 |
return true; |
|
1478 |
} |
|
1479 |
} |
|
1480 |
} else { |
|
1481 |
x = (x - vp->left + 3) * 4 + vp->virtual_left; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1482 |
y = (y - vp->top + 3) * 4 + vp->virtual_top; |
0 | 1483 |
FOR_ALL_TOWNS(t) { |
1484 |
if (t->xy && |
|
1485 |
y >= t->sign.top && |
|
1486 |
y < t->sign.top + 24 && |
|
1487 |
x >= t->sign.left && |
|
1488 |
x < t->sign.left + t->sign.width_2 * 4) { |
|
1489 |
ShowTownViewWindow(t->index); |
|
1490 |
return true; |
|
1491 |
} |
|
1492 |
} |
|
1493 |
} |
|
1494 |
||
1495 |
return false; |
|
1496 |
} |
|
1497 |
||
2116 | 1498 |
static bool CheckClickOnStation(const ViewPort *vp, int x, int y) |
0 | 1499 |
{ |
2116 | 1500 |
const Station *st; |
0 | 1501 |
|
2116 | 1502 |
if (!(_display_opt & DO_SHOW_STATION_NAMES)) return false; |
0 | 1503 |
|
1504 |
if (vp->zoom < 1) { |
|
1505 |
x = x - vp->left + vp->virtual_left; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1506 |
y = y - vp->top + vp->virtual_top; |
0 | 1507 |
|
1508 |
FOR_ALL_STATIONS(st) { |
|
1509 |
if (st->xy && |
|
1510 |
y >= st->sign.top && |
|
1511 |
y < st->sign.top + 12 && |
|
1512 |
x >= st->sign.left && |
|
1513 |
x < st->sign.left + st->sign.width_1) { |
|
1514 |
ShowStationViewWindow(st->index); |
|
1515 |
return true; |
|
1516 |
} |
|
1517 |
} |
|
1518 |
} else if (vp->zoom == 1) { |
|
1519 |
x = (x - vp->left + 1) * 2 + vp->virtual_left; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1520 |
y = (y - vp->top + 1) * 2 + vp->virtual_top; |
0 | 1521 |
FOR_ALL_STATIONS(st) { |
1522 |
if (st->xy && |
|
1523 |
y >= st->sign.top && |
|
1524 |
y < st->sign.top + 24 && |
|
1525 |
x >= st->sign.left && |
|
1526 |
x < st->sign.left + st->sign.width_1 * 2) { |
|
1527 |
ShowStationViewWindow(st->index); |
|
1528 |
return true; |
|
1529 |
} |
|
1530 |
} |
|
1531 |
} else { |
|
1532 |
x = (x - vp->left + 3) * 4 + vp->virtual_left; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1533 |
y = (y - vp->top + 3) * 4 + vp->virtual_top; |
0 | 1534 |
FOR_ALL_STATIONS(st) { |
1535 |
if (st->xy && |
|
1536 |
y >= st->sign.top && |
|
1537 |
y < st->sign.top + 24 && |
|
1538 |
x >= st->sign.left && |
|
1539 |
x < st->sign.left + st->sign.width_2 * 4) { |
|
1540 |
ShowStationViewWindow(st->index); |
|
1541 |
return true; |
|
1542 |
} |
|
1543 |
} |
|
1544 |
} |
|
1545 |
||
1546 |
return false; |
|
1547 |
} |
|
1548 |
||
2116 | 1549 |
static bool CheckClickOnSign(const ViewPort *vp, int x, int y) |
0 | 1550 |
{ |
2116 | 1551 |
const SignStruct *ss; |
0 | 1552 |
|
2116 | 1553 |
if (!(_display_opt & DO_SHOW_SIGNS)) return false; |
0 | 1554 |
|
1555 |
if (vp->zoom < 1) { |
|
1556 |
x = x - vp->left + vp->virtual_left; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1557 |
y = y - vp->top + vp->virtual_top; |
0 | 1558 |
|
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
981
diff
changeset
|
1559 |
FOR_ALL_SIGNS(ss) { |
0 | 1560 |
if (ss->str && |
1561 |
y >= ss->sign.top && |
|
1562 |
y < ss->sign.top + 12 && |
|
1563 |
x >= ss->sign.left && |
|
1564 |
x < ss->sign.left + ss->sign.width_1) { |
|
1565 |
ShowRenameSignWindow(ss); |
|
1566 |
return true; |
|
1567 |
} |
|
1568 |
} |
|
1569 |
} else if (vp->zoom == 1) { |
|
1570 |
x = (x - vp->left + 1) * 2 + vp->virtual_left; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1571 |
y = (y - vp->top + 1) * 2 + vp->virtual_top; |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
981
diff
changeset
|
1572 |
FOR_ALL_SIGNS(ss) { |
0 | 1573 |
if (ss->str && |
1574 |
y >= ss->sign.top && |
|
1575 |
y < ss->sign.top + 24 && |
|
1576 |
x >= ss->sign.left && |
|
1577 |
x < ss->sign.left + ss->sign.width_1 * 2) { |
|
1578 |
ShowRenameSignWindow(ss); |
|
1579 |
return true; |
|
1580 |
} |
|
1581 |
} |
|
1582 |
} else { |
|
1583 |
x = (x - vp->left + 3) * 4 + vp->virtual_left; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1584 |
y = (y - vp->top + 3) * 4 + vp->virtual_top; |
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
981
diff
changeset
|
1585 |
FOR_ALL_SIGNS(ss) { |
0 | 1586 |
if (ss->str && |
1587 |
y >= ss->sign.top && |
|
1588 |
y < ss->sign.top + 24 && |
|
1589 |
x >= ss->sign.left && |
|
1590 |
x < ss->sign.left + ss->sign.width_2 * 4) { |
|
1591 |
ShowRenameSignWindow(ss); |
|
1592 |
return true; |
|
1593 |
} |
|
1594 |
} |
|
1595 |
} |
|
1596 |
||
1597 |
return false; |
|
1598 |
} |
|
1599 |
||
2116 | 1600 |
static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y) |
0 | 1601 |
{ |
2116 | 1602 |
const Waypoint *wp; |
0 | 1603 |
|
2116 | 1604 |
if (!(_display_opt & DO_WAYPOINTS)) return false; |
0 | 1605 |
|
1606 |
if (vp->zoom < 1) { |
|
1607 |
x = x - vp->left + vp->virtual_left; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1608 |
y = y - vp->top + vp->virtual_top; |
0 | 1609 |
|
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
1610 |
FOR_ALL_WAYPOINTS(wp) { |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
1611 |
if (wp->xy && |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
1612 |
y >= wp->sign.top && |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
1613 |
y < wp->sign.top + 12 && |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
1614 |
x >= wp->sign.left && |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
1615 |
x < wp->sign.left + wp->sign.width_1) { |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
1616 |
ShowRenameWaypointWindow(wp); |
0 | 1617 |
return true; |
1618 |
} |
|
1619 |
} |
|
1620 |
} else if (vp->zoom == 1) { |
|
1621 |
x = (x - vp->left + 1) * 2 + vp->virtual_left; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1622 |
y = (y - vp->top + 1) * 2 + vp->virtual_top; |
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
1623 |
FOR_ALL_WAYPOINTS(wp) { |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
1624 |
if (wp->xy && |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
1625 |
y >= wp->sign.top && |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
1626 |
y < wp->sign.top + 24 && |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
1627 |
x >= wp->sign.left && |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
1628 |
x < wp->sign.left + wp->sign.width_1 * 2) { |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
1629 |
ShowRenameWaypointWindow(wp); |
0 | 1630 |
return true; |
1631 |
} |
|
1632 |
} |
|
1633 |
} else { |
|
1634 |
x = (x - vp->left + 3) * 4 + vp->virtual_left; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1635 |
y = (y - vp->top + 3) * 4 + vp->virtual_top; |
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
1636 |
FOR_ALL_WAYPOINTS(wp) { |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
1637 |
if (wp->xy && |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
1638 |
y >= wp->sign.top && |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
1639 |
y < wp->sign.top + 24 && |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
1640 |
x >= wp->sign.left && |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
1641 |
x < wp->sign.left + wp->sign.width_2 * 4) { |
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
1642 |
ShowRenameWaypointWindow(wp); |
0 | 1643 |
return true; |
1644 |
} |
|
1645 |
} |
|
1646 |
} |
|
1647 |
||
1648 |
return false; |
|
1649 |
} |
|
1650 |
||
1651 |
||
2116 | 1652 |
static void CheckClickOnLandscape(const ViewPort *vp, int x, int y) |
0 | 1653 |
{ |
2116 | 1654 |
Point pt = TranslateXYToTileCoord(vp, x, y); |
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1964
diff
changeset
|
1655 |
|
1980
6c5917cfcb78
(svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY
tron
parents:
1977
diff
changeset
|
1656 |
if (pt.x != -1) ClickTile(TileVirtXY(pt.x, pt.y)); |
0 | 1657 |
} |
1658 |
||
2662
8b46824bd821
(svn r3204) Make handling of clicking on vehicles a bit less ugly by avoiding function declarations in .c files and unnecessary indirection
tron
parents:
2484
diff
changeset
|
1659 |
|
8b46824bd821
(svn r3204) Make handling of clicking on vehicles a bit less ugly by avoiding function declarations in .c files and unnecessary indirection
tron
parents:
2484
diff
changeset
|
1660 |
static void SafeShowTrainViewWindow(const Vehicle* v) |
8b46824bd821
(svn r3204) Make handling of clicking on vehicles a bit less ugly by avoiding function declarations in .c files and unnecessary indirection
tron
parents:
2484
diff
changeset
|
1661 |
{ |
2676
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
2662
diff
changeset
|
1662 |
if (!IsFrontEngine(v)) v = GetFirstVehicleInChain(v); |
2662
8b46824bd821
(svn r3204) Make handling of clicking on vehicles a bit less ugly by avoiding function declarations in .c files and unnecessary indirection
tron
parents:
2484
diff
changeset
|
1663 |
ShowTrainViewWindow(v); |
8b46824bd821
(svn r3204) Make handling of clicking on vehicles a bit less ugly by avoiding function declarations in .c files and unnecessary indirection
tron
parents:
2484
diff
changeset
|
1664 |
} |
8b46824bd821
(svn r3204) Make handling of clicking on vehicles a bit less ugly by avoiding function declarations in .c files and unnecessary indirection
tron
parents:
2484
diff
changeset
|
1665 |
|
8b46824bd821
(svn r3204) Make handling of clicking on vehicles a bit less ugly by avoiding function declarations in .c files and unnecessary indirection
tron
parents:
2484
diff
changeset
|
1666 |
static void Nop(const Vehicle* v) {} |
8b46824bd821
(svn r3204) Make handling of clicking on vehicles a bit less ugly by avoiding function declarations in .c files and unnecessary indirection
tron
parents:
2484
diff
changeset
|
1667 |
|
8b46824bd821
(svn r3204) Make handling of clicking on vehicles a bit less ugly by avoiding function declarations in .c files and unnecessary indirection
tron
parents:
2484
diff
changeset
|
1668 |
typedef void OnVehicleClickProc(const Vehicle* v); |
8b46824bd821
(svn r3204) Make handling of clicking on vehicles a bit less ugly by avoiding function declarations in .c files and unnecessary indirection
tron
parents:
2484
diff
changeset
|
1669 |
static OnVehicleClickProc* const _on_vehicle_click_proc[] = { |
8b46824bd821
(svn r3204) Make handling of clicking on vehicles a bit less ugly by avoiding function declarations in .c files and unnecessary indirection
tron
parents:
2484
diff
changeset
|
1670 |
SafeShowTrainViewWindow, |
8b46824bd821
(svn r3204) Make handling of clicking on vehicles a bit less ugly by avoiding function declarations in .c files and unnecessary indirection
tron
parents:
2484
diff
changeset
|
1671 |
ShowRoadVehViewWindow, |
8b46824bd821
(svn r3204) Make handling of clicking on vehicles a bit less ugly by avoiding function declarations in .c files and unnecessary indirection
tron
parents:
2484
diff
changeset
|
1672 |
ShowShipViewWindow, |
8b46824bd821
(svn r3204) Make handling of clicking on vehicles a bit less ugly by avoiding function declarations in .c files and unnecessary indirection
tron
parents:
2484
diff
changeset
|
1673 |
ShowAircraftViewWindow, |
8b46824bd821
(svn r3204) Make handling of clicking on vehicles a bit less ugly by avoiding function declarations in .c files and unnecessary indirection
tron
parents:
2484
diff
changeset
|
1674 |
Nop, // Special vehicles |
8b46824bd821
(svn r3204) Make handling of clicking on vehicles a bit less ugly by avoiding function declarations in .c files and unnecessary indirection
tron
parents:
2484
diff
changeset
|
1675 |
Nop // Disaster vehicles |
0 | 1676 |
}; |
1677 |
||
2116 | 1678 |
void HandleViewportClicked(const ViewPort *vp, int x, int y) |
0 | 1679 |
{ |
2662
8b46824bd821
(svn r3204) Make handling of clicking on vehicles a bit less ugly by avoiding function declarations in .c files and unnecessary indirection
tron
parents:
2484
diff
changeset
|
1680 |
const Vehicle* v; |
0 | 1681 |
|
2116 | 1682 |
if (CheckClickOnTown(vp, x, y)) return; |
1683 |
if (CheckClickOnStation(vp, x, y)) return; |
|
1684 |
if (CheckClickOnSign(vp, x, y)) return; |
|
1685 |
if (CheckClickOnWaypoint(vp, x, y)) return; |
|
0 | 1686 |
CheckClickOnLandscape(vp, x, y); |
1687 |
||
2116 | 1688 |
v = CheckClickOnVehicle(vp, x, y); |
1689 |
if (v != NULL) _on_vehicle_click_proc[v->type - 0x10](v); |
|
0 | 1690 |
} |
1691 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1083
diff
changeset
|
1692 |
Vehicle *CheckMouseOverVehicle(void) |
0 | 1693 |
{ |
2116 | 1694 |
const Window* w; |
1695 |
const ViewPort* vp; |
|
0 | 1696 |
|
1697 |
int x = _cursor.pos.x; |
|
1698 |
int y = _cursor.pos.y; |
|
1699 |
||
1700 |
w = FindWindowFromPt(x, y); |
|
2116 | 1701 |
if (w == NULL) return NULL; |
0 | 1702 |
|
1703 |
vp = IsPtInWindowViewport(w, x, y); |
|
2116 | 1704 |
return (vp != NULL) ? CheckClickOnVehicle(vp, x, y) : NULL; |
0 | 1705 |
} |
1706 |
||
1707 |
||
1708 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1083
diff
changeset
|
1709 |
void PlaceObject(void) |
0 | 1710 |
{ |
1711 |
Point pt; |
|
1712 |
Window *w; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1713 |
|
0 | 1714 |
pt = GetTileBelowCursor(); |
2116 | 1715 |
if (pt.x == -1) return; |
0 | 1716 |
|
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1717 |
if (_thd.place_mode == VHM_POINT) { |
0 | 1718 |
pt.x += 8; |
1719 |
pt.y += 8; |
|
1720 |
} |
|
1721 |
||
1722 |
_tile_fract_coords.x = pt.x & 0xF; |
|
1723 |
_tile_fract_coords.y = pt.y & 0xF; |
|
1724 |
||
2116 | 1725 |
w = GetCallbackWnd(); |
1726 |
if (w != NULL) { |
|
1727 |
WindowEvent e; |
|
1728 |
||
0 | 1729 |
e.event = WE_PLACE_OBJ; |
1730 |
e.place.pt = pt; |
|
1980
6c5917cfcb78
(svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY
tron
parents:
1977
diff
changeset
|
1731 |
e.place.tile = TileVirtXY(pt.x, pt.y); |
0 | 1732 |
w->wndproc(w, &e); |
1733 |
} |
|
1734 |
} |
|
1735 |
||
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:
137
diff
changeset
|
1736 |
|
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:
137
diff
changeset
|
1737 |
/* scrolls the viewport in a window to a given location */ |
2116 | 1738 |
bool ScrollWindowTo(int x , int y, 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:
137
diff
changeset
|
1739 |
{ |
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:
137
diff
changeset
|
1740 |
Point pt; |
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:
137
diff
changeset
|
1741 |
|
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:
137
diff
changeset
|
1742 |
pt = MapXYZToViewport(w->viewport, x, y, GetSlopeZ(x, y)); |
2116 | 1743 |
WP(w, vp_d).follow_vehicle = INVALID_VEHICLE; |
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:
137
diff
changeset
|
1744 |
|
2116 | 1745 |
if (WP(w, vp_d).scrollpos_x == pt.x && WP(w, vp_d).scrollpos_y == pt.y) |
1746 |
return false; |
|
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:
137
diff
changeset
|
1747 |
|
2116 | 1748 |
WP(w, vp_d).scrollpos_x = pt.x; |
1749 |
WP(w, vp_d).scrollpos_y = pt.y; |
|
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:
137
diff
changeset
|
1750 |
return true; |
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:
137
diff
changeset
|
1751 |
} |
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:
137
diff
changeset
|
1752 |
|
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:
137
diff
changeset
|
1753 |
|
0 | 1754 |
bool ScrollMainWindowTo(int x, int y) |
1755 |
{ |
|
2116 | 1756 |
return ScrollWindowTo(x, y, FindWindowById(WC_MAIN_WINDOW, 0)); |
0 | 1757 |
} |
1758 |
||
1759 |
||
1760 |
bool ScrollMainWindowToTile(TileIndex tile) |
|
1761 |
{ |
|
3421
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1762 |
return ScrollMainWindowTo(TileX(tile) * TILE_SIZE + 8, TileY(tile) * TILE_SIZE + 8); |
0 | 1763 |
} |
1764 |
||
1765 |
void SetRedErrorSquare(TileIndex tile) |
|
1766 |
{ |
|
1767 |
TileIndex old; |
|
1768 |
||
1769 |
old = _thd.redsq; |
|
1770 |
_thd.redsq = tile; |
|
1771 |
||
1772 |
if (tile != old) { |
|
3281
757d7da49445
(svn r3995) -Fix: Committed one file too much in 3992 (Thanks to Tron for pointing it out)
celestar
parents:
3279
diff
changeset
|
1773 |
if (tile != 0) MarkTileDirtyByTile(tile); |
757d7da49445
(svn r3995) -Fix: Committed one file too much in 3992 (Thanks to Tron for pointing it out)
celestar
parents:
3279
diff
changeset
|
1774 |
if (old != 0) MarkTileDirtyByTile(old); |
0 | 1775 |
} |
1776 |
} |
|
1777 |
||
1778 |
void SetTileSelectSize(int w, int h) |
|
1779 |
{ |
|
3421
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1780 |
_thd.new_size.x = w * TILE_SIZE; |
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1781 |
_thd.new_size.y = h * TILE_SIZE; |
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1782 |
_thd.new_outersize.x = 0; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1783 |
_thd.new_outersize.y = 0; |
0 | 1784 |
} |
1785 |
||
2116 | 1786 |
void SetTileSelectBigSize(int ox, int oy, int sx, int sy) |
1787 |
{ |
|
3421
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1788 |
_thd.offs.x = ox * TILE_SIZE; |
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1789 |
_thd.offs.y = oy * TILE_SIZE; |
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1790 |
_thd.new_outersize.x = sx * TILE_SIZE; |
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1791 |
_thd.new_outersize.y = sy * TILE_SIZE; |
0 | 1792 |
} |
1793 |
||
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1794 |
/* returns the best autorail highlight type from map coordinates */ |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1795 |
static byte GetAutorailHT(int x, int y) |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1796 |
{ |
2710
44278abd3ef9
(svn r3254) - Fix: graphical glitch with autorail tool on a certain tile-type.
Darkvater
parents:
2676
diff
changeset
|
1797 |
return HT_RAIL | _AutorailPiece[x & 0xF][y & 0xF]; |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1798 |
} |
0 | 1799 |
|
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1800 |
// called regular to update tile highlighting in all cases |
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1083
diff
changeset
|
1801 |
void UpdateTileSelection(void) |
0 | 1802 |
{ |
2116 | 1803 |
int x1; |
1804 |
int y1; |
|
0 | 1805 |
|
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1806 |
_thd.new_drawstyle = 0; |
0 | 1807 |
|
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1808 |
if (_thd.place_mode == VHM_SPECIAL) { |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1809 |
x1 = _thd.selend.x; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1810 |
y1 = _thd.selend.y; |
0 | 1811 |
if (x1 != -1) { |
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1812 |
int x2 = _thd.selstart.x; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1813 |
int y2 = _thd.selstart.y; |
0 | 1814 |
x1 &= ~0xF; |
1815 |
y1 &= ~0xF; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1816 |
|
0 | 1817 |
if (x1 >= x2) intswap(x1,x2); |
1818 |
if (y1 >= y2) intswap(y1,y2); |
|
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1819 |
_thd.new_pos.x = x1; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1820 |
_thd.new_pos.y = y1; |
3421
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1821 |
_thd.new_size.x = x2 - x1 + TILE_SIZE; |
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1822 |
_thd.new_size.y = y2 - y1 + TILE_SIZE; |
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1823 |
_thd.new_drawstyle = _thd.next_drawstyle; |
0 | 1824 |
} |
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1825 |
} else if (_thd.place_mode != VHM_NONE) { |
2116 | 1826 |
Point pt = GetTileBelowCursor(); |
0 | 1827 |
x1 = pt.x; |
1828 |
y1 = pt.y; |
|
1829 |
if (x1 != -1) { |
|
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1830 |
switch (_thd.place_mode) { |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1831 |
case VHM_RECT: |
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1832 |
_thd.new_drawstyle = HT_RECT; |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1833 |
break; |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1834 |
case VHM_POINT: |
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1835 |
_thd.new_drawstyle = HT_POINT; |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1836 |
x1 += 8; |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1837 |
y1 += 8; |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1838 |
break; |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1839 |
case VHM_RAIL: |
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1840 |
_thd.new_drawstyle = GetAutorailHT(pt.x, pt.y); // draw one highlighted tile |
0 | 1841 |
} |
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1842 |
_thd.new_pos.x = x1 & ~0xF; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1843 |
_thd.new_pos.y = y1 & ~0xF; |
0 | 1844 |
} |
1845 |
} |
|
1846 |
||
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1847 |
// redraw selection |
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1848 |
if (_thd.drawstyle != _thd.new_drawstyle || |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1849 |
_thd.pos.x != _thd.new_pos.x || _thd.pos.y != _thd.new_pos.y || |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1850 |
_thd.size.x != _thd.new_size.x || _thd.size.y != _thd.new_size.y) { |
0 | 1851 |
// clear the old selection? |
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1852 |
if (_thd.drawstyle) SetSelectionTilesDirty(); |
0 | 1853 |
|
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1854 |
_thd.drawstyle = _thd.new_drawstyle; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1855 |
_thd.pos = _thd.new_pos; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1856 |
_thd.size = _thd.new_size; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1857 |
_thd.outersize = _thd.new_outersize; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1858 |
_thd.dirty = 0xff; |
0 | 1859 |
|
1860 |
// draw the new selection? |
|
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1861 |
if (_thd.new_drawstyle) SetSelectionTilesDirty(); |
0 | 1862 |
} |
1863 |
} |
|
1864 |
||
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1865 |
// highlighting tiles while only going over them with the mouse |
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1964
diff
changeset
|
1866 |
void VpStartPlaceSizing(TileIndex tile, int user) |
0 | 1867 |
{ |
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1868 |
_thd.userdata = user; |
3421
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1869 |
_thd.selend.x = TileX(tile) * TILE_SIZE; |
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1870 |
_thd.selstart.x = TileX(tile) * TILE_SIZE; |
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1871 |
_thd.selend.y = TileY(tile) * TILE_SIZE; |
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1872 |
_thd.selstart.y = TileY(tile) * TILE_SIZE; |
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1873 |
if (_thd.place_mode == VHM_RECT) { |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1874 |
_thd.place_mode = VHM_SPECIAL; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1875 |
_thd.next_drawstyle = HT_RECT; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1876 |
} else if (_thd.place_mode == VHM_RAIL) { // autorail one piece |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1877 |
_thd.place_mode = VHM_SPECIAL; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1878 |
_thd.next_drawstyle = _thd.drawstyle; |
0 | 1879 |
} else { |
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1880 |
_thd.place_mode = VHM_SPECIAL; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1881 |
_thd.next_drawstyle = HT_POINT; |
0 | 1882 |
} |
1883 |
_special_mouse_mode = WSM_SIZING; |
|
1884 |
} |
|
1885 |
||
1886 |
void VpSetPlaceSizingLimit(int limit) |
|
1887 |
{ |
|
1888 |
_thd.sizelimit = limit; |
|
1889 |
} |
|
1890 |
||
1891 |
void VpSetPresizeRange(uint from, uint to) |
|
1892 |
{ |
|
3421
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1893 |
_thd.selend.x = TileX(to) * TILE_SIZE; |
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1894 |
_thd.selend.y = TileY(to) * TILE_SIZE; |
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1895 |
_thd.selstart.x = TileX(from) * TILE_SIZE; |
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1896 |
_thd.selstart.y = TileY(from) * TILE_SIZE; |
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1897 |
_thd.next_drawstyle = HT_RECT; |
0 | 1898 |
} |
1899 |
||
2817 | 1900 |
static void VpStartPreSizing(void) |
0 | 1901 |
{ |
1902 |
_thd.selend.x = -1; |
|
1903 |
_special_mouse_mode = WSM_PRESIZE; |
|
1904 |
} |
|
1905 |
||
1109
ecb98f43ba2c
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1095
diff
changeset
|
1906 |
/* returns information about the 2x1 piece to be build. |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1907 |
* The lower bits (0-3) are the track type. */ |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1908 |
static byte Check2x1AutoRail(int mode) |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1909 |
{ |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1910 |
int fxpy = _tile_fract_coords.x + _tile_fract_coords.y; |
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1911 |
int sxpy = (_thd.selend.x & 0xF) + (_thd.selend.y & 0xF); |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1912 |
int fxmy = _tile_fract_coords.x - _tile_fract_coords.y; |
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1913 |
int sxmy = (_thd.selend.x & 0xF) - (_thd.selend.y & 0xF); |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1914 |
|
2952 | 1915 |
switch (mode) { |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1916 |
case 0: // end piece is lower right |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1917 |
if (fxpy >= 20 && sxpy <= 12) { /*SwapSelection(); DoRailroadTrack(0); */return 3; } |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1918 |
if (fxmy < -3 && sxmy > 3) {/* DoRailroadTrack(0); */return 5; } |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1919 |
return 1; |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1920 |
|
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1921 |
case 1: |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1922 |
if (fxmy > 3 && sxmy < -3) { /*SwapSelection(); DoRailroadTrack(0); */return 4; } |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1923 |
if (fxpy <= 12 && sxpy >= 20) { /*DoRailroadTrack(0); */return 2; } |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1924 |
return 1; |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1925 |
|
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1926 |
case 2: |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1927 |
if (fxmy > 3 && sxmy < -3) { /*DoRailroadTrack(3);*/ return 4; } |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1928 |
if (fxpy >= 20 && sxpy <= 12) { /*SwapSelection(); DoRailroadTrack(0); */return 3; } |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1929 |
return 0; |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1930 |
|
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1931 |
case 3: |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1932 |
if (fxmy < -3 && sxmy > 3) { /*SwapSelection(); DoRailroadTrack(3);*/ return 5; } |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1933 |
if (fxpy <= 12 && sxpy >= 20) { /*DoRailroadTrack(0); */return 2; } |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1934 |
return 0; |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1935 |
} |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1936 |
|
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1937 |
return 0; // avoids compiler warnings |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1938 |
} |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1939 |
|
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1940 |
|
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1941 |
// while dragging |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1942 |
static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y, int method) |
0 | 1943 |
{ |
1944 |
int d; |
|
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1945 |
byte b=6; |
0 | 1946 |
uint w,h; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1947 |
|
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1948 |
int dx = thd->selstart.x - (thd->selend.x&~0xF); |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1949 |
int dy = thd->selstart.y - (thd->selend.y&~0xF); |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1950 |
w = myabs(dx) + 16; |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1951 |
h = myabs(dy) + 16; |
0 | 1952 |
|
1980
6c5917cfcb78
(svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY
tron
parents:
1977
diff
changeset
|
1953 |
if (TileVirtXY(thd->selstart.x, thd->selstart.y) == TileVirtXY(x, y)) { // check if we're only within one tile |
2116 | 1954 |
if (method == VPM_RAILDIRS) |
1955 |
b = GetAutorailHT(x, y); |
|
1956 |
else // rect for autosignals on one tile |
|
1957 |
b = HT_RECT; |
|
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1958 |
} else if (h == 16) { // Is this in X direction? |
2116 | 1959 |
if (dx == 16) // 2x1 special handling |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1960 |
b = (Check2x1AutoRail(3)) | HT_LINE; |
2116 | 1961 |
else if (dx == -16) |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1962 |
b = (Check2x1AutoRail(2)) | HT_LINE; |
1109
ecb98f43ba2c
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1095
diff
changeset
|
1963 |
else |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1964 |
b = HT_LINE | HT_DIR_X; |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1965 |
y = thd->selstart.y; |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1966 |
} else if (w == 16) { // Or Y direction? |
2116 | 1967 |
if (dy == 16) // 2x1 special handling |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1968 |
b = (Check2x1AutoRail(1)) | HT_LINE; |
2116 | 1969 |
else if (dy == -16) // 2x1 other direction |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1970 |
b = (Check2x1AutoRail(0)) | HT_LINE; |
1109
ecb98f43ba2c
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1095
diff
changeset
|
1971 |
else |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1972 |
b = HT_LINE | HT_DIR_Y; |
0 | 1973 |
x = thd->selstart.x; |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1974 |
} else if (w > h * 2) { // still count as x dir? |
2116 | 1975 |
b = HT_LINE | HT_DIR_X; |
0 | 1976 |
y = thd->selstart.y; |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1977 |
} else if (h > w * 2) { // still count as y dir? |
2116 | 1978 |
b = HT_LINE | HT_DIR_Y; |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1979 |
x = thd->selstart.x; |
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
1980 |
} else { // complicated direction |
0 | 1981 |
d = w - h; |
2116 | 1982 |
thd->selend.x = thd->selend.x & ~0xF; |
1983 |
thd->selend.y = thd->selend.y & ~0xF; |
|
0 | 1984 |
|
1985 |
// four cases. |
|
1986 |
if (x > thd->selstart.x) { |
|
1987 |
if (y > thd->selstart.y) { |
|
1988 |
// south |
|
2116 | 1989 |
if (d == 0) { |
1990 |
b = (x & 0xF) > (y & 0xF) ? HT_LINE | HT_DIR_VL : HT_LINE | HT_DIR_VR; |
|
1991 |
} else if (d >= 0) { |
|
1992 |
x = thd->selstart.x + h; |
|
1993 |
b = HT_LINE | HT_DIR_VL; |
|
1994 |
// return px == py || px == py + 16; |
|
1995 |
} else { |
|
1996 |
y = thd->selstart.y + w; |
|
1997 |
b = HT_LINE | HT_DIR_VR; |
|
1998 |
} // return px == py || px == py - 16; |
|
0 | 1999 |
} else { |
2000 |
// west |
|
2116 | 2001 |
if (d == 0) { |
2002 |
b = (x & 0xF) + (y & 0xF) >= 0x10 ? HT_LINE | HT_DIR_HL : HT_LINE | HT_DIR_HU; |
|
2003 |
} else if (d >= 0) { |
|
2004 |
x = thd->selstart.x + h; |
|
2005 |
b = HT_LINE | HT_DIR_HL; |
|
2006 |
} else { |
|
2007 |
y = thd->selstart.y - w; |
|
2008 |
b = HT_LINE | HT_DIR_HU; |
|
2009 |
} |
|
0 | 2010 |
} |
2011 |
} else { |
|
2012 |
if (y > thd->selstart.y) { |
|
2013 |
// east |
|
2116 | 2014 |
if (d == 0) { |
2015 |
b = (x & 0xF) + (y & 0xF) >= 0x10 ? HT_LINE | HT_DIR_HL : HT_LINE | HT_DIR_HU; |
|
2016 |
} else if (d >= 0) { |
|
2017 |
x = thd->selstart.x - h; |
|
2018 |
b = HT_LINE | HT_DIR_HU; |
|
2019 |
// return px == -py || px == -py - 16; |
|
2020 |
} else { |
|
2021 |
y = thd->selstart.y + w; |
|
2022 |
b = HT_LINE | HT_DIR_HL; |
|
2023 |
} // return px == -py || px == -py + 16; |
|
0 | 2024 |
} else { |
2025 |
// north |
|
2116 | 2026 |
if (d == 0) { |
2027 |
b = (x & 0xF) > (y & 0xF) ? HT_LINE | HT_DIR_VL : HT_LINE | HT_DIR_VR; |
|
2028 |
} else if (d >= 0) { |
|
2029 |
x = thd->selstart.x - h; |
|
2030 |
b = HT_LINE | HT_DIR_VR; |
|
2031 |
// return px == py || px == py - 16; |
|
2032 |
} else { |
|
2033 |
y = thd->selstart.y - w; |
|
2034 |
b = HT_LINE | HT_DIR_VL; |
|
2035 |
} //return px == py || px == py + 16; |
|
0 | 2036 |
} |
2037 |
} |
|
2038 |
} |
|
2039 |
thd->selend.x = x; |
|
2040 |
thd->selend.y = y; |
|
2041 |
thd->next_drawstyle = b; |
|
2042 |
} |
|
2043 |
||
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2044 |
// while dragging |
0 | 2045 |
void VpSelectTilesWithMethod(int x, int y, int method) |
2046 |
{ |
|
2116 | 2047 |
int sx; |
2048 |
int sy; |
|
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2049 |
|
0 | 2050 |
if (x == -1) { |
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2051 |
_thd.selend.x = -1; |
0 | 2052 |
return; |
2053 |
} |
|
2054 |
||
2055 |
// allow drag in any rail direction |
|
58
b9fdcc9b5c90
(svn r59) -Feature: Added Autosignals, just like Autorail. Can copy signal style, convert signal<->semaphore, etc. Big thanks to betatesters Dribbel and Testman57 (Darkvater)
darkvater
parents:
0
diff
changeset
|
2056 |
if (method == VPM_RAILDIRS || method == VPM_SIGNALDIRS) { |
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2057 |
_thd.selend.x = x; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2058 |
_thd.selend.y = y; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2059 |
CalcRaildirsDrawstyle(&_thd, x, y, method); |
0 | 2060 |
return; |
2061 |
} |
|
2062 |
||
2116 | 2063 |
if (_thd.next_drawstyle == HT_POINT) { |
2064 |
x += 8; |
|
2065 |
y += 8; |
|
2066 |
} |
|
0 | 2067 |
|
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2068 |
sx = _thd.selstart.x; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2069 |
sy = _thd.selstart.y; |
0 | 2070 |
|
2116 | 2071 |
switch (method) { |
2072 |
case VPM_FIX_X: |
|
2073 |
x = sx; |
|
2074 |
break; |
|
0 | 2075 |
|
2116 | 2076 |
case VPM_FIX_Y: |
2077 |
y = sy; |
|
2078 |
break; |
|
0 | 2079 |
|
2116 | 2080 |
case VPM_X_OR_Y: |
2081 |
if (myabs(sy - y) < myabs(sx - x)) y = sy; else x = sx; |
|
2082 |
break; |
|
2083 |
||
2084 |
case VPM_X_AND_Y: |
|
2085 |
break; |
|
2086 |
||
2087 |
// limit the selected area to a 10x10 rect. |
|
2088 |
case VPM_X_AND_Y_LIMITED: { |
|
2089 |
int limit = (_thd.sizelimit - 1) * 16; |
|
2090 |
x = sx + clamp(x - sx, -limit, limit); |
|
2091 |
y = sy + clamp(y - sy, -limit, limit); |
|
2092 |
break; |
|
2093 |
} |
|
0 | 2094 |
} |
2095 |
||
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2096 |
_thd.selend.x = x; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2097 |
_thd.selend.y = y; |
0 | 2098 |
} |
2099 |
||
1109
ecb98f43ba2c
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1095
diff
changeset
|
2100 |
// while dragging |
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1083
diff
changeset
|
2101 |
bool VpHandlePlaceSizingDrag(void) |
0 | 2102 |
{ |
2103 |
Window *w; |
|
2104 |
WindowEvent e; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
2105 |
|
2116 | 2106 |
if (_special_mouse_mode != WSM_SIZING) return true; |
0 | 2107 |
|
2108 |
e.place.userdata = _thd.userdata; |
|
2109 |
||
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2110 |
// stop drag mode if the window has been closed |
0 | 2111 |
w = FindWindowById(_thd.window_class,_thd.window_number); |
2112 |
if (w == NULL) { |
|
2113 |
ResetObjectToPlace(); |
|
2114 |
return false; |
|
2115 |
} |
|
2116 |
||
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2117 |
// while dragging execute the drag procedure of the corresponding window (mostly VpSelectTilesWithMethod() ) |
0 | 2118 |
if (_left_button_down) { |
2119 |
e.event = WE_PLACE_DRAG; |
|
2120 |
e.place.pt = GetTileBelowCursor(); |
|
2121 |
w->wndproc(w, &e); |
|
2122 |
return false; |
|
2123 |
} |
|
2124 |
||
2125 |
// mouse button released.. |
|
2126 |
// keep the selected tool, but reset it to the original mode. |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
2127 |
_special_mouse_mode = WSM_NONE; |
2116 | 2128 |
if (_thd.next_drawstyle == HT_RECT) { |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2129 |
_thd.place_mode = VHM_RECT; |
2116 | 2130 |
} else if ((e.place.userdata & 0xF) == VPM_SIGNALDIRS) { // some might call this a hack... -- Dominik |
2131 |
_thd.place_mode = VHM_RECT; |
|
2132 |
} else if (_thd.next_drawstyle & HT_LINE) { |
|
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2133 |
_thd.place_mode = VHM_RAIL; |
2116 | 2134 |
} else if (_thd.next_drawstyle & HT_RAIL) { |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2135 |
_thd.place_mode = VHM_RAIL; |
2116 | 2136 |
} else { |
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2137 |
_thd.place_mode = VHM_POINT; |
2116 | 2138 |
} |
0 | 2139 |
SetTileSelectSize(1, 1); |
2140 |
||
2141 |
// and call the mouseup event. |
|
2142 |
e.event = WE_PLACE_MOUSEUP; |
|
2143 |
e.place.pt = _thd.selend; |
|
1980
6c5917cfcb78
(svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY
tron
parents:
1977
diff
changeset
|
2144 |
e.place.tile = TileVirtXY(e.place.pt.x, e.place.pt.y); |
6c5917cfcb78
(svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY
tron
parents:
1977
diff
changeset
|
2145 |
e.place.starttile = TileVirtXY(_thd.selstart.x, _thd.selstart.y); |
0 | 2146 |
w->wndproc(w, &e); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
2147 |
|
0 | 2148 |
return false; |
2149 |
} |
|
2150 |
||
1914
2b4b3c3a95b4
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
2151 |
void SetObjectToPlaceWnd(CursorID icon, byte mode, Window *w) |
0 | 2152 |
{ |
1914
2b4b3c3a95b4
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
2153 |
SetObjectToPlace(icon, mode, w->window_class, w->window_number); |
0 | 2154 |
} |
2155 |
||
2156 |
#include "table/animcursors.h" |
|
2157 |
||
1914
2b4b3c3a95b4
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
2158 |
void SetObjectToPlace(CursorID icon, byte mode, WindowClass window_class, WindowNumber window_num) |
0 | 2159 |
{ |
2160 |
Window *w; |
|
2161 |
||
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2162 |
// undo clicking on button |
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2163 |
if (_thd.place_mode != 0) { |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2164 |
_thd.place_mode = 0; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2165 |
w = FindWindowById(_thd.window_class, _thd.window_number); |
2116 | 2166 |
if (w != NULL) CallWindowEventNP(w, WE_ABORT_PLACE_OBJ); |
0 | 2167 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
2168 |
|
0 | 2169 |
SetTileSelectSize(1, 1); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
2170 |
|
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2171 |
_thd.make_square_red = false; |
0 | 2172 |
|
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2173 |
if (mode == VHM_DRAG) { // mode 4 is for dragdropping trains in the depot window |
0 | 2174 |
mode = 0; |
2175 |
_special_mouse_mode = WSM_DRAGDROP; |
|
2176 |
} else { |
|
2177 |
_special_mouse_mode = WSM_NONE; |
|
2178 |
} |
|
2179 |
||
1863
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2180 |
_thd.place_mode = mode; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2181 |
_thd.window_class = window_class; |
74a8379bb868
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2182 |
_thd.window_number = window_num; |
0 | 2183 |
|
1070
bd31ed783fd3
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2184 |
if (mode == VHM_SPECIAL) // special tools, like tunnels or docks start with presizing mode |
0 | 2185 |
VpStartPreSizing(); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
2186 |
|
0 | 2187 |
if ( (int)icon < 0) |
2484
0e45d70ae908
(svn r3010) Get rid of quite some dubious casts, either by using GB(), proper types or just removing them
tron
parents:
2482
diff
changeset
|
2188 |
SetAnimatedMouseCursor(_animcursors[~icon]); |
0 | 2189 |
else |
2190 |
SetMouseCursor(icon); |
|
2191 |
} |
|
2192 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1083
diff
changeset
|
2193 |
void ResetObjectToPlace(void) |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1083
diff
changeset
|
2194 |
{ |
1914
2b4b3c3a95b4
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
2195 |
SetObjectToPlace(SPR_CURSOR_MOUSE, 0, 0, 0); |
0 | 2196 |
} |