Mercurial > hg > openttd
annotate src/viewport.cpp @ 10864:e10213483b43 draft
(svn r15199) -Fix (r15190): The south point of the south-most tile wasn't highlighted during terraforming.
author | Yexo <Yexo@openttd.org> |
---|---|
date | Wed, 21 Jan 2009 22:35:07 +0000 |
parents | 7881d9cd55ab |
children | a4e5b5d2837c |
rev | line source |
---|---|
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2 |
9111
d48433370037
(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 <rubidium@openttd.org>
parents:
9082
diff
changeset
|
3 /** @file viewport.cpp Handling of all viewports. |
8957
484f482e54fa
(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 <rubidium@openttd.org>
parents:
8953
diff
changeset
|
4 * |
484f482e54fa
(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 <rubidium@openttd.org>
parents:
8953
diff
changeset
|
5 * \verbatim |
484f482e54fa
(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 <rubidium@openttd.org>
parents:
8953
diff
changeset
|
6 * The in-game coordinate system looks like this * |
484f482e54fa
(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 <rubidium@openttd.org>
parents:
8953
diff
changeset
|
7 * * |
484f482e54fa
(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 <rubidium@openttd.org>
parents:
8953
diff
changeset
|
8 * ^ Z * |
484f482e54fa
(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 <rubidium@openttd.org>
parents:
8953
diff
changeset
|
9 * | * |
484f482e54fa
(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 <rubidium@openttd.org>
parents:
8953
diff
changeset
|
10 * | * |
484f482e54fa
(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 <rubidium@openttd.org>
parents:
8953
diff
changeset
|
11 * | * |
484f482e54fa
(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 <rubidium@openttd.org>
parents:
8953
diff
changeset
|
12 * | * |
484f482e54fa
(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 <rubidium@openttd.org>
parents:
8953
diff
changeset
|
13 * / \ * |
484f482e54fa
(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 <rubidium@openttd.org>
parents:
8953
diff
changeset
|
14 * / \ * |
484f482e54fa
(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 <rubidium@openttd.org>
parents:
8953
diff
changeset
|
15 * / \ * |
484f482e54fa
(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 <rubidium@openttd.org>
parents:
8953
diff
changeset
|
16 * / \ * |
484f482e54fa
(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 <rubidium@openttd.org>
parents:
8953
diff
changeset
|
17 * X < > Y * |
484f482e54fa
(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 <rubidium@openttd.org>
parents:
8953
diff
changeset
|
18 * \endverbatim |
484f482e54fa
(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 <rubidium@openttd.org>
parents:
8953
diff
changeset
|
19 */ |
6117
6def6ecb1bf7
(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 <belugas@openttd.org>
parents:
6106
diff
changeset
|
20 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
21 #include "stdafx.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
22 #include "openttd.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
23 #include "debug.h" |
8119
b6ec923e9fa8
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium <rubidium@openttd.org>
parents:
8114
diff
changeset
|
24 #include "tile_cmd.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
25 #include "gui.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
26 #include "spritecache.h" |
6453
666fc3ef3174
(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 <maedhros@openttd.org>
parents:
6448
diff
changeset
|
27 #include "landscape.h" |
8224
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
28 #include "viewport_func.h" |
8785
2a8950a812dc
(svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium <rubidium@openttd.org>
parents:
8743
diff
changeset
|
29 #include "station_base.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
30 #include "town.h" |
8790
5ef0059ccfc0
(svn r12501) -Codechange: split signs.h.
rubidium <rubidium@openttd.org>
parents:
8785
diff
changeset
|
31 #include "signs_base.h" |
5ef0059ccfc0
(svn r12501) -Codechange: split signs.h.
rubidium <rubidium@openttd.org>
parents:
8785
diff
changeset
|
32 #include "signs_func.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
33 #include "waypoint.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
34 #include "variables.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
35 #include "train.h" |
6857
0005a9ed1903
(svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for
maedhros <maedhros@openttd.org>
parents:
6853
diff
changeset
|
36 #include "roadveh.h" |
7486
1af81beda3fb
(svn r10997) -Codechange: unify the vehicle view window. Patch by PhilSophus.
rubidium <rubidium@openttd.org>
parents:
7333
diff
changeset
|
37 #include "vehicle_gui.h" |
6937
b6cf3513b2c4
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight <truelight@openttd.org>
parents:
6878
diff
changeset
|
38 #include "blitter/factory.hpp" |
7849
e6ee8bfd9045
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas <belugas@openttd.org>
parents:
7824
diff
changeset
|
39 #include "transparency.h" |
8114
2d6af5d7a142
(svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
8106
diff
changeset
|
40 #include "strings_func.h" |
8123
c26c28875749
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium <rubidium@openttd.org>
parents:
8121
diff
changeset
|
41 #include "zoom_func.h" |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
8139
diff
changeset
|
42 #include "vehicle_func.h" |
10208
39cf8eebfda5
(svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
10207
diff
changeset
|
43 #include "company_func.h" |
8270
5613b863190d
(svn r11834) -Codechange: only include settings_type.h if needed.
rubidium <rubidium@openttd.org>
parents:
8264
diff
changeset
|
44 #include "settings_type.h" |
8785
2a8950a812dc
(svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium <rubidium@openttd.org>
parents:
8743
diff
changeset
|
45 #include "station_func.h" |
8925
d0568cbc5bdf
(svn r12695) -Codechange: only allocate window structs when needed. Based on a patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8806
diff
changeset
|
46 #include "core/alloc_type.hpp" |
9555
73e3eef68bf1
(svn r13575) -Codechange: Move small vector to core since it fits better in there
skidd13 <skidd13@openttd.org>
parents:
9553
diff
changeset
|
47 #include "core/smallvec_type.hpp" |
9117
453c3d26f4bc
(svn r12977) -Codechange: remove quite some redundant (duplicate) function declarations.
rubidium <rubidium@openttd.org>
parents:
9111
diff
changeset
|
48 #include "window_func.h" |
9127
428852b86d4d
(svn r12987) -Codechange: split viewport and tile selection.
rubidium <rubidium@openttd.org>
parents:
9117
diff
changeset
|
49 #include "tilehighlight_func.h" |
9274
85a62fb8608f
(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 <rubidium@openttd.org>
parents:
9273
diff
changeset
|
50 #include "window_gui.h" |
8946
402107c0562f
(svn r12734) -Codechange: use a vector instead of allocating memory in a big byte array for StringSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8925
diff
changeset
|
51 |
8264
2495310e220f
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8254
diff
changeset
|
52 #include "table/sprites.h" |
2495310e220f
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8254
diff
changeset
|
53 #include "table/strings.h" |
2495310e220f
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents:
8254
diff
changeset
|
54 |
8224
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
55 PlaceProc *_place_proc; |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
56 Point _tile_fract_coords; |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
57 ZoomLevel _saved_scrollpos_zoom; |
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
58 |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
59 struct StringSpriteToDraw { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
60 uint16 string; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
61 uint16 color; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
62 int32 x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
63 int32 y; |
7006
933d3ee6d37d
(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 <rubidium@openttd.org>
parents:
6937
diff
changeset
|
64 uint64 params[2]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
65 uint16 width; |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
66 }; |
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
67 |
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
68 struct TileSpriteToDraw { |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5602
diff
changeset
|
69 SpriteID image; |
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5602
diff
changeset
|
70 SpriteID pal; |
7681
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
71 const SubSprite *sub; ///< only draw a rectangular part of the sprite |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
72 int32 x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
73 int32 y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
74 byte z; |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
75 }; |
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
76 |
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
77 struct ChildScreenSpriteToDraw { |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5602
diff
changeset
|
78 SpriteID image; |
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5602
diff
changeset
|
79 SpriteID pal; |
7681
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
80 const SubSprite *sub; ///< only draw a rectangular part of the sprite |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
81 int32 x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
82 int32 y; |
9534
564d5fd5a247
(svn r13538) -Fix (r12740)[FS#2087]: ChildSprites of foundations are not necessarily consecutive.
frosch <frosch@openttd.org>
parents:
9510
diff
changeset
|
83 int next; ///< next child to draw (-1 at the end) |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
84 }; |
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
85 |
10233
63a58f4b2607
(svn r14461) -Document: add some doxygen comments (Albert)
rubidium <rubidium@openttd.org>
parents:
10216
diff
changeset
|
86 /** Parent sprite that should be drawn */ |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
87 struct ParentSpriteToDraw { |
7569
326049261489
(svn r11094) -Documentation: Add comments on viewport structures and change an obscure variable name to something a little more meaningfull.
belugas <belugas@openttd.org>
parents:
7545
diff
changeset
|
88 SpriteID image; ///< sprite to draw |
326049261489
(svn r11094) -Documentation: Add comments on viewport structures and change an obscure variable name to something a little more meaningfull.
belugas <belugas@openttd.org>
parents:
7545
diff
changeset
|
89 SpriteID pal; ///< palette to use |
7681
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
90 const SubSprite *sub; ///< only draw a rectangular part of the sprite |
7569
326049261489
(svn r11094) -Documentation: Add comments on viewport structures and change an obscure variable name to something a little more meaningfull.
belugas <belugas@openttd.org>
parents:
7545
diff
changeset
|
91 |
7580
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
92 int32 x; ///< screen X coordinate of sprite |
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
93 int32 y; ///< screen Y coordinate of sprite |
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
94 |
7569
326049261489
(svn r11094) -Documentation: Add comments on viewport structures and change an obscure variable name to something a little more meaningfull.
belugas <belugas@openttd.org>
parents:
7545
diff
changeset
|
95 int32 left; ///< minimal screen X coordinate of sprite (= x + sprite->x_offs), reference point for child sprites |
326049261489
(svn r11094) -Documentation: Add comments on viewport structures and change an obscure variable name to something a little more meaningfull.
belugas <belugas@openttd.org>
parents:
7545
diff
changeset
|
96 int32 top; ///< minimal screen Y coordinate of sprite (= y + sprite->y_offs), reference point for child sprites |
326049261489
(svn r11094) -Documentation: Add comments on viewport structures and change an obscure variable name to something a little more meaningfull.
belugas <belugas@openttd.org>
parents:
7545
diff
changeset
|
97 |
326049261489
(svn r11094) -Documentation: Add comments on viewport structures and change an obscure variable name to something a little more meaningfull.
belugas <belugas@openttd.org>
parents:
7545
diff
changeset
|
98 int32 xmin; ///< minimal world X coordinate of bounding box |
326049261489
(svn r11094) -Documentation: Add comments on viewport structures and change an obscure variable name to something a little more meaningfull.
belugas <belugas@openttd.org>
parents:
7545
diff
changeset
|
99 int32 xmax; ///< maximal world X coordinate of bounding box |
326049261489
(svn r11094) -Documentation: Add comments on viewport structures and change an obscure variable name to something a little more meaningfull.
belugas <belugas@openttd.org>
parents:
7545
diff
changeset
|
100 int32 ymin; ///< minimal world Y coordinate of bounding box |
326049261489
(svn r11094) -Documentation: Add comments on viewport structures and change an obscure variable name to something a little more meaningfull.
belugas <belugas@openttd.org>
parents:
7545
diff
changeset
|
101 int32 ymax; ///< maximal world Y coordinate of bounding box |
7580
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
102 int zmin; ///< minimal world Z coordinate of bounding box |
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
103 int zmax; ///< maximal world Z coordinate of bounding box |
7569
326049261489
(svn r11094) -Documentation: Add comments on viewport structures and change an obscure variable name to something a little more meaningfull.
belugas <belugas@openttd.org>
parents:
7545
diff
changeset
|
104 |
8952
2a7a810979e0
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8951
diff
changeset
|
105 int first_child; ///< the first child to draw. |
7580
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
106 bool comparison_done; ///< Used during sprite sorting: true if sprite has been compared with all other sprites |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
107 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
108 |
10233
63a58f4b2607
(svn r14461) -Document: add some doxygen comments (Albert)
rubidium <rubidium@openttd.org>
parents:
10216
diff
changeset
|
109 /** Enumeration of multi-part foundations */ |
7769
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
110 enum FoundationPart { |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
111 FOUNDATION_PART_NONE = 0xFF, ///< Neither foundation nor groundsprite drawn yet. |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
112 FOUNDATION_PART_NORMAL = 0, ///< First part (normal foundation or no foundation) |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
113 FOUNDATION_PART_HALFTILE = 1, ///< Second part (halftile foundation) |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
114 FOUNDATION_PART_END |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
115 }; |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
116 |
8949
36b54e6eec1e
(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 <peter1138@openttd.org>
parents:
8948
diff
changeset
|
117 typedef SmallVector<TileSpriteToDraw, 64> TileSpriteToDrawVector; |
36b54e6eec1e
(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 <peter1138@openttd.org>
parents:
8948
diff
changeset
|
118 typedef SmallVector<StringSpriteToDraw, 4> StringSpriteToDrawVector; |
8951
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
119 typedef SmallVector<ParentSpriteToDraw, 64> ParentSpriteToDrawVector; |
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
120 typedef SmallVector<ParentSpriteToDraw*, 64> ParentSpriteToSortVector; |
8952
2a7a810979e0
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8951
diff
changeset
|
121 typedef SmallVector<ChildScreenSpriteToDraw, 16> ChildScreenSpriteToDrawVector; |
8946
402107c0562f
(svn r12734) -Codechange: use a vector instead of allocating memory in a big byte array for StringSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8925
diff
changeset
|
122 |
10233
63a58f4b2607
(svn r14461) -Document: add some doxygen comments (Albert)
rubidium <rubidium@openttd.org>
parents:
10216
diff
changeset
|
123 /** Data structure storing rendering information */ |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
124 struct ViewportDrawer { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
125 DrawPixelInfo dpi; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
126 |
8946
402107c0562f
(svn r12734) -Codechange: use a vector instead of allocating memory in a big byte array for StringSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8925
diff
changeset
|
127 StringSpriteToDrawVector string_sprites_to_draw; |
8947
20e58270e32d
(svn r12735) -Codechange: use a vector instead of allocating memory in a byte array for TileSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8946
diff
changeset
|
128 TileSpriteToDrawVector tile_sprites_to_draw; |
8951
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
129 ParentSpriteToDrawVector parent_sprites_to_draw; |
10233
63a58f4b2607
(svn r14461) -Document: add some doxygen comments (Albert)
rubidium <rubidium@openttd.org>
parents:
10216
diff
changeset
|
130 ParentSpriteToSortVector parent_sprites_to_sort; ///< Parent sprite pointer array used for sorting |
8952
2a7a810979e0
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8951
diff
changeset
|
131 ChildScreenSpriteToDrawVector child_screen_sprites_to_draw; |
2a7a810979e0
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8951
diff
changeset
|
132 |
2a7a810979e0
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8951
diff
changeset
|
133 int *last_child; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
134 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
135 byte combine_sprites; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
136 |
8952
2a7a810979e0
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8951
diff
changeset
|
137 int foundation[FOUNDATION_PART_END]; ///< Foundation sprites (index into parent_sprites_to_draw). |
2a7a810979e0
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8951
diff
changeset
|
138 FoundationPart foundation_part; ///< Currently active foundation for ground sprite drawing. |
2a7a810979e0
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8951
diff
changeset
|
139 int *last_foundation_child[FOUNDATION_PART_END]; ///< Tail of ChildSprite list of the foundations. (index into child_screen_sprites_to_draw) |
2a7a810979e0
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8951
diff
changeset
|
140 Point foundation_offset[FOUNDATION_PART_END]; ///< Pixeloffset for ground sprites on the foundations. |
6248
0789677a15a0
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
141 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
142 |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
143 static ViewportDrawer _vd; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
144 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
145 TileHighlightData _thd; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
146 static TileInfo *_cur_ti; |
8979
e6dbe6d84c32
(svn r12771) -Codechange: remove more from variables.h.
rubidium <rubidium@openttd.org>
parents:
8969
diff
changeset
|
147 bool _draw_bounding_boxes = false; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
148 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
149 static Point MapXYZToViewport(const ViewPort *vp, uint x, uint y, uint z) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
150 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
151 Point p = RemapCoords(x, y, z); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
152 p.x -= vp->virtual_width / 2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
153 p.y -= vp->virtual_height / 2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
154 return p; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
155 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
156 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
157 void DeleteWindowViewport(Window *w) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
158 { |
9184
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
159 free(w->viewport); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
160 w->viewport = NULL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
161 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
162 |
8992
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
163 /** |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
164 * Initialize viewport of the window for use. |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
165 * @param w Window to use/display the viewport in |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
166 * @param x Offset of left edge of viewport with respect to left edge window \a w |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
167 * @param y Offset of top edge of viewport with respect to top edge window \a w |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
168 * @param width Width of the viewport |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
169 * @param height Height of the viewport |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
170 * @param follow_flags Flags controlling the viewport. |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
171 * - If bit 31 is set, the lower 16 bits are the vehicle that the viewport should follow. |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
172 * - If bit 31 is clear, it is a tile position. |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
173 * @param zoom Zoomlevel to display |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
174 */ |
8994
e4c3087abbde
(svn r12789) -Codechange: rename AssignWindowViewport to InitializeWindowViewport because the viewport is now part of the window struct. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8992
diff
changeset
|
175 void InitializeWindowViewport(Window *w, int x, int y, |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
176 int width, int height, uint32 follow_flags, ZoomLevel zoom) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
177 { |
8957
484f482e54fa
(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 <rubidium@openttd.org>
parents:
8953
diff
changeset
|
178 assert(w->viewport == NULL); |
484f482e54fa
(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 <rubidium@openttd.org>
parents:
8953
diff
changeset
|
179 |
9184
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
180 ViewportData *vp = CallocT<ViewportData>(1); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
181 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
182 vp->left = x + w->left; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
183 vp->top = y + w->top; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
184 vp->width = width; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
185 vp->height = height; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
186 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
187 vp->zoom = zoom; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
188 |
6654
860f3e5f70ec
(svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight <truelight@openttd.org>
parents:
6653
diff
changeset
|
189 vp->virtual_width = ScaleByZoom(width, zoom); |
860f3e5f70ec
(svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight <truelight@openttd.org>
parents:
6653
diff
changeset
|
190 vp->virtual_height = ScaleByZoom(height, zoom); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
191 |
8957
484f482e54fa
(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 <rubidium@openttd.org>
parents:
8953
diff
changeset
|
192 Point pt; |
484f482e54fa
(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 <rubidium@openttd.org>
parents:
8953
diff
changeset
|
193 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
194 if (follow_flags & 0x80000000) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
195 const Vehicle *veh; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
196 |
9184
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
197 vp->follow_vehicle = (VehicleID)(follow_flags & 0xFFFF); |
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
198 veh = GetVehicle(vp->follow_vehicle); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
199 pt = MapXYZToViewport(vp, veh->x_pos, veh->y_pos, veh->z_pos); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
200 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
201 uint x = TileX(follow_flags) * TILE_SIZE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
202 uint y = TileY(follow_flags) * TILE_SIZE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
203 |
9184
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
204 vp->follow_vehicle = INVALID_VEHICLE; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
205 pt = MapXYZToViewport(vp, x, y, GetSlopeZ(x, y)); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
206 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
207 |
9184
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
208 vp->scrollpos_x = pt.x; |
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
209 vp->scrollpos_y = pt.y; |
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
210 vp->dest_scrollpos_x = pt.x; |
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
211 vp->dest_scrollpos_y = pt.y; |
6730
0b56358a0e3d
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138 <peter1138@openttd.org>
parents:
6669
diff
changeset
|
212 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
213 w->viewport = vp; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
214 vp->virtual_left = 0;//pt.x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
215 vp->virtual_top = 0;//pt.y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
216 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
217 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
218 static Point _vp_move_offs; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
219 |
10610
1d2aeaa16ec6
(svn r14899) -Feature: remove the window limit, but leave a configurable limit on the number of non-sticky non-vital windows.
rubidium <rubidium@openttd.org>
parents:
10600
diff
changeset
|
220 static void DoSetViewportPosition(const Window *w, int left, int top, int width, int height) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
221 { |
10614
48b9085d5b21
(svn r14905) -Fix (r14899): in some corner cases already freed memory could be read.
rubidium <rubidium@openttd.org>
parents:
10610
diff
changeset
|
222 FOR_ALL_WINDOWS_FROM_BACK_FROM(w, w) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
223 if (left + width > w->left && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
224 w->left + w->width > left && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
225 top + height > w->top && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
226 w->top + w->height > top) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
227 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
228 if (left < w->left) { |
10610
1d2aeaa16ec6
(svn r14899) -Feature: remove the window limit, but leave a configurable limit on the number of non-sticky non-vital windows.
rubidium <rubidium@openttd.org>
parents:
10600
diff
changeset
|
229 DoSetViewportPosition(w, left, top, w->left - left, height); |
1d2aeaa16ec6
(svn r14899) -Feature: remove the window limit, but leave a configurable limit on the number of non-sticky non-vital windows.
rubidium <rubidium@openttd.org>
parents:
10600
diff
changeset
|
230 DoSetViewportPosition(w, left + (w->left - left), top, width - (w->left - left), height); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
231 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
232 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
233 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
234 if (left + width > w->left + w->width) { |
10610
1d2aeaa16ec6
(svn r14899) -Feature: remove the window limit, but leave a configurable limit on the number of non-sticky non-vital windows.
rubidium <rubidium@openttd.org>
parents:
10600
diff
changeset
|
235 DoSetViewportPosition(w, left, top, (w->left + w->width - left), height); |
1d2aeaa16ec6
(svn r14899) -Feature: remove the window limit, but leave a configurable limit on the number of non-sticky non-vital windows.
rubidium <rubidium@openttd.org>
parents:
10600
diff
changeset
|
236 DoSetViewportPosition(w, left + (w->left + w->width - left), top, width - (w->left + w->width - left) , height); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
237 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
238 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
239 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
240 if (top < w->top) { |
10610
1d2aeaa16ec6
(svn r14899) -Feature: remove the window limit, but leave a configurable limit on the number of non-sticky non-vital windows.
rubidium <rubidium@openttd.org>
parents:
10600
diff
changeset
|
241 DoSetViewportPosition(w, left, top, width, (w->top - top)); |
1d2aeaa16ec6
(svn r14899) -Feature: remove the window limit, but leave a configurable limit on the number of non-sticky non-vital windows.
rubidium <rubidium@openttd.org>
parents:
10600
diff
changeset
|
242 DoSetViewportPosition(w, left, top + (w->top - top), width, height - (w->top - top)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
243 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
244 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
245 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
246 if (top + height > w->top + w->height) { |
10610
1d2aeaa16ec6
(svn r14899) -Feature: remove the window limit, but leave a configurable limit on the number of non-sticky non-vital windows.
rubidium <rubidium@openttd.org>
parents:
10600
diff
changeset
|
247 DoSetViewportPosition(w, left, top, width, (w->top + w->height - top)); |
1d2aeaa16ec6
(svn r14899) -Feature: remove the window limit, but leave a configurable limit on the number of non-sticky non-vital windows.
rubidium <rubidium@openttd.org>
parents:
10600
diff
changeset
|
248 DoSetViewportPosition(w, left, top + (w->top + w->height - top), width , height - (w->top + w->height - top)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
249 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
250 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
251 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
252 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
253 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
254 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
255 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
256 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
257 int xo = _vp_move_offs.x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
258 int yo = _vp_move_offs.y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
259 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
260 if (abs(xo) >= width || abs(yo) >= height) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
261 /* fully_outside */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
262 RedrawScreenRect(left, top, left + width, top + height); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
263 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
264 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
265 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
266 GfxScroll(left, top, width, height, xo, yo); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
267 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
268 if (xo > 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
269 RedrawScreenRect(left, top, xo + left, top + height); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
270 left += xo; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
271 width -= xo; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
272 } else if (xo < 0) { |
10642
29bc871ff8d1
(svn r14944) -Cleanup: add spaces around some operators
rubidium <rubidium@openttd.org>
parents:
10626
diff
changeset
|
273 RedrawScreenRect(left + width + xo, top, left + width, top + height); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
274 width += xo; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
275 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
276 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
277 if (yo > 0) { |
10642
29bc871ff8d1
(svn r14944) -Cleanup: add spaces around some operators
rubidium <rubidium@openttd.org>
parents:
10626
diff
changeset
|
278 RedrawScreenRect(left, top, width + left, top + yo); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
279 } else if (yo < 0) { |
10642
29bc871ff8d1
(svn r14944) -Cleanup: add spaces around some operators
rubidium <rubidium@openttd.org>
parents:
10626
diff
changeset
|
280 RedrawScreenRect(left, top + height + yo, width + left, top + height); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
281 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
282 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
283 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
284 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
285 static void SetViewportPosition(Window *w, int x, int y) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
286 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
287 ViewPort *vp = w->viewport; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
288 int old_left = vp->virtual_left; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
289 int old_top = vp->virtual_top; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
290 int i; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
291 int left, top, width, height; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
292 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
293 vp->virtual_left = x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
294 vp->virtual_top = y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
295 |
7905
63c86d0b97e7
(svn r11456) -Fix [FS#1412] (r10070): Viewport is bound to its top-left corner
smatz <smatz@openttd.org>
parents:
7889
diff
changeset
|
296 /* viewport is bound to its left top corner, so it must be rounded down (UnScaleByZoomLower) |
63c86d0b97e7
(svn r11456) -Fix [FS#1412] (r10070): Viewport is bound to its top-left corner
smatz <smatz@openttd.org>
parents:
7889
diff
changeset
|
297 * else glitch described in FS#1412 will happen (offset by 1 pixel with zoom level > NORMAL) |
63c86d0b97e7
(svn r11456) -Fix [FS#1412] (r10070): Viewport is bound to its top-left corner
smatz <smatz@openttd.org>
parents:
7889
diff
changeset
|
298 */ |
63c86d0b97e7
(svn r11456) -Fix [FS#1412] (r10070): Viewport is bound to its top-left corner
smatz <smatz@openttd.org>
parents:
7889
diff
changeset
|
299 old_left = UnScaleByZoomLower(old_left, vp->zoom); |
63c86d0b97e7
(svn r11456) -Fix [FS#1412] (r10070): Viewport is bound to its top-left corner
smatz <smatz@openttd.org>
parents:
7889
diff
changeset
|
300 old_top = UnScaleByZoomLower(old_top, vp->zoom); |
63c86d0b97e7
(svn r11456) -Fix [FS#1412] (r10070): Viewport is bound to its top-left corner
smatz <smatz@openttd.org>
parents:
7889
diff
changeset
|
301 x = UnScaleByZoomLower(x, vp->zoom); |
63c86d0b97e7
(svn r11456) -Fix [FS#1412] (r10070): Viewport is bound to its top-left corner
smatz <smatz@openttd.org>
parents:
7889
diff
changeset
|
302 y = UnScaleByZoomLower(y, vp->zoom); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
303 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
304 old_left -= x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
305 old_top -= y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
306 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
307 if (old_top == 0 && old_left == 0) return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
308 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
309 _vp_move_offs.x = old_left; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
310 _vp_move_offs.y = old_top; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
311 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
312 left = vp->left; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
313 top = vp->top; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
314 width = vp->width; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
315 height = vp->height; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
316 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
317 if (left < 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
318 width += left; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
319 left = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
320 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
321 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
322 i = left + width - _screen.width; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
323 if (i >= 0) width -= i; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
324 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
325 if (width > 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
326 if (top < 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
327 height += top; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
328 top = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
329 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
330 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
331 i = top + height - _screen.height; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
332 if (i >= 0) height -= i; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
333 |
10610
1d2aeaa16ec6
(svn r14899) -Feature: remove the window limit, but leave a configurable limit on the number of non-sticky non-vital windows.
rubidium <rubidium@openttd.org>
parents:
10600
diff
changeset
|
334 if (height > 0) DoSetViewportPosition(w->z_front, left, top, width, height); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
335 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
336 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
337 |
8992
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
338 /** |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
339 * Is a xy position inside the viewport of the window? |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
340 * @param w Window to examine its viewport |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
341 * @param x X coordinate of the xy position |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
342 * @param y Y coordinate of the xy position |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
343 * @return Pointer to the viewport if the xy position is in the viewport of the window, |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
344 * otherwise \c NULL is returned. |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
345 */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
346 ViewPort *IsPtInWindowViewport(const Window *w, int x, int y) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
347 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
348 ViewPort *vp = w->viewport; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
349 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
350 if (vp != NULL && |
8562
f539be5f3bd3
(svn r12140) -Codechange: A bit of code style fixes(Geektoo).
belugas <belugas@openttd.org>
parents:
8473
diff
changeset
|
351 IsInsideMM(x, vp->left, vp->left + vp->width) && |
7954
38bb7c45688f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13 <skidd13@openttd.org>
parents:
7951
diff
changeset
|
352 IsInsideMM(y, vp->top, vp->top + vp->height)) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
353 return vp; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
354 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
355 return NULL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
356 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
357 |
10233
63a58f4b2607
(svn r14461) -Document: add some doxygen comments (Albert)
rubidium <rubidium@openttd.org>
parents:
10216
diff
changeset
|
358 /** |
63a58f4b2607
(svn r14461) -Document: add some doxygen comments (Albert)
rubidium <rubidium@openttd.org>
parents:
10216
diff
changeset
|
359 * Translate screen coordinate in a viewport to a tile coordinate |
63a58f4b2607
(svn r14461) -Document: add some doxygen comments (Albert)
rubidium <rubidium@openttd.org>
parents:
10216
diff
changeset
|
360 * @param vp Viewport that contains the (\a x, \a y) screen coordinate |
63a58f4b2607
(svn r14461) -Document: add some doxygen comments (Albert)
rubidium <rubidium@openttd.org>
parents:
10216
diff
changeset
|
361 * @param x Screen x coordinate |
63a58f4b2607
(svn r14461) -Document: add some doxygen comments (Albert)
rubidium <rubidium@openttd.org>
parents:
10216
diff
changeset
|
362 * @param y Screen y coordinate |
63a58f4b2607
(svn r14461) -Document: add some doxygen comments (Albert)
rubidium <rubidium@openttd.org>
parents:
10216
diff
changeset
|
363 * @return Tile coordinate */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
364 static Point TranslateXYToTileCoord(const ViewPort *vp, int x, int y) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
365 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
366 Point pt; |
10642
29bc871ff8d1
(svn r14944) -Cleanup: add spaces around some operators
rubidium <rubidium@openttd.org>
parents:
10626
diff
changeset
|
367 int a, b; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
368 uint z; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
369 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
370 if ( (uint)(x -= vp->left) >= (uint)vp->width || |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
371 (uint)(y -= vp->top) >= (uint)vp->height) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
372 Point pt = {-1, -1}; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
373 return pt; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
374 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
375 |
6626
f940341a80f0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents:
6624
diff
changeset
|
376 x = (ScaleByZoom(x, vp->zoom) + vp->virtual_left) >> 2; |
f940341a80f0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents:
6624
diff
changeset
|
377 y = (ScaleByZoom(y, vp->zoom) + vp->virtual_top) >> 1; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
378 |
10642
29bc871ff8d1
(svn r14944) -Cleanup: add spaces around some operators
rubidium <rubidium@openttd.org>
parents:
10626
diff
changeset
|
379 a = y - x; |
29bc871ff8d1
(svn r14944) -Cleanup: add spaces around some operators
rubidium <rubidium@openttd.org>
parents:
10626
diff
changeset
|
380 b = y + x; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
381 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
382 /* we need to move variables in to the valid range, as the |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
383 * GetTileZoomCenterWindow() function can call here with invalid x and/or y, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
384 * when the user tries to zoom out along the sides of the map */ |
10855
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
385 a = Clamp(a, -4 * TILE_SIZE, (int)(MapMaxX() * TILE_SIZE) - 1); |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
386 b = Clamp(b, -4 * TILE_SIZE, (int)(MapMaxY() * TILE_SIZE) - 1); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
387 |
7764
4cdd7ef382fe
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7726
diff
changeset
|
388 /* (a, b) is the X/Y-world coordinate that belongs to (x,y) if the landscape would be completely flat on height 0. |
4cdd7ef382fe
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7726
diff
changeset
|
389 * Now find the Z-world coordinate by fix point iteration. |
4cdd7ef382fe
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7726
diff
changeset
|
390 * This is a bit tricky because the tile height is non-continuous at foundations. |
4cdd7ef382fe
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7726
diff
changeset
|
391 * The clicked point should be approached from the back, otherwise there are regions that are not clickable. |
4cdd7ef382fe
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7726
diff
changeset
|
392 * (FOUNDATION_HALFTILE_LOWER on SLOPE_STEEP_S hides north halftile completely) |
4cdd7ef382fe
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7726
diff
changeset
|
393 * So give it a z-malus of 4 in the first iterations. |
4cdd7ef382fe
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7726
diff
changeset
|
394 */ |
4cdd7ef382fe
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7726
diff
changeset
|
395 z = 0; |
10855
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
396 |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
397 int min_coord = _settings_game.construction.freeform_edges ? TILE_SIZE : 0; |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
398 |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
399 for (int i = 0; i < 5; i++) z = GetSlopeZ(Clamp(a + (int)max(z, 4u) - 4, min_coord, MapMaxX() * TILE_SIZE - 1), Clamp(b + (int)max(z, 4u) - 4, min_coord, MapMaxY() * TILE_SIZE - 1)) / 2; |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
400 for (uint malus = 3; malus > 0; malus--) z = GetSlopeZ(Clamp(a + (int)max(z, malus) - (int)malus, min_coord, MapMaxX() * TILE_SIZE - 1), Clamp(b + (int)max(z, malus) - (int)malus, min_coord, MapMaxY() * TILE_SIZE - 1)) / 2; |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
401 for (int i = 0; i < 5; i++) z = GetSlopeZ(Clamp(a + (int)z, min_coord, MapMaxX() * TILE_SIZE - 1), Clamp(b + (int)z, min_coord, MapMaxY() * TILE_SIZE - 1)) / 2; |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
402 |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
403 pt.x = Clamp(a + (int)z, min_coord, MapMaxX() * TILE_SIZE - 1); |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
404 pt.y = Clamp(b + (int)z, min_coord, MapMaxY() * TILE_SIZE - 1); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
405 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
406 return pt; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
407 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
408 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
409 /* When used for zooming, check area below current coordinates (x,y) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
410 * and return the tile of the zoomed out/in position (zoom_x, zoom_y) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
411 * when you just want the tile, make x = zoom_x and y = zoom_y */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
412 static Point GetTileFromScreenXY(int x, int y, int zoom_x, int zoom_y) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
413 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
414 Window *w; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
415 ViewPort *vp; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
416 Point pt; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
417 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
418 if ( (w = FindWindowFromPt(x, y)) != NULL && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
419 (vp = IsPtInWindowViewport(w, x, y)) != NULL) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
420 return TranslateXYToTileCoord(vp, zoom_x, zoom_y); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
421 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
422 pt.y = pt.x = -1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
423 return pt; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
424 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
425 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6117
diff
changeset
|
426 Point GetTileBelowCursor() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
427 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
428 return GetTileFromScreenXY(_cursor.pos.x, _cursor.pos.y, _cursor.pos.x, _cursor.pos.y); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
429 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
430 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
431 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
432 Point GetTileZoomCenterWindow(bool in, Window * w) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
433 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
434 int x, y; |
9184
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
435 ViewPort *vp = w->viewport; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
436 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
437 if (in) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
438 x = ((_cursor.pos.x - vp->left) >> 1) + (vp->width >> 2); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
439 y = ((_cursor.pos.y - vp->top) >> 1) + (vp->height >> 2); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
440 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
441 x = vp->width - (_cursor.pos.x - vp->left); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
442 y = vp->height - (_cursor.pos.y - vp->top); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
443 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
444 /* Get the tile below the cursor and center on the zoomed-out center */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
445 return GetTileFromScreenXY(_cursor.pos.x, _cursor.pos.y, x + vp->left, y + vp->top); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
446 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
447 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
448 /** Update the status of the zoom-buttons according to the zoom-level |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
449 * of the viewport. This will update their status and invalidate accordingly |
6443
bc27521ccac0
(svn r9580) -Documentation: Correction of doxygen function declarations
belugas <belugas@openttd.org>
parents:
6427
diff
changeset
|
450 * @param w Window pointer to the window that has the zoom buttons |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
451 * @param vp pointer to the viewport whose zoom-level the buttons represent |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
452 * @param widget_zoom_in widget index for window with zoom-in button |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
453 * @param widget_zoom_out widget index for window with zoom-out button */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
454 void HandleZoomMessage(Window *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
455 { |
7997
d109780d515b
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents:
7970
diff
changeset
|
456 w->SetWidgetDisabledState(widget_zoom_in, vp->zoom == ZOOM_LVL_MIN); |
8028
936ad1eb1c04
(svn r11588) -Codechange: use the new member introduced in r11551
glx <glx@openttd.org>
parents:
7997
diff
changeset
|
457 w->InvalidateWidget(widget_zoom_in); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
458 |
7997
d109780d515b
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents:
7970
diff
changeset
|
459 w->SetWidgetDisabledState(widget_zoom_out, vp->zoom == ZOOM_LVL_MAX); |
8028
936ad1eb1c04
(svn r11588) -Codechange: use the new member introduced in r11551
glx <glx@openttd.org>
parents:
7997
diff
changeset
|
460 w->InvalidateWidget(widget_zoom_out); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
461 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
462 |
7681
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
463 /** |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
464 * Draws a ground sprite at a specific world-coordinate. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
465 * |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
466 * @param image the image to draw. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
467 * @param pal the provided palette. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
468 * @param x position x of the sprite. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
469 * @param y position y of the sprite. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
470 * @param z position z of the sprite. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
471 * @param sub Only draw a part of the sprite. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
472 * |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
473 */ |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
474 void DrawGroundSpriteAt(SpriteID image, SpriteID pal, int32 x, int32 y, byte z, const SubSprite *sub) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
475 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
476 assert((image & SPRITE_MASK) < MAX_SPRITES); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
477 |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
478 TileSpriteToDraw *ts = _vd.tile_sprites_to_draw.Append(); |
8949
36b54e6eec1e
(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 <peter1138@openttd.org>
parents:
8948
diff
changeset
|
479 ts->image = image; |
36b54e6eec1e
(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 <peter1138@openttd.org>
parents:
8948
diff
changeset
|
480 ts->pal = pal; |
36b54e6eec1e
(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 <peter1138@openttd.org>
parents:
8948
diff
changeset
|
481 ts->sub = sub; |
36b54e6eec1e
(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 <peter1138@openttd.org>
parents:
8948
diff
changeset
|
482 ts->x = x; |
36b54e6eec1e
(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 <peter1138@openttd.org>
parents:
8948
diff
changeset
|
483 ts->y = y; |
36b54e6eec1e
(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 <peter1138@openttd.org>
parents:
8948
diff
changeset
|
484 ts->z = z; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
485 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
486 |
7681
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
487 /** |
7726
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
488 * Adds a child sprite to the active foundation. |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
489 * |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
490 * The pixel offset of the sprite relative to the ParentSprite is the sum of the offset passed to OffsetGroundSprite() and extra_offs_?. |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
491 * |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
492 * @param image the image to draw. |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
493 * @param pal the provided palette. |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
494 * @param sub Only draw a part of the sprite. |
7769
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
495 * @param foundation_part Foundation part. |
7726
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
496 * @param extra_offs_x Pixel X offset for the sprite position. |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
497 * @param extra_offs_y Pixel Y offset for the sprite position. |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
498 */ |
7769
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
499 static void AddChildSpriteToFoundation(SpriteID image, SpriteID pal, const SubSprite *sub, FoundationPart foundation_part, int extra_offs_x, int extra_offs_y) |
7726
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
500 { |
7954
38bb7c45688f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13 <skidd13@openttd.org>
parents:
7951
diff
changeset
|
501 assert(IsInsideMM(foundation_part, 0, FOUNDATION_PART_END)); |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
502 assert(_vd.foundation[foundation_part] != -1); |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
503 Point offs = _vd.foundation_offset[foundation_part]; |
7726
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
504 |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
505 /* Change the active ChildSprite list to the one of the foundation */ |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
506 int *old_child = _vd.last_child; |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
507 _vd.last_child = _vd.last_foundation_child[foundation_part]; |
7726
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
508 |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
509 AddChildSpriteScreen(image, pal, offs.x + extra_offs_x, offs.y + extra_offs_y, false, sub); |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
510 |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
511 /* Switch back to last ChildSprite list */ |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
512 _vd.last_child = old_child; |
7726
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
513 } |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
514 |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
515 /** |
7681
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
516 * Draws a ground sprite for the current tile. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
517 * If the current tile is drawn on top of a foundation the sprite is added as child sprite to the "foundation"-ParentSprite. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
518 * |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
519 * @param image the image to draw. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
520 * @param pal the provided palette. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
521 * @param sub Only draw a part of the sprite. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
522 */ |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
523 void DrawGroundSprite(SpriteID image, SpriteID pal, const SubSprite *sub) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
524 { |
7769
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
525 /* Switch to first foundation part, if no foundation was drawn */ |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
526 if (_vd.foundation_part == FOUNDATION_PART_NONE) _vd.foundation_part = FOUNDATION_PART_NORMAL; |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
527 |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
528 if (_vd.foundation[_vd.foundation_part] != -1) { |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
529 AddChildSpriteToFoundation(image, pal, sub, _vd.foundation_part, 0, 0); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
530 } else { |
7681
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
531 DrawGroundSpriteAt(image, pal, _cur_ti->x, _cur_ti->y, _cur_ti->z, sub); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
532 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
533 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
534 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
535 |
7726
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
536 /** |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
537 * Called when a foundation has been drawn for the current tile. |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
538 * Successive ground sprites for the current tile will be drawn as child sprites of the "foundation"-ParentSprite, not as TileSprites. |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
539 * |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
540 * @param x sprite x-offset (screen coordinates) of ground sprites relative to the "foundation"-ParentSprite. |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
541 * @param y sprite y-offset (screen coordinates) of ground sprites relative to the "foundation"-ParentSprite. |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
542 */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
543 void OffsetGroundSprite(int x, int y) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
544 { |
7769
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
545 /* Switch to next foundation part */ |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
546 switch (_vd.foundation_part) { |
7769
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
547 case FOUNDATION_PART_NONE: |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
548 _vd.foundation_part = FOUNDATION_PART_NORMAL; |
7769
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
549 break; |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
550 case FOUNDATION_PART_NORMAL: |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
551 _vd.foundation_part = FOUNDATION_PART_HALFTILE; |
7769
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
552 break; |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
553 default: NOT_REACHED(); |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
554 } |
7726
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
555 |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
556 /* _vd.last_child == NULL if foundation sprite was clipped by the viewport bounds */ |
9553
0069339d03bf
(svn r13573) -Codechange: Use smallvec class functions instead of class members
skidd13 <skidd13@openttd.org>
parents:
9534
diff
changeset
|
557 if (_vd.last_child != NULL) _vd.foundation[_vd.foundation_part] = _vd.parent_sprites_to_draw.Length() - 1; |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
558 |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
559 _vd.foundation_offset[_vd.foundation_part].x = x; |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
560 _vd.foundation_offset[_vd.foundation_part].y = y; |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
561 _vd.last_foundation_child[_vd.foundation_part] = _vd.last_child; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
562 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
563 |
7681
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
564 /** |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
565 * Adds a child sprite to a parent sprite. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
566 * In contrast to "AddChildSpriteScreen()" the sprite position is in world coordinates |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
567 * |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
568 * @param image the image to draw. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
569 * @param pal the provided palette. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
570 * @param x position x of the sprite. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
571 * @param y position y of the sprite. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
572 * @param z position z of the sprite. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
573 * @param sub Only draw a part of the sprite. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
574 */ |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
575 static void AddCombinedSprite(SpriteID image, SpriteID pal, int x, int y, byte z, const SubSprite *sub) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
576 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
577 Point pt = RemapCoords(x, y, z); |
10647
592ae9307430
(svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents:
10645
diff
changeset
|
578 const Sprite *spr = GetSprite(image & SPRITE_MASK, ST_NORMAL); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
579 |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
580 if (pt.x + spr->x_offs >= _vd.dpi.left + _vd.dpi.width || |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
581 pt.x + spr->x_offs + spr->width <= _vd.dpi.left || |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
582 pt.y + spr->y_offs >= _vd.dpi.top + _vd.dpi.height || |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
583 pt.y + spr->y_offs + spr->height <= _vd.dpi.top) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
584 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
585 |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
586 const ParentSpriteToDraw *pstd = _vd.parent_sprites_to_draw.End() - 1; |
8951
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
587 AddChildSpriteScreen(image, pal, pt.x - pstd->left, pt.y - pstd->top, false, sub); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
588 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
589 |
7580
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
590 /** Draw a (transparent) sprite at given coordinates with a given bounding box. |
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
591 * 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. |
7617
efa2262af59e
(svn r11147) -Fix [FS#1247] (r11105): reallow bounding boxes with x/y/z-extent 0. Some NewGRFs need them. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
592 * Bounding boxes with bb_offset_x == w or bb_offset_y == h or bb_offset_z == dz are allowed and produce thin slices. |
7580
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
593 * |
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
594 * @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 |
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
595 * defined by the sprite offset in the grf file. |
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
596 * However if modifying the sprite offsets is not suitable (e.g. when using existing graphics), the bounding box can be tuned by bb_offset. |
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
597 * |
7617
efa2262af59e
(svn r11147) -Fix [FS#1247] (r11105): reallow bounding boxes with x/y/z-extent 0. Some NewGRFs need them. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
598 * @pre w >= bb_offset_x, h >= bb_offset_y, dz >= bb_offset_z. Else w, h or dz are ignored. |
7580
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
599 * |
7333
7110c41ab174
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium <rubidium@openttd.org>
parents:
7321
diff
changeset
|
600 * @param image the image to combine and draw, |
7110c41ab174
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium <rubidium@openttd.org>
parents:
7321
diff
changeset
|
601 * @param pal the provided palette, |
7580
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
602 * @param x position X (world) of the sprite, |
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
603 * @param y position Y (world) of the sprite, |
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
604 * @param w bounding box extent towards positive X (world), |
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
605 * @param h bounding box extent towards positive Y (world), |
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
606 * @param dz bounding box extent towards positive Z (world), |
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
607 * @param z position Z (world) of the sprite, |
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
608 * @param transparent if true, switch the palette between the provided palette and the transparent palette, |
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
609 * @param bb_offset_x bounding box extent towards negative X (world), |
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
610 * @param bb_offset_y bounding box extent towards negative Y (world), |
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
611 * @param bb_offset_z bounding box extent towards negative Z (world) |
7681
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
612 * @param sub Only draw a part of the sprite. |
7333
7110c41ab174
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium <rubidium@openttd.org>
parents:
7321
diff
changeset
|
613 */ |
7681
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
614 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) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
615 { |
7643
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
616 int32 left, right, top, bottom; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
617 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
618 assert((image & SPRITE_MASK) < MAX_SPRITES); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
619 |
7333
7110c41ab174
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium <rubidium@openttd.org>
parents:
7321
diff
changeset
|
620 /* make the sprites transparent with the right palette */ |
7110c41ab174
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium <rubidium@openttd.org>
parents:
7321
diff
changeset
|
621 if (transparent) { |
7931
44ff7a6d801f
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7929
diff
changeset
|
622 SetBit(image, PALETTE_MODIFIER_TRANSPARENT); |
7333
7110c41ab174
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium <rubidium@openttd.org>
parents:
7321
diff
changeset
|
623 pal = PALETTE_TO_TRANSPARENT; |
7110c41ab174
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium <rubidium@openttd.org>
parents:
7321
diff
changeset
|
624 } |
7110c41ab174
(svn r10696) -Codechange: remove duplication of the "make sprite transparent" code.
rubidium <rubidium@openttd.org>
parents:
7321
diff
changeset
|
625 |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
626 if (_vd.combine_sprites == 2) { |
7681
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
627 AddCombinedSprite(image, pal, x, y, z, sub); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
628 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
629 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
630 |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
631 _vd.last_child = NULL; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
632 |
8951
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
633 Point pt = RemapCoords(x, y, z); |
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
634 int tmp_left, tmp_top, tmp_x = pt.x, tmp_y = pt.y; |
7643
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
635 |
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
636 /* Compute screen extents of sprite */ |
7601
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7580
diff
changeset
|
637 if (image == SPR_EMPTY_BOUNDING_BOX) { |
8951
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
638 left = tmp_left = RemapCoords(x + w , y + bb_offset_y, z + bb_offset_z).x; |
7643
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
639 right = RemapCoords(x + bb_offset_x, y + h , z + bb_offset_z).x + 1; |
8951
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
640 top = tmp_top = RemapCoords(x + bb_offset_x, y + bb_offset_y, z + dz ).y; |
7643
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
641 bottom = RemapCoords(x + w , y + h , z + bb_offset_z).y + 1; |
7601
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7580
diff
changeset
|
642 } else { |
10056
7867701f63e4
(svn r14223) -Codechange: make GetSprite aware of the 4 different types of sprites: fonts, recolour, mapgen and normal sprites.
rubidium <rubidium@openttd.org>
parents:
10055
diff
changeset
|
643 const Sprite *spr = GetSprite(image & SPRITE_MASK, ST_NORMAL); |
8951
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
644 left = tmp_left = (pt.x += spr->x_offs); |
7643
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
645 right = (pt.x + spr->width ); |
8951
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
646 top = tmp_top = (pt.y += spr->y_offs); |
7643
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
647 bottom = (pt.y + spr->height); |
7601
b5ee57f72673
(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 <rubidium@openttd.org>
parents:
7580
diff
changeset
|
648 } |
8562
f539be5f3bd3
(svn r12140) -Codechange: A bit of code style fixes(Geektoo).
belugas <belugas@openttd.org>
parents:
8473
diff
changeset
|
649 |
7643
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
650 if (_draw_bounding_boxes && (image != SPR_EMPTY_BOUNDING_BOX)) { |
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
651 /* Compute maximal extents of sprite and it's bounding box */ |
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
652 left = min(left , RemapCoords(x + w , y + bb_offset_y, z + bb_offset_z).x); |
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
653 right = max(right , RemapCoords(x + bb_offset_x, y + h , z + bb_offset_z).x + 1); |
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
654 top = min(top , RemapCoords(x + bb_offset_x, y + bb_offset_y, z + dz ).y); |
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
655 bottom = max(bottom, RemapCoords(x + w , y + h , z + bb_offset_z).y + 1); |
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
656 } |
8562
f539be5f3bd3
(svn r12140) -Codechange: A bit of code style fixes(Geektoo).
belugas <belugas@openttd.org>
parents:
8473
diff
changeset
|
657 |
7643
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
658 /* Do not add the sprite to the viewport, if it is outside */ |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
659 if (left >= _vd.dpi.left + _vd.dpi.width || |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
660 right <= _vd.dpi.left || |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
661 top >= _vd.dpi.top + _vd.dpi.height || |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
662 bottom <= _vd.dpi.top) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
663 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
664 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
665 |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
666 ParentSpriteToDraw *ps = _vd.parent_sprites_to_draw.Append(); |
8951
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
667 ps->x = tmp_x; |
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
668 ps->y = tmp_y; |
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
669 |
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
670 ps->left = tmp_left; |
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
671 ps->top = tmp_top; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
672 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
673 ps->image = image; |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5602
diff
changeset
|
674 ps->pal = pal; |
7681
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
675 ps->sub = sub; |
7580
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
676 ps->xmin = x + bb_offset_x; |
7617
efa2262af59e
(svn r11147) -Fix [FS#1247] (r11105): reallow bounding boxes with x/y/z-extent 0. Some NewGRFs need them. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
677 ps->xmax = x + max(bb_offset_x, w) - 1; |
7580
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
678 |
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
679 ps->ymin = y + bb_offset_y; |
7617
efa2262af59e
(svn r11147) -Fix [FS#1247] (r11105): reallow bounding boxes with x/y/z-extent 0. Some NewGRFs need them. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
680 ps->ymax = y + max(bb_offset_y, h) - 1; |
7580
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
681 |
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
682 ps->zmin = z + bb_offset_z; |
7617
efa2262af59e
(svn r11147) -Fix [FS#1247] (r11105): reallow bounding boxes with x/y/z-extent 0. Some NewGRFs need them. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7601
diff
changeset
|
683 ps->zmax = z + max(bb_offset_z, dz) - 1; |
7580
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
684 |
8ae764721b47
(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 <rubidium@openttd.org>
parents:
7579
diff
changeset
|
685 ps->comparison_done = false; |
9534
564d5fd5a247
(svn r13538) -Fix (r12740)[FS#2087]: ChildSprites of foundations are not necessarily consecutive.
frosch <frosch@openttd.org>
parents:
9510
diff
changeset
|
686 ps->first_child = -1; |
564d5fd5a247
(svn r13538) -Fix (r12740)[FS#2087]: ChildSprites of foundations are not necessarily consecutive.
frosch <frosch@openttd.org>
parents:
9510
diff
changeset
|
687 |
564d5fd5a247
(svn r13538) -Fix (r12740)[FS#2087]: ChildSprites of foundations are not necessarily consecutive.
frosch <frosch@openttd.org>
parents:
9510
diff
changeset
|
688 _vd.last_child = &ps->first_child; |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
689 |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
690 if (_vd.combine_sprites == 1) _vd.combine_sprites = 2; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
691 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
692 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6117
diff
changeset
|
693 void StartSpriteCombine() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
694 { |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
695 _vd.combine_sprites = 1; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
696 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
697 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6117
diff
changeset
|
698 void EndSpriteCombine() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
699 { |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
700 _vd.combine_sprites = 0; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
701 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
702 |
7681
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
703 /** |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
704 * Add a child sprite to a parent sprite. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
705 * |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
706 * @param image the image to draw. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
707 * @param pal the provided palette. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
708 * @param x sprite x-offset (screen coordinates) relative to parent sprite. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
709 * @param y sprite y-offset (screen coordinates) relative to parent sprite. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
710 * @param transparent if true, switch the palette between the provided palette and the transparent palette, |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
711 * @param sub Only draw a part of the sprite. |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
712 */ |
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
713 void AddChildSpriteScreen(SpriteID image, SpriteID pal, int x, int y, bool transparent, const SubSprite *sub) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
714 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
715 assert((image & SPRITE_MASK) < MAX_SPRITES); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
716 |
8952
2a7a810979e0
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8951
diff
changeset
|
717 /* If the ParentSprite was clipped by the viewport bounds, do not draw the ChildSprites either */ |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
718 if (_vd.last_child == NULL) return; |
8952
2a7a810979e0
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8951
diff
changeset
|
719 |
7659
03747e97c53b
(svn r11190) -Fix: make snowy roofs of (newgrf) houses also transparent.
rubidium <rubidium@openttd.org>
parents:
7643
diff
changeset
|
720 /* make the sprites transparent with the right palette */ |
03747e97c53b
(svn r11190) -Fix: make snowy roofs of (newgrf) houses also transparent.
rubidium <rubidium@openttd.org>
parents:
7643
diff
changeset
|
721 if (transparent) { |
7931
44ff7a6d801f
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7929
diff
changeset
|
722 SetBit(image, PALETTE_MODIFIER_TRANSPARENT); |
7659
03747e97c53b
(svn r11190) -Fix: make snowy roofs of (newgrf) houses also transparent.
rubidium <rubidium@openttd.org>
parents:
7643
diff
changeset
|
723 pal = PALETTE_TO_TRANSPARENT; |
03747e97c53b
(svn r11190) -Fix: make snowy roofs of (newgrf) houses also transparent.
rubidium <rubidium@openttd.org>
parents:
7643
diff
changeset
|
724 } |
03747e97c53b
(svn r11190) -Fix: make snowy roofs of (newgrf) houses also transparent.
rubidium <rubidium@openttd.org>
parents:
7643
diff
changeset
|
725 |
9553
0069339d03bf
(svn r13573) -Codechange: Use smallvec class functions instead of class members
skidd13 <skidd13@openttd.org>
parents:
9534
diff
changeset
|
726 *_vd.last_child = _vd.child_screen_sprites_to_draw.Length(); |
9534
564d5fd5a247
(svn r13538) -Fix (r12740)[FS#2087]: ChildSprites of foundations are not necessarily consecutive.
frosch <frosch@openttd.org>
parents:
9510
diff
changeset
|
727 |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
728 ChildScreenSpriteToDraw *cs = _vd.child_screen_sprites_to_draw.Append(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
729 cs->image = image; |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5602
diff
changeset
|
730 cs->pal = pal; |
7681
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
731 cs->sub = sub; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
732 cs->x = x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
733 cs->y = y; |
9534
564d5fd5a247
(svn r13538) -Fix (r12740)[FS#2087]: ChildSprites of foundations are not necessarily consecutive.
frosch <frosch@openttd.org>
parents:
9510
diff
changeset
|
734 cs->next = -1; |
564d5fd5a247
(svn r13538) -Fix (r12740)[FS#2087]: ChildSprites of foundations are not necessarily consecutive.
frosch <frosch@openttd.org>
parents:
9510
diff
changeset
|
735 |
564d5fd5a247
(svn r13538) -Fix (r12740)[FS#2087]: ChildSprites of foundations are not necessarily consecutive.
frosch <frosch@openttd.org>
parents:
9510
diff
changeset
|
736 /* Append the sprite to the active ChildSprite list. |
564d5fd5a247
(svn r13538) -Fix (r12740)[FS#2087]: ChildSprites of foundations are not necessarily consecutive.
frosch <frosch@openttd.org>
parents:
9510
diff
changeset
|
737 * If the active ParentSprite is a foundation, update last_foundation_child as well. |
564d5fd5a247
(svn r13538) -Fix (r12740)[FS#2087]: ChildSprites of foundations are not necessarily consecutive.
frosch <frosch@openttd.org>
parents:
9510
diff
changeset
|
738 * Note: ChildSprites of foundations are NOT sequential in the vector, as selection sprites are added at last. */ |
564d5fd5a247
(svn r13538) -Fix (r12740)[FS#2087]: ChildSprites of foundations are not necessarily consecutive.
frosch <frosch@openttd.org>
parents:
9510
diff
changeset
|
739 if (_vd.last_foundation_child[0] == _vd.last_child) _vd.last_foundation_child[0] = &cs->next; |
564d5fd5a247
(svn r13538) -Fix (r12740)[FS#2087]: ChildSprites of foundations are not necessarily consecutive.
frosch <frosch@openttd.org>
parents:
9510
diff
changeset
|
740 if (_vd.last_foundation_child[1] == _vd.last_child) _vd.last_foundation_child[1] = &cs->next; |
564d5fd5a247
(svn r13538) -Fix (r12740)[FS#2087]: ChildSprites of foundations are not necessarily consecutive.
frosch <frosch@openttd.org>
parents:
9510
diff
changeset
|
741 _vd.last_child = &cs->next; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
742 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
743 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
744 /* Returns a StringSpriteToDraw */ |
8946
402107c0562f
(svn r12734) -Codechange: use a vector instead of allocating memory in a big byte array for StringSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8925
diff
changeset
|
745 void AddStringToDraw(int x, int y, StringID string, uint64 params_1, uint64 params_2, uint16 color, uint16 width) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
746 { |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
747 StringSpriteToDraw *ss = _vd.string_sprites_to_draw.Append(); |
8949
36b54e6eec1e
(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 <peter1138@openttd.org>
parents:
8948
diff
changeset
|
748 ss->string = string; |
36b54e6eec1e
(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 <peter1138@openttd.org>
parents:
8948
diff
changeset
|
749 ss->x = x; |
36b54e6eec1e
(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 <peter1138@openttd.org>
parents:
8948
diff
changeset
|
750 ss->y = y; |
36b54e6eec1e
(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 <peter1138@openttd.org>
parents:
8948
diff
changeset
|
751 ss->params[0] = params_1; |
36b54e6eec1e
(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 <peter1138@openttd.org>
parents:
8948
diff
changeset
|
752 ss->params[1] = params_2; |
36b54e6eec1e
(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 <peter1138@openttd.org>
parents:
8948
diff
changeset
|
753 ss->width = width; |
36b54e6eec1e
(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 <peter1138@openttd.org>
parents:
8948
diff
changeset
|
754 ss->color = color; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
755 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
756 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
757 |
7726
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
758 /** |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
759 * Draws sprites between ground sprite and everything above. |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
760 * |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
761 * The sprite is either drawn as TileSprite or as ChildSprite of the active foundation. |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
762 * |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
763 * @param image the image to draw. |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
764 * @param pal the provided palette. |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
765 * @param ti TileInfo Tile that is being drawn |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
766 * @param z_offset Z offset relative to the groundsprite. Only used for the sprite position, not for sprite sorting. |
7769
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
767 * @param foundation_part Foundation part the sprite belongs to. |
7726
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
768 */ |
7769
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
769 static void DrawSelectionSprite(SpriteID image, SpriteID pal, const TileInfo *ti, int z_offset, FoundationPart foundation_part) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
770 { |
7726
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
771 /* FIXME: This is not totally valid for some autorail highlights, that extent over the edges of the tile. */ |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
772 if (_vd.foundation[foundation_part] == -1) { |
7726
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
773 /* draw on real ground */ |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
774 DrawGroundSpriteAt(image, pal, ti->x, ti->y, ti->z + z_offset); |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
775 } else { |
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
776 /* draw on top of foundation */ |
7769
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
777 AddChildSpriteToFoundation(image, pal, NULL, foundation_part, 0, -z_offset); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
778 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
779 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
780 |
7679
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
781 /** |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
782 * Draws a selection rectangle on a tile. |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
783 * |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
784 * @param ti TileInfo Tile that is being drawn |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
785 * @param pal Palette to apply. |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
786 */ |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
787 static void DrawTileSelectionRect(const TileInfo *ti, SpriteID pal) |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
788 { |
10815
8966b7fa7a24
(svn r15150) -Fix: Don't highlight tiles outside the visible map.
Yexo <Yexo@openttd.org>
parents:
10732
diff
changeset
|
789 if (!IsValidTile(ti->tile)) return; |
8966b7fa7a24
(svn r15150) -Fix: Don't highlight tiles outside the visible map.
Yexo <Yexo@openttd.org>
parents:
10732
diff
changeset
|
790 |
7769
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
791 SpriteID sel; |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
792 if (IsHalftileSlope(ti->tileh)) { |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
793 Corner halftile_corner = GetHalftileSlopeCorner(ti->tileh); |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
794 SpriteID sel2 = SPR_HALFTILE_SELECTION_FLAT + halftile_corner; |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
795 DrawSelectionSprite(sel2, pal, ti, 7 + TILE_HEIGHT, FOUNDATION_PART_HALFTILE); |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
796 |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
797 Corner opposite_corner = OppositeCorner(halftile_corner); |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
798 if (IsSteepSlope(ti->tileh)) { |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
799 sel = SPR_HALFTILE_SELECTION_DOWN; |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
800 } else { |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
801 sel = ((ti->tileh & SlopeWithOneCornerRaised(opposite_corner)) != 0 ? SPR_HALFTILE_SELECTION_UP : SPR_HALFTILE_SELECTION_FLAT); |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
802 } |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
803 sel += opposite_corner; |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
804 } else { |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
805 sel = SPR_SELECT_TILE + _tileh_to_sprite[ti->tileh]; |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
806 } |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
807 DrawSelectionSprite(sel, pal, ti, 7, FOUNDATION_PART_NORMAL); |
7679
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
808 } |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
809 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
810 static bool IsPartOfAutoLine(int px, int py) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
811 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
812 px -= _thd.selstart.x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
813 py -= _thd.selstart.y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
814 |
8224
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
815 if ((_thd.drawstyle & ~HT_DIR_MASK) != HT_LINE) return false; |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
816 |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
817 switch (_thd.drawstyle & HT_DIR_MASK) { |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
818 case HT_DIR_X: return py == 0; // x direction |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
819 case HT_DIR_Y: return px == 0; // y direction |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
820 case HT_DIR_HU: return px == -py || px == -py - 16; // horizontal upper |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
821 case HT_DIR_HL: return px == -py || px == -py + 16; // horizontal lower |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
822 case HT_DIR_VL: return px == py || px == py + 16; // vertival left |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
823 case HT_DIR_VR: return px == py || px == py - 16; // vertical right |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
824 default: |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
825 NOT_REACHED(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
826 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
827 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
828 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
829 // [direction][side] |
8224
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
830 static const HighLightStyle _autorail_type[6][2] = { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
831 { HT_DIR_X, HT_DIR_X }, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
832 { HT_DIR_Y, HT_DIR_Y }, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
833 { HT_DIR_HU, HT_DIR_HL }, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
834 { HT_DIR_HL, HT_DIR_HU }, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
835 { HT_DIR_VL, HT_DIR_VR }, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
836 { HT_DIR_VR, HT_DIR_VL } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
837 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
838 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
839 #include "table/autorail.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
840 |
7078
c4d51d528cd2
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas <belugas@openttd.org>
parents:
7069
diff
changeset
|
841 /** |
7679
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
842 * Draws autorail highlights. |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
843 * |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
844 * @param *ti TileInfo Tile that is being drawn |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
845 * @param autorail_type Offset into _AutorailTilehSprite[][] |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
846 */ |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
847 static void DrawAutorailSelection(const TileInfo *ti, uint autorail_type) |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
848 { |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
849 SpriteID image; |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
850 SpriteID pal; |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
851 int offset; |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
852 |
7769
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
853 FoundationPart foundation_part = FOUNDATION_PART_NORMAL; |
8413
5c456105e68a
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch <frosch@openttd.org>
parents:
8270
diff
changeset
|
854 Slope autorail_tileh = RemoveHalftileSlope(ti->tileh); |
7769
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
855 if (IsHalftileSlope(ti->tileh)) { |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
856 static const uint _lower_rail[4] = { 5U, 2U, 4U, 3U }; |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
857 Corner halftile_corner = GetHalftileSlopeCorner(ti->tileh); |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
858 if (autorail_type != _lower_rail[halftile_corner]) { |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
859 foundation_part = FOUNDATION_PART_HALFTILE; |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
860 /* Here we draw the highlights of the "three-corners-raised"-slope. That looks ok to me. */ |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
861 autorail_tileh = SlopeWithThreeCornersRaised(OppositeCorner(halftile_corner)); |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
862 } |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
863 } |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
864 |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
865 offset = _AutorailTilehSprite[autorail_tileh][autorail_type]; |
7679
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
866 if (offset >= 0) { |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
867 image = SPR_AUTORAIL_BASE + offset; |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
868 pal = PAL_NONE; |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
869 } else { |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
870 image = SPR_AUTORAIL_BASE - offset; |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
871 pal = PALETTE_SEL_TILE_RED; |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
872 } |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
873 |
7769
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
874 DrawSelectionSprite(image, _thd.make_square_red ? PALETTE_SEL_TILE_RED : pal, ti, 7, foundation_part); |
7679
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
875 } |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
876 |
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
877 /** |
7078
c4d51d528cd2
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas <belugas@openttd.org>
parents:
7069
diff
changeset
|
878 * Checks if the specified tile is selected and if so draws selection using correct selectionstyle. |
c4d51d528cd2
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas <belugas@openttd.org>
parents:
7069
diff
changeset
|
879 * @param *ti TileInfo Tile that is being drawn |
c4d51d528cd2
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas <belugas@openttd.org>
parents:
7069
diff
changeset
|
880 */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
881 static void DrawTileSelection(const TileInfo *ti) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
882 { |
6423
72ac8bfaa32f
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas <belugas@openttd.org>
parents:
6248
diff
changeset
|
883 /* Draw a red error square? */ |
10816
35b3e8e25590
(svn r15151) -Fix: tile 0 can now be highlighted as error tile
Yexo <Yexo@openttd.org>
parents:
10815
diff
changeset
|
884 bool is_redsq = _thd.redsq == ti->tile; |
8743
d6d6bbb8da9c
(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 <rubidium@openttd.org>
parents:
8585
diff
changeset
|
885 if (is_redsq) DrawTileSelectionRect(ti, PALETTE_TILE_RED_PULSATING); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
886 |
6423
72ac8bfaa32f
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas <belugas@openttd.org>
parents:
6248
diff
changeset
|
887 /* no selection active? */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
888 if (_thd.drawstyle == 0) return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
889 |
6423
72ac8bfaa32f
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas <belugas@openttd.org>
parents:
6248
diff
changeset
|
890 /* Inside the inner area? */ |
7954
38bb7c45688f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13 <skidd13@openttd.org>
parents:
7951
diff
changeset
|
891 if (IsInsideBS(ti->x, _thd.pos.x, _thd.size.x) && |
38bb7c45688f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13 <skidd13@openttd.org>
parents:
7951
diff
changeset
|
892 IsInsideBS(ti->y, _thd.pos.y, _thd.size.y)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
893 if (_thd.drawstyle & HT_RECT) { |
8743
d6d6bbb8da9c
(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 <rubidium@openttd.org>
parents:
8585
diff
changeset
|
894 if (!is_redsq) DrawTileSelectionRect(ti, _thd.make_square_red ? PALETTE_SEL_TILE_RED : PAL_NONE); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
895 } else if (_thd.drawstyle & HT_POINT) { |
6423
72ac8bfaa32f
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas <belugas@openttd.org>
parents:
6248
diff
changeset
|
896 /* Figure out the Z coordinate for the single dot. */ |
7726
9f29ddfd8351
(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 <rubidium@openttd.org>
parents:
7681
diff
changeset
|
897 byte z = 0; |
7769
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
898 FoundationPart foundation_part = FOUNDATION_PART_NORMAL; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
899 if (ti->tileh & SLOPE_N) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
900 z += TILE_HEIGHT; |
8413
5c456105e68a
(svn r11983) -Codechange: Add some helper functions for slopes and use them.
frosch <frosch@openttd.org>
parents:
8270
diff
changeset
|
901 if (RemoveHalftileSlope(ti->tileh) == SLOPE_STEEP_N) z += TILE_HEIGHT; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
902 } |
7769
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
903 if (IsHalftileSlope(ti->tileh)) { |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
904 Corner halftile_corner = GetHalftileSlopeCorner(ti->tileh); |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
905 if ((halftile_corner == CORNER_W) || (halftile_corner == CORNER_E)) z += TILE_HEIGHT; |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
906 if (halftile_corner != CORNER_S) { |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
907 foundation_part = FOUNDATION_PART_HALFTILE; |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
908 if (IsSteepSlope(ti->tileh)) z -= TILE_HEIGHT; |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
909 } |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
910 } |
ca89a62f72e1
(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 <rubidium@openttd.org>
parents:
7764
diff
changeset
|
911 DrawSelectionSprite(_cur_dpi->zoom <= ZOOM_LVL_DETAIL ? SPR_DOT : SPR_DOT_SMALL, PAL_NONE, ti, z, foundation_part); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
912 } else if (_thd.drawstyle & HT_RAIL /*&& _thd.place_mode == VHM_RAIL*/) { |
6423
72ac8bfaa32f
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas <belugas@openttd.org>
parents:
6248
diff
changeset
|
913 /* autorail highlight piece under cursor */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
914 uint type = _thd.drawstyle & 0xF; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
915 assert(type <= 5); |
8224
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
916 DrawAutorailSelection(ti, _autorail_type[type][0]); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
917 } else if (IsPartOfAutoLine(ti->x, ti->y)) { |
6423
72ac8bfaa32f
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas <belugas@openttd.org>
parents:
6248
diff
changeset
|
918 /* autorail highlighting long line */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
919 int dir = _thd.drawstyle & ~0xF0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
920 uint side; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
921 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
922 if (dir < 2) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
923 side = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
924 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
925 TileIndex start = TileVirtXY(_thd.selstart.x, _thd.selstart.y); |
7970
c49c1607b294
(svn r11526) -Codechange: Rename the function delta fitting to the naming style
skidd13 <skidd13@openttd.org>
parents:
7954
diff
changeset
|
926 side = Delta(Delta(TileX(start), TileX(ti->tile)), Delta(TileY(start), TileY(ti->tile))); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
927 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
928 |
8224
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
929 DrawAutorailSelection(ti, _autorail_type[dir][side]); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
930 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
931 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
932 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
933 |
6423
72ac8bfaa32f
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas <belugas@openttd.org>
parents:
6248
diff
changeset
|
934 /* Check if it's inside the outer area? */ |
8743
d6d6bbb8da9c
(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 <rubidium@openttd.org>
parents:
8585
diff
changeset
|
935 if (!is_redsq && _thd.outersize.x && |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
936 _thd.size.x < _thd.size.x + _thd.outersize.x && |
7954
38bb7c45688f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13 <skidd13@openttd.org>
parents:
7951
diff
changeset
|
937 IsInsideBS(ti->x, _thd.pos.x + _thd.offs.x, _thd.size.x + _thd.outersize.x) && |
38bb7c45688f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13 <skidd13@openttd.org>
parents:
7951
diff
changeset
|
938 IsInsideBS(ti->y, _thd.pos.y + _thd.offs.y, _thd.size.y + _thd.outersize.y)) { |
6423
72ac8bfaa32f
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas <belugas@openttd.org>
parents:
6248
diff
changeset
|
939 /* Draw a blue rect. */ |
7679
9e222b8c9065
(svn r11210) -Codechange: unify the way that selection sprites are drawn. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7659
diff
changeset
|
940 DrawTileSelectionRect(ti, PALETTE_SEL_TILE_BLUE); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
941 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
942 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
943 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
944 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6117
diff
changeset
|
945 static void ViewportAddLandscape() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
946 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
947 int x, y, width, height; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
948 TileInfo ti; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
949 bool direction; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
950 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
951 _cur_ti = &ti; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
952 |
6423
72ac8bfaa32f
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas <belugas@openttd.org>
parents:
6248
diff
changeset
|
953 /* Transform into tile coordinates and round to closest full tile */ |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
954 x = ((_vd.dpi.top >> 1) - (_vd.dpi.left >> 2)) & ~0xF; |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
955 y = ((_vd.dpi.top >> 1) + (_vd.dpi.left >> 2) - 0x10) & ~0xF; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
956 |
6423
72ac8bfaa32f
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas <belugas@openttd.org>
parents:
6248
diff
changeset
|
957 /* determine size of area */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
958 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
959 Point pt = RemapCoords(x, y, 241); |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
960 width = (_vd.dpi.left + _vd.dpi.width - pt.x + 95) >> 6; |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
961 height = (_vd.dpi.top + _vd.dpi.height - pt.y) >> 5 << 1; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
962 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
963 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
964 assert(width > 0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
965 assert(height > 0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
966 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
967 direction = false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
968 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
969 do { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
970 int width_cur = width; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
971 int x_cur = x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
972 int y_cur = y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
973 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
974 do { |
10855
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
975 TileType tt = MP_VOID; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
976 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
977 ti.x = x_cur; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
978 ti.y = y_cur; |
10855
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
979 |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
980 ti.z = 0; |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
981 |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
982 ti.tileh = SLOPE_FLAT; |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
983 ti.tile = INVALID_TILE; |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
984 |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
985 if (0 <= x_cur && x_cur < (int)MapMaxX() * TILE_SIZE && |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
986 0 <= y_cur && y_cur < (int)MapMaxY() * TILE_SIZE) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
987 TileIndex tile = TileVirtXY(x_cur, y_cur); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
988 |
10855
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
989 if (!_settings_game.construction.freeform_edges || (TileX(tile) != 0 && TileY(tile) != 0)) { |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
990 if (x_cur == ((int)MapMaxX() - 1) * TILE_SIZE || y_cur == ((int)MapMaxY() - 1) * TILE_SIZE) { |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
991 uint maxh = max<uint>(TileHeight(tile), 1); |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
992 for (uint h = 0; h < maxh; h++) { |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
993 DrawGroundSpriteAt(SPR_SHADOW_CELL, PAL_NONE, ti.x, ti.y, h * TILE_HEIGHT); |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
994 } |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
995 } |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
996 |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
997 ti.tile = tile; |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
998 ti.tileh = GetTileSlope(tile, &ti.z); |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
999 tt = GetTileType(tile); |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
1000 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1001 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1002 |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1003 _vd.foundation_part = FOUNDATION_PART_NONE; |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1004 _vd.foundation[0] = -1; |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1005 _vd.foundation[1] = -1; |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1006 _vd.last_foundation_child[0] = NULL; |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1007 _vd.last_foundation_child[1] = NULL; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1008 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1009 _tile_type_procs[tt]->draw_tile_proc(&ti); |
10855
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
1010 |
10864
e10213483b43
(svn r15199) -Fix (r15190): The south point of the south-most tile wasn't highlighted during terraforming.
Yexo <Yexo@openttd.org>
parents:
10855
diff
changeset
|
1011 if ((x_cur == (int)MapMaxX() * TILE_SIZE && IsInsideMM(y_cur, 0, MapMaxY() * TILE_SIZE + 1)) || |
e10213483b43
(svn r15199) -Fix (r15190): The south point of the south-most tile wasn't highlighted during terraforming.
Yexo <Yexo@openttd.org>
parents:
10855
diff
changeset
|
1012 (y_cur == (int)MapMaxY() * TILE_SIZE && IsInsideMM(x_cur, 0, MapMaxX() * TILE_SIZE + 1))) { |
10855
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
1013 TileIndex tile = TileVirtXY(x_cur, y_cur); |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
1014 ti.tile = tile; |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
1015 ti.tileh = GetTileSlope(tile, &ti.z); |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
1016 tt = GetTileType(tile); |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
1017 } |
10815
8966b7fa7a24
(svn r15150) -Fix: Don't highlight tiles outside the visible map.
Yexo <Yexo@openttd.org>
parents:
10732
diff
changeset
|
1018 if (ti.tile != INVALID_TILE) DrawTileSelection(&ti); |
10855
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
1019 |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
1020 y_cur += 0x10; |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10816
diff
changeset
|
1021 x_cur -= 0x10; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1022 } while (--width_cur); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1023 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1024 if ((direction ^= 1) != 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1025 y += 0x10; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1026 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1027 x += 0x10; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1028 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1029 } while (--height); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1030 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1031 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1032 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1033 static void ViewportAddTownNames(DrawPixelInfo *dpi) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1034 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1035 Town *t; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1036 int left, top, right, bottom; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1037 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7923
diff
changeset
|
1038 if (!HasBit(_display_opt, DO_SHOW_TOWN_NAMES) || _game_mode == GM_MENU) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1039 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1040 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1041 left = dpi->left; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1042 top = dpi->top; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1043 right = left + dpi->width; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1044 bottom = top + dpi->height; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1045 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1046 switch (dpi->zoom) { |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1047 case ZOOM_LVL_NORMAL: |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1048 FOR_ALL_TOWNS(t) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1049 if (bottom > t->sign.top && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1050 top < t->sign.top + 12 && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1051 right > t->sign.left && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1052 left < t->sign.left + t->sign.width_1) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1053 AddStringToDraw(t->sign.left + 1, t->sign.top + 1, |
9413
512ea64da840
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents:
9410
diff
changeset
|
1054 _settings_client.gui.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL, |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1055 t->index, t->population); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1056 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1057 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1058 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1059 |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1060 case ZOOM_LVL_OUT_2X: |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1061 right += 2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1062 bottom += 2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1063 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1064 FOR_ALL_TOWNS(t) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1065 if (bottom > t->sign.top && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1066 top < t->sign.top + 24 && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1067 right > t->sign.left && |
8969
01cc3ee6ecb1
(svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium <rubidium@openttd.org>
parents:
8957
diff
changeset
|
1068 left < t->sign.left + t->sign.width_1 * 2) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1069 AddStringToDraw(t->sign.left + 1, t->sign.top + 1, |
9413
512ea64da840
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents:
9410
diff
changeset
|
1070 _settings_client.gui.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL, |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1071 t->index, t->population); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1072 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1073 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1074 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1075 |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1076 case ZOOM_LVL_OUT_4X: |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1077 case ZOOM_LVL_OUT_8X: |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1078 right += ScaleByZoom(1, dpi->zoom); |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1079 bottom += ScaleByZoom(1, dpi->zoom) + 1; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1080 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1081 FOR_ALL_TOWNS(t) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1082 if (bottom > t->sign.top && |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1083 top < t->sign.top + ScaleByZoom(12, dpi->zoom) && |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1084 right > t->sign.left && |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1085 left < t->sign.left + ScaleByZoom(t->sign.width_2, dpi->zoom)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1086 AddStringToDraw(t->sign.left + 5, t->sign.top + 1, STR_TOWN_LABEL_TINY_BLACK, t->index, 0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1087 AddStringToDraw(t->sign.left + 1, t->sign.top - 3, STR_TOWN_LABEL_TINY_WHITE, t->index, 0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1088 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1089 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1090 break; |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1091 |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1092 default: NOT_REACHED(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1093 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1094 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1095 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1096 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1097 static void AddStation(const Station *st, StringID str, uint16 width) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1098 { |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10196
diff
changeset
|
1099 AddStringToDraw(st->sign.left + 1, st->sign.top + 1, str, st->index, st->facilities, (st->owner == OWNER_NONE || st->facilities == 0) ? 0xE : _company_colours[st->owner], width); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1100 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1101 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1102 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1103 static void ViewportAddStationNames(DrawPixelInfo *dpi) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1104 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1105 int left, top, right, bottom; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1106 const Station *st; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1107 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7923
diff
changeset
|
1108 if (!HasBit(_display_opt, DO_SHOW_STATION_NAMES) || _game_mode == GM_MENU) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1109 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1110 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1111 left = dpi->left; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1112 top = dpi->top; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1113 right = left + dpi->width; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1114 bottom = top + dpi->height; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1115 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1116 switch (dpi->zoom) { |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1117 case ZOOM_LVL_NORMAL: |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1118 FOR_ALL_STATIONS(st) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1119 if (bottom > st->sign.top && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1120 top < st->sign.top + 12 && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1121 right > st->sign.left && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1122 left < st->sign.left + st->sign.width_1) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1123 AddStation(st, STR_305C_0, st->sign.width_1); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1124 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1125 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1126 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1127 |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1128 case ZOOM_LVL_OUT_2X: |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1129 right += 2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1130 bottom += 2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1131 FOR_ALL_STATIONS(st) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1132 if (bottom > st->sign.top && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1133 top < st->sign.top + 24 && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1134 right > st->sign.left && |
8969
01cc3ee6ecb1
(svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium <rubidium@openttd.org>
parents:
8957
diff
changeset
|
1135 left < st->sign.left + st->sign.width_1 * 2) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1136 AddStation(st, STR_305C_0, st->sign.width_1); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1137 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1138 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1139 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1140 |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1141 case ZOOM_LVL_OUT_4X: |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1142 case ZOOM_LVL_OUT_8X: |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1143 right += ScaleByZoom(1, dpi->zoom); |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1144 bottom += ScaleByZoom(1, dpi->zoom) + 1; |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1145 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1146 FOR_ALL_STATIONS(st) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1147 if (bottom > st->sign.top && |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1148 top < st->sign.top + ScaleByZoom(12, dpi->zoom) && |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1149 right > st->sign.left && |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1150 left < st->sign.left + ScaleByZoom(st->sign.width_2, dpi->zoom)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1151 AddStation(st, STR_STATION_SIGN_TINY, st->sign.width_2 | 0x8000); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1152 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1153 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1154 break; |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1155 |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1156 default: NOT_REACHED(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1157 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1158 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1159 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1160 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1161 static void AddSign(const Sign *si, StringID str, uint16 width) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1162 { |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10196
diff
changeset
|
1163 AddStringToDraw(si->sign.left + 1, si->sign.top + 1, str, si->index, 0, (si->owner == OWNER_NONE) ? 14 : _company_colours[si->owner], width); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1164 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1165 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1166 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1167 static void ViewportAddSigns(DrawPixelInfo *dpi) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1168 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1169 const Sign *si; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1170 int left, top, right, bottom; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1171 |
8806
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8798
diff
changeset
|
1172 /* Signs are turned off or are invisible */ |
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8798
diff
changeset
|
1173 if (!HasBit(_display_opt, DO_SHOW_SIGNS) || IsInvisibilitySet(TO_SIGNS)) return; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1174 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1175 left = dpi->left; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1176 top = dpi->top; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1177 right = left + dpi->width; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1178 bottom = top + dpi->height; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1179 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1180 switch (dpi->zoom) { |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1181 case ZOOM_LVL_NORMAL: |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1182 FOR_ALL_SIGNS(si) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1183 if (bottom > si->sign.top && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1184 top < si->sign.top + 12 && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1185 right > si->sign.left && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1186 left < si->sign.left + si->sign.width_1) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1187 AddSign(si, STR_2806, si->sign.width_1); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1188 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1189 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1190 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1191 |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1192 case ZOOM_LVL_OUT_2X: |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1193 right += 2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1194 bottom += 2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1195 FOR_ALL_SIGNS(si) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1196 if (bottom > si->sign.top && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1197 top < si->sign.top + 24 && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1198 right > si->sign.left && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1199 left < si->sign.left + si->sign.width_1 * 2) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1200 AddSign(si, STR_2806, si->sign.width_1); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1201 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1202 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1203 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1204 |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1205 case ZOOM_LVL_OUT_4X: |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1206 case ZOOM_LVL_OUT_8X: |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1207 right += ScaleByZoom(1, dpi->zoom); |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1208 bottom += ScaleByZoom(1, dpi->zoom) + 1; |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1209 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1210 FOR_ALL_SIGNS(si) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1211 if (bottom > si->sign.top && |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1212 top < si->sign.top + ScaleByZoom(12, dpi->zoom) && |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1213 right > si->sign.left && |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1214 left < si->sign.left + ScaleByZoom(si->sign.width_2, dpi->zoom)) { |
7951
f6ffbf027b5a
(svn r11507) -Fix [FS#1463]: signs totally illegible when transparant signs is turned on and zoomed out more than one level.
rubidium <rubidium@openttd.org>
parents:
7931
diff
changeset
|
1215 AddSign(si, IsTransparencySet(TO_SIGNS) ? STR_2002_WHITE : STR_2002, si->sign.width_2 | 0x8000); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1216 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1217 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1218 break; |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1219 |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1220 default: NOT_REACHED(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1221 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1222 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1223 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1224 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1225 static void AddWaypoint(const Waypoint *wp, StringID str, uint16 width) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1226 { |
8946
402107c0562f
(svn r12734) -Codechange: use a vector instead of allocating memory in a big byte array for StringSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8925
diff
changeset
|
1227 AddStringToDraw(wp->sign.left + 1, wp->sign.top + 1, str, wp->index, 0, (wp->deleted ? 0xE : 11), width); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1228 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1229 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1230 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1231 static void ViewportAddWaypoints(DrawPixelInfo *dpi) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1232 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1233 const Waypoint *wp; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1234 int left, top, right, bottom; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1235 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7923
diff
changeset
|
1236 if (!HasBit(_display_opt, DO_WAYPOINTS)) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1237 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1238 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1239 left = dpi->left; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1240 top = dpi->top; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1241 right = left + dpi->width; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1242 bottom = top + dpi->height; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1243 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1244 switch (dpi->zoom) { |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1245 case ZOOM_LVL_NORMAL: |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1246 FOR_ALL_WAYPOINTS(wp) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1247 if (bottom > wp->sign.top && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1248 top < wp->sign.top + 12 && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1249 right > wp->sign.left && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1250 left < wp->sign.left + wp->sign.width_1) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1251 AddWaypoint(wp, STR_WAYPOINT_VIEWPORT, wp->sign.width_1); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1252 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1253 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1254 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1255 |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1256 case ZOOM_LVL_OUT_2X: |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1257 right += 2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1258 bottom += 2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1259 FOR_ALL_WAYPOINTS(wp) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1260 if (bottom > wp->sign.top && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1261 top < wp->sign.top + 24 && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1262 right > wp->sign.left && |
8969
01cc3ee6ecb1
(svn r12761) -Codechange: lots of minor whitespace coding style fixes around operators.
rubidium <rubidium@openttd.org>
parents:
8957
diff
changeset
|
1263 left < wp->sign.left + wp->sign.width_1 * 2) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1264 AddWaypoint(wp, STR_WAYPOINT_VIEWPORT, wp->sign.width_1); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1265 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1266 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1267 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1268 |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1269 case ZOOM_LVL_OUT_4X: |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1270 case ZOOM_LVL_OUT_8X: |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1271 right += ScaleByZoom(1, dpi->zoom); |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1272 bottom += ScaleByZoom(1, dpi->zoom) + 1; |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1273 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1274 FOR_ALL_WAYPOINTS(wp) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1275 if (bottom > wp->sign.top && |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1276 top < wp->sign.top + ScaleByZoom(12, dpi->zoom) && |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1277 right > wp->sign.left && |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1278 left < wp->sign.left + ScaleByZoom(wp->sign.width_2, dpi->zoom)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1279 AddWaypoint(wp, STR_WAYPOINT_VIEWPORT_TINY, wp->sign.width_2 | 0x8000); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1280 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1281 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1282 break; |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1283 |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1284 default: NOT_REACHED(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1285 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1286 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1287 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1288 void UpdateViewportSignPos(ViewportSign *sign, int left, int top, StringID str) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1289 { |
10055
598f63d43920
(svn r14221) -Fix: signs (town name, station name, ...) could be too long for 8bit width in pixels
smatz <smatz@openttd.org>
parents:
9982
diff
changeset
|
1290 char buffer[256]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1291 uint w; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1292 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1293 sign->top = top; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1294 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1295 GetString(buffer, str, lastof(buffer)); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1296 w = GetStringBoundingBox(buffer).width + 3; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1297 sign->width_1 = w; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1298 sign->left = left - w / 2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1299 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1300 /* zoomed out version */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1301 _cur_fontsize = FS_SMALL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1302 w = GetStringBoundingBox(buffer).width + 3; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1303 _cur_fontsize = FS_NORMAL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1304 sign->width_2 = w; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1305 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1306 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1307 |
8947
20e58270e32d
(svn r12735) -Codechange: use a vector instead of allocating memory in a byte array for TileSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8946
diff
changeset
|
1308 static void ViewportDrawTileSprites(const TileSpriteToDrawVector *tstdv) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1309 { |
8949
36b54e6eec1e
(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 <peter1138@openttd.org>
parents:
8948
diff
changeset
|
1310 const TileSpriteToDraw *tsend = tstdv->End(); |
36b54e6eec1e
(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 <peter1138@openttd.org>
parents:
8948
diff
changeset
|
1311 for (const TileSpriteToDraw *ts = tstdv->Begin(); ts != tsend; ++ts) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1312 Point pt = RemapCoords(ts->x, ts->y, ts->z); |
7681
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
1313 DrawSprite(ts->image, ts->pal, pt.x, pt.y, ts->sub); |
8947
20e58270e32d
(svn r12735) -Codechange: use a vector instead of allocating memory in a byte array for TileSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8946
diff
changeset
|
1314 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1315 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1316 |
10233
63a58f4b2607
(svn r14461) -Document: add some doxygen comments (Albert)
rubidium <rubidium@openttd.org>
parents:
10216
diff
changeset
|
1317 /** Sort parent sprites pointer array */ |
8951
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
1318 static void ViewportSortParentSprites(ParentSpriteToSortVector *psdv) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1319 { |
8951
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
1320 ParentSpriteToDraw **psdvend = psdv->End(); |
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
1321 ParentSpriteToDraw **psd = psdv->Begin(); |
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
1322 while (psd != psdvend) { |
8948
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1323 ParentSpriteToDraw *ps = *psd; |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1324 |
8950
1e8449e9c1ec
(svn r12738) -Fix (r12736): some sprites could be left unsorted
smatz <smatz@openttd.org>
parents:
8949
diff
changeset
|
1325 if (ps->comparison_done) { |
1e8449e9c1ec
(svn r12738) -Fix (r12736): some sprites could be left unsorted
smatz <smatz@openttd.org>
parents:
8949
diff
changeset
|
1326 psd++; |
1e8449e9c1ec
(svn r12738) -Fix (r12736): some sprites could be left unsorted
smatz <smatz@openttd.org>
parents:
8949
diff
changeset
|
1327 continue; |
1e8449e9c1ec
(svn r12738) -Fix (r12736): some sprites could be left unsorted
smatz <smatz@openttd.org>
parents:
8949
diff
changeset
|
1328 } |
8948
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1329 |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1330 ps->comparison_done = true; |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1331 |
8951
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
1332 for (ParentSpriteToDraw **psd2 = psd + 1; psd2 != psdvend; psd2++) { |
8948
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1333 ParentSpriteToDraw *ps2 = *psd2; |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1334 |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1335 if (ps2->comparison_done) continue; |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1336 |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1337 /* Decide which comparator to use, based on whether the bounding |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1338 * boxes overlap |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1339 */ |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1340 if (ps->xmax >= ps2->xmin && ps->xmin <= ps2->xmax && // overlap in X? |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1341 ps->ymax >= ps2->ymin && ps->ymin <= ps2->ymax && // overlap in Y? |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1342 ps->zmax >= ps2->zmin && ps->zmin <= ps2->zmax) { // overlap in Z? |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1343 /* Use X+Y+Z as the sorting order, so sprites closer to the bottom of |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1344 * the screen and with higher Z elevation, are drawn in front. |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1345 * Here X,Y,Z are the coordinates of the "center of mass" of the sprite, |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1346 * i.e. X=(left+right)/2, etc. |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1347 * However, since we only care about order, don't actually divide / 2 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1348 */ |
8948
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1349 if (ps->xmin + ps->xmax + ps->ymin + ps->ymax + ps->zmin + ps->zmax <= |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1350 ps2->xmin + ps2->xmax + ps2->ymin + ps2->ymax + ps2->zmin + ps2->zmax) { |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1351 continue; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1352 } |
8948
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1353 } else { |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1354 /* We only change the order, if it is definite. |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1355 * I.e. every single order of X, Y, Z says ps2 is behind ps or they overlap. |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1356 * That is: If one partial order says ps behind ps2, do not change the order. |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1357 */ |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1358 if (ps->xmax < ps2->xmin || |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1359 ps->ymax < ps2->ymin || |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1360 ps->zmax < ps2->zmin) { |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1361 continue; |
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1362 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1363 } |
8948
6b08c7cd7921
(svn r12736) -Codechange: a (small) touch of coding style in viewport.cpp.
rubidium <rubidium@openttd.org>
parents:
8947
diff
changeset
|
1364 |
10196
d44af18ae6c7
(svn r14409) -Codechange: Simplify a loop and correct a comment.
frosch <frosch@openttd.org>
parents:
10056
diff
changeset
|
1365 /* Move ps2 in front of ps */ |
d44af18ae6c7
(svn r14409) -Codechange: Simplify a loop and correct a comment.
frosch <frosch@openttd.org>
parents:
10056
diff
changeset
|
1366 ParentSpriteToDraw *temp = ps2; |
d44af18ae6c7
(svn r14409) -Codechange: Simplify a loop and correct a comment.
frosch <frosch@openttd.org>
parents:
10056
diff
changeset
|
1367 for (ParentSpriteToDraw **psd3 = psd2; psd3 > psd; psd3--) { |
d44af18ae6c7
(svn r14409) -Codechange: Simplify a loop and correct a comment.
frosch <frosch@openttd.org>
parents:
10056
diff
changeset
|
1368 *psd3 = *(psd3 - 1); |
d44af18ae6c7
(svn r14409) -Codechange: Simplify a loop and correct a comment.
frosch <frosch@openttd.org>
parents:
10056
diff
changeset
|
1369 } |
d44af18ae6c7
(svn r14409) -Codechange: Simplify a loop and correct a comment.
frosch <frosch@openttd.org>
parents:
10056
diff
changeset
|
1370 *psd = temp; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1371 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1372 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1373 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1374 |
8952
2a7a810979e0
(svn r12740) -Codechange: use a vector instead of allocating memory in a byte array for ChildScreenSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8951
diff
changeset
|
1375 static void ViewportDrawParentSprites(const ParentSpriteToSortVector *psd, const ChildScreenSpriteToDrawVector *csstdv) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1376 { |
8951
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
1377 const ParentSpriteToDraw * const *psd_end = psd->End(); |
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
1378 for (const ParentSpriteToDraw * const *it = psd->Begin(); it != psd_end; it++) { |
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
1379 const ParentSpriteToDraw *ps = *it; |
7681
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
1380 if (ps->image != SPR_EMPTY_BOUNDING_BOX) DrawSprite(ps->image, ps->pal, ps->x, ps->y, ps->sub); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1381 |
9534
564d5fd5a247
(svn r13538) -Fix (r12740)[FS#2087]: ChildSprites of foundations are not necessarily consecutive.
frosch <frosch@openttd.org>
parents:
9510
diff
changeset
|
1382 int child_idx = ps->first_child; |
564d5fd5a247
(svn r13538) -Fix (r12740)[FS#2087]: ChildSprites of foundations are not necessarily consecutive.
frosch <frosch@openttd.org>
parents:
9510
diff
changeset
|
1383 while (child_idx >= 0) { |
564d5fd5a247
(svn r13538) -Fix (r12740)[FS#2087]: ChildSprites of foundations are not necessarily consecutive.
frosch <frosch@openttd.org>
parents:
9510
diff
changeset
|
1384 const ChildScreenSpriteToDraw *cs = csstdv->Get(child_idx); |
564d5fd5a247
(svn r13538) -Fix (r12740)[FS#2087]: ChildSprites of foundations are not necessarily consecutive.
frosch <frosch@openttd.org>
parents:
9510
diff
changeset
|
1385 child_idx = cs->next; |
7681
7ab16079f91b
(svn r11212) -Codechange: add support for drawing parts of sprites. Patch by frosch.
rubidium <rubidium@openttd.org>
parents:
7679
diff
changeset
|
1386 DrawSprite(cs->image, cs->pal, ps->left + cs->x, ps->top + cs->y, cs->sub); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1387 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1388 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1389 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1390 |
7643
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
1391 /** |
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
1392 * Draws the bounding boxes of all ParentSprites |
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
1393 * @param psd Array of ParentSprites |
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
1394 */ |
8951
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
1395 static void ViewportDrawBoundingBoxes(const ParentSpriteToSortVector *psd) |
7643
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
1396 { |
8951
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
1397 const ParentSpriteToDraw * const *psd_end = psd->End(); |
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
1398 for (const ParentSpriteToDraw * const *it = psd->Begin(); it != psd_end; it++) { |
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
1399 const ParentSpriteToDraw *ps = *it; |
7643
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
1400 Point pt1 = RemapCoords(ps->xmax + 1, ps->ymax + 1, ps->zmax + 1); // top front corner |
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
1401 Point pt2 = RemapCoords(ps->xmin , ps->ymax + 1, ps->zmax + 1); // top left corner |
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
1402 Point pt3 = RemapCoords(ps->xmax + 1, ps->ymin , ps->zmax + 1); // top right corner |
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
1403 Point pt4 = RemapCoords(ps->xmax + 1, ps->ymax + 1, ps->zmin ); // bottom front corner |
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
1404 |
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
1405 DrawBox( pt1.x, pt1.y, |
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
1406 pt2.x - pt1.x, pt2.y - pt1.y, |
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
1407 pt3.x - pt1.x, pt3.y - pt1.y, |
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
1408 pt4.x - pt1.x, pt4.y - pt1.y); |
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
1409 } |
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
1410 } |
5dadd473fda6
(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 <rubidium@openttd.org>
parents:
7617
diff
changeset
|
1411 |
8946
402107c0562f
(svn r12734) -Codechange: use a vector instead of allocating memory in a big byte array for StringSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8925
diff
changeset
|
1412 static void ViewportDrawStrings(DrawPixelInfo *dpi, const StringSpriteToDrawVector *sstdv) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1413 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1414 DrawPixelInfo dp; |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1415 ZoomLevel zoom; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1416 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1417 _cur_dpi = &dp; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1418 dp = *dpi; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1419 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1420 zoom = dp.zoom; |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1421 dp.zoom = ZOOM_LVL_NORMAL; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1422 |
6654
860f3e5f70ec
(svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight <truelight@openttd.org>
parents:
6653
diff
changeset
|
1423 dp.left = UnScaleByZoom(dp.left, zoom); |
860f3e5f70ec
(svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight <truelight@openttd.org>
parents:
6653
diff
changeset
|
1424 dp.top = UnScaleByZoom(dp.top, zoom); |
860f3e5f70ec
(svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight <truelight@openttd.org>
parents:
6653
diff
changeset
|
1425 dp.width = UnScaleByZoom(dp.width, zoom); |
860f3e5f70ec
(svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight <truelight@openttd.org>
parents:
6653
diff
changeset
|
1426 dp.height = UnScaleByZoom(dp.height, zoom); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1427 |
8949
36b54e6eec1e
(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 <peter1138@openttd.org>
parents:
8948
diff
changeset
|
1428 const StringSpriteToDraw *ssend = sstdv->End(); |
36b54e6eec1e
(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 <peter1138@openttd.org>
parents:
8948
diff
changeset
|
1429 for (const StringSpriteToDraw *ss = sstdv->Begin(); ss != ssend; ++ss) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1430 uint16 colour; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1431 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1432 if (ss->width != 0) { |
8806
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8798
diff
changeset
|
1433 /* Do not draw signs nor station names if they are set invisible */ |
8946
402107c0562f
(svn r12734) -Codechange: use a vector instead of allocating memory in a big byte array for StringSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8925
diff
changeset
|
1434 if (IsInvisibilitySet(TO_SIGNS) && ss->string != STR_2806) continue; |
8806
104bbcae351d
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents:
8798
diff
changeset
|
1435 |
6654
860f3e5f70ec
(svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight <truelight@openttd.org>
parents:
6653
diff
changeset
|
1436 int x = UnScaleByZoom(ss->x, zoom) - 1; |
860f3e5f70ec
(svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight <truelight@openttd.org>
parents:
6653
diff
changeset
|
1437 int y = UnScaleByZoom(ss->y, zoom) - 1; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1438 int bottom = y + 11; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1439 int w = ss->width; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1440 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1441 if (w & 0x8000) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1442 w &= ~0x8000; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1443 y--; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1444 bottom -= 6; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1445 w -= 3; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1446 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1447 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1448 /* Draw the rectangle if 'tranparent station signs' is off, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1449 * or if we are drawing a general text sign (STR_2806) */ |
7849
e6ee8bfd9045
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas <belugas@openttd.org>
parents:
7824
diff
changeset
|
1450 if (!IsTransparencySet(TO_SIGNS) || ss->string == STR_2806) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1451 DrawFrameRect( |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1452 x, y, x + w, bottom, ss->color, |
7849
e6ee8bfd9045
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas <belugas@openttd.org>
parents:
7824
diff
changeset
|
1453 IsTransparencySet(TO_SIGNS) ? FR_TRANSPARENT : FR_NONE |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1454 ); |
6427
2437ed7b277c
(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 <peter1138@openttd.org>
parents:
6423
diff
changeset
|
1455 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1456 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1457 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1458 SetDParam(0, ss->params[0]); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1459 SetDParam(1, ss->params[1]); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1460 /* if we didn't draw a rectangle, or if transparant building is on, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1461 * draw the text in the color the rectangle would have */ |
7849
e6ee8bfd9045
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas <belugas@openttd.org>
parents:
7824
diff
changeset
|
1462 if (IsTransparencySet(TO_SIGNS) && ss->string != STR_2806 && ss->width != 0) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1463 /* Real colors need the IS_PALETTE_COLOR flag |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1464 * otherwise colors from _string_colormap are assumed. */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1465 colour = _colour_gradient[ss->color][6] | IS_PALETTE_COLOR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1466 } else { |
7824
7ae5bda4e8dd
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents:
7769
diff
changeset
|
1467 colour = TC_BLACK; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1468 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1469 DrawString( |
6654
860f3e5f70ec
(svn r9885) -Fix r9846: some last bitshifts with zoom-levels that were forgotten
truelight <truelight@openttd.org>
parents:
6653
diff
changeset
|
1470 UnScaleByZoom(ss->x, zoom), UnScaleByZoom(ss->y, zoom) - (ss->width & 0x8000 ? 2 : 0), |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1471 ss->string, colour |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1472 ); |
8947
20e58270e32d
(svn r12735) -Codechange: use a vector instead of allocating memory in a byte array for TileSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8946
diff
changeset
|
1473 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1474 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1475 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1476 void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1477 { |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1478 DrawPixelInfo *old_dpi = _cur_dpi; |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1479 _cur_dpi = &_vd.dpi; |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1480 |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1481 _vd.dpi.zoom = vp->zoom; |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1482 int mask = ScaleByZoom(-1, vp->zoom); |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1483 |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1484 _vd.combine_sprites = 0; |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1485 |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1486 _vd.dpi.width = (right - left) & mask; |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1487 _vd.dpi.height = (bottom - top) & mask; |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1488 _vd.dpi.left = left & mask; |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1489 _vd.dpi.top = top & mask; |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1490 _vd.dpi.pitch = old_dpi->pitch; |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1491 _vd.last_child = NULL; |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1492 |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1493 int x = UnScaleByZoom(_vd.dpi.left - (vp->virtual_left & mask), vp->zoom) + vp->left; |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1494 int y = UnScaleByZoom(_vd.dpi.top - (vp->virtual_top & mask), vp->zoom) + vp->top; |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1495 |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1496 _vd.dpi.dst_ptr = BlitterFactoryBase::GetCurrentBlitter()->MoveTo(old_dpi->dst_ptr, x - old_dpi->left, y - old_dpi->top); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1497 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1498 ViewportAddLandscape(); |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1499 ViewportAddVehicles(&_vd.dpi); |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1500 |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1501 ViewportAddTownNames(&_vd.dpi); |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1502 ViewportAddStationNames(&_vd.dpi); |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1503 ViewportAddSigns(&_vd.dpi); |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1504 ViewportAddWaypoints(&_vd.dpi); |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1505 |
9847
cc5c11ce4280
(svn r13991) -Codechange: draw text effects after all other signs
smatz <smatz@openttd.org>
parents:
9781
diff
changeset
|
1506 DrawTextEffects(&_vd.dpi); |
cc5c11ce4280
(svn r13991) -Codechange: draw text effects after all other signs
smatz <smatz@openttd.org>
parents:
9781
diff
changeset
|
1507 |
9553
0069339d03bf
(svn r13573) -Codechange: Use smallvec class functions instead of class members
skidd13 <skidd13@openttd.org>
parents:
9534
diff
changeset
|
1508 if (_vd.tile_sprites_to_draw.Length() != 0) ViewportDrawTileSprites(&_vd.tile_sprites_to_draw); |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1509 |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1510 ParentSpriteToDraw *psd_end = _vd.parent_sprites_to_draw.End(); |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1511 for (ParentSpriteToDraw *it = _vd.parent_sprites_to_draw.Begin(); it != psd_end; it++) { |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1512 *_vd.parent_sprites_to_sort.Append() = it; |
8951
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
1513 } |
231bd4dd1f98
(svn r12739) -Codechange: use a vector instead of allocating memory in a byte array for ParentSpriteToDraw.
rubidium <rubidium@openttd.org>
parents:
8950
diff
changeset
|
1514 |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1515 ViewportSortParentSprites(&_vd.parent_sprites_to_sort); |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1516 ViewportDrawParentSprites(&_vd.parent_sprites_to_sort, &_vd.child_screen_sprites_to_draw); |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1517 |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1518 if (_draw_bounding_boxes) ViewportDrawBoundingBoxes(&_vd.parent_sprites_to_sort); |
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1519 |
9553
0069339d03bf
(svn r13573) -Codechange: Use smallvec class functions instead of class members
skidd13 <skidd13@openttd.org>
parents:
9534
diff
changeset
|
1520 if (_vd.string_sprites_to_draw.Length() != 0) ViewportDrawStrings(&_vd.dpi, &_vd.string_sprites_to_draw); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1521 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1522 _cur_dpi = old_dpi; |
8953
0f3c6c845c6f
(svn r12741) -Codechange: do not allocate the viewport drawer each time on the stack, but only once and reuse this.
rubidium <rubidium@openttd.org>
parents:
8952
diff
changeset
|
1523 |
9553
0069339d03bf
(svn r13573) -Codechange: Use smallvec class functions instead of class members
skidd13 <skidd13@openttd.org>
parents:
9534
diff
changeset
|
1524 _vd.string_sprites_to_draw.Clear(); |
0069339d03bf
(svn r13573) -Codechange: Use smallvec class functions instead of class members
skidd13 <skidd13@openttd.org>
parents:
9534
diff
changeset
|
1525 _vd.tile_sprites_to_draw.Clear(); |
0069339d03bf
(svn r13573) -Codechange: Use smallvec class functions instead of class members
skidd13 <skidd13@openttd.org>
parents:
9534
diff
changeset
|
1526 _vd.parent_sprites_to_draw.Clear(); |
0069339d03bf
(svn r13573) -Codechange: Use smallvec class functions instead of class members
skidd13 <skidd13@openttd.org>
parents:
9534
diff
changeset
|
1527 _vd.parent_sprites_to_sort.Clear(); |
0069339d03bf
(svn r13573) -Codechange: Use smallvec class functions instead of class members
skidd13 <skidd13@openttd.org>
parents:
9534
diff
changeset
|
1528 _vd.child_screen_sprites_to_draw.Clear(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1529 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1530 |
6423
72ac8bfaa32f
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas <belugas@openttd.org>
parents:
6248
diff
changeset
|
1531 /** Make sure we don't draw a too big area at a time. |
72ac8bfaa32f
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas <belugas@openttd.org>
parents:
6248
diff
changeset
|
1532 * If we do, the sprite memory will overflow. */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1533 static void ViewportDrawChk(const ViewPort *vp, int left, int top, int right, int bottom) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1534 { |
6626
f940341a80f0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents:
6624
diff
changeset
|
1535 if (ScaleByZoom(bottom - top, vp->zoom) * ScaleByZoom(right - left, vp->zoom) > 180000) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1536 if ((bottom - top) > (right - left)) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1537 int t = (top + bottom) >> 1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1538 ViewportDrawChk(vp, left, top, right, t); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1539 ViewportDrawChk(vp, left, t, right, bottom); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1540 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1541 int t = (left + right) >> 1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1542 ViewportDrawChk(vp, left, top, t, bottom); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1543 ViewportDrawChk(vp, t, top, right, bottom); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1544 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1545 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1546 ViewportDoDraw(vp, |
6626
f940341a80f0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents:
6624
diff
changeset
|
1547 ScaleByZoom(left - vp->left, vp->zoom) + vp->virtual_left, |
f940341a80f0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents:
6624
diff
changeset
|
1548 ScaleByZoom(top - vp->top, vp->zoom) + vp->virtual_top, |
f940341a80f0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents:
6624
diff
changeset
|
1549 ScaleByZoom(right - vp->left, vp->zoom) + vp->virtual_left, |
f940341a80f0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight <truelight@openttd.org>
parents:
6624
diff
changeset
|
1550 ScaleByZoom(bottom - vp->top, vp->zoom) + vp->virtual_top |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1551 ); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1552 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1553 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1554 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1555 static inline void ViewportDraw(const ViewPort *vp, int left, int top, int right, int bottom) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1556 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1557 if (right <= vp->left || bottom <= vp->top) return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1558 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1559 if (left >= vp->left + vp->width) return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1560 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1561 if (left < vp->left) left = vp->left; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1562 if (right > vp->left + vp->width) right = vp->left + vp->width; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1563 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1564 if (top >= vp->top + vp->height) return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1565 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1566 if (top < vp->top) top = vp->top; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1567 if (bottom > vp->top + vp->height) bottom = vp->top + vp->height; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1568 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1569 ViewportDrawChk(vp, left, top, right, bottom); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1570 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1571 |
10238
12805d675e85
(svn r14466) -Doc: remove some obsolete parameters, fix a few parameter names in comments and add a little more doxygen documentation.
rubidium <rubidium@openttd.org>
parents:
10233
diff
changeset
|
1572 /** |
12805d675e85
(svn r14466) -Doc: remove some obsolete parameters, fix a few parameter names in comments and add a little more doxygen documentation.
rubidium <rubidium@openttd.org>
parents:
10233
diff
changeset
|
1573 * Draw the viewport of this window. |
12805d675e85
(svn r14466) -Doc: remove some obsolete parameters, fix a few parameter names in comments and add a little more doxygen documentation.
rubidium <rubidium@openttd.org>
parents:
10233
diff
changeset
|
1574 */ |
9273
72a6d2e60834
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents:
9244
diff
changeset
|
1575 void Window::DrawViewport() const |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1576 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1577 DrawPixelInfo *dpi = _cur_dpi; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1578 |
9273
72a6d2e60834
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents:
9244
diff
changeset
|
1579 dpi->left += this->left; |
72a6d2e60834
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents:
9244
diff
changeset
|
1580 dpi->top += this->top; |
72a6d2e60834
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents:
9244
diff
changeset
|
1581 |
72a6d2e60834
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents:
9244
diff
changeset
|
1582 ViewportDraw(this->viewport, dpi->left, dpi->top, dpi->left + dpi->width, dpi->top + dpi->height); |
72a6d2e60834
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents:
9244
diff
changeset
|
1583 |
72a6d2e60834
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents:
9244
diff
changeset
|
1584 dpi->left -= this->left; |
72a6d2e60834
(svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents:
9244
diff
changeset
|
1585 dpi->top -= this->top; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1586 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1587 |
7069
6de5150e902f
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138 <peter1138@openttd.org>
parents:
7056
diff
changeset
|
1588 static inline void ClampViewportToMap(const ViewPort *vp, int &x, int &y) |
6de5150e902f
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138 <peter1138@openttd.org>
parents:
7056
diff
changeset
|
1589 { |
6de5150e902f
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138 <peter1138@openttd.org>
parents:
7056
diff
changeset
|
1590 /* Centre of the viewport is hot spot */ |
6de5150e902f
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138 <peter1138@openttd.org>
parents:
7056
diff
changeset
|
1591 x += vp->virtual_width / 2; |
6de5150e902f
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138 <peter1138@openttd.org>
parents:
7056
diff
changeset
|
1592 y += vp->virtual_height / 2; |
6de5150e902f
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138 <peter1138@openttd.org>
parents:
7056
diff
changeset
|
1593 |
6de5150e902f
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138 <peter1138@openttd.org>
parents:
7056
diff
changeset
|
1594 /* Convert viewport coordinates to map coordinates |
6de5150e902f
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138 <peter1138@openttd.org>
parents:
7056
diff
changeset
|
1595 * Calculation is scaled by 4 to avoid rounding errors */ |
6de5150e902f
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138 <peter1138@openttd.org>
parents:
7056
diff
changeset
|
1596 int vx = -x + y * 2; |
6de5150e902f
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138 <peter1138@openttd.org>
parents:
7056
diff
changeset
|
1597 int vy = x + y * 2; |
6de5150e902f
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138 <peter1138@openttd.org>
parents:
7056
diff
changeset
|
1598 |
6de5150e902f
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138 <peter1138@openttd.org>
parents:
7056
diff
changeset
|
1599 /* clamp to size of map */ |
7922
ff1975ced735
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13 <skidd13@openttd.org>
parents:
7918
diff
changeset
|
1600 vx = Clamp(vx, 0, MapMaxX() * TILE_SIZE * 4); |
ff1975ced735
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13 <skidd13@openttd.org>
parents:
7918
diff
changeset
|
1601 vy = Clamp(vy, 0, MapMaxY() * TILE_SIZE * 4); |
7069
6de5150e902f
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138 <peter1138@openttd.org>
parents:
7056
diff
changeset
|
1602 |
6de5150e902f
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138 <peter1138@openttd.org>
parents:
7056
diff
changeset
|
1603 /* Convert map coordinates to viewport coordinates */ |
6de5150e902f
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138 <peter1138@openttd.org>
parents:
7056
diff
changeset
|
1604 x = (-vx + vy) / 2; |
6de5150e902f
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138 <peter1138@openttd.org>
parents:
7056
diff
changeset
|
1605 y = ( vx + vy) / 4; |
6de5150e902f
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138 <peter1138@openttd.org>
parents:
7056
diff
changeset
|
1606 |
6de5150e902f
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138 <peter1138@openttd.org>
parents:
7056
diff
changeset
|
1607 /* Remove centreing */ |
6de5150e902f
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138 <peter1138@openttd.org>
parents:
7056
diff
changeset
|
1608 x -= vp->virtual_width / 2; |
6de5150e902f
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138 <peter1138@openttd.org>
parents:
7056
diff
changeset
|
1609 y -= vp->virtual_height / 2; |
6de5150e902f
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138 <peter1138@openttd.org>
parents:
7056
diff
changeset
|
1610 } |
6de5150e902f
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138 <peter1138@openttd.org>
parents:
7056
diff
changeset
|
1611 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1612 void UpdateViewportPosition(Window *w) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1613 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1614 const ViewPort *vp = w->viewport; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1615 |
9184
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
1616 if (w->viewport->follow_vehicle != INVALID_VEHICLE) { |
10647
592ae9307430
(svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents:
10645
diff
changeset
|
1617 const Vehicle *veh = GetVehicle(w->viewport->follow_vehicle); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1618 Point pt = MapXYZToViewport(vp, veh->x_pos, veh->y_pos, veh->z_pos); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1619 |
10645
d20b89e45634
(svn r14947) -Fix [FS#2519]: vehicle following did not update the location from where to smooth scroll, thus any new viewport center would smooth scroll from the location where you were just before you started following the vehicle
rubidium <rubidium@openttd.org>
parents:
10642
diff
changeset
|
1620 w->viewport->scrollpos_x = pt.x; |
d20b89e45634
(svn r14947) -Fix [FS#2519]: vehicle following did not update the location from where to smooth scroll, thus any new viewport center would smooth scroll from the location where you were just before you started following the vehicle
rubidium <rubidium@openttd.org>
parents:
10642
diff
changeset
|
1621 w->viewport->scrollpos_y = pt.y; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1622 SetViewportPosition(w, pt.x, pt.y); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1623 } else { |
7069
6de5150e902f
(svn r10334) -Fix [FS#937]: with smooth scrolling enabled, the viewport destination was not clamped to the map
peter1138 <peter1138@openttd.org>
parents:
7056
diff
changeset
|
1624 /* Ensure the destination location is within the map */ |
9184
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
1625 ClampViewportToMap(vp, w->viewport->dest_scrollpos_x, w->viewport->dest_scrollpos_y); |
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
1626 |
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
1627 int delta_x = w->viewport->dest_scrollpos_x - w->viewport->scrollpos_x; |
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
1628 int delta_y = w->viewport->dest_scrollpos_y - w->viewport->scrollpos_y; |
6730
0b56358a0e3d
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138 <peter1138@openttd.org>
parents:
6669
diff
changeset
|
1629 |
0b56358a0e3d
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138 <peter1138@openttd.org>
parents:
6669
diff
changeset
|
1630 if (delta_x != 0 || delta_y != 0) { |
9413
512ea64da840
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents:
9410
diff
changeset
|
1631 if (_settings_client.gui.smooth_scroll) { |
6731
5b13b47b071c
(svn r9963) -Fix (r9962): 'smooth_scroll' patch setting was ignored (always on) in some places.
peter1138 <peter1138@openttd.org>
parents:
6730
diff
changeset
|
1632 int max_scroll = ScaleByMapSize1D(512); |
5b13b47b071c
(svn r9963) -Fix (r9962): 'smooth_scroll' patch setting was ignored (always on) in some places.
peter1138 <peter1138@openttd.org>
parents:
6730
diff
changeset
|
1633 /* Not at our desired positon yet... */ |
9184
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
1634 w->viewport->scrollpos_x += Clamp(delta_x / 4, -max_scroll, max_scroll); |
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
1635 w->viewport->scrollpos_y += Clamp(delta_y / 4, -max_scroll, max_scroll); |
6731
5b13b47b071c
(svn r9963) -Fix (r9962): 'smooth_scroll' patch setting was ignored (always on) in some places.
peter1138 <peter1138@openttd.org>
parents:
6730
diff
changeset
|
1636 } else { |
9184
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
1637 w->viewport->scrollpos_x = w->viewport->dest_scrollpos_x; |
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
1638 w->viewport->scrollpos_y = w->viewport->dest_scrollpos_y; |
6731
5b13b47b071c
(svn r9963) -Fix (r9962): 'smooth_scroll' patch setting was ignored (always on) in some places.
peter1138 <peter1138@openttd.org>
parents:
6730
diff
changeset
|
1639 } |
6730
0b56358a0e3d
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138 <peter1138@openttd.org>
parents:
6669
diff
changeset
|
1640 } |
0b56358a0e3d
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138 <peter1138@openttd.org>
parents:
6669
diff
changeset
|
1641 |
9184
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
1642 ClampViewportToMap(vp, w->viewport->scrollpos_x, w->viewport->scrollpos_y); |
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
1643 |
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
1644 SetViewportPosition(w, w->viewport->scrollpos_x, w->viewport->scrollpos_y); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1645 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1646 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1647 |
7545
a84d70ad7876
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7497
diff
changeset
|
1648 /** |
8992
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
1649 * Marks a viewport as dirty for repaint if it displays (a part of) the area the needs to be repainted. |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
1650 * @param vp The viewport to mark as dirty |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
1651 * @param left Left edge of area to repaint |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
1652 * @param top Top edge of area to repaint |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
1653 * @param right Right edge of area to repaint |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
1654 * @param bottom Bottom edge of area to repaint |
7545
a84d70ad7876
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7497
diff
changeset
|
1655 * @ingroup dirty |
a84d70ad7876
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7497
diff
changeset
|
1656 */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1657 static void MarkViewportDirty(const ViewPort *vp, int left, int top, int right, int bottom) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1658 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1659 right -= vp->virtual_left; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1660 if (right <= 0) return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1661 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1662 bottom -= vp->virtual_top; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1663 if (bottom <= 0) return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1664 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1665 left = max(0, left - vp->virtual_left); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1666 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1667 if (left >= vp->virtual_width) return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1668 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1669 top = max(0, top - vp->virtual_top); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1670 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1671 if (top >= vp->virtual_height) return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1672 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1673 SetDirtyBlocks( |
10549
dd9cc2c7c5be
(svn r14806) -Fix: MarkAllViewportsDirty() didn't mark dirty whole area when zoomed out, visible by aircraft leaving trails sometimes
smatz <smatz@openttd.org>
parents:
10532
diff
changeset
|
1674 UnScaleByZoomLower(left, vp->zoom) + vp->left, |
dd9cc2c7c5be
(svn r14806) -Fix: MarkAllViewportsDirty() didn't mark dirty whole area when zoomed out, visible by aircraft leaving trails sometimes
smatz <smatz@openttd.org>
parents:
10532
diff
changeset
|
1675 UnScaleByZoomLower(top, vp->zoom) + vp->top, |
dd9cc2c7c5be
(svn r14806) -Fix: MarkAllViewportsDirty() didn't mark dirty whole area when zoomed out, visible by aircraft leaving trails sometimes
smatz <smatz@openttd.org>
parents:
10532
diff
changeset
|
1676 UnScaleByZoom(right, vp->zoom) + vp->left + 1, |
dd9cc2c7c5be
(svn r14806) -Fix: MarkAllViewportsDirty() didn't mark dirty whole area when zoomed out, visible by aircraft leaving trails sometimes
smatz <smatz@openttd.org>
parents:
10532
diff
changeset
|
1677 UnScaleByZoom(bottom, vp->zoom) + vp->top + 1 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1678 ); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1679 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1680 |
8992
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
1681 /** |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
1682 * Mark all viewports that display an area as dirty (in need of repaint). |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
1683 * @param left Left edge of area to repaint |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
1684 * @param top Top edge of area to repaint |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
1685 * @param right Right edge of area to repaint |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
1686 * @param bottom Bottom edge of area to repaint |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
1687 * @ingroup dirty |
c0e03990caf0
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
8979
diff
changeset
|
1688 */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1689 void MarkAllViewportsDirty(int left, int top, int right, int bottom) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1690 { |
10597
b9297d5178c0
(svn r14880) -Codechange: make it clear which way the FOR_ALL_WINDOWS goes (from back to front or vice versa) and make it iterate over the Window* instead of Window**.
rubidium <rubidium@openttd.org>
parents:
10571
diff
changeset
|
1691 Window *w; |
b9297d5178c0
(svn r14880) -Codechange: make it clear which way the FOR_ALL_WINDOWS goes (from back to front or vice versa) and make it iterate over the Window* instead of Window**.
rubidium <rubidium@openttd.org>
parents:
10571
diff
changeset
|
1692 FOR_ALL_WINDOWS_FROM_BACK(w) { |
b9297d5178c0
(svn r14880) -Codechange: make it clear which way the FOR_ALL_WINDOWS goes (from back to front or vice versa) and make it iterate over the Window* instead of Window**.
rubidium <rubidium@openttd.org>
parents:
10571
diff
changeset
|
1693 ViewPort *vp = w->viewport; |
8957
484f482e54fa
(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 <rubidium@openttd.org>
parents:
8953
diff
changeset
|
1694 if (vp != NULL) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1695 assert(vp->width != 0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1696 MarkViewportDirty(vp, left, top, right, bottom); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1697 } |
8957
484f482e54fa
(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 <rubidium@openttd.org>
parents:
8953
diff
changeset
|
1698 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1699 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1700 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1701 void MarkTileDirtyByTile(TileIndex tile) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1702 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1703 Point pt = RemapCoords(TileX(tile) * TILE_SIZE, TileY(tile) * TILE_SIZE, GetTileZ(tile)); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1704 MarkAllViewportsDirty( |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1705 pt.x - 31, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1706 pt.y - 122, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1707 pt.x - 31 + 67, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1708 pt.y - 122 + 154 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1709 ); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1710 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1711 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1712 void MarkTileDirty(int x, int y) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1713 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1714 uint z = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1715 Point pt; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1716 |
7954
38bb7c45688f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13 <skidd13@openttd.org>
parents:
7951
diff
changeset
|
1717 if (IsInsideMM(x, 0, MapSizeX() * TILE_SIZE) && |
38bb7c45688f
(svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13 <skidd13@openttd.org>
parents:
7951
diff
changeset
|
1718 IsInsideMM(y, 0, MapSizeY() * TILE_SIZE)) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1719 z = GetTileZ(TileVirtXY(x, y)); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1720 pt = RemapCoords(x, y, z); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1721 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1722 MarkAllViewportsDirty( |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1723 pt.x - 31, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1724 pt.y - 122, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1725 pt.x - 31 + 67, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1726 pt.y - 122 + 154 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1727 ); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1728 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1729 |
7545
a84d70ad7876
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7497
diff
changeset
|
1730 /** |
a84d70ad7876
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7497
diff
changeset
|
1731 * Marks the selected tiles as dirty. |
a84d70ad7876
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7497
diff
changeset
|
1732 * |
a84d70ad7876
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7497
diff
changeset
|
1733 * This function marks the selected tiles as dirty for repaint |
a84d70ad7876
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7497
diff
changeset
|
1734 * |
a84d70ad7876
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7497
diff
changeset
|
1735 * @note Documentation may be wrong (Progman) |
a84d70ad7876
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7497
diff
changeset
|
1736 * @ingroup dirty |
a84d70ad7876
(svn r11065) -Documentation [FS#1186]: of the dirty marking/repainting subsystem. Patch by Progman.
rubidium <rubidium@openttd.org>
parents:
7497
diff
changeset
|
1737 */ |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6117
diff
changeset
|
1738 static void SetSelectionTilesDirty() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1739 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1740 int y_size, x_size; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1741 int x = _thd.pos.x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1742 int y = _thd.pos.y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1743 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1744 x_size = _thd.size.x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1745 y_size = _thd.size.y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1746 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1747 if (_thd.outersize.x) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1748 x_size += _thd.outersize.x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1749 x += _thd.offs.x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1750 y_size += _thd.outersize.y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1751 y += _thd.offs.y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1752 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1753 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1754 assert(x_size > 0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1755 assert(y_size > 0); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1756 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1757 x_size += x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1758 y_size += y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1759 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1760 do { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1761 int y_bk = y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1762 do { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1763 MarkTileDirty(x, y); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1764 } while ( (y += TILE_SIZE) != y_size); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1765 y = y_bk; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1766 } while ( (x += TILE_SIZE) != x_size); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1767 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1768 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1769 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1770 void SetSelectionRed(bool b) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1771 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1772 _thd.make_square_red = b; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1773 SetSelectionTilesDirty(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1774 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1775 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1776 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1777 static bool CheckClickOnTown(const ViewPort *vp, int x, int y) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1778 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1779 const Town *t; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1780 |
7928
4e8dfd103163
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents:
7923
diff
changeset
|
1781 if (!HasBit(_display_opt, DO_SHOW_TOWN_NAMES)) return false; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1782 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1783 switch (vp->zoom) { |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1784 case ZOOM_LVL_NORMAL: |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1785 x = x - vp->left + vp->virtual_left; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1786 y = y - vp->top + vp->virtual_top; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1787 FOR_ALL_TOWNS(t) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1788 if (y >= t->sign.top && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1789 y < t->sign.top + 12 && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1790 x >= t->sign.left && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1791 x < t->sign.left + t->sign.width_1) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1792 ShowTownViewWindow(t->index); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1793 return true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1794 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1795 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1796 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1797 |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1798 case ZOOM_LVL_OUT_2X: |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1799 x = (x - vp->left + 1) * 2 + vp->virtual_left; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1800 y = (y - vp->top + 1) * 2 + vp->virtual_top; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1801 FOR_ALL_TOWNS(t) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1802 if (y >= t->sign.top && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1803 y < t->sign.top + 24 && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1804 x >= t->sign.left && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1805 x < t->sign.left + t->sign.width_1 * 2) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1806 ShowTownViewWindow(t->index); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1807 return true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1808 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1809 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1810 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1811 |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1812 case ZOOM_LVL_OUT_4X: |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1813 case ZOOM_LVL_OUT_8X: |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1814 x = ScaleByZoom(x - vp->left + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_left; |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1815 y = ScaleByZoom(y - vp->top + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_top; |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1816 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1817 FOR_ALL_TOWNS(t) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1818 if (y >= t->sign.top && |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1819 y < t->sign.top + ScaleByZoom(12, vp->zoom) && |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1820 x >= t->sign.left && |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1821 x < t->sign.left + ScaleByZoom(t->sign.width_2, vp->zoom)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1822 ShowTownViewWindow(t->index); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1823 return true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1824 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1825 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1826 break; |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1827 |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1828 default: NOT_REACHED(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1829 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1830 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1831 return false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1832 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1833 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1834 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1835 static bool CheckClickOnStation(const ViewPort *vp, int x, int y) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1836 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1837 const Station *st; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1838 |
9755
41ba172f49f7
(svn r13891) -Fix (r12547): one could click on waypoint and station signs even when they were invisible
smatz <smatz@openttd.org>
parents:
9555
diff
changeset
|
1839 if (!HasBit(_display_opt, DO_SHOW_STATION_NAMES) || IsInvisibilitySet(TO_SIGNS)) return false; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1840 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1841 switch (vp->zoom) { |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1842 case ZOOM_LVL_NORMAL: |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1843 x = x - vp->left + vp->virtual_left; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1844 y = y - vp->top + vp->virtual_top; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1845 FOR_ALL_STATIONS(st) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1846 if (y >= st->sign.top && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1847 y < st->sign.top + 12 && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1848 x >= st->sign.left && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1849 x < st->sign.left + st->sign.width_1) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1850 ShowStationViewWindow(st->index); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1851 return true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1852 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1853 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1854 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1855 |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1856 case ZOOM_LVL_OUT_2X: |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1857 x = (x - vp->left + 1) * 2 + vp->virtual_left; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1858 y = (y - vp->top + 1) * 2 + vp->virtual_top; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1859 FOR_ALL_STATIONS(st) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1860 if (y >= st->sign.top && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1861 y < st->sign.top + 24 && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1862 x >= st->sign.left && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1863 x < st->sign.left + st->sign.width_1 * 2) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1864 ShowStationViewWindow(st->index); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1865 return true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1866 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1867 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1868 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1869 |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1870 case ZOOM_LVL_OUT_4X: |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1871 case ZOOM_LVL_OUT_8X: |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1872 x = ScaleByZoom(x - vp->left + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_left; |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1873 y = ScaleByZoom(y - vp->top + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_top; |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1874 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1875 FOR_ALL_STATIONS(st) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1876 if (y >= st->sign.top && |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1877 y < st->sign.top + ScaleByZoom(12, vp->zoom) && |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1878 x >= st->sign.left && |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1879 x < st->sign.left + ScaleByZoom(st->sign.width_2, vp->zoom)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1880 ShowStationViewWindow(st->index); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1881 return true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1882 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1883 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1884 break; |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1885 |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1886 default: NOT_REACHED(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1887 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1888 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1889 return false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1890 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1891 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1892 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1893 static bool CheckClickOnSign(const ViewPort *vp, int x, int y) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1894 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1895 const Sign *si; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1896 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10196
diff
changeset
|
1897 /* Signs are turned off, or they are transparent and invisibility is ON, or company is a spectator */ |
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10196
diff
changeset
|
1898 if (!HasBit(_display_opt, DO_SHOW_SIGNS) || IsInvisibilitySet(TO_SIGNS) || _current_company == COMPANY_SPECTATOR) return false; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1899 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1900 switch (vp->zoom) { |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1901 case ZOOM_LVL_NORMAL: |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1902 x = x - vp->left + vp->virtual_left; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1903 y = y - vp->top + vp->virtual_top; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1904 FOR_ALL_SIGNS(si) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1905 if (y >= si->sign.top && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1906 y < si->sign.top + 12 && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1907 x >= si->sign.left && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1908 x < si->sign.left + si->sign.width_1) { |
9510
e5653305882a
(svn r13501) -Feature(tte): ctrl+click on sign you own to remove it (Osai, planetmaker)
smatz <smatz@openttd.org>
parents:
9413
diff
changeset
|
1909 HandleClickOnSign(si); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1910 return true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1911 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1912 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1913 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1914 |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1915 case ZOOM_LVL_OUT_2X: |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1916 x = (x - vp->left + 1) * 2 + vp->virtual_left; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1917 y = (y - vp->top + 1) * 2 + vp->virtual_top; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1918 FOR_ALL_SIGNS(si) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1919 if (y >= si->sign.top && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1920 y < si->sign.top + 24 && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1921 x >= si->sign.left && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1922 x < si->sign.left + si->sign.width_1 * 2) { |
9510
e5653305882a
(svn r13501) -Feature(tte): ctrl+click on sign you own to remove it (Osai, planetmaker)
smatz <smatz@openttd.org>
parents:
9413
diff
changeset
|
1923 HandleClickOnSign(si); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1924 return true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1925 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1926 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1927 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1928 |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1929 case ZOOM_LVL_OUT_4X: |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1930 case ZOOM_LVL_OUT_8X: |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1931 x = ScaleByZoom(x - vp->left + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_left; |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1932 y = ScaleByZoom(y - vp->top + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_top; |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1933 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1934 FOR_ALL_SIGNS(si) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1935 if (y >= si->sign.top && |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1936 y < si->sign.top + ScaleByZoom(12, vp->zoom) && |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1937 x >= si->sign.left && |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1938 x < si->sign.left + ScaleByZoom(si->sign.width_2, vp->zoom)) { |
9510
e5653305882a
(svn r13501) -Feature(tte): ctrl+click on sign you own to remove it (Osai, planetmaker)
smatz <smatz@openttd.org>
parents:
9413
diff
changeset
|
1939 HandleClickOnSign(si); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1940 return true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1941 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1942 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1943 break; |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1944 |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1945 default: NOT_REACHED(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1946 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1947 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1948 return false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1949 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1950 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1951 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1952 static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1953 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1954 const Waypoint *wp; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1955 |
9755
41ba172f49f7
(svn r13891) -Fix (r12547): one could click on waypoint and station signs even when they were invisible
smatz <smatz@openttd.org>
parents:
9555
diff
changeset
|
1956 if (!HasBit(_display_opt, DO_WAYPOINTS) || IsInvisibilitySet(TO_SIGNS)) return false; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1957 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1958 switch (vp->zoom) { |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1959 case ZOOM_LVL_NORMAL: |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1960 x = x - vp->left + vp->virtual_left; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1961 y = y - vp->top + vp->virtual_top; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1962 FOR_ALL_WAYPOINTS(wp) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1963 if (y >= wp->sign.top && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1964 y < wp->sign.top + 12 && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1965 x >= wp->sign.left && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1966 x < wp->sign.left + wp->sign.width_1) { |
9949
d991fb317728
(svn r14104) -Feature: Add a window for waypoints, allowing to view all the trains having the selected waypoint in their orders.
belugas <belugas@openttd.org>
parents:
9847
diff
changeset
|
1967 ShowWaypointWindow(wp); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1968 return true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1969 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1970 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1971 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1972 |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1973 case ZOOM_LVL_OUT_2X: |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1974 x = (x - vp->left + 1) * 2 + vp->virtual_left; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1975 y = (y - vp->top + 1) * 2 + vp->virtual_top; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1976 FOR_ALL_WAYPOINTS(wp) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1977 if (y >= wp->sign.top && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1978 y < wp->sign.top + 24 && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1979 x >= wp->sign.left && |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1980 x < wp->sign.left + wp->sign.width_1 * 2) { |
9949
d991fb317728
(svn r14104) -Feature: Add a window for waypoints, allowing to view all the trains having the selected waypoint in their orders.
belugas <belugas@openttd.org>
parents:
9847
diff
changeset
|
1981 ShowWaypointWindow(wp); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1982 return true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1983 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1984 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1985 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1986 |
6624
bf5d7b24a7ab
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight <truelight@openttd.org>
parents:
6591
diff
changeset
|
1987 case ZOOM_LVL_OUT_4X: |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1988 case ZOOM_LVL_OUT_8X: |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1989 x = ScaleByZoom(x - vp->left + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_left; |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1990 y = ScaleByZoom(y - vp->top + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_top; |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1991 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1992 FOR_ALL_WAYPOINTS(wp) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1993 if (y >= wp->sign.top && |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1994 y < wp->sign.top + ScaleByZoom(12, vp->zoom) && |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1995 x >= wp->sign.left && |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
1996 x < wp->sign.left + ScaleByZoom(wp->sign.width_2, vp->zoom)) { |
9949
d991fb317728
(svn r14104) -Feature: Add a window for waypoints, allowing to view all the trains having the selected waypoint in their orders.
belugas <belugas@openttd.org>
parents:
9847
diff
changeset
|
1997 ShowWaypointWindow(wp); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1998 return true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1999 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2000 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2001 break; |
6653
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
2002 |
cbe12394f776
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight <truelight@openttd.org>
parents:
6626
diff
changeset
|
2003 default: NOT_REACHED(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2004 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2005 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2006 return false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2007 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2008 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2009 |
10532
d33755b6159a
(svn r14789) -Feature: allow scrolling with the left mouse button pressed (if enabled). Primarily useful for systems with touch screen (aapo)
rubidium <rubidium@openttd.org>
parents:
10238
diff
changeset
|
2010 static bool CheckClickOnLandscape(const ViewPort *vp, int x, int y) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2011 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2012 Point pt = TranslateXYToTileCoord(vp, x, y); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2013 |
10532
d33755b6159a
(svn r14789) -Feature: allow scrolling with the left mouse button pressed (if enabled). Primarily useful for systems with touch screen (aapo)
rubidium <rubidium@openttd.org>
parents:
10238
diff
changeset
|
2014 if (pt.x != -1) return ClickTile(TileVirtXY(pt.x, pt.y)); |
d33755b6159a
(svn r14789) -Feature: allow scrolling with the left mouse button pressed (if enabled). Primarily useful for systems with touch screen (aapo)
rubidium <rubidium@openttd.org>
parents:
10238
diff
changeset
|
2015 return true; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2016 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2017 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2018 |
10532
d33755b6159a
(svn r14789) -Feature: allow scrolling with the left mouse button pressed (if enabled). Primarily useful for systems with touch screen (aapo)
rubidium <rubidium@openttd.org>
parents:
10238
diff
changeset
|
2019 bool HandleViewportClicked(const ViewPort *vp, int x, int y) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2020 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2021 const Vehicle *v; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2022 |
10532
d33755b6159a
(svn r14789) -Feature: allow scrolling with the left mouse button pressed (if enabled). Primarily useful for systems with touch screen (aapo)
rubidium <rubidium@openttd.org>
parents:
10238
diff
changeset
|
2023 if (CheckClickOnTown(vp, x, y)) return true; |
d33755b6159a
(svn r14789) -Feature: allow scrolling with the left mouse button pressed (if enabled). Primarily useful for systems with touch screen (aapo)
rubidium <rubidium@openttd.org>
parents:
10238
diff
changeset
|
2024 if (CheckClickOnStation(vp, x, y)) return true; |
d33755b6159a
(svn r14789) -Feature: allow scrolling with the left mouse button pressed (if enabled). Primarily useful for systems with touch screen (aapo)
rubidium <rubidium@openttd.org>
parents:
10238
diff
changeset
|
2025 if (CheckClickOnSign(vp, x, y)) return true; |
d33755b6159a
(svn r14789) -Feature: allow scrolling with the left mouse button pressed (if enabled). Primarily useful for systems with touch screen (aapo)
rubidium <rubidium@openttd.org>
parents:
10238
diff
changeset
|
2026 if (CheckClickOnWaypoint(vp, x, y)) return true; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2027 CheckClickOnLandscape(vp, x, y); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2028 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2029 v = CheckClickOnVehicle(vp, x, y); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2030 if (v != NULL) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2031 DEBUG(misc, 2, "Vehicle %d (index %d) at %p", v->unitnumber, v->index, v); |
10600
2c78f89aa7e9
(svn r14884) -Codechange: simplify code responsible for opening vehicle view windows
smatz <smatz@openttd.org>
parents:
10597
diff
changeset
|
2032 if (IsCompanyBuildableVehicleType(v)) ShowVehicleViewWindow(v->First()); |
10532
d33755b6159a
(svn r14789) -Feature: allow scrolling with the left mouse button pressed (if enabled). Primarily useful for systems with touch screen (aapo)
rubidium <rubidium@openttd.org>
parents:
10238
diff
changeset
|
2033 return true; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2034 } |
10532
d33755b6159a
(svn r14789) -Feature: allow scrolling with the left mouse button pressed (if enabled). Primarily useful for systems with touch screen (aapo)
rubidium <rubidium@openttd.org>
parents:
10238
diff
changeset
|
2035 return CheckClickOnLandscape(vp, x, y); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2036 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2037 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6117
diff
changeset
|
2038 Vehicle *CheckMouseOverVehicle() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2039 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2040 const Window *w; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2041 const ViewPort *vp; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2042 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2043 int x = _cursor.pos.x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2044 int y = _cursor.pos.y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2045 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2046 w = FindWindowFromPt(x, y); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2047 if (w == NULL) return NULL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2048 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2049 vp = IsPtInWindowViewport(w, x, y); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2050 return (vp != NULL) ? CheckClickOnVehicle(vp, x, y) : NULL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2051 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2052 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2053 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2054 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6117
diff
changeset
|
2055 void PlaceObject() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2056 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2057 Point pt; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2058 Window *w; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2059 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2060 pt = GetTileBelowCursor(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2061 if (pt.x == -1) return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2062 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2063 if (_thd.place_mode == VHM_POINT) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2064 pt.x += 8; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2065 pt.y += 8; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2066 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2067 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2068 _tile_fract_coords.x = pt.x & 0xF; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2069 _tile_fract_coords.y = pt.y & 0xF; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2070 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2071 w = GetCallbackWnd(); |
9166
45b1388fe9ba
(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 <rubidium@openttd.org>
parents:
9147
diff
changeset
|
2072 if (w != NULL) w->OnPlaceObject(pt, TileVirtXY(pt.x, pt.y)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2073 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2074 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2075 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2076 /* scrolls the viewport in a window to a given location */ |
6730
0b56358a0e3d
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138 <peter1138@openttd.org>
parents:
6669
diff
changeset
|
2077 bool ScrollWindowTo(int x , int y, Window *w, bool instant) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2078 { |
8473
75c79ef760e8
(svn r12044) -Fix [FS#1741]: crash when centering on a vehicle (aircraft) that is outside of the map.
rubidium <rubidium@openttd.org>
parents:
8413
diff
changeset
|
2079 /* The slope cannot be acquired outside of the map, so make sure we are always within the map. */ |
10216
6f11075b1de8
(svn r14439) -Fix (r12044)(r14139): centering on a plane at the SE border could cause crash
smatz <smatz@openttd.org>
parents:
10208
diff
changeset
|
2080 Point pt = MapXYZToViewport(w->viewport, x, y, GetSlopeZ(Clamp(x, 0, MapSizeX() * TILE_SIZE - 1), Clamp(y, 0, MapSizeY() * TILE_SIZE - 1))); |
9184
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
2081 w->viewport->follow_vehicle = INVALID_VEHICLE; |
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
2082 |
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
2083 if (w->viewport->dest_scrollpos_x == pt.x && w->viewport->dest_scrollpos_y == pt.y) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2084 return false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2085 |
6731
5b13b47b071c
(svn r9963) -Fix (r9962): 'smooth_scroll' patch setting was ignored (always on) in some places.
peter1138 <peter1138@openttd.org>
parents:
6730
diff
changeset
|
2086 if (instant) { |
9184
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
2087 w->viewport->scrollpos_x = pt.x; |
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
2088 w->viewport->scrollpos_y = pt.y; |
6730
0b56358a0e3d
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138 <peter1138@openttd.org>
parents:
6669
diff
changeset
|
2089 } |
0b56358a0e3d
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138 <peter1138@openttd.org>
parents:
6669
diff
changeset
|
2090 |
9184
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
2091 w->viewport->dest_scrollpos_x = pt.x; |
a7020e34c67b
(svn r13047) -Codechange: remove vp_d
glx <glx@openttd.org>
parents:
9166
diff
changeset
|
2092 w->viewport->dest_scrollpos_y = pt.y; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2093 return true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2094 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2095 |
6730
0b56358a0e3d
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138 <peter1138@openttd.org>
parents:
6669
diff
changeset
|
2096 bool ScrollMainWindowToTile(TileIndex tile, bool instant) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2097 { |
6730
0b56358a0e3d
(svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138 <peter1138@openttd.org>
parents:
6669
diff
changeset
|
2098 return ScrollMainWindowTo(TileX(tile) * TILE_SIZE + TILE_SIZE / 2, TileY(tile) * TILE_SIZE + TILE_SIZE / 2, instant); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2099 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2100 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2101 void SetRedErrorSquare(TileIndex tile) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2102 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2103 TileIndex old; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2104 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2105 old = _thd.redsq; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2106 _thd.redsq = tile; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2107 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2108 if (tile != old) { |
10816
35b3e8e25590
(svn r15151) -Fix: tile 0 can now be highlighted as error tile
Yexo <Yexo@openttd.org>
parents:
10815
diff
changeset
|
2109 if (tile != INVALID_TILE) MarkTileDirtyByTile(tile); |
35b3e8e25590
(svn r15151) -Fix: tile 0 can now be highlighted as error tile
Yexo <Yexo@openttd.org>
parents:
10815
diff
changeset
|
2110 if (old != INVALID_TILE) MarkTileDirtyByTile(old); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2111 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2112 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2113 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2114 void SetTileSelectSize(int w, int h) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2115 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2116 _thd.new_size.x = w * TILE_SIZE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2117 _thd.new_size.y = h * TILE_SIZE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2118 _thd.new_outersize.x = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2119 _thd.new_outersize.y = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2120 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2121 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2122 void SetTileSelectBigSize(int ox, int oy, int sx, int sy) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2123 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2124 _thd.offs.x = ox * TILE_SIZE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2125 _thd.offs.y = oy * TILE_SIZE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2126 _thd.new_outersize.x = sx * TILE_SIZE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2127 _thd.new_outersize.y = sy * TILE_SIZE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2128 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2129 |
6423
72ac8bfaa32f
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas <belugas@openttd.org>
parents:
6248
diff
changeset
|
2130 /** returns the best autorail highlight type from map coordinates */ |
8224
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
2131 static HighLightStyle GetAutorailHT(int x, int y) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2132 { |
8224
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
2133 return HT_RAIL | _autorail_piece[x & 0xF][y & 0xF]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2134 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2135 |
7078
c4d51d528cd2
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas <belugas@openttd.org>
parents:
7069
diff
changeset
|
2136 /** |
c4d51d528cd2
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas <belugas@openttd.org>
parents:
7069
diff
changeset
|
2137 * Updates tile highlighting for all cases. |
c4d51d528cd2
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas <belugas@openttd.org>
parents:
7069
diff
changeset
|
2138 * Uses _thd.selstart and _thd.selend and _thd.place_mode (set elsewhere) to determine _thd.pos and _thd.size |
c4d51d528cd2
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas <belugas@openttd.org>
parents:
7069
diff
changeset
|
2139 * Also drawstyle is determined. Uses _thd.new.* as a buffer and calls SetSelectionTilesDirty() twice, |
c4d51d528cd2
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas <belugas@openttd.org>
parents:
7069
diff
changeset
|
2140 * Once for the old and once for the new selection. |
c4d51d528cd2
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas <belugas@openttd.org>
parents:
7069
diff
changeset
|
2141 * _thd is TileHighlightData, found in viewport.h |
c4d51d528cd2
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas <belugas@openttd.org>
parents:
7069
diff
changeset
|
2142 */ |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6117
diff
changeset
|
2143 void UpdateTileSelection() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2144 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2145 int x1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2146 int y1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2147 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2148 _thd.new_drawstyle = 0; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2149 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2150 if (_thd.place_mode == VHM_SPECIAL) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2151 x1 = _thd.selend.x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2152 y1 = _thd.selend.y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2153 if (x1 != -1) { |
7912
357db556fc02
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz <smatz@openttd.org>
parents:
7905
diff
changeset
|
2154 int x2 = _thd.selstart.x & ~0xF; |
357db556fc02
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz <smatz@openttd.org>
parents:
7905
diff
changeset
|
2155 int y2 = _thd.selstart.y & ~0xF; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2156 x1 &= ~0xF; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2157 y1 &= ~0xF; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2158 |
6106 | 2159 if (x1 >= x2) Swap(x1, x2); |
2160 if (y1 >= y2) Swap(y1, y2); | |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2161 _thd.new_pos.x = x1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2162 _thd.new_pos.y = y1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2163 _thd.new_size.x = x2 - x1 + TILE_SIZE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2164 _thd.new_size.y = y2 - y1 + TILE_SIZE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2165 _thd.new_drawstyle = _thd.next_drawstyle; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2166 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2167 } else if (_thd.place_mode != VHM_NONE) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2168 Point pt = GetTileBelowCursor(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2169 x1 = pt.x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2170 y1 = pt.y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2171 if (x1 != -1) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2172 switch (_thd.place_mode) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2173 case VHM_RECT: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2174 _thd.new_drawstyle = HT_RECT; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2175 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2176 case VHM_POINT: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2177 _thd.new_drawstyle = HT_POINT; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2178 x1 += 8; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2179 y1 += 8; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2180 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2181 case VHM_RAIL: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2182 _thd.new_drawstyle = GetAutorailHT(pt.x, pt.y); // draw one highlighted tile |
7918
7a122ebfa7cf
(svn r11471) -Codechange: one more variable retyped to enum ViewportHighlightMode
smatz <smatz@openttd.org>
parents:
7912
diff
changeset
|
2183 break; |
7a122ebfa7cf
(svn r11471) -Codechange: one more variable retyped to enum ViewportHighlightMode
smatz <smatz@openttd.org>
parents:
7912
diff
changeset
|
2184 default: |
7a122ebfa7cf
(svn r11471) -Codechange: one more variable retyped to enum ViewportHighlightMode
smatz <smatz@openttd.org>
parents:
7912
diff
changeset
|
2185 NOT_REACHED(); |
7a122ebfa7cf
(svn r11471) -Codechange: one more variable retyped to enum ViewportHighlightMode
smatz <smatz@openttd.org>
parents:
7912
diff
changeset
|
2186 break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2187 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2188 _thd.new_pos.x = x1 & ~0xF; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2189 _thd.new_pos.y = y1 & ~0xF; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2190 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2191 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2192 |
6423
72ac8bfaa32f
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas <belugas@openttd.org>
parents:
6248
diff
changeset
|
2193 /* redraw selection */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2194 if (_thd.drawstyle != _thd.new_drawstyle || |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2195 _thd.pos.x != _thd.new_pos.x || _thd.pos.y != _thd.new_pos.y || |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2196 _thd.size.x != _thd.new_size.x || _thd.size.y != _thd.new_size.y || |
7078
c4d51d528cd2
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas <belugas@openttd.org>
parents:
7069
diff
changeset
|
2197 _thd.outersize.x != _thd.new_outersize.x || |
c4d51d528cd2
(svn r10343) -Cleanup: Add documentation of functions and code-style fix.
belugas <belugas@openttd.org>
parents:
7069
diff
changeset
|
2198 _thd.outersize.y != _thd.new_outersize.y) { |
6423
72ac8bfaa32f
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas <belugas@openttd.org>
parents:
6248
diff
changeset
|
2199 /* clear the old selection? */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2200 if (_thd.drawstyle) SetSelectionTilesDirty(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2201 |
10626
3189a053f43a
(svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10614
diff
changeset
|
2202 if (!_thd.lock_pos) { |
3189a053f43a
(svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10614
diff
changeset
|
2203 _thd.pos = _thd.new_pos; |
3189a053f43a
(svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10614
diff
changeset
|
2204 _thd.drawstyle = _thd.new_drawstyle; |
3189a053f43a
(svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10614
diff
changeset
|
2205 } |
3189a053f43a
(svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10614
diff
changeset
|
2206 |
3189a053f43a
(svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10614
diff
changeset
|
2207 if (!_thd.lock_size) { |
3189a053f43a
(svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10614
diff
changeset
|
2208 _thd.size = _thd.new_size; |
3189a053f43a
(svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10614
diff
changeset
|
2209 _thd.dirty = 0xff; |
3189a053f43a
(svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10614
diff
changeset
|
2210 } |
3189a053f43a
(svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10614
diff
changeset
|
2211 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2212 _thd.outersize = _thd.new_outersize; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2213 |
6423
72ac8bfaa32f
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas <belugas@openttd.org>
parents:
6248
diff
changeset
|
2214 /* draw the new selection? */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2215 if (_thd.new_drawstyle) SetSelectionTilesDirty(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2216 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2217 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2218 |
9781
5ab8b1b156bb
(svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents:
9755
diff
changeset
|
2219 /** Displays the measurement tooltips when selecting multiple tiles |
5ab8b1b156bb
(svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents:
9755
diff
changeset
|
2220 * @param str String to be displayed |
5ab8b1b156bb
(svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents:
9755
diff
changeset
|
2221 * @param paramcount number of params to deal with |
5ab8b1b156bb
(svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents:
9755
diff
changeset
|
2222 * @param params (optional) up to 5 pieces of additional information that may be added to a tooltip |
5ab8b1b156bb
(svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents:
9755
diff
changeset
|
2223 */ |
5ab8b1b156bb
(svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents:
9755
diff
changeset
|
2224 static inline void ShowMeasurementTooltips(StringID str, uint paramcount, const uint64 params[]) |
5ab8b1b156bb
(svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents:
9755
diff
changeset
|
2225 { |
5ab8b1b156bb
(svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents:
9755
diff
changeset
|
2226 if (!_settings_client.gui.measure_tooltip) return; |
5ab8b1b156bb
(svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents:
9755
diff
changeset
|
2227 GuiShowTooltips(str, paramcount, params, true); |
5ab8b1b156bb
(svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents:
9755
diff
changeset
|
2228 } |
5ab8b1b156bb
(svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents:
9755
diff
changeset
|
2229 |
6423
72ac8bfaa32f
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas <belugas@openttd.org>
parents:
6248
diff
changeset
|
2230 /** highlighting tiles while only going over them with the mouse */ |
9147
6c9755fab091
(svn r13009) -Codechange: move more tile highlighting related functions/types to tilehighlight_*.h.
rubidium <rubidium@openttd.org>
parents:
9127
diff
changeset
|
2231 void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2232 { |
6669
66456dace92f
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros <maedhros@openttd.org>
parents:
6654
diff
changeset
|
2233 _thd.select_method = method; |
66456dace92f
(svn r9900) -Codechange: Separate the variables for how to highlight a land area and what to do with it afterwards.
maedhros <maedhros@openttd.org>
parents:
6654
diff
changeset
|
2234 _thd.select_proc = process; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2235 _thd.selend.x = TileX(tile) * TILE_SIZE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2236 _thd.selstart.x = TileX(tile) * TILE_SIZE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2237 _thd.selend.y = TileY(tile) * TILE_SIZE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2238 _thd.selstart.y = TileY(tile) * TILE_SIZE; |
7912
357db556fc02
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz <smatz@openttd.org>
parents:
7905
diff
changeset
|
2239 |
357db556fc02
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz <smatz@openttd.org>
parents:
7905
diff
changeset
|
2240 /* Needed so several things (road, autoroad, bridges, ...) are placed correctly. |
357db556fc02
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz <smatz@openttd.org>
parents:
7905
diff
changeset
|
2241 * In effect, placement starts from the centre of a tile |
357db556fc02
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz <smatz@openttd.org>
parents:
7905
diff
changeset
|
2242 */ |
357db556fc02
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz <smatz@openttd.org>
parents:
7905
diff
changeset
|
2243 if (method == VPM_X_OR_Y || method == VPM_FIX_X || method == VPM_FIX_Y) { |
357db556fc02
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz <smatz@openttd.org>
parents:
7905
diff
changeset
|
2244 _thd.selend.x += TILE_SIZE / 2; |
357db556fc02
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz <smatz@openttd.org>
parents:
7905
diff
changeset
|
2245 _thd.selend.y += TILE_SIZE / 2; |
357db556fc02
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz <smatz@openttd.org>
parents:
7905
diff
changeset
|
2246 _thd.selstart.x += TILE_SIZE / 2; |
357db556fc02
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz <smatz@openttd.org>
parents:
7905
diff
changeset
|
2247 _thd.selstart.y += TILE_SIZE / 2; |
357db556fc02
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz <smatz@openttd.org>
parents:
7905
diff
changeset
|
2248 } |
357db556fc02
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz <smatz@openttd.org>
parents:
7905
diff
changeset
|
2249 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2250 if (_thd.place_mode == VHM_RECT) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2251 _thd.place_mode = VHM_SPECIAL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2252 _thd.next_drawstyle = HT_RECT; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2253 } else if (_thd.place_mode == VHM_RAIL) { // autorail one piece |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2254 _thd.place_mode = VHM_SPECIAL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2255 _thd.next_drawstyle = _thd.drawstyle; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2256 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2257 _thd.place_mode = VHM_SPECIAL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2258 _thd.next_drawstyle = HT_POINT; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2259 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2260 _special_mouse_mode = WSM_SIZING; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2261 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2262 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2263 void VpSetPlaceSizingLimit(int limit) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2264 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2265 _thd.sizelimit = limit; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2266 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2267 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2268 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2269 * Highlights all tiles between a set of two tiles. Used in dock and tunnel placement |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2270 * @param from TileIndex of the first tile to highlight |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2271 * @param to TileIndex of the last tile to highlight */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2272 void VpSetPresizeRange(TileIndex from, TileIndex to) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2273 { |
7006
933d3ee6d37d
(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 <rubidium@openttd.org>
parents:
6937
diff
changeset
|
2274 uint64 distance = DistanceManhattan(from, to) + 1; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2275 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2276 _thd.selend.x = TileX(to) * TILE_SIZE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2277 _thd.selend.y = TileY(to) * TILE_SIZE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2278 _thd.selstart.x = TileX(from) * TILE_SIZE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2279 _thd.selstart.y = TileY(from) * TILE_SIZE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2280 _thd.next_drawstyle = HT_RECT; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2281 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2282 /* show measurement only if there is any length to speak of */ |
9781
5ab8b1b156bb
(svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents:
9755
diff
changeset
|
2283 if (distance > 1) ShowMeasurementTooltips(STR_MEASURE_LENGTH, 1, &distance); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2284 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2285 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6117
diff
changeset
|
2286 static void VpStartPreSizing() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2287 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2288 _thd.selend.x = -1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2289 _special_mouse_mode = WSM_PRESIZE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2290 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2291 |
6423
72ac8bfaa32f
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas <belugas@openttd.org>
parents:
6248
diff
changeset
|
2292 /** returns information about the 2x1 piece to be build. |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2293 * The lower bits (0-3) are the track type. */ |
8224
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
2294 static HighLightStyle Check2x1AutoRail(int mode) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2295 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2296 int fxpy = _tile_fract_coords.x + _tile_fract_coords.y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2297 int sxpy = (_thd.selend.x & 0xF) + (_thd.selend.y & 0xF); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2298 int fxmy = _tile_fract_coords.x - _tile_fract_coords.y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2299 int sxmy = (_thd.selend.x & 0xF) - (_thd.selend.y & 0xF); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2300 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2301 switch (mode) { |
8224
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
2302 default: NOT_REACHED(); |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
2303 case 0: // end piece is lower right |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
2304 if (fxpy >= 20 && sxpy <= 12) { /*SwapSelection(); DoRailroadTrack(0); */return HT_DIR_HL; } |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
2305 if (fxmy < -3 && sxmy > 3) {/* DoRailroadTrack(0); */return HT_DIR_VR; } |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
2306 return HT_DIR_Y; |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
2307 |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
2308 case 1: |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
2309 if (fxmy > 3 && sxmy < -3) { /*SwapSelection(); DoRailroadTrack(0); */return HT_DIR_VL; } |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
2310 if (fxpy <= 12 && sxpy >= 20) { /*DoRailroadTrack(0); */return HT_DIR_HU; } |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
2311 return HT_DIR_Y; |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
2312 |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
2313 case 2: |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
2314 if (fxmy > 3 && sxmy < -3) { /*DoRailroadTrack(3);*/ return HT_DIR_VL; } |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
2315 if (fxpy >= 20 && sxpy <= 12) { /*SwapSelection(); DoRailroadTrack(0); */return HT_DIR_HL; } |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
2316 return HT_DIR_X; |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
2317 |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
2318 case 3: |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
2319 if (fxmy < -3 && sxmy > 3) { /*SwapSelection(); DoRailroadTrack(3);*/ return HT_DIR_VR; } |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
2320 if (fxpy <= 12 && sxpy >= 20) { /*DoRailroadTrack(0); */return HT_DIR_HU; } |
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
2321 return HT_DIR_X; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2322 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2323 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2324 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2325 /** Check if the direction of start and end tile should be swapped based on |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2326 * the dragging-style. Default directions are: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2327 * in the case of a line (HT_RAIL, HT_LINE): DIR_NE, DIR_NW, DIR_N, DIR_E |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2328 * in the case of a rect (HT_RECT, HT_POINT): DIR_S, DIR_E |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2329 * For example dragging a rectangle area from south to north should be swapped to |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2330 * north-south (DIR_S) to obtain the same results with less code. This is what |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2331 * the return value signifies. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2332 * @param style HighLightStyle dragging style |
6484
17fdaec13730
(svn r9665) -Documentation: Doxygen corrections,errors, corrections of corrections...
belugas <belugas@openttd.org>
parents:
6453
diff
changeset
|
2333 * @param start_tile start tile of drag |
17fdaec13730
(svn r9665) -Documentation: Doxygen corrections,errors, corrections of corrections...
belugas <belugas@openttd.org>
parents:
6453
diff
changeset
|
2334 * @param end_tile end tile of drag |
17fdaec13730
(svn r9665) -Documentation: Doxygen corrections,errors, corrections of corrections...
belugas <belugas@openttd.org>
parents:
6453
diff
changeset
|
2335 * @return boolean value which when true means start/end should be swapped */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2336 static bool SwapDirection(HighLightStyle style, TileIndex start_tile, TileIndex end_tile) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2337 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2338 uint start_x = TileX(start_tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2339 uint start_y = TileY(start_tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2340 uint end_x = TileX(end_tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2341 uint end_y = TileY(end_tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2342 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2343 switch (style & HT_DRAG_MASK) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2344 case HT_RAIL: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2345 case HT_LINE: return (end_x > start_x || (end_x == start_x && end_y > start_y)); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2346 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2347 case HT_RECT: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2348 case HT_POINT: return (end_x != start_x && end_y < start_y); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2349 default: NOT_REACHED(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2350 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2351 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2352 return false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2353 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2354 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2355 /** Calculates height difference between one tile and another |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2356 * Multiplies the result to suit the standard given by minimap - 50 meters high |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2357 * To correctly get the height difference we need the direction we are dragging |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2358 * in, as well as with what kind of tool we are dragging. For example a horizontal |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2359 * autorail tool that starts in bottom and ends at the top of a tile will need the |
6491
696f0e1b046e
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium <rubidium@openttd.org>
parents:
6484
diff
changeset
|
2360 * maximum of SW, S and SE, N corners respectively. This is handled by the lookup table below |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2361 * See _tileoffs_by_dir in map.c for the direction enums if you can't figure out |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2362 * the values yourself. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2363 * @param style HightlightStyle of drag. This includes direction and style (autorail, rect, etc.) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2364 * @param distance amount of tiles dragged, important for horizontal/vertical drags |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2365 * ignored for others |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2366 * @param start_tile, end_tile start and end tile of drag operation |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2367 * @return height difference between two tiles. Tile measurement tool utilizes |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2368 * this value in its tooltips */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2369 static int CalcHeightdiff(HighLightStyle style, uint distance, TileIndex start_tile, TileIndex end_tile) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2370 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2371 bool swap = SwapDirection(style, start_tile, end_tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2372 byte style_t; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2373 uint h0, h1, ht; // start heigth, end height, and temp variable |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2374 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2375 if (start_tile == end_tile) return 0; |
5733 | 2376 if (swap) Swap(start_tile, end_tile); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2377 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2378 switch (style & HT_DRAG_MASK) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2379 case HT_RECT: { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2380 static const TileIndexDiffC heightdiff_area_by_dir[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2381 /* Start */ {1, 0}, /* Dragging east */ {0, 0}, /* Dragging south */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2382 /* End */ {0, 1}, /* Dragging east */ {1, 1} /* Dragging south */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2383 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2384 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2385 /* In the case of an area we can determine whether we were dragging south or |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2386 * east by checking the X-coordinates of the tiles */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2387 style_t = (byte)(TileX(end_tile) > TileX(start_tile)); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2388 start_tile = TILE_ADD(start_tile, ToTileIndexDiff(heightdiff_area_by_dir[style_t])); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2389 end_tile = TILE_ADD(end_tile, ToTileIndexDiff(heightdiff_area_by_dir[2 + style_t])); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2390 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2391 /* Fallthrough */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2392 case HT_POINT: |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2393 h0 = TileHeight(start_tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2394 h1 = TileHeight(end_tile); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2395 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2396 default: { /* All other types, this is mostly only line/autorail */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2397 static const HighLightStyle flip_style_direction[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2398 HT_DIR_X, HT_DIR_Y, HT_DIR_HL, HT_DIR_HU, HT_DIR_VR, HT_DIR_VL |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2399 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2400 static const TileIndexDiffC heightdiff_line_by_dir[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2401 /* Start */ {1, 0}, {1, 1}, /* HT_DIR_X */ {0, 1}, {1, 1}, /* HT_DIR_Y */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2402 /* Start */ {1, 0}, {0, 0}, /* HT_DIR_HU */ {1, 0}, {1, 1}, /* HT_DIR_HL */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2403 /* Start */ {1, 0}, {1, 1}, /* HT_DIR_VL */ {0, 1}, {1, 1}, /* HT_DIR_VR */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2404 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2405 /* Start */ {0, 1}, {0, 0}, /* HT_DIR_X */ {1, 0}, {0, 0}, /* HT_DIR_Y */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2406 /* End */ {0, 1}, {0, 0}, /* HT_DIR_HU */ {1, 1}, {0, 1}, /* HT_DIR_HL */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2407 /* End */ {1, 0}, {0, 0}, /* HT_DIR_VL */ {0, 0}, {0, 1}, /* HT_DIR_VR */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2408 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2409 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2410 distance %= 2; // we're only interested if the distance is even or uneven |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2411 style &= HT_DIR_MASK; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2412 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2413 /* To handle autorail, we do some magic to be able to use a lookup table. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2414 * Firstly if we drag the other way around, we switch start&end, and if needed |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2415 * also flip the drag-position. Eg if it was on the left, and the distance is even |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2416 * that means the end, which is now the start is on the right */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2417 if (swap && distance == 0) style = flip_style_direction[style]; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2418 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2419 /* Use lookup table for start-tile based on HighLightStyle direction */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2420 style_t = style * 2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2421 assert(style_t < lengthof(heightdiff_line_by_dir) - 13); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2422 h0 = TileHeight(TILE_ADD(start_tile, ToTileIndexDiff(heightdiff_line_by_dir[style_t]))); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2423 ht = TileHeight(TILE_ADD(start_tile, ToTileIndexDiff(heightdiff_line_by_dir[style_t + 1]))); |
5601
ca6b459bf488
(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 <celestar@openttd.org>
parents:
5587
diff
changeset
|
2424 h0 = max(h0, ht); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2425 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2426 /* Use lookup table for end-tile based on HighLightStyle direction |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2427 * flip around side (lower/upper, left/right) based on distance */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2428 if (distance == 0) style_t = flip_style_direction[style] * 2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2429 assert(style_t < lengthof(heightdiff_line_by_dir) - 13); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2430 h1 = TileHeight(TILE_ADD(end_tile, ToTileIndexDiff(heightdiff_line_by_dir[12 + style_t]))); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2431 ht = TileHeight(TILE_ADD(end_tile, ToTileIndexDiff(heightdiff_line_by_dir[12 + style_t + 1]))); |
5601
ca6b459bf488
(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 <celestar@openttd.org>
parents:
5587
diff
changeset
|
2432 h1 = max(h1, ht); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2433 } break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2434 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2435 |
5733 | 2436 if (swap) Swap(h0, h1); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2437 /* Minimap shows height in intervals of 50 meters, let's do the same */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2438 return (int)(h1 - h0) * 50; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2439 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2440 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2441 static const StringID measure_strings_length[] = {STR_NULL, STR_MEASURE_LENGTH, STR_MEASURE_LENGTH_HEIGHTDIFF}; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2442 |
6423
72ac8bfaa32f
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas <belugas@openttd.org>
parents:
6248
diff
changeset
|
2443 /** while dragging */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2444 static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y, int method) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2445 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2446 HighLightStyle b; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2447 uint w, h; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2448 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2449 int dx = thd->selstart.x - (thd->selend.x & ~0xF); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2450 int dy = thd->selstart.y - (thd->selend.y & ~0xF); |
7923
504d4b2ecc6c
(svn r11476) -Codechange: rename the function myabs to abs to get rid of an unneeded define
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
2451 w = abs(dx) + 16; |
504d4b2ecc6c
(svn r11476) -Codechange: rename the function myabs to abs to get rid of an unneeded define
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
2452 h = abs(dy) + 16; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2453 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2454 if (TileVirtXY(thd->selstart.x, thd->selstart.y) == TileVirtXY(x, y)) { // check if we're only within one tile |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2455 if (method == VPM_RAILDIRS) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2456 b = GetAutorailHT(x, y); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2457 } else { // rect for autosignals on one tile |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2458 b = HT_RECT; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2459 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2460 } else if (h == 16) { // Is this in X direction? |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2461 if (dx == 16) { // 2x1 special handling |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2462 b = (Check2x1AutoRail(3)) | HT_LINE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2463 } else if (dx == -16) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2464 b = (Check2x1AutoRail(2)) | HT_LINE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2465 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2466 b = HT_LINE | HT_DIR_X; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2467 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2468 y = thd->selstart.y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2469 } else if (w == 16) { // Or Y direction? |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2470 if (dy == 16) { // 2x1 special handling |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2471 b = (Check2x1AutoRail(1)) | HT_LINE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2472 } else if (dy == -16) { // 2x1 other direction |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2473 b = (Check2x1AutoRail(0)) | HT_LINE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2474 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2475 b = HT_LINE | HT_DIR_Y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2476 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2477 x = thd->selstart.x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2478 } else if (w > h * 2) { // still count as x dir? |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2479 b = HT_LINE | HT_DIR_X; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2480 y = thd->selstart.y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2481 } else if (h > w * 2) { // still count as y dir? |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2482 b = HT_LINE | HT_DIR_Y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2483 x = thd->selstart.x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2484 } else { // complicated direction |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2485 int d = w - h; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2486 thd->selend.x = thd->selend.x & ~0xF; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2487 thd->selend.y = thd->selend.y & ~0xF; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2488 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2489 // four cases. |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2490 if (x > thd->selstart.x) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2491 if (y > thd->selstart.y) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2492 // south |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2493 if (d == 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2494 b = (x & 0xF) > (y & 0xF) ? HT_LINE | HT_DIR_VL : HT_LINE | HT_DIR_VR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2495 } else if (d >= 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2496 x = thd->selstart.x + h; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2497 b = HT_LINE | HT_DIR_VL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2498 // return px == py || px == py + 16; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2499 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2500 y = thd->selstart.y + w; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2501 b = HT_LINE | HT_DIR_VR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2502 } // return px == py || px == py - 16; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2503 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2504 // west |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2505 if (d == 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2506 b = (x & 0xF) + (y & 0xF) >= 0x10 ? HT_LINE | HT_DIR_HL : HT_LINE | HT_DIR_HU; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2507 } else if (d >= 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2508 x = thd->selstart.x + h; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2509 b = HT_LINE | HT_DIR_HL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2510 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2511 y = thd->selstart.y - w; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2512 b = HT_LINE | HT_DIR_HU; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2513 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2514 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2515 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2516 if (y > thd->selstart.y) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2517 // east |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2518 if (d == 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2519 b = (x & 0xF) + (y & 0xF) >= 0x10 ? HT_LINE | HT_DIR_HL : HT_LINE | HT_DIR_HU; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2520 } else if (d >= 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2521 x = thd->selstart.x - h; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2522 b = HT_LINE | HT_DIR_HU; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2523 // return px == -py || px == -py - 16; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2524 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2525 y = thd->selstart.y + w; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2526 b = HT_LINE | HT_DIR_HL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2527 } // return px == -py || px == -py + 16; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2528 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2529 // north |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2530 if (d == 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2531 b = (x & 0xF) > (y & 0xF) ? HT_LINE | HT_DIR_VL : HT_LINE | HT_DIR_VR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2532 } else if (d >= 0) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2533 x = thd->selstart.x - h; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2534 b = HT_LINE | HT_DIR_VR; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2535 // return px == py || px == py - 16; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2536 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2537 y = thd->selstart.y - w; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2538 b = HT_LINE | HT_DIR_VL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2539 } //return px == py || px == py + 16; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2540 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2541 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2542 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2543 |
9413
512ea64da840
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents:
9410
diff
changeset
|
2544 if (_settings_client.gui.measure_tooltip) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2545 TileIndex t0 = TileVirtXY(thd->selstart.x, thd->selstart.y); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2546 TileIndex t1 = TileVirtXY(x, y); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2547 uint distance = DistanceManhattan(t0, t1) + 1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2548 byte index = 0; |
7006
933d3ee6d37d
(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 <rubidium@openttd.org>
parents:
6937
diff
changeset
|
2549 uint64 params[2]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2550 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2551 if (distance != 1) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2552 int heightdiff = CalcHeightdiff(b, distance, t0, t1); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2553 /* If we are showing a tooltip for horizontal or vertical drags, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2554 * 2 tiles have a length of 1. To bias towards the ceiling we add |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2555 * one before division. It feels more natural to count 3 lengths as 2 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2556 if ((b & HT_DIR_MASK) != HT_DIR_X && (b & HT_DIR_MASK) != HT_DIR_Y) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2557 distance = (distance + 1) / 2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2558 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2559 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2560 params[index++] = distance; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2561 if (heightdiff != 0) params[index++] = heightdiff; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2562 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2563 |
9781
5ab8b1b156bb
(svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents:
9755
diff
changeset
|
2564 ShowMeasurementTooltips(measure_strings_length[index], index, params); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2565 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2566 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2567 thd->selend.x = x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2568 thd->selend.y = y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2569 thd->next_drawstyle = b; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2570 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2571 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2572 /** |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2573 * Selects tiles while dragging |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2574 * @param x X coordinate of end of selection |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2575 * @param y Y coordinate of end of selection |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2576 * @param method modifies the way tiles are selected. Possible |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2577 * methods are VPM_* in viewport.h */ |
7888
194fee5b8120
(svn r11439) -Codechange: replace some magic numbers by a ViewportPlaceMethod enumified constant. Patch by SmatZ.
rubidium <rubidium@openttd.org>
parents:
7849
diff
changeset
|
2578 void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2579 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2580 int sx, sy; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2581 HighLightStyle style; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2582 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2583 if (x == -1) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2584 _thd.selend.x = -1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2585 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2586 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2587 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2588 /* Special handling of drag in any (8-way) direction */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2589 if (method == VPM_RAILDIRS || method == VPM_SIGNALDIRS) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2590 _thd.selend.x = x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2591 _thd.selend.y = y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2592 CalcRaildirsDrawstyle(&_thd, x, y, method); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2593 return; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2594 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2595 |
7912
357db556fc02
(svn r11465) -Fix: more user-friedly placement in X and Y directions (most noticeable with autoroad)
smatz <smatz@openttd.org>
parents:
7905
diff
changeset
|
2596 /* Needed so level-land is placed correctly */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2597 if (_thd.next_drawstyle == HT_POINT) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2598 x += TILE_SIZE / 2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2599 y += TILE_SIZE / 2; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2600 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2601 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2602 sx = _thd.selstart.x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2603 sy = _thd.selstart.y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2604 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2605 switch (method) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2606 case VPM_X_OR_Y: /* drag in X or Y direction */ |
7923
504d4b2ecc6c
(svn r11476) -Codechange: rename the function myabs to abs to get rid of an unneeded define
skidd13 <skidd13@openttd.org>
parents:
7922
diff
changeset
|
2607 if (abs(sy - y) < abs(sx - x)) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2608 y = sy; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2609 style = HT_DIR_X; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2610 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2611 x = sx; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2612 style = HT_DIR_Y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2613 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2614 goto calc_heightdiff_single_direction; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2615 case VPM_FIX_X: /* drag in Y direction */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2616 x = sx; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2617 style = HT_DIR_Y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2618 goto calc_heightdiff_single_direction; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2619 case VPM_FIX_Y: /* drag in X direction */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2620 y = sy; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2621 style = HT_DIR_X; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2622 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2623 calc_heightdiff_single_direction:; |
9413
512ea64da840
(svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium <rubidium@openttd.org>
parents:
9410
diff
changeset
|
2624 if (_settings_client.gui.measure_tooltip) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2625 TileIndex t0 = TileVirtXY(sx, sy); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2626 TileIndex t1 = TileVirtXY(x, y); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2627 uint distance = DistanceManhattan(t0, t1) + 1; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2628 byte index = 0; |
7006
933d3ee6d37d
(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 <rubidium@openttd.org>
parents:
6937
diff
changeset
|
2629 uint64 params[2]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2630 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2631 if (distance != 1) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2632 /* With current code passing a HT_LINE style to calculate the height |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2633 * difference is enough. However if/when a point-tool is created |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2634 * with this method, function should be called with new_style (below) |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2635 * instead of HT_LINE | style case HT_POINT is handled specially |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2636 * new_style := (_thd.next_drawstyle & HT_RECT) ? HT_LINE | style : _thd.next_drawstyle; */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2637 int heightdiff = CalcHeightdiff(HT_LINE | style, 0, t0, t1); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2638 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2639 params[index++] = distance; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2640 if (heightdiff != 0) params[index++] = heightdiff; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2641 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2642 |
9781
5ab8b1b156bb
(svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents:
9755
diff
changeset
|
2643 ShowMeasurementTooltips(measure_strings_length[index], index, params); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2644 } break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2645 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2646 case VPM_X_AND_Y_LIMITED: { /* drag an X by Y constrained rect area */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2647 int limit = (_thd.sizelimit - 1) * TILE_SIZE; |
7922
ff1975ced735
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13 <skidd13@openttd.org>
parents:
7918
diff
changeset
|
2648 x = sx + Clamp(x - sx, -limit, limit); |
ff1975ced735
(svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13 <skidd13@openttd.org>
parents:
7918
diff
changeset
|
2649 y = sy + Clamp(y - sy, -limit, limit); |
5587
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
2650 } /* Fallthrough */ |
c44c070c5032
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents:
5584
diff
changeset
|
2651 case VPM_X_AND_Y: { /* drag an X by Y area */ |
10626
3189a053f43a
(svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10614
diff
changeset
|
2652 if (_settings_client.gui.measure_tooltip && !_thd.lock_size) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2653 static const StringID measure_strings_area[] = { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2654 STR_NULL, STR_NULL, STR_MEASURE_AREA, STR_MEASURE_AREA_HEIGHTDIFF |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2655 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2656 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2657 TileIndex t0 = TileVirtXY(sx, sy); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2658 TileIndex t1 = TileVirtXY(x, y); |
7970
c49c1607b294
(svn r11526) -Codechange: Rename the function delta fitting to the naming style
skidd13 <skidd13@openttd.org>
parents:
7954
diff
changeset
|
2659 uint dx = Delta(TileX(t0), TileX(t1)) + 1; |
c49c1607b294
(svn r11526) -Codechange: Rename the function delta fitting to the naming style
skidd13 <skidd13@openttd.org>
parents:
7954
diff
changeset
|
2660 uint dy = Delta(TileY(t0), TileY(t1)) + 1; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2661 byte index = 0; |
7006
933d3ee6d37d
(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 <rubidium@openttd.org>
parents:
6937
diff
changeset
|
2662 uint64 params[3]; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2663 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2664 /* If dragging an area (eg dynamite tool) and it is actually a single |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2665 * row/column, change the type to 'line' to get proper calculation for height */ |
8224
c45446125bf0
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents:
8144
diff
changeset
|
2666 style = (HighLightStyle)_thd.next_drawstyle; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2667 if (style & HT_RECT) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2668 if (dx == 1) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2669 style = HT_LINE | HT_DIR_Y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2670 } else if (dy == 1) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2671 style = HT_LINE | HT_DIR_X; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2672 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2673 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2674 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2675 if (dx != 1 || dy != 1) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2676 int heightdiff = CalcHeightdiff(style, 0, t0, t1); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2677 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2678 params[index++] = dx; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2679 params[index++] = dy; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2680 if (heightdiff != 0) params[index++] = heightdiff; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2681 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2682 |
9781
5ab8b1b156bb
(svn r13922) -Codechange: Move measurement-tooltip related stuff out of the general tooltip window.
frosch <frosch@openttd.org>
parents:
9755
diff
changeset
|
2683 ShowMeasurementTooltips(measure_strings_area[index], index, params); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2684 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2685 break; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2686 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2687 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2688 default: NOT_REACHED(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2689 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2690 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2691 _thd.selend.x = x; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2692 _thd.selend.y = y; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2693 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2694 |
9314
93a764ca7ec7
(svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
9274
diff
changeset
|
2695 /** |
93a764ca7ec7
(svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
9274
diff
changeset
|
2696 * Handle the mouse while dragging for placement/resizing. |
93a764ca7ec7
(svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
9274
diff
changeset
|
2697 * @return Boolean whether search for a handler should continue |
93a764ca7ec7
(svn r13182) -Doc: add documentation to mostly rail_gui related functions. Patch by Alberth.
rubidium <rubidium@openttd.org>
parents:
9274
diff
changeset
|
2698 */ |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6117
diff
changeset
|
2699 bool VpHandlePlaceSizingDrag() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2700 { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2701 if (_special_mouse_mode != WSM_SIZING) return true; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2702 |
6423
72ac8bfaa32f
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas <belugas@openttd.org>
parents:
6248
diff
changeset
|
2703 /* stop drag mode if the window has been closed */ |
9166
45b1388fe9ba
(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 <rubidium@openttd.org>
parents:
9147
diff
changeset
|
2704 Window *w = FindWindowById(_thd.window_class, _thd.window_number); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2705 if (w == NULL) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2706 ResetObjectToPlace(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2707 return false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2708 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2709 |
6423
72ac8bfaa32f
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas <belugas@openttd.org>
parents:
6248
diff
changeset
|
2710 /* while dragging execute the drag procedure of the corresponding window (mostly VpSelectTilesWithMethod() ) */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2711 if (_left_button_down) { |
9166
45b1388fe9ba
(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 <rubidium@openttd.org>
parents:
9147
diff
changeset
|
2712 w->OnPlaceDrag(_thd.select_method, _thd.select_proc, GetTileBelowCursor()); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2713 return false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2714 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2715 |
6423
72ac8bfaa32f
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas <belugas@openttd.org>
parents:
6248
diff
changeset
|
2716 /* mouse button released.. |
72ac8bfaa32f
(svn r9559) -Documentation: doxygen and comment changes: 'U' and 'V' now. Almost done. Yeah. I know, I've already said that...
belugas <belugas@openttd.org>
parents:
6248
diff
changeset
|
2717 * keep the selected tool, but reset it to the original mode. */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2718 _special_mouse_mode = WSM_NONE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2719 if (_thd.next_drawstyle == HT_RECT) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2720 _thd.place_mode = VHM_RECT; |
9166
45b1388fe9ba
(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 <rubidium@openttd.org>
parents:
9147
diff
changeset
|
2721 } else if (_thd.select_method == VPM_SIGNALDIRS) { // some might call this a hack... -- Dominik |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2722 _thd.place_mode = VHM_RECT; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2723 } else if (_thd.next_drawstyle & HT_LINE) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2724 _thd.place_mode = VHM_RAIL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2725 } else if (_thd.next_drawstyle & HT_RAIL) { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2726 _thd.place_mode = VHM_RAIL; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2727 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2728 _thd.place_mode = VHM_POINT; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2729 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2730 SetTileSelectSize(1, 1); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2731 |
9166
45b1388fe9ba
(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 <rubidium@openttd.org>
parents:
9147
diff
changeset
|
2732 w->OnPlaceMouseUp(_thd.select_method, _thd.select_proc, _thd.selend, TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2733 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2734 return false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2735 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2736 |
7889
1ed44baec4d2
(svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium <rubidium@openttd.org>
parents:
7888
diff
changeset
|
2737 void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, ViewportHighlightMode mode, Window *w) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2738 { |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5602
diff
changeset
|
2739 SetObjectToPlace(icon, pal, mode, w->window_class, w->window_number); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2740 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2741 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2742 #include "table/animcursors.h" |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2743 |
7889
1ed44baec4d2
(svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium <rubidium@openttd.org>
parents:
7888
diff
changeset
|
2744 void SetObjectToPlace(CursorID icon, SpriteID pal, ViewportHighlightMode mode, WindowClass window_class, WindowNumber window_num) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2745 { |
10626
3189a053f43a
(svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10614
diff
changeset
|
2746 /* unlock position and size */ |
3189a053f43a
(svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10614
diff
changeset
|
2747 _thd.lock_pos = false; |
3189a053f43a
(svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10614
diff
changeset
|
2748 _thd.lock_size = false; |
3189a053f43a
(svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10614
diff
changeset
|
2749 |
8585
2880bcf43f14
(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 <smatz@openttd.org>
parents:
8562
diff
changeset
|
2750 /* undo clicking on button and drag & drop */ |
2880bcf43f14
(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 <smatz@openttd.org>
parents:
8562
diff
changeset
|
2751 if (_thd.place_mode != VHM_NONE || _special_mouse_mode == WSM_DRAGDROP) { |
9244
07d38b0d61ce
(svn r13110) -Fix [FS#2018]: some toolbar buttons not being unpressed properly.
rubidium <rubidium@openttd.org>
parents:
9238
diff
changeset
|
2752 Window *w = FindWindowById(_thd.window_class, _thd.window_number); |
07d38b0d61ce
(svn r13110) -Fix [FS#2018]: some toolbar buttons not being unpressed properly.
rubidium <rubidium@openttd.org>
parents:
9238
diff
changeset
|
2753 if (w != NULL) { |
07d38b0d61ce
(svn r13110) -Fix [FS#2018]: some toolbar buttons not being unpressed properly.
rubidium <rubidium@openttd.org>
parents:
9238
diff
changeset
|
2754 /* Call the abort function, but set the window class to something |
07d38b0d61ce
(svn r13110) -Fix [FS#2018]: some toolbar buttons not being unpressed properly.
rubidium <rubidium@openttd.org>
parents:
9238
diff
changeset
|
2755 * that will never be used to avoid infinite loops. Setting it to |
07d38b0d61ce
(svn r13110) -Fix [FS#2018]: some toolbar buttons not being unpressed properly.
rubidium <rubidium@openttd.org>
parents:
9238
diff
changeset
|
2756 * the 'next' window class must not be done because recursion into |
07d38b0d61ce
(svn r13110) -Fix [FS#2018]: some toolbar buttons not being unpressed properly.
rubidium <rubidium@openttd.org>
parents:
9238
diff
changeset
|
2757 * this function might in some cases reset the newly set object to |
07d38b0d61ce
(svn r13110) -Fix [FS#2018]: some toolbar buttons not being unpressed properly.
rubidium <rubidium@openttd.org>
parents:
9238
diff
changeset
|
2758 * place or not properly reset the original selection. */ |
07d38b0d61ce
(svn r13110) -Fix [FS#2018]: some toolbar buttons not being unpressed properly.
rubidium <rubidium@openttd.org>
parents:
9238
diff
changeset
|
2759 _thd.window_class = WC_INVALID; |
07d38b0d61ce
(svn r13110) -Fix [FS#2018]: some toolbar buttons not being unpressed properly.
rubidium <rubidium@openttd.org>
parents:
9238
diff
changeset
|
2760 w->OnPlaceObjectAbort(); |
07d38b0d61ce
(svn r13110) -Fix [FS#2018]: some toolbar buttons not being unpressed properly.
rubidium <rubidium@openttd.org>
parents:
9238
diff
changeset
|
2761 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2762 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2763 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2764 SetTileSelectSize(1, 1); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2765 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2766 _thd.make_square_red = false; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2767 |
7889
1ed44baec4d2
(svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium <rubidium@openttd.org>
parents:
7888
diff
changeset
|
2768 if (mode == VHM_DRAG) { // VHM_DRAG is for dragdropping trains in the depot window |
1ed44baec4d2
(svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium <rubidium@openttd.org>
parents:
7888
diff
changeset
|
2769 mode = VHM_NONE; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2770 _special_mouse_mode = WSM_DRAGDROP; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2771 } else { |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2772 _special_mouse_mode = WSM_NONE; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2773 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2774 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2775 _thd.place_mode = mode; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2776 _thd.window_class = window_class; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2777 _thd.window_number = window_num; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2778 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2779 if (mode == VHM_SPECIAL) // special tools, like tunnels or docks start with presizing mode |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2780 VpStartPreSizing(); |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2781 |
9238
cef3cbdc68c6
(svn r13104) -Codechange: make ResetObjectToPlace safe to be called recursively via the OnPlaceObjectAbort callback and use this knowledge to simplify closing some windows.
rubidium <rubidium@openttd.org>
parents:
9192
diff
changeset
|
2782 if ((int)icon < 0) { |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2783 SetAnimatedMouseCursor(_animcursors[~icon]); |
9238
cef3cbdc68c6
(svn r13104) -Codechange: make ResetObjectToPlace safe to be called recursively via the OnPlaceObjectAbort callback and use this knowledge to simplify closing some windows.
rubidium <rubidium@openttd.org>
parents:
9192
diff
changeset
|
2784 } else { |
5668
3d6d9bff3dd8
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138 <peter1138@openttd.org>
parents:
5602
diff
changeset
|
2785 SetMouseCursor(icon, pal); |
9238
cef3cbdc68c6
(svn r13104) -Codechange: make ResetObjectToPlace safe to be called recursively via the OnPlaceObjectAbort callback and use this knowledge to simplify closing some windows.
rubidium <rubidium@openttd.org>
parents:
9192
diff
changeset
|
2786 } |
cef3cbdc68c6
(svn r13104) -Codechange: make ResetObjectToPlace safe to be called recursively via the OnPlaceObjectAbort callback and use this knowledge to simplify closing some windows.
rubidium <rubidium@openttd.org>
parents:
9192
diff
changeset
|
2787 |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2788 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2789 |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6117
diff
changeset
|
2790 void ResetObjectToPlace() |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2791 { |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5733
diff
changeset
|
2792 SetObjectToPlace(SPR_CURSOR_MOUSE, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2793 } |