author | tron |
Mon, 14 Feb 2005 18:55:10 +0000 | |
changeset 1370 | c86b2c30fd01 |
parent 1350 | fd0136012af1 |
child 1511 | 5917a04566df |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
1349
15979a2e9001
(svn r1853) Move spritecache function declarations into a header of their own and use SpriteID as parameter type where appropriate
tron
parents:
1214
diff
changeset
|
3 |
#include "spritecache.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
500
diff
changeset
|
4 |
#include "table/strings.h" |
679
04ca2cd69420
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
541
diff
changeset
|
5 |
#include "map.h" |
1209
2e00193652b2
(svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents:
1093
diff
changeset
|
6 |
#include "tile.h" |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
7 |
#include "gui.h" |
0 | 8 |
#include "window.h" |
9 |
#include "gfx.h" |
|
10 |
#include "viewport.h" |
|
11 |
#include "player.h" |
|
12 |
#include "vehicle.h" |
|
13 |
#include "town.h" |
|
337
cbe0c766c947
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
193
diff
changeset
|
14 |
#include "sound.h" |
0 | 15 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
16 |
static const Widget _smallmap_widgets[] = { |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
17 |
{ WWT_TEXTBTN, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
18 |
{ WWT_CAPTION, RESIZE_RIGHT, 13, 11, 433, 0, 13, STR_00B0_MAP,STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
19 |
{ WWT_STICKYBOX, RESIZE_LR, 13, 434, 445, 0, 13, 0x0, STR_STICKY_BUTTON}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
20 |
{ WWT_IMGBTN, RESIZE_RB, 13, 0, 445, 14, 257, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
21 |
{ WWT_6, RESIZE_RB, 13, 2, 443, 16, 255, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
22 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 380, 401, 258, 279, 0x2E2, STR_0191_SHOW_LAND_CONTOURS_ON_MAP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
23 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 402, 423, 258, 279, 0x2E3, STR_0192_SHOW_VEHICLES_ON_MAP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
24 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 424, 445, 258, 279, 0x2E5, STR_0193_SHOW_INDUSTRIES_ON_MAP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
25 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 380, 401, 280, 301, 0x2E4, STR_0194_SHOW_TRANSPORT_ROUTES_ON}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
26 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 402, 423, 280, 301, 0x2E6, STR_0195_SHOW_VEGETATION_ON_MAP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
27 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 424, 445, 280, 301, 0x2E7, STR_0196_SHOW_LAND_OWNERS_ON_MAP}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
28 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 358, 379, 258, 279, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
29 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 358, 379, 280, 301, 0xFED, STR_0197_TOGGLE_TOWN_NAMES_ON_OFF}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
30 |
{ WWT_IMGBTN, RESIZE_RTB, 13, 0, 357, 258, 301, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
31 |
{ WWT_PANEL, RESIZE_RTB, 13, 0, 433, 302, 313, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
32 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 13, 434, 445, 302, 313, 0x0, STR_RESIZE_BUTTON}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
154
diff
changeset
|
33 |
{ WIDGETS_END}, |
0 | 34 |
}; |
35 |
||
36 |
static int _smallmap_type; |
|
37 |
static bool _smallmap_show_towns = true; |
|
38 |
||
39 |
#define MK(a,b) a,b |
|
40 |
#define MKEND() 0xffff |
|
41 |
#define MS(a,b) (a|0x100),b |
|
42 |
||
43 |
static const uint16 _legend_land_contours[] = { |
|
44 |
MK(0x5A,STR_00F0_100M), |
|
45 |
MK(0x5C,STR_00F1_200M), |
|
46 |
MK(0x5E,STR_00F2_300M), |
|
47 |
MK(0x1F,STR_00F3_400M), |
|
48 |
MK(0x27,STR_00F4_500M), |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
49 |
|
0 | 50 |
MS(0xD7,STR_00EB_ROADS), |
51 |
MK(0x0A,STR_00EC_RAILROADS), |
|
52 |
MK(0x98,STR_00ED_STATIONS_AIRPORTS_DOCKS), |
|
53 |
MK(0xB5,STR_00EE_BUILDINGS_INDUSTRIES), |
|
54 |
MK(0x0F,STR_00EF_VEHICLES), |
|
55 |
MKEND() |
|
56 |
}; |
|
57 |
||
58 |
static const uint16 _legend_vehicles[] = { |
|
59 |
MK(0xB8,STR_00F5_TRAINS), |
|
60 |
MK(0xBF,STR_00F6_ROAD_VEHICLES), |
|
61 |
MK(0x98,STR_00F7_SHIPS), |
|
62 |
MK(0x0F,STR_00F8_AIRCRAFT), |
|
63 |
MS(0xD7,STR_00F9_TRANSPORT_ROUTES), |
|
64 |
MK(0xB5,STR_00EE_BUILDINGS_INDUSTRIES), |
|
65 |
MKEND() |
|
66 |
}; |
|
67 |
||
68 |
static const uint16 _legend_industries_normal[] = { |
|
69 |
MK(0xD7,STR_00FA_COAL_MINE), |
|
70 |
MK(0xB8,STR_00FB_POWER_STATION), |
|
71 |
MK(0x56,STR_00FC_FOREST), |
|
72 |
MK(0xC2,STR_00FD_SAWMILL), |
|
73 |
MK(0xBF,STR_00FE_OIL_REFINERY), |
|
74 |
MK(0x0F,STR_0105_BANK), |
|
75 |
||
76 |
MS(0x30,STR_00FF_FARM), |
|
77 |
MK(0xAE,STR_0100_FACTORY), |
|
78 |
MK(0x98,STR_0102_OIL_WELLS), |
|
79 |
MK(0x37,STR_0103_IRON_ORE_MINE), |
|
80 |
MK(0x0A,STR_0104_STEEL_MILL), |
|
81 |
MKEND() |
|
82 |
}; |
|
83 |
||
84 |
static const uint16 _legend_industries_hilly[] = { |
|
85 |
MK(0xD7,STR_00FA_COAL_MINE), |
|
86 |
MK(0xB8,STR_00FB_POWER_STATION), |
|
87 |
MK(0x56,STR_00FC_FOREST), |
|
88 |
MK(0x0A,STR_0106_PAPER_MILL), |
|
89 |
MK(0xBF,STR_00FE_OIL_REFINERY), |
|
90 |
MK(0x37,STR_0108_FOOD_PROCESSING_PLANT), |
|
91 |
MS(0x30,STR_00FF_FARM), |
|
92 |
||
93 |
MK(0xAE,STR_0101_PRINTING_WORKS), |
|
94 |
MK(0x98,STR_0102_OIL_WELLS), |
|
95 |
MK(0xC2,STR_0107_GOLD_MINE), |
|
96 |
MK(0x0F,STR_0105_BANK), |
|
97 |
MKEND() |
|
98 |
}; |
|
99 |
||
100 |
static const uint16 _legend_industries_desert[] = { |
|
101 |
MK(0xBF,STR_00FE_OIL_REFINERY), |
|
102 |
MK(0x98,STR_0102_OIL_WELLS), |
|
103 |
MK(0x0F,STR_0105_BANK), |
|
104 |
MK(0xB8,STR_0109_DIAMOND_MINE), |
|
105 |
MK(0x37,STR_0108_FOOD_PROCESSING_PLANT), |
|
106 |
MK(0x0A,STR_010A_COPPER_ORE_MINE), |
|
107 |
MK(0x30,STR_00FF_FARM), |
|
108 |
MS(0x56,STR_010B_FRUIT_PLANTATION), |
|
109 |
||
110 |
MK(0x27,STR_010C_RUBBER_PLANTATION), |
|
111 |
MK(0x25,STR_010D_WATER_SUPPLY), |
|
112 |
MK(0xD0,STR_010E_WATER_TOWER), |
|
113 |
MK(0xAE,STR_0100_FACTORY), |
|
114 |
MK(0xC2,STR_010F_LUMBER_MILL), |
|
115 |
MKEND() |
|
116 |
}; |
|
117 |
||
118 |
static const uint16 _legend_industries_candy[] = { |
|
119 |
MK(0x30,STR_0110_COTTON_CANDY_FOREST), |
|
120 |
MK(0xAE,STR_0111_CANDY_FACTORY), |
|
121 |
MK(0x27,STR_0112_BATTERY_FARM), |
|
122 |
MK(0x37,STR_0113_COLA_WELLS), |
|
123 |
MK(0xD0,STR_0114_TOY_SHOP), |
|
124 |
MK(0x0A,STR_0115_TOY_FACTORY), |
|
125 |
MS(0x25,STR_0116_PLASTIC_FOUNTAINS), |
|
126 |
||
127 |
MK(0xB8,STR_0117_FIZZY_DRINK_FACTORY), |
|
128 |
MK(0x98,STR_0118_BUBBLE_GENERATOR), |
|
129 |
MK(0xC2,STR_0119_TOFFEE_QUARRY), |
|
130 |
MK(0x0F,STR_011A_SUGAR_MINE), |
|
131 |
MKEND() |
|
132 |
}; |
|
133 |
||
134 |
static const uint16 _legend_routes[] = { |
|
135 |
MK(0xD7,STR_00EB_ROADS), |
|
136 |
MK(0x0A,STR_00EC_RAILROADS), |
|
137 |
MK(0xB5,STR_00EE_BUILDINGS_INDUSTRIES), |
|
138 |
MS(0x56,STR_011B_RAILROAD_STATION), |
|
139 |
||
140 |
MK(0xC2,STR_011C_TRUCK_LOADING_BAY), |
|
141 |
MK(0xBF,STR_011D_BUS_STATION), |
|
142 |
MK(0xB8,STR_011E_AIRPORT_HELIPORT), |
|
143 |
MK(0x98,STR_011F_DOCK), |
|
144 |
MKEND() |
|
145 |
}; |
|
146 |
||
147 |
static const uint16 _legend_vegetation[] = { |
|
148 |
MK(0x52,STR_0120_ROUGH_LAND), |
|
149 |
MK(0x54,STR_0121_GRASS_LAND), |
|
150 |
MK(0x37,STR_0122_BARE_LAND), |
|
151 |
MK(0x25,STR_0123_FIELDS), |
|
152 |
MK(0x57,STR_0124_TREES), |
|
153 |
MK(0xD0,STR_00FC_FOREST), |
|
154 |
MS(0x0A,STR_0125_ROCKS), |
|
155 |
||
156 |
MK(0xC2,STR_012A_DESERT), |
|
157 |
MK(0x98,STR_012B_SNOW), |
|
158 |
MK(0xD7,STR_00F9_TRANSPORT_ROUTES), |
|
159 |
MK(0xB5,STR_00EE_BUILDINGS_INDUSTRIES), |
|
160 |
MKEND() |
|
161 |
}; |
|
162 |
||
163 |
static const uint16 _legend_land_owners[] = { |
|
164 |
MK(0xCA,STR_0126_WATER), |
|
165 |
MK(0x54,STR_0127_NO_OWNER), |
|
166 |
MK(0xB4,STR_0128_TOWNS), |
|
167 |
MK(0x20,STR_0129_INDUSTRIES), |
|
168 |
MKEND() |
|
169 |
}; |
|
170 |
#undef MK |
|
171 |
#undef MS |
|
172 |
#undef MKEND |
|
173 |
||
174 |
||
175 |
enum { IND_OFFS = 6 }; |
|
176 |
static const uint16 * const _legend_table[] = { |
|
177 |
_legend_land_contours, |
|
178 |
_legend_vehicles, |
|
179 |
NULL, |
|
180 |
_legend_routes, |
|
181 |
_legend_vegetation, |
|
182 |
_legend_land_owners, |
|
183 |
||
184 |
_legend_industries_normal, |
|
185 |
_legend_industries_hilly, |
|
186 |
_legend_industries_desert, |
|
187 |
_legend_industries_candy, |
|
188 |
}; |
|
189 |
||
190 |
#if defined(TTD_ALIGNMENT_4) |
|
500
8e52f7797b48
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
337
diff
changeset
|
191 |
static inline void WRITE_PIXELS(void *dst, uint32 val) |
0 | 192 |
{ |
193 |
byte *d = (byte*)dst; |
|
194 |
# if defined(TTD_BIG_ENDIAN) |
|
195 |
d[0] = (byte)(val >> 24); |
|
196 |
d[1] = (byte)(val >> 16); |
|
197 |
d[2] = (byte)(val >> 8); |
|
198 |
d[3] = (byte)(val >> 0); |
|
199 |
# elif defined(TTD_LITTLE_ENDIAN) |
|
200 |
d[0] = (byte)(val >> 0); |
|
201 |
d[1] = (byte)(val >> 8); |
|
202 |
d[2] = (byte)(val >> 16); |
|
203 |
d[3] = (byte)(val >> 24); |
|
204 |
# endif |
|
205 |
} |
|
206 |
||
207 |
/* need to use OR, otherwise we will overwrite the wrong pixels at the edges :( */ |
|
500
8e52f7797b48
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
337
diff
changeset
|
208 |
static inline void WRITE_PIXELS_OR(void *dst, uint32 val) |
0 | 209 |
{ |
210 |
byte *d = (byte*)dst; |
|
211 |
# if defined(TTD_BIG_ENDIAN) |
|
212 |
d[0] |= (byte)(val >> 24); |
|
213 |
d[1] |= (byte)(val >> 16); |
|
214 |
d[2] |= (byte)(val >> 8); |
|
215 |
d[3] |= (byte)(val >> 0); |
|
216 |
# elif defined(TTD_LITTLE_ENDIAN) |
|
217 |
d[0] |= (byte)(val >> 0); |
|
218 |
d[1] |= (byte)(val >> 8); |
|
219 |
d[2] |= (byte)(val >> 16); |
|
220 |
d[3] |= (byte)(val >> 24); |
|
221 |
# endif |
|
222 |
} |
|
223 |
#else |
|
224 |
# define WRITE_PIXELS(dst, val) *(uint32*)(dst) = (val); |
|
225 |
# define WRITE_PIXELS_OR(dst,val) *(uint32*)(dst) |= (val); |
|
226 |
#endif |
|
227 |
||
228 |
#if defined(TTD_BIG_ENDIAN) |
|
229 |
# define MKCOLOR(x) BSWAP32(x) |
|
230 |
#elif defined(TTD_LITTLE_ENDIAN) |
|
231 |
# define MKCOLOR(x) (x) |
|
232 |
#endif |
|
233 |
||
234 |
static const uint32 _map_height_bits[16] = { |
|
235 |
MKCOLOR(0x5A5A5A5A), |
|
236 |
MKCOLOR(0x5A5B5A5B), |
|
237 |
MKCOLOR(0x5B5B5B5B), |
|
238 |
MKCOLOR(0x5B5C5B5C), |
|
239 |
MKCOLOR(0x5C5C5C5C), |
|
240 |
MKCOLOR(0x5C5D5C5D), |
|
241 |
MKCOLOR(0x5D5D5D5D), |
|
242 |
MKCOLOR(0x5D5E5D5E), |
|
243 |
MKCOLOR(0x5E5E5E5E), |
|
244 |
MKCOLOR(0x5E5F5E5F), |
|
245 |
MKCOLOR(0x5F5F5F5F), |
|
246 |
MKCOLOR(0x5F1F5F1F), |
|
247 |
MKCOLOR(0x1F1F1F1F), |
|
248 |
MKCOLOR(0x1F271F27), |
|
249 |
MKCOLOR(0x27272727), |
|
250 |
MKCOLOR(0x27272727), |
|
251 |
}; |
|
252 |
||
253 |
static const uint32 _smallmap_contours_andor[12][2] = { |
|
254 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
255 |
{MKCOLOR(0x000A0A00),MKCOLOR(0xFF0000FF)}, |
|
256 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
257 |
{MKCOLOR(0x00B5B500),MKCOLOR(0xFF0000FF)}, |
|
258 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
259 |
{MKCOLOR(0x98989898),MKCOLOR(0x00000000)}, |
|
260 |
{MKCOLOR(0xCACACACA),MKCOLOR(0x00000000)}, |
|
261 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
262 |
{MKCOLOR(0xB5B5B5B5),MKCOLOR(0x00000000)}, |
|
263 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
264 |
{MKCOLOR(0x00B5B500),MKCOLOR(0xFF0000FF)}, |
|
265 |
{MKCOLOR(0x000A0A00),MKCOLOR(0xFF0000FF)}, |
|
266 |
}; |
|
267 |
||
268 |
static const uint32 _smallmap_vehicles_andor[12][2] = { |
|
269 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
270 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
271 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
272 |
{MKCOLOR(0x00B5B500),MKCOLOR(0xFF0000FF)}, |
|
273 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
274 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
275 |
{MKCOLOR(0xCACACACA),MKCOLOR(0x00000000)}, |
|
276 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
277 |
{MKCOLOR(0xB5B5B5B5),MKCOLOR(0x00000000)}, |
|
278 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
279 |
{MKCOLOR(0x00B5B500),MKCOLOR(0xFF0000FF)}, |
|
280 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
281 |
}; |
|
282 |
||
283 |
static const uint32 _smallmap_vegetation_andor[12][2] = { |
|
284 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
285 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
286 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
287 |
{MKCOLOR(0x00B5B500),MKCOLOR(0xFF0000FF)}, |
|
288 |
{MKCOLOR(0x00575700),MKCOLOR(0xFF0000FF)}, |
|
289 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
290 |
{MKCOLOR(0xCACACACA),MKCOLOR(0x00000000)}, |
|
291 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
292 |
{MKCOLOR(0xB5B5B5B5),MKCOLOR(0x00000000)}, |
|
293 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
294 |
{MKCOLOR(0x00B5B500),MKCOLOR(0xFF0000FF)}, |
|
295 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
296 |
}; |
|
297 |
||
500
8e52f7797b48
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
337
diff
changeset
|
298 |
static inline uint32 GetSmallMapCountoursPixels(uint tile) |
0 | 299 |
{ |
300 |
uint t; |
|
301 |
||
1214
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1209
diff
changeset
|
302 |
t = GetTileType(tile); |
0 | 303 |
if (t == MP_TUNNELBRIDGE) { |
304 |
t = _map5[tile]; |
|
305 |
if ((t & 0x80) == 0) t>>=1; |
|
306 |
if ((t & 6) == 0) { |
|
307 |
t = MP_RAILWAY; |
|
308 |
} else if ((t & 6) == 2) { |
|
309 |
t = MP_STREET; |
|
310 |
} else { |
|
311 |
t = MP_WATER; |
|
312 |
} |
|
313 |
} |
|
314 |
||
1044
63e0601a43cc
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1035
diff
changeset
|
315 |
return (_map_height_bits[TileHeight(tile)] & _smallmap_contours_andor[t][1]) | _smallmap_contours_andor[t][0]; |
0 | 316 |
} |
317 |
||
318 |
static void DrawSmallMapContours(byte *dst, uint xc, uint yc, int pitch, int reps, uint32 mask) |
|
319 |
{ |
|
320 |
do { |
|
856
918759cedca8
(svn r1337) Use MapMax[XY]() (or MapSize[XY]() if appropriate) instead of TILE_MAX_[XY]
tron
parents:
758
diff
changeset
|
321 |
if (xc < MapMaxX() && yc < MapMaxY()) |
12 | 322 |
if (dst > _screen.dst_ptr && dst < (_screen.dst_ptr + _screen.width * _screen.height - _screen.width) ) |
323 |
WRITE_PIXELS_OR( dst, GetSmallMapCountoursPixels(TILE_XY(xc,yc)) & mask ); |
|
0 | 324 |
} while (xc++,yc++,dst+=pitch,--reps != 0); |
325 |
} |
|
326 |
||
327 |
||
500
8e52f7797b48
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
337
diff
changeset
|
328 |
static inline uint32 GetSmallMapVehiclesPixels(uint tile) |
0 | 329 |
{ |
330 |
uint t; |
|
331 |
||
1214
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1209
diff
changeset
|
332 |
t = GetTileType(tile); |
0 | 333 |
if (t == MP_TUNNELBRIDGE) { |
334 |
t = _map5[tile]; |
|
335 |
if ((t & 0x80) == 0) t>>=1; |
|
336 |
if ((t & 6) == 0) { |
|
337 |
t = MP_RAILWAY; |
|
338 |
} else if ((t & 6) == 2) { |
|
339 |
t = MP_STREET; |
|
340 |
} else { |
|
341 |
t = MP_WATER; |
|
342 |
} |
|
343 |
} |
|
344 |
return (MKCOLOR(0x54545454) & _smallmap_vehicles_andor[t][1]) | _smallmap_vehicles_andor[t][0]; |
|
345 |
} |
|
346 |
||
347 |
||
348 |
static void DrawSmallMapVehicles(byte *dst, uint xc, uint yc, int pitch, int reps, uint32 mask) |
|
349 |
{ |
|
350 |
do { |
|
856
918759cedca8
(svn r1337) Use MapMax[XY]() (or MapSize[XY]() if appropriate) instead of TILE_MAX_[XY]
tron
parents:
758
diff
changeset
|
351 |
if (xc < MapMaxX() && yc < MapMaxY()) |
0 | 352 |
WRITE_PIXELS_OR( dst, GetSmallMapVehiclesPixels(TILE_XY(xc,yc)) & mask ); |
353 |
} while (xc++,yc++,dst+=pitch,--reps != 0); |
|
354 |
} |
|
355 |
||
356 |
static const byte _industry_smallmap_colors[175] = { |
|
357 |
215,215,215,215,215,215,215,184, |
|
358 |
184,184,184,194,194,194,194,194, |
|
359 |
86, 86,191,191,191,191,191,191, |
|
360 |
152,152,152,152,152,152,152,152, |
|
361 |
152, 48, 48, 48, 48, 48, 48,174, |
|
362 |
174,174,174,174,174,174,174, 10, |
|
363 |
10, 10, 10, 10, 10, 10, 10, 10, |
|
364 |
10, 10, 15, 15, 55, 55, 55, 55, |
|
365 |
10, 10, 10, 10, 10, 10, 10, 10, |
|
366 |
194,194,194,194,194,194,194,194, |
|
367 |
194,194,194,194,194,194,194,194, |
|
368 |
194, 15, 15,184,184,184,184,184, |
|
369 |
184,184,184,184, 55, 55, 55, 55, |
|
370 |
55, 55, 55, 55, 55, 55, 55, 55, |
|
371 |
55, 55, 55, 55, 86, 39, 37, 37, |
|
372 |
208,174,174,174,174,194,194,194, |
|
373 |
194, 48, 48,174,174,174,174, 39, |
|
374 |
39, 55,208,208,208,208, 10, 10, |
|
375 |
10, 10, 10, 10, 37, 37, 37, 37, |
|
376 |
37, 37, 37, 37,184,184,184,184, |
|
377 |
152,152,152,152,194,194,194, 15, |
|
378 |
15, 15, 15, 15, 15, 15, 15, |
|
379 |
}; |
|
380 |
||
500
8e52f7797b48
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
337
diff
changeset
|
381 |
static inline uint32 GetSmallMapIndustriesPixels(uint tile) |
0 | 382 |
{ |
383 |
int t; |
|
384 |
||
1214
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1209
diff
changeset
|
385 |
t = GetTileType(tile); |
0 | 386 |
if (t == MP_INDUSTRY) { |
387 |
byte color = _industry_smallmap_colors[_map5[tile]]; |
|
388 |
return color + (color << 8) + (color << 16) + (color << 24); |
|
389 |
} else { |
|
390 |
if (t == MP_TUNNELBRIDGE) { |
|
391 |
t = _map5[tile]; |
|
392 |
if ((t & 0x80) == 0) t>>=1; |
|
393 |
if ((t & 6) == 0) { |
|
394 |
t = MP_RAILWAY; |
|
395 |
} else if ((t & 6) == 2) { |
|
396 |
t = MP_STREET; |
|
397 |
} else { |
|
398 |
t = MP_WATER; |
|
399 |
} |
|
400 |
} |
|
401 |
return ((MKCOLOR(0x54545454) & _smallmap_vehicles_andor[t][1]) | _smallmap_vehicles_andor[t][0]); |
|
402 |
} |
|
403 |
} |
|
404 |
||
405 |
static void DrawSmallMapIndustries(byte *dst, uint xc, uint yc, int pitch, int reps, uint32 mask) |
|
406 |
{ |
|
407 |
do { |
|
856
918759cedca8
(svn r1337) Use MapMax[XY]() (or MapSize[XY]() if appropriate) instead of TILE_MAX_[XY]
tron
parents:
758
diff
changeset
|
408 |
if (xc < MapMaxX() && yc < MapMaxY()) |
0 | 409 |
WRITE_PIXELS_OR(dst, GetSmallMapIndustriesPixels(TILE_XY(xc,yc)) & mask); |
410 |
} while (xc++,yc++,dst+=pitch,--reps != 0); |
|
411 |
} |
|
412 |
||
500
8e52f7797b48
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
337
diff
changeset
|
413 |
static inline uint32 GetSmallMapRoutesPixels(uint tile) |
0 | 414 |
{ |
415 |
int t; |
|
416 |
uint32 bits; |
|
417 |
||
1214
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1209
diff
changeset
|
418 |
t = GetTileType(tile); |
0 | 419 |
if (t == MP_STATION) { |
420 |
byte m5 = _map5[tile]; |
|
421 |
(bits = MKCOLOR(0x56565656), m5 < 8) || // 8 - railroad station (green) |
|
422 |
(bits = MKCOLOR(0xB8B8B8B8), m5 < 0x43) || // 67 - airport (red) |
|
423 |
(bits = MKCOLOR(0xC2C2C2C2), m5 < 0x47) || // 71 - truck loading bay (orange) |
|
424 |
(bits = MKCOLOR(0xBFBFBFBF), m5 < 0x4B) || // 75 - bus station (yellow) |
|
425 |
(bits = MKCOLOR(0x98989898), m5 < 0x53) || // 83 - docks (blue) |
|
426 |
(bits = MKCOLOR(0xB8B8B8B8), m5 < 0x73) || // 115 - airport (red) (new airports) |
|
427 |
(bits = MKCOLOR(0xFFFFFFFF), true); // all others |
|
428 |
} else { |
|
429 |
if (t == MP_TUNNELBRIDGE) { |
|
430 |
t = _map5[tile]; |
|
431 |
if ((t & 0x80) == 0) t>>=1; |
|
432 |
if ((t & 6) == 0) { |
|
433 |
t = MP_RAILWAY; |
|
434 |
} else if ((t & 6) == 2) { |
|
435 |
t = MP_STREET; |
|
436 |
} else { |
|
437 |
t = MP_WATER; |
|
438 |
} |
|
439 |
} |
|
440 |
// ground color |
|
441 |
bits = ((MKCOLOR(0x54545454) & _smallmap_contours_andor[t][1]) | _smallmap_contours_andor[t][0]); |
|
442 |
} |
|
443 |
return bits; |
|
444 |
} |
|
445 |
||
446 |
static void DrawSmallMapRoutes(byte *dst, uint xc, uint yc, int pitch, int reps, uint32 mask) |
|
447 |
{ |
|
448 |
do { |
|
856
918759cedca8
(svn r1337) Use MapMax[XY]() (or MapSize[XY]() if appropriate) instead of TILE_MAX_[XY]
tron
parents:
758
diff
changeset
|
449 |
if (xc < MapMaxX() && yc < MapMaxY()) |
0 | 450 |
WRITE_PIXELS_OR(dst, GetSmallMapRoutesPixels(TILE_XY(xc,yc)) & mask); |
451 |
} while (xc++,yc++,dst+=pitch,--reps != 0); |
|
452 |
} |
|
453 |
||
454 |
static const uint32 _vegetation_clear_bits[4 + 7] = { |
|
455 |
MKCOLOR(0x37373737), |
|
456 |
MKCOLOR(0x37373737), |
|
457 |
MKCOLOR(0x37373737), |
|
458 |
MKCOLOR(0x54545454), |
|
459 |
||
460 |
MKCOLOR(0x52525252), |
|
461 |
MKCOLOR(0x0A0A0A0A), |
|
462 |
MKCOLOR(0x25252525), |
|
463 |
MKCOLOR(0x98989898), |
|
464 |
MKCOLOR(0xC2C2C2C2), |
|
465 |
MKCOLOR(0x54545454), |
|
466 |
MKCOLOR(0x54545454), |
|
467 |
}; |
|
468 |
||
500
8e52f7797b48
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
337
diff
changeset
|
469 |
static inline uint32 GetSmallMapVegetationPixels(uint tile) |
0 | 470 |
{ |
471 |
int i,t; |
|
472 |
uint32 bits; |
|
473 |
||
1214
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1209
diff
changeset
|
474 |
t = GetTileType(tile); |
0 | 475 |
if (t == MP_CLEAR) { |
476 |
i = (_map5[tile] & 0x1F) - 4; |
|
477 |
if (i >= 0) i = (i >> 2); |
|
478 |
bits = _vegetation_clear_bits[i + 4]; |
|
479 |
} else if (t == MP_INDUSTRY) { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
480 |
bits = IS_BYTE_INSIDE(_map5[tile], 0x10, 0x12) ? MKCOLOR(0xD0D0D0D0) : MKCOLOR(0xB5B5B5B5); |
0 | 481 |
} else if (t == MP_TREES) { |
482 |
bits = MKCOLOR(0x54575754); |
|
483 |
if ((_map2[tile] & 0x30) == 0x20) |
|
484 |
bits = (_opt.landscape == LT_HILLY) ? MKCOLOR(0x98575798) : MKCOLOR(0xC25757C2); |
|
485 |
} else { |
|
486 |
if (t == MP_TUNNELBRIDGE) { |
|
487 |
t = _map5[tile]; |
|
488 |
if ((t & 0x80) == 0) t>>=1; |
|
489 |
if ((t & 6) == 0) { |
|
490 |
t = MP_RAILWAY; |
|
491 |
} else if ((t & 6) == 2) { |
|
492 |
t = MP_STREET; |
|
493 |
} else { |
|
494 |
t = MP_WATER; |
|
495 |
} |
|
496 |
} |
|
497 |
bits = ((MKCOLOR(0x54545454) & _smallmap_vehicles_andor[t][1]) | _smallmap_vehicles_andor[t][0]); |
|
498 |
} |
|
499 |
||
500 |
return bits; |
|
501 |
} |
|
502 |
||
503 |
||
504 |
static void DrawSmallMapVegetation(byte *dst, uint xc, uint yc, int pitch, int reps, uint32 mask) |
|
505 |
{ |
|
506 |
do { |
|
856
918759cedca8
(svn r1337) Use MapMax[XY]() (or MapSize[XY]() if appropriate) instead of TILE_MAX_[XY]
tron
parents:
758
diff
changeset
|
507 |
if (xc < MapMaxX() && yc < MapMaxY()) |
0 | 508 |
WRITE_PIXELS_OR(dst, GetSmallMapVegetationPixels(TILE_XY(xc,yc)) & mask); |
509 |
} while (xc++,yc++,dst+=pitch,--reps != 0); |
|
510 |
} |
|
511 |
||
512 |
||
1092 | 513 |
static uint32 _owner_colors[256]; |
0 | 514 |
|
500
8e52f7797b48
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
337
diff
changeset
|
515 |
static inline uint32 GetSmallMapOwnerPixels(uint tile) |
0 | 516 |
{ |
517 |
int t; |
|
518 |
||
1214
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1209
diff
changeset
|
519 |
t = GetTileType(tile); |
0 | 520 |
if (t == MP_HOUSE || _map_owner[tile] == OWNER_TOWN) { |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
521 |
t = 0x80; |
0 | 522 |
} else if (t == MP_INDUSTRY) { |
523 |
t = 0xff; |
|
524 |
} else { |
|
525 |
t = _map_owner[tile]; |
|
526 |
} |
|
527 |
||
528 |
return _owner_colors[t]; |
|
529 |
} |
|
530 |
||
531 |
||
532 |
static void DrawSmallMapOwners(byte *dst, uint xc, uint yc, int pitch, int reps, uint32 mask) |
|
533 |
{ |
|
534 |
do { |
|
856
918759cedca8
(svn r1337) Use MapMax[XY]() (or MapSize[XY]() if appropriate) instead of TILE_MAX_[XY]
tron
parents:
758
diff
changeset
|
535 |
if (xc < MapMaxX() && yc < MapMaxY()) |
0 | 536 |
WRITE_PIXELS_OR(dst, GetSmallMapOwnerPixels(TILE_XY(xc,yc)) & mask); |
537 |
} while (xc++,yc++,dst+=pitch,--reps != 0); |
|
538 |
} |
|
539 |
||
540 |
||
541 |
static const uint32 _smallmap_mask_left[3] = { |
|
542 |
MKCOLOR(0xFF000000), |
|
543 |
MKCOLOR(0xFFFF0000), |
|
544 |
MKCOLOR(0xFFFFFF00), |
|
545 |
}; |
|
546 |
||
547 |
static const uint32 _smallmap_mask_right[4] = { |
|
548 |
MKCOLOR(0x00000000), |
|
549 |
MKCOLOR(0x000000FF), |
|
550 |
MKCOLOR(0x0000FFFF), |
|
551 |
MKCOLOR(0x00FFFFFF), |
|
552 |
}; |
|
553 |
||
554 |
/* each tile has 4 x pixels and 1 y pixel */ |
|
555 |
||
556 |
typedef void SmallmapDrawProc(byte *dst, uint xc, uint yc, int pitch, int reps, uint32 mask); |
|
557 |
||
558 |
static SmallmapDrawProc *_smallmap_draw_procs[] = { |
|
559 |
DrawSmallMapContours, |
|
560 |
DrawSmallMapVehicles, |
|
561 |
DrawSmallMapIndustries, |
|
562 |
DrawSmallMapRoutes, |
|
563 |
DrawSmallMapVegetation, |
|
564 |
DrawSmallMapOwners, |
|
565 |
}; |
|
566 |
||
567 |
static const byte _vehicle_type_colors[6] = { |
|
568 |
184, 191, 152, 15, 215, 184 |
|
569 |
}; |
|
570 |
||
500
8e52f7797b48
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
337
diff
changeset
|
571 |
static inline uint32 dup_byte32(byte b) { |
0 | 572 |
return b + (b << 8) + (b << 16) + (b << 24); |
573 |
} |
|
574 |
||
575 |
static void DrawVertMapIndicator(int x, int y, int x2, int y2) |
|
576 |
{ |
|
577 |
GfxFillRect(x, y, x2, y + 3, 69); |
|
578 |
GfxFillRect(x, y2 - 3, x2, y2, 69); |
|
579 |
} |
|
580 |
||
581 |
static void DrawHorizMapIndicator(int x, int y, int x2, int y2) |
|
582 |
{ |
|
583 |
GfxFillRect(x, y, x + 3, y2, 69); |
|
584 |
GfxFillRect(x2 - 3, y, x2, y2, 69); |
|
585 |
} |
|
586 |
||
587 |
static void DrawSmallMap(DrawPixelInfo *dpi, Window *w, int type, bool show_towns) |
|
588 |
{ |
|
589 |
DrawPixelInfo *old_dpi; |
|
590 |
int dx,dy, x, y, x2, y2; |
|
591 |
byte *ptr; |
|
592 |
uint tile_x, tile_y; |
|
593 |
uint32 mask; |
|
594 |
int t; |
|
595 |
int reps; |
|
596 |
SmallmapDrawProc *proc; |
|
597 |
ViewPort *vp; |
|
598 |
||
599 |
old_dpi = _cur_dpi; |
|
600 |
_cur_dpi = dpi; |
|
601 |
||
602 |
/* clear it */ |
|
603 |
GfxFillRect(dpi->left, dpi->top, dpi->left + dpi->width - 1, dpi->top + dpi->height - 1, 0); |
|
604 |
||
605 |
/* setup owner table */ |
|
606 |
if (type == 5) { |
|
607 |
Player *p; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
608 |
|
0 | 609 |
/* clear the town colors */ |
1092 | 610 |
memset(&_owner_colors[128], 0xB4, 128 * sizeof(*_owner_colors)); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
611 |
|
0 | 612 |
/* fill with some special colors */ |
1092 | 613 |
_owner_colors[0x10] = MKCOLOR(0x54545454); |
614 |
_owner_colors[0x11] = MKCOLOR(0xCACACACA); |
|
615 |
_owner_colors[0xff] = MKCOLOR(0x20202020); /* industry */ |
|
0 | 616 |
|
617 |
/* now fill with the player colors */ |
|
618 |
FOR_ALL_PLAYERS(p) { |
|
1092 | 619 |
if (p->is_active) |
620 |
_owner_colors[p->index] = |
|
1350
fd0136012af1
(svn r1854) Split GetSpritePtr() into GetSprite() for regular sprites (returning a Sprite*) and GetNonSprite() for "sprites" of type 0xFF (returning byte*)
tron
parents:
1349
diff
changeset
|
621 |
dup_byte32(GetNonSprite(0x307 + p->player_color)[0xCB]); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
622 |
} |
0 | 623 |
} |
624 |
||
625 |
tile_x = (int)WP(w,smallmap_d).scroll_x >> 4; |
|
626 |
tile_y = (int)WP(w,smallmap_d).scroll_y >> 4; |
|
627 |
||
628 |
dx = dpi->left + WP(w,smallmap_d).subscroll; |
|
629 |
tile_x -= (dx >> 2); |
|
630 |
tile_y += (dx >> 2); |
|
631 |
dx &= 3; |
|
632 |
||
633 |
dy = dpi->top; |
|
634 |
tile_x += (dy >> 1); |
|
635 |
tile_y += (dy >> 1); |
|
636 |
||
637 |
if (dy & 1) { |
|
638 |
tile_x++; |
|
639 |
dx += 2; |
|
640 |
if (dx > 3) { |
|
641 |
dx -= 4; |
|
642 |
tile_x--; |
|
643 |
tile_y++; |
|
644 |
} |
|
645 |
} |
|
646 |
||
647 |
proc = _smallmap_draw_procs[type]; |
|
648 |
||
649 |
ptr = dpi->dst_ptr - dx - 4; |
|
650 |
x = - dx - 4; |
|
651 |
y = 0; |
|
652 |
||
653 |
for(;;) { |
|
654 |
mask = (uint32)-1; |
|
655 |
||
656 |
/* distance from left edge */ |
|
657 |
if (x < 0) { |
|
658 |
if (x < -3) goto skip_column; |
|
659 |
/* mask to use at the left edge */ |
|
660 |
mask = _smallmap_mask_left[x + 3]; |
|
661 |
} |
|
662 |
||
663 |
/* distance from right edge */ |
|
664 |
t = dpi->width - x; |
|
665 |
if (t < 4) { |
|
666 |
if (t < 0) |
|
667 |
break; /* exit loop */ |
|
668 |
/* mask to use at the right edge */ |
|
669 |
mask &= _smallmap_mask_right[t]; |
|
670 |
} |
|
671 |
||
672 |
/* number of lines */ |
|
673 |
reps = ((dpi->height - y + 1) >> 1); |
|
674 |
if (reps > 0) { |
|
675 |
// assert(ptr >= dpi->dst_ptr); |
|
676 |
proc(ptr, tile_x, tile_y, dpi->pitch*2, reps, mask); |
|
677 |
} |
|
678 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
679 |
skip_column: |
0 | 680 |
if (y == 0) { |
681 |
tile_y++; |
|
682 |
y++; |
|
683 |
ptr += dpi->pitch; |
|
684 |
} else { |
|
685 |
tile_x--; |
|
686 |
y--; |
|
687 |
ptr -= dpi->pitch; |
|
688 |
} |
|
689 |
ptr += 2; |
|
690 |
x += 2; |
|
691 |
} |
|
692 |
||
693 |
/* draw vehicles? */ |
|
694 |
if (type == 0 || type == 1) { |
|
695 |
Vehicle *v; |
|
696 |
bool skip; |
|
697 |
byte color; |
|
698 |
||
699 |
FOR_ALL_VEHICLES(v) { |
|
700 |
if (v->type != 0 && v->type != 0x14 && (v->vehstatus & (VS_HIDDEN|VS_UNCLICKABLE)) == 0) { |
|
701 |
// Remap into flat coordinates. |
|
702 |
Point pt = RemapCoords( |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
703 |
(int)(v->x_pos - WP(w,smallmap_d).scroll_x) >> 4, |
0 | 704 |
(int)(v->y_pos - WP(w,smallmap_d).scroll_y) >> 4, |
705 |
0); |
|
706 |
x = pt.x; |
|
707 |
y = pt.y; |
|
708 |
||
709 |
// Check if y is out of bounds? |
|
710 |
y -= dpi->top; |
|
711 |
if ((uint)y >= (uint)dpi->height) |
|
712 |
continue; |
|
713 |
||
714 |
// Default is to draw both pixels. |
|
715 |
skip = false; |
|
716 |
||
717 |
// Offset X coordinate |
|
718 |
x -= WP(w,smallmap_d).subscroll + 3 + dpi->left; |
|
719 |
||
720 |
if (x < 0) { |
|
721 |
// if x+1 is 0, that means we're on the very left edge, |
|
722 |
// and should thus only draw a single pixel |
|
723 |
if (++x != 0) |
|
724 |
continue; |
|
725 |
skip = true; |
|
726 |
} else if (x >= dpi->width - 1) { |
|
727 |
// Check if we're at the very right edge, and if so draw only a single pixel |
|
728 |
if (x != dpi->width - 1) |
|
729 |
continue; |
|
730 |
skip = true; |
|
731 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
732 |
|
0 | 733 |
// Calculate pointer to pixel and the color |
734 |
ptr = dpi->dst_ptr + y * dpi->pitch + x; |
|
735 |
color = (type == 1) ? _vehicle_type_colors[v->type-0x10] : 0xF; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
736 |
|
0 | 737 |
// And draw either one or two pixels depending on clipping |
738 |
ptr[0] = color; |
|
739 |
if (!skip) |
|
740 |
ptr[1] = color; |
|
741 |
} |
|
742 |
} |
|
743 |
} |
|
744 |
||
745 |
if (show_towns) { |
|
746 |
Town *t; |
|
747 |
FOR_ALL_TOWNS(t) { |
|
748 |
if (t->xy != 0) { |
|
749 |
// Remap the town coordinate |
|
750 |
Point pt = RemapCoords( |
|
926
a6d140a6a4de
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
867
diff
changeset
|
751 |
(int)(TileX(t->xy) * 16 - WP(w,smallmap_d).scroll_x) >> 4, |
a6d140a6a4de
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
867
diff
changeset
|
752 |
(int)(TileY(t->xy) * 16 - WP(w,smallmap_d).scroll_y) >> 4, |
0 | 753 |
0); |
754 |
x = pt.x - WP(w,smallmap_d).subscroll + 3 - (t->sign.width_2 >> 1); |
|
755 |
y = pt.y; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
756 |
|
0 | 757 |
// Check if the town sign is within bounds |
758 |
if (x + t->sign.width_2 > dpi->left && |
|
759 |
x < dpi->left + dpi->width && |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
760 |
y + 6 > dpi->top && |
0 | 761 |
y < dpi->top + dpi->height) { |
762 |
// And draw it. |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
763 |
SetDParam(0, t->index); |
0 | 764 |
DrawString(x, y, STR_2056, 12); |
765 |
} |
|
766 |
} |
|
767 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
768 |
} |
0 | 769 |
|
770 |
// Draw map indicators |
|
771 |
{ |
|
772 |
Point pt; |
|
773 |
||
774 |
// Find main viewport. |
|
775 |
vp = FindWindowById(WC_MAIN_WINDOW,0)->viewport; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
776 |
|
0 | 777 |
pt = RemapCoords( |
778 |
WP(w,smallmap_d).scroll_x, |
|
779 |
WP(w,smallmap_d).scroll_y, |
|
780 |
0); |
|
781 |
||
782 |
x = vp->virtual_left - pt.x; |
|
783 |
y = vp->virtual_top - pt.y; |
|
784 |
x2 = (x + vp->virtual_width) >> 4; |
|
785 |
y2 = (y + vp->virtual_height) >> 4; |
|
786 |
x >>= 4; |
|
787 |
y >>= 4; |
|
788 |
||
789 |
x -= WP(w,smallmap_d).subscroll; |
|
790 |
x2 -= WP(w,smallmap_d).subscroll; |
|
791 |
||
792 |
DrawVertMapIndicator(x, y, x, y2); |
|
793 |
DrawVertMapIndicator(x2, y, x2, y2); |
|
794 |
||
795 |
DrawHorizMapIndicator(x, y, x2, y); |
|
796 |
DrawHorizMapIndicator(x, y2, x2, y2); |
|
797 |
} |
|
798 |
_cur_dpi = old_dpi; |
|
799 |
} |
|
800 |
||
801 |
static void SmallMapWindowProc(Window *w, WindowEvent *e) |
|
802 |
{ |
|
803 |
switch(e->event) { |
|
804 |
case WE_PAINT: { |
|
805 |
const uint16 *tbl; |
|
806 |
int x,y,y_org; |
|
807 |
DrawPixelInfo new_dpi; |
|
808 |
||
809 |
/* draw the window */ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
810 |
SetDParam(0, STR_00E5_CONTOURS + _smallmap_type); |
0 | 811 |
DrawWindowWidgets(w); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
812 |
|
0 | 813 |
/* draw the legend */ |
814 |
tbl = _legend_table[(_smallmap_type != 2) ? _smallmap_type : (_opt.landscape + IND_OFFS)]; |
|
815 |
x = 4; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
816 |
y_org = w->height - 43 - 11; |
0 | 817 |
y = y_org; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
818 |
while (true) { |
0 | 819 |
GfxFillRect(x, y+1, x+8, y + 5, 0); |
820 |
GfxFillRect(x+1, y+2, x+7, y + 4, (byte)tbl[0]); |
|
821 |
DrawString(x+11, y, tbl[1], 0); |
|
822 |
||
823 |
tbl += 2; |
|
824 |
y += 6; |
|
825 |
||
826 |
if (tbl[0] == 0xFFFF) { |
|
827 |
break; |
|
828 |
} else if (tbl[0] & 0x100) { |
|
829 |
x += 123; |
|
830 |
y = y_org; |
|
831 |
} |
|
832 |
} |
|
833 |
||
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
834 |
if (!FillDrawPixelInfo(&new_dpi, NULL, 3, 17, w->width - 28 + 22, w->height - 64 - 11)) |
0 | 835 |
return; |
836 |
||
837 |
DrawSmallMap(&new_dpi, w, _smallmap_type, _smallmap_show_towns); |
|
838 |
} break; |
|
839 |
||
840 |
case WE_CLICK: |
|
841 |
switch(e->click.widget) { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
842 |
case 4: {/* main wnd */ |
0 | 843 |
Window *w2; |
844 |
Point pt; |
|
845 |
||
846 |
_left_button_clicked = false; |
|
847 |
||
848 |
w2 = FindWindowById(WC_MAIN_WINDOW, 0); |
|
849 |
||
850 |
pt = RemapCoords(WP(w,smallmap_d).scroll_x, WP(w,smallmap_d).scroll_y, 0); |
|
851 |
WP(w2,vp_d).scrollpos_x = pt.x + ((_cursor.pos.x - w->left + 2) << 4) - (w2->viewport->virtual_width >> 1); |
|
852 |
WP(w2,vp_d).scrollpos_y = pt.y + ((_cursor.pos.y - w->top - 16) << 4) - (w2->viewport->virtual_height >> 1); |
|
853 |
} break; |
|
854 |
||
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
855 |
case 5: /* show land contours */ |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
856 |
case 6: /* show vehicles */ |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
857 |
case 7: /* show industries */ |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
858 |
case 8: /* show transport routes */ |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
859 |
case 9: /* show vegetation */ |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
860 |
case 10: /* show land owners */ |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
861 |
w->click_state &= ~(1<<5|1<<6|1<<7|1<<8|1<<9|1<<10); |
0 | 862 |
w->click_state |= 1 << e->click.widget; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
863 |
_smallmap_type = e->click.widget - 5; |
0 | 864 |
|
865 |
SetWindowDirty(w); |
|
541 | 866 |
SndPlayFx(SND_15_BEEP); |
0 | 867 |
break; |
868 |
||
758
423ae0bcba07
(svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents:
682
diff
changeset
|
869 |
case 12: /* toggle town names */ |
423ae0bcba07
(svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents:
682
diff
changeset
|
870 |
w->click_state ^= (1 << 12); |
423ae0bcba07
(svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents:
682
diff
changeset
|
871 |
_smallmap_show_towns = (w->click_state >> 12) & 1; |
0 | 872 |
SetWindowDirty(w); |
541 | 873 |
SndPlayFx(SND_15_BEEP); |
0 | 874 |
break; |
875 |
} |
|
876 |
break; |
|
877 |
||
878 |
case WE_RCLICK: |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
879 |
if (e->click.widget == 4) { |
0 | 880 |
if (_scrolling_viewport) |
881 |
return; |
|
882 |
_scrolling_viewport = true; |
|
883 |
_cursor.delta.x = 0; |
|
884 |
_cursor.delta.y = 0; |
|
885 |
} |
|
886 |
break; |
|
887 |
||
888 |
case WE_MOUSELOOP: |
|
889 |
/* update the window every now and then */ |
|
890 |
if ((++w->vscroll.pos & 0x1F) == 0) |
|
891 |
SetWindowDirty(w); |
|
892 |
break; |
|
893 |
} |
|
894 |
} |
|
895 |
||
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
896 |
static const WindowDesc _smallmap_desc = { |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
897 |
-1,-1, 446, 314, |
0 | 898 |
WC_SMALLMAP,0, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
899 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
900 |
_smallmap_widgets, |
0 | 901 |
SmallMapWindowProc |
902 |
}; |
|
903 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1092
diff
changeset
|
904 |
void ShowSmallMap(void) |
0 | 905 |
{ |
906 |
Window *w; |
|
907 |
ViewPort *vp; |
|
908 |
int x,y; |
|
909 |
||
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
910 |
w = AllocateWindowDescFront(&_smallmap_desc, 0); |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
911 |
if (w) { |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
912 |
w->click_state = ((1<<5) << _smallmap_type) | (_smallmap_show_towns << 12); |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
913 |
w->resize.width = 350; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
914 |
w->resize.height = 250; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
915 |
|
0 | 916 |
vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport; |
917 |
||
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
918 |
x = (((vp->virtual_width - (220*32)) / 2) + vp->virtual_left) / 4; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
919 |
y = ((((vp->virtual_height- (120*32)) / 2) + vp->virtual_top ) / 2) - 32; |
0 | 920 |
WP(w,smallmap_d).scroll_x = (y-x) & ~0xF; |
921 |
WP(w,smallmap_d).scroll_y = (x+y) & ~0xF; |
|
922 |
WP(w,smallmap_d).subscroll = 0; |
|
923 |
} |
|
924 |
} |
|
925 |
||
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
926 |
/* Extra ViewPort Window Stuff */ |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
927 |
static const Widget _extra_view_port_widgets[] = { |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
928 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
929 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 287, 0, 13, STR_EXTRA_VIEW_PORT_TITLE, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
930 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 288, 299, 0, 13, 0x0, STR_STICKY_BUTTON}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
931 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 299, 14, 233, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
932 |
{ WWT_6, RESIZE_RB, 14, 2, 297, 16, 231, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
933 |
{ WWT_PANEL, RESIZE_TB, 14, 0, 21, 234, 255, 0x2DF, STR_017F_ZOOM_THE_VIEW_IN}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
934 |
{ WWT_PANEL, RESIZE_TB, 14, 22, 43, 234, 255, 0x2E0, STR_0180_ZOOM_THE_VIEW_OUT}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
935 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 44, 171, 234, 255, STR_EXTRA_VIEW_MOVE_MAIN_TO_VIEW,STR_EXTRA_VIEW_MOVE_MAIN_TO_VIEW_TT}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
936 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 172, 298, 234, 255, STR_EXTRA_VIEW_MOVE_VIEW_TO_MAIN,STR_EXTRA_VIEW_MOVE_VIEW_TO_MAIN_TT}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
937 |
{ WWT_PANEL, RESIZE_RTB, 14, 299, 299, 234, 255, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
938 |
{ WWT_PANEL, RESIZE_RTB, 14, 0, 287, 256, 267, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
939 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 288, 299, 256, 267, 0x0, STR_RESIZE_BUTTON}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
154
diff
changeset
|
940 |
{ WIDGETS_END}, |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
941 |
}; |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
942 |
|
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
943 |
static void ExtraViewPortWndProc(Window *w, WindowEvent *e) |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
944 |
{ |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
945 |
ViewPort *vp = w->viewport; |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
946 |
|
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
947 |
switch(e->event) { |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
948 |
case WE_PAINT: { |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
949 |
// set the number in the title bar |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
950 |
SetDParam(0, (w->window_number+1)); |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
951 |
|
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
952 |
DrawWindowWidgets(w); |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
953 |
DrawWindowViewport(w); |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
954 |
} break; |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
955 |
case WE_CLICK: { |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
956 |
switch(e->click.widget) { |
682
74c70f645d95
(svn r1121) -Feature: Added sticky windows feature. A small pin allows the user to set the window as undeletable and can only be closed by hand. As an example the viewport window has been stickied (thanks to Neko-San)
darkvater
parents:
679
diff
changeset
|
957 |
case 5: { /* zoom in */ |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
958 |
DoZoomInOutWindow(ZOOM_IN, w); |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
959 |
} break; |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
960 |
|
682
74c70f645d95
(svn r1121) -Feature: Added sticky windows feature. A small pin allows the user to set the window as undeletable and can only be closed by hand. As an example the viewport window has been stickied (thanks to Neko-San)
darkvater
parents:
679
diff
changeset
|
961 |
case 6: { /* zoom out */ |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
962 |
DoZoomInOutWindow(ZOOM_OUT, w); |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
963 |
} break; |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
964 |
|
682
74c70f645d95
(svn r1121) -Feature: Added sticky windows feature. A small pin allows the user to set the window as undeletable and can only be closed by hand. As an example the viewport window has been stickied (thanks to Neko-San)
darkvater
parents:
679
diff
changeset
|
965 |
case 7: { /* location button (move main view to same spot as this view) */ |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
966 |
Window * w2 = FindWindowById(WC_MAIN_WINDOW, 0); |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
967 |
int x = WP(w,vp_d).scrollpos_x; // Where is the main looking at |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
968 |
int y = WP(w,vp_d).scrollpos_y; |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
969 |
|
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
970 |
// set this view to same location. Based on the center, adjusting for zoom |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
971 |
WP(w2,vp_d).scrollpos_x = x - (w2->viewport->virtual_width - (w->viewport->virtual_width << vp->zoom)) / 2; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
972 |
WP(w2,vp_d).scrollpos_y = y - (w2->viewport->virtual_height - (w->viewport->virtual_height << vp->zoom)) / 2; |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
973 |
} break; |
682
74c70f645d95
(svn r1121) -Feature: Added sticky windows feature. A small pin allows the user to set the window as undeletable and can only be closed by hand. As an example the viewport window has been stickied (thanks to Neko-San)
darkvater
parents:
679
diff
changeset
|
974 |
case 8: { /* inverse location button (move this view to same spot as main view) */ |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
975 |
Window * w2 = FindWindowById(WC_MAIN_WINDOW, 0); |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
976 |
int x = WP(w2,vp_d).scrollpos_x; |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
977 |
int y = WP(w2,vp_d).scrollpos_y; |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
978 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
979 |
WP(w,vp_d).scrollpos_x = x + (w2->viewport->virtual_width - (w->viewport->virtual_width << vp->zoom)) / 2; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
980 |
WP(w,vp_d).scrollpos_y = y + (w2->viewport->virtual_height - (w->viewport->virtual_height << vp->zoom)) / 2; |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
981 |
} break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
982 |
} |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
983 |
} break; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
984 |
case WE_RESIZE: { |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
985 |
w->viewport->width += e->sizing.diff.x; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
986 |
w->viewport->height += e->sizing.diff.y; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
987 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
988 |
w->viewport->virtual_width += e->sizing.diff.x; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
989 |
w->viewport->virtual_height += e->sizing.diff.y; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
990 |
} break; |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
991 |
} |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
992 |
} |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
993 |
|
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
994 |
static const WindowDesc _extra_view_port_desc = { |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
995 |
-1,-1, 300, 268, |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
996 |
WC_EXTRA_VIEW_PORT,0, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
997 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
998 |
_extra_view_port_widgets, |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
999 |
ExtraViewPortWndProc |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1000 |
}; |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1001 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1092
diff
changeset
|
1002 |
void ShowExtraViewPortWindow(void) |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1003 |
{ |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1004 |
Window *w, *v; |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1005 |
int i = 0; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1006 |
|
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1007 |
// find next free window number for extra viewport |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
1008 |
while (FindWindowById(WC_EXTRA_VIEW_PORT, i) ) { |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1009 |
i++; |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1010 |
} |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1011 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
1012 |
w = AllocateWindowDescFront(&_extra_view_port_desc, i); |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1013 |
if (w) { |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
1014 |
int x, y; |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1015 |
// disable zoom in button |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
1016 |
w->disabled_state = (1 << 4); |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1017 |
// the main window with the main view |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1018 |
v = FindWindowById(WC_MAIN_WINDOW, 0); |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1019 |
// New viewport start ats (zero,zero) |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1020 |
AssignWindowViewport(w, 3, 17, 294, 214, 0 , 0); |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1021 |
|
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1022 |
// center on same place as main window (zoom is maximum, no adjustment needed) |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1023 |
x = WP(v,vp_d).scrollpos_x; |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1024 |
y = WP(v,vp_d).scrollpos_y; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
1025 |
WP(w,vp_d).scrollpos_x = x + (v->viewport->virtual_width - (294)) / 2; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
1026 |
WP(w,vp_d).scrollpos_y = y + (v->viewport->virtual_height - (214)) / 2; |
152
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1027 |
} |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1028 |
} |