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