47 }; |
47 }; |
48 |
48 |
49 static int _smallmap_type; |
49 static int _smallmap_type; |
50 static bool _smallmap_show_towns = true; |
50 static bool _smallmap_show_towns = true; |
51 |
51 |
52 #define MK(a,b) a, b |
52 /** Macro for ordinary entry of LegendAndColor */ |
53 #define MKEND() 0xFFFF |
53 #define MK(a,b) {a, b, false, false} |
54 #define MS(a,b) (a | 0x100), b |
54 /** Macro for end of list marker in arrays of LegendAndColor */ |
55 |
55 #define MKEND() {0, STR_NULL, true, false} |
56 /* Legend text giving the colours to look for on the minimap */ |
56 /** Macro for break marker in arrays of LegendAndColor. |
57 static const uint16 _legend_land_contours[] = { |
57 * It will have valid data, though */ |
|
58 #define MS(a,b) {a, b, false, true} |
|
59 |
|
60 /** Structure for holding relevant data for legends in small map */ |
|
61 struct LegendAndColour { |
|
62 uint16 colour; ///< color of the item on the map |
|
63 StringID legend; ///< string corresponding to the colored item |
|
64 bool end; ///< this is the end of the list |
|
65 bool col_break; ///< perform a break and go one collumn further |
|
66 }; |
|
67 |
|
68 /** Legend text giving the colours to look for on the minimap */ |
|
69 static const LegendAndColour _legend_land_contours[] = { |
58 MK(0x5A, STR_00F0_100M), |
70 MK(0x5A, STR_00F0_100M), |
59 MK(0x5C, STR_00F1_200M), |
71 MK(0x5C, STR_00F1_200M), |
60 MK(0x5E, STR_00F2_300M), |
72 MK(0x5E, STR_00F2_300M), |
61 MK(0x1F, STR_00F3_400M), |
73 MK(0x1F, STR_00F3_400M), |
62 MK(0x27, STR_00F4_500M), |
74 MK(0x27, STR_00F4_500M), |
67 MK(0xB5, STR_00EE_BUILDINGS_INDUSTRIES), |
79 MK(0xB5, STR_00EE_BUILDINGS_INDUSTRIES), |
68 MK(0x0F, STR_00EF_VEHICLES), |
80 MK(0x0F, STR_00EF_VEHICLES), |
69 MKEND() |
81 MKEND() |
70 }; |
82 }; |
71 |
83 |
72 static const uint16 _legend_vehicles[] = { |
84 static const LegendAndColour _legend_vehicles[] = { |
73 MK(0xB8, STR_00F5_TRAINS), |
85 MK(0xB8, STR_00F5_TRAINS), |
74 MK(0xBF, STR_00F6_ROAD_VEHICLES), |
86 MK(0xBF, STR_00F6_ROAD_VEHICLES), |
75 MK(0x98, STR_00F7_SHIPS), |
87 MK(0x98, STR_00F7_SHIPS), |
76 MK(0x0F, STR_00F8_AIRCRAFT), |
88 MK(0x0F, STR_00F8_AIRCRAFT), |
77 MS(0xD7, STR_00F9_TRANSPORT_ROUTES), |
89 MS(0xD7, STR_00F9_TRANSPORT_ROUTES), |
78 MK(0xB5, STR_00EE_BUILDINGS_INDUSTRIES), |
90 MK(0xB5, STR_00EE_BUILDINGS_INDUSTRIES), |
79 MKEND() |
91 MKEND() |
80 }; |
92 }; |
81 |
93 |
82 static const uint16 _legend_industries_normal[] = { |
94 static const LegendAndColour _legend_industries_normal[] = { |
83 MK(0xD7, STR_00FA_COAL_MINE), |
95 MK(0xD7, STR_00FA_COAL_MINE), |
84 MK(0xB8, STR_00FB_POWER_STATION), |
96 MK(0xB8, STR_00FB_POWER_STATION), |
85 MK(0x56, STR_00FC_FOREST), |
97 MK(0x56, STR_00FC_FOREST), |
86 MK(0xC2, STR_00FD_SAWMILL), |
98 MK(0xC2, STR_00FD_SAWMILL), |
87 MK(0xBF, STR_00FE_OIL_REFINERY), |
99 MK(0xBF, STR_00FE_OIL_REFINERY), |
93 MK(0x37, STR_0103_IRON_ORE_MINE), |
105 MK(0x37, STR_0103_IRON_ORE_MINE), |
94 MK(0x0A, STR_0104_STEEL_MILL), |
106 MK(0x0A, STR_0104_STEEL_MILL), |
95 MKEND() |
107 MKEND() |
96 }; |
108 }; |
97 |
109 |
98 static const uint16 _legend_industries_hilly[] = { |
110 static const LegendAndColour _legend_industries_hilly[] = { |
99 MK(0xD7, STR_00FA_COAL_MINE), |
111 MK(0xD7, STR_00FA_COAL_MINE), |
100 MK(0xB8, STR_00FB_POWER_STATION), |
112 MK(0xB8, STR_00FB_POWER_STATION), |
101 MK(0x56, STR_00FC_FOREST), |
113 MK(0x56, STR_00FC_FOREST), |
102 MK(0x0A, STR_0106_PAPER_MILL), |
114 MK(0x0A, STR_0106_PAPER_MILL), |
103 MK(0xBF, STR_00FE_OIL_REFINERY), |
115 MK(0xBF, STR_00FE_OIL_REFINERY), |
109 MK(0xC2, STR_0107_GOLD_MINE), |
121 MK(0xC2, STR_0107_GOLD_MINE), |
110 MK(0x0F, STR_0105_BANK), |
122 MK(0x0F, STR_0105_BANK), |
111 MKEND() |
123 MKEND() |
112 }; |
124 }; |
113 |
125 |
114 static const uint16 _legend_industries_desert[] = { |
126 static const LegendAndColour _legend_industries_desert[] = { |
115 MK(0xBF, STR_00FE_OIL_REFINERY), |
127 MK(0xBF, STR_00FE_OIL_REFINERY), |
116 MK(0x98, STR_0102_OIL_WELLS), |
128 MK(0x98, STR_0102_OIL_WELLS), |
117 MK(0x0F, STR_0105_BANK), |
129 MK(0x0F, STR_0105_BANK), |
118 MK(0xB8, STR_0109_DIAMOND_MINE), |
130 MK(0xB8, STR_0109_DIAMOND_MINE), |
119 MK(0x37, STR_0108_FOOD_PROCESSING_PLANT), |
131 MK(0x37, STR_0108_FOOD_PROCESSING_PLANT), |
127 MK(0xAE, STR_0100_FACTORY), |
139 MK(0xAE, STR_0100_FACTORY), |
128 MK(0xC2, STR_010F_LUMBER_MILL), |
140 MK(0xC2, STR_010F_LUMBER_MILL), |
129 MKEND() |
141 MKEND() |
130 }; |
142 }; |
131 |
143 |
132 static const uint16 _legend_industries_candy[] = { |
144 static const LegendAndColour _legend_industries_candy[] = { |
133 MK(0x30, STR_0110_COTTON_CANDY_FOREST), |
145 MK(0x30, STR_0110_COTTON_CANDY_FOREST), |
134 MK(0xAE, STR_0111_CANDY_FACTORY), |
146 MK(0xAE, STR_0111_CANDY_FACTORY), |
135 MK(0x27, STR_0112_BATTERY_FARM), |
147 MK(0x27, STR_0112_BATTERY_FARM), |
136 MK(0x37, STR_0113_COLA_WELLS), |
148 MK(0x37, STR_0113_COLA_WELLS), |
137 MK(0xD0, STR_0114_TOY_SHOP), |
149 MK(0xD0, STR_0114_TOY_SHOP), |
143 MK(0xC2, STR_0119_TOFFEE_QUARRY), |
155 MK(0xC2, STR_0119_TOFFEE_QUARRY), |
144 MK(0x0F, STR_011A_SUGAR_MINE), |
156 MK(0x0F, STR_011A_SUGAR_MINE), |
145 MKEND() |
157 MKEND() |
146 }; |
158 }; |
147 |
159 |
148 static const uint16 _legend_routes[] = { |
160 static const LegendAndColour _legend_routes[] = { |
149 MK(0xD7, STR_00EB_ROADS), |
161 MK(0xD7, STR_00EB_ROADS), |
150 MK(0x0A, STR_00EC_RAILROADS), |
162 MK(0x0A, STR_00EC_RAILROADS), |
151 MK(0xB5, STR_00EE_BUILDINGS_INDUSTRIES), |
163 MK(0xB5, STR_00EE_BUILDINGS_INDUSTRIES), |
152 MS(0x56, STR_011B_RAILROAD_STATION), |
164 MS(0x56, STR_011B_RAILROAD_STATION), |
153 |
165 |
156 MK(0xB8, STR_011E_AIRPORT_HELIPORT), |
168 MK(0xB8, STR_011E_AIRPORT_HELIPORT), |
157 MK(0x98, STR_011F_DOCK), |
169 MK(0x98, STR_011F_DOCK), |
158 MKEND() |
170 MKEND() |
159 }; |
171 }; |
160 |
172 |
161 static const uint16 _legend_vegetation[] = { |
173 static const LegendAndColour _legend_vegetation[] = { |
162 MK(0x52, STR_0120_ROUGH_LAND), |
174 MK(0x52, STR_0120_ROUGH_LAND), |
163 MK(0x54, STR_0121_GRASS_LAND), |
175 MK(0x54, STR_0121_GRASS_LAND), |
164 MK(0x37, STR_0122_BARE_LAND), |
176 MK(0x37, STR_0122_BARE_LAND), |
165 MK(0x25, STR_0123_FIELDS), |
177 MK(0x25, STR_0123_FIELDS), |
166 MK(0x57, STR_0124_TREES), |
178 MK(0x57, STR_0124_TREES), |
172 MK(0xD7, STR_00F9_TRANSPORT_ROUTES), |
184 MK(0xD7, STR_00F9_TRANSPORT_ROUTES), |
173 MK(0xB5, STR_00EE_BUILDINGS_INDUSTRIES), |
185 MK(0xB5, STR_00EE_BUILDINGS_INDUSTRIES), |
174 MKEND() |
186 MKEND() |
175 }; |
187 }; |
176 |
188 |
177 static const uint16 _legend_land_owners[] = { |
189 static const LegendAndColour _legend_land_owners[] = { |
178 MK(0xCA, STR_0126_WATER), |
190 MK(0xCA, STR_0126_WATER), |
179 MK(0x54, STR_0127_NO_OWNER), |
191 MK(0x54, STR_0127_NO_OWNER), |
180 MK(0xB4, STR_0128_TOWNS), |
192 MK(0xB4, STR_0128_TOWNS), |
181 MK(0x20, STR_0129_INDUSTRIES), |
193 MK(0x20, STR_0129_INDUSTRIES), |
182 MKEND() |
194 MKEND() |
381 } |
394 } |
382 |
395 |
383 /** |
396 /** |
384 * Return the color a tile would be displayed with in the small map in mode "Vehicles". |
397 * Return the color a tile would be displayed with in the small map in mode "Vehicles". |
385 * |
398 * |
386 * @param t The tile of which we would like to get the color. |
399 * @param tile The tile of which we would like to get the color. |
387 * @return The color of tile in the small map in mode "Vehicles" |
400 * @return The color of tile in the small map in mode "Vehicles" |
388 */ |
401 */ |
389 static inline uint32 GetSmallMapVehiclesPixels(TileIndex tile) |
402 static inline uint32 GetSmallMapVehiclesPixels(TileIndex tile) |
390 { |
403 { |
391 TileType t = GetEffectiveTileType(tile); |
404 TileType t = GetEffectiveTileType(tile); |
411 } |
424 } |
412 |
425 |
413 /** |
426 /** |
414 * Return the color a tile would be displayed with in the small map in mode "Routes". |
427 * Return the color a tile would be displayed with in the small map in mode "Routes". |
415 * |
428 * |
416 * @param t The tile of which we would like to get the color. |
429 * @param tile The tile of which we would like to get the color. |
417 * @return The color of tile in the small map in mode "Routes" |
430 * @return The color of tile in the small map in mode "Routes" |
418 */ |
431 */ |
419 static inline uint32 GetSmallMapRoutesPixels(TileIndex tile) |
432 static inline uint32 GetSmallMapRoutesPixels(TileIndex tile) |
420 { |
433 { |
421 TileType t = GetEffectiveTileType(tile); |
434 TileType t = GetEffectiveTileType(tile); |
487 static uint32 _owner_colors[OWNER_END + 1]; |
500 static uint32 _owner_colors[OWNER_END + 1]; |
488 |
501 |
489 /** |
502 /** |
490 * Return the color a tile would be displayed with in the small map in mode "Owner". |
503 * Return the color a tile would be displayed with in the small map in mode "Owner". |
491 * |
504 * |
492 * @param t The tile of which we would like to get the color. |
505 * @param tile The tile of which we would like to get the color. |
493 * @return The color of tile in the small map in mode "Owner" |
506 * @return The color of tile in the small map in mode "Owner" |
494 */ |
507 */ |
495 static inline uint32 GetSmallMapOwnerPixels(TileIndex tile) |
508 static inline uint32 GetSmallMapOwnerPixels(TileIndex tile) |
496 { |
509 { |
497 Owner o; |
510 Owner o; |
551 * |
564 * |
552 * Basically, the small map is draw column of pixels by column of pixels. The pixels |
565 * Basically, the small map is draw column of pixels by column of pixels. The pixels |
553 * are drawn directly into the screen buffer. The final map is drawn in multiple passes. |
566 * are drawn directly into the screen buffer. The final map is drawn in multiple passes. |
554 * The passes are: |
567 * The passes are: |
555 * <ol><li>The colors of tiles in the different modes.</li> |
568 * <ol><li>The colors of tiles in the different modes.</li> |
556 * <li>Town names (optional)</li> |
569 * <li>Town names (optional)</li></ol> |
557 * |
570 * |
558 * @param dpi pointer to pixel to write onto |
571 * @param dpi pointer to pixel to write onto |
559 * @param w pointer to BaseWindow struct |
572 * @param w pointer to BaseWindow struct |
560 * @param type type of map requested (vegetation, owners, routes, etc) |
573 * @param type type of map requested (vegetation, owners, routes, etc) |
561 * @param show_towns true if the town names should be displayed, false if not. |
574 * @param show_towns true if the town names should be displayed, false if not. |
792 x = 4; |
805 x = 4; |
793 y_org = w->Height() - 44 - 11; |
806 y_org = w->Height() - 44 - 11; |
794 y = y_org; |
807 y = y_org; |
795 for (;;) { |
808 for (;;) { |
796 GfxFillRect(x, y + 1, x + 8, y + 5, 0); |
809 GfxFillRect(x, y + 1, x + 8, y + 5, 0); |
797 GfxFillRect(x + 1, y + 2, x + 7, y + 4, (byte)tbl[0]); |
810 GfxFillRect(x + 1, y + 2, x + 7, y + 4, tbl->colour); |
798 DrawString(x + 11, y, tbl[1], 0); |
811 DrawString(x + 11, y, tbl->legend, 0); |
799 |
812 |
800 tbl += 2; |
813 tbl += 1; |
801 y += 6; |
814 y += 6; |
802 |
815 |
803 if (tbl[0] == 0xFFFF) { |
816 if (tbl->end) { // end of the list |
804 break; |
817 break; |
805 } else if (tbl[0] & 0x100) { |
818 } else if (tbl->col_break) { |
|
819 /* break asked, continue at top, 123 pixels (one "row") to the right */ |
806 x += 123; |
820 x += 123; |
807 y = y_org; |
821 y = y_org; |
808 } |
822 } |
809 } |
823 } |
810 |
824 |