File diff r16986:652ac23f0157 → r16987:076ce713b4f2
src/smallmap_gui.cpp
Show inline comments
 
@@ -62,12 +62,15 @@ static const int NUM_NO_COMPANY_ENTRIES 
 
/** Macro for a height legend entry with configurable colour. */
 
#define MC(height)  {0, STR_TINY_BLACK_HEIGHT, {height}, true, false, false}
 

	
 
/** Macro for non-company owned property entry of LegendAndColour */
 
#define MO(a, b) {a, b, {INVALID_COMPANY}, true, false, false}
 

	
 
/** Macro used for forcing a rebuild of the owner legend the first time it is used. */
 
#define MOEND() {0, 0, {OWNER_NONE}, true, true, false}
 

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

	
 
/**
 
 * Macro for break marker in arrays of LegendAndColour.
 
 * It will have valid data, though
 
@@ -147,19 +150,21 @@ static const LegendAndColour _legend_veg
 

	
 
static LegendAndColour _legend_land_owners[NUM_NO_COMPANY_ENTRIES + MAX_COMPANIES + 1] = {
 
	MO(0xCA, STR_SMALLMAP_LEGENDA_WATER),
 
	MO(0x00, STR_SMALLMAP_LEGENDA_NO_OWNER), // This colour will vary depending on settings.
 
	MO(0xB4, STR_SMALLMAP_LEGENDA_TOWNS),
 
	MO(0x20, STR_SMALLMAP_LEGENDA_INDUSTRIES),
 
	/* The legend will be terminated after adding the companies. */
 
	/* The legend will be terminated the first time it is used. */
 
	MOEND(),
 
};
 

	
 
#undef MK
 
#undef MC
 
#undef MS
 
#undef MO
 
#undef MOEND
 
#undef MKEND
 

	
 
/**
 
 * Allow room for all industries, plus a terminator entry
 
 * This is required in order to have the indutry slots all filled up
 
 */
 
@@ -1104,12 +1109,18 @@ public:
 
				if (i == SMT_INDUSTRY) {
 
					SetDParam(0, tbl->legend);
 
					SetDParam(1, IndustryPool::MAX_SIZE);
 
					str = STR_SMALLMAP_INDUSTRY;
 
				} else if (i == SMT_OWNER) {
 
					if (tbl->u.company != INVALID_COMPANY) {
 
						if (!Company::IsValidID(tbl->u.company)) {
 
							/* Rebuild the owner legend. */
 
							BuildOwnerLegend();
 
							this->OnInit();
 
							return;
 
						}
 
						/* Non-fixed legend entries for the owner view. */
 
						SetDParam(0, tbl->u.company);
 
						str = STR_SMALLMAP_COMPANY;
 
					} else {
 
						str = tbl->legend;
 
					}
 
@@ -1129,12 +1140,28 @@ public:
 
		}
 

	
 
		/* The width of a column is the minimum width of all texts + the size of the blob + some spacing */
 
		this->column_width = min_width + LEGEND_BLOB_WIDTH + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		if (this->map_type == SMT_OWNER) {
 
			for (const LegendAndColour *tbl = _legend_table[this->map_type]; !tbl->end; ++tbl) {
 
				if (tbl->u.company != INVALID_COMPANY && !Company::IsValidID(tbl->u.company)) {
 
					/* Rebuild the owner legend. */
 
					BuildOwnerLegend();
 
					this->InvalidateData(1);
 
					break;
 
				}
 
			}
 
		}
 

	
 
		this->DrawWidgets();
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		switch (widget) {
 
			case SM_WIDGET_MAP: {
 
				DrawPixelInfo new_dpi;
 
				if (!FillDrawPixelInfo(&new_dpi, r.left + 1, r.top + 1, r.right - r.left - 1, r.bottom - r.top - 1)) return;