File diff r6090:ce473ff6fa95 → r6091:2faa7d307565
src/station_gui.cpp
Show inline comments
 
@@ -17,12 +17,13 @@
 
#include "variables.h"
 
#include "vehicle_gui.h"
 
#include "date.h"
 
#include "vehicle.h"
 
#include "table/sprites.h"
 
#include "helpers.hpp"
 
#include "cargotype.h"
 

	
 
enum StationListWidgets {
 
	STATIONLIST_WIDGET_CLOSEBOX = 0,
 
	STATIONLIST_WIDGET_LIST = 3,
 
	STATIONLIST_WIDGET_TRAIN =6,
 
	STATIONLIST_WIDGET_TRUCK,
 
@@ -54,13 +55,16 @@ static StationSortListingTypeFunction St
 
 * @param x,y X/Y coordinate to draw the box at
 
 * @param type Cargo type
 
 * @param amount Cargo amount
 
 * @param rating ratings data for that particular cargo */
 
static void StationsWndShowStationRating(int x, int y, CargoID type, uint amount, byte rating)
 
{
 
	int colour = _cargo_colours[type];
 
	const CargoSpec *cs = GetCargo(type);
 
	if (cs->bitnum == 0xFF) return;
 

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

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

	
 
	/* Draw a one pixel-wide bar of additional cargo meter, useful
 
@@ -70,13 +74,13 @@ static void StationsWndShowStationRating
 
		if (rest != 0) {
 
			w += x;
 
			GfxFillRect(w, y + 6 - rest, w, y + 6, colour);
 
		}
 
	}
 

	
 
	DrawString(x + 1, y, _cargoc.names_short[type], 0x10);
 
	DrawString(x + 1, y, cs->abbrev, 0x10);
 

	
 
	/* Draw green/red ratings bar (fits into 14 pixels) */
 
	y += 8;
 
	GfxFillRect(x + 1, y, x + 14, y, 0xB8);
 
	rating = minu(rating,  224) / 16;
 
	if (rating != 0) GfxFillRect(x + 1, y, x + rating, y, 0xD0);
 
@@ -320,14 +324,17 @@ static void PlayerStationsWndProc(Window
 
			x = 89;
 
			y = 14;
 

	
 
			for (i = 0; i < NUM_CARGO; i++) {
 
				cg_ofst = IsWindowWidgetLowered(w, i + STATIONLIST_WIDGET_CARGOSTART) ? 2 : 1;
 

	
 
				GfxFillRect(x + cg_ofst, y + cg_ofst, x + cg_ofst + 10 , y + cg_ofst + 7, _cargo_colours[i]);
 
				DrawStringCentered(x + 6 + cg_ofst, y + cg_ofst, _cargoc.names_short[i], 0x10);
 
				const CargoSpec *cs = GetCargo(i);
 
				if (cs->bitnum != 0xFF) {
 
					GfxFillRect(x + cg_ofst, y + cg_ofst, x + cg_ofst + 10 , y + cg_ofst + 7, cs->rating_colour);
 
					DrawStringCentered(x + 6 + cg_ofst, y + cg_ofst, cs->abbrev, 0x10);
 
				}
 
				x += 14;
 
			}
 

	
 
			x += 6;
 
			cg_ofst = IsWindowWidgetLowered(w, STATIONLIST_WIDGET_NOCARGOWAITING) ? 2 : 1;
 
			DrawStringCentered(x + cg_ofst, y + cg_ofst, STR_ABBREV_NONE, 16);
 
@@ -653,13 +660,13 @@ static void DrawStationViewWindow(Window
 

	
 
		num = (waiting + 5) / 10;
 
		if (num != 0) {
 
			int cur_x = x;
 
			num = min(num, 23);
 
			do {
 
				DrawSprite(_cargoc.sprites[i], PAL_NONE, cur_x, y);
 
				DrawSprite(GetCargo(i)->sprite, PAL_NONE, cur_x, y);
 
				cur_x += 10;
 
			} while (--num);
 
		}
 

	
 
		if ( st->goods[i].enroute_from == station_id) {
 
			if (--pos < 0) {
 
@@ -698,13 +705,13 @@ static void DrawStationViewWindow(Window
 
					first = false;
 
				} else {
 
					/* Add a comma if this is not the first item */
 
					*b++ = ',';
 
					*b++ = ' ';
 
				}
 
				b = InlineString(b, _cargoc.names_s[i]);
 
				b = InlineString(b, GetCargo(i)->name);
 
			}
 
		}
 

	
 
		/* If first is still true then no cargo is accepted */
 
		if (first) b = InlineString(b, STR_00D0_NOTHING);
 

	
 
@@ -713,13 +720,13 @@ static void DrawStationViewWindow(Window
 
	} else {
 
		DrawString(2, 67, STR_3034_LOCAL_RATING_OF_TRANSPORT, 0);
 

	
 
		y = 77;
 
		for (i = 0; i != NUM_CARGO; i++) {
 
			if (st->goods[i].enroute_from != INVALID_STATION) {
 
				SetDParam(0, _cargoc.names_s[i]);
 
				SetDParam(0, GetCargo(i)->name);
 
				SetDParam(2, st->goods[i].rating * 101 >> 8);
 
				SetDParam(1, STR_3035_APPALLING + (st->goods[i].rating >> 5));
 
				DrawString(8, y, STR_303D, 0);
 
				y += 10;
 
			}
 
		}