File diff r11449:b2be852b4065 → r11450:cc7b953d0155
src/station_gui.cpp
Show inline comments
 
@@ -31,52 +31,53 @@
 

	
 
/**
 
 * Draw small boxes of cargo amount and ratings data at the given
 
 * coordinates. If amount exceeds 576 units, it is shown 'full', same
 
 * goes for the rating: at above 90% orso (224) it is also 'full'
 
 *
 
 * @param x coordinate to draw the box at
 
 * @param y coordinate to draw the box at
 
 * @param type Cargo type
 
 * @param left   left most coordinate to draw the box at
 
 * @param right  right most coordinate to draw the box at
 
 * @param y      coordinate to draw the box at
 
 * @param type   Cargo type
 
 * @param amount Cargo amount
 
 * @param rating ratings data for that particular cargo
 
 *
 
 * @note Each cargo-bar is 16 pixels wide and 6 pixels high
 
 * @note Each rating 14 pixels wide and 1 pixel high and is 1 pixel below the cargo-bar
 
 */
 
static void StationsWndShowStationRating(int x, int y, CargoID type, uint amount, byte rating)
 
static void StationsWndShowStationRating(int left, int right, int y, CargoID type, uint amount, byte rating)
 
{
 
	static const uint units_full  = 576; ///< number of units to show station as 'full'
 
	static const uint rating_full = 224; ///< rating needed so it is shown as 'full'
 

	
 
	const CargoSpec *cs = GetCargo(type);
 
	if (!cs->IsValid()) return;
 

	
 
	int colour = cs->rating_colour;
 
	uint w = (minu(amount, units_full) + 5) / 36;
 

	
 
	/* Draw total cargo (limited) on station (fits into 16 pixels) */
 
	if (w != 0) GfxFillRect(x, y, x + w - 1, y + 6, colour);
 
	if (w != 0) GfxFillRect(left, y, left + w - 1, y + 6, colour);
 

	
 
	/* Draw a one pixel-wide bar of additional cargo meter, useful
 
	 * for stations with only a small amount (<=30) */
 
	if (w == 0) {
 
		uint rest = amount / 5;
 
		if (rest != 0) {
 
			w += x;
 
			w += left;
 
			GfxFillRect(w, y + 6 - rest, w, y + 6, colour);
 
		}
 
	}
 

	
 
	DrawString(x + 1, y, cs->abbrev, TC_BLACK);
 
	DrawString(left + 1, right, y, cs->abbrev, TC_BLACK);
 

	
 
	/* Draw green/red ratings bar (fits into 14 pixels) */
 
	y += 8;
 
	GfxFillRect(x + 1, y, x + 14, y, 0xB8);
 
	GfxFillRect(left + 1, y, left + 14, y, 0xB8);
 
	rating = minu(rating, rating_full) / 16;
 
	if (rating != 0) GfxFillRect(x + 1, y, x + rating, y, 0xD0);
 
	if (rating != 0) GfxFillRect(left + 1, y, left + rating, y, 0xD0);
 
}
 

	
 
typedef GUIList<const Station*> GUIStationList;
 

	
 
/**
 
 * The list of stations per company.
 
@@ -343,16 +344,16 @@ public:
 
		DrawString(x + cg_ofst, x + cg_ofst + 12, y + cg_ofst, STR_ABBREV_NONE, TC_BLACK, SA_CENTER);
 
		x += 14;
 
		cg_ofst = this->IsWidgetLowered(SLW_CARGOALL) ? 2 : 1;
 
		DrawString(x + cg_ofst, x + cg_ofst + 12, y + cg_ofst, STR_ABBREV_ALL, TC_BLACK, SA_CENTER);
 

	
 
		cg_ofst = this->IsWidgetLowered(SLW_FACILALL) ? 2 : 1;
 
		DrawString(71 + cg_ofst, y + cg_ofst, STR_ABBREV_ALL, TC_BLACK);
 
		DrawString(71 + cg_ofst, 71 + cg_ofst + 12, y + cg_ofst, STR_ABBREV_ALL, TC_BLACK);
 

	
 
		if (this->vscroll.count == 0) { // company has no stations
 
			DrawString(xb, 40, STR_304A_NONE, TC_FROMSTRING);
 
			DrawString(xb, this->width, 40, STR_304A_NONE, TC_FROMSTRING);
 
			return;
 
		}
 

	
 
		int max = min(this->vscroll.pos + this->vscroll.cap, this->stations.Length());
 
		y = 40; // start of the list-widget
 

	
 
@@ -365,18 +366,18 @@ public:
 
			/* Do not do the complex check HasStationInUse here, it may be even false
 
			 * when the order had been removed and the station list hasn't been removed yet */
 
			assert(st->owner == owner || (st->owner == OWNER_NONE && !st->IsBuoy()));
 

	
 
			SetDParam(0, st->index);
 
			SetDParam(1, st->facilities);
 
			x = DrawString(xb, y, STR_3049_0, TC_FROMSTRING) + 5;
 
			x = DrawString(xb, this->widget[SLW_LIST].right, y, STR_3049_0, TC_FROMSTRING) + 5;
 

	
 
			/* show cargo waiting and station ratings */
 
			for (CargoID j = 0; j < NUM_CARGO; j++) {
 
				if (!st->goods[j].cargo.Empty()) {
 
					StationsWndShowStationRating(x, y, j, st->goods[j].cargo.Count(), st->goods[j].rating);
 
					StationsWndShowStationRating(x, this->widget[SLW_LIST].right, y, j, st->goods[j].cargo.Count(), st->goods[j].rating);
 
					x += 20;
 
				}
 
			}
 
			y += 10;
 
		}
 
	}
 
@@ -799,13 +800,13 @@ struct StationViewWindow : public Window
 
		if (--pos < 0) {
 
			str = STR_00D0_NOTHING;
 
			for (CargoID i = 0; i < NUM_CARGO; i++) {
 
				if (!st->goods[i].cargo.Empty()) str = STR_EMPTY;
 
			}
 
			SetDParam(0, str);
 
			DrawString(x, y, STR_0008_WAITING, TC_FROMSTRING);
 
			DrawString(x, this->widget[SVW_WAITING].right - 2, y, STR_0008_WAITING, TC_FROMSTRING);
 
			y += 10;
 
		}
 

	
 
		for (CargoDataList::const_iterator it = cargolist.begin(); it != cargolist.end() && pos > -maxrows; ++it) {
 
			if (--pos < 0) {
 
				const CargoData *cd = &(*it);
 
@@ -864,26 +865,26 @@ struct StationViewWindow : public Window
 

	
 
			SetDParamStr(0, string);
 
			DrawStringMultiLine(this->widget[SVW_ACCEPTLIST].left + 2, this->widget[SVW_ACCEPTLIST].right - 2, this->widget[SVW_ACCEPTLIST].bottom - 1, this->widget[SVW_ACCEPTLIST].top + 1, STR_JUST_RAW_STRING);
 
		} else { // extended window with list of cargo ratings
 
			y = this->widget[SVW_RATINGLIST].top + 1;
 

	
 
			DrawString(2, y, STR_3034_LOCAL_RATING_OF_TRANSPORT, TC_FROMSTRING);
 
			DrawString(this->widget[SVW_ACCEPTLIST].left + 2, this->widget[SVW_ACCEPTLIST].right - 2, y, STR_3034_LOCAL_RATING_OF_TRANSPORT, TC_FROMSTRING);
 
			y += 10;
 

	
 
			for (CargoID i = 0; i < NUM_CARGO; i++) {
 
				const CargoSpec *cs = GetCargo(i);
 
				if (!cs->IsValid()) continue;
 

	
 
				const GoodsEntry *ge = &st->goods[i];
 
				if (!HasBit(ge->acceptance_pickup, GoodsEntry::PICKUP)) continue;
 

	
 
				SetDParam(0, cs->name);
 
				SetDParam(2, ge->rating * 101 >> 8);
 
				SetDParam(1, STR_3035_APPALLING + (ge->rating >> 5));
 
				DrawString(8, y, STR_303D, TC_FROMSTRING);
 
				DrawString(this->widget[SVW_ACCEPTLIST].left + 8, this->widget[SVW_ACCEPTLIST].right - 2, y, STR_303D, TC_FROMSTRING);
 
				y += 10;
 
			}
 
		}
 
	}
 

	
 
	void HandleCargoWaitingClick(int row)