author | truelight |
Thu, 24 Mar 2005 14:43:40 +0000 | |
changeset 1540 | 6eef12dab5bf |
parent 1516 | dc914162ad01 |
child 1815 | 733868a48ab3 |
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 |
||
1511
5917a04566df
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
253 |
typedef struct AndOr { |
5917a04566df
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
254 |
uint32 mor; |
5917a04566df
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
255 |
uint32 mand; |
5917a04566df
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
256 |
} AndOr; |
5917a04566df
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
257 |
|
5917a04566df
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
258 |
static inline uint32 ApplyMask(uint32 colour, const AndOr* mask) |
5917a04566df
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
259 |
{ |
5917a04566df
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
260 |
return (colour & mask->mand) | mask->mor; |
5917a04566df
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
261 |
} |
5917a04566df
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
262 |
|
5917a04566df
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
263 |
static const AndOr _smallmap_contours_andor[] = { |
0 | 264 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
265 |
{MKCOLOR(0x000A0A00),MKCOLOR(0xFF0000FF)}, |
|
266 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
267 |
{MKCOLOR(0x00B5B500),MKCOLOR(0xFF0000FF)}, |
|
268 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
269 |
{MKCOLOR(0x98989898),MKCOLOR(0x00000000)}, |
|
270 |
{MKCOLOR(0xCACACACA),MKCOLOR(0x00000000)}, |
|
271 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
272 |
{MKCOLOR(0xB5B5B5B5),MKCOLOR(0x00000000)}, |
|
273 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
274 |
{MKCOLOR(0x00B5B500),MKCOLOR(0xFF0000FF)}, |
|
275 |
{MKCOLOR(0x000A0A00),MKCOLOR(0xFF0000FF)}, |
|
276 |
}; |
|
277 |
||
1511
5917a04566df
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
278 |
static const AndOr _smallmap_vehicles_andor[] = { |
0 | 279 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
280 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
281 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
282 |
{MKCOLOR(0x00B5B500),MKCOLOR(0xFF0000FF)}, |
|
283 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
284 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
285 |
{MKCOLOR(0xCACACACA),MKCOLOR(0x00000000)}, |
|
286 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
287 |
{MKCOLOR(0xB5B5B5B5),MKCOLOR(0x00000000)}, |
|
288 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
289 |
{MKCOLOR(0x00B5B500),MKCOLOR(0xFF0000FF)}, |
|
290 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
291 |
}; |
|
292 |
||
1511
5917a04566df
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
293 |
static const AndOr _smallmap_vegetation_andor[] = { |
0 | 294 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
295 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
296 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
297 |
{MKCOLOR(0x00B5B500),MKCOLOR(0xFF0000FF)}, |
|
298 |
{MKCOLOR(0x00575700),MKCOLOR(0xFF0000FF)}, |
|
299 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
300 |
{MKCOLOR(0xCACACACA),MKCOLOR(0x00000000)}, |
|
301 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
302 |
{MKCOLOR(0xB5B5B5B5),MKCOLOR(0x00000000)}, |
|
303 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
304 |
{MKCOLOR(0x00B5B500),MKCOLOR(0xFF0000FF)}, |
|
305 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
306 |
}; |
|
307 |
||
1516
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
308 |
|
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
309 |
static inline TileType GetEffectiveTileType(TileIndex tile) |
0 | 310 |
{ |
1516
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
311 |
TileType t = GetTileType(tile); |
0 | 312 |
|
313 |
if (t == MP_TUNNELBRIDGE) { |
|
314 |
t = _map5[tile]; |
|
1516
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
315 |
if ((t & 0x80) == 0) t >>= 1; |
0 | 316 |
if ((t & 6) == 0) { |
317 |
t = MP_RAILWAY; |
|
318 |
} else if ((t & 6) == 2) { |
|
319 |
t = MP_STREET; |
|
320 |
} else { |
|
321 |
t = MP_WATER; |
|
322 |
} |
|
323 |
} |
|
1516
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
324 |
return t; |
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
325 |
} |
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
326 |
|
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
327 |
|
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
328 |
static inline uint32 GetSmallMapContoursPixels(TileIndex tile) |
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
329 |
{ |
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
330 |
TileType t = GetEffectiveTileType(tile); |
0 | 331 |
|
1511
5917a04566df
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
332 |
return |
5917a04566df
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
333 |
ApplyMask(_map_height_bits[TileHeight(tile)], &_smallmap_contours_andor[t]); |
0 | 334 |
} |
335 |
||
336 |
static void DrawSmallMapContours(byte *dst, uint xc, uint yc, int pitch, int reps, uint32 mask) |
|
337 |
{ |
|
338 |
do { |
|
856
918759cedca8
(svn r1337) Use MapMax[XY]() (or MapSize[XY]() if appropriate) instead of TILE_MAX_[XY]
tron
parents:
758
diff
changeset
|
339 |
if (xc < MapMaxX() && yc < MapMaxY()) |
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
340 |
if (dst > _screen.dst_ptr && dst < (_screen.dst_ptr + _screen.width * _screen.height - _screen.width)) |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
341 |
WRITE_PIXELS_OR(dst, GetSmallMapContoursPixels(TILE_XY(xc,yc)) & mask); |
0 | 342 |
} while (xc++,yc++,dst+=pitch,--reps != 0); |
343 |
} |
|
344 |
||
345 |
||
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
346 |
static inline uint32 GetSmallMapVehiclesPixels(TileIndex tile) |
0 | 347 |
{ |
1516
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
348 |
TileType t = GetEffectiveTileType(tile); |
0 | 349 |
|
1511
5917a04566df
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
350 |
return ApplyMask(MKCOLOR(0x54545454), &_smallmap_vehicles_andor[t]); |
0 | 351 |
} |
352 |
||
353 |
||
354 |
static void DrawSmallMapVehicles(byte *dst, uint xc, uint yc, int pitch, int reps, uint32 mask) |
|
355 |
{ |
|
356 |
do { |
|
856
918759cedca8
(svn r1337) Use MapMax[XY]() (or MapSize[XY]() if appropriate) instead of TILE_MAX_[XY]
tron
parents:
758
diff
changeset
|
357 |
if (xc < MapMaxX() && yc < MapMaxY()) |
0 | 358 |
WRITE_PIXELS_OR( dst, GetSmallMapVehiclesPixels(TILE_XY(xc,yc)) & mask ); |
359 |
} while (xc++,yc++,dst+=pitch,--reps != 0); |
|
360 |
} |
|
361 |
||
362 |
static const byte _industry_smallmap_colors[175] = { |
|
363 |
215,215,215,215,215,215,215,184, |
|
364 |
184,184,184,194,194,194,194,194, |
|
365 |
86, 86,191,191,191,191,191,191, |
|
366 |
152,152,152,152,152,152,152,152, |
|
367 |
152, 48, 48, 48, 48, 48, 48,174, |
|
368 |
174,174,174,174,174,174,174, 10, |
|
369 |
10, 10, 10, 10, 10, 10, 10, 10, |
|
370 |
10, 10, 15, 15, 55, 55, 55, 55, |
|
371 |
10, 10, 10, 10, 10, 10, 10, 10, |
|
372 |
194,194,194,194,194,194,194,194, |
|
373 |
194,194,194,194,194,194,194,194, |
|
374 |
194, 15, 15,184,184,184,184,184, |
|
375 |
184,184,184,184, 55, 55, 55, 55, |
|
376 |
55, 55, 55, 55, 55, 55, 55, 55, |
|
377 |
55, 55, 55, 55, 86, 39, 37, 37, |
|
378 |
208,174,174,174,174,194,194,194, |
|
379 |
194, 48, 48,174,174,174,174, 39, |
|
380 |
39, 55,208,208,208,208, 10, 10, |
|
381 |
10, 10, 10, 10, 37, 37, 37, 37, |
|
382 |
37, 37, 37, 37,184,184,184,184, |
|
383 |
152,152,152,152,194,194,194, 15, |
|
384 |
15, 15, 15, 15, 15, 15, 15, |
|
385 |
}; |
|
386 |
||
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
387 |
static inline uint32 GetSmallMapIndustriesPixels(TileIndex tile) |
0 | 388 |
{ |
1516
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
389 |
TileType t = GetEffectiveTileType(tile); |
0 | 390 |
|
391 |
if (t == MP_INDUSTRY) { |
|
392 |
byte color = _industry_smallmap_colors[_map5[tile]]; |
|
393 |
return color + (color << 8) + (color << 16) + (color << 24); |
|
394 |
} else { |
|
1511
5917a04566df
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
395 |
return ApplyMask(MKCOLOR(0x54545454), &_smallmap_vehicles_andor[t]); |
0 | 396 |
} |
397 |
} |
|
398 |
||
399 |
static void DrawSmallMapIndustries(byte *dst, uint xc, uint yc, int pitch, int reps, uint32 mask) |
|
400 |
{ |
|
401 |
do { |
|
856
918759cedca8
(svn r1337) Use MapMax[XY]() (or MapSize[XY]() if appropriate) instead of TILE_MAX_[XY]
tron
parents:
758
diff
changeset
|
402 |
if (xc < MapMaxX() && yc < MapMaxY()) |
0 | 403 |
WRITE_PIXELS_OR(dst, GetSmallMapIndustriesPixels(TILE_XY(xc,yc)) & mask); |
404 |
} while (xc++,yc++,dst+=pitch,--reps != 0); |
|
405 |
} |
|
406 |
||
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
407 |
static inline uint32 GetSmallMapRoutesPixels(TileIndex tile) |
0 | 408 |
{ |
1516
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
409 |
TileType t = GetEffectiveTileType(tile); |
0 | 410 |
uint32 bits; |
411 |
||
412 |
if (t == MP_STATION) { |
|
413 |
byte m5 = _map5[tile]; |
|
414 |
(bits = MKCOLOR(0x56565656), m5 < 8) || // 8 - railroad station (green) |
|
415 |
(bits = MKCOLOR(0xB8B8B8B8), m5 < 0x43) || // 67 - airport (red) |
|
416 |
(bits = MKCOLOR(0xC2C2C2C2), m5 < 0x47) || // 71 - truck loading bay (orange) |
|
417 |
(bits = MKCOLOR(0xBFBFBFBF), m5 < 0x4B) || // 75 - bus station (yellow) |
|
418 |
(bits = MKCOLOR(0x98989898), m5 < 0x53) || // 83 - docks (blue) |
|
419 |
(bits = MKCOLOR(0xB8B8B8B8), m5 < 0x73) || // 115 - airport (red) (new airports) |
|
420 |
(bits = MKCOLOR(0xFFFFFFFF), true); // all others |
|
421 |
} else { |
|
422 |
// ground color |
|
1511
5917a04566df
(svn r2015) Use a struct and an inline function for colour masking on the mini-map - this should improve readability a bit
tron
parents:
1350
diff
changeset
|
423 |
bits = ApplyMask(MKCOLOR(0x54545454), &_smallmap_contours_andor[t]); |
0 | 424 |
} |
425 |
return bits; |
|
426 |
} |
|
427 |
||
428 |
static void DrawSmallMapRoutes(byte *dst, uint xc, uint yc, int pitch, int reps, uint32 mask) |
|
429 |
{ |
|
430 |
do { |
|
856
918759cedca8
(svn r1337) Use MapMax[XY]() (or MapSize[XY]() if appropriate) instead of TILE_MAX_[XY]
tron
parents:
758
diff
changeset
|
431 |
if (xc < MapMaxX() && yc < MapMaxY()) |
0 | 432 |
WRITE_PIXELS_OR(dst, GetSmallMapRoutesPixels(TILE_XY(xc,yc)) & mask); |
433 |
} while (xc++,yc++,dst+=pitch,--reps != 0); |
|
434 |
} |
|
435 |
||
436 |
static const uint32 _vegetation_clear_bits[4 + 7] = { |
|
437 |
MKCOLOR(0x37373737), |
|
438 |
MKCOLOR(0x37373737), |
|
439 |
MKCOLOR(0x37373737), |
|
440 |
MKCOLOR(0x54545454), |
|
441 |
||
442 |
MKCOLOR(0x52525252), |
|
443 |
MKCOLOR(0x0A0A0A0A), |
|
444 |
MKCOLOR(0x25252525), |
|
445 |
MKCOLOR(0x98989898), |
|
446 |
MKCOLOR(0xC2C2C2C2), |
|
447 |
MKCOLOR(0x54545454), |
|
448 |
MKCOLOR(0x54545454), |
|
449 |
}; |
|
450 |
||
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
451 |
static inline uint32 GetSmallMapVegetationPixels(TileIndex tile) |
0 | 452 |
{ |
1516
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
453 |
TileType t = GetEffectiveTileType(tile); |
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
454 |
int i; |
0 | 455 |
uint32 bits; |
456 |
||
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
457 |
switch (t) { |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
458 |
case MP_CLEAR: |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
459 |
i = (_map5[tile] & 0x1F) - 4; |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
460 |
if (i >= 0) i >>= 2; |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
461 |
bits = _vegetation_clear_bits[i + 4]; |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
462 |
break; |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
463 |
|
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
464 |
case MP_INDUSTRY: |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
465 |
bits = IS_BYTE_INSIDE(_map5[tile], 0x10, 0x12) ? MKCOLOR(0xD0D0D0D0) : MKCOLOR(0xB5B5B5B5); |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
466 |
break; |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
467 |
|
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
468 |
case MP_TREES: |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
469 |
if ((_map2[tile] & 0x30) == 0x20) |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
470 |
bits = (_opt.landscape == LT_HILLY) ? MKCOLOR(0x98575798) : MKCOLOR(0xC25757C2); |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
471 |
else |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
472 |
bits = MKCOLOR(0x54575754); |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
473 |
break; |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
474 |
|
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
475 |
default: |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
476 |
bits = ApplyMask(MKCOLOR(0x54545454), &_smallmap_vehicles_andor[t]); |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
477 |
break; |
0 | 478 |
} |
479 |
||
480 |
return bits; |
|
481 |
} |
|
482 |
||
483 |
||
484 |
static void DrawSmallMapVegetation(byte *dst, uint xc, uint yc, int pitch, int reps, uint32 mask) |
|
485 |
{ |
|
486 |
do { |
|
856
918759cedca8
(svn r1337) Use MapMax[XY]() (or MapSize[XY]() if appropriate) instead of TILE_MAX_[XY]
tron
parents:
758
diff
changeset
|
487 |
if (xc < MapMaxX() && yc < MapMaxY()) |
0 | 488 |
WRITE_PIXELS_OR(dst, GetSmallMapVegetationPixels(TILE_XY(xc,yc)) & mask); |
489 |
} while (xc++,yc++,dst+=pitch,--reps != 0); |
|
490 |
} |
|
491 |
||
492 |
||
1092 | 493 |
static uint32 _owner_colors[256]; |
0 | 494 |
|
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
495 |
static inline uint32 GetSmallMapOwnerPixels(TileIndex tile) |
0 | 496 |
{ |
1516
dc914162ad01
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
497 |
TileType t = GetTileType(tile); |
0 | 498 |
|
499 |
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
|
500 |
t = 0x80; |
0 | 501 |
} else if (t == MP_INDUSTRY) { |
502 |
t = 0xff; |
|
503 |
} else { |
|
504 |
t = _map_owner[tile]; |
|
505 |
} |
|
506 |
||
507 |
return _owner_colors[t]; |
|
508 |
} |
|
509 |
||
510 |
||
511 |
static void DrawSmallMapOwners(byte *dst, uint xc, uint yc, int pitch, int reps, uint32 mask) |
|
512 |
{ |
|
513 |
do { |
|
856
918759cedca8
(svn r1337) Use MapMax[XY]() (or MapSize[XY]() if appropriate) instead of TILE_MAX_[XY]
tron
parents:
758
diff
changeset
|
514 |
if (xc < MapMaxX() && yc < MapMaxY()) |
0 | 515 |
WRITE_PIXELS_OR(dst, GetSmallMapOwnerPixels(TILE_XY(xc,yc)) & mask); |
516 |
} while (xc++,yc++,dst+=pitch,--reps != 0); |
|
517 |
} |
|
518 |
||
519 |
||
520 |
static const uint32 _smallmap_mask_left[3] = { |
|
521 |
MKCOLOR(0xFF000000), |
|
522 |
MKCOLOR(0xFFFF0000), |
|
523 |
MKCOLOR(0xFFFFFF00), |
|
524 |
}; |
|
525 |
||
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
526 |
static const uint32 _smallmap_mask_right[] = { |
0 | 527 |
MKCOLOR(0x000000FF), |
528 |
MKCOLOR(0x0000FFFF), |
|
529 |
MKCOLOR(0x00FFFFFF), |
|
530 |
}; |
|
531 |
||
532 |
/* each tile has 4 x pixels and 1 y pixel */ |
|
533 |
||
534 |
typedef void SmallmapDrawProc(byte *dst, uint xc, uint yc, int pitch, int reps, uint32 mask); |
|
535 |
||
536 |
static SmallmapDrawProc *_smallmap_draw_procs[] = { |
|
537 |
DrawSmallMapContours, |
|
538 |
DrawSmallMapVehicles, |
|
539 |
DrawSmallMapIndustries, |
|
540 |
DrawSmallMapRoutes, |
|
541 |
DrawSmallMapVegetation, |
|
542 |
DrawSmallMapOwners, |
|
543 |
}; |
|
544 |
||
545 |
static const byte _vehicle_type_colors[6] = { |
|
546 |
184, 191, 152, 15, 215, 184 |
|
547 |
}; |
|
548 |
||
500
8e52f7797b48
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
337
diff
changeset
|
549 |
static inline uint32 dup_byte32(byte b) { |
0 | 550 |
return b + (b << 8) + (b << 16) + (b << 24); |
551 |
} |
|
552 |
||
553 |
static void DrawVertMapIndicator(int x, int y, int x2, int y2) |
|
554 |
{ |
|
555 |
GfxFillRect(x, y, x2, y + 3, 69); |
|
556 |
GfxFillRect(x, y2 - 3, x2, y2, 69); |
|
557 |
} |
|
558 |
||
559 |
static void DrawHorizMapIndicator(int x, int y, int x2, int y2) |
|
560 |
{ |
|
561 |
GfxFillRect(x, y, x + 3, y2, 69); |
|
562 |
GfxFillRect(x2 - 3, y, x2, y2, 69); |
|
563 |
} |
|
564 |
||
565 |
static void DrawSmallMap(DrawPixelInfo *dpi, Window *w, int type, bool show_towns) |
|
566 |
{ |
|
567 |
DrawPixelInfo *old_dpi; |
|
568 |
int dx,dy, x, y, x2, y2; |
|
569 |
byte *ptr; |
|
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
570 |
int tile_x; |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
571 |
int tile_y; |
0 | 572 |
SmallmapDrawProc *proc; |
573 |
ViewPort *vp; |
|
574 |
||
575 |
old_dpi = _cur_dpi; |
|
576 |
_cur_dpi = dpi; |
|
577 |
||
578 |
/* clear it */ |
|
579 |
GfxFillRect(dpi->left, dpi->top, dpi->left + dpi->width - 1, dpi->top + dpi->height - 1, 0); |
|
580 |
||
581 |
/* setup owner table */ |
|
582 |
if (type == 5) { |
|
583 |
Player *p; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
584 |
|
0 | 585 |
/* clear the town colors */ |
1092 | 586 |
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
|
587 |
|
0 | 588 |
/* fill with some special colors */ |
1092 | 589 |
_owner_colors[0x10] = MKCOLOR(0x54545454); |
590 |
_owner_colors[0x11] = MKCOLOR(0xCACACACA); |
|
591 |
_owner_colors[0xff] = MKCOLOR(0x20202020); /* industry */ |
|
0 | 592 |
|
593 |
/* now fill with the player colors */ |
|
594 |
FOR_ALL_PLAYERS(p) { |
|
1092 | 595 |
if (p->is_active) |
596 |
_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
|
597 |
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
|
598 |
} |
0 | 599 |
} |
600 |
||
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
601 |
tile_x = WP(w,smallmap_d).scroll_x / 16; |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
602 |
tile_y = WP(w,smallmap_d).scroll_y / 16; |
0 | 603 |
|
604 |
dx = dpi->left + WP(w,smallmap_d).subscroll; |
|
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
605 |
tile_x -= dx / 4; |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
606 |
tile_y += dx / 4; |
0 | 607 |
dx &= 3; |
608 |
||
609 |
dy = dpi->top; |
|
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
610 |
tile_x += dy / 2; |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
611 |
tile_y += dy / 2; |
0 | 612 |
|
613 |
if (dy & 1) { |
|
614 |
tile_x++; |
|
615 |
dx += 2; |
|
616 |
if (dx > 3) { |
|
617 |
dx -= 4; |
|
618 |
tile_x--; |
|
619 |
tile_y++; |
|
620 |
} |
|
621 |
} |
|
622 |
||
623 |
proc = _smallmap_draw_procs[type]; |
|
624 |
||
625 |
ptr = dpi->dst_ptr - dx - 4; |
|
626 |
x = - dx - 4; |
|
627 |
y = 0; |
|
628 |
||
629 |
for(;;) { |
|
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
630 |
uint32 mask; |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
631 |
int reps; |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
632 |
int t; |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
633 |
|
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
634 |
mask = 0xFFFFFFFF; |
0 | 635 |
|
636 |
/* distance from left edge */ |
|
637 |
if (x < 0) { |
|
638 |
if (x < -3) goto skip_column; |
|
639 |
/* mask to use at the left edge */ |
|
640 |
mask = _smallmap_mask_left[x + 3]; |
|
641 |
} |
|
642 |
||
643 |
/* distance from right edge */ |
|
644 |
t = dpi->width - x; |
|
645 |
if (t < 4) { |
|
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
646 |
if (t <= 0) |
0 | 647 |
break; /* exit loop */ |
648 |
/* mask to use at the right edge */ |
|
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
649 |
mask &= _smallmap_mask_right[t - 1]; |
0 | 650 |
} |
651 |
||
652 |
/* number of lines */ |
|
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
653 |
reps = (dpi->height - y + 1) / 2; |
0 | 654 |
if (reps > 0) { |
655 |
// assert(ptr >= dpi->dst_ptr); |
|
656 |
proc(ptr, tile_x, tile_y, dpi->pitch*2, reps, mask); |
|
657 |
} |
|
658 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
659 |
skip_column: |
0 | 660 |
if (y == 0) { |
661 |
tile_y++; |
|
662 |
y++; |
|
663 |
ptr += dpi->pitch; |
|
664 |
} else { |
|
665 |
tile_x--; |
|
666 |
y--; |
|
667 |
ptr -= dpi->pitch; |
|
668 |
} |
|
669 |
ptr += 2; |
|
670 |
x += 2; |
|
671 |
} |
|
672 |
||
673 |
/* draw vehicles? */ |
|
674 |
if (type == 0 || type == 1) { |
|
675 |
Vehicle *v; |
|
676 |
bool skip; |
|
677 |
byte color; |
|
678 |
||
679 |
FOR_ALL_VEHICLES(v) { |
|
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
680 |
if (v->type != 0 && v->type != VEH_Special && |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
681 |
(v->vehstatus & (VS_HIDDEN | VS_UNCLICKABLE)) == 0) { |
0 | 682 |
// Remap into flat coordinates. |
683 |
Point pt = RemapCoords( |
|
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
684 |
(v->x_pos - WP(w,smallmap_d).scroll_x) / 16, |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
685 |
(v->y_pos - WP(w,smallmap_d).scroll_y) / 16, |
0 | 686 |
0); |
687 |
x = pt.x; |
|
688 |
y = pt.y; |
|
689 |
||
690 |
// Check if y is out of bounds? |
|
691 |
y -= dpi->top; |
|
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
692 |
if (!IS_INT_INSIDE(y, 0, dpi->height)) continue; |
0 | 693 |
|
694 |
// Default is to draw both pixels. |
|
695 |
skip = false; |
|
696 |
||
697 |
// Offset X coordinate |
|
698 |
x -= WP(w,smallmap_d).subscroll + 3 + dpi->left; |
|
699 |
||
700 |
if (x < 0) { |
|
701 |
// if x+1 is 0, that means we're on the very left edge, |
|
702 |
// and should thus only draw a single pixel |
|
703 |
if (++x != 0) |
|
704 |
continue; |
|
705 |
skip = true; |
|
706 |
} else if (x >= dpi->width - 1) { |
|
707 |
// Check if we're at the very right edge, and if so draw only a single pixel |
|
708 |
if (x != dpi->width - 1) |
|
709 |
continue; |
|
710 |
skip = true; |
|
711 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
712 |
|
0 | 713 |
// Calculate pointer to pixel and the color |
714 |
ptr = dpi->dst_ptr + y * dpi->pitch + x; |
|
715 |
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
|
716 |
|
0 | 717 |
// And draw either one or two pixels depending on clipping |
718 |
ptr[0] = color; |
|
719 |
if (!skip) |
|
720 |
ptr[1] = color; |
|
721 |
} |
|
722 |
} |
|
723 |
} |
|
724 |
||
725 |
if (show_towns) { |
|
726 |
Town *t; |
|
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
727 |
|
0 | 728 |
FOR_ALL_TOWNS(t) { |
729 |
if (t->xy != 0) { |
|
730 |
// Remap the town coordinate |
|
731 |
Point pt = RemapCoords( |
|
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
732 |
(int)(TileX(t->xy) * 16 - WP(w, smallmap_d).scroll_x) / 16, |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
733 |
(int)(TileY(t->xy) * 16 - WP(w, smallmap_d).scroll_y) / 16, |
0 | 734 |
0); |
735 |
x = pt.x - WP(w,smallmap_d).subscroll + 3 - (t->sign.width_2 >> 1); |
|
736 |
y = pt.y; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
737 |
|
0 | 738 |
// Check if the town sign is within bounds |
739 |
if (x + t->sign.width_2 > dpi->left && |
|
740 |
x < dpi->left + dpi->width && |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
741 |
y + 6 > dpi->top && |
0 | 742 |
y < dpi->top + dpi->height) { |
743 |
// And draw it. |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
744 |
SetDParam(0, t->index); |
0 | 745 |
DrawString(x, y, STR_2056, 12); |
746 |
} |
|
747 |
} |
|
748 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
749 |
} |
0 | 750 |
|
751 |
// Draw map indicators |
|
752 |
{ |
|
753 |
Point pt; |
|
754 |
||
755 |
// Find main viewport. |
|
756 |
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
|
757 |
|
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
758 |
pt = RemapCoords(WP(w, smallmap_d).scroll_x, WP(w, smallmap_d).scroll_y, 0); |
0 | 759 |
|
760 |
x = vp->virtual_left - pt.x; |
|
761 |
y = vp->virtual_top - pt.y; |
|
1515
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
762 |
x2 = (x + vp->virtual_width) / 16; |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
763 |
y2 = (y + vp->virtual_height) / 16; |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
764 |
x /= 16; |
071fe1565cb8
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
765 |
y /= 16; |
0 | 766 |
|
767 |
x -= WP(w,smallmap_d).subscroll; |
|
768 |
x2 -= WP(w,smallmap_d).subscroll; |
|
769 |
||
770 |
DrawVertMapIndicator(x, y, x, y2); |
|
771 |
DrawVertMapIndicator(x2, y, x2, y2); |
|
772 |
||
773 |
DrawHorizMapIndicator(x, y, x2, y); |
|
774 |
DrawHorizMapIndicator(x, y2, x2, y2); |
|
775 |
} |
|
776 |
_cur_dpi = old_dpi; |
|
777 |
} |
|
778 |
||
779 |
static void SmallMapWindowProc(Window *w, WindowEvent *e) |
|
780 |
{ |
|
781 |
switch(e->event) { |
|
782 |
case WE_PAINT: { |
|
783 |
const uint16 *tbl; |
|
784 |
int x,y,y_org; |
|
785 |
DrawPixelInfo new_dpi; |
|
786 |
||
787 |
/* draw the window */ |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
788 |
SetDParam(0, STR_00E5_CONTOURS + _smallmap_type); |
0 | 789 |
DrawWindowWidgets(w); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
790 |
|
0 | 791 |
/* draw the legend */ |
792 |
tbl = _legend_table[(_smallmap_type != 2) ? _smallmap_type : (_opt.landscape + IND_OFFS)]; |
|
793 |
x = 4; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
794 |
y_org = w->height - 43 - 11; |
0 | 795 |
y = y_org; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
796 |
while (true) { |
0 | 797 |
GfxFillRect(x, y+1, x+8, y + 5, 0); |
798 |
GfxFillRect(x+1, y+2, x+7, y + 4, (byte)tbl[0]); |
|
799 |
DrawString(x+11, y, tbl[1], 0); |
|
800 |
||
801 |
tbl += 2; |
|
802 |
y += 6; |
|
803 |
||
804 |
if (tbl[0] == 0xFFFF) { |
|
805 |
break; |
|
806 |
} else if (tbl[0] & 0x100) { |
|
807 |
x += 123; |
|
808 |
y = y_org; |
|
809 |
} |
|
810 |
} |
|
811 |
||
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
812 |
if (!FillDrawPixelInfo(&new_dpi, NULL, 3, 17, w->width - 28 + 22, w->height - 64 - 11)) |
0 | 813 |
return; |
814 |
||
815 |
DrawSmallMap(&new_dpi, w, _smallmap_type, _smallmap_show_towns); |
|
816 |
} break; |
|
817 |
||
818 |
case WE_CLICK: |
|
819 |
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
|
820 |
case 4: {/* main wnd */ |
0 | 821 |
Window *w2; |
822 |
Point pt; |
|
823 |
||
824 |
_left_button_clicked = false; |
|
825 |
||
826 |
w2 = FindWindowById(WC_MAIN_WINDOW, 0); |
|
827 |
||
828 |
pt = RemapCoords(WP(w,smallmap_d).scroll_x, WP(w,smallmap_d).scroll_y, 0); |
|
829 |
WP(w2,vp_d).scrollpos_x = pt.x + ((_cursor.pos.x - w->left + 2) << 4) - (w2->viewport->virtual_width >> 1); |
|
830 |
WP(w2,vp_d).scrollpos_y = pt.y + ((_cursor.pos.y - w->top - 16) << 4) - (w2->viewport->virtual_height >> 1); |
|
831 |
} break; |
|
832 |
||
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
833 |
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
|
834 |
case 6: /* show vehicles */ |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
835 |
case 7: /* show industries */ |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
836 |
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
|
837 |
case 9: /* show vegetation */ |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
838 |
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
|
839 |
w->click_state &= ~(1<<5|1<<6|1<<7|1<<8|1<<9|1<<10); |
0 | 840 |
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
|
841 |
_smallmap_type = e->click.widget - 5; |
0 | 842 |
|
843 |
SetWindowDirty(w); |
|
541 | 844 |
SndPlayFx(SND_15_BEEP); |
0 | 845 |
break; |
846 |
||
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
|
847 |
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
|
848 |
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
|
849 |
_smallmap_show_towns = (w->click_state >> 12) & 1; |
0 | 850 |
SetWindowDirty(w); |
541 | 851 |
SndPlayFx(SND_15_BEEP); |
0 | 852 |
break; |
853 |
} |
|
854 |
break; |
|
855 |
||
856 |
case WE_RCLICK: |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
857 |
if (e->click.widget == 4) { |
0 | 858 |
if (_scrolling_viewport) |
859 |
return; |
|
860 |
_scrolling_viewport = true; |
|
861 |
_cursor.delta.x = 0; |
|
862 |
_cursor.delta.y = 0; |
|
863 |
} |
|
864 |
break; |
|
865 |
||
866 |
case WE_MOUSELOOP: |
|
867 |
/* update the window every now and then */ |
|
868 |
if ((++w->vscroll.pos & 0x1F) == 0) |
|
869 |
SetWindowDirty(w); |
|
870 |
break; |
|
871 |
} |
|
872 |
} |
|
873 |
||
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
874 |
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
|
875 |
-1,-1, 446, 314, |
0 | 876 |
WC_SMALLMAP,0, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
877 |
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
|
878 |
_smallmap_widgets, |
0 | 879 |
SmallMapWindowProc |
880 |
}; |
|
881 |
||
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
|
882 |
void ShowSmallMap(void) |
0 | 883 |
{ |
884 |
Window *w; |
|
885 |
ViewPort *vp; |
|
886 |
int x,y; |
|
887 |
||
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
888 |
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
|
889 |
if (w) { |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
890 |
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
|
891 |
w->resize.width = 350; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
892 |
w->resize.height = 250; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
893 |
|
0 | 894 |
vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport; |
895 |
||
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
896 |
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
|
897 |
y = ((((vp->virtual_height- (120*32)) / 2) + vp->virtual_top ) / 2) - 32; |
0 | 898 |
WP(w,smallmap_d).scroll_x = (y-x) & ~0xF; |
899 |
WP(w,smallmap_d).scroll_y = (x+y) & ~0xF; |
|
900 |
WP(w,smallmap_d).subscroll = 0; |
|
901 |
} |
|
902 |
} |
|
903 |
||
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
|
904 |
/* 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
|
905 |
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
|
906 |
{ 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
|
907 |
{ 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
|
908 |
{ 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
|
909 |
{ 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
|
910 |
{ 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
|
911 |
{ 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
|
912 |
{ 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
|
913 |
{ 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
|
914 |
{ 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
|
915 |
{ 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
|
916 |
{ 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
|
917 |
{ 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
|
918 |
{ 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
|
919 |
}; |
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
|
920 |
|
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
|
921 |
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
|
922 |
{ |
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
|
923 |
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
|
924 |
|
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 |
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
|
926 |
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
|
927 |
// 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
|
928 |
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
|
929 |
|
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
|
930 |
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
|
931 |
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
|
932 |
} 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
|
933 |
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
|
934 |
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
|
935 |
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
|
936 |
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
|
937 |
} 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
|
938 |
|
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
|
939 |
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
|
940 |
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
|
941 |
} 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
|
942 |
|
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
|
943 |
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
|
944 |
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
|
945 |
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
|
946 |
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
|
947 |
|
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 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
|
949 |
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
|
950 |
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
|
951 |
} 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
|
952 |
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
|
953 |
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
|
954 |
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
|
955 |
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
|
956 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
957 |
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
|
958 |
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
|
959 |
} break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
960 |
} |
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
|
961 |
} break; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
962 |
case WE_RESIZE: { |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
963 |
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
|
964 |
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
|
965 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
966 |
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
|
967 |
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
|
968 |
} 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
|
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 |
} |
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
|
971 |
|
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 |
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
|
973 |
-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
|
974 |
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
|
975 |
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
|
976 |
_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
|
977 |
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
|
978 |
}; |
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
|
979 |
|
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
|
980 |
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
|
981 |
{ |
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 |
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
|
983 |
int i = 0; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
984 |
|
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
|
985 |
// 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
|
986 |
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
|
987 |
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
|
988 |
} |
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
|
989 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
990 |
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
|
991 |
if (w) { |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
992 |
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
|
993 |
// 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
|
994 |
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
|
995 |
// 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
|
996 |
v = FindWindowById(WC_MAIN_WINDOW, 0); |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
997 |
// 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
|
998 |
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
|
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 |
// 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
|
1001 |
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
|
1002 |
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
|
1003 |
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
|
1004 |
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
|
1005 |
} |
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 |
} |