Changeset - r15127:bbd6ac65a02f
[Not reviewed]
master
0 1 0
alberth - 14 years ago 2010-05-07 20:27:22
alberth@openttd.org
(svn r19766) -Codechange: Store tile height of smallmap contour legend in the LegendAndColour struct.
1 file changed with 29 insertions and 26 deletions:
0 comments (0 inline, 0 general)
src/smallmap_gui.cpp
Show inline comments
 
@@ -52,39 +52,45 @@ enum SmallMapWindowWidgets {
 
	SM_WIDGET_SHOW_HEIGHT,       ///< Show heightmap toggle button.
 
};
 

	
 
static int _smallmap_industry_count; ///< Number of used industries
 

	
 
/** Macro for ordinary entry of LegendAndColour */
 
#define MK(a, b) {a, b, INVALID_INDUSTRYTYPE, true, false, false}
 
/** Macro for an entry with configurable colour. */
 
#define MC(b) MK(0, b)
 
#define MK(a, b) {a, b, {INVALID_INDUSTRYTYPE}, true, false, false}
 

	
 
/** Macro for a height legend entry with configurable colour. */
 
#define MC(height)  {0, STR_TINY_BLACK_HEIGHT, {height}, true, false, false}
 

	
 
/** Macro for end of list marker in arrays of LegendAndColour */
 
#define MKEND() {0, STR_NULL, INVALID_INDUSTRYTYPE, true, true, false}
 
#define MKEND() {0, STR_NULL, {INVALID_INDUSTRYTYPE}, true, true, false}
 

	
 
/** Macro for break marker in arrays of LegendAndColour.
 
 * It will have valid data, though */
 
#define MS(a, b) {a, b, INVALID_INDUSTRYTYPE, true, false, true}
 
#define MS(a, b) {a, b, {INVALID_INDUSTRYTYPE}, true, false, true}
 

	
 
/** Structure for holding relevant data for legends in small map */
 
struct LegendAndColour {
 
	uint8 colour;      ///< colour of the item on the map
 
	StringID legend;   ///< string corresponding to the coloured item
 
	IndustryType type; ///< type of industry
 
	bool show_on_map;  ///< for filtering industries, if true is shown on map in colour
 
	bool end;          ///< this is the end of the list
 
	bool col_break;    ///< perform a break and go one column further
 
	uint8 colour;              ///< Colour of the item on the map.
 
	StringID legend;           ///< String corresponding to the coloured item.
 
	union {
 
		IndustryType type; ///< Type of industry.
 
		uint8 height;      ///< Height in tiles.
 
	} u;
 
	bool show_on_map;          ///< For filtering industries, if \c true, industry is shown on the map in colour.
 
	bool end;                  ///< This is the end of the list.
 
	bool col_break;            ///< Perform a column break and go further at the next column.
 
};
 

	
 
/** Legend text giving the colours to look for on the minimap */
 
static LegendAndColour _legend_land_contours[] = {
 
	/* The colours for the following values are set at BuildLandLegend() based on each colour scheme. */
 
	MC(STR_TINY_BLACK_HEIGHT),
 
	MC(STR_TINY_BLACK_HEIGHT),
 
	MC(STR_TINY_BLACK_HEIGHT),
 
	MC(STR_TINY_BLACK_HEIGHT),
 
	MC(STR_TINY_BLACK_HEIGHT),
 
	MC(0),
 
	MC(4),
 
	MC(8),
 
	MC(12),
 
	MC(14),
 

	
 
	MS(0xD7, STR_SMALLMAP_LEGENDA_ROADS),
 
	MK(0x0A, STR_SMALLMAP_LEGENDA_RAILROADS),
 
	MK(0x98, STR_SMALLMAP_LEGENDA_STATIONS_AIRPORTS_DOCKS),
 
	MK(0xB5, STR_SMALLMAP_LEGENDA_BUILDINGS_INDUSTRIES),
 
	MK(0x0F, STR_SMALLMAP_LEGENDA_VEHICLES),
 
@@ -162,13 +168,13 @@ void BuildIndustriesLegend()
 
	for (uint8 i = 0; i < NUM_INDUSTRYTYPES; i++) {
 
		IndustryType ind = _sorted_industry_types[i];
 
		const IndustrySpec *indsp = GetIndustrySpec(ind);
 
		if (indsp->enabled) {
 
			_legend_from_industries[j].legend = indsp->name;
 
			_legend_from_industries[j].colour = indsp->map_colour;
 
			_legend_from_industries[j].type = ind;
 
			_legend_from_industries[j].u.type = ind;
 
			_legend_from_industries[j].show_on_map = true;
 
			_legend_from_industries[j].col_break = false;
 
			_legend_from_industries[j].end = false;
 

	
 
			/* Store widget number for this industry type. */
 
			_industry_to_list_pos[ind] = j;
 
@@ -268,17 +274,15 @@ static const SmallMapColourScheme _heigh
 
	{_dark_green_map_heights, MKCOLOUR(0x62626262)}, ///< Dark green colour scheme.
 
	{_violet_map_heights,     MKCOLOUR(0x82828282)}, ///< Violet colour scheme.
 
};
 

	
 
void BuildLandLegend()
 
{
 
	_legend_land_contours[0].colour = _heightmap_schemes[_settings_client.gui.smallmap_land_colour].height_colours[0];
 
	_legend_land_contours[1].colour = _heightmap_schemes[_settings_client.gui.smallmap_land_colour].height_colours[4];
 
	_legend_land_contours[2].colour = _heightmap_schemes[_settings_client.gui.smallmap_land_colour].height_colours[8];
 
	_legend_land_contours[3].colour = _heightmap_schemes[_settings_client.gui.smallmap_land_colour].height_colours[12];
 
	_legend_land_contours[4].colour = _heightmap_schemes[_settings_client.gui.smallmap_land_colour].height_colours[14];
 
	for (LegendAndColour *lc = _legend_land_contours; lc->legend == STR_TINY_BLACK_HEIGHT; lc++) {
 
		lc->colour = _heightmap_schemes[_settings_client.gui.smallmap_land_colour].height_colours[lc->u.height];
 
	}
 
}
 

	
 
struct AndOr {
 
	uint32 mor;
 
	uint32 mand;
 
};
 
@@ -1090,25 +1094,24 @@ public:
 
					}
 

	
 
					if (this->map_type == SMT_INDUSTRY) {
 
						/* Industry name must be formatted, since it's not in tiny font in the specs.
 
						 * So, draw with a parameter and use the STR_SMALLMAP_INDUSTRY string, which is tiny font */
 
						SetDParam(0, tbl->legend);
 
						SetDParam(1, Industry::GetIndustryTypeCount(tbl->type));
 
						SetDParam(1, Industry::GetIndustryTypeCount(tbl->u.type));
 
						if (!tbl->show_on_map) {
 
							/* Simply draw the string, not the black border of the legend colour.
 
							 * This will enforce the idea of the disabled item */
 
							DrawString(x + text_left, x + text_right, y, STR_SMALLMAP_INDUSTRY, TC_GREY);
 
						} else {
 
							DrawString(x + text_left, x + text_right, y, STR_SMALLMAP_INDUSTRY, TC_BLACK);
 
							GfxFillRect(x + blob_left, y + 1, x + blob_right, y + row_height - 1, 0); // Outer border of the legend colour
 
						}
 
					} else {
 
						if (this->map_type == SMT_CONTOUR) {
 
							SetDParam(0, (tbl - _legend_table[this->map_type] + 1) * 100);
 
						}
 
						if (this->map_type == SMT_CONTOUR) SetDParam(0, tbl->u.height * 100);
 

	
 
						/* Anything that is not an industry is using normal process */
 
						GfxFillRect(x + blob_left, y + 1, x + blob_right, y + row_height - 1, 0);
 
						DrawString(x + text_left, x + text_right, y, tbl->legend);
 
					}
 
					GfxFillRect(x + blob_left + 1, y + 2, x + blob_right - 1, y + row_height - 2, tbl->colour); // Legend colour
 

	
0 comments (0 inline, 0 general)