(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,

thanks for the inspiration Rince. Workings of the small 1-pixel wide bar have changed a
 little. Up till now it was pretty random, now it is only drawn for stations with minimal
 amount of cargo (<=30) and 1-pixel height is 5 units.
pull/155/head
Darkvater 18 years ago
parent 8559b4e726
commit 0fabe8f8ef

@ -44,38 +44,40 @@ static StationSortListingTypeFunction StationTypeSorter;
static StationSortListingTypeFunction StationWaitingSorter; static StationSortListingTypeFunction StationWaitingSorter;
static StationSortListingTypeFunction StationRatingMaxSorter; static StationSortListingTypeFunction StationRatingMaxSorter;
static void StationsWndShowStationRating(int x, int y, int type, uint acceptance, int rating) /** 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'
* Each cargo-bar is 16 pixels wide and 6 pixels high
* Each rating 14 pixels wide and 1 pixel high and is 1 pixel below the cargo-bar
* @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 color = _cargo_colours[type]; int colour = _cargo_colours[type];
uint w; uint w = (minu(amount, 576) + 5) / 36;
if (acceptance > 575) acceptance = 575; /* Draw total cargo (limited) on station (fits into 16 pixels) */
if (w != 0) GfxFillRect(x, y, x + w - 1, y + 6, colour);
acceptance = (acceptance + 7) / 8; /* Draw a one pixel-wide bar of additional cargo meter, useful
* for stations with only a small amount (<=30) */
/* draw cargo */ if (w == 0) {
w = acceptance / 8; uint rest = amount / 5;
if (w != 0) { if (rest != 0) {
GfxFillRect(x, y, x + w - 1, y + 6, color); w += x;
x += w; GfxFillRect(w, y + 6 - rest, w, y + 6, colour);
} }
w = acceptance % 8;
if (w != 0) {
if (w == 7) w--;
GfxFillRect(x, y + (w - 1), x, y + 6, color);
} }
x -= acceptance / 8;
DrawString(x + 1, y, _cargoc.names_short[type], 0x10); DrawString(x + 1, y, _cargoc.names_short[type], 0x10);
/* draw green/red ratings bar */ /* Draw green/red ratings bar (fits into 14 pixels) */
GfxFillRect(x + 1, y + 8, x + 7, y + 8, 0xB8); y += 8;
GfxFillRect(x + 1, y, x + 14, y, 0xB8);
rating >>= 5; rating = minu(rating, 224) / 16;
if (rating != 0) GfxFillRect(x + 1, y, x + rating, y, 0xD0);
if (rating != 0) GfxFillRect(x + 1, y + 8, x + rating, y + 8, 0xD0);
} }
const StringID _station_sort_listing[] = { const StringID _station_sort_listing[] = {
@ -341,10 +343,10 @@ static void PlayerStationsWndProc(Window *w, WindowEvent *e)
for (i = w->vscroll.pos; i < max; ++i) { // do until max number of stations of owner for (i = w->vscroll.pos; i < max; ++i) { // do until max number of stations of owner
const Station *st = sl->sort_list[i]; const Station *st = sl->sort_list[i];
uint j; CargoID j;
int x; int x;
assert(st->xy); assert(st->xy != 0);
assert(st->owner == owner); assert(st->owner == owner);
SetDParam(0, st->index); SetDParam(0, st->index);
@ -353,11 +355,11 @@ static void PlayerStationsWndProc(Window *w, WindowEvent *e)
// show cargo waiting and station ratings // show cargo waiting and station ratings
for (j = 0; j != NUM_CARGO; j++) { for (j = 0; j != NUM_CARGO; j++) {
uint acc = GB(st->goods[j].waiting_acceptance, 0, 12); uint amount = GB(st->goods[j].waiting_acceptance, 0, 12);
if (acc != 0) { if (amount != 0) {
StationsWndShowStationRating(x, y, j, acc, st->goods[j].rating); StationsWndShowStationRating(x, y, j, amount, st->goods[j].rating);
x += 10; x += 20;
} }
} }
y += 10; y += 10;

Loading…
Cancel
Save