author | rubidium |
Mon, 19 May 2008 09:24:03 +0000 | |
changeset 10638 | 1234ac29df11 |
parent 10596 | 0ee9eba64c9c |
child 10703 | 2c998f3776d1 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
10429
1b99254f9607
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
10399
diff
changeset
|
3 |
/** @file viewport.cpp Handling of all viewports. |
10217
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
4 |
* |
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
5 |
* \verbatim |
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
6 |
* The in-game coordinate system looks like this * |
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
7 |
* * |
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
8 |
* ^ Z * |
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
9 |
* | * |
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
10 |
* | * |
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
11 |
* | * |
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
12 |
* | * |
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
13 |
* / \ * |
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
14 |
* / \ * |
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
15 |
* / \ * |
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
16 |
* / \ * |
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
17 |
* X < > Y * |
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
18 |
* \endverbatim |
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
19 |
*/ |
6443
b8f06d8eb7be
(svn r8853) -Cleanup: doxygen changes. Correct forgotten c files to cpp files with the @file tag as well as a few general comments style
belugas
parents:
6432
diff
changeset
|
20 |
|
0 | 21 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1864
diff
changeset
|
22 |
#include "openttd.h" |
1299
0a6510cc889b
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1172
diff
changeset
|
23 |
#include "debug.h" |
8615
6b91ca653bad
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
8610
diff
changeset
|
24 |
#include "tile_cmd.h" |
2662
42c11a1a0a4b
(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
|
25 |
#include "gui.h" |
1349
07514c2cc6d1
(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
|
26 |
#include "spritecache.h" |
6949
72d11a1e1e60
(svn r9609) -Codechange: Move some function prototypes out of functions.h and into landscape.h, and add a few where they didn't exist.
maedhros
parents:
6944
diff
changeset
|
27 |
#include "landscape.h" |
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
28 |
#include "viewport_func.h" |
9281
d8cd9ac52a68
(svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
9239
diff
changeset
|
29 |
#include "station_base.h" |
0 | 30 |
#include "town.h" |
9286 | 31 |
#include "signs_base.h" |
32 |
#include "signs_func.h" |
|
1542
2ca6d1624e6d
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1390
diff
changeset
|
33 |
#include "waypoint.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2125
diff
changeset
|
34 |
#include "variables.h" |
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
2662
diff
changeset
|
35 |
#include "train.h" |
7353
716c6dd9322a
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
7349
diff
changeset
|
36 |
#include "roadveh.h" |
7982
539e32cc37ce
(svn r10997) -Codechange: unify the vehicle view window. Patch by PhilSophus.
rubidium
parents:
7829
diff
changeset
|
37 |
#include "vehicle_gui.h" |
7433
8e410e7ec0d7
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
7374
diff
changeset
|
38 |
#include "blitter/factory.hpp" |
8345
6caa3fdb972c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
8320
diff
changeset
|
39 |
#include "transparency.h" |
8610
17cc343a23dd
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8602
diff
changeset
|
40 |
#include "strings_func.h" |
8619
c2434269c3eb
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents:
8617
diff
changeset
|
41 |
#include "zoom_func.h" |
8640
1e93b81e96d2
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8635
diff
changeset
|
42 |
#include "vehicle_func.h" |
8750
fdd6054e7bae
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8733
diff
changeset
|
43 |
#include "player_func.h" |
8766
c86cfa3a7580
(svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents:
8760
diff
changeset
|
44 |
#include "settings_type.h" |
9281
d8cd9ac52a68
(svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
9239
diff
changeset
|
45 |
#include "station_func.h" |
10164
3ff9e65f3d49
(svn r12695) -Codechange: only allocate window structs when needed. Based on a patch by Alberth.
rubidium
parents:
9302
diff
changeset
|
46 |
#include "core/alloc_type.hpp" |
10205
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
10204
diff
changeset
|
47 |
#include "misc/smallvec.h" |
10435
0e2b98df9707
(svn r12977) -Codechange: remove quite some redundant (duplicate) function declarations.
rubidium
parents:
10429
diff
changeset
|
48 |
#include "window_func.h" |
10445
2dd7d9d0a957
(svn r12987) -Codechange: split viewport and tile selection.
rubidium
parents:
10435
diff
changeset
|
49 |
#include "tilehighlight_func.h" |
10596
0ee9eba64c9c
(svn r13140) -Codechange: move the gui-list-sorting out of window_gui.h so window_gui.h only needs to be included in *_gui.cpp.
rubidium
parents:
10595
diff
changeset
|
50 |
#include "window_gui.h" |
10202
19da84f6725c
(svn r12734) -Codechange: use a vector instead of allocating memory in a big byte array for StringSpriteToDraw.
rubidium
parents:
10164
diff
changeset
|
51 |
|
8760
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
52 |
#include "table/sprites.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
53 |
#include "table/strings.h" |
ce0891c412ce
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8750
diff
changeset
|
54 |
|
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
55 |
PlaceProc *_place_proc; |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
56 |
Point _tile_fract_coords; |
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
57 |
ZoomLevel _saved_scrollpos_zoom; |
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
58 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
59 |
struct StringSpriteToDraw { |
0 | 60 |
uint16 string; |
61 |
uint16 color; |
|
849
c6223dbdb202
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
62 |
int32 x; |
c6223dbdb202
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
63 |
int32 y; |
7502
71f5d2c6a605
(svn r10262) -Fix (r10258): some places that needed to be changed to uint64 were hidden/forgotten, which caused memory corruptions and that in caused all kinds of assertions to trigger.
rubidium
parents:
7433
diff
changeset
|
64 |
uint64 params[2]; |
0 | 65 |
uint16 width; |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
66 |
}; |
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
67 |
|
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
68 |
struct TileSpriteToDraw { |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5853
diff
changeset
|
69 |
SpriteID image; |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5853
diff
changeset
|
70 |
SpriteID pal; |
8177
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
71 |
const SubSprite *sub; ///< only draw a rectangular part of the sprite |
849
c6223dbdb202
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
72 |
int32 x; |
c6223dbdb202
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
73 |
int32 y; |
0 | 74 |
byte z; |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
75 |
}; |
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
76 |
|
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
77 |
struct ChildScreenSpriteToDraw { |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5853
diff
changeset
|
78 |
SpriteID image; |
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5853
diff
changeset
|
79 |
SpriteID pal; |
8177
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
80 |
const SubSprite *sub; ///< only draw a rectangular part of the sprite |
849
c6223dbdb202
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
81 |
int32 x; |
c6223dbdb202
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
82 |
int32 y; |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
83 |
ChildScreenSpriteToDraw *next; |
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
84 |
}; |
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
85 |
|
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
86 |
struct ParentSpriteToDraw { |
8065
1ec515080c33
(svn r11094) -Documentation: Add comments on viewport structures and change an obscure variable name to something a little more meaningfull.
belugas
parents:
8041
diff
changeset
|
87 |
SpriteID image; ///< sprite to draw |
1ec515080c33
(svn r11094) -Documentation: Add comments on viewport structures and change an obscure variable name to something a little more meaningfull.
belugas
parents:
8041
diff
changeset
|
88 |
SpriteID pal; ///< palette to use |
8177
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
89 |
const SubSprite *sub; ///< only draw a rectangular part of the sprite |
8065
1ec515080c33
(svn r11094) -Documentation: Add comments on viewport structures and change an obscure variable name to something a little more meaningfull.
belugas
parents:
8041
diff
changeset
|
90 |
|
8076
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
91 |
int32 x; ///< screen X coordinate of sprite |
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
92 |
int32 y; ///< screen Y coordinate of sprite |
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
93 |
|
8065
1ec515080c33
(svn r11094) -Documentation: Add comments on viewport structures and change an obscure variable name to something a little more meaningfull.
belugas
parents:
8041
diff
changeset
|
94 |
int32 left; ///< minimal screen X coordinate of sprite (= x + sprite->x_offs), reference point for child sprites |
1ec515080c33
(svn r11094) -Documentation: Add comments on viewport structures and change an obscure variable name to something a little more meaningfull.
belugas
parents:
8041
diff
changeset
|
95 |
int32 top; ///< minimal screen Y coordinate of sprite (= y + sprite->y_offs), reference point for child sprites |
1ec515080c33
(svn r11094) -Documentation: Add comments on viewport structures and change an obscure variable name to something a little more meaningfull.
belugas
parents:
8041
diff
changeset
|
96 |
|
1ec515080c33
(svn r11094) -Documentation: Add comments on viewport structures and change an obscure variable name to something a little more meaningfull.
belugas
parents:
8041
diff
changeset
|
97 |
int32 xmin; ///< minimal world X coordinate of bounding box |
1ec515080c33
(svn r11094) -Documentation: Add comments on viewport structures and change an obscure variable name to something a little more meaningfull.
belugas
parents:
8041
diff
changeset
|
98 |
int32 xmax; ///< maximal world X coordinate of bounding box |
1ec515080c33
(svn r11094) -Documentation: Add comments on viewport structures and change an obscure variable name to something a little more meaningfull.
belugas
parents:
8041
diff
changeset
|
99 |
int32 ymin; ///< minimal world Y coordinate of bounding box |
1ec515080c33
(svn r11094) -Documentation: Add comments on viewport structures and change an obscure variable name to something a little more meaningfull.
belugas
parents:
8041
diff
changeset
|
100 |
int32 ymax; ///< maximal world Y coordinate of bounding box |
8076
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
101 |
int zmin; ///< minimal world Z coordinate of bounding box |
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
102 |
int zmax; ///< maximal world Z coordinate of bounding box |
8065
1ec515080c33
(svn r11094) -Documentation: Add comments on viewport structures and change an obscure variable name to something a little more meaningfull.
belugas
parents:
8041
diff
changeset
|
103 |
|
10208
98dc9f65629e
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium
parents:
10207
diff
changeset
|
104 |
int first_child; ///< the first child to draw. |
98dc9f65629e
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium
parents:
10207
diff
changeset
|
105 |
int last_child; ///< the last sprite to draw. |
8076
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
106 |
bool comparison_done; ///< Used during sprite sorting: true if sprite has been compared with all other sprites |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
107 |
}; |
0 | 108 |
|
8265
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
109 |
/* Enumeration of multi-part foundations */ |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
110 |
enum FoundationPart { |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
111 |
FOUNDATION_PART_NONE = 0xFF, ///< Neither foundation nor groundsprite drawn yet. |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
112 |
FOUNDATION_PART_NORMAL = 0, ///< First part (normal foundation or no foundation) |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
113 |
FOUNDATION_PART_HALFTILE = 1, ///< Second part (halftile foundation) |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
114 |
FOUNDATION_PART_END |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
115 |
}; |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
116 |
|
10205
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
10204
diff
changeset
|
117 |
typedef SmallVector<TileSpriteToDraw, 64> TileSpriteToDrawVector; |
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
10204
diff
changeset
|
118 |
typedef SmallVector<StringSpriteToDraw, 4> StringSpriteToDrawVector; |
10207
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
119 |
typedef SmallVector<ParentSpriteToDraw, 64> ParentSpriteToDrawVector; |
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
120 |
typedef SmallVector<ParentSpriteToDraw*, 64> ParentSpriteToSortVector; |
10208
98dc9f65629e
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium
parents:
10207
diff
changeset
|
121 |
typedef SmallVector<ChildScreenSpriteToDraw, 16> ChildScreenSpriteToDrawVector; |
10202
19da84f6725c
(svn r12734) -Codechange: use a vector instead of allocating memory in a big byte array for StringSpriteToDraw.
rubidium
parents:
10164
diff
changeset
|
122 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
123 |
struct ViewportDrawer { |
0 | 124 |
DrawPixelInfo dpi; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
125 |
|
10202
19da84f6725c
(svn r12734) -Codechange: use a vector instead of allocating memory in a big byte array for StringSpriteToDraw.
rubidium
parents:
10164
diff
changeset
|
126 |
StringSpriteToDrawVector string_sprites_to_draw; |
10203
766c98a973c5
(svn r12735) -Codechange: use a vector instead of allocating memory in a byte array for TileSpriteToDraw.
rubidium
parents:
10202
diff
changeset
|
127 |
TileSpriteToDrawVector tile_sprites_to_draw; |
10207
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
128 |
ParentSpriteToDrawVector parent_sprites_to_draw; |
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
129 |
ParentSpriteToSortVector parent_sprites_to_sort; |
10208
98dc9f65629e
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium
parents:
10207
diff
changeset
|
130 |
ChildScreenSpriteToDrawVector child_screen_sprites_to_draw; |
98dc9f65629e
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium
parents:
10207
diff
changeset
|
131 |
|
98dc9f65629e
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium
parents:
10207
diff
changeset
|
132 |
int *last_child; |
0 | 133 |
|
134 |
byte combine_sprites; |
|
135 |
||
10208
98dc9f65629e
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium
parents:
10207
diff
changeset
|
136 |
int foundation[FOUNDATION_PART_END]; ///< Foundation sprites (index into parent_sprites_to_draw). |
98dc9f65629e
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium
parents:
10207
diff
changeset
|
137 |
FoundationPart foundation_part; ///< Currently active foundation for ground sprite drawing. |
98dc9f65629e
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium
parents:
10207
diff
changeset
|
138 |
int *last_foundation_child[FOUNDATION_PART_END]; ///< Tail of ChildSprite list of the foundations. (index into child_screen_sprites_to_draw) |
98dc9f65629e
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium
parents:
10207
diff
changeset
|
139 |
Point foundation_offset[FOUNDATION_PART_END]; ///< Pixeloffset for ground sprites on the foundations. |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
140 |
}; |
0 | 141 |
|
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
142 |
static ViewportDrawer _vd; |
0 | 143 |
|
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
144 |
TileHighlightData _thd; |
0 | 145 |
static TileInfo *_cur_ti; |
10239
a66b15550485
(svn r12771) -Codechange: remove more from variables.h.
rubidium
parents:
10229
diff
changeset
|
146 |
bool _draw_bounding_boxes = false; |
0 | 147 |
|
2116 | 148 |
static Point MapXYZToViewport(const ViewPort *vp, uint x, uint y, uint z) |
0 | 149 |
{ |
150 |
Point p = RemapCoords(x, y, z); |
|
2116 | 151 |
p.x -= vp->virtual_width / 2; |
152 |
p.y -= vp->virtual_height / 2; |
|
0 | 153 |
return p; |
154 |
} |
|
155 |
||
5122
a68d16b055fa
(svn r7202) -Codechange: Move _viewports and _active_viewports local to viewport.c and have them
Darkvater
parents:
5120
diff
changeset
|
156 |
void DeleteWindowViewport(Window *w) |
a68d16b055fa
(svn r7202) -Codechange: Move _viewports and _active_viewports local to viewport.c and have them
Darkvater
parents:
5120
diff
changeset
|
157 |
{ |
10504 | 158 |
free(w->viewport); |
5122
a68d16b055fa
(svn r7202) -Codechange: Move _viewports and _active_viewports local to viewport.c and have them
Darkvater
parents:
5120
diff
changeset
|
159 |
w->viewport = NULL; |
a68d16b055fa
(svn r7202) -Codechange: Move _viewports and _active_viewports local to viewport.c and have them
Darkvater
parents:
5120
diff
changeset
|
160 |
} |
a68d16b055fa
(svn r7202) -Codechange: Move _viewports and _active_viewports local to viewport.c and have them
Darkvater
parents:
5120
diff
changeset
|
161 |
|
10255
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
162 |
/** |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
163 |
* Initialize viewport of the window for use. |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
164 |
* @param w Window to use/display the viewport in |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
165 |
* @param x Offset of left edge of viewport with respect to left edge window \a w |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
166 |
* @param y Offset of top edge of viewport with respect to top edge window \a w |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
167 |
* @param width Width of the viewport |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
168 |
* @param height Height of the viewport |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
169 |
* @param follow_flags Flags controlling the viewport. |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
170 |
* - If bit 31 is set, the lower 16 bits are the vehicle that the viewport should follow. |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
171 |
* - If bit 31 is clear, it is a tile position. |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
172 |
* @param zoom Zoomlevel to display |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
173 |
*/ |
10257
fe75471234f3
(svn r12789) -Codechange: rename AssignWindowViewport to InitializeWindowViewport because the viewport is now part of the window struct. Patch by Alberth.
rubidium
parents:
10255
diff
changeset
|
174 |
void InitializeWindowViewport(Window *w, int x, int y, |
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
175 |
int width, int height, uint32 follow_flags, ZoomLevel zoom) |
0 | 176 |
{ |
10217
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
177 |
assert(w->viewport == NULL); |
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
178 |
|
10504 | 179 |
ViewportData *vp = CallocT<ViewportData>(1); |
0 | 180 |
|
181 |
vp->left = x + w->left; |
|
182 |
vp->top = y + w->top; |
|
183 |
vp->width = width; |
|
184 |
vp->height = height; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
185 |
|
0 | 186 |
vp->zoom = zoom; |
187 |
||
7150
2cfe4a46fa1c
(svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight
parents:
7149
diff
changeset
|
188 |
vp->virtual_width = ScaleByZoom(width, zoom); |
2cfe4a46fa1c
(svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight
parents:
7149
diff
changeset
|
189 |
vp->virtual_height = ScaleByZoom(height, zoom); |
0 | 190 |
|
10217
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
191 |
Point pt; |
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
192 |
|
0 | 193 |
if (follow_flags & 0x80000000) { |
2116 | 194 |
const Vehicle *veh; |
195 |
||
10504 | 196 |
vp->follow_vehicle = (VehicleID)(follow_flags & 0xFFFF); |
197 |
veh = GetVehicle(vp->follow_vehicle); |
|
0 | 198 |
pt = MapXYZToViewport(vp, veh->x_pos, veh->y_pos, veh->z_pos); |
199 |
} else { |
|
3421
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
200 |
uint x = TileX(follow_flags) * TILE_SIZE; |
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
201 |
uint y = TileY(follow_flags) * TILE_SIZE; |
2116 | 202 |
|
10504 | 203 |
vp->follow_vehicle = INVALID_VEHICLE; |
2116 | 204 |
pt = MapXYZToViewport(vp, x, y, GetSlopeZ(x, y)); |
0 | 205 |
} |
206 |
||
10504 | 207 |
vp->scrollpos_x = pt.x; |
208 |
vp->scrollpos_y = pt.y; |
|
209 |
vp->dest_scrollpos_x = pt.x; |
|
210 |
vp->dest_scrollpos_y = pt.y; |
|
7226
a8650d6ecb53
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
7165
diff
changeset
|
211 |
|
0 | 212 |
w->viewport = vp; |
213 |
vp->virtual_left = 0;//pt.x; |
|
214 |
vp->virtual_top = 0;//pt.y; |
|
215 |
} |
|
216 |
||
217 |
static Point _vp_move_offs; |
|
218 |
||
5137
a1f26c30fecd
(svn r7219) -Fix: Several warnings by gcc introduced in r7206 which MSVC found not of a problem. Thanks Tron
Darkvater
parents:
5124
diff
changeset
|
219 |
static void DoSetViewportPosition(Window* const *wz, int left, int top, int width, int height) |
0 | 220 |
{ |
5124
d30772d0e9e1
(svn r7205) -Fix [FS#350, SF#1560913]: Window allocation and deletion messed with the actual window
Darkvater
parents:
5122
diff
changeset
|
221 |
|
d30772d0e9e1
(svn r7205) -Fix [FS#350, SF#1560913]: Window allocation and deletion messed with the actual window
Darkvater
parents:
5122
diff
changeset
|
222 |
for (; wz != _last_z_window; wz++) { |
d30772d0e9e1
(svn r7205) -Fix [FS#350, SF#1560913]: Window allocation and deletion messed with the actual window
Darkvater
parents:
5122
diff
changeset
|
223 |
const Window *w = *wz; |
d30772d0e9e1
(svn r7205) -Fix [FS#350, SF#1560913]: Window allocation and deletion messed with the actual window
Darkvater
parents:
5122
diff
changeset
|
224 |
|
0 | 225 |
if (left + width > w->left && |
2116 | 226 |
w->left + w->width > left && |
0 | 227 |
top + height > w->top && |
2116 | 228 |
w->top + w->height > top) { |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
229 |
|
0 | 230 |
if (left < w->left) { |
5124
d30772d0e9e1
(svn r7205) -Fix [FS#350, SF#1560913]: Window allocation and deletion messed with the actual window
Darkvater
parents:
5122
diff
changeset
|
231 |
DoSetViewportPosition(wz, left, top, w->left - left, height); |
d30772d0e9e1
(svn r7205) -Fix [FS#350, SF#1560913]: Window allocation and deletion messed with the actual window
Darkvater
parents:
5122
diff
changeset
|
232 |
DoSetViewportPosition(wz, left + (w->left - left), top, width - (w->left - left), height); |
0 | 233 |
return; |
234 |
} |
|
235 |
||
236 |
if (left + width > w->left + w->width) { |
|
5124
d30772d0e9e1
(svn r7205) -Fix [FS#350, SF#1560913]: Window allocation and deletion messed with the actual window
Darkvater
parents:
5122
diff
changeset
|
237 |
DoSetViewportPosition(wz, left, top, (w->left + w->width - left), height); |
d30772d0e9e1
(svn r7205) -Fix [FS#350, SF#1560913]: Window allocation and deletion messed with the actual window
Darkvater
parents:
5122
diff
changeset
|
238 |
DoSetViewportPosition(wz, left + (w->left + w->width - left), top, width - (w->left + w->width - left) , height); |
0 | 239 |
return; |
240 |
} |
|
241 |
||
242 |
if (top < w->top) { |
|
5124
d30772d0e9e1
(svn r7205) -Fix [FS#350, SF#1560913]: Window allocation and deletion messed with the actual window
Darkvater
parents:
5122
diff
changeset
|
243 |
DoSetViewportPosition(wz, left, top, width, (w->top - top)); |
d30772d0e9e1
(svn r7205) -Fix [FS#350, SF#1560913]: Window allocation and deletion messed with the actual window
Darkvater
parents:
5122
diff
changeset
|
244 |
DoSetViewportPosition(wz, left, top + (w->top - top), width, height - (w->top - top)); |
0 | 245 |
return; |
246 |
} |
|
247 |
||
248 |
if (top + height > w->top + w->height) { |
|
5124
d30772d0e9e1
(svn r7205) -Fix [FS#350, SF#1560913]: Window allocation and deletion messed with the actual window
Darkvater
parents:
5122
diff
changeset
|
249 |
DoSetViewportPosition(wz, left, top, width, (w->top + w->height - top)); |
d30772d0e9e1
(svn r7205) -Fix [FS#350, SF#1560913]: Window allocation and deletion messed with the actual window
Darkvater
parents:
5122
diff
changeset
|
250 |
DoSetViewportPosition(wz, left, top + (w->top + w->height - top), width , height - (w->top + w->height - top)); |
0 | 251 |
return; |
252 |
} |
|
253 |
||
254 |
return; |
|
255 |
} |
|
256 |
} |
|
257 |
||
258 |
{ |
|
259 |
int xo = _vp_move_offs.x; |
|
260 |
int yo = _vp_move_offs.y; |
|
261 |
||
262 |
if (abs(xo) >= width || abs(yo) >= height) { |
|
263 |
/* fully_outside */ |
|
2116 | 264 |
RedrawScreenRect(left, top, left + width, top + height); |
0 | 265 |
return; |
266 |
} |
|
267 |
||
268 |
GfxScroll(left, top, width, height, xo, yo); |
|
269 |
||
270 |
if (xo > 0) { |
|
271 |
RedrawScreenRect(left, top, xo + left, top + height); |
|
272 |
left += xo; |
|
273 |
width -= xo; |
|
274 |
} else if (xo < 0) { |
|
275 |
RedrawScreenRect(left+width+xo, top, left+width, top + height); |
|
276 |
width += xo; |
|
277 |
} |
|
278 |
||
279 |
if (yo > 0) { |
|
280 |
RedrawScreenRect(left, top, width+left, top + yo); |
|
281 |
} else if (yo < 0) { |
|
282 |
RedrawScreenRect(left, top + height + yo, width+left, top + height); |
|
283 |
} |
|
284 |
} |
|
285 |
} |
|
286 |
||
4171 | 287 |
static void SetViewportPosition(Window *w, int x, int y) |
0 | 288 |
{ |
289 |
ViewPort *vp = w->viewport; |
|
290 |
int old_left = vp->virtual_left; |
|
291 |
int old_top = vp->virtual_top; |
|
292 |
int i; |
|
293 |
int left, top, width, height; |
|
294 |
||
295 |
vp->virtual_left = x; |
|
296 |
vp->virtual_top = y; |
|
297 |
||
8401
3b1db2134a9e
(svn r11456) -Fix [FS#1412] (r10070): Viewport is bound to its top-left corner
smatz
parents:
8385
diff
changeset
|
298 |
/* viewport is bound to its left top corner, so it must be rounded down (UnScaleByZoomLower) |
3b1db2134a9e
(svn r11456) -Fix [FS#1412] (r10070): Viewport is bound to its top-left corner
smatz
parents:
8385
diff
changeset
|
299 |
* else glitch described in FS#1412 will happen (offset by 1 pixel with zoom level > NORMAL) |
3b1db2134a9e
(svn r11456) -Fix [FS#1412] (r10070): Viewport is bound to its top-left corner
smatz
parents:
8385
diff
changeset
|
300 |
*/ |
3b1db2134a9e
(svn r11456) -Fix [FS#1412] (r10070): Viewport is bound to its top-left corner
smatz
parents:
8385
diff
changeset
|
301 |
old_left = UnScaleByZoomLower(old_left, vp->zoom); |
3b1db2134a9e
(svn r11456) -Fix [FS#1412] (r10070): Viewport is bound to its top-left corner
smatz
parents:
8385
diff
changeset
|
302 |
old_top = UnScaleByZoomLower(old_top, vp->zoom); |
3b1db2134a9e
(svn r11456) -Fix [FS#1412] (r10070): Viewport is bound to its top-left corner
smatz
parents:
8385
diff
changeset
|
303 |
x = UnScaleByZoomLower(x, vp->zoom); |
3b1db2134a9e
(svn r11456) -Fix [FS#1412] (r10070): Viewport is bound to its top-left corner
smatz
parents:
8385
diff
changeset
|
304 |
y = UnScaleByZoomLower(y, vp->zoom); |
0 | 305 |
|
306 |
old_left -= x; |
|
307 |
old_top -= y; |
|
308 |
||
2116 | 309 |
if (old_top == 0 && old_left == 0) return; |
0 | 310 |
|
311 |
_vp_move_offs.x = old_left; |
|
312 |
_vp_move_offs.y = old_top; |
|
313 |
||
314 |
left = vp->left; |
|
315 |
top = vp->top; |
|
316 |
width = vp->width; |
|
317 |
height = vp->height; |
|
318 |
||
319 |
if (left < 0) { |
|
320 |
width += left; |
|
321 |
left = 0; |
|
322 |
} |
|
323 |
||
2116 | 324 |
i = left + width - _screen.width; |
325 |
if (i >= 0) width -= i; |
|
0 | 326 |
|
327 |
if (width > 0) { |
|
328 |
if (top < 0) { |
|
329 |
height += top; |
|
330 |
top = 0; |
|
331 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
332 |
|
2116 | 333 |
i = top + height - _screen.height; |
334 |
if (i >= 0) height -= i; |
|
0 | 335 |
|
5124
d30772d0e9e1
(svn r7205) -Fix [FS#350, SF#1560913]: Window allocation and deletion messed with the actual window
Darkvater
parents:
5122
diff
changeset
|
336 |
if (height > 0) DoSetViewportPosition(FindWindowZPosition(w) + 1, left, top, width, height); |
0 | 337 |
} |
338 |
} |
|
339 |
||
10255
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
340 |
/** |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
341 |
* Is a xy position inside the viewport of the window? |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
342 |
* @param w Window to examine its viewport |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
343 |
* @param x X coordinate of the xy position |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
344 |
* @param y Y coordinate of the xy position |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
345 |
* @return Pointer to the viewport if the xy position is in the viewport of the window, |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
346 |
* otherwise \c NULL is returned. |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
347 |
*/ |
2116 | 348 |
ViewPort *IsPtInWindowViewport(const Window *w, int x, int y) |
0 | 349 |
{ |
350 |
ViewPort *vp = w->viewport; |
|
2116 | 351 |
|
0 | 352 |
if (vp != NULL && |
9058
b9c3fec968b8
(svn r12140) -Codechange: A bit of code style fixes(Geektoo).
belugas
parents:
8969
diff
changeset
|
353 |
IsInsideMM(x, vp->left, vp->left + vp->width) && |
8450
dce58137301f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents:
8447
diff
changeset
|
354 |
IsInsideMM(y, vp->top, vp->top + vp->height)) |
0 | 355 |
return vp; |
356 |
||
357 |
return NULL; |
|
358 |
} |
|
359 |
||
2116 | 360 |
static Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y) |
1095 | 361 |
{ |
0 | 362 |
Point pt; |
363 |
int a,b; |
|
5014
aaa61af89635
(svn r7047) -Fix [FS#317]: Zooming out near map-borders would previously fail because the new centre
Darkvater
parents:
4912
diff
changeset
|
364 |
uint z; |
0 | 365 |
|
366 |
if ( (uint)(x -= vp->left) >= (uint)vp->width || |
|
367 |
(uint)(y -= vp->top) >= (uint)vp->height) { |
|
368 |
Point pt = {-1, -1}; |
|
369 |
return pt; |
|
370 |
} |
|
371 |
||
7122
0607a15aedc0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
7120
diff
changeset
|
372 |
x = (ScaleByZoom(x, vp->zoom) + vp->virtual_left) >> 2; |
0607a15aedc0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
7120
diff
changeset
|
373 |
y = (ScaleByZoom(y, vp->zoom) + vp->virtual_top) >> 1; |
0 | 374 |
|
375 |
a = y-x; |
|
376 |
b = y+x; |
|
377 |
||
5014
aaa61af89635
(svn r7047) -Fix [FS#317]: Zooming out near map-borders would previously fail because the new centre
Darkvater
parents:
4912
diff
changeset
|
378 |
/* we need to move variables in to the valid range, as the |
aaa61af89635
(svn r7047) -Fix [FS#317]: Zooming out near map-borders would previously fail because the new centre
Darkvater
parents:
4912
diff
changeset
|
379 |
* GetTileZoomCenterWindow() function can call here with invalid x and/or y, |
aaa61af89635
(svn r7047) -Fix [FS#317]: Zooming out near map-borders would previously fail because the new centre
Darkvater
parents:
4912
diff
changeset
|
380 |
* when the user tries to zoom out along the sides of the map */ |
8418
b49fc6be1ab9
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents:
8414
diff
changeset
|
381 |
a = Clamp(a, 0, (int)(MapMaxX() * TILE_SIZE) - 1); |
b49fc6be1ab9
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents:
8414
diff
changeset
|
382 |
b = Clamp(b, 0, (int)(MapMaxY() * TILE_SIZE) - 1); |
5014
aaa61af89635
(svn r7047) -Fix [FS#317]: Zooming out near map-borders would previously fail because the new centre
Darkvater
parents:
4912
diff
changeset
|
383 |
|
8260
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8222
diff
changeset
|
384 |
/* (a, b) is the X/Y-world coordinate that belongs to (x,y) if the landscape would be completely flat on height 0. |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8222
diff
changeset
|
385 |
* Now find the Z-world coordinate by fix point iteration. |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8222
diff
changeset
|
386 |
* This is a bit tricky because the tile height is non-continuous at foundations. |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8222
diff
changeset
|
387 |
* The clicked point should be approached from the back, otherwise there are regions that are not clickable. |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8222
diff
changeset
|
388 |
* (FOUNDATION_HALFTILE_LOWER on SLOPE_STEEP_S hides north halftile completely) |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8222
diff
changeset
|
389 |
* So give it a z-malus of 4 in the first iterations. |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8222
diff
changeset
|
390 |
*/ |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8222
diff
changeset
|
391 |
z = 0; |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8222
diff
changeset
|
392 |
for (int i = 0; i < 5; i++) z = GetSlopeZ(a + max(z, 4u) - 4, b + max(z, 4u) - 4) / 2; |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8222
diff
changeset
|
393 |
for (uint malus = 3; malus > 0; malus--) z = GetSlopeZ(a + max(z, malus) - malus, b + max(z, malus) - malus) / 2; |
c7d75cebe3f6
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium
parents:
8222
diff
changeset
|
394 |
for (int i = 0; i < 5; i++) z = GetSlopeZ(a + z, b + z) / 2; |
5014
aaa61af89635
(svn r7047) -Fix [FS#317]: Zooming out near map-borders would previously fail because the new centre
Darkvater
parents:
4912
diff
changeset
|
395 |
|
aaa61af89635
(svn r7047) -Fix [FS#317]: Zooming out near map-borders would previously fail because the new centre
Darkvater
parents:
4912
diff
changeset
|
396 |
pt.x = a + z; |
aaa61af89635
(svn r7047) -Fix [FS#317]: Zooming out near map-borders would previously fail because the new centre
Darkvater
parents:
4912
diff
changeset
|
397 |
pt.y = b + z; |
0 | 398 |
|
399 |
return pt; |
|
400 |
} |
|
401 |
||
981
25c7b445dcb8
(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
|
402 |
/* When used for zooming, check area below current coordinates (x,y) |
25c7b445dcb8
(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
|
403 |
* and return the tile of the zoomed out/in position (zoom_x, zoom_y) |
25c7b445dcb8
(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
|
404 |
* when you just want the tile, make x = zoom_x and y = zoom_y */ |
25c7b445dcb8
(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
|
405 |
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
|
406 |
{ |
0 | 407 |
Window *w; |
408 |
ViewPort *vp; |
|
409 |
Point pt; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
410 |
|
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
411 |
if ( (w = FindWindowFromPt(x, y)) != NULL && |
0 | 412 |
(vp = IsPtInWindowViewport(w, x, y)) != NULL) |
981
25c7b445dcb8
(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
|
413 |
return TranslateXYToTileCoord(vp, zoom_x, zoom_y); |
0 | 414 |
|
415 |
pt.y = pt.x = -1; |
|
416 |
return pt; |
|
417 |
} |
|
418 |
||
6573 | 419 |
Point GetTileBelowCursor() |
0 | 420 |
{ |
981
25c7b445dcb8
(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
|
421 |
return GetTileFromScreenXY(_cursor.pos.x, _cursor.pos.y, _cursor.pos.x, _cursor.pos.y); |
0 | 422 |
} |
423 |
||
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
|
424 |
|
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
|
425 |
Point GetTileZoomCenterWindow(bool in, Window * w) |
0 | 426 |
{ |
427 |
int x, y; |
|
10504 | 428 |
ViewPort *vp = w->viewport; |
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
|
429 |
|
2026 | 430 |
if (in) { |
2116 | 431 |
x = ((_cursor.pos.x - vp->left) >> 1) + (vp->width >> 2); |
432 |
y = ((_cursor.pos.y - vp->top) >> 1) + (vp->height >> 2); |
|
433 |
} 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
|
434 |
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
|
435 |
y = vp->height - (_cursor.pos.y - vp->top); |
0 | 436 |
} |
981
25c7b445dcb8
(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
|
437 |
/* Get the tile below the cursor and center on the zoomed-out center */ |
25c7b445dcb8
(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
|
438 |
return GetTileFromScreenXY(_cursor.pos.x, _cursor.pos.y, x + vp->left, y + vp->top); |
0 | 439 |
} |
440 |
||
5045
3e734e178dae
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5027
diff
changeset
|
441 |
/** Update the status of the zoom-buttons according to the zoom-level |
3e734e178dae
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5027
diff
changeset
|
442 |
* of the viewport. This will update their status and invalidate accordingly |
6939
50b3cf596ce2
(svn r9580) -Documentation: Correction of doxygen function declarations
belugas
parents:
6923
diff
changeset
|
443 |
* @param w Window pointer to the window that has the zoom buttons |
5045
3e734e178dae
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5027
diff
changeset
|
444 |
* @param vp pointer to the viewport whose zoom-level the buttons represent |
3e734e178dae
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5027
diff
changeset
|
445 |
* @param widget_zoom_in widget index for window with zoom-in button |
3e734e178dae
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5027
diff
changeset
|
446 |
* @param widget_zoom_out widget index for window with zoom-out button */ |
3e734e178dae
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5027
diff
changeset
|
447 |
void HandleZoomMessage(Window *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out) |
3e734e178dae
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5027
diff
changeset
|
448 |
{ |
8493
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8466
diff
changeset
|
449 |
w->SetWidgetDisabledState(widget_zoom_in, vp->zoom == ZOOM_LVL_MIN); |
8524
baf4ab1ba18d
(svn r11588) -Codechange: use the new member introduced in r11551
glx
parents:
8493
diff
changeset
|
450 |
w->InvalidateWidget(widget_zoom_in); |
5045
3e734e178dae
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5027
diff
changeset
|
451 |
|
8493
3ab458f7cff4
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
8466
diff
changeset
|
452 |
w->SetWidgetDisabledState(widget_zoom_out, vp->zoom == ZOOM_LVL_MAX); |
8524
baf4ab1ba18d
(svn r11588) -Codechange: use the new member introduced in r11551
glx
parents:
8493
diff
changeset
|
453 |
w->InvalidateWidget(widget_zoom_out); |
5045
3e734e178dae
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5027
diff
changeset
|
454 |
} |
3e734e178dae
(svn r7094) -Codechange: Get rid of the window-specific code in DoZoomInOutWindow (enable, disable
Darkvater
parents:
5027
diff
changeset
|
455 |
|
8177
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
456 |
/** |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
457 |
* Draws a ground sprite at a specific world-coordinate. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
458 |
* |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
459 |
* @param image the image to draw. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
460 |
* @param pal the provided palette. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
461 |
* @param x position x of the sprite. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
462 |
* @param y position y of the sprite. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
463 |
* @param z position z of the sprite. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
464 |
* @param sub Only draw a part of the sprite. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
465 |
* |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
466 |
*/ |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
467 |
void DrawGroundSpriteAt(SpriteID image, SpriteID pal, int32 x, int32 y, byte z, const SubSprite *sub) |
0 | 468 |
{ |
2187
2a51f8925eeb
(svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar
parents:
2186
diff
changeset
|
469 |
assert((image & SPRITE_MASK) < MAX_SPRITES); |
0 | 470 |
|
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
471 |
TileSpriteToDraw *ts = _vd.tile_sprites_to_draw.Append(); |
10205
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
10204
diff
changeset
|
472 |
ts->image = image; |
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
10204
diff
changeset
|
473 |
ts->pal = pal; |
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
10204
diff
changeset
|
474 |
ts->sub = sub; |
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
10204
diff
changeset
|
475 |
ts->x = x; |
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
10204
diff
changeset
|
476 |
ts->y = y; |
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
10204
diff
changeset
|
477 |
ts->z = z; |
0 | 478 |
} |
479 |
||
8177
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
480 |
/** |
8222
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
481 |
* Adds a child sprite to the active foundation. |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
482 |
* |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
483 |
* The pixel offset of the sprite relative to the ParentSprite is the sum of the offset passed to OffsetGroundSprite() and extra_offs_?. |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
484 |
* |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
485 |
* @param image the image to draw. |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
486 |
* @param pal the provided palette. |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
487 |
* @param sub Only draw a part of the sprite. |
8265
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
488 |
* @param foundation_part Foundation part. |
8222
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
489 |
* @param extra_offs_x Pixel X offset for the sprite position. |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
490 |
* @param extra_offs_y Pixel Y offset for the sprite position. |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
491 |
*/ |
8265
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
492 |
static void AddChildSpriteToFoundation(SpriteID image, SpriteID pal, const SubSprite *sub, FoundationPart foundation_part, int extra_offs_x, int extra_offs_y) |
8222
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
493 |
{ |
8450
dce58137301f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents:
8447
diff
changeset
|
494 |
assert(IsInsideMM(foundation_part, 0, FOUNDATION_PART_END)); |
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
495 |
assert(_vd.foundation[foundation_part] != -1); |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
496 |
Point offs = _vd.foundation_offset[foundation_part]; |
8222
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
497 |
|
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
498 |
/* Change the active ChildSprite list to the one of the foundation */ |
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
499 |
int *old_child = _vd.last_child; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
500 |
_vd.last_child = _vd.last_foundation_child[foundation_part]; |
8222
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
501 |
|
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
502 |
AddChildSpriteScreen(image, pal, offs.x + extra_offs_x, offs.y + extra_offs_y, false, sub); |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
503 |
|
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
504 |
/* Switch back to last ChildSprite list */ |
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
505 |
_vd.last_child = old_child; |
8222
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
506 |
} |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
507 |
|
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
508 |
/** |
8177
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
509 |
* Draws a ground sprite for the current tile. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
510 |
* If the current tile is drawn on top of a foundation the sprite is added as child sprite to the "foundation"-ParentSprite. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
511 |
* |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
512 |
* @param image the image to draw. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
513 |
* @param pal the provided palette. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
514 |
* @param sub Only draw a part of the sprite. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
515 |
*/ |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
516 |
void DrawGroundSprite(SpriteID image, SpriteID pal, const SubSprite *sub) |
0 | 517 |
{ |
8265
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
518 |
/* Switch to first foundation part, if no foundation was drawn */ |
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
519 |
if (_vd.foundation_part == FOUNDATION_PART_NONE) _vd.foundation_part = FOUNDATION_PART_NORMAL; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
520 |
|
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
521 |
if (_vd.foundation[_vd.foundation_part] != -1) { |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
522 |
AddChildSpriteToFoundation(image, pal, sub, _vd.foundation_part, 0, 0); |
0 | 523 |
} else { |
8177
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
524 |
DrawGroundSpriteAt(image, pal, _cur_ti->x, _cur_ti->y, _cur_ti->z, sub); |
0 | 525 |
} |
526 |
} |
|
527 |
||
528 |
||
8222
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
529 |
/** |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
530 |
* Called when a foundation has been drawn for the current tile. |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
531 |
* Successive ground sprites for the current tile will be drawn as child sprites of the "foundation"-ParentSprite, not as TileSprites. |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
532 |
* |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
533 |
* @param x sprite x-offset (screen coordinates) of ground sprites relative to the "foundation"-ParentSprite. |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
534 |
* @param y sprite y-offset (screen coordinates) of ground sprites relative to the "foundation"-ParentSprite. |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
535 |
*/ |
0 | 536 |
void OffsetGroundSprite(int x, int y) |
537 |
{ |
|
8265
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
538 |
/* Switch to next foundation part */ |
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
539 |
switch (_vd.foundation_part) { |
8265
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
540 |
case FOUNDATION_PART_NONE: |
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
541 |
_vd.foundation_part = FOUNDATION_PART_NORMAL; |
8265
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
542 |
break; |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
543 |
case FOUNDATION_PART_NORMAL: |
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
544 |
_vd.foundation_part = FOUNDATION_PART_HALFTILE; |
8265
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
545 |
break; |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
546 |
default: NOT_REACHED(); |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
547 |
} |
8222
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
548 |
|
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
549 |
/* _vd.last_child == NULL if foundation sprite was clipped by the viewport bounds */ |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
550 |
if (_vd.last_child != NULL) _vd.foundation[_vd.foundation_part] = _vd.parent_sprites_to_draw.items - 1; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
551 |
|
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
552 |
_vd.foundation_offset[_vd.foundation_part].x = x; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
553 |
_vd.foundation_offset[_vd.foundation_part].y = y; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
554 |
_vd.last_foundation_child[_vd.foundation_part] = _vd.last_child; |
0 | 555 |
} |
556 |
||
8177
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
557 |
/** |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
558 |
* Adds a child sprite to a parent sprite. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
559 |
* In contrast to "AddChildSpriteScreen()" the sprite position is in world coordinates |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
560 |
* |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
561 |
* @param image the image to draw. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
562 |
* @param pal the provided palette. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
563 |
* @param x position x of the sprite. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
564 |
* @param y position y of the sprite. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
565 |
* @param z position z of the sprite. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
566 |
* @param sub Only draw a part of the sprite. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
567 |
*/ |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
568 |
static void AddCombinedSprite(SpriteID image, SpriteID pal, int x, int y, byte z, const SubSprite *sub) |
0 | 569 |
{ |
570 |
Point pt = RemapCoords(x, y, z); |
|
2319
9902d3ffa309
(svn r2845) Remove sprite size caching, it was unused
tron
parents:
2187
diff
changeset
|
571 |
const Sprite* spr = GetSprite(image & SPRITE_MASK); |
0 | 572 |
|
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
573 |
if (pt.x + spr->x_offs >= _vd.dpi.left + _vd.dpi.width || |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
574 |
pt.x + spr->x_offs + spr->width <= _vd.dpi.left || |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
575 |
pt.y + spr->y_offs >= _vd.dpi.top + _vd.dpi.height || |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
576 |
pt.y + spr->y_offs + spr->height <= _vd.dpi.top) |
0 | 577 |
return; |
578 |
||
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
579 |
const ParentSpriteToDraw *pstd = _vd.parent_sprites_to_draw.End() - 1; |
10207
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
580 |
AddChildSpriteScreen(image, pal, pt.x - pstd->left, pt.y - pstd->top, false, sub); |
0 | 581 |
} |
582 |
||
8076
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
583 |
/** Draw a (transparent) sprite at given coordinates with a given bounding box. |
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
584 |
* The bounding box extends from (x + bb_offset_x, y + bb_offset_y, z + bb_offset_z) to (x + w - 1, y + h - 1, z + dz - 1), both corners included. |
8113
f7a573c5d56c
(svn r11147) -Fix [FS#1247] (r11105): reallow bounding boxes with x/y/z-extent 0. Some NewGRFs need them. Patch by frosch.
rubidium
parents:
8097
diff
changeset
|
585 |
* Bounding boxes with bb_offset_x == w or bb_offset_y == h or bb_offset_z == dz are allowed and produce thin slices. |
8076
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
586 |
* |
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
587 |
* @note Bounding boxes are normally specified with bb_offset_x = bb_offset_y = bb_offset_z = 0. The extent of the bounding box in negative direction is |
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
588 |
* defined by the sprite offset in the grf file. |
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
589 |
* However if modifying the sprite offsets is not suitable (e.g. when using existing graphics), the bounding box can be tuned by bb_offset. |
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
590 |
* |
8113
f7a573c5d56c
(svn r11147) -Fix [FS#1247] (r11105): reallow bounding boxes with x/y/z-extent 0. Some NewGRFs need them. Patch by frosch.
rubidium
parents:
8097
diff
changeset
|
591 |
* @pre w >= bb_offset_x, h >= bb_offset_y, dz >= bb_offset_z. Else w, h or dz are ignored. |
8076
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
592 |
* |
7829
88883899c9e6
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium
parents:
7817
diff
changeset
|
593 |
* @param image the image to combine and draw, |
88883899c9e6
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium
parents:
7817
diff
changeset
|
594 |
* @param pal the provided palette, |
8076
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
595 |
* @param x position X (world) of the sprite, |
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
596 |
* @param y position Y (world) of the sprite, |
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
597 |
* @param w bounding box extent towards positive X (world), |
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
598 |
* @param h bounding box extent towards positive Y (world), |
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
599 |
* @param dz bounding box extent towards positive Z (world), |
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
600 |
* @param z position Z (world) of the sprite, |
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
601 |
* @param transparent if true, switch the palette between the provided palette and the transparent palette, |
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
602 |
* @param bb_offset_x bounding box extent towards negative X (world), |
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
603 |
* @param bb_offset_y bounding box extent towards negative Y (world), |
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
604 |
* @param bb_offset_z bounding box extent towards negative Z (world) |
8177
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
605 |
* @param sub Only draw a part of the sprite. |
7829
88883899c9e6
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium
parents:
7817
diff
changeset
|
606 |
*/ |
8177
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
607 |
void AddSortableSpriteToDraw(SpriteID image, SpriteID pal, int x, int y, int w, int h, int dz, int z, bool transparent, int bb_offset_x, int bb_offset_y, int bb_offset_z, const SubSprite *sub) |
0 | 608 |
{ |
8139
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
609 |
int32 left, right, top, bottom; |
0 | 610 |
|
2187
2a51f8925eeb
(svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar
parents:
2186
diff
changeset
|
611 |
assert((image & SPRITE_MASK) < MAX_SPRITES); |
0 | 612 |
|
7829
88883899c9e6
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium
parents:
7817
diff
changeset
|
613 |
/* make the sprites transparent with the right palette */ |
88883899c9e6
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium
parents:
7817
diff
changeset
|
614 |
if (transparent) { |
8427
143b0be22af1
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
8425
diff
changeset
|
615 |
SetBit(image, PALETTE_MODIFIER_TRANSPARENT); |
7829
88883899c9e6
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium
parents:
7817
diff
changeset
|
616 |
pal = PALETTE_TO_TRANSPARENT; |
88883899c9e6
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium
parents:
7817
diff
changeset
|
617 |
} |
88883899c9e6
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium
parents:
7817
diff
changeset
|
618 |
|
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
619 |
if (_vd.combine_sprites == 2) { |
8177
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
620 |
AddCombinedSprite(image, pal, x, y, z, sub); |
0 | 621 |
return; |
622 |
} |
|
623 |
||
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
624 |
_vd.last_child = NULL; |
0 | 625 |
|
10207
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
626 |
Point pt = RemapCoords(x, y, z); |
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
627 |
int tmp_left, tmp_top, tmp_x = pt.x, tmp_y = pt.y; |
8139
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
628 |
|
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
629 |
/* Compute screen extents of sprite */ |
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8076
diff
changeset
|
630 |
if (image == SPR_EMPTY_BOUNDING_BOX) { |
10207
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
631 |
left = tmp_left = RemapCoords(x + w , y + bb_offset_y, z + bb_offset_z).x; |
8139
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
632 |
right = RemapCoords(x + bb_offset_x, y + h , z + bb_offset_z).x + 1; |
10207
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
633 |
top = tmp_top = RemapCoords(x + bb_offset_x, y + bb_offset_y, z + dz ).y; |
8139
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
634 |
bottom = RemapCoords(x + w , y + h , z + bb_offset_z).y + 1; |
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8076
diff
changeset
|
635 |
} else { |
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8076
diff
changeset
|
636 |
const Sprite *spr = GetSprite(image & SPRITE_MASK); |
10207
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
637 |
left = tmp_left = (pt.x += spr->x_offs); |
8139
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
638 |
right = (pt.x + spr->width ); |
10207
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
639 |
top = tmp_top = (pt.y += spr->y_offs); |
8139
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
640 |
bottom = (pt.y + spr->height); |
8097
68eefbb4ff46
(svn r11128) -Fix: a lot of graphical glitches by changing some bounding boxes. It's not perfect yet, but a *very* good step into the right direction. Patch by frosch.
rubidium
parents:
8076
diff
changeset
|
641 |
} |
9058
b9c3fec968b8
(svn r12140) -Codechange: A bit of code style fixes(Geektoo).
belugas
parents:
8969
diff
changeset
|
642 |
|
8139
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
643 |
if (_draw_bounding_boxes && (image != SPR_EMPTY_BOUNDING_BOX)) { |
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
644 |
/* Compute maximal extents of sprite and it's bounding box */ |
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
645 |
left = min(left , RemapCoords(x + w , y + bb_offset_y, z + bb_offset_z).x); |
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
646 |
right = max(right , RemapCoords(x + bb_offset_x, y + h , z + bb_offset_z).x + 1); |
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
647 |
top = min(top , RemapCoords(x + bb_offset_x, y + bb_offset_y, z + dz ).y); |
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
648 |
bottom = max(bottom, RemapCoords(x + w , y + h , z + bb_offset_z).y + 1); |
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
649 |
} |
9058
b9c3fec968b8
(svn r12140) -Codechange: A bit of code style fixes(Geektoo).
belugas
parents:
8969
diff
changeset
|
650 |
|
8139
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
651 |
/* Do not add the sprite to the viewport, if it is outside */ |
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
652 |
if (left >= _vd.dpi.left + _vd.dpi.width || |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
653 |
right <= _vd.dpi.left || |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
654 |
top >= _vd.dpi.top + _vd.dpi.height || |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
655 |
bottom <= _vd.dpi.top) { |
4189
258f98b17f57
(svn r5631) Don't allocate memory for information about a sprite which isn't drawn
tron
parents:
4188
diff
changeset
|
656 |
return; |
258f98b17f57
(svn r5631) Don't allocate memory for information about a sprite which isn't drawn
tron
parents:
4188
diff
changeset
|
657 |
} |
258f98b17f57
(svn r5631) Don't allocate memory for information about a sprite which isn't drawn
tron
parents:
4188
diff
changeset
|
658 |
|
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
659 |
ParentSpriteToDraw *ps = _vd.parent_sprites_to_draw.Append(); |
10207
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
660 |
ps->x = tmp_x; |
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
661 |
ps->y = tmp_y; |
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
662 |
|
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
663 |
ps->left = tmp_left; |
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
664 |
ps->top = tmp_top; |
0 | 665 |
|
666 |
ps->image = image; |
|
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5853
diff
changeset
|
667 |
ps->pal = pal; |
8177
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
668 |
ps->sub = sub; |
8076
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
669 |
ps->xmin = x + bb_offset_x; |
8113
f7a573c5d56c
(svn r11147) -Fix [FS#1247] (r11105): reallow bounding boxes with x/y/z-extent 0. Some NewGRFs need them. Patch by frosch.
rubidium
parents:
8097
diff
changeset
|
670 |
ps->xmax = x + max(bb_offset_x, w) - 1; |
8076
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
671 |
|
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
672 |
ps->ymin = y + bb_offset_y; |
8113
f7a573c5d56c
(svn r11147) -Fix [FS#1247] (r11105): reallow bounding boxes with x/y/z-extent 0. Some NewGRFs need them. Patch by frosch.
rubidium
parents:
8097
diff
changeset
|
673 |
ps->ymax = y + max(bb_offset_y, h) - 1; |
8076
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
674 |
|
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
675 |
ps->zmin = z + bb_offset_z; |
8113
f7a573c5d56c
(svn r11147) -Fix [FS#1247] (r11105): reallow bounding boxes with x/y/z-extent 0. Some NewGRFs need them. Patch by frosch.
rubidium
parents:
8097
diff
changeset
|
676 |
ps->zmax = z + max(bb_offset_z, dz) - 1; |
8076
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
677 |
|
10e9b5e354d9
(svn r11105) -Codechange [FS#1223]: add some support for tuning of the bounding boxes for some special cases (like tunnels and bridges). Patch by frosch.
rubidium
parents:
8075
diff
changeset
|
678 |
ps->comparison_done = false; |
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
679 |
ps->first_child = _vd.child_screen_sprites_to_draw.items; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
680 |
ps->last_child = _vd.child_screen_sprites_to_draw.items; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
681 |
|
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
682 |
_vd.last_child = &ps->last_child; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
683 |
|
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
684 |
if (_vd.combine_sprites == 1) _vd.combine_sprites = 2; |
0 | 685 |
} |
686 |
||
6573 | 687 |
void StartSpriteCombine() |
0 | 688 |
{ |
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
689 |
_vd.combine_sprites = 1; |
0 | 690 |
} |
691 |
||
6573 | 692 |
void EndSpriteCombine() |
0 | 693 |
{ |
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
694 |
_vd.combine_sprites = 0; |
0 | 695 |
} |
696 |
||
8177
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
697 |
/** |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
698 |
* Add a child sprite to a parent sprite. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
699 |
* |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
700 |
* @param image the image to draw. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
701 |
* @param pal the provided palette. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
702 |
* @param x sprite x-offset (screen coordinates) relative to parent sprite. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
703 |
* @param y sprite y-offset (screen coordinates) relative to parent sprite. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
704 |
* @param transparent if true, switch the palette between the provided palette and the transparent palette, |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
705 |
* @param sub Only draw a part of the sprite. |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
706 |
*/ |
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
707 |
void AddChildSpriteScreen(SpriteID image, SpriteID pal, int x, int y, bool transparent, const SubSprite *sub) |
0 | 708 |
{ |
2187
2a51f8925eeb
(svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar
parents:
2186
diff
changeset
|
709 |
assert((image & SPRITE_MASK) < MAX_SPRITES); |
0 | 710 |
|
10208
98dc9f65629e
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium
parents:
10207
diff
changeset
|
711 |
/* If the ParentSprite was clipped by the viewport bounds, do not draw the ChildSprites either */ |
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
712 |
if (_vd.last_child == NULL) return; |
10208
98dc9f65629e
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium
parents:
10207
diff
changeset
|
713 |
|
8155
db4561087736
(svn r11190) -Fix: make snowy roofs of (newgrf) houses also transparent.
rubidium
parents:
8139
diff
changeset
|
714 |
/* make the sprites transparent with the right palette */ |
db4561087736
(svn r11190) -Fix: make snowy roofs of (newgrf) houses also transparent.
rubidium
parents:
8139
diff
changeset
|
715 |
if (transparent) { |
8427
143b0be22af1
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
8425
diff
changeset
|
716 |
SetBit(image, PALETTE_MODIFIER_TRANSPARENT); |
8155
db4561087736
(svn r11190) -Fix: make snowy roofs of (newgrf) houses also transparent.
rubidium
parents:
8139
diff
changeset
|
717 |
pal = PALETTE_TO_TRANSPARENT; |
db4561087736
(svn r11190) -Fix: make snowy roofs of (newgrf) houses also transparent.
rubidium
parents:
8139
diff
changeset
|
718 |
} |
db4561087736
(svn r11190) -Fix: make snowy roofs of (newgrf) houses also transparent.
rubidium
parents:
8139
diff
changeset
|
719 |
|
8222
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
720 |
/* Append the sprite to the active ChildSprite list. |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
721 |
* If the active ParentSprite is a foundation, update last_foundation_child as well. */ |
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
722 |
ChildScreenSpriteToDraw *cs = _vd.child_screen_sprites_to_draw.Append(); |
0 | 723 |
cs->image = image; |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5853
diff
changeset
|
724 |
cs->pal = pal; |
8177
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
725 |
cs->sub = sub; |
0 | 726 |
cs->x = x; |
727 |
cs->y = y; |
|
728 |
cs->next = NULL; |
|
10208
98dc9f65629e
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium
parents:
10207
diff
changeset
|
729 |
|
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
730 |
*_vd.last_child = _vd.child_screen_sprites_to_draw.items; |
0 | 731 |
} |
732 |
||
733 |
/* Returns a StringSpriteToDraw */ |
|
10202
19da84f6725c
(svn r12734) -Codechange: use a vector instead of allocating memory in a big byte array for StringSpriteToDraw.
rubidium
parents:
10164
diff
changeset
|
734 |
void AddStringToDraw(int x, int y, StringID string, uint64 params_1, uint64 params_2, uint16 color, uint16 width) |
0 | 735 |
{ |
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
736 |
StringSpriteToDraw *ss = _vd.string_sprites_to_draw.Append(); |
10205
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
10204
diff
changeset
|
737 |
ss->string = string; |
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
10204
diff
changeset
|
738 |
ss->x = x; |
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
10204
diff
changeset
|
739 |
ss->y = y; |
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
10204
diff
changeset
|
740 |
ss->params[0] = params_1; |
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
10204
diff
changeset
|
741 |
ss->params[1] = params_2; |
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
10204
diff
changeset
|
742 |
ss->width = width; |
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
10204
diff
changeset
|
743 |
ss->color = color; |
0 | 744 |
} |
745 |
||
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3809
diff
changeset
|
746 |
|
8222
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
747 |
/** |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
748 |
* Draws sprites between ground sprite and everything above. |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
749 |
* |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
750 |
* The sprite is either drawn as TileSprite or as ChildSprite of the active foundation. |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
751 |
* |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
752 |
* @param image the image to draw. |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
753 |
* @param pal the provided palette. |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
754 |
* @param ti TileInfo Tile that is being drawn |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
755 |
* @param z_offset Z offset relative to the groundsprite. Only used for the sprite position, not for sprite sorting. |
8265
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
756 |
* @param foundation_part Foundation part the sprite belongs to. |
8222
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
757 |
*/ |
8265
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
758 |
static void DrawSelectionSprite(SpriteID image, SpriteID pal, const TileInfo *ti, int z_offset, FoundationPart foundation_part) |
0 | 759 |
{ |
8222
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
760 |
/* FIXME: This is not totally valid for some autorail highlights, that extent over the edges of the tile. */ |
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
761 |
if (_vd.foundation[foundation_part] == -1) { |
8222
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
762 |
/* draw on real ground */ |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
763 |
DrawGroundSpriteAt(image, pal, ti->x, ti->y, ti->z + z_offset); |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
764 |
} else { |
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
765 |
/* draw on top of foundation */ |
8265
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
766 |
AddChildSpriteToFoundation(image, pal, NULL, foundation_part, 0, -z_offset); |
1083
2e9d525af38d
(svn r1584) Fix: Highlighlighting tiles under bridges works again correctly for square selection tools.
dominik
parents:
1070
diff
changeset
|
767 |
} |
0 | 768 |
} |
769 |
||
8175
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
770 |
/** |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
771 |
* Draws a selection rectangle on a tile. |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
772 |
* |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
773 |
* @param ti TileInfo Tile that is being drawn |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
774 |
* @param pal Palette to apply. |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
775 |
*/ |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
776 |
static void DrawTileSelectionRect(const TileInfo *ti, SpriteID pal) |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
777 |
{ |
8265
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
778 |
SpriteID sel; |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
779 |
if (IsHalftileSlope(ti->tileh)) { |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
780 |
Corner halftile_corner = GetHalftileSlopeCorner(ti->tileh); |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
781 |
SpriteID sel2 = SPR_HALFTILE_SELECTION_FLAT + halftile_corner; |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
782 |
DrawSelectionSprite(sel2, pal, ti, 7 + TILE_HEIGHT, FOUNDATION_PART_HALFTILE); |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
783 |
|
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
784 |
Corner opposite_corner = OppositeCorner(halftile_corner); |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
785 |
if (IsSteepSlope(ti->tileh)) { |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
786 |
sel = SPR_HALFTILE_SELECTION_DOWN; |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
787 |
} else { |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
788 |
sel = ((ti->tileh & SlopeWithOneCornerRaised(opposite_corner)) != 0 ? SPR_HALFTILE_SELECTION_UP : SPR_HALFTILE_SELECTION_FLAT); |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
789 |
} |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
790 |
sel += opposite_corner; |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
791 |
} else { |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
792 |
sel = SPR_SELECT_TILE + _tileh_to_sprite[ti->tileh]; |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
793 |
} |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
794 |
DrawSelectionSprite(sel, pal, ti, 7, FOUNDATION_PART_NORMAL); |
8175
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
795 |
} |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
796 |
|
0 | 797 |
static bool IsPartOfAutoLine(int px, int py) |
798 |
{ |
|
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
799 |
px -= _thd.selstart.x; |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
800 |
py -= _thd.selstart.y; |
0 | 801 |
|
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
802 |
if ((_thd.drawstyle & ~HT_DIR_MASK) != HT_LINE) return false; |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
803 |
|
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
804 |
switch (_thd.drawstyle & HT_DIR_MASK) { |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
805 |
case HT_DIR_X: return py == 0; // x direction |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
806 |
case HT_DIR_Y: return px == 0; // y direction |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
807 |
case HT_DIR_HU: return px == -py || px == -py - 16; // horizontal upper |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
808 |
case HT_DIR_HL: return px == -py || px == -py + 16; // horizontal lower |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
809 |
case HT_DIR_VL: return px == py || px == py + 16; // vertival left |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
810 |
case HT_DIR_VR: return px == py || px == py - 16; // vertical right |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
811 |
default: |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
812 |
NOT_REACHED(); |
0 | 813 |
} |
814 |
} |
|
815 |
||
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
816 |
// [direction][side] |
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
817 |
static const HighLightStyle _autorail_type[6][2] = { |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
818 |
{ HT_DIR_X, HT_DIR_X }, |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
819 |
{ HT_DIR_Y, HT_DIR_Y }, |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
820 |
{ HT_DIR_HU, HT_DIR_HL }, |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
821 |
{ HT_DIR_HL, HT_DIR_HU }, |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
822 |
{ HT_DIR_VL, HT_DIR_VR }, |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
823 |
{ HT_DIR_VR, HT_DIR_VL } |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
824 |
}; |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
825 |
|
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
826 |
#include "table/autorail.h" |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
827 |
|
7574
0d76e3392fa4
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas
parents:
7565
diff
changeset
|
828 |
/** |
8175
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
829 |
* Draws autorail highlights. |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
830 |
* |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
831 |
* @param *ti TileInfo Tile that is being drawn |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
832 |
* @param autorail_type Offset into _AutorailTilehSprite[][] |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
833 |
*/ |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
834 |
static void DrawAutorailSelection(const TileInfo *ti, uint autorail_type) |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
835 |
{ |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
836 |
SpriteID image; |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
837 |
SpriteID pal; |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
838 |
int offset; |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
839 |
|
8265
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
840 |
FoundationPart foundation_part = FOUNDATION_PART_NORMAL; |
8909
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8766
diff
changeset
|
841 |
Slope autorail_tileh = RemoveHalftileSlope(ti->tileh); |
8265
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
842 |
if (IsHalftileSlope(ti->tileh)) { |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
843 |
static const uint _lower_rail[4] = { 5U, 2U, 4U, 3U }; |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
844 |
Corner halftile_corner = GetHalftileSlopeCorner(ti->tileh); |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
845 |
if (autorail_type != _lower_rail[halftile_corner]) { |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
846 |
foundation_part = FOUNDATION_PART_HALFTILE; |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
847 |
/* Here we draw the highlights of the "three-corners-raised"-slope. That looks ok to me. */ |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
848 |
autorail_tileh = SlopeWithThreeCornersRaised(OppositeCorner(halftile_corner)); |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
849 |
} |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
850 |
} |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
851 |
|
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
852 |
offset = _AutorailTilehSprite[autorail_tileh][autorail_type]; |
8175
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
853 |
if (offset >= 0) { |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
854 |
image = SPR_AUTORAIL_BASE + offset; |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
855 |
pal = PAL_NONE; |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
856 |
} else { |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
857 |
image = SPR_AUTORAIL_BASE - offset; |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
858 |
pal = PALETTE_SEL_TILE_RED; |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
859 |
} |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
860 |
|
8265
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
861 |
DrawSelectionSprite(image, _thd.make_square_red ? PALETTE_SEL_TILE_RED : pal, ti, 7, foundation_part); |
8175
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
862 |
} |
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
863 |
|
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
864 |
/** |
7574
0d76e3392fa4
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas
parents:
7565
diff
changeset
|
865 |
* Checks if the specified tile is selected and if so draws selection using correct selectionstyle. |
0d76e3392fa4
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas
parents:
7565
diff
changeset
|
866 |
* @param *ti TileInfo Tile that is being drawn |
0d76e3392fa4
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas
parents:
7565
diff
changeset
|
867 |
*/ |
0 | 868 |
static void DrawTileSelection(const TileInfo *ti) |
869 |
{ |
|
6919
339210ecccd3
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6574
diff
changeset
|
870 |
/* Draw a red error square? */ |
9239
7b7a9495a0eb
(svn r12439) -Fix [FS#1871]: do not 'disable' the drawing of autorail overlays when the tile is 'error'-marked (red pulsating selection). Patch by Icosikai.
rubidium
parents:
9081
diff
changeset
|
871 |
bool is_redsq = _thd.redsq != 0 && _thd.redsq == ti->tile; |
7b7a9495a0eb
(svn r12439) -Fix [FS#1871]: do not 'disable' the drawing of autorail overlays when the tile is 'error'-marked (red pulsating selection). Patch by Icosikai.
rubidium
parents:
9081
diff
changeset
|
872 |
if (is_redsq) DrawTileSelectionRect(ti, PALETTE_TILE_RED_PULSATING); |
0 | 873 |
|
6919
339210ecccd3
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6574
diff
changeset
|
874 |
/* no selection active? */ |
2116 | 875 |
if (_thd.drawstyle == 0) return; |
0 | 876 |
|
6919
339210ecccd3
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6574
diff
changeset
|
877 |
/* Inside the inner area? */ |
8450
dce58137301f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents:
8447
diff
changeset
|
878 |
if (IsInsideBS(ti->x, _thd.pos.x, _thd.size.x) && |
dce58137301f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents:
8447
diff
changeset
|
879 |
IsInsideBS(ti->y, _thd.pos.y, _thd.size.y)) { |
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
880 |
if (_thd.drawstyle & HT_RECT) { |
9239
7b7a9495a0eb
(svn r12439) -Fix [FS#1871]: do not 'disable' the drawing of autorail overlays when the tile is 'error'-marked (red pulsating selection). Patch by Icosikai.
rubidium
parents:
9081
diff
changeset
|
881 |
if (!is_redsq) DrawTileSelectionRect(ti, _thd.make_square_red ? PALETTE_SEL_TILE_RED : PAL_NONE); |
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
882 |
} else if (_thd.drawstyle & HT_POINT) { |
6919
339210ecccd3
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6574
diff
changeset
|
883 |
/* Figure out the Z coordinate for the single dot. */ |
8222
c0f05fd821ab
(svn r11261) -Codechange: Draw selection sprites (HT_RECT, HT_POINT, HT_RAIL) on foundations as ChildSprite of the foundation, not as single ParentSprite. Patch by frosch.
rubidium
parents:
8177
diff
changeset
|
884 |
byte z = 0; |
8265
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
885 |
FoundationPart foundation_part = FOUNDATION_PART_NORMAL; |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3609
diff
changeset
|
886 |
if (ti->tileh & SLOPE_N) { |
3645
86af43f87885
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3636
diff
changeset
|
887 |
z += TILE_HEIGHT; |
8909
fa15e9afad2f
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch
parents:
8766
diff
changeset
|
888 |
if (RemoveHalftileSlope(ti->tileh) == SLOPE_STEEP_N) z += TILE_HEIGHT; |
0 | 889 |
} |
8265
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
890 |
if (IsHalftileSlope(ti->tileh)) { |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
891 |
Corner halftile_corner = GetHalftileSlopeCorner(ti->tileh); |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
892 |
if ((halftile_corner == CORNER_W) || (halftile_corner == CORNER_E)) z += TILE_HEIGHT; |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
893 |
if (halftile_corner != CORNER_S) { |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
894 |
foundation_part = FOUNDATION_PART_HALFTILE; |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
895 |
if (IsSteepSlope(ti->tileh)) z -= TILE_HEIGHT; |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
896 |
} |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
897 |
} |
9d7c69a31cdc
(svn r11318) -Codechange: add the actual support for drawing selections on halftiles, r11316 just added the things needed to load the sprites. Patch by frosch.
rubidium
parents:
8260
diff
changeset
|
898 |
DrawSelectionSprite(_cur_dpi->zoom <= ZOOM_LVL_DETAIL ? SPR_DOT : SPR_DOT_SMALL, PAL_NONE, ti, z, foundation_part); |
2116 | 899 |
} else if (_thd.drawstyle & HT_RAIL /*&& _thd.place_mode == VHM_RAIL*/) { |
6919
339210ecccd3
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6574
diff
changeset
|
900 |
/* autorail highlight piece under cursor */ |
2116 | 901 |
uint type = _thd.drawstyle & 0xF; |
902 |
assert(type <= 5); |
|
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
903 |
DrawAutorailSelection(ti, _autorail_type[type][0]); |
2116 | 904 |
} else if (IsPartOfAutoLine(ti->x, ti->y)) { |
6919
339210ecccd3
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6574
diff
changeset
|
905 |
/* autorail highlighting long line */ |
2116 | 906 |
int dir = _thd.drawstyle & ~0xF0; |
907 |
uint side; |
|
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
908 |
|
2116 | 909 |
if (dir < 2) { |
910 |
side = 0; |
|
911 |
} else { |
|
912 |
TileIndex start = TileVirtXY(_thd.selstart.x, _thd.selstart.y); |
|
8466
9ce95e16f9f9
(svn r11526) -Codechange: Rename the function delta fitting to the naming style
skidd13
parents:
8450
diff
changeset
|
913 |
side = Delta(Delta(TileX(start), TileX(ti->tile)), Delta(TileY(start), TileY(ti->tile))); |
2116 | 914 |
} |
1109
1bab892228cd
(svn r1610) Remove trailing whitespace (last time ever, i hope)
tron
parents:
1095
diff
changeset
|
915 |
|
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
916 |
DrawAutorailSelection(ti, _autorail_type[dir][side]); |
2116 | 917 |
} |
0 | 918 |
return; |
919 |
} |
|
920 |
||
6919
339210ecccd3
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6574
diff
changeset
|
921 |
/* Check if it's inside the outer area? */ |
9239
7b7a9495a0eb
(svn r12439) -Fix [FS#1871]: do not 'disable' the drawing of autorail overlays when the tile is 'error'-marked (red pulsating selection). Patch by Icosikai.
rubidium
parents:
9081
diff
changeset
|
922 |
if (!is_redsq && _thd.outersize.x && |
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
923 |
_thd.size.x < _thd.size.x + _thd.outersize.x && |
8450
dce58137301f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents:
8447
diff
changeset
|
924 |
IsInsideBS(ti->x, _thd.pos.x + _thd.offs.x, _thd.size.x + _thd.outersize.x) && |
dce58137301f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents:
8447
diff
changeset
|
925 |
IsInsideBS(ti->y, _thd.pos.y + _thd.offs.y, _thd.size.y + _thd.outersize.y)) { |
6919
339210ecccd3
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6574
diff
changeset
|
926 |
/* Draw a blue rect. */ |
8175
d67b421799bc
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium
parents:
8155
diff
changeset
|
927 |
DrawTileSelectionRect(ti, PALETTE_SEL_TILE_BLUE); |
0 | 928 |
return; |
929 |
} |
|
930 |
} |
|
931 |
||
6573 | 932 |
static void ViewportAddLandscape() |
0 | 933 |
{ |
934 |
int x, y, width, height; |
|
935 |
TileInfo ti; |
|
936 |
bool direction; |
|
937 |
||
938 |
_cur_ti = &ti; |
|
939 |
||
6919
339210ecccd3
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6574
diff
changeset
|
940 |
/* Transform into tile coordinates and round to closest full tile */ |
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
941 |
x = ((_vd.dpi.top >> 1) - (_vd.dpi.left >> 2)) & ~0xF; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
942 |
y = ((_vd.dpi.top >> 1) + (_vd.dpi.left >> 2) - 0x10) & ~0xF; |
5752
7e417aab8074
(svn r7794) -Cleanup: Remove obsolete, never-used landscape rotation code. And spell obsolete correctly.
peter1138
parents:
5726
diff
changeset
|
943 |
|
6919
339210ecccd3
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6574
diff
changeset
|
944 |
/* determine size of area */ |
0 | 945 |
{ |
946 |
Point pt = RemapCoords(x, y, 241); |
|
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
947 |
width = (_vd.dpi.left + _vd.dpi.width - pt.x + 95) >> 6; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
948 |
height = (_vd.dpi.top + _vd.dpi.height - pt.y) >> 5 << 1; |
0 | 949 |
} |
950 |
||
951 |
assert(width > 0); |
|
952 |
assert(height > 0); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
953 |
|
0 | 954 |
direction = false; |
955 |
||
956 |
do { |
|
957 |
int width_cur = width; |
|
958 |
int x_cur = x; |
|
959 |
int y_cur = y; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
960 |
|
0 | 961 |
do { |
4238
e017178ca040
(svn r5806) Inline FindLandscapeHeight() into its only remaining caller and remove the attribute "type" from struct TileInfo
tron
parents:
4231
diff
changeset
|
962 |
TileType tt; |
e017178ca040
(svn r5806) Inline FindLandscapeHeight() into its only remaining caller and remove the attribute "type" from struct TileInfo
tron
parents:
4231
diff
changeset
|
963 |
|
e017178ca040
(svn r5806) Inline FindLandscapeHeight() into its only remaining caller and remove the attribute "type" from struct TileInfo
tron
parents:
4231
diff
changeset
|
964 |
ti.x = x_cur; |
e017178ca040
(svn r5806) Inline FindLandscapeHeight() into its only remaining caller and remove the attribute "type" from struct TileInfo
tron
parents:
4231
diff
changeset
|
965 |
ti.y = y_cur; |
e017178ca040
(svn r5806) Inline FindLandscapeHeight() into its only remaining caller and remove the attribute "type" from struct TileInfo
tron
parents:
4231
diff
changeset
|
966 |
if (0 <= x_cur && x_cur < (int)MapMaxX() * TILE_SIZE && |
e017178ca040
(svn r5806) Inline FindLandscapeHeight() into its only remaining caller and remove the attribute "type" from struct TileInfo
tron
parents:
4231
diff
changeset
|
967 |
0 <= y_cur && y_cur < (int)MapMaxY() * TILE_SIZE) { |
e017178ca040
(svn r5806) Inline FindLandscapeHeight() into its only remaining caller and remove the attribute "type" from struct TileInfo
tron
parents:
4231
diff
changeset
|
968 |
TileIndex tile = TileVirtXY(x_cur, y_cur); |
e017178ca040
(svn r5806) Inline FindLandscapeHeight() into its only remaining caller and remove the attribute "type" from struct TileInfo
tron
parents:
4231
diff
changeset
|
969 |
|
e017178ca040
(svn r5806) Inline FindLandscapeHeight() into its only remaining caller and remove the attribute "type" from struct TileInfo
tron
parents:
4231
diff
changeset
|
970 |
ti.tile = tile; |
e017178ca040
(svn r5806) Inline FindLandscapeHeight() into its only remaining caller and remove the attribute "type" from struct TileInfo
tron
parents:
4231
diff
changeset
|
971 |
ti.tileh = GetTileSlope(tile, &ti.z); |
e017178ca040
(svn r5806) Inline FindLandscapeHeight() into its only remaining caller and remove the attribute "type" from struct TileInfo
tron
parents:
4231
diff
changeset
|
972 |
tt = GetTileType(tile); |
e017178ca040
(svn r5806) Inline FindLandscapeHeight() into its only remaining caller and remove the attribute "type" from struct TileInfo
tron
parents:
4231
diff
changeset
|
973 |
} else { |
e017178ca040
(svn r5806) Inline FindLandscapeHeight() into its only remaining caller and remove the attribute "type" from struct TileInfo
tron
parents:
4231
diff
changeset
|
974 |
ti.tileh = SLOPE_FLAT; |
e017178ca040
(svn r5806) Inline FindLandscapeHeight() into its only remaining caller and remove the attribute "type" from struct TileInfo
tron
parents:
4231
diff
changeset
|
975 |
ti.tile = 0; |
e017178ca040
(svn r5806) Inline FindLandscapeHeight() into its only remaining caller and remove the attribute "type" from struct TileInfo
tron
parents:
4231
diff
changeset
|
976 |
ti.z = 0; |
e017178ca040
(svn r5806) Inline FindLandscapeHeight() into its only remaining caller and remove the attribute "type" from struct TileInfo
tron
parents:
4231
diff
changeset
|
977 |
tt = MP_VOID; |
e017178ca040
(svn r5806) Inline FindLandscapeHeight() into its only remaining caller and remove the attribute "type" from struct TileInfo
tron
parents:
4231
diff
changeset
|
978 |
} |
e017178ca040
(svn r5806) Inline FindLandscapeHeight() into its only remaining caller and remove the attribute "type" from struct TileInfo
tron
parents:
4231
diff
changeset
|
979 |
|
0 | 980 |
y_cur += 0x10; |
981 |
x_cur -= 0x10; |
|
5752
7e417aab8074
(svn r7794) -Cleanup: Remove obsolete, never-used landscape rotation code. And spell obsolete correctly.
peter1138
parents:
5726
diff
changeset
|
982 |
|
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
983 |
_vd.foundation_part = FOUNDATION_PART_NONE; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
984 |
_vd.foundation[0] = -1; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
985 |
_vd.foundation[1] = -1; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
986 |
_vd.last_foundation_child[0] = NULL; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
987 |
_vd.last_foundation_child[1] = NULL; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
988 |
|
4238
e017178ca040
(svn r5806) Inline FindLandscapeHeight() into its only remaining caller and remove the attribute "type" from struct TileInfo
tron
parents:
4231
diff
changeset
|
989 |
_tile_type_procs[tt]->draw_tile_proc(&ti); |
0 | 990 |
DrawTileSelection(&ti); |
991 |
} while (--width_cur); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
992 |
|
5752
7e417aab8074
(svn r7794) -Cleanup: Remove obsolete, never-used landscape rotation code. And spell obsolete correctly.
peter1138
parents:
5726
diff
changeset
|
993 |
if ((direction ^= 1) != 0) { |
0 | 994 |
y += 0x10; |
5752
7e417aab8074
(svn r7794) -Cleanup: Remove obsolete, never-used landscape rotation code. And spell obsolete correctly.
peter1138
parents:
5726
diff
changeset
|
995 |
} else { |
0 | 996 |
x += 0x10; |
5752
7e417aab8074
(svn r7794) -Cleanup: Remove obsolete, never-used landscape rotation code. And spell obsolete correctly.
peter1138
parents:
5726
diff
changeset
|
997 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
998 |
} while (--height); |
0 | 999 |
} |
1000 |
||
1001 |
||
410 | 1002 |
static void ViewportAddTownNames(DrawPixelInfo *dpi) |
0 | 1003 |
{ |
1004 |
Town *t; |
|
1005 |
int left, top, right, bottom; |
|
1006 |
||
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8419
diff
changeset
|
1007 |
if (!HasBit(_display_opt, DO_SHOW_TOWN_NAMES) || _game_mode == GM_MENU) |
0 | 1008 |
return; |
1009 |
||
1010 |
left = dpi->left; |
|
1011 |
top = dpi->top; |
|
1012 |
right = left + dpi->width; |
|
1013 |
bottom = top + dpi->height; |
|
1014 |
||
5027 | 1015 |
switch (dpi->zoom) { |
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1016 |
case ZOOM_LVL_NORMAL: |
5027 | 1017 |
FOR_ALL_TOWNS(t) { |
1018 |
if (bottom > t->sign.top && |
|
1019 |
top < t->sign.top + 12 && |
|
1020 |
right > t->sign.left && |
|
1021 |
left < t->sign.left + t->sign.width_1) { |
|
1022 |
AddStringToDraw(t->sign.left + 1, t->sign.top + 1, |
|
1023 |
_patches.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL, |
|
1024 |
t->index, t->population); |
|
1025 |
} |
|
0 | 1026 |
} |
5027 | 1027 |
break; |
1028 |
||
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1029 |
case ZOOM_LVL_OUT_2X: |
5027 | 1030 |
right += 2; |
1031 |
bottom += 2; |
|
1032 |
||
1033 |
FOR_ALL_TOWNS(t) { |
|
1034 |
if (bottom > t->sign.top && |
|
1035 |
top < t->sign.top + 24 && |
|
1036 |
right > t->sign.left && |
|
10229
fba3f9fa44d7
(svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium
parents:
10217
diff
changeset
|
1037 |
left < t->sign.left + t->sign.width_1 * 2) { |
5027 | 1038 |
AddStringToDraw(t->sign.left + 1, t->sign.top + 1, |
1039 |
_patches.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL, |
|
1040 |
t->index, t->population); |
|
1041 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1042 |
} |
5027 | 1043 |
break; |
1044 |
||
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1045 |
case ZOOM_LVL_OUT_4X: |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1046 |
case ZOOM_LVL_OUT_8X: |
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1047 |
right += ScaleByZoom(1, dpi->zoom); |
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1048 |
bottom += ScaleByZoom(1, dpi->zoom) + 1; |
5027 | 1049 |
|
1050 |
FOR_ALL_TOWNS(t) { |
|
1051 |
if (bottom > t->sign.top && |
|
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1052 |
top < t->sign.top + ScaleByZoom(12, dpi->zoom) && |
5027 | 1053 |
right > t->sign.left && |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1054 |
left < t->sign.left + ScaleByZoom(t->sign.width_2, dpi->zoom)) { |
5027 | 1055 |
AddStringToDraw(t->sign.left + 5, t->sign.top + 1, STR_TOWN_LABEL_TINY_BLACK, t->index, 0); |
1056 |
AddStringToDraw(t->sign.left + 1, t->sign.top - 3, STR_TOWN_LABEL_TINY_WHITE, t->index, 0); |
|
1057 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1058 |
} |
5027 | 1059 |
break; |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1060 |
|
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1061 |
default: NOT_REACHED(); |
0 | 1062 |
} |
1063 |
} |
|
1064 |
||
5025 | 1065 |
|
1066 |
static void AddStation(const Station *st, StringID str, uint16 width) |
|
1067 |
{ |
|
10202
19da84f6725c
(svn r12734) -Codechange: use a vector instead of allocating memory in a big byte array for StringSpriteToDraw.
rubidium
parents:
10164
diff
changeset
|
1068 |
AddStringToDraw(st->sign.left + 1, st->sign.top + 1, str, st->index, st->facilities, (st->owner == OWNER_NONE || st->facilities == 0) ? 0xE : _player_colors[st->owner], width); |
5025 | 1069 |
} |
1070 |
||
1071 |
||
410 | 1072 |
static void ViewportAddStationNames(DrawPixelInfo *dpi) |
0 | 1073 |
{ |
1074 |
int left, top, right, bottom; |
|
5025 | 1075 |
const Station *st; |
0 | 1076 |
|
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8419
diff
changeset
|
1077 |
if (!HasBit(_display_opt, DO_SHOW_STATION_NAMES) || _game_mode == GM_MENU) |
0 | 1078 |
return; |
1079 |
||
1080 |
left = dpi->left; |
|
1081 |
top = dpi->top; |
|
1082 |
right = left + dpi->width; |
|
1083 |
bottom = top + dpi->height; |
|
1084 |
||
5027 | 1085 |
switch (dpi->zoom) { |
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1086 |
case ZOOM_LVL_NORMAL: |
5027 | 1087 |
FOR_ALL_STATIONS(st) { |
1088 |
if (bottom > st->sign.top && |
|
1089 |
top < st->sign.top + 12 && |
|
1090 |
right > st->sign.left && |
|
1091 |
left < st->sign.left + st->sign.width_1) { |
|
1092 |
AddStation(st, STR_305C_0, st->sign.width_1); |
|
1093 |
} |
|
0 | 1094 |
} |
5027 | 1095 |
break; |
1096 |
||
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1097 |
case ZOOM_LVL_OUT_2X: |
5027 | 1098 |
right += 2; |
1099 |
bottom += 2; |
|
1100 |
FOR_ALL_STATIONS(st) { |
|
1101 |
if (bottom > st->sign.top && |
|
1102 |
top < st->sign.top + 24 && |
|
1103 |
right > st->sign.left && |
|
10229
fba3f9fa44d7
(svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium
parents:
10217
diff
changeset
|
1104 |
left < st->sign.left + st->sign.width_1 * 2) { |
5027 | 1105 |
AddStation(st, STR_305C_0, st->sign.width_1); |
1106 |
} |
|
0 | 1107 |
} |
5027 | 1108 |
break; |
1109 |
||
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1110 |
case ZOOM_LVL_OUT_4X: |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1111 |
case ZOOM_LVL_OUT_8X: |
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1112 |
right += ScaleByZoom(1, dpi->zoom); |
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1113 |
bottom += ScaleByZoom(1, dpi->zoom) + 1; |
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1114 |
|
5027 | 1115 |
FOR_ALL_STATIONS(st) { |
1116 |
if (bottom > st->sign.top && |
|
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1117 |
top < st->sign.top + ScaleByZoom(12, dpi->zoom) && |
5027 | 1118 |
right > st->sign.left && |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1119 |
left < st->sign.left + ScaleByZoom(st->sign.width_2, dpi->zoom)) { |
5027 | 1120 |
AddStation(st, STR_STATION_SIGN_TINY, st->sign.width_2 | 0x8000); |
1121 |
} |
|
0 | 1122 |
} |
5027 | 1123 |
break; |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1124 |
|
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1125 |
default: NOT_REACHED(); |
0 | 1126 |
} |
1127 |
} |
|
1128 |
||
5025 | 1129 |
|
1130 |
static void AddSign(const Sign *si, StringID str, uint16 width) |
|
1131 |
{ |
|
10202
19da84f6725c
(svn r12734) -Codechange: use a vector instead of allocating memory in a big byte array for StringSpriteToDraw.
rubidium
parents:
10164
diff
changeset
|
1132 |
AddStringToDraw(si->sign.left + 1, si->sign.top + 1, str, si->index, 0, (si->owner == OWNER_NONE) ? 14 : _player_colors[si->owner], width); |
5025 | 1133 |
} |
1134 |
||
1135 |
||
410 | 1136 |
static void ViewportAddSigns(DrawPixelInfo *dpi) |
0 | 1137 |
{ |
5025 | 1138 |
const Sign *si; |
0 | 1139 |
int left, top, right, bottom; |
1140 |
||
9302
4aa3c4a44b16
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
9294
diff
changeset
|
1141 |
/* Signs are turned off or are invisible */ |
4aa3c4a44b16
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
9294
diff
changeset
|
1142 |
if (!HasBit(_display_opt, DO_SHOW_SIGNS) || IsInvisibilitySet(TO_SIGNS)) return; |
0 | 1143 |
|
1144 |
left = dpi->left; |
|
1145 |
top = dpi->top; |
|
1146 |
right = left + dpi->width; |
|
1147 |
bottom = top + dpi->height; |
|
1148 |
||
5027 | 1149 |
switch (dpi->zoom) { |
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1150 |
case ZOOM_LVL_NORMAL: |
5027 | 1151 |
FOR_ALL_SIGNS(si) { |
1152 |
if (bottom > si->sign.top && |
|
1153 |
top < si->sign.top + 12 && |
|
1154 |
right > si->sign.left && |
|
1155 |
left < si->sign.left + si->sign.width_1) { |
|
1156 |
AddSign(si, STR_2806, si->sign.width_1); |
|
1157 |
} |
|
0 | 1158 |
} |
5027 | 1159 |
break; |
1160 |
||
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1161 |
case ZOOM_LVL_OUT_2X: |
5027 | 1162 |
right += 2; |
1163 |
bottom += 2; |
|
1164 |
FOR_ALL_SIGNS(si) { |
|
1165 |
if (bottom > si->sign.top && |
|
1166 |
top < si->sign.top + 24 && |
|
1167 |
right > si->sign.left && |
|
1168 |
left < si->sign.left + si->sign.width_1 * 2) { |
|
1169 |
AddSign(si, STR_2806, si->sign.width_1); |
|
1170 |
} |
|
0 | 1171 |
} |
5027 | 1172 |
break; |
1173 |
||
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1174 |
case ZOOM_LVL_OUT_4X: |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1175 |
case ZOOM_LVL_OUT_8X: |
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1176 |
right += ScaleByZoom(1, dpi->zoom); |
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1177 |
bottom += ScaleByZoom(1, dpi->zoom) + 1; |
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1178 |
|
5027 | 1179 |
FOR_ALL_SIGNS(si) { |
1180 |
if (bottom > si->sign.top && |
|
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1181 |
top < si->sign.top + ScaleByZoom(12, dpi->zoom) && |
5027 | 1182 |
right > si->sign.left && |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1183 |
left < si->sign.left + ScaleByZoom(si->sign.width_2, dpi->zoom)) { |
8447
286f94800163
(svn r11507) -Fix [FS#1463]: signs totally illegible when transparant signs is turned on and zoomed out more than one level.
rubidium
parents:
8427
diff
changeset
|
1184 |
AddSign(si, IsTransparencySet(TO_SIGNS) ? STR_2002_WHITE : STR_2002, si->sign.width_2 | 0x8000); |
5027 | 1185 |
} |
0 | 1186 |
} |
5027 | 1187 |
break; |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1188 |
|
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1189 |
default: NOT_REACHED(); |
0 | 1190 |
} |
1191 |
} |
|
1192 |
||
5025 | 1193 |
|
1194 |
static void AddWaypoint(const Waypoint *wp, StringID str, uint16 width) |
|
1195 |
{ |
|
10202
19da84f6725c
(svn r12734) -Codechange: use a vector instead of allocating memory in a big byte array for StringSpriteToDraw.
rubidium
parents:
10164
diff
changeset
|
1196 |
AddStringToDraw(wp->sign.left + 1, wp->sign.top + 1, str, wp->index, 0, (wp->deleted ? 0xE : 11), width); |
5025 | 1197 |
} |
1198 |
||
1199 |
||
410 | 1200 |
static void ViewportAddWaypoints(DrawPixelInfo *dpi) |
0 | 1201 |
{ |
5025 | 1202 |
const Waypoint *wp; |
0 | 1203 |
int left, top, right, bottom; |
1204 |
||
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8419
diff
changeset
|
1205 |
if (!HasBit(_display_opt, DO_WAYPOINTS)) |
0 | 1206 |
return; |
1207 |
||
1208 |
left = dpi->left; |
|
1209 |
top = dpi->top; |
|
1210 |
right = left + dpi->width; |
|
1211 |
bottom = top + dpi->height; |
|
1212 |
||
5027 | 1213 |
switch (dpi->zoom) { |
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1214 |
case ZOOM_LVL_NORMAL: |
5027 | 1215 |
FOR_ALL_WAYPOINTS(wp) { |
1216 |
if (bottom > wp->sign.top && |
|
1217 |
top < wp->sign.top + 12 && |
|
1218 |
right > wp->sign.left && |
|
1219 |
left < wp->sign.left + wp->sign.width_1) { |
|
1220 |
AddWaypoint(wp, STR_WAYPOINT_VIEWPORT, wp->sign.width_1); |
|
1221 |
} |
|
0 | 1222 |
} |
5027 | 1223 |
break; |
1224 |
||
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1225 |
case ZOOM_LVL_OUT_2X: |
5027 | 1226 |
right += 2; |
1227 |
bottom += 2; |
|
1228 |
FOR_ALL_WAYPOINTS(wp) { |
|
1229 |
if (bottom > wp->sign.top && |
|
1230 |
top < wp->sign.top + 24 && |
|
1231 |
right > wp->sign.left && |
|
10229
fba3f9fa44d7
(svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium
parents:
10217
diff
changeset
|
1232 |
left < wp->sign.left + wp->sign.width_1 * 2) { |
5027 | 1233 |
AddWaypoint(wp, STR_WAYPOINT_VIEWPORT, wp->sign.width_1); |
1234 |
} |
|
0 | 1235 |
} |
5027 | 1236 |
break; |
1237 |
||
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1238 |
case ZOOM_LVL_OUT_4X: |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1239 |
case ZOOM_LVL_OUT_8X: |
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1240 |
right += ScaleByZoom(1, dpi->zoom); |
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1241 |
bottom += ScaleByZoom(1, dpi->zoom) + 1; |
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1242 |
|
5027 | 1243 |
FOR_ALL_WAYPOINTS(wp) { |
1244 |
if (bottom > wp->sign.top && |
|
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1245 |
top < wp->sign.top + ScaleByZoom(12, dpi->zoom) && |
5027 | 1246 |
right > wp->sign.left && |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1247 |
left < wp->sign.left + ScaleByZoom(wp->sign.width_2, dpi->zoom)) { |
5027 | 1248 |
AddWaypoint(wp, STR_WAYPOINT_VIEWPORT_TINY, wp->sign.width_2 | 0x8000); |
1249 |
} |
|
0 | 1250 |
} |
5027 | 1251 |
break; |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1252 |
|
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1253 |
default: NOT_REACHED(); |
0 | 1254 |
} |
1255 |
} |
|
1256 |
||
1257 |
void UpdateViewportSignPos(ViewportSign *sign, int left, int top, StringID str) |
|
1258 |
{ |
|
1259 |
char buffer[128]; |
|
2116 | 1260 |
uint w; |
0 | 1261 |
|
1262 |
sign->top = top; |
|
1263 |
||
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4885
diff
changeset
|
1264 |
GetString(buffer, str, lastof(buffer)); |
4609
6c337b3fbf4b
(svn r6462) -Codechange: Have GetStringWidth() return width as well as the height bounding
Darkvater
parents:
4539
diff
changeset
|
1265 |
w = GetStringBoundingBox(buffer).width + 3; |
0 | 1266 |
sign->width_1 = w; |
2116 | 1267 |
sign->left = left - w / 2; |
0 | 1268 |
|
4609
6c337b3fbf4b
(svn r6462) -Codechange: Have GetStringWidth() return width as well as the height bounding
Darkvater
parents:
4539
diff
changeset
|
1269 |
/* zoomed out version */ |
3798
37a2090eac94
(svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents:
3645
diff
changeset
|
1270 |
_cur_fontsize = FS_SMALL; |
4609
6c337b3fbf4b
(svn r6462) -Codechange: Have GetStringWidth() return width as well as the height bounding
Darkvater
parents:
4539
diff
changeset
|
1271 |
w = GetStringBoundingBox(buffer).width + 3; |
3798
37a2090eac94
(svn r4802) - Codechange: replace _stringwidth_base and associated magic numbers with a FontSize enum, using the numbers (which are SpriteIDs) in only the places needed.
peter1138
parents:
3645
diff
changeset
|
1272 |
_cur_fontsize = FS_NORMAL; |
1390
53a5713cf3f9
(svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents:
1363
diff
changeset
|
1273 |
sign->width_2 = w; |
0 | 1274 |
} |
1275 |
||
1276 |
||
10203
766c98a973c5
(svn r12735) -Codechange: use a vector instead of allocating memory in a byte array for TileSpriteToDraw.
rubidium
parents:
10202
diff
changeset
|
1277 |
static void ViewportDrawTileSprites(const TileSpriteToDrawVector *tstdv) |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1278 |
{ |
10205
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
10204
diff
changeset
|
1279 |
const TileSpriteToDraw *tsend = tstdv->End(); |
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
10204
diff
changeset
|
1280 |
for (const TileSpriteToDraw *ts = tstdv->Begin(); ts != tsend; ++ts) { |
0 | 1281 |
Point pt = RemapCoords(ts->x, ts->y, ts->z); |
8177
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
1282 |
DrawSprite(ts->image, ts->pal, pt.x, pt.y, ts->sub); |
10203
766c98a973c5
(svn r12735) -Codechange: use a vector instead of allocating memory in a byte array for TileSpriteToDraw.
rubidium
parents:
10202
diff
changeset
|
1283 |
} |
0 | 1284 |
} |
1285 |
||
10207
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
1286 |
static void ViewportSortParentSprites(ParentSpriteToSortVector *psdv) |
0 | 1287 |
{ |
10207
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
1288 |
ParentSpriteToDraw **psdvend = psdv->End(); |
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
1289 |
ParentSpriteToDraw **psd = psdv->Begin(); |
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
1290 |
while (psd != psdvend) { |
10204
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1291 |
ParentSpriteToDraw *ps = *psd; |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1292 |
|
10206
69c8c35ffa7e
(svn r12738) -Fix (r12736): some sprites could be left unsorted
smatz
parents:
10205
diff
changeset
|
1293 |
if (ps->comparison_done) { |
69c8c35ffa7e
(svn r12738) -Fix (r12736): some sprites could be left unsorted
smatz
parents:
10205
diff
changeset
|
1294 |
psd++; |
69c8c35ffa7e
(svn r12738) -Fix (r12736): some sprites could be left unsorted
smatz
parents:
10205
diff
changeset
|
1295 |
continue; |
69c8c35ffa7e
(svn r12738) -Fix (r12736): some sprites could be left unsorted
smatz
parents:
10205
diff
changeset
|
1296 |
} |
10204
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1297 |
|
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1298 |
ps->comparison_done = true; |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1299 |
|
10207
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
1300 |
for (ParentSpriteToDraw **psd2 = psd + 1; psd2 != psdvend; psd2++) { |
10204
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1301 |
ParentSpriteToDraw *ps2 = *psd2; |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1302 |
|
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1303 |
if (ps2->comparison_done) continue; |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1304 |
|
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1305 |
/* Decide which comparator to use, based on whether the bounding |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1306 |
* boxes overlap |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1307 |
*/ |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1308 |
if (ps->xmax >= ps2->xmin && ps->xmin <= ps2->xmax && // overlap in X? |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1309 |
ps->ymax >= ps2->ymin && ps->ymin <= ps2->ymax && // overlap in Y? |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1310 |
ps->zmax >= ps2->zmin && ps->zmin <= ps2->zmax) { // overlap in Z? |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1311 |
/* Use X+Y+Z as the sorting order, so sprites closer to the bottom of |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1312 |
* the screen and with higher Z elevation, are drawn in front. |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1313 |
* Here X,Y,Z are the coordinates of the "center of mass" of the sprite, |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1314 |
* i.e. X=(left+right)/2, etc. |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1315 |
* However, since we only care about order, don't actually divide / 2 |
4187
50b94420d9a2
(svn r5629) Simplify the test whether two bounding boxes overlap
tron
parents:
4186
diff
changeset
|
1316 |
*/ |
10204
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1317 |
if (ps->xmin + ps->xmax + ps->ymin + ps->ymax + ps->zmin + ps->zmax <= |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1318 |
ps2->xmin + ps2->xmax + ps2->ymin + ps2->ymax + ps2->zmin + ps2->zmax) { |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1319 |
continue; |
1934
b3d568113d4d
(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
|
1320 |
} |
10204
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1321 |
} else { |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1322 |
/* We only change the order, if it is definite. |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1323 |
* I.e. every single order of X, Y, Z says ps2 is behind ps or they overlap. |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1324 |
* That is: If one partial order says ps behind ps2, do not change the order. |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1325 |
*/ |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1326 |
if (ps->xmax < ps2->xmin || |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1327 |
ps->ymax < ps2->ymin || |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1328 |
ps->zmax < ps2->zmin) { |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1329 |
continue; |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1330 |
} |
0 | 1331 |
} |
10204
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1332 |
|
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1333 |
/* Swap the two sprites ps and ps2 using bubble-sort algorithm. */ |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1334 |
ParentSpriteToDraw **psd3 = psd; |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1335 |
do { |
10207
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
1336 |
ParentSpriteToDraw *temp = *psd3; |
10204
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1337 |
*psd3 = ps2; |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1338 |
ps2 = temp; |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1339 |
|
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1340 |
psd3++; |
5d58118e6820
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium
parents:
10203
diff
changeset
|
1341 |
} while (psd3 <= psd2); |
0 | 1342 |
} |
1343 |
} |
|
1344 |
} |
|
1345 |
||
10208
98dc9f65629e
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium
parents:
10207
diff
changeset
|
1346 |
static void ViewportDrawParentSprites(const ParentSpriteToSortVector *psd, const ChildScreenSpriteToDrawVector *csstdv) |
0 | 1347 |
{ |
10207
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
1348 |
const ParentSpriteToDraw * const *psd_end = psd->End(); |
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
1349 |
for (const ParentSpriteToDraw * const *it = psd->Begin(); it != psd_end; it++) { |
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
1350 |
const ParentSpriteToDraw *ps = *it; |
8177
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
1351 |
if (ps->image != SPR_EMPTY_BOUNDING_BOX) DrawSprite(ps->image, ps->pal, ps->x, ps->y, ps->sub); |
0 | 1352 |
|
10208
98dc9f65629e
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium
parents:
10207
diff
changeset
|
1353 |
const ChildScreenSpriteToDraw *last = csstdv->Get(ps->last_child); |
98dc9f65629e
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium
parents:
10207
diff
changeset
|
1354 |
for (const ChildScreenSpriteToDraw *cs = csstdv->Get(ps->first_child); cs != last; cs++) { |
8177
f0bcc8e149f3
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium
parents:
8175
diff
changeset
|
1355 |
DrawSprite(cs->image, cs->pal, ps->left + cs->x, ps->top + cs->y, cs->sub); |
0 | 1356 |
} |
1357 |
} |
|
1358 |
} |
|
1359 |
||
8139
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
1360 |
/** |
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
1361 |
* Draws the bounding boxes of all ParentSprites |
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
1362 |
* @param psd Array of ParentSprites |
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
1363 |
*/ |
10207
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
1364 |
static void ViewportDrawBoundingBoxes(const ParentSpriteToSortVector *psd) |
8139
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
1365 |
{ |
10207
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
1366 |
const ParentSpriteToDraw * const *psd_end = psd->End(); |
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
1367 |
for (const ParentSpriteToDraw * const *it = psd->Begin(); it != psd_end; it++) { |
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
1368 |
const ParentSpriteToDraw *ps = *it; |
8139
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
1369 |
Point pt1 = RemapCoords(ps->xmax + 1, ps->ymax + 1, ps->zmax + 1); // top front corner |
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
1370 |
Point pt2 = RemapCoords(ps->xmin , ps->ymax + 1, ps->zmax + 1); // top left corner |
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
1371 |
Point pt3 = RemapCoords(ps->xmax + 1, ps->ymin , ps->zmax + 1); // top right corner |
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
1372 |
Point pt4 = RemapCoords(ps->xmax + 1, ps->ymax + 1, ps->zmin ); // bottom front corner |
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
1373 |
|
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
1374 |
DrawBox( pt1.x, pt1.y, |
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
1375 |
pt2.x - pt1.x, pt2.y - pt1.y, |
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
1376 |
pt3.x - pt1.x, pt3.y - pt1.y, |
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
1377 |
pt4.x - pt1.x, pt4.y - pt1.y); |
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
1378 |
} |
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
1379 |
} |
16ad832aa538
(svn r11174) -Codechange: add possibility to show the bounding boxes of sprites using CTRL-B so one can get a better understanding of the used bounding boxes to fix the glitches that still exist. Patch by frosch.
rubidium
parents:
8113
diff
changeset
|
1380 |
|
10202
19da84f6725c
(svn r12734) -Codechange: use a vector instead of allocating memory in a big byte array for StringSpriteToDraw.
rubidium
parents:
10164
diff
changeset
|
1381 |
static void ViewportDrawStrings(DrawPixelInfo *dpi, const StringSpriteToDrawVector *sstdv) |
0 | 1382 |
{ |
1383 |
DrawPixelInfo dp; |
|
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1384 |
ZoomLevel zoom; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1385 |
|
0 | 1386 |
_cur_dpi = &dp; |
1387 |
dp = *dpi; |
|
1388 |
||
2116 | 1389 |
zoom = dp.zoom; |
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1390 |
dp.zoom = ZOOM_LVL_NORMAL; |
0 | 1391 |
|
7150
2cfe4a46fa1c
(svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight
parents:
7149
diff
changeset
|
1392 |
dp.left = UnScaleByZoom(dp.left, zoom); |
2cfe4a46fa1c
(svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight
parents:
7149
diff
changeset
|
1393 |
dp.top = UnScaleByZoom(dp.top, zoom); |
2cfe4a46fa1c
(svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight
parents:
7149
diff
changeset
|
1394 |
dp.width = UnScaleByZoom(dp.width, zoom); |
2cfe4a46fa1c
(svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight
parents:
7149
diff
changeset
|
1395 |
dp.height = UnScaleByZoom(dp.height, zoom); |
0 | 1396 |
|
10205
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
10204
diff
changeset
|
1397 |
const StringSpriteToDraw *ssend = sstdv->End(); |
d37e906c7070
(svn r12737) -Codechange: Replace vector with a cut down class to allocate space as necessary. This avoids copying data around for vector's push_back() function.
peter1138
parents:
10204
diff
changeset
|
1398 |
for (const StringSpriteToDraw *ss = sstdv->Begin(); ss != ssend; ++ss) { |
5025 | 1399 |
uint16 colour; |
1400 |
||
0 | 1401 |
if (ss->width != 0) { |
9302
4aa3c4a44b16
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
9294
diff
changeset
|
1402 |
/* Do not draw signs nor station names if they are set invisible */ |
10202
19da84f6725c
(svn r12734) -Codechange: use a vector instead of allocating memory in a big byte array for StringSpriteToDraw.
rubidium
parents:
10164
diff
changeset
|
1403 |
if (IsInvisibilitySet(TO_SIGNS) && ss->string != STR_2806) continue; |
9302
4aa3c4a44b16
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
9294
diff
changeset
|
1404 |
|
7150
2cfe4a46fa1c
(svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight
parents:
7149
diff
changeset
|
1405 |
int x = UnScaleByZoom(ss->x, zoom) - 1; |
2cfe4a46fa1c
(svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight
parents:
7149
diff
changeset
|
1406 |
int y = UnScaleByZoom(ss->y, zoom) - 1; |
2116 | 1407 |
int bottom = y + 11; |
1408 |
int w = ss->width; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1409 |
|
0 | 1410 |
if (w & 0x8000) { |
1411 |
w &= ~0x8000; |
|
1412 |
y--; |
|
1413 |
bottom -= 6; |
|
1414 |
w -= 3; |
|
1415 |
} |
|
1416 |
||
2116 | 1417 |
/* Draw the rectangle if 'tranparent station signs' is off, |
1418 |
* or if we are drawing a general text sign (STR_2806) */ |
|
8345
6caa3fdb972c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
8320
diff
changeset
|
1419 |
if (!IsTransparencySet(TO_SIGNS) || ss->string == STR_2806) { |
2116 | 1420 |
DrawFrameRect( |
1421 |
x, y, x + w, bottom, ss->color, |
|
8345
6caa3fdb972c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
8320
diff
changeset
|
1422 |
IsTransparencySet(TO_SIGNS) ? FR_TRANSPARENT : FR_NONE |
2116 | 1423 |
); |
6923
6913c8a82cc0
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6919
diff
changeset
|
1424 |
} |
0 | 1425 |
} |
1426 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1427 |
SetDParam(0, ss->params[0]); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
1428 |
SetDParam(1, ss->params[1]); |
2116 | 1429 |
/* if we didn't draw a rectangle, or if transparant building is on, |
1430 |
* draw the text in the color the rectangle would have */ |
|
8345
6caa3fdb972c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
8320
diff
changeset
|
1431 |
if (IsTransparencySet(TO_SIGNS) && ss->string != STR_2806 && ss->width != 0) { |
2116 | 1432 |
/* Real colors need the IS_PALETTE_COLOR flag |
1433 |
* otherwise colors from _string_colormap are assumed. */ |
|
5025 | 1434 |
colour = _colour_gradient[ss->color][6] | IS_PALETTE_COLOR; |
0 | 1435 |
} else { |
8320
6ffad7a5d242
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
8265
diff
changeset
|
1436 |
colour = TC_BLACK; |
0 | 1437 |
} |
5025 | 1438 |
DrawString( |
7150
2cfe4a46fa1c
(svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight
parents:
7149
diff
changeset
|
1439 |
UnScaleByZoom(ss->x, zoom), UnScaleByZoom(ss->y, zoom) - (ss->width & 0x8000 ? 2 : 0), |
5025 | 1440 |
ss->string, colour |
1441 |
); |
|
10203
766c98a973c5
(svn r12735) -Codechange: use a vector instead of allocating memory in a byte array for TileSpriteToDraw.
rubidium
parents:
10202
diff
changeset
|
1442 |
} |
0 | 1443 |
} |
1444 |
||
430 | 1445 |
void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom) |
0 | 1446 |
{ |
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1447 |
DrawPixelInfo *old_dpi = _cur_dpi; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1448 |
_cur_dpi = &_vd.dpi; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1449 |
|
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1450 |
_vd.dpi.zoom = vp->zoom; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1451 |
int mask = ScaleByZoom(-1, vp->zoom); |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1452 |
|
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1453 |
_vd.combine_sprites = 0; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1454 |
|
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1455 |
_vd.dpi.width = (right - left) & mask; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1456 |
_vd.dpi.height = (bottom - top) & mask; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1457 |
_vd.dpi.left = left & mask; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1458 |
_vd.dpi.top = top & mask; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1459 |
_vd.dpi.pitch = old_dpi->pitch; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1460 |
_vd.last_child = NULL; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1461 |
|
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1462 |
int x = UnScaleByZoom(_vd.dpi.left - (vp->virtual_left & mask), vp->zoom) + vp->left; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1463 |
int y = UnScaleByZoom(_vd.dpi.top - (vp->virtual_top & mask), vp->zoom) + vp->top; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1464 |
|
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1465 |
_vd.dpi.dst_ptr = BlitterFactoryBase::GetCurrentBlitter()->MoveTo(old_dpi->dst_ptr, x - old_dpi->left, y - old_dpi->top); |
0 | 1466 |
|
1467 |
ViewportAddLandscape(); |
|
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1468 |
ViewportAddVehicles(&_vd.dpi); |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1469 |
DrawTextEffects(&_vd.dpi); |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1470 |
|
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1471 |
ViewportAddTownNames(&_vd.dpi); |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1472 |
ViewportAddStationNames(&_vd.dpi); |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1473 |
ViewportAddSigns(&_vd.dpi); |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1474 |
ViewportAddWaypoints(&_vd.dpi); |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1475 |
|
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1476 |
if (_vd.tile_sprites_to_draw.items != 0) ViewportDrawTileSprites(&_vd.tile_sprites_to_draw); |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1477 |
|
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1478 |
ParentSpriteToDraw *psd_end = _vd.parent_sprites_to_draw.End(); |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1479 |
for (ParentSpriteToDraw *it = _vd.parent_sprites_to_draw.Begin(); it != psd_end; it++) { |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1480 |
*_vd.parent_sprites_to_sort.Append() = it; |
10207
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
1481 |
} |
0bdc24d88198
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium
parents:
10206
diff
changeset
|
1482 |
|
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1483 |
ViewportSortParentSprites(&_vd.parent_sprites_to_sort); |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1484 |
ViewportDrawParentSprites(&_vd.parent_sprites_to_sort, &_vd.child_screen_sprites_to_draw); |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1485 |
|
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1486 |
if (_draw_bounding_boxes) ViewportDrawBoundingBoxes(&_vd.parent_sprites_to_sort); |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1487 |
|
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1488 |
if (_vd.string_sprites_to_draw.items != 0) ViewportDrawStrings(&_vd.dpi, &_vd.string_sprites_to_draw); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1489 |
|
0 | 1490 |
_cur_dpi = old_dpi; |
10209
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1491 |
|
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1492 |
_vd.string_sprites_to_draw.items = 0; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1493 |
_vd.tile_sprites_to_draw.items = 0; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1494 |
_vd.parent_sprites_to_draw.items = 0; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1495 |
_vd.parent_sprites_to_sort.items = 0; |
13cb37e961f6
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium
parents:
10208
diff
changeset
|
1496 |
_vd.child_screen_sprites_to_draw.items = 0; |
0 | 1497 |
} |
1498 |
||
6919
339210ecccd3
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6574
diff
changeset
|
1499 |
/** Make sure we don't draw a too big area at a time. |
339210ecccd3
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6574
diff
changeset
|
1500 |
* If we do, the sprite memory will overflow. */ |
5120
e12dfc67761f
(svn r7200) -Codechange: remove unneeded redraw (console.c), coding style, use FindWindowById
Darkvater
parents:
5045
diff
changeset
|
1501 |
static void ViewportDrawChk(const ViewPort *vp, int left, int top, int right, int bottom) |
0 | 1502 |
{ |
7122
0607a15aedc0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
7120
diff
changeset
|
1503 |
if (ScaleByZoom(bottom - top, vp->zoom) * ScaleByZoom(right - left, vp->zoom) > 180000) { |
0 | 1504 |
if ((bottom - top) > (right - left)) { |
1505 |
int t = (top + bottom) >> 1; |
|
1506 |
ViewportDrawChk(vp, left, top, right, t); |
|
1507 |
ViewportDrawChk(vp, left, t, right, bottom); |
|
1508 |
} else { |
|
1509 |
int t = (left + right) >> 1; |
|
1510 |
ViewportDrawChk(vp, left, top, t, bottom); |
|
1511 |
ViewportDrawChk(vp, t, top, right, bottom); |
|
1512 |
} |
|
1513 |
} else { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1514 |
ViewportDoDraw(vp, |
7122
0607a15aedc0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
7120
diff
changeset
|
1515 |
ScaleByZoom(left - vp->left, vp->zoom) + vp->virtual_left, |
0607a15aedc0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
7120
diff
changeset
|
1516 |
ScaleByZoom(top - vp->top, vp->zoom) + vp->virtual_top, |
0607a15aedc0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
7120
diff
changeset
|
1517 |
ScaleByZoom(right - vp->left, vp->zoom) + vp->virtual_left, |
0607a15aedc0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
7120
diff
changeset
|
1518 |
ScaleByZoom(bottom - vp->top, vp->zoom) + vp->virtual_top |
0 | 1519 |
); |
1520 |
} |
|
1521 |
} |
|
1522 |
||
5120
e12dfc67761f
(svn r7200) -Codechange: remove unneeded redraw (console.c), coding style, use FindWindowById
Darkvater
parents:
5045
diff
changeset
|
1523 |
static inline void ViewportDraw(const ViewPort *vp, int left, int top, int right, int bottom) |
0 | 1524 |
{ |
2116 | 1525 |
if (right <= vp->left || bottom <= vp->top) return; |
0 | 1526 |
|
2116 | 1527 |
if (left >= vp->left + vp->width) return; |
0 | 1528 |
|
1529 |
if (left < vp->left) left = vp->left; |
|
2116 | 1530 |
if (right > vp->left + vp->width) right = vp->left + vp->width; |
0 | 1531 |
|
2116 | 1532 |
if (top >= vp->top + vp->height) return; |
0 | 1533 |
|
1534 |
if (top < vp->top) top = vp->top; |
|
2116 | 1535 |
if (bottom > vp->top + vp->height) bottom = vp->top + vp->height; |
0 | 1536 |
|
1537 |
ViewportDrawChk(vp, left, top, right, bottom); |
|
1538 |
} |
|
1539 |
||
10595
7957c71b0dfe
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents:
10566
diff
changeset
|
1540 |
void Window::DrawViewport() const |
2116 | 1541 |
{ |
0 | 1542 |
DrawPixelInfo *dpi = _cur_dpi; |
1543 |
||
10595
7957c71b0dfe
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents:
10566
diff
changeset
|
1544 |
dpi->left += this->left; |
7957c71b0dfe
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents:
10566
diff
changeset
|
1545 |
dpi->top += this->top; |
7957c71b0dfe
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents:
10566
diff
changeset
|
1546 |
|
7957c71b0dfe
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents:
10566
diff
changeset
|
1547 |
ViewportDraw(this->viewport, dpi->left, dpi->top, dpi->left + dpi->width, dpi->top + dpi->height); |
7957c71b0dfe
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents:
10566
diff
changeset
|
1548 |
|
7957c71b0dfe
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents:
10566
diff
changeset
|
1549 |
dpi->left -= this->left; |
7957c71b0dfe
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents:
10566
diff
changeset
|
1550 |
dpi->top -= this->top; |
0 | 1551 |
} |
1552 |
||
7565
a2948dd92c0e
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138
parents:
7552
diff
changeset
|
1553 |
static inline void ClampViewportToMap(const ViewPort *vp, int &x, int &y) |
a2948dd92c0e
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138
parents:
7552
diff
changeset
|
1554 |
{ |
a2948dd92c0e
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138
parents:
7552
diff
changeset
|
1555 |
/* Centre of the viewport is hot spot */ |
a2948dd92c0e
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138
parents:
7552
diff
changeset
|
1556 |
x += vp->virtual_width / 2; |
a2948dd92c0e
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138
parents:
7552
diff
changeset
|
1557 |
y += vp->virtual_height / 2; |
a2948dd92c0e
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138
parents:
7552
diff
changeset
|
1558 |
|
a2948dd92c0e
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138
parents:
7552
diff
changeset
|
1559 |
/* Convert viewport coordinates to map coordinates |
a2948dd92c0e
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138
parents:
7552
diff
changeset
|
1560 |
* Calculation is scaled by 4 to avoid rounding errors */ |
a2948dd92c0e
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138
parents:
7552
diff
changeset
|
1561 |
int vx = -x + y * 2; |
a2948dd92c0e
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138
parents:
7552
diff
changeset
|
1562 |
int vy = x + y * 2; |
a2948dd92c0e
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138
parents:
7552
diff
changeset
|
1563 |
|
a2948dd92c0e
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138
parents:
7552
diff
changeset
|
1564 |
/* clamp to size of map */ |
8418
b49fc6be1ab9
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents:
8414
diff
changeset
|
1565 |
vx = Clamp(vx, 0, MapMaxX() * TILE_SIZE * 4); |
b49fc6be1ab9
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents:
8414
diff
changeset
|
1566 |
vy = Clamp(vy, 0, MapMaxY() * TILE_SIZE * 4); |
7565
a2948dd92c0e
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138
parents:
7552
diff
changeset
|
1567 |
|
a2948dd92c0e
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138
parents:
7552
diff
changeset
|
1568 |
/* Convert map coordinates to viewport coordinates */ |
a2948dd92c0e
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138
parents:
7552
diff
changeset
|
1569 |
x = (-vx + vy) / 2; |
a2948dd92c0e
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138
parents:
7552
diff
changeset
|
1570 |
y = ( vx + vy) / 4; |
a2948dd92c0e
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138
parents:
7552
diff
changeset
|
1571 |
|
a2948dd92c0e
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138
parents:
7552
diff
changeset
|
1572 |
/* Remove centreing */ |
a2948dd92c0e
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138
parents:
7552
diff
changeset
|
1573 |
x -= vp->virtual_width / 2; |
a2948dd92c0e
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138
parents:
7552
diff
changeset
|
1574 |
y -= vp->virtual_height / 2; |
a2948dd92c0e
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138
parents:
7552
diff
changeset
|
1575 |
} |
a2948dd92c0e
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138
parents:
7552
diff
changeset
|
1576 |
|
0 | 1577 |
void UpdateViewportPosition(Window *w) |
1578 |
{ |
|
2116 | 1579 |
const ViewPort *vp = w->viewport; |
0 | 1580 |
|
10504 | 1581 |
if (w->viewport->follow_vehicle != INVALID_VEHICLE) { |
1582 |
const Vehicle* veh = GetVehicle(w->viewport->follow_vehicle); |
|
2116 | 1583 |
Point pt = MapXYZToViewport(vp, veh->x_pos, veh->y_pos, veh->z_pos); |
0 | 1584 |
|
1585 |
SetViewportPosition(w, pt.x, pt.y); |
|
1586 |
} else { |
|
7565
a2948dd92c0e
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138
parents:
7552
diff
changeset
|
1587 |
/* Ensure the destination location is within the map */ |
10504 | 1588 |
ClampViewportToMap(vp, w->viewport->dest_scrollpos_x, w->viewport->dest_scrollpos_y); |
1589 |
||
1590 |
int delta_x = w->viewport->dest_scrollpos_x - w->viewport->scrollpos_x; |
|
1591 |
int delta_y = w->viewport->dest_scrollpos_y - w->viewport->scrollpos_y; |
|
7226
a8650d6ecb53
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
7165
diff
changeset
|
1592 |
|
a8650d6ecb53
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
7165
diff
changeset
|
1593 |
if (delta_x != 0 || delta_y != 0) { |
7227
41a868cb2c8e
(svn r9963) -Fix (r9962): 'smooth_scroll' patch setting was ignored (always on) in some places.
peter1138
parents:
7226
diff
changeset
|
1594 |
if (_patches.smooth_scroll) { |
41a868cb2c8e
(svn r9963) -Fix (r9962): 'smooth_scroll' patch setting was ignored (always on) in some places.
peter1138
parents:
7226
diff
changeset
|
1595 |
int max_scroll = ScaleByMapSize1D(512); |
41a868cb2c8e
(svn r9963) -Fix (r9962): 'smooth_scroll' patch setting was ignored (always on) in some places.
peter1138
parents:
7226
diff
changeset
|
1596 |
/* Not at our desired positon yet... */ |
10504 | 1597 |
w->viewport->scrollpos_x += Clamp(delta_x / 4, -max_scroll, max_scroll); |
1598 |
w->viewport->scrollpos_y += Clamp(delta_y / 4, -max_scroll, max_scroll); |
|
7227
41a868cb2c8e
(svn r9963) -Fix (r9962): 'smooth_scroll' patch setting was ignored (always on) in some places.
peter1138
parents:
7226
diff
changeset
|
1599 |
} else { |
10504 | 1600 |
w->viewport->scrollpos_x = w->viewport->dest_scrollpos_x; |
1601 |
w->viewport->scrollpos_y = w->viewport->dest_scrollpos_y; |
|
7227
41a868cb2c8e
(svn r9963) -Fix (r9962): 'smooth_scroll' patch setting was ignored (always on) in some places.
peter1138
parents:
7226
diff
changeset
|
1602 |
} |
7226
a8650d6ecb53
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
7165
diff
changeset
|
1603 |
} |
a8650d6ecb53
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
7165
diff
changeset
|
1604 |
|
10504 | 1605 |
ClampViewportToMap(vp, w->viewport->scrollpos_x, w->viewport->scrollpos_y); |
1606 |
||
1607 |
SetViewportPosition(w, w->viewport->scrollpos_x, w->viewport->scrollpos_y); |
|
0 | 1608 |
} |
1609 |
} |
|
1610 |
||
8041
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
7993
diff
changeset
|
1611 |
/** |
10255
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
1612 |
* Marks a viewport as dirty for repaint if it displays (a part of) the area the needs to be repainted. |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
1613 |
* @param vp The viewport to mark as dirty |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
1614 |
* @param left Left edge of area to repaint |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
1615 |
* @param top Top edge of area to repaint |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
1616 |
* @param right Right edge of area to repaint |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
1617 |
* @param bottom Bottom edge of area to repaint |
8041
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
7993
diff
changeset
|
1618 |
* @ingroup dirty |
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
7993
diff
changeset
|
1619 |
*/ |
2116 | 1620 |
static void MarkViewportDirty(const ViewPort *vp, int left, int top, int right, int bottom) |
0 | 1621 |
{ |
2116 | 1622 |
right -= vp->virtual_left; |
1623 |
if (right <= 0) return; |
|
0 | 1624 |
|
2116 | 1625 |
bottom -= vp->virtual_top; |
1626 |
if (bottom <= 0) return; |
|
0 | 1627 |
|
2116 | 1628 |
left = max(0, left - vp->virtual_left); |
0 | 1629 |
|
2116 | 1630 |
if (left >= vp->virtual_width) return; |
0 | 1631 |
|
2116 | 1632 |
top = max(0, top - vp->virtual_top); |
1633 |
||
1634 |
if (top >= vp->virtual_height) return; |
|
0 | 1635 |
|
1636 |
SetDirtyBlocks( |
|
7122
0607a15aedc0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
7120
diff
changeset
|
1637 |
UnScaleByZoom(left, vp->zoom) + vp->left, |
0607a15aedc0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
7120
diff
changeset
|
1638 |
UnScaleByZoom(top, vp->zoom) + vp->top, |
0607a15aedc0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
7120
diff
changeset
|
1639 |
UnScaleByZoom(right, vp->zoom) + vp->left, |
0607a15aedc0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
7120
diff
changeset
|
1640 |
UnScaleByZoom(bottom, vp->zoom) + vp->top |
0 | 1641 |
); |
1642 |
} |
|
1643 |
||
10255
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
1644 |
/** |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
1645 |
* Mark all viewports that display an area as dirty (in need of repaint). |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
1646 |
* @param left Left edge of area to repaint |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
1647 |
* @param top Top edge of area to repaint |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
1648 |
* @param right Right edge of area to repaint |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
1649 |
* @param bottom Bottom edge of area to repaint |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
1650 |
* @ingroup dirty |
5600b575e6e7
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
10239
diff
changeset
|
1651 |
*/ |
0 | 1652 |
void MarkAllViewportsDirty(int left, int top, int right, int bottom) |
1653 |
{ |
|
10217
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
1654 |
Window **wz; |
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
1655 |
|
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
1656 |
FOR_ALL_WINDOWS(wz) { |
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
1657 |
ViewPort *vp = (*wz)->viewport; |
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
1658 |
if (vp != NULL) { |
0 | 1659 |
assert(vp->width != 0); |
1660 |
MarkViewportDirty(vp, left, top, right, bottom); |
|
1661 |
} |
|
10217
691a6b2140c6
(svn r12749) -Codechange: store the viewport information in the windows that have a viewport instead of one global array with a viewport for each window, even when they do not use the viewport.
rubidium
parents:
10209
diff
changeset
|
1662 |
} |
0 | 1663 |
} |
1664 |
||
2116 | 1665 |
void MarkTileDirtyByTile(TileIndex tile) |
1666 |
{ |
|
3421
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1667 |
Point pt = RemapCoords(TileX(tile) * TILE_SIZE, TileY(tile) * TILE_SIZE, GetTileZ(tile)); |
0 | 1668 |
MarkAllViewportsDirty( |
1669 |
pt.x - 31, |
|
1670 |
pt.y - 122, |
|
1671 |
pt.x - 31 + 67, |
|
1672 |
pt.y - 122 + 154 |
|
1673 |
); |
|
1674 |
} |
|
1675 |
||
1676 |
void MarkTileDirty(int x, int y) |
|
1677 |
{ |
|
2116 | 1678 |
uint z = 0; |
0 | 1679 |
Point pt; |
2116 | 1680 |
|
8450
dce58137301f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents:
8447
diff
changeset
|
1681 |
if (IsInsideMM(x, 0, MapSizeX() * TILE_SIZE) && |
dce58137301f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents:
8447
diff
changeset
|
1682 |
IsInsideMM(y, 0, MapSizeY() * TILE_SIZE)) |
1980
9ea0c89fbb58
(svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY
tron
parents:
1977
diff
changeset
|
1683 |
z = GetTileZ(TileVirtXY(x, y)); |
0 | 1684 |
pt = RemapCoords(x, y, z); |
1685 |
||
1686 |
MarkAllViewportsDirty( |
|
1687 |
pt.x - 31, |
|
1688 |
pt.y - 122, |
|
1689 |
pt.x - 31 + 67, |
|
1690 |
pt.y - 122 + 154 |
|
1691 |
); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
1692 |
} |
0 | 1693 |
|
8041
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
7993
diff
changeset
|
1694 |
/** |
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
7993
diff
changeset
|
1695 |
* Marks the selected tiles as dirty. |
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
7993
diff
changeset
|
1696 |
* |
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
7993
diff
changeset
|
1697 |
* This function marks the selected tiles as dirty for repaint |
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
7993
diff
changeset
|
1698 |
* |
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
7993
diff
changeset
|
1699 |
* @note Documentation may be wrong (Progman) |
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
7993
diff
changeset
|
1700 |
* @ingroup dirty |
63e760418a15
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium
parents:
7993
diff
changeset
|
1701 |
*/ |
6573 | 1702 |
static void SetSelectionTilesDirty() |
0 | 1703 |
{ |
1704 |
int y_size, x_size; |
|
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1705 |
int x = _thd.pos.x; |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1706 |
int y = _thd.pos.y; |
0 | 1707 |
|
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1708 |
x_size = _thd.size.x; |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1709 |
y_size = _thd.size.y; |
0 | 1710 |
|
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1711 |
if (_thd.outersize.x) { |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1712 |
x_size += _thd.outersize.x; |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1713 |
x += _thd.offs.x; |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1714 |
y_size += _thd.outersize.y; |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
1715 |
y += _thd.offs.y; |
0 | 1716 |
} |
1717 |
||
1718 |
assert(x_size > 0); |
|
1719 |
assert(y_size > 0); |
|
1720 |
||
1721 |
x_size += x; |
|
1722 |
y_size += y; |
|
1723 |
||
1724 |
do { |
|
1725 |
int y_bk = y; |
|
1726 |
do { |
|
1727 |
MarkTileDirty(x, y); |
|
3421
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1728 |
} while ( (y += TILE_SIZE) != y_size); |
0 | 1729 |
y = y_bk; |
3421
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
1730 |
} while ( (x += TILE_SIZE) != x_size); |
0 | 1731 |
} |
1732 |
||
1733 |
||
1990
90eb49e87b90
(svn r2496) -Fix: [1179933] When toggling build/remove via keyboard the selection wasn't correctly redrawn
tron
parents:
1980
diff
changeset
|
1734 |
void SetSelectionRed(bool b) |
90eb49e87b90
(svn r2496) -Fix: [1179933] When toggling build/remove via keyboard the selection wasn't correctly redrawn
tron
parents:
1980
diff
changeset
|
1735 |
{ |
90eb49e87b90
(svn r2496) -Fix: [1179933] When toggling build/remove via keyboard the selection wasn't correctly redrawn
tron
parents:
1980
diff
changeset
|
1736 |
_thd.make_square_red = b; |
90eb49e87b90
(svn r2496) -Fix: [1179933] When toggling build/remove via keyboard the selection wasn't correctly redrawn
tron
parents:
1980
diff
changeset
|
1737 |
SetSelectionTilesDirty(); |
90eb49e87b90
(svn r2496) -Fix: [1179933] When toggling build/remove via keyboard the selection wasn't correctly redrawn
tron
parents:
1980
diff
changeset
|
1738 |
} |
90eb49e87b90
(svn r2496) -Fix: [1179933] When toggling build/remove via keyboard the selection wasn't correctly redrawn
tron
parents:
1980
diff
changeset
|
1739 |
|
90eb49e87b90
(svn r2496) -Fix: [1179933] When toggling build/remove via keyboard the selection wasn't correctly redrawn
tron
parents:
1980
diff
changeset
|
1740 |
|
2116 | 1741 |
static bool CheckClickOnTown(const ViewPort *vp, int x, int y) |
0 | 1742 |
{ |
2116 | 1743 |
const Town *t; |
0 | 1744 |
|
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8419
diff
changeset
|
1745 |
if (!HasBit(_display_opt, DO_SHOW_TOWN_NAMES)) return false; |
0 | 1746 |
|
4471 | 1747 |
switch (vp->zoom) { |
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1748 |
case ZOOM_LVL_NORMAL: |
4471 | 1749 |
x = x - vp->left + vp->virtual_left; |
1750 |
y = y - vp->top + vp->virtual_top; |
|
1751 |
FOR_ALL_TOWNS(t) { |
|
1752 |
if (y >= t->sign.top && |
|
1753 |
y < t->sign.top + 12 && |
|
1754 |
x >= t->sign.left && |
|
1755 |
x < t->sign.left + t->sign.width_1) { |
|
1756 |
ShowTownViewWindow(t->index); |
|
1757 |
return true; |
|
1758 |
} |
|
0 | 1759 |
} |
4471 | 1760 |
break; |
1761 |
||
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1762 |
case ZOOM_LVL_OUT_2X: |
4471 | 1763 |
x = (x - vp->left + 1) * 2 + vp->virtual_left; |
1764 |
y = (y - vp->top + 1) * 2 + vp->virtual_top; |
|
1765 |
FOR_ALL_TOWNS(t) { |
|
1766 |
if (y >= t->sign.top && |
|
1767 |
y < t->sign.top + 24 && |
|
1768 |
x >= t->sign.left && |
|
1769 |
x < t->sign.left + t->sign.width_1 * 2) { |
|
1770 |
ShowTownViewWindow(t->index); |
|
1771 |
return true; |
|
1772 |
} |
|
0 | 1773 |
} |
4471 | 1774 |
break; |
1775 |
||
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1776 |
case ZOOM_LVL_OUT_4X: |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1777 |
case ZOOM_LVL_OUT_8X: |
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1778 |
x = ScaleByZoom(x - vp->left + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_left; |
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1779 |
y = ScaleByZoom(y - vp->top + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_top; |
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1780 |
|
4471 | 1781 |
FOR_ALL_TOWNS(t) { |
1782 |
if (y >= t->sign.top && |
|
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1783 |
y < t->sign.top + ScaleByZoom(12, vp->zoom) && |
4471 | 1784 |
x >= t->sign.left && |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1785 |
x < t->sign.left + ScaleByZoom(t->sign.width_2, vp->zoom)) { |
4471 | 1786 |
ShowTownViewWindow(t->index); |
1787 |
return true; |
|
1788 |
} |
|
0 | 1789 |
} |
4471 | 1790 |
break; |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1791 |
|
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1792 |
default: NOT_REACHED(); |
0 | 1793 |
} |
1794 |
||
1795 |
return false; |
|
1796 |
} |
|
1797 |
||
4471 | 1798 |
|
2116 | 1799 |
static bool CheckClickOnStation(const ViewPort *vp, int x, int y) |
0 | 1800 |
{ |
2116 | 1801 |
const Station *st; |
0 | 1802 |
|
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8419
diff
changeset
|
1803 |
if (!HasBit(_display_opt, DO_SHOW_STATION_NAMES)) return false; |
0 | 1804 |
|
4471 | 1805 |
switch (vp->zoom) { |
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1806 |
case ZOOM_LVL_NORMAL: |
4471 | 1807 |
x = x - vp->left + vp->virtual_left; |
1808 |
y = y - vp->top + vp->virtual_top; |
|
1809 |
FOR_ALL_STATIONS(st) { |
|
1810 |
if (y >= st->sign.top && |
|
1811 |
y < st->sign.top + 12 && |
|
1812 |
x >= st->sign.left && |
|
1813 |
x < st->sign.left + st->sign.width_1) { |
|
1814 |
ShowStationViewWindow(st->index); |
|
1815 |
return true; |
|
1816 |
} |
|
0 | 1817 |
} |
4471 | 1818 |
break; |
1819 |
||
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1820 |
case ZOOM_LVL_OUT_2X: |
4471 | 1821 |
x = (x - vp->left + 1) * 2 + vp->virtual_left; |
1822 |
y = (y - vp->top + 1) * 2 + vp->virtual_top; |
|
1823 |
FOR_ALL_STATIONS(st) { |
|
1824 |
if (y >= st->sign.top && |
|
1825 |
y < st->sign.top + 24 && |
|
1826 |
x >= st->sign.left && |
|
1827 |
x < st->sign.left + st->sign.width_1 * 2) { |
|
1828 |
ShowStationViewWindow(st->index); |
|
1829 |
return true; |
|
1830 |
} |
|
0 | 1831 |
} |
4471 | 1832 |
break; |
1833 |
||
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1834 |
case ZOOM_LVL_OUT_4X: |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1835 |
case ZOOM_LVL_OUT_8X: |
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1836 |
x = ScaleByZoom(x - vp->left + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_left; |
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1837 |
y = ScaleByZoom(y - vp->top + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_top; |
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1838 |
|
4471 | 1839 |
FOR_ALL_STATIONS(st) { |
1840 |
if (y >= st->sign.top && |
|
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1841 |
y < st->sign.top + ScaleByZoom(12, vp->zoom) && |
4471 | 1842 |
x >= st->sign.left && |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1843 |
x < st->sign.left + ScaleByZoom(st->sign.width_2, vp->zoom)) { |
4471 | 1844 |
ShowStationViewWindow(st->index); |
1845 |
return true; |
|
1846 |
} |
|
0 | 1847 |
} |
4471 | 1848 |
break; |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1849 |
|
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1850 |
default: NOT_REACHED(); |
0 | 1851 |
} |
1852 |
||
1853 |
return false; |
|
1854 |
} |
|
1855 |
||
4471 | 1856 |
|
2116 | 1857 |
static bool CheckClickOnSign(const ViewPort *vp, int x, int y) |
0 | 1858 |
{ |
4349
2fc39ff2626e
(svn r6050) -Codechange: mass-renamed SignStruct -> Sign and ss -> si. Now functions and variables all match eachother
truelight
parents:
4346
diff
changeset
|
1859 |
const Sign *si; |
0 | 1860 |
|
9302
4aa3c4a44b16
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
9294
diff
changeset
|
1861 |
/* Signs are turned off, or they are transparent and invisibility is ON, or player is a spectator */ |
4aa3c4a44b16
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
9294
diff
changeset
|
1862 |
if (!HasBit(_display_opt, DO_SHOW_SIGNS) || IsInvisibilitySet(TO_SIGNS) || _current_player == PLAYER_SPECTATOR) return false; |
0 | 1863 |
|
4471 | 1864 |
switch (vp->zoom) { |
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1865 |
case ZOOM_LVL_NORMAL: |
4471 | 1866 |
x = x - vp->left + vp->virtual_left; |
1867 |
y = y - vp->top + vp->virtual_top; |
|
1868 |
FOR_ALL_SIGNS(si) { |
|
1869 |
if (y >= si->sign.top && |
|
1870 |
y < si->sign.top + 12 && |
|
1871 |
x >= si->sign.left && |
|
1872 |
x < si->sign.left + si->sign.width_1) { |
|
1873 |
ShowRenameSignWindow(si); |
|
1874 |
return true; |
|
1875 |
} |
|
0 | 1876 |
} |
4471 | 1877 |
break; |
1878 |
||
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1879 |
case ZOOM_LVL_OUT_2X: |
4471 | 1880 |
x = (x - vp->left + 1) * 2 + vp->virtual_left; |
1881 |
y = (y - vp->top + 1) * 2 + vp->virtual_top; |
|
1882 |
FOR_ALL_SIGNS(si) { |
|
1883 |
if (y >= si->sign.top && |
|
1884 |
y < si->sign.top + 24 && |
|
1885 |
x >= si->sign.left && |
|
1886 |
x < si->sign.left + si->sign.width_1 * 2) { |
|
1887 |
ShowRenameSignWindow(si); |
|
1888 |
return true; |
|
1889 |
} |
|
0 | 1890 |
} |
4471 | 1891 |
break; |
1892 |
||
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1893 |
case ZOOM_LVL_OUT_4X: |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1894 |
case ZOOM_LVL_OUT_8X: |
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1895 |
x = ScaleByZoom(x - vp->left + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_left; |
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1896 |
y = ScaleByZoom(y - vp->top + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_top; |
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1897 |
|
4471 | 1898 |
FOR_ALL_SIGNS(si) { |
1899 |
if (y >= si->sign.top && |
|
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1900 |
y < si->sign.top + ScaleByZoom(12, vp->zoom) && |
4471 | 1901 |
x >= si->sign.left && |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1902 |
x < si->sign.left + ScaleByZoom(si->sign.width_2, vp->zoom)) { |
4471 | 1903 |
ShowRenameSignWindow(si); |
1904 |
return true; |
|
1905 |
} |
|
0 | 1906 |
} |
4471 | 1907 |
break; |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1908 |
|
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1909 |
default: NOT_REACHED(); |
0 | 1910 |
} |
1911 |
||
1912 |
return false; |
|
1913 |
} |
|
1914 |
||
4471 | 1915 |
|
2116 | 1916 |
static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y) |
0 | 1917 |
{ |
2116 | 1918 |
const Waypoint *wp; |
0 | 1919 |
|
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
8419
diff
changeset
|
1920 |
if (!HasBit(_display_opt, DO_WAYPOINTS)) return false; |
0 | 1921 |
|
4471 | 1922 |
switch (vp->zoom) { |
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1923 |
case ZOOM_LVL_NORMAL: |
4471 | 1924 |
x = x - vp->left + vp->virtual_left; |
1925 |
y = y - vp->top + vp->virtual_top; |
|
1926 |
FOR_ALL_WAYPOINTS(wp) { |
|
1927 |
if (y >= wp->sign.top && |
|
1928 |
y < wp->sign.top + 12 && |
|
1929 |
x >= wp->sign.left && |
|
1930 |
x < wp->sign.left + wp->sign.width_1) { |
|
1931 |
ShowRenameWaypointWindow(wp); |
|
1932 |
return true; |
|
1933 |
} |
|
0 | 1934 |
} |
4471 | 1935 |
break; |
1936 |
||
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1937 |
case ZOOM_LVL_OUT_2X: |
4471 | 1938 |
x = (x - vp->left + 1) * 2 + vp->virtual_left; |
1939 |
y = (y - vp->top + 1) * 2 + vp->virtual_top; |
|
1940 |
FOR_ALL_WAYPOINTS(wp) { |
|
1941 |
if (y >= wp->sign.top && |
|
1942 |
y < wp->sign.top + 24 && |
|
1943 |
x >= wp->sign.left && |
|
1944 |
x < wp->sign.left + wp->sign.width_1 * 2) { |
|
1945 |
ShowRenameWaypointWindow(wp); |
|
1946 |
return true; |
|
1947 |
} |
|
0 | 1948 |
} |
4471 | 1949 |
break; |
1950 |
||
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
7087
diff
changeset
|
1951 |
case ZOOM_LVL_OUT_4X: |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1952 |
case ZOOM_LVL_OUT_8X: |
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1953 |
x = ScaleByZoom(x - vp->left + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_left; |
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1954 |
y = ScaleByZoom(y - vp->top + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_top; |
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1955 |
|
4471 | 1956 |
FOR_ALL_WAYPOINTS(wp) { |
1957 |
if (y >= wp->sign.top && |
|
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1958 |
y < wp->sign.top + ScaleByZoom(12, vp->zoom) && |
4471 | 1959 |
x >= wp->sign.left && |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1960 |
x < wp->sign.left + ScaleByZoom(wp->sign.width_2, vp->zoom)) { |
4471 | 1961 |
ShowRenameWaypointWindow(wp); |
1962 |
return true; |
|
1963 |
} |
|
0 | 1964 |
} |
4471 | 1965 |
break; |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1966 |
|
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
1967 |
default: NOT_REACHED(); |
0 | 1968 |
} |
1969 |
||
1970 |
return false; |
|
1971 |
} |
|
1972 |
||
1973 |
||
2116 | 1974 |
static void CheckClickOnLandscape(const ViewPort *vp, int x, int y) |
0 | 1975 |
{ |
2116 | 1976 |
Point pt = TranslateXYToTileCoord(vp, x, y); |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1964
diff
changeset
|
1977 |
|
1980
9ea0c89fbb58
(svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY
tron
parents:
1977
diff
changeset
|
1978 |
if (pt.x != -1) ClickTile(TileVirtXY(pt.x, pt.y)); |
0 | 1979 |
} |
1980 |
||
2662
42c11a1a0a4b
(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
|
1981 |
|
42c11a1a0a4b
(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
|
1982 |
static void SafeShowTrainViewWindow(const Vehicle* v) |
42c11a1a0a4b
(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
|
1983 |
{ |
7993
76b0eb3e19c9
(svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents:
7982
diff
changeset
|
1984 |
if (!IsFrontEngine(v)) v = v->First(); |
7982
539e32cc37ce
(svn r10997) -Codechange: unify the vehicle view window. Patch by PhilSophus.
rubidium
parents:
7829
diff
changeset
|
1985 |
ShowVehicleViewWindow(v); |
2662
42c11a1a0a4b
(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
|
1986 |
} |
42c11a1a0a4b
(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
|
1987 |
|
7353
716c6dd9322a
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
7349
diff
changeset
|
1988 |
static void SafeShowRoadVehViewWindow(const Vehicle *v) |
716c6dd9322a
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
7349
diff
changeset
|
1989 |
{ |
7993
76b0eb3e19c9
(svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents:
7982
diff
changeset
|
1990 |
if (!IsRoadVehFront(v)) v = v->First(); |
7982
539e32cc37ce
(svn r10997) -Codechange: unify the vehicle view window. Patch by PhilSophus.
rubidium
parents:
7829
diff
changeset
|
1991 |
ShowVehicleViewWindow(v); |
7353
716c6dd9322a
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
7349
diff
changeset
|
1992 |
} |
716c6dd9322a
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
7349
diff
changeset
|
1993 |
|
4171 | 1994 |
static void Nop(const Vehicle *v) {} |
2662
42c11a1a0a4b
(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
|
1995 |
|
4171 | 1996 |
typedef void OnVehicleClickProc(const Vehicle *v); |
2662
42c11a1a0a4b
(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
|
1997 |
static OnVehicleClickProc* const _on_vehicle_click_proc[] = { |
42c11a1a0a4b
(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
|
1998 |
SafeShowTrainViewWindow, |
7353
716c6dd9322a
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros
parents:
7349
diff
changeset
|
1999 |
SafeShowRoadVehViewWindow, |
7982
539e32cc37ce
(svn r10997) -Codechange: unify the vehicle view window. Patch by PhilSophus.
rubidium
parents:
7829
diff
changeset
|
2000 |
ShowVehicleViewWindow, |
539e32cc37ce
(svn r10997) -Codechange: unify the vehicle view window. Patch by PhilSophus.
rubidium
parents:
7829
diff
changeset
|
2001 |
ShowVehicleViewWindow, |
2662
42c11a1a0a4b
(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
|
2002 |
Nop, // Special vehicles |
42c11a1a0a4b
(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
|
2003 |
Nop // Disaster vehicles |
0 | 2004 |
}; |
2005 |
||
2116 | 2006 |
void HandleViewportClicked(const ViewPort *vp, int x, int y) |
0 | 2007 |
{ |
4171 | 2008 |
const Vehicle *v; |
0 | 2009 |
|
2116 | 2010 |
if (CheckClickOnTown(vp, x, y)) return; |
2011 |
if (CheckClickOnStation(vp, x, y)) return; |
|
2012 |
if (CheckClickOnSign(vp, x, y)) return; |
|
2013 |
if (CheckClickOnWaypoint(vp, x, y)) return; |
|
0 | 2014 |
CheckClickOnLandscape(vp, x, y); |
2015 |
||
2116 | 2016 |
v = CheckClickOnVehicle(vp, x, y); |
3809
cff6d5e916f7
(svn r4819) -Debug: When clicking on a vehicle in the viewport, the index and address of the vehicle get dumped for "misc" debug levels >= 2
celestar
parents:
3798
diff
changeset
|
2017 |
if (v != NULL) { |
5568
75f13d7bfaed
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5137
diff
changeset
|
2018 |
DEBUG(misc, 2, "Vehicle %d (index %d) at %p", v->unitnumber, v->index, v); |
6206
67358999d80d
(svn r8621) -Codechange: assigned new numbers to the VEH_(type) enum so that VEH_Train is 0, VEH_Road is 1 and so on
bjarni
parents:
6144
diff
changeset
|
2019 |
_on_vehicle_click_proc[v->type](v); |
3809
cff6d5e916f7
(svn r4819) -Debug: When clicking on a vehicle in the viewport, the index and address of the vehicle get dumped for "misc" debug levels >= 2
celestar
parents:
3798
diff
changeset
|
2020 |
} |
0 | 2021 |
} |
2022 |
||
6573 | 2023 |
Vehicle *CheckMouseOverVehicle() |
0 | 2024 |
{ |
4171 | 2025 |
const Window *w; |
2026 |
const ViewPort *vp; |
|
0 | 2027 |
|
2028 |
int x = _cursor.pos.x; |
|
2029 |
int y = _cursor.pos.y; |
|
2030 |
||
2031 |
w = FindWindowFromPt(x, y); |
|
2116 | 2032 |
if (w == NULL) return NULL; |
0 | 2033 |
|
2034 |
vp = IsPtInWindowViewport(w, x, y); |
|
2116 | 2035 |
return (vp != NULL) ? CheckClickOnVehicle(vp, x, y) : NULL; |
0 | 2036 |
} |
2037 |
||
2038 |
||
2039 |
||
6573 | 2040 |
void PlaceObject() |
0 | 2041 |
{ |
2042 |
Point pt; |
|
2043 |
Window *w; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
2044 |
|
0 | 2045 |
pt = GetTileBelowCursor(); |
2116 | 2046 |
if (pt.x == -1) return; |
0 | 2047 |
|
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2048 |
if (_thd.place_mode == VHM_POINT) { |
0 | 2049 |
pt.x += 8; |
2050 |
pt.y += 8; |
|
2051 |
} |
|
2052 |
||
2053 |
_tile_fract_coords.x = pt.x & 0xF; |
|
2054 |
_tile_fract_coords.y = pt.y & 0xF; |
|
2055 |
||
2116 | 2056 |
w = GetCallbackWnd(); |
10486
247d43dfa6f1
(svn r13029) -Codechange: more work in the road to getting the WP macros and byte[WINDOW_CUSTOM_SIZE] removed. This step changes the event handling to work directly on the Window class instead of via a function pointer and big switches while keeping backward compatability while we're rewriting the Windows to the new scheme.
rubidium
parents:
10466
diff
changeset
|
2057 |
if (w != NULL) w->OnPlaceObject(pt, TileVirtXY(pt.x, pt.y)); |
0 | 2058 |
} |
2059 |
||
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
|
2060 |
|
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
|
2061 |
/* scrolls the viewport in a window to a given location */ |
7226
a8650d6ecb53
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
7165
diff
changeset
|
2062 |
bool ScrollWindowTo(int x , int y, Window *w, bool instant) |
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
|
2063 |
{ |
8969
243021ceca31
(svn r12044) -Fix [FS#1741]: crash when centering on a vehicle (aircraft) that is outside of the map.
rubidium
parents:
8909
diff
changeset
|
2064 |
/* The slope cannot be acquired outside of the map, so make sure we are always within the map. */ |
243021ceca31
(svn r12044) -Fix [FS#1741]: crash when centering on a vehicle (aircraft) that is outside of the map.
rubidium
parents:
8909
diff
changeset
|
2065 |
Point pt = MapXYZToViewport(w->viewport, x, y, GetSlopeZ(Clamp(x, 0, MapSizeX()), Clamp(y, 0, MapSizeY()))); |
10504 | 2066 |
w->viewport->follow_vehicle = INVALID_VEHICLE; |
2067 |
||
2068 |
if (w->viewport->dest_scrollpos_x == pt.x && w->viewport->dest_scrollpos_y == pt.y) |
|
2116 | 2069 |
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
|
2070 |
|
7227
41a868cb2c8e
(svn r9963) -Fix (r9962): 'smooth_scroll' patch setting was ignored (always on) in some places.
peter1138
parents:
7226
diff
changeset
|
2071 |
if (instant) { |
10504 | 2072 |
w->viewport->scrollpos_x = pt.x; |
2073 |
w->viewport->scrollpos_y = pt.y; |
|
7226
a8650d6ecb53
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
7165
diff
changeset
|
2074 |
} |
a8650d6ecb53
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
7165
diff
changeset
|
2075 |
|
10504 | 2076 |
w->viewport->dest_scrollpos_x = pt.x; |
2077 |
w->viewport->dest_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
|
2078 |
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
|
2079 |
} |
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
|
2080 |
|
7226
a8650d6ecb53
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
7165
diff
changeset
|
2081 |
bool ScrollMainWindowToTile(TileIndex tile, bool instant) |
0 | 2082 |
{ |
7226
a8650d6ecb53
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents:
7165
diff
changeset
|
2083 |
return ScrollMainWindowTo(TileX(tile) * TILE_SIZE + TILE_SIZE / 2, TileY(tile) * TILE_SIZE + TILE_SIZE / 2, instant); |
0 | 2084 |
} |
2085 |
||
2086 |
void SetRedErrorSquare(TileIndex tile) |
|
2087 |
{ |
|
2088 |
TileIndex old; |
|
2089 |
||
2090 |
old = _thd.redsq; |
|
2091 |
_thd.redsq = tile; |
|
2092 |
||
2093 |
if (tile != old) { |
|
3281
0f3d836e35b1
(svn r3995) -Fix: Committed one file too much in 3992 (Thanks to Tron for pointing it out)
celestar
parents:
3279
diff
changeset
|
2094 |
if (tile != 0) MarkTileDirtyByTile(tile); |
0f3d836e35b1
(svn r3995) -Fix: Committed one file too much in 3992 (Thanks to Tron for pointing it out)
celestar
parents:
3279
diff
changeset
|
2095 |
if (old != 0) MarkTileDirtyByTile(old); |
0 | 2096 |
} |
2097 |
} |
|
2098 |
||
2099 |
void SetTileSelectSize(int w, int h) |
|
2100 |
{ |
|
3421
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
2101 |
_thd.new_size.x = w * TILE_SIZE; |
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
2102 |
_thd.new_size.y = h * TILE_SIZE; |
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2103 |
_thd.new_outersize.x = 0; |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2104 |
_thd.new_outersize.y = 0; |
0 | 2105 |
} |
2106 |
||
2116 | 2107 |
void SetTileSelectBigSize(int ox, int oy, int sx, int sy) |
2108 |
{ |
|
3421
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
2109 |
_thd.offs.x = ox * TILE_SIZE; |
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
2110 |
_thd.offs.y = oy * TILE_SIZE; |
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
2111 |
_thd.new_outersize.x = sx * TILE_SIZE; |
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
2112 |
_thd.new_outersize.y = sy * TILE_SIZE; |
0 | 2113 |
} |
2114 |
||
6919
339210ecccd3
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6574
diff
changeset
|
2115 |
/** returns the best autorail highlight type from map coordinates */ |
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
2116 |
static HighLightStyle GetAutorailHT(int x, int y) |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2117 |
{ |
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
2118 |
return HT_RAIL | _autorail_piece[x & 0xF][y & 0xF]; |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2119 |
} |
0 | 2120 |
|
7574
0d76e3392fa4
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas
parents:
7565
diff
changeset
|
2121 |
/** |
0d76e3392fa4
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas
parents:
7565
diff
changeset
|
2122 |
* Updates tile highlighting for all cases. |
0d76e3392fa4
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas
parents:
7565
diff
changeset
|
2123 |
* Uses _thd.selstart and _thd.selend and _thd.place_mode (set elsewhere) to determine _thd.pos and _thd.size |
0d76e3392fa4
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas
parents:
7565
diff
changeset
|
2124 |
* Also drawstyle is determined. Uses _thd.new.* as a buffer and calls SetSelectionTilesDirty() twice, |
0d76e3392fa4
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas
parents:
7565
diff
changeset
|
2125 |
* Once for the old and once for the new selection. |
0d76e3392fa4
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas
parents:
7565
diff
changeset
|
2126 |
* _thd is TileHighlightData, found in viewport.h |
0d76e3392fa4
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas
parents:
7565
diff
changeset
|
2127 |
* Called by MouseLoop() in windows.cpp |
0d76e3392fa4
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas
parents:
7565
diff
changeset
|
2128 |
*/ |
6573 | 2129 |
void UpdateTileSelection() |
0 | 2130 |
{ |
2116 | 2131 |
int x1; |
2132 |
int y1; |
|
0 | 2133 |
|
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2134 |
_thd.new_drawstyle = 0; |
0 | 2135 |
|
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2136 |
if (_thd.place_mode == VHM_SPECIAL) { |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2137 |
x1 = _thd.selend.x; |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2138 |
y1 = _thd.selend.y; |
0 | 2139 |
if (x1 != -1) { |
8408
b14e4f68d1d7
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz
parents:
8401
diff
changeset
|
2140 |
int x2 = _thd.selstart.x & ~0xF; |
b14e4f68d1d7
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz
parents:
8401
diff
changeset
|
2141 |
int y2 = _thd.selstart.y & ~0xF; |
0 | 2142 |
x1 &= ~0xF; |
2143 |
y1 &= ~0xF; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
2144 |
|
6432 | 2145 |
if (x1 >= x2) Swap(x1, x2); |
2146 |
if (y1 >= y2) Swap(y1, y2); |
|
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2147 |
_thd.new_pos.x = x1; |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2148 |
_thd.new_pos.y = y1; |
3421
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
2149 |
_thd.new_size.x = x2 - x1 + TILE_SIZE; |
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
2150 |
_thd.new_size.y = y2 - y1 + TILE_SIZE; |
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2151 |
_thd.new_drawstyle = _thd.next_drawstyle; |
0 | 2152 |
} |
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2153 |
} else if (_thd.place_mode != VHM_NONE) { |
2116 | 2154 |
Point pt = GetTileBelowCursor(); |
0 | 2155 |
x1 = pt.x; |
2156 |
y1 = pt.y; |
|
2157 |
if (x1 != -1) { |
|
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2158 |
switch (_thd.place_mode) { |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2159 |
case VHM_RECT: |
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2160 |
_thd.new_drawstyle = HT_RECT; |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2161 |
break; |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2162 |
case VHM_POINT: |
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2163 |
_thd.new_drawstyle = HT_POINT; |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2164 |
x1 += 8; |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2165 |
y1 += 8; |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2166 |
break; |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2167 |
case VHM_RAIL: |
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2168 |
_thd.new_drawstyle = GetAutorailHT(pt.x, pt.y); // draw one highlighted tile |
8414
8c2ecc2dc12c
(svn r11471) -Codechange: one more variable retyped to enum ViewportHighlightMode
smatz
parents:
8408
diff
changeset
|
2169 |
break; |
8c2ecc2dc12c
(svn r11471) -Codechange: one more variable retyped to enum ViewportHighlightMode
smatz
parents:
8408
diff
changeset
|
2170 |
default: |
8c2ecc2dc12c
(svn r11471) -Codechange: one more variable retyped to enum ViewportHighlightMode
smatz
parents:
8408
diff
changeset
|
2171 |
NOT_REACHED(); |
8c2ecc2dc12c
(svn r11471) -Codechange: one more variable retyped to enum ViewportHighlightMode
smatz
parents:
8408
diff
changeset
|
2172 |
break; |
0 | 2173 |
} |
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2174 |
_thd.new_pos.x = x1 & ~0xF; |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2175 |
_thd.new_pos.y = y1 & ~0xF; |
0 | 2176 |
} |
2177 |
} |
|
2178 |
||
6919
339210ecccd3
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6574
diff
changeset
|
2179 |
/* redraw selection */ |
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2180 |
if (_thd.drawstyle != _thd.new_drawstyle || |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2181 |
_thd.pos.x != _thd.new_pos.x || _thd.pos.y != _thd.new_pos.y || |
4539
0b13858554fb
(svn r6368) -Fix [FS#136]: Station catchment area persists after switching tools. The
Darkvater
parents:
4523
diff
changeset
|
2182 |
_thd.size.x != _thd.new_size.x || _thd.size.y != _thd.new_size.y || |
7574
0d76e3392fa4
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas
parents:
7565
diff
changeset
|
2183 |
_thd.outersize.x != _thd.new_outersize.x || |
0d76e3392fa4
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas
parents:
7565
diff
changeset
|
2184 |
_thd.outersize.y != _thd.new_outersize.y) { |
6919
339210ecccd3
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6574
diff
changeset
|
2185 |
/* clear the old selection? */ |
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2186 |
if (_thd.drawstyle) SetSelectionTilesDirty(); |
0 | 2187 |
|
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2188 |
_thd.drawstyle = _thd.new_drawstyle; |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2189 |
_thd.pos = _thd.new_pos; |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2190 |
_thd.size = _thd.new_size; |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2191 |
_thd.outersize = _thd.new_outersize; |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2192 |
_thd.dirty = 0xff; |
0 | 2193 |
|
6919
339210ecccd3
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6574
diff
changeset
|
2194 |
/* draw the new selection? */ |
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2195 |
if (_thd.new_drawstyle) SetSelectionTilesDirty(); |
0 | 2196 |
} |
2197 |
} |
|
2198 |
||
6919
339210ecccd3
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6574
diff
changeset
|
2199 |
/** highlighting tiles while only going over them with the mouse */ |
10466
54dfadd481b0
(svn r13009) -Codechange: move more tile highlighting related functions/types to tilehighlight_*.h.
rubidium
parents:
10445
diff
changeset
|
2200 |
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process) |
0 | 2201 |
{ |
7165
37eb253f3c06
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents:
7150
diff
changeset
|
2202 |
_thd.select_method = method; |
37eb253f3c06
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros
parents:
7150
diff
changeset
|
2203 |
_thd.select_proc = process; |
3421
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
2204 |
_thd.selend.x = TileX(tile) * TILE_SIZE; |
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
2205 |
_thd.selstart.x = TileX(tile) * TILE_SIZE; |
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
2206 |
_thd.selend.y = TileY(tile) * TILE_SIZE; |
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
2207 |
_thd.selstart.y = TileY(tile) * TILE_SIZE; |
8408
b14e4f68d1d7
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz
parents:
8401
diff
changeset
|
2208 |
|
b14e4f68d1d7
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz
parents:
8401
diff
changeset
|
2209 |
/* Needed so several things (road, autoroad, bridges, ...) are placed correctly. |
b14e4f68d1d7
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz
parents:
8401
diff
changeset
|
2210 |
* In effect, placement starts from the centre of a tile |
b14e4f68d1d7
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz
parents:
8401
diff
changeset
|
2211 |
*/ |
b14e4f68d1d7
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz
parents:
8401
diff
changeset
|
2212 |
if (method == VPM_X_OR_Y || method == VPM_FIX_X || method == VPM_FIX_Y) { |
b14e4f68d1d7
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz
parents:
8401
diff
changeset
|
2213 |
_thd.selend.x += TILE_SIZE / 2; |
b14e4f68d1d7
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz
parents:
8401
diff
changeset
|
2214 |
_thd.selend.y += TILE_SIZE / 2; |
b14e4f68d1d7
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz
parents:
8401
diff
changeset
|
2215 |
_thd.selstart.x += TILE_SIZE / 2; |
b14e4f68d1d7
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz
parents:
8401
diff
changeset
|
2216 |
_thd.selstart.y += TILE_SIZE / 2; |
b14e4f68d1d7
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz
parents:
8401
diff
changeset
|
2217 |
} |
b14e4f68d1d7
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz
parents:
8401
diff
changeset
|
2218 |
|
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2219 |
if (_thd.place_mode == VHM_RECT) { |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2220 |
_thd.place_mode = VHM_SPECIAL; |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2221 |
_thd.next_drawstyle = HT_RECT; |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2222 |
} else if (_thd.place_mode == VHM_RAIL) { // autorail one piece |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2223 |
_thd.place_mode = VHM_SPECIAL; |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2224 |
_thd.next_drawstyle = _thd.drawstyle; |
0 | 2225 |
} else { |
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2226 |
_thd.place_mode = VHM_SPECIAL; |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2227 |
_thd.next_drawstyle = HT_POINT; |
0 | 2228 |
} |
2229 |
_special_mouse_mode = WSM_SIZING; |
|
2230 |
} |
|
2231 |
||
2232 |
void VpSetPlaceSizingLimit(int limit) |
|
2233 |
{ |
|
2234 |
_thd.sizelimit = limit; |
|
2235 |
} |
|
2236 |
||
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2237 |
/** |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2238 |
* Highlights all tiles between a set of two tiles. Used in dock and tunnel placement |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2239 |
* @param from TileIndex of the first tile to highlight |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2240 |
* @param to TileIndex of the last tile to highlight */ |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2241 |
void VpSetPresizeRange(TileIndex from, TileIndex to) |
0 | 2242 |
{ |
7502
71f5d2c6a605
(svn r10262) -Fix (r10258): some places that needed to be changed to uint64 were hidden/forgotten, which caused memory corruptions and that in caused all kinds of assertions to trigger.
rubidium
parents:
7433
diff
changeset
|
2243 |
uint64 distance = DistanceManhattan(from, to) + 1; |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2244 |
|
3421
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
2245 |
_thd.selend.x = TileX(to) * TILE_SIZE; |
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
2246 |
_thd.selend.y = TileY(to) * TILE_SIZE; |
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
2247 |
_thd.selstart.x = TileX(from) * TILE_SIZE; |
8ab76c47c72c
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3281
diff
changeset
|
2248 |
_thd.selstart.y = TileY(from) * TILE_SIZE; |
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2249 |
_thd.next_drawstyle = HT_RECT; |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2250 |
|
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2251 |
/* show measurement only if there is any length to speak of */ |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2252 |
if (distance > 1) GuiShowTooltipsWithArgs(STR_MEASURE_LENGTH, 1, &distance); |
0 | 2253 |
} |
2254 |
||
6573 | 2255 |
static void VpStartPreSizing() |
0 | 2256 |
{ |
2257 |
_thd.selend.x = -1; |
|
2258 |
_special_mouse_mode = WSM_PRESIZE; |
|
2259 |
} |
|
2260 |
||
6919
339210ecccd3
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6574
diff
changeset
|
2261 |
/** returns information about the 2x1 piece to be build. |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2262 |
* The lower bits (0-3) are the track type. */ |
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
2263 |
static HighLightStyle Check2x1AutoRail(int mode) |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2264 |
{ |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2265 |
int fxpy = _tile_fract_coords.x + _tile_fract_coords.y; |
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2266 |
int sxpy = (_thd.selend.x & 0xF) + (_thd.selend.y & 0xF); |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2267 |
int fxmy = _tile_fract_coords.x - _tile_fract_coords.y; |
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2268 |
int sxmy = (_thd.selend.x & 0xF) - (_thd.selend.y & 0xF); |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2269 |
|
2952 | 2270 |
switch (mode) { |
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
2271 |
default: NOT_REACHED(); |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
2272 |
case 0: // end piece is lower right |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
2273 |
if (fxpy >= 20 && sxpy <= 12) { /*SwapSelection(); DoRailroadTrack(0); */return HT_DIR_HL; } |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
2274 |
if (fxmy < -3 && sxmy > 3) {/* DoRailroadTrack(0); */return HT_DIR_VR; } |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
2275 |
return HT_DIR_Y; |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
2276 |
|
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
2277 |
case 1: |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
2278 |
if (fxmy > 3 && sxmy < -3) { /*SwapSelection(); DoRailroadTrack(0); */return HT_DIR_VL; } |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
2279 |
if (fxpy <= 12 && sxpy >= 20) { /*DoRailroadTrack(0); */return HT_DIR_HU; } |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
2280 |
return HT_DIR_Y; |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
2281 |
|
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
2282 |
case 2: |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
2283 |
if (fxmy > 3 && sxmy < -3) { /*DoRailroadTrack(3);*/ return HT_DIR_VL; } |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
2284 |
if (fxpy >= 20 && sxpy <= 12) { /*SwapSelection(); DoRailroadTrack(0); */return HT_DIR_HL; } |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
2285 |
return HT_DIR_X; |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
2286 |
|
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
2287 |
case 3: |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
2288 |
if (fxmy < -3 && sxmy > 3) { /*SwapSelection(); DoRailroadTrack(3);*/ return HT_DIR_VR; } |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
2289 |
if (fxpy <= 12 && sxpy >= 20) { /*DoRailroadTrack(0); */return HT_DIR_HU; } |
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
2290 |
return HT_DIR_X; |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2291 |
} |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2292 |
} |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2293 |
|
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2294 |
/** Check if the direction of start and end tile should be swapped based on |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2295 |
* the dragging-style. Default directions are: |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2296 |
* in the case of a line (HT_RAIL, HT_LINE): DIR_NE, DIR_NW, DIR_N, DIR_E |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2297 |
* in the case of a rect (HT_RECT, HT_POINT): DIR_S, DIR_E |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2298 |
* For example dragging a rectangle area from south to north should be swapped to |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2299 |
* north-south (DIR_S) to obtain the same results with less code. This is what |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2300 |
* the return value signifies. |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2301 |
* @param style HighLightStyle dragging style |
6980
6b5dee376733
(svn r9665) -Documentation: Doxygen corrections,errors, corrections of corrections...
belugas
parents:
6949
diff
changeset
|
2302 |
* @param start_tile start tile of drag |
6b5dee376733
(svn r9665) -Documentation: Doxygen corrections,errors, corrections of corrections...
belugas
parents:
6949
diff
changeset
|
2303 |
* @param end_tile end tile of drag |
6b5dee376733
(svn r9665) -Documentation: Doxygen corrections,errors, corrections of corrections...
belugas
parents:
6949
diff
changeset
|
2304 |
* @return boolean value which when true means start/end should be swapped */ |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2305 |
static bool SwapDirection(HighLightStyle style, TileIndex start_tile, TileIndex end_tile) |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2306 |
{ |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2307 |
uint start_x = TileX(start_tile); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2308 |
uint start_y = TileY(start_tile); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2309 |
uint end_x = TileX(end_tile); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2310 |
uint end_y = TileY(end_tile); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2311 |
|
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2312 |
switch (style & HT_DRAG_MASK) { |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2313 |
case HT_RAIL: |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2314 |
case HT_LINE: return (end_x > start_x || (end_x == start_x && end_y > start_y)); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2315 |
|
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2316 |
case HT_RECT: |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2317 |
case HT_POINT: return (end_x != start_x && end_y < start_y); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2318 |
default: NOT_REACHED(); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2319 |
} |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2320 |
|
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2321 |
return false; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2322 |
} |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2323 |
|
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2324 |
/** Calculates height difference between one tile and another |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2325 |
* Multiplies the result to suit the standard given by minimap - 50 meters high |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2326 |
* To correctly get the height difference we need the direction we are dragging |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2327 |
* in, as well as with what kind of tool we are dragging. For example a horizontal |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2328 |
* autorail tool that starts in bottom and ends at the top of a tile will need the |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6980
diff
changeset
|
2329 |
* maximum of SW, S and SE, N corners respectively. This is handled by the lookup table below |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2330 |
* See _tileoffs_by_dir in map.c for the direction enums if you can't figure out |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2331 |
* the values yourself. |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2332 |
* @param style HightlightStyle of drag. This includes direction and style (autorail, rect, etc.) |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2333 |
* @param distance amount of tiles dragged, important for horizontal/vertical drags |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2334 |
* ignored for others |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2335 |
* @param start_tile, end_tile start and end tile of drag operation |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2336 |
* @return height difference between two tiles. Tile measurement tool utilizes |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2337 |
* this value in its tooltips */ |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2338 |
static int CalcHeightdiff(HighLightStyle style, uint distance, TileIndex start_tile, TileIndex end_tile) |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2339 |
{ |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2340 |
bool swap = SwapDirection(style, start_tile, end_tile); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2341 |
byte style_t; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2342 |
uint h0, h1, ht; // start heigth, end height, and temp variable |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2343 |
|
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2344 |
if (start_tile == end_tile) return 0; |
5984 | 2345 |
if (swap) Swap(start_tile, end_tile); |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2346 |
|
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2347 |
switch (style & HT_DRAG_MASK) { |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2348 |
case HT_RECT: { |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2349 |
static const TileIndexDiffC heightdiff_area_by_dir[] = { |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2350 |
/* Start */ {1, 0}, /* Dragging east */ {0, 0}, /* Dragging south */ |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2351 |
/* End */ {0, 1}, /* Dragging east */ {1, 1} /* Dragging south */ |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2352 |
}; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2353 |
|
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2354 |
/* In the case of an area we can determine whether we were dragging south or |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2355 |
* east by checking the X-coordinates of the tiles */ |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2356 |
style_t = (byte)(TileX(end_tile) > TileX(start_tile)); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2357 |
start_tile = TILE_ADD(start_tile, ToTileIndexDiff(heightdiff_area_by_dir[style_t])); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2358 |
end_tile = TILE_ADD(end_tile, ToTileIndexDiff(heightdiff_area_by_dir[2 + style_t])); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2359 |
} |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2360 |
/* Fallthrough */ |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2361 |
case HT_POINT: |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2362 |
h0 = TileHeight(start_tile); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2363 |
h1 = TileHeight(end_tile); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2364 |
break; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2365 |
default: { /* All other types, this is mostly only line/autorail */ |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2366 |
static const HighLightStyle flip_style_direction[] = { |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2367 |
HT_DIR_X, HT_DIR_Y, HT_DIR_HL, HT_DIR_HU, HT_DIR_VR, HT_DIR_VL |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2368 |
}; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2369 |
static const TileIndexDiffC heightdiff_line_by_dir[] = { |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2370 |
/* Start */ {1, 0}, {1, 1}, /* HT_DIR_X */ {0, 1}, {1, 1}, /* HT_DIR_Y */ |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2371 |
/* Start */ {1, 0}, {0, 0}, /* HT_DIR_HU */ {1, 0}, {1, 1}, /* HT_DIR_HL */ |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2372 |
/* Start */ {1, 0}, {1, 1}, /* HT_DIR_VL */ {0, 1}, {1, 1}, /* HT_DIR_VR */ |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2373 |
|
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2374 |
/* Start */ {0, 1}, {0, 0}, /* HT_DIR_X */ {1, 0}, {0, 0}, /* HT_DIR_Y */ |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2375 |
/* End */ {0, 1}, {0, 0}, /* HT_DIR_HU */ {1, 1}, {0, 1}, /* HT_DIR_HL */ |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2376 |
/* End */ {1, 0}, {0, 0}, /* HT_DIR_VL */ {0, 0}, {0, 1}, /* HT_DIR_VR */ |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2377 |
}; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2378 |
|
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2379 |
distance %= 2; // we're only interested if the distance is even or uneven |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2380 |
style &= HT_DIR_MASK; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2381 |
|
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2382 |
/* To handle autorail, we do some magic to be able to use a lookup table. |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2383 |
* Firstly if we drag the other way around, we switch start&end, and if needed |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2384 |
* also flip the drag-position. Eg if it was on the left, and the distance is even |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2385 |
* that means the end, which is now the start is on the right */ |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2386 |
if (swap && distance == 0) style = flip_style_direction[style]; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2387 |
|
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2388 |
/* Use lookup table for start-tile based on HighLightStyle direction */ |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2389 |
style_t = style * 2; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2390 |
assert(style_t < lengthof(heightdiff_line_by_dir) - 13); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2391 |
h0 = TileHeight(TILE_ADD(start_tile, ToTileIndexDiff(heightdiff_line_by_dir[style_t]))); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2392 |
ht = TileHeight(TILE_ADD(start_tile, ToTileIndexDiff(heightdiff_line_by_dir[style_t + 1]))); |
5852
cb3f71b16e1a
(svn r8055) -Codechange: Replace the different max, dmax, maxu whatever macros by a simple template function max(), that requires two arguments of the same type. While I'm at it change a variable called "max" to "maxval" in a function that calls max().
celestar
parents:
5838
diff
changeset
|
2393 |
h0 = max(h0, ht); |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2394 |
|
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2395 |
/* Use lookup table for end-tile based on HighLightStyle direction |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2396 |
* flip around side (lower/upper, left/right) based on distance */ |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2397 |
if (distance == 0) style_t = flip_style_direction[style] * 2; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2398 |
assert(style_t < lengthof(heightdiff_line_by_dir) - 13); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2399 |
h1 = TileHeight(TILE_ADD(end_tile, ToTileIndexDiff(heightdiff_line_by_dir[12 + style_t]))); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2400 |
ht = TileHeight(TILE_ADD(end_tile, ToTileIndexDiff(heightdiff_line_by_dir[12 + style_t + 1]))); |
5852
cb3f71b16e1a
(svn r8055) -Codechange: Replace the different max, dmax, maxu whatever macros by a simple template function max(), that requires two arguments of the same type. While I'm at it change a variable called "max" to "maxval" in a function that calls max().
celestar
parents:
5838
diff
changeset
|
2401 |
h1 = max(h1, ht); |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2402 |
} break; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2403 |
} |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2404 |
|
5984 | 2405 |
if (swap) Swap(h0, h1); |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2406 |
/* Minimap shows height in intervals of 50 meters, let's do the same */ |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2407 |
return (int)(h1 - h0) * 50; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2408 |
} |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2409 |
|
4885
c9fe8c52fd50
(svn r6822) -Fix r6821: add type for measure_strings_length[]
glx
parents:
4884
diff
changeset
|
2410 |
static const StringID measure_strings_length[] = {STR_NULL, STR_MEASURE_LENGTH, STR_MEASURE_LENGTH_HEIGHTDIFF}; |
4884
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2411 |
|
6919
339210ecccd3
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6574
diff
changeset
|
2412 |
/** while dragging */ |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2413 |
static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y, int method) |
0 | 2414 |
{ |
4799
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4634
diff
changeset
|
2415 |
HighLightStyle b; |
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4634
diff
changeset
|
2416 |
uint w, h; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
2417 |
|
4799
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4634
diff
changeset
|
2418 |
int dx = thd->selstart.x - (thd->selend.x & ~0xF); |
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4634
diff
changeset
|
2419 |
int dy = thd->selstart.y - (thd->selend.y & ~0xF); |
8419
de9999f762d0
(svn r11476) -Codechange: rename the function myabs to abs to get rid of an unneeded define
skidd13
parents:
8418
diff
changeset
|
2420 |
w = abs(dx) + 16; |
de9999f762d0
(svn r11476) -Codechange: rename the function myabs to abs to get rid of an unneeded define
skidd13
parents:
8418
diff
changeset
|
2421 |
h = abs(dy) + 16; |
0 | 2422 |
|
1980
9ea0c89fbb58
(svn r2486) Turn TILE_FROM_XY into an inline function and rename it to TileVirtXY
tron
parents:
1977
diff
changeset
|
2423 |
if (TileVirtXY(thd->selstart.x, thd->selstart.y) == TileVirtXY(x, y)) { // check if we're only within one tile |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4000
diff
changeset
|
2424 |
if (method == VPM_RAILDIRS) { |
2116 | 2425 |
b = GetAutorailHT(x, y); |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4000
diff
changeset
|
2426 |
} else { // rect for autosignals on one tile |
2116 | 2427 |
b = HT_RECT; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4000
diff
changeset
|
2428 |
} |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2429 |
} else if (h == 16) { // Is this in X direction? |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4000
diff
changeset
|
2430 |
if (dx == 16) { // 2x1 special handling |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2431 |
b = (Check2x1AutoRail(3)) | HT_LINE; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4000
diff
changeset
|
2432 |
} else if (dx == -16) { |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2433 |
b = (Check2x1AutoRail(2)) | HT_LINE; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4000
diff
changeset
|
2434 |
} else { |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2435 |
b = HT_LINE | HT_DIR_X; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4000
diff
changeset
|
2436 |
} |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2437 |
y = thd->selstart.y; |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2438 |
} else if (w == 16) { // Or Y direction? |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4000
diff
changeset
|
2439 |
if (dy == 16) { // 2x1 special handling |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2440 |
b = (Check2x1AutoRail(1)) | HT_LINE; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4000
diff
changeset
|
2441 |
} else if (dy == -16) { // 2x1 other direction |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2442 |
b = (Check2x1AutoRail(0)) | HT_LINE; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4000
diff
changeset
|
2443 |
} else { |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2444 |
b = HT_LINE | HT_DIR_Y; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4000
diff
changeset
|
2445 |
} |
0 | 2446 |
x = thd->selstart.x; |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2447 |
} else if (w > h * 2) { // still count as x dir? |
2116 | 2448 |
b = HT_LINE | HT_DIR_X; |
0 | 2449 |
y = thd->selstart.y; |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2450 |
} else if (h > w * 2) { // still count as y dir? |
2116 | 2451 |
b = HT_LINE | HT_DIR_Y; |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2452 |
x = thd->selstart.x; |
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2453 |
} else { // complicated direction |
4799
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4634
diff
changeset
|
2454 |
int d = w - h; |
2116 | 2455 |
thd->selend.x = thd->selend.x & ~0xF; |
2456 |
thd->selend.y = thd->selend.y & ~0xF; |
|
0 | 2457 |
|
2458 |
// four cases. |
|
2459 |
if (x > thd->selstart.x) { |
|
2460 |
if (y > thd->selstart.y) { |
|
2461 |
// south |
|
2116 | 2462 |
if (d == 0) { |
2463 |
b = (x & 0xF) > (y & 0xF) ? HT_LINE | HT_DIR_VL : HT_LINE | HT_DIR_VR; |
|
2464 |
} else if (d >= 0) { |
|
2465 |
x = thd->selstart.x + h; |
|
2466 |
b = HT_LINE | HT_DIR_VL; |
|
2467 |
// return px == py || px == py + 16; |
|
2468 |
} else { |
|
2469 |
y = thd->selstart.y + w; |
|
2470 |
b = HT_LINE | HT_DIR_VR; |
|
2471 |
} // return px == py || px == py - 16; |
|
0 | 2472 |
} else { |
2473 |
// west |
|
2116 | 2474 |
if (d == 0) { |
2475 |
b = (x & 0xF) + (y & 0xF) >= 0x10 ? HT_LINE | HT_DIR_HL : HT_LINE | HT_DIR_HU; |
|
2476 |
} else if (d >= 0) { |
|
2477 |
x = thd->selstart.x + h; |
|
2478 |
b = HT_LINE | HT_DIR_HL; |
|
2479 |
} else { |
|
2480 |
y = thd->selstart.y - w; |
|
2481 |
b = HT_LINE | HT_DIR_HU; |
|
2482 |
} |
|
0 | 2483 |
} |
2484 |
} else { |
|
2485 |
if (y > thd->selstart.y) { |
|
2486 |
// east |
|
2116 | 2487 |
if (d == 0) { |
2488 |
b = (x & 0xF) + (y & 0xF) >= 0x10 ? HT_LINE | HT_DIR_HL : HT_LINE | HT_DIR_HU; |
|
2489 |
} else if (d >= 0) { |
|
2490 |
x = thd->selstart.x - h; |
|
2491 |
b = HT_LINE | HT_DIR_HU; |
|
2492 |
// return px == -py || px == -py - 16; |
|
2493 |
} else { |
|
2494 |
y = thd->selstart.y + w; |
|
2495 |
b = HT_LINE | HT_DIR_HL; |
|
2496 |
} // return px == -py || px == -py + 16; |
|
0 | 2497 |
} else { |
2498 |
// north |
|
2116 | 2499 |
if (d == 0) { |
2500 |
b = (x & 0xF) > (y & 0xF) ? HT_LINE | HT_DIR_VL : HT_LINE | HT_DIR_VR; |
|
2501 |
} else if (d >= 0) { |
|
2502 |
x = thd->selstart.x - h; |
|
2503 |
b = HT_LINE | HT_DIR_VR; |
|
2504 |
// return px == py || px == py - 16; |
|
2505 |
} else { |
|
2506 |
y = thd->selstart.y - w; |
|
2507 |
b = HT_LINE | HT_DIR_VL; |
|
2508 |
} //return px == py || px == py + 16; |
|
0 | 2509 |
} |
2510 |
} |
|
2511 |
} |
|
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2512 |
|
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2513 |
if (_patches.measure_tooltip) { |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2514 |
TileIndex t0 = TileVirtXY(thd->selstart.x, thd->selstart.y); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2515 |
TileIndex t1 = TileVirtXY(x, y); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2516 |
uint distance = DistanceManhattan(t0, t1) + 1; |
4884
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2517 |
byte index = 0; |
7502
71f5d2c6a605
(svn r10262) -Fix (r10258): some places that needed to be changed to uint64 were hidden/forgotten, which caused memory corruptions and that in caused all kinds of assertions to trigger.
rubidium
parents:
7433
diff
changeset
|
2518 |
uint64 params[2]; |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2519 |
|
4884
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2520 |
if (distance != 1) { |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2521 |
int heightdiff = CalcHeightdiff(b, distance, t0, t1); |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2522 |
/* If we are showing a tooltip for horizontal or vertical drags, |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2523 |
* 2 tiles have a length of 1. To bias towards the ceiling we add |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2524 |
* one before division. It feels more natural to count 3 lengths as 2 */ |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2525 |
if ((b & HT_DIR_MASK) != HT_DIR_X && (b & HT_DIR_MASK) != HT_DIR_Y) { |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2526 |
distance = (distance + 1) / 2; |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2527 |
} |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2528 |
|
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2529 |
params[index++] = distance; |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2530 |
if (heightdiff != 0) params[index++] = heightdiff; |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2531 |
} |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2532 |
|
4884
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2533 |
GuiShowTooltipsWithArgs(measure_strings_length[index], index, params); |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2534 |
} |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2535 |
|
0 | 2536 |
thd->selend.x = x; |
2537 |
thd->selend.y = y; |
|
2538 |
thd->next_drawstyle = b; |
|
2539 |
} |
|
2540 |
||
4799
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4634
diff
changeset
|
2541 |
/** |
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4634
diff
changeset
|
2542 |
* Selects tiles while dragging |
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4634
diff
changeset
|
2543 |
* @param x X coordinate of end of selection |
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4634
diff
changeset
|
2544 |
* @param y Y coordinate of end of selection |
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4634
diff
changeset
|
2545 |
* @param method modifies the way tiles are selected. Possible |
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4634
diff
changeset
|
2546 |
* methods are VPM_* in viewport.h */ |
8384
cda01fb6ec2a
(svn r11439) -Codechange: replace some magic numbers by a ViewportPlaceMethod enumified constant. Patch by SmatZ.
rubidium
parents:
8345
diff
changeset
|
2547 |
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method) |
0 | 2548 |
{ |
4799
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4634
diff
changeset
|
2549 |
int sx, sy; |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2550 |
HighLightStyle style; |
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2551 |
|
0 | 2552 |
if (x == -1) { |
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2553 |
_thd.selend.x = -1; |
0 | 2554 |
return; |
2555 |
} |
|
2556 |
||
4799
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4634
diff
changeset
|
2557 |
/* Special handling of drag in any (8-way) 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
|
2558 |
if (method == VPM_RAILDIRS || method == VPM_SIGNALDIRS) { |
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2559 |
_thd.selend.x = x; |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2560 |
_thd.selend.y = y; |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2561 |
CalcRaildirsDrawstyle(&_thd, x, y, method); |
0 | 2562 |
return; |
2563 |
} |
|
2564 |
||
8408
b14e4f68d1d7
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz
parents:
8401
diff
changeset
|
2565 |
/* Needed so level-land is placed correctly */ |
2116 | 2566 |
if (_thd.next_drawstyle == HT_POINT) { |
4799
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4634
diff
changeset
|
2567 |
x += TILE_SIZE / 2; |
a32af5dd7b6c
(svn r6721) -Codechange: some comments, aligning, types and variable localization.
Darkvater
parents:
4634
diff
changeset
|
2568 |
y += TILE_SIZE / 2; |
2116 | 2569 |
} |
0 | 2570 |
|
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2571 |
sx = _thd.selstart.x; |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2572 |
sy = _thd.selstart.y; |
0 | 2573 |
|
2116 | 2574 |
switch (method) { |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2575 |
case VPM_X_OR_Y: /* drag in X or Y direction */ |
8419
de9999f762d0
(svn r11476) -Codechange: rename the function myabs to abs to get rid of an unneeded define
skidd13
parents:
8418
diff
changeset
|
2576 |
if (abs(sy - y) < abs(sx - x)) { |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4000
diff
changeset
|
2577 |
y = sy; |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2578 |
style = HT_DIR_X; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4000
diff
changeset
|
2579 |
} else { |
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4000
diff
changeset
|
2580 |
x = sx; |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2581 |
style = HT_DIR_Y; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4000
diff
changeset
|
2582 |
} |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2583 |
goto calc_heightdiff_single_direction; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2584 |
case VPM_FIX_X: /* drag in Y direction */ |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2585 |
x = sx; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2586 |
style = HT_DIR_Y; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2587 |
goto calc_heightdiff_single_direction; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2588 |
case VPM_FIX_Y: /* drag in X direction */ |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2589 |
y = sy; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2590 |
style = HT_DIR_X; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2591 |
|
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2592 |
calc_heightdiff_single_direction:; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2593 |
if (_patches.measure_tooltip) { |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2594 |
TileIndex t0 = TileVirtXY(sx, sy); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2595 |
TileIndex t1 = TileVirtXY(x, y); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2596 |
uint distance = DistanceManhattan(t0, t1) + 1; |
4884
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2597 |
byte index = 0; |
7502
71f5d2c6a605
(svn r10262) -Fix (r10258): some places that needed to be changed to uint64 were hidden/forgotten, which caused memory corruptions and that in caused all kinds of assertions to trigger.
rubidium
parents:
7433
diff
changeset
|
2598 |
uint64 params[2]; |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2599 |
|
4884
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2600 |
if (distance != 1) { |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2601 |
/* With current code passing a HT_LINE style to calculate the height |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2602 |
* difference is enough. However if/when a point-tool is created |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2603 |
* with this method, function should be called with new_style (below) |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2604 |
* instead of HT_LINE | style case HT_POINT is handled specially |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2605 |
* new_style := (_thd.next_drawstyle & HT_RECT) ? HT_LINE | style : _thd.next_drawstyle; */ |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2606 |
int heightdiff = CalcHeightdiff(HT_LINE | style, 0, t0, t1); |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2607 |
|
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2608 |
params[index++] = distance; |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2609 |
if (heightdiff != 0) params[index++] = heightdiff; |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2610 |
} |
4884
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2611 |
|
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2612 |
GuiShowTooltipsWithArgs(measure_strings_length[index], index, params); |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2613 |
} break; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2614 |
|
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2615 |
case VPM_X_AND_Y_LIMITED: { /* drag an X by Y constrained rect area */ |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2616 |
int limit = (_thd.sizelimit - 1) * TILE_SIZE; |
8418
b49fc6be1ab9
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents:
8414
diff
changeset
|
2617 |
x = sx + Clamp(x - sx, -limit, limit); |
b49fc6be1ab9
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents:
8414
diff
changeset
|
2618 |
y = sy + Clamp(y - sy, -limit, limit); |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
2619 |
} /* Fallthrough */ |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
2620 |
case VPM_X_AND_Y: { /* drag an X by Y area */ |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2621 |
if (_patches.measure_tooltip) { |
4884
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2622 |
static const StringID measure_strings_area[] = { |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2623 |
STR_NULL, STR_NULL, STR_MEASURE_AREA, STR_MEASURE_AREA_HEIGHTDIFF |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2624 |
}; |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2625 |
|
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2626 |
TileIndex t0 = TileVirtXY(sx, sy); |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2627 |
TileIndex t1 = TileVirtXY(x, y); |
8466
9ce95e16f9f9
(svn r11526) -Codechange: Rename the function delta fitting to the naming style
skidd13
parents:
8450
diff
changeset
|
2628 |
uint dx = Delta(TileX(t0), TileX(t1)) + 1; |
9ce95e16f9f9
(svn r11526) -Codechange: Rename the function delta fitting to the naming style
skidd13
parents:
8450
diff
changeset
|
2629 |
uint dy = Delta(TileY(t0), TileY(t1)) + 1; |
4884
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2630 |
byte index = 0; |
7502
71f5d2c6a605
(svn r10262) -Fix (r10258): some places that needed to be changed to uint64 were hidden/forgotten, which caused memory corruptions and that in caused all kinds of assertions to trigger.
rubidium
parents:
7433
diff
changeset
|
2631 |
uint64 params[3]; |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2632 |
|
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2633 |
/* If dragging an area (eg dynamite tool) and it is actually a single |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2634 |
* row/column, change the type to 'line' to get proper calculation for height */ |
8720
4e60c30e2006
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8640
diff
changeset
|
2635 |
style = (HighLightStyle)_thd.next_drawstyle; |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2636 |
if (style & HT_RECT) { |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2637 |
if (dx == 1) { |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2638 |
style = HT_LINE | HT_DIR_Y; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2639 |
} else if (dy == 1) { |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2640 |
style = HT_LINE | HT_DIR_X; |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2641 |
} |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2642 |
} |
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2643 |
|
4884
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2644 |
if (dx != 1 || dy != 1) { |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2645 |
int heightdiff = CalcHeightdiff(style, 0, t0, t1); |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2646 |
|
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2647 |
params[index++] = dx; |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2648 |
params[index++] = dy; |
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2649 |
if (heightdiff != 0) params[index++] = heightdiff; |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2650 |
} |
4884
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2651 |
|
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2652 |
GuiShowTooltipsWithArgs(measure_strings_area[index], index, params); |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2653 |
} |
4884
895f06b87934
(svn r6821) -Codechange: For the measurement tool do not show the tooltip when the selection
Darkvater
parents:
4838
diff
changeset
|
2654 |
break; |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2655 |
|
2116 | 2656 |
} |
4834
ddcf440d0ffd
(svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents:
4799
diff
changeset
|
2657 |
default: NOT_REACHED(); |
0 | 2658 |
} |
2659 |
||
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2660 |
_thd.selend.x = x; |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2661 |
_thd.selend.y = y; |
0 | 2662 |
} |
2663 |
||
10638
1234ac29df11
(svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents:
10596
diff
changeset
|
2664 |
/** |
1234ac29df11
(svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents:
10596
diff
changeset
|
2665 |
* Handle the mouse while dragging for placement/resizing. |
1234ac29df11
(svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents:
10596
diff
changeset
|
2666 |
* @return Boolean whether search for a handler should continue |
1234ac29df11
(svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium
parents:
10596
diff
changeset
|
2667 |
*/ |
6573 | 2668 |
bool VpHandlePlaceSizingDrag() |
0 | 2669 |
{ |
2116 | 2670 |
if (_special_mouse_mode != WSM_SIZING) return true; |
0 | 2671 |
|
6919
339210ecccd3
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6574
diff
changeset
|
2672 |
/* stop drag mode if the window has been closed */ |
10486
247d43dfa6f1
(svn r13029) -Codechange: more work in the road to getting the WP macros and byte[WINDOW_CUSTOM_SIZE] removed. This step changes the event handling to work directly on the Window class instead of via a function pointer and big switches while keeping backward compatability while we're rewriting the Windows to the new scheme.
rubidium
parents:
10466
diff
changeset
|
2673 |
Window *w = FindWindowById(_thd.window_class, _thd.window_number); |
0 | 2674 |
if (w == NULL) { |
2675 |
ResetObjectToPlace(); |
|
2676 |
return false; |
|
2677 |
} |
|
2678 |
||
6919
339210ecccd3
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6574
diff
changeset
|
2679 |
/* while dragging execute the drag procedure of the corresponding window (mostly VpSelectTilesWithMethod() ) */ |
0 | 2680 |
if (_left_button_down) { |
10486
247d43dfa6f1
(svn r13029) -Codechange: more work in the road to getting the WP macros and byte[WINDOW_CUSTOM_SIZE] removed. This step changes the event handling to work directly on the Window class instead of via a function pointer and big switches while keeping backward compatability while we're rewriting the Windows to the new scheme.
rubidium
parents:
10466
diff
changeset
|
2681 |
w->OnPlaceDrag(_thd.select_method, _thd.select_proc, GetTileBelowCursor()); |
0 | 2682 |
return false; |
2683 |
} |
|
2684 |
||
6919
339210ecccd3
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6574
diff
changeset
|
2685 |
/* mouse button released.. |
339210ecccd3
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas
parents:
6574
diff
changeset
|
2686 |
* 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
|
2687 |
_special_mouse_mode = WSM_NONE; |
2116 | 2688 |
if (_thd.next_drawstyle == HT_RECT) { |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2689 |
_thd.place_mode = VHM_RECT; |
10486
247d43dfa6f1
(svn r13029) -Codechange: more work in the road to getting the WP macros and byte[WINDOW_CUSTOM_SIZE] removed. This step changes the event handling to work directly on the Window class instead of via a function pointer and big switches while keeping backward compatability while we're rewriting the Windows to the new scheme.
rubidium
parents:
10466
diff
changeset
|
2690 |
} else if (_thd.select_method == VPM_SIGNALDIRS) { // some might call this a hack... -- Dominik |
2116 | 2691 |
_thd.place_mode = VHM_RECT; |
2692 |
} else if (_thd.next_drawstyle & HT_LINE) { |
|
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2693 |
_thd.place_mode = VHM_RAIL; |
2116 | 2694 |
} else if (_thd.next_drawstyle & HT_RAIL) { |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2695 |
_thd.place_mode = VHM_RAIL; |
2116 | 2696 |
} else { |
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2697 |
_thd.place_mode = VHM_POINT; |
2116 | 2698 |
} |
0 | 2699 |
SetTileSelectSize(1, 1); |
2700 |
||
10486
247d43dfa6f1
(svn r13029) -Codechange: more work in the road to getting the WP macros and byte[WINDOW_CUSTOM_SIZE] removed. This step changes the event handling to work directly on the Window class instead of via a function pointer and big switches while keeping backward compatability while we're rewriting the Windows to the new scheme.
rubidium
parents:
10466
diff
changeset
|
2701 |
w->OnPlaceMouseUp(_thd.select_method, _thd.select_proc, _thd.selend, TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y)); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
2702 |
|
0 | 2703 |
return false; |
2704 |
} |
|
2705 |
||
8385
aedd7656cfd1
(svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents:
8384
diff
changeset
|
2706 |
void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, ViewportHighlightMode mode, Window *w) |
0 | 2707 |
{ |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5853
diff
changeset
|
2708 |
SetObjectToPlace(icon, pal, mode, w->window_class, w->window_number); |
0 | 2709 |
} |
2710 |
||
2711 |
#include "table/animcursors.h" |
|
2712 |
||
8385
aedd7656cfd1
(svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents:
8384
diff
changeset
|
2713 |
void SetObjectToPlace(CursorID icon, SpriteID pal, ViewportHighlightMode mode, WindowClass window_class, WindowNumber window_num) |
0 | 2714 |
{ |
9081
4c47047836f3
(svn r12166) -Fix [FS#337]: when drag&drop mode was cancelled by keyboard input, depot/group window wasn't updated (original patch by GrimRC)
smatz
parents:
9058
diff
changeset
|
2715 |
/* undo clicking on button and drag & drop */ |
4c47047836f3
(svn r12166) -Fix [FS#337]: when drag&drop mode was cancelled by keyboard input, depot/group window wasn't updated (original patch by GrimRC)
smatz
parents:
9058
diff
changeset
|
2716 |
if (_thd.place_mode != VHM_NONE || _special_mouse_mode == WSM_DRAGDROP) { |
10566
6467a5398cfb
(svn r13110) -Fix [FS#2018]: some toolbar buttons not being unpressed properly.
rubidium
parents:
10560
diff
changeset
|
2717 |
Window *w = FindWindowById(_thd.window_class, _thd.window_number); |
6467a5398cfb
(svn r13110) -Fix [FS#2018]: some toolbar buttons not being unpressed properly.
rubidium
parents:
10560
diff
changeset
|
2718 |
if (w != NULL) { |
6467a5398cfb
(svn r13110) -Fix [FS#2018]: some toolbar buttons not being unpressed properly.
rubidium
parents:
10560
diff
changeset
|
2719 |
/* Call the abort function, but set the window class to something |
6467a5398cfb
(svn r13110) -Fix [FS#2018]: some toolbar buttons not being unpressed properly.
rubidium
parents:
10560
diff
changeset
|
2720 |
* that will never be used to avoid infinite loops. Setting it to |
6467a5398cfb
(svn r13110) -Fix [FS#2018]: some toolbar buttons not being unpressed properly.
rubidium
parents:
10560
diff
changeset
|
2721 |
* the 'next' window class must not be done because recursion into |
6467a5398cfb
(svn r13110) -Fix [FS#2018]: some toolbar buttons not being unpressed properly.
rubidium
parents:
10560
diff
changeset
|
2722 |
* this function might in some cases reset the newly set object to |
6467a5398cfb
(svn r13110) -Fix [FS#2018]: some toolbar buttons not being unpressed properly.
rubidium
parents:
10560
diff
changeset
|
2723 |
* place or not properly reset the original selection. */ |
6467a5398cfb
(svn r13110) -Fix [FS#2018]: some toolbar buttons not being unpressed properly.
rubidium
parents:
10560
diff
changeset
|
2724 |
_thd.window_class = WC_INVALID; |
6467a5398cfb
(svn r13110) -Fix [FS#2018]: some toolbar buttons not being unpressed properly.
rubidium
parents:
10560
diff
changeset
|
2725 |
w->OnPlaceObjectAbort(); |
6467a5398cfb
(svn r13110) -Fix [FS#2018]: some toolbar buttons not being unpressed properly.
rubidium
parents:
10560
diff
changeset
|
2726 |
} |
0 | 2727 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
2728 |
|
0 | 2729 |
SetTileSelectSize(1, 1); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
2730 |
|
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2731 |
_thd.make_square_red = false; |
0 | 2732 |
|
8385
aedd7656cfd1
(svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents:
8384
diff
changeset
|
2733 |
if (mode == VHM_DRAG) { // VHM_DRAG is for dragdropping trains in the depot window |
aedd7656cfd1
(svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents:
8384
diff
changeset
|
2734 |
mode = VHM_NONE; |
0 | 2735 |
_special_mouse_mode = WSM_DRAGDROP; |
2736 |
} else { |
|
2737 |
_special_mouse_mode = WSM_NONE; |
|
2738 |
} |
|
2739 |
||
1863
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2740 |
_thd.place_mode = mode; |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2741 |
_thd.window_class = window_class; |
610acc8bc189
(svn r2369) Remove _thd_ptr: It always holds the address of _thd
tron
parents:
1542
diff
changeset
|
2742 |
_thd.window_number = window_num; |
0 | 2743 |
|
1070
bef634a62323
(svn r1571) Feature: Visually enhanced autorail placing
dominik
parents:
988
diff
changeset
|
2744 |
if (mode == VHM_SPECIAL) // special tools, like tunnels or docks start with presizing mode |
0 | 2745 |
VpStartPreSizing(); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
152
diff
changeset
|
2746 |
|
10560
0cf0a95ebaf9
(svn r13104) -Codechange: make ResetObjectToPlace safe to be called recursively via the OnPlaceObjectAbort callback and use this knowledge to simplify closing some windows.
rubidium
parents:
10512
diff
changeset
|
2747 |
if ((int)icon < 0) { |
4334
75322a204d0c
(svn r6035) -Revert r5900 which supposedly fixed an invalid warning caused by buggy MS software
Darkvater
parents:
4272
diff
changeset
|
2748 |
SetAnimatedMouseCursor(_animcursors[~icon]); |
10560
0cf0a95ebaf9
(svn r13104) -Codechange: make ResetObjectToPlace safe to be called recursively via the OnPlaceObjectAbort callback and use this knowledge to simplify closing some windows.
rubidium
parents:
10512
diff
changeset
|
2749 |
} else { |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5853
diff
changeset
|
2750 |
SetMouseCursor(icon, pal); |
10560
0cf0a95ebaf9
(svn r13104) -Codechange: make ResetObjectToPlace safe to be called recursively via the OnPlaceObjectAbort callback and use this knowledge to simplify closing some windows.
rubidium
parents:
10512
diff
changeset
|
2751 |
} |
0cf0a95ebaf9
(svn r13104) -Codechange: make ResetObjectToPlace safe to be called recursively via the OnPlaceObjectAbort callback and use this knowledge to simplify closing some windows.
rubidium
parents:
10512
diff
changeset
|
2752 |
|
0 | 2753 |
} |
2754 |
||
6573 | 2755 |
void ResetObjectToPlace() |
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1083
diff
changeset
|
2756 |
{ |
6144
5a0ffbf27ced
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5984
diff
changeset
|
2757 |
SetObjectToPlace(SPR_CURSOR_MOUSE, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0); |
0 | 2758 |
} |