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