author | Darkvater |
Sat, 18 Mar 2006 15:12:24 +0000 | |
branch | 0.4.5 |
changeset 9918 | a151c4749c7a |
parent 2907 | 65c92989a1f3 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1815
diff
changeset
|
4 |
#include "openttd.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
5 |
#include "functions.h" |
1349
07514c2cc6d1
(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
|
6 |
#include "spritecache.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
500
diff
changeset
|
7 |
#include "table/strings.h" |
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
8 |
#include "table/sprites.h" |
679
e959706a3e4d
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
541
diff
changeset
|
9 |
#include "map.h" |
1209
a1ac96655b79
(svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents:
1093
diff
changeset
|
10 |
#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
|
11 |
#include "gui.h" |
0 | 12 |
#include "window.h" |
13 |
#include "gfx.h" |
|
14 |
#include "viewport.h" |
|
15 |
#include "player.h" |
|
16 |
#include "vehicle.h" |
|
17 |
#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
|
18 |
#include "sound.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2062
diff
changeset
|
19 |
#include "variables.h" |
0 | 20 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
21 |
static const Widget _smallmap_widgets[] = { |
2725
5c632bc5be28
(svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents:
2635
diff
changeset
|
22 |
{ WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
23 |
{ WWT_CAPTION, RESIZE_RIGHT, 13, 11, 433, 0, 13, STR_00B0_MAP, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
24 |
{ WWT_STICKYBOX, RESIZE_LR, 13, 434, 445, 0, 13, 0x0, STR_STICKY_BUTTON}, |
2907
65c92989a1f3
(svn r3462) - Fix: a one-off pixel alignment in the minimap window that "overflowed" its panel in the tropical climate (qball should be satisfied now)
Darkvater
parents:
2725
diff
changeset
|
25 |
{ WWT_PANEL, RESIZE_RB, 13, 0, 445, 14, 257, 0x0, STR_NULL}, |
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
26 |
{ WWT_6, RESIZE_RB, 13, 2, 443, 16, 255, 0x0, STR_NULL}, |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
27 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 380, 401, 258, 279, SPR_IMG_SHOW_COUNTOURS, STR_0191_SHOW_LAND_CONTOURS_ON_MAP}, |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
28 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 402, 423, 258, 279, SPR_IMG_SHOW_VEHICLES, STR_0192_SHOW_VEHICLES_ON_MAP}, |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
29 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 424, 445, 258, 279, SPR_IMG_INDUSTRY, STR_0193_SHOW_INDUSTRIES_ON_MAP}, |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
30 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 380, 401, 280, 301, SPR_IMG_SHOW_ROUTES, STR_0194_SHOW_TRANSPORT_ROUTES_ON}, |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
31 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 402, 423, 280, 301, SPR_IMG_PLANTTREES, STR_0195_SHOW_VEGETATION_ON_MAP}, |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
32 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 424, 445, 280, 301, SPR_IMG_COMPANY_GENERAL, STR_0196_SHOW_LAND_OWNERS_ON_MAP}, |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
33 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 358, 379, 258, 279, 0x0, STR_NULL}, |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
34 |
{ WWT_IMGBTN, RESIZE_LRTB, 13, 358, 379, 280, 301, SPR_IMG_TOWN, STR_0197_TOGGLE_TOWN_NAMES_ON_OFF}, |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
35 |
{ WWT_IMGBTN, RESIZE_RTB, 13, 0, 357, 258, 301, 0x0, STR_NULL}, |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
36 |
{ WWT_PANEL, RESIZE_RTB, 13, 0, 433, 302, 313, 0x0, STR_NULL}, |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
37 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 13, 434, 445, 302, 313, 0x0, STR_RESIZE_BUTTON}, |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
38 |
{ WIDGETS_END}, |
0 | 39 |
}; |
40 |
||
41 |
static int _smallmap_type; |
|
42 |
static bool _smallmap_show_towns = true; |
|
43 |
||
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
44 |
#define MK(a,b) a, b |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
45 |
#define MKEND() 0xFFFF |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
46 |
#define MS(a,b) (a | 0x100), b |
0 | 47 |
|
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
48 |
/* Legend text giving the colours to look for on the minimap */ |
0 | 49 |
static const uint16 _legend_land_contours[] = { |
50 |
MK(0x5A,STR_00F0_100M), |
|
51 |
MK(0x5C,STR_00F1_200M), |
|
52 |
MK(0x5E,STR_00F2_300M), |
|
53 |
MK(0x1F,STR_00F3_400M), |
|
54 |
MK(0x27,STR_00F4_500M), |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
55 |
|
0 | 56 |
MS(0xD7,STR_00EB_ROADS), |
57 |
MK(0x0A,STR_00EC_RAILROADS), |
|
58 |
MK(0x98,STR_00ED_STATIONS_AIRPORTS_DOCKS), |
|
59 |
MK(0xB5,STR_00EE_BUILDINGS_INDUSTRIES), |
|
60 |
MK(0x0F,STR_00EF_VEHICLES), |
|
61 |
MKEND() |
|
62 |
}; |
|
63 |
||
64 |
static const uint16 _legend_vehicles[] = { |
|
65 |
MK(0xB8,STR_00F5_TRAINS), |
|
66 |
MK(0xBF,STR_00F6_ROAD_VEHICLES), |
|
67 |
MK(0x98,STR_00F7_SHIPS), |
|
68 |
MK(0x0F,STR_00F8_AIRCRAFT), |
|
69 |
MS(0xD7,STR_00F9_TRANSPORT_ROUTES), |
|
70 |
MK(0xB5,STR_00EE_BUILDINGS_INDUSTRIES), |
|
71 |
MKEND() |
|
72 |
}; |
|
73 |
||
74 |
static const uint16 _legend_industries_normal[] = { |
|
75 |
MK(0xD7,STR_00FA_COAL_MINE), |
|
76 |
MK(0xB8,STR_00FB_POWER_STATION), |
|
77 |
MK(0x56,STR_00FC_FOREST), |
|
78 |
MK(0xC2,STR_00FD_SAWMILL), |
|
79 |
MK(0xBF,STR_00FE_OIL_REFINERY), |
|
80 |
MK(0x0F,STR_0105_BANK), |
|
81 |
||
82 |
MS(0x30,STR_00FF_FARM), |
|
83 |
MK(0xAE,STR_0100_FACTORY), |
|
84 |
MK(0x98,STR_0102_OIL_WELLS), |
|
85 |
MK(0x37,STR_0103_IRON_ORE_MINE), |
|
86 |
MK(0x0A,STR_0104_STEEL_MILL), |
|
87 |
MKEND() |
|
88 |
}; |
|
89 |
||
90 |
static const uint16 _legend_industries_hilly[] = { |
|
91 |
MK(0xD7,STR_00FA_COAL_MINE), |
|
92 |
MK(0xB8,STR_00FB_POWER_STATION), |
|
93 |
MK(0x56,STR_00FC_FOREST), |
|
94 |
MK(0x0A,STR_0106_PAPER_MILL), |
|
95 |
MK(0xBF,STR_00FE_OIL_REFINERY), |
|
96 |
MK(0x37,STR_0108_FOOD_PROCESSING_PLANT), |
|
97 |
MS(0x30,STR_00FF_FARM), |
|
98 |
||
99 |
MK(0xAE,STR_0101_PRINTING_WORKS), |
|
100 |
MK(0x98,STR_0102_OIL_WELLS), |
|
101 |
MK(0xC2,STR_0107_GOLD_MINE), |
|
102 |
MK(0x0F,STR_0105_BANK), |
|
103 |
MKEND() |
|
104 |
}; |
|
105 |
||
106 |
static const uint16 _legend_industries_desert[] = { |
|
107 |
MK(0xBF,STR_00FE_OIL_REFINERY), |
|
108 |
MK(0x98,STR_0102_OIL_WELLS), |
|
109 |
MK(0x0F,STR_0105_BANK), |
|
110 |
MK(0xB8,STR_0109_DIAMOND_MINE), |
|
111 |
MK(0x37,STR_0108_FOOD_PROCESSING_PLANT), |
|
112 |
MK(0x0A,STR_010A_COPPER_ORE_MINE), |
|
113 |
MK(0x30,STR_00FF_FARM), |
|
114 |
MS(0x56,STR_010B_FRUIT_PLANTATION), |
|
115 |
||
116 |
MK(0x27,STR_010C_RUBBER_PLANTATION), |
|
117 |
MK(0x25,STR_010D_WATER_SUPPLY), |
|
118 |
MK(0xD0,STR_010E_WATER_TOWER), |
|
119 |
MK(0xAE,STR_0100_FACTORY), |
|
120 |
MK(0xC2,STR_010F_LUMBER_MILL), |
|
121 |
MKEND() |
|
122 |
}; |
|
123 |
||
124 |
static const uint16 _legend_industries_candy[] = { |
|
125 |
MK(0x30,STR_0110_COTTON_CANDY_FOREST), |
|
126 |
MK(0xAE,STR_0111_CANDY_FACTORY), |
|
127 |
MK(0x27,STR_0112_BATTERY_FARM), |
|
128 |
MK(0x37,STR_0113_COLA_WELLS), |
|
129 |
MK(0xD0,STR_0114_TOY_SHOP), |
|
130 |
MK(0x0A,STR_0115_TOY_FACTORY), |
|
131 |
MS(0x25,STR_0116_PLASTIC_FOUNTAINS), |
|
132 |
||
133 |
MK(0xB8,STR_0117_FIZZY_DRINK_FACTORY), |
|
134 |
MK(0x98,STR_0118_BUBBLE_GENERATOR), |
|
135 |
MK(0xC2,STR_0119_TOFFEE_QUARRY), |
|
136 |
MK(0x0F,STR_011A_SUGAR_MINE), |
|
137 |
MKEND() |
|
138 |
}; |
|
139 |
||
140 |
static const uint16 _legend_routes[] = { |
|
141 |
MK(0xD7,STR_00EB_ROADS), |
|
142 |
MK(0x0A,STR_00EC_RAILROADS), |
|
143 |
MK(0xB5,STR_00EE_BUILDINGS_INDUSTRIES), |
|
144 |
MS(0x56,STR_011B_RAILROAD_STATION), |
|
145 |
||
146 |
MK(0xC2,STR_011C_TRUCK_LOADING_BAY), |
|
147 |
MK(0xBF,STR_011D_BUS_STATION), |
|
148 |
MK(0xB8,STR_011E_AIRPORT_HELIPORT), |
|
149 |
MK(0x98,STR_011F_DOCK), |
|
150 |
MKEND() |
|
151 |
}; |
|
152 |
||
153 |
static const uint16 _legend_vegetation[] = { |
|
154 |
MK(0x52,STR_0120_ROUGH_LAND), |
|
155 |
MK(0x54,STR_0121_GRASS_LAND), |
|
156 |
MK(0x37,STR_0122_BARE_LAND), |
|
157 |
MK(0x25,STR_0123_FIELDS), |
|
158 |
MK(0x57,STR_0124_TREES), |
|
159 |
MK(0xD0,STR_00FC_FOREST), |
|
160 |
MS(0x0A,STR_0125_ROCKS), |
|
161 |
||
162 |
MK(0xC2,STR_012A_DESERT), |
|
163 |
MK(0x98,STR_012B_SNOW), |
|
164 |
MK(0xD7,STR_00F9_TRANSPORT_ROUTES), |
|
165 |
MK(0xB5,STR_00EE_BUILDINGS_INDUSTRIES), |
|
166 |
MKEND() |
|
167 |
}; |
|
168 |
||
169 |
static const uint16 _legend_land_owners[] = { |
|
170 |
MK(0xCA,STR_0126_WATER), |
|
171 |
MK(0x54,STR_0127_NO_OWNER), |
|
172 |
MK(0xB4,STR_0128_TOWNS), |
|
173 |
MK(0x20,STR_0129_INDUSTRIES), |
|
174 |
MKEND() |
|
175 |
}; |
|
176 |
#undef MK |
|
177 |
#undef MS |
|
178 |
#undef MKEND |
|
179 |
||
180 |
||
181 |
enum { IND_OFFS = 6 }; |
|
182 |
static const uint16 * const _legend_table[] = { |
|
183 |
_legend_land_contours, |
|
184 |
_legend_vehicles, |
|
185 |
NULL, |
|
186 |
_legend_routes, |
|
187 |
_legend_vegetation, |
|
188 |
_legend_land_owners, |
|
189 |
||
190 |
_legend_industries_normal, |
|
191 |
_legend_industries_hilly, |
|
192 |
_legend_industries_desert, |
|
193 |
_legend_industries_candy, |
|
194 |
}; |
|
195 |
||
9918
a151c4749c7a
(svn r3948) - Fix: [ 1415782 ] crash in string code with openbsd/zaurus; alignment issues (thanks Tron for the help). Backport of r3529, r3553 from trunk
Darkvater
parents:
2907
diff
changeset
|
196 |
#if defined(OTTD_ALIGNMENT) |
2062 | 197 |
static inline void WRITE_PIXELS(Pixel* d, uint32 val) |
0 | 198 |
{ |
199 |
# if defined(TTD_BIG_ENDIAN) |
|
2635 | 200 |
d[0] = GB(val, 24, 8); |
201 |
d[1] = GB(val, 16, 8); |
|
202 |
d[2] = GB(val, 8, 8); |
|
203 |
d[3] = GB(val, 0, 8); |
|
0 | 204 |
# elif defined(TTD_LITTLE_ENDIAN) |
2635 | 205 |
d[0] = GB(val, 0, 8); |
206 |
d[1] = GB(val, 8, 8); |
|
207 |
d[2] = GB(val, 16, 8); |
|
208 |
d[3] = GB(val, 24, 8); |
|
0 | 209 |
# endif |
210 |
} |
|
211 |
||
212 |
/* need to use OR, otherwise we will overwrite the wrong pixels at the edges :( */ |
|
2062 | 213 |
static inline void WRITE_PIXELS_OR(Pixel* d, uint32 val) |
0 | 214 |
{ |
215 |
# if defined(TTD_BIG_ENDIAN) |
|
2635 | 216 |
d[0] |= GB(val, 24, 8); |
217 |
d[1] |= GB(val, 16, 8); |
|
218 |
d[2] |= GB(val, 8, 8); |
|
219 |
d[3] |= GB(val, 0, 8); |
|
0 | 220 |
# elif defined(TTD_LITTLE_ENDIAN) |
2635 | 221 |
d[0] |= GB(val, 0, 8); |
222 |
d[1] |= GB(val, 8, 8); |
|
223 |
d[2] |= GB(val, 16, 8); |
|
224 |
d[3] |= GB(val, 24, 8); |
|
0 | 225 |
# endif |
226 |
} |
|
227 |
#else |
|
228 |
# define WRITE_PIXELS(dst, val) *(uint32*)(dst) = (val); |
|
229 |
# define WRITE_PIXELS_OR(dst,val) *(uint32*)(dst) |= (val); |
|
230 |
#endif |
|
231 |
||
232 |
#if defined(TTD_BIG_ENDIAN) |
|
233 |
# define MKCOLOR(x) BSWAP32(x) |
|
234 |
#elif defined(TTD_LITTLE_ENDIAN) |
|
235 |
# define MKCOLOR(x) (x) |
|
236 |
#endif |
|
237 |
||
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
238 |
/* Height encodings; 16 levels XXX - needs updating for more/finer heights! */ |
0 | 239 |
static const uint32 _map_height_bits[16] = { |
240 |
MKCOLOR(0x5A5A5A5A), |
|
241 |
MKCOLOR(0x5A5B5A5B), |
|
242 |
MKCOLOR(0x5B5B5B5B), |
|
243 |
MKCOLOR(0x5B5C5B5C), |
|
244 |
MKCOLOR(0x5C5C5C5C), |
|
245 |
MKCOLOR(0x5C5D5C5D), |
|
246 |
MKCOLOR(0x5D5D5D5D), |
|
247 |
MKCOLOR(0x5D5E5D5E), |
|
248 |
MKCOLOR(0x5E5E5E5E), |
|
249 |
MKCOLOR(0x5E5F5E5F), |
|
250 |
MKCOLOR(0x5F5F5F5F), |
|
251 |
MKCOLOR(0x5F1F5F1F), |
|
252 |
MKCOLOR(0x1F1F1F1F), |
|
253 |
MKCOLOR(0x1F271F27), |
|
254 |
MKCOLOR(0x27272727), |
|
255 |
MKCOLOR(0x27272727), |
|
256 |
}; |
|
257 |
||
1511
32b095e3da76
(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 |
typedef struct AndOr { |
32b095e3da76
(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 |
uint32 mor; |
32b095e3da76
(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 |
uint32 mand; |
32b095e3da76
(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 |
} AndOr; |
32b095e3da76
(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 |
|
32b095e3da76
(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 inline uint32 ApplyMask(uint32 colour, const AndOr* mask) |
32b095e3da76
(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
|
264 |
{ |
32b095e3da76
(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
|
265 |
return (colour & mask->mand) | mask->mor; |
32b095e3da76
(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
|
266 |
} |
32b095e3da76
(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
|
267 |
|
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
268 |
|
1511
32b095e3da76
(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
|
269 |
static const AndOr _smallmap_contours_andor[] = { |
0 | 270 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
271 |
{MKCOLOR(0x000A0A00),MKCOLOR(0xFF0000FF)}, |
|
272 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
273 |
{MKCOLOR(0x00B5B500),MKCOLOR(0xFF0000FF)}, |
|
274 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
275 |
{MKCOLOR(0x98989898),MKCOLOR(0x00000000)}, |
|
276 |
{MKCOLOR(0xCACACACA),MKCOLOR(0x00000000)}, |
|
277 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
278 |
{MKCOLOR(0xB5B5B5B5),MKCOLOR(0x00000000)}, |
|
279 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
280 |
{MKCOLOR(0x00B5B500),MKCOLOR(0xFF0000FF)}, |
|
281 |
{MKCOLOR(0x000A0A00),MKCOLOR(0xFF0000FF)}, |
|
282 |
}; |
|
283 |
||
1511
32b095e3da76
(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
|
284 |
static const AndOr _smallmap_vehicles_andor[] = { |
0 | 285 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
286 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
287 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
288 |
{MKCOLOR(0x00B5B500),MKCOLOR(0xFF0000FF)}, |
|
289 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
290 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
291 |
{MKCOLOR(0xCACACACA),MKCOLOR(0x00000000)}, |
|
292 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
293 |
{MKCOLOR(0xB5B5B5B5),MKCOLOR(0x00000000)}, |
|
294 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
295 |
{MKCOLOR(0x00B5B500),MKCOLOR(0xFF0000FF)}, |
|
296 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
297 |
}; |
|
298 |
||
1511
32b095e3da76
(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
|
299 |
static const AndOr _smallmap_vegetation_andor[] = { |
0 | 300 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
301 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
302 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
303 |
{MKCOLOR(0x00B5B500),MKCOLOR(0xFF0000FF)}, |
|
304 |
{MKCOLOR(0x00575700),MKCOLOR(0xFF0000FF)}, |
|
305 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
306 |
{MKCOLOR(0xCACACACA),MKCOLOR(0x00000000)}, |
|
307 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
308 |
{MKCOLOR(0xB5B5B5B5),MKCOLOR(0x00000000)}, |
|
309 |
{MKCOLOR(0x00000000),MKCOLOR(0xFFFFFFFF)}, |
|
310 |
{MKCOLOR(0x00B5B500),MKCOLOR(0xFF0000FF)}, |
|
311 |
{MKCOLOR(0x00D7D700),MKCOLOR(0xFF0000FF)}, |
|
312 |
}; |
|
313 |
||
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
314 |
typedef uint32 GetSmallMapPixels(TileIndex tile); // typedef callthrough function |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
315 |
|
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
316 |
/** |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
317 |
* Draws one column of the small map in a certain mode onto the screen buffer. This |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
318 |
* function looks exactly the same for all types |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
319 |
* |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
320 |
* @param dst Pointer to a part of the screen buffer to write to. |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
321 |
* @param xc The X coordinate of the first tile in the column. |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
322 |
* @param yc The Y coordinate of the first tile in the column |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
323 |
* @param pitch Number of pixels to advance in the screen buffer each time a pixel is written. |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
324 |
* @param reps Number of lines to draw |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
325 |
* @param mask ? |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
326 |
* @param proc Pointer to the colour function |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
327 |
* @see GetSmallMapPixels(TileIndex) |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
328 |
*/ |
2062 | 329 |
static void DrawSmallMapStuff(Pixel *dst, uint xc, uint yc, int pitch, int reps, uint32 mask, GetSmallMapPixels *proc) |
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
330 |
{ |
2062 | 331 |
Pixel *dst_ptr_end = _screen.dst_ptr + _screen.width * _screen.height - _screen.width; |
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
332 |
|
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
333 |
do { |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
334 |
// check if the tile (xc,yc) is within the map range |
1919
0ad642b26ff2
(svn r2425) - Fix (regression): wrong sprite for level-land cursor (thx Tron)
Darkvater
parents:
1918
diff
changeset
|
335 |
if (xc < MapMaxX() && yc < MapMaxY()) { |
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
336 |
// check if the dst pointer points to a pixel inside the screen buffer |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
337 |
if (dst > _screen.dst_ptr && dst < dst_ptr_end) |
1981 | 338 |
WRITE_PIXELS_OR(dst, proc(TileXY(xc, yc)) & mask); |
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
339 |
} |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
340 |
// switch to next tile in the column |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
341 |
} while (xc++, yc++, dst += pitch, --reps != 0); |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
342 |
} |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
343 |
|
1516
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
344 |
|
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
345 |
static inline TileType GetEffectiveTileType(TileIndex tile) |
0 | 346 |
{ |
1516
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
347 |
TileType t = GetTileType(tile); |
0 | 348 |
|
349 |
if (t == MP_TUNNELBRIDGE) { |
|
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1981
diff
changeset
|
350 |
t = _m[tile].m5; |
1516
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
351 |
if ((t & 0x80) == 0) t >>= 1; |
0 | 352 |
if ((t & 6) == 0) { |
353 |
t = MP_RAILWAY; |
|
354 |
} else if ((t & 6) == 2) { |
|
355 |
t = MP_STREET; |
|
356 |
} else { |
|
357 |
t = MP_WATER; |
|
358 |
} |
|
359 |
} |
|
1516
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
360 |
return t; |
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
361 |
} |
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
362 |
|
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
363 |
/** |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
364 |
* Return the color a tile would be displayed with in the small map in mode "Contour". |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
365 |
* @param tile The tile of which we would like to get the color. |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
366 |
* @return The color of tile in the small map in mode "Contour" |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
367 |
*/ |
1516
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
368 |
static inline uint32 GetSmallMapContoursPixels(TileIndex tile) |
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
369 |
{ |
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
370 |
TileType t = GetEffectiveTileType(tile); |
0 | 371 |
|
1511
32b095e3da76
(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
|
372 |
return |
32b095e3da76
(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
|
373 |
ApplyMask(_map_height_bits[TileHeight(tile)], &_smallmap_contours_andor[t]); |
0 | 374 |
} |
375 |
||
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
376 |
/** |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
377 |
* Return the color a tile would be displayed with in the small map in mode "Vehicles". |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
378 |
* |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
379 |
* @param t The tile of which we would like to get the color. |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
380 |
* @return The color of tile in the small map in mode "Vehicles" |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
381 |
*/ |
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
382 |
static inline uint32 GetSmallMapVehiclesPixels(TileIndex tile) |
0 | 383 |
{ |
1516
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
384 |
TileType t = GetEffectiveTileType(tile); |
0 | 385 |
|
1511
32b095e3da76
(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
|
386 |
return ApplyMask(MKCOLOR(0x54545454), &_smallmap_vehicles_andor[t]); |
0 | 387 |
} |
388 |
||
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
389 |
/* Industry colours... a total of 175 gfx - XXX - increase if more industries */ |
0 | 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 |
||
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
415 |
/** |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
416 |
* Return the color a tile would be displayed with in the small map in mode "Industries". |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
417 |
* |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
418 |
* @param tile The tile of which we would like to get the color. |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
419 |
* @return The color of tile in the small map in mode "Industries" |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
420 |
*/ |
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
421 |
static inline uint32 GetSmallMapIndustriesPixels(TileIndex tile) |
0 | 422 |
{ |
1516
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
423 |
TileType t = GetEffectiveTileType(tile); |
0 | 424 |
|
425 |
if (t == MP_INDUSTRY) { |
|
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1981
diff
changeset
|
426 |
byte color = _industry_smallmap_colors[_m[tile].m5]; |
0 | 427 |
return color + (color << 8) + (color << 16) + (color << 24); |
428 |
} |
|
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
429 |
|
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
430 |
return ApplyMask(MKCOLOR(0x54545454), &_smallmap_vehicles_andor[t]); |
0 | 431 |
} |
432 |
||
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
433 |
/** |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
434 |
* Return the color a tile would be displayed with in the small map in mode "Routes". |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
435 |
* |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
436 |
* @param t The tile of which we would like to get the color. |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
437 |
* @return The color of tile in the small map in mode "Routes" |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
438 |
*/ |
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
439 |
static inline uint32 GetSmallMapRoutesPixels(TileIndex tile) |
0 | 440 |
{ |
1516
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
441 |
TileType t = GetEffectiveTileType(tile); |
0 | 442 |
uint32 bits; |
443 |
||
444 |
if (t == MP_STATION) { |
|
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1981
diff
changeset
|
445 |
byte m5 = _m[tile].m5; |
0 | 446 |
(bits = MKCOLOR(0x56565656), m5 < 8) || // 8 - railroad station (green) |
447 |
(bits = MKCOLOR(0xB8B8B8B8), m5 < 0x43) || // 67 - airport (red) |
|
448 |
(bits = MKCOLOR(0xC2C2C2C2), m5 < 0x47) || // 71 - truck loading bay (orange) |
|
449 |
(bits = MKCOLOR(0xBFBFBFBF), m5 < 0x4B) || // 75 - bus station (yellow) |
|
450 |
(bits = MKCOLOR(0x98989898), m5 < 0x53) || // 83 - docks (blue) |
|
451 |
(bits = MKCOLOR(0xB8B8B8B8), m5 < 0x73) || // 115 - airport (red) (new airports) |
|
452 |
(bits = MKCOLOR(0xFFFFFFFF), true); // all others |
|
453 |
} else { |
|
454 |
// ground color |
|
1511
32b095e3da76
(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
|
455 |
bits = ApplyMask(MKCOLOR(0x54545454), &_smallmap_contours_andor[t]); |
0 | 456 |
} |
457 |
return bits; |
|
458 |
} |
|
459 |
||
460 |
||
461 |
static const uint32 _vegetation_clear_bits[4 + 7] = { |
|
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
462 |
MKCOLOR(0x37373737), ///< bare land |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
463 |
MKCOLOR(0x37373737), ///< 1/3 grass |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
464 |
MKCOLOR(0x37373737), ///< 2/3 grass |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
465 |
MKCOLOR(0x54545454), ///< full grass |
0 | 466 |
|
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
467 |
MKCOLOR(0x52525252), ///< rough land |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
468 |
MKCOLOR(0x0A0A0A0A), ///< rocks |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
469 |
MKCOLOR(0x25252525), ///< fields |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
470 |
MKCOLOR(0x98989898), ///< snow |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
471 |
MKCOLOR(0xC2C2C2C2), ///< desert |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
472 |
MKCOLOR(0x54545454), ///< unused |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
473 |
MKCOLOR(0x54545454), ///< unused |
0 | 474 |
}; |
475 |
||
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
476 |
static inline uint32 GetSmallMapVegetationPixels(TileIndex tile) |
0 | 477 |
{ |
1516
997a23b8b16c
(svn r2020) Reduce code duplication in the minimap code a bit
tron
parents:
1515
diff
changeset
|
478 |
TileType t = GetEffectiveTileType(tile); |
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
479 |
int i; |
0 | 480 |
uint32 bits; |
481 |
||
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
482 |
switch (t) { |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
483 |
case MP_CLEAR: |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1981
diff
changeset
|
484 |
i = (_m[tile].m5 & 0x1F) - 4; |
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
485 |
if (i >= 0) i >>= 2; |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
486 |
bits = _vegetation_clear_bits[i + 4]; |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
487 |
break; |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
488 |
|
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
489 |
case MP_INDUSTRY: |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1981
diff
changeset
|
490 |
bits = IS_BYTE_INSIDE(_m[tile].m5, 0x10, 0x12) ? MKCOLOR(0xD0D0D0D0) : MKCOLOR(0xB5B5B5B5); |
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
491 |
break; |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
492 |
|
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
493 |
case MP_TREES: |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1981
diff
changeset
|
494 |
if ((_m[tile].m2 & 0x30) == 0x20) |
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
495 |
bits = (_opt.landscape == LT_HILLY) ? MKCOLOR(0x98575798) : MKCOLOR(0xC25757C2); |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
496 |
else |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
497 |
bits = MKCOLOR(0x54575754); |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
498 |
break; |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
499 |
|
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
500 |
default: |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
501 |
bits = ApplyMask(MKCOLOR(0x54545454), &_smallmap_vehicles_andor[t]); |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
502 |
break; |
0 | 503 |
} |
504 |
||
505 |
return bits; |
|
506 |
} |
|
507 |
||
508 |
||
1092 | 509 |
static uint32 _owner_colors[256]; |
0 | 510 |
|
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
511 |
/** |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
512 |
* Return the color a tile would be displayed with in the small map in mode "Owner". |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
513 |
* |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
514 |
* @param t The tile of which we would like to get the color. |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
515 |
* @return The color of tile in the small map in mode "Owner" |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
516 |
*/ |
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
517 |
static inline uint32 GetSmallMapOwnerPixels(TileIndex tile) |
0 | 518 |
{ |
2368
d5a31a409219
(svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents:
2332
diff
changeset
|
519 |
Owner o; |
0 | 520 |
|
2368
d5a31a409219
(svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents:
2332
diff
changeset
|
521 |
switch (GetTileType(tile)) { |
d5a31a409219
(svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents:
2332
diff
changeset
|
522 |
case MP_INDUSTRY: o = OWNER_SPECTATOR; break; |
d5a31a409219
(svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents:
2332
diff
changeset
|
523 |
case MP_HOUSE: o = OWNER_TOWN; break; |
d5a31a409219
(svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents:
2332
diff
changeset
|
524 |
default: o = GetTileOwner(tile); break; |
0 | 525 |
} |
526 |
||
2368
d5a31a409219
(svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents:
2332
diff
changeset
|
527 |
return _owner_colors[o]; |
0 | 528 |
} |
529 |
||
530 |
||
531 |
static const uint32 _smallmap_mask_left[3] = { |
|
532 |
MKCOLOR(0xFF000000), |
|
533 |
MKCOLOR(0xFFFF0000), |
|
534 |
MKCOLOR(0xFFFFFF00), |
|
535 |
}; |
|
536 |
||
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
537 |
static const uint32 _smallmap_mask_right[] = { |
0 | 538 |
MKCOLOR(0x000000FF), |
539 |
MKCOLOR(0x0000FFFF), |
|
540 |
MKCOLOR(0x00FFFFFF), |
|
541 |
}; |
|
542 |
||
543 |
/* each tile has 4 x pixels and 1 y pixel */ |
|
544 |
||
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
545 |
static GetSmallMapPixels *_smallmap_draw_procs[] = { |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
546 |
GetSmallMapContoursPixels, |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
547 |
GetSmallMapVehiclesPixels, |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
548 |
GetSmallMapIndustriesPixels, |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
549 |
GetSmallMapRoutesPixels, |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
550 |
GetSmallMapVegetationPixels, |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
551 |
GetSmallMapOwnerPixels, |
0 | 552 |
}; |
553 |
||
554 |
static const byte _vehicle_type_colors[6] = { |
|
555 |
184, 191, 152, 15, 215, 184 |
|
556 |
}; |
|
557 |
||
500
ef288590e096
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
337
diff
changeset
|
558 |
static inline uint32 dup_byte32(byte b) { |
0 | 559 |
return b + (b << 8) + (b << 16) + (b << 24); |
560 |
} |
|
561 |
||
562 |
static void DrawVertMapIndicator(int x, int y, int x2, int y2) |
|
563 |
{ |
|
564 |
GfxFillRect(x, y, x2, y + 3, 69); |
|
565 |
GfxFillRect(x, y2 - 3, x2, y2, 69); |
|
566 |
} |
|
567 |
||
568 |
static void DrawHorizMapIndicator(int x, int y, int x2, int y2) |
|
569 |
{ |
|
570 |
GfxFillRect(x, y, x + 3, y2, 69); |
|
571 |
GfxFillRect(x2 - 3, y, x2, y2, 69); |
|
572 |
} |
|
573 |
||
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
574 |
/** |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
575 |
* Draws the small map. |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
576 |
* |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
577 |
* Basically, the small map is draw column of pixels by column of pixels. The pixels |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
578 |
* are drawn directly into the screen buffer. The final map is drawn in multiple passes. |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
579 |
* The passes are: |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
580 |
* <ol><li>The colors of tiles in the different modes.</li> |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
581 |
* <li>Town names (optional)</li> |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
582 |
* |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
583 |
* @param dpi pointer to pixel to write onto |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
584 |
* @param w pointer to Window struct |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
585 |
* @param type type of map requested (vegetation, owners, routes, etc) |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
586 |
* @param show_towns true if the town names should be displayed, false if not. |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
587 |
*/ |
0 | 588 |
static void DrawSmallMap(DrawPixelInfo *dpi, Window *w, int type, bool show_towns) |
589 |
{ |
|
590 |
DrawPixelInfo *old_dpi; |
|
591 |
int dx,dy, x, y, x2, y2; |
|
2062 | 592 |
Pixel *ptr; |
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
593 |
int tile_x; |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
594 |
int tile_y; |
0 | 595 |
ViewPort *vp; |
596 |
||
597 |
old_dpi = _cur_dpi; |
|
598 |
_cur_dpi = dpi; |
|
599 |
||
600 |
/* clear it */ |
|
601 |
GfxFillRect(dpi->left, dpi->top, dpi->left + dpi->width - 1, dpi->top + dpi->height - 1, 0); |
|
602 |
||
603 |
/* setup owner table */ |
|
604 |
if (type == 5) { |
|
2368
d5a31a409219
(svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents:
2332
diff
changeset
|
605 |
const Player* p; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
606 |
|
0 | 607 |
/* fill with some special colors */ |
2368
d5a31a409219
(svn r2894) Simplify colouring in owner-mode in the minimap regarding towns and get rid of some magic numbers
tron
parents:
2332
diff
changeset
|
608 |
_owner_colors[OWNER_TOWN] = MKCOLOR(0xB4B4B4B4); |
2332
fa9dc1350e22
(svn r2858) -Codechange: resolved some magic numbers (_Luca_)
truelight
parents:
2186
diff
changeset
|
609 |
_owner_colors[OWNER_NONE] = MKCOLOR(0x54545454); |
fa9dc1350e22
(svn r2858) -Codechange: resolved some magic numbers (_Luca_)
truelight
parents:
2186
diff
changeset
|
610 |
_owner_colors[OWNER_WATER] = MKCOLOR(0xCACACACA); |
fa9dc1350e22
(svn r2858) -Codechange: resolved some magic numbers (_Luca_)
truelight
parents:
2186
diff
changeset
|
611 |
_owner_colors[OWNER_SPECTATOR] = MKCOLOR(0x20202020); /* industry */ |
0 | 612 |
|
613 |
/* now fill with the player colors */ |
|
614 |
FOR_ALL_PLAYERS(p) { |
|
1092 | 615 |
if (p->is_active) |
616 |
_owner_colors[p->index] = |
|
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
617 |
dup_byte32(GetNonSprite(775 + p->player_color)[0xCB]); // XXX - magic pixel |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
618 |
} |
0 | 619 |
} |
620 |
||
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
621 |
tile_x = WP(w,smallmap_d).scroll_x / 16; |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
622 |
tile_y = WP(w,smallmap_d).scroll_y / 16; |
0 | 623 |
|
624 |
dx = dpi->left + WP(w,smallmap_d).subscroll; |
|
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
625 |
tile_x -= dx / 4; |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
626 |
tile_y += dx / 4; |
0 | 627 |
dx &= 3; |
628 |
||
629 |
dy = dpi->top; |
|
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
630 |
tile_x += dy / 2; |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
631 |
tile_y += dy / 2; |
0 | 632 |
|
633 |
if (dy & 1) { |
|
634 |
tile_x++; |
|
635 |
dx += 2; |
|
636 |
if (dx > 3) { |
|
637 |
dx -= 4; |
|
638 |
tile_x--; |
|
639 |
tile_y++; |
|
640 |
} |
|
641 |
} |
|
642 |
||
643 |
ptr = dpi->dst_ptr - dx - 4; |
|
644 |
x = - dx - 4; |
|
645 |
y = 0; |
|
646 |
||
647 |
for(;;) { |
|
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
648 |
uint32 mask; |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
649 |
int reps; |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
650 |
int t; |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
651 |
|
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
652 |
mask = 0xFFFFFFFF; |
0 | 653 |
|
654 |
/* distance from left edge */ |
|
655 |
if (x < 0) { |
|
656 |
if (x < -3) goto skip_column; |
|
657 |
/* mask to use at the left edge */ |
|
658 |
mask = _smallmap_mask_left[x + 3]; |
|
659 |
} |
|
660 |
||
661 |
/* distance from right edge */ |
|
662 |
t = dpi->width - x; |
|
663 |
if (t < 4) { |
|
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
664 |
if (t <= 0) |
0 | 665 |
break; /* exit loop */ |
666 |
/* mask to use at the right edge */ |
|
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
667 |
mask &= _smallmap_mask_right[t - 1]; |
0 | 668 |
} |
669 |
||
670 |
/* number of lines */ |
|
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
671 |
reps = (dpi->height - y + 1) / 2; |
0 | 672 |
if (reps > 0) { |
673 |
// assert(ptr >= dpi->dst_ptr); |
|
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
674 |
DrawSmallMapStuff(ptr, tile_x, tile_y, dpi->pitch*2, reps, mask, _smallmap_draw_procs[type]); |
0 | 675 |
} |
676 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
677 |
skip_column: |
0 | 678 |
if (y == 0) { |
679 |
tile_y++; |
|
680 |
y++; |
|
681 |
ptr += dpi->pitch; |
|
682 |
} else { |
|
683 |
tile_x--; |
|
684 |
y--; |
|
685 |
ptr -= dpi->pitch; |
|
686 |
} |
|
687 |
ptr += 2; |
|
688 |
x += 2; |
|
689 |
} |
|
690 |
||
691 |
/* draw vehicles? */ |
|
692 |
if (type == 0 || type == 1) { |
|
693 |
Vehicle *v; |
|
694 |
bool skip; |
|
695 |
byte color; |
|
696 |
||
697 |
FOR_ALL_VEHICLES(v) { |
|
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
698 |
if (v->type != 0 && v->type != VEH_Special && |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
699 |
(v->vehstatus & (VS_HIDDEN | VS_UNCLICKABLE)) == 0) { |
0 | 700 |
// Remap into flat coordinates. |
701 |
Point pt = RemapCoords( |
|
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
702 |
(v->x_pos - WP(w,smallmap_d).scroll_x) / 16, |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
703 |
(v->y_pos - WP(w,smallmap_d).scroll_y) / 16, |
0 | 704 |
0); |
705 |
x = pt.x; |
|
706 |
y = pt.y; |
|
707 |
||
708 |
// Check if y is out of bounds? |
|
709 |
y -= dpi->top; |
|
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
710 |
if (!IS_INT_INSIDE(y, 0, dpi->height)) continue; |
0 | 711 |
|
712 |
// Default is to draw both pixels. |
|
713 |
skip = false; |
|
714 |
||
715 |
// Offset X coordinate |
|
716 |
x -= WP(w,smallmap_d).subscroll + 3 + dpi->left; |
|
717 |
||
718 |
if (x < 0) { |
|
719 |
// if x+1 is 0, that means we're on the very left edge, |
|
720 |
// and should thus only draw a single pixel |
|
721 |
if (++x != 0) |
|
722 |
continue; |
|
723 |
skip = true; |
|
724 |
} else if (x >= dpi->width - 1) { |
|
725 |
// Check if we're at the very right edge, and if so draw only a single pixel |
|
726 |
if (x != dpi->width - 1) |
|
727 |
continue; |
|
728 |
skip = true; |
|
729 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
730 |
|
0 | 731 |
// Calculate pointer to pixel and the color |
732 |
ptr = dpi->dst_ptr + y * dpi->pitch + x; |
|
733 |
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
|
734 |
|
0 | 735 |
// And draw either one or two pixels depending on clipping |
736 |
ptr[0] = color; |
|
737 |
if (!skip) |
|
738 |
ptr[1] = color; |
|
739 |
} |
|
740 |
} |
|
741 |
} |
|
742 |
||
743 |
if (show_towns) { |
|
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
744 |
const Town *t; |
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
745 |
|
0 | 746 |
FOR_ALL_TOWNS(t) { |
747 |
if (t->xy != 0) { |
|
748 |
// Remap the town coordinate |
|
749 |
Point pt = RemapCoords( |
|
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
750 |
(int)(TileX(t->xy) * 16 - WP(w, smallmap_d).scroll_x) / 16, |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
751 |
(int)(TileY(t->xy) * 16 - WP(w, smallmap_d).scroll_y) / 16, |
0 | 752 |
0); |
753 |
x = pt.x - WP(w,smallmap_d).subscroll + 3 - (t->sign.width_2 >> 1); |
|
754 |
y = pt.y; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
755 |
|
0 | 756 |
// Check if the town sign is within bounds |
757 |
if (x + t->sign.width_2 > dpi->left && |
|
758 |
x < dpi->left + dpi->width && |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
759 |
y + 6 > dpi->top && |
0 | 760 |
y < dpi->top + dpi->height) { |
761 |
// And draw it. |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
762 |
SetDParam(0, t->index); |
0 | 763 |
DrawString(x, y, STR_2056, 12); |
764 |
} |
|
765 |
} |
|
766 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
767 |
} |
0 | 768 |
|
769 |
// Draw map indicators |
|
770 |
{ |
|
771 |
Point pt; |
|
772 |
||
773 |
// Find main viewport. |
|
774 |
vp = FindWindowById(WC_MAIN_WINDOW,0)->viewport; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
775 |
|
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
776 |
pt = RemapCoords(WP(w, smallmap_d).scroll_x, WP(w, smallmap_d).scroll_y, 0); |
0 | 777 |
|
778 |
x = vp->virtual_left - pt.x; |
|
779 |
y = vp->virtual_top - pt.y; |
|
1515
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
780 |
x2 = (x + vp->virtual_width) / 16; |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
781 |
y2 = (y + vp->virtual_height) / 16; |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
782 |
x /= 16; |
f466d02bd936
(svn r2019) Miscellaneous cleanups, like uint -> TileIndex, >> -> /, if cascade -> switch
tron
parents:
1511
diff
changeset
|
783 |
y /= 16; |
0 | 784 |
|
785 |
x -= WP(w,smallmap_d).subscroll; |
|
786 |
x2 -= WP(w,smallmap_d).subscroll; |
|
787 |
||
788 |
DrawVertMapIndicator(x, y, x, y2); |
|
789 |
DrawVertMapIndicator(x2, y, x2, y2); |
|
790 |
||
791 |
DrawHorizMapIndicator(x, y, x2, y); |
|
792 |
DrawHorizMapIndicator(x, y2, x2, y2); |
|
793 |
} |
|
794 |
_cur_dpi = old_dpi; |
|
795 |
} |
|
796 |
||
797 |
static void SmallMapWindowProc(Window *w, WindowEvent *e) |
|
798 |
{ |
|
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
799 |
switch (e->event) { |
0 | 800 |
case WE_PAINT: { |
801 |
const uint16 *tbl; |
|
802 |
int x,y,y_org; |
|
803 |
DrawPixelInfo new_dpi; |
|
804 |
||
805 |
/* draw the window */ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
806 |
SetDParam(0, STR_00E5_CONTOURS + _smallmap_type); |
0 | 807 |
DrawWindowWidgets(w); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
808 |
|
0 | 809 |
/* draw the legend */ |
810 |
tbl = _legend_table[(_smallmap_type != 2) ? _smallmap_type : (_opt.landscape + IND_OFFS)]; |
|
811 |
x = 4; |
|
2907
65c92989a1f3
(svn r3462) - Fix: a one-off pixel alignment in the minimap window that "overflowed" its panel in the tropical climate (qball should be satisfied now)
Darkvater
parents:
2725
diff
changeset
|
812 |
y_org = w->height - 44 - 11; |
0 | 813 |
y = y_org; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
814 |
while (true) { |
0 | 815 |
GfxFillRect(x, y+1, x+8, y + 5, 0); |
816 |
GfxFillRect(x+1, y+2, x+7, y + 4, (byte)tbl[0]); |
|
817 |
DrawString(x+11, y, tbl[1], 0); |
|
818 |
||
819 |
tbl += 2; |
|
820 |
y += 6; |
|
821 |
||
822 |
if (tbl[0] == 0xFFFF) { |
|
823 |
break; |
|
824 |
} else if (tbl[0] & 0x100) { |
|
825 |
x += 123; |
|
826 |
y = y_org; |
|
827 |
} |
|
828 |
} |
|
829 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
830 |
if (!FillDrawPixelInfo(&new_dpi, NULL, 3, 17, w->width - 28 + 22, w->height - 64 - 11)) |
0 | 831 |
return; |
832 |
||
833 |
DrawSmallMap(&new_dpi, w, _smallmap_type, _smallmap_show_towns); |
|
834 |
} break; |
|
835 |
||
836 |
case WE_CLICK: |
|
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
837 |
switch (e->click.widget) { |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
838 |
case 4: {/* Main wnd */ |
0 | 839 |
Window *w2; |
840 |
Point pt; |
|
841 |
||
842 |
_left_button_clicked = false; |
|
843 |
||
844 |
w2 = FindWindowById(WC_MAIN_WINDOW, 0); |
|
845 |
||
846 |
pt = RemapCoords(WP(w,smallmap_d).scroll_x, WP(w,smallmap_d).scroll_y, 0); |
|
847 |
WP(w2,vp_d).scrollpos_x = pt.x + ((_cursor.pos.x - w->left + 2) << 4) - (w2->viewport->virtual_width >> 1); |
|
848 |
WP(w2,vp_d).scrollpos_y = pt.y + ((_cursor.pos.y - w->top - 16) << 4) - (w2->viewport->virtual_height >> 1); |
|
849 |
} break; |
|
850 |
||
1918
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
851 |
case 5: /* Show land contours */ |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
852 |
case 6: /* Show vehicles */ |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
853 |
case 7: /* Show industries */ |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
854 |
case 8: /* Show transport routes */ |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
855 |
case 9: /* Show vegetation */ |
68d78ef6833d
(svn r2424) - Fix: backport the smallmap_gui.c changes from the map/ branch into trunk. This also implicitely fixes the bug where the game would crash in certain resolutions with certain minimap masks when dragged partly outside the game-area.
Darkvater
parents:
1901
diff
changeset
|
856 |
case 10: /* Show land owners */ |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
857 |
w->click_state &= ~(1<<5|1<<6|1<<7|1<<8|1<<9|1<<10); |
0 | 858 |
w->click_state |= 1 << e->click.widget; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
859 |
_smallmap_type = e->click.widget - 5; |
0 | 860 |
|
861 |
SetWindowDirty(w); |
|
541 | 862 |
SndPlayFx(SND_15_BEEP); |
0 | 863 |
break; |
864 |
||
758
bd9e868b9fae
(svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents:
682
diff
changeset
|
865 |
case 12: /* toggle town names */ |
bd9e868b9fae
(svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents:
682
diff
changeset
|
866 |
w->click_state ^= (1 << 12); |
bd9e868b9fae
(svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents:
682
diff
changeset
|
867 |
_smallmap_show_towns = (w->click_state >> 12) & 1; |
0 | 868 |
SetWindowDirty(w); |
541 | 869 |
SndPlayFx(SND_15_BEEP); |
0 | 870 |
break; |
871 |
} |
|
872 |
break; |
|
873 |
||
874 |
case WE_RCLICK: |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
875 |
if (e->click.widget == 4) { |
0 | 876 |
if (_scrolling_viewport) |
877 |
return; |
|
878 |
_scrolling_viewport = true; |
|
879 |
_cursor.delta.x = 0; |
|
880 |
_cursor.delta.y = 0; |
|
881 |
} |
|
882 |
break; |
|
883 |
||
884 |
case WE_MOUSELOOP: |
|
885 |
/* update the window every now and then */ |
|
886 |
if ((++w->vscroll.pos & 0x1F) == 0) |
|
887 |
SetWindowDirty(w); |
|
888 |
break; |
|
889 |
} |
|
890 |
} |
|
891 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
892 |
static const WindowDesc _smallmap_desc = { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
893 |
-1,-1, 446, 314, |
0 | 894 |
WC_SMALLMAP,0, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
895 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
896 |
_smallmap_widgets, |
0 | 897 |
SmallMapWindowProc |
898 |
}; |
|
899 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1092
diff
changeset
|
900 |
void ShowSmallMap(void) |
0 | 901 |
{ |
902 |
Window *w; |
|
903 |
ViewPort *vp; |
|
904 |
int x,y; |
|
905 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
906 |
w = AllocateWindowDescFront(&_smallmap_desc, 0); |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
907 |
if (w) { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
908 |
w->click_state = ((1<<5) << _smallmap_type) | (_smallmap_show_towns << 12); |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
909 |
w->resize.width = 350; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
910 |
w->resize.height = 250; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
911 |
|
0 | 912 |
vp = FindWindowById(WC_MAIN_WINDOW, 0)->viewport; |
913 |
||
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
914 |
x = (((vp->virtual_width - (220*32)) / 2) + vp->virtual_left) / 4; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
915 |
y = ((((vp->virtual_height- (120*32)) / 2) + vp->virtual_top ) / 2) - 32; |
0 | 916 |
WP(w,smallmap_d).scroll_x = (y-x) & ~0xF; |
917 |
WP(w,smallmap_d).scroll_y = (x+y) & ~0xF; |
|
918 |
WP(w,smallmap_d).subscroll = 0; |
|
919 |
} |
|
920 |
} |
|
921 |
||
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
|
922 |
/* Extra ViewPort Window Stuff */ |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
923 |
static const Widget _extra_view_port_widgets[] = { |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
924 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
925 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 287, 0, 13, STR_EXTRA_VIEW_PORT_TITLE, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
926 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 288, 299, 0, 13, 0x0, STR_STICKY_BUTTON}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
927 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 299, 14, 233, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
928 |
{ WWT_6, RESIZE_RB, 14, 2, 297, 16, 231, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
929 |
{ WWT_PANEL, RESIZE_TB, 14, 0, 21, 234, 255, 0x2DF, STR_017F_ZOOM_THE_VIEW_IN}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
930 |
{ WWT_PANEL, RESIZE_TB, 14, 22, 43, 234, 255, 0x2E0, STR_0180_ZOOM_THE_VIEW_OUT}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
931 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 44, 171, 234, 255, STR_EXTRA_VIEW_MOVE_MAIN_TO_VIEW,STR_EXTRA_VIEW_MOVE_MAIN_TO_VIEW_TT}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
932 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 172, 298, 234, 255, STR_EXTRA_VIEW_MOVE_VIEW_TO_MAIN,STR_EXTRA_VIEW_MOVE_VIEW_TO_MAIN_TT}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
933 |
{ WWT_PANEL, RESIZE_RTB, 14, 299, 299, 234, 255, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
934 |
{ WWT_PANEL, RESIZE_RTB, 14, 0, 287, 256, 267, 0x0, STR_NULL}, |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
935 |
{ 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
|
936 |
{ 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
|
937 |
}; |
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 |
|
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
|
939 |
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
|
940 |
{ |
1815
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
941 |
switch (e->event) { |
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
942 |
case WE_CREATE: /* Disable zoom in button */ |
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
943 |
w->disabled_state = (1 << 5); |
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
944 |
break; |
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
945 |
case WE_PAINT: |
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
|
946 |
// 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
|
947 |
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
|
948 |
|
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
949 |
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
|
950 |
DrawWindowViewport(w); |
1815
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
951 |
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
|
952 |
|
1815
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
953 |
case WE_CLICK: { |
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
954 |
switch (e->click.widget) { |
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
955 |
case 5: /* zoom in */ |
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
956 |
DoZoomInOutWindow(ZOOM_IN, w); |
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
957 |
break; |
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
958 |
case 6: /* zoom out */ |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
959 |
DoZoomInOutWindow(ZOOM_OUT, w); |
1815
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
960 |
break; |
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
961 |
case 7: { /* location button (move main view to same spot as this view) 'Paste Location' */ |
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
962 |
Window *w2 = FindWindowById(WC_MAIN_WINDOW, 0); |
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
963 |
int x = WP(w, vp_d).scrollpos_x; // Where is the main looking at |
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
964 |
int y = WP(w, vp_d).scrollpos_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
|
965 |
|
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
966 |
// set this view to same location. Based on the center, adjusting for zoom |
1815
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
967 |
WP(w2, vp_d).scrollpos_x = x - (w2->viewport->virtual_width - w->viewport->virtual_width) / 2; |
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
968 |
WP(w2, vp_d).scrollpos_y = y - (w2->viewport->virtual_height - w->viewport->virtual_height) / 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
|
969 |
} break; |
1815
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
970 |
case 8: { /* inverse location button (move this view to same spot as main view) 'Copy Location' */ |
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2368
diff
changeset
|
971 |
const Window* w2 = FindWindowById(WC_MAIN_WINDOW, 0); |
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2368
diff
changeset
|
972 |
int x = WP(w2, const vp_d).scrollpos_x; |
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2368
diff
changeset
|
973 |
int y = WP(w2, const vp_d).scrollpos_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
|
974 |
|
1815
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
975 |
WP(w, vp_d).scrollpos_x = x + (w2->viewport->virtual_width - w->viewport->virtual_width) / 2; |
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
976 |
WP(w, vp_d).scrollpos_y = y + (w2->viewport->virtual_height - w->viewport->virtual_height) / 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
|
977 |
} break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
978 |
} |
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
|
979 |
} break; |
1815
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
980 |
|
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
981 |
case WE_RESIZE: |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
982 |
w->viewport->width += e->sizing.diff.x; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
983 |
w->viewport->height += e->sizing.diff.y; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
984 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
985 |
w->viewport->virtual_width += e->sizing.diff.x; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
986 |
w->viewport->virtual_height += e->sizing.diff.y; |
1815
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
987 |
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
|
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 |
} |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
990 |
|
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
991 |
static const WindowDesc _extra_view_port_desc = { |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
992 |
-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
|
993 |
WC_EXTRA_VIEW_PORT,0, |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
994 |
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
|
995 |
_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
|
996 |
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
|
997 |
}; |
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 |
|
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1092
diff
changeset
|
999 |
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
|
1000 |
{ |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1001 |
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
|
1002 |
int i = 0; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1003 |
|
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
|
1004 |
// find next free window number for extra viewport |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
1005 |
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
|
1006 |
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
|
1007 |
} |
c3964b43943e
(svn r153) -Feature: [1009710] Extra Viewport. In the minimap dropdown menu, open a new viewport to have a quick look at your favorite map-positions. Independent zoom and quick jump to/from viewport (Dribbel)
darkvater
parents:
12
diff
changeset
|
1008 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
1009 |
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
|
1010 |
if (w) { |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
856
diff
changeset
|
1011 |
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
|
1012 |
// 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
|
1013 |
v = FindWindowById(WC_MAIN_WINDOW, 0); |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1014 |
// 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
|
1015 |
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
|
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 |
// center on same place as main window (zoom is maximum, no adjustment needed) |
1815
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
1018 |
x = WP(v, vp_d).scrollpos_x; |
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
1019 |
y = WP(v, vp_d).scrollpos_y; |
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
1020 |
WP(w, vp_d).scrollpos_x = x + (v->viewport->virtual_width - (294)) / 2; |
cfc1399ea8c9
(svn r2319) - Fix: copying/pasting from the extra viewport did not center on what you wanted to see if one of the windows (viewport or main) was zoomed out. Also fix the undisabled-zoom-in button upon creation.
Darkvater
parents:
1516
diff
changeset
|
1021 |
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
|
1022 |
} |
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 |
} |