42 static StationSortListingTypeFunction StationNameSorter; |
42 static StationSortListingTypeFunction StationNameSorter; |
43 static StationSortListingTypeFunction StationTypeSorter; |
43 static StationSortListingTypeFunction StationTypeSorter; |
44 static StationSortListingTypeFunction StationWaitingSorter; |
44 static StationSortListingTypeFunction StationWaitingSorter; |
45 static StationSortListingTypeFunction StationRatingMaxSorter; |
45 static StationSortListingTypeFunction StationRatingMaxSorter; |
46 |
46 |
47 static void StationsWndShowStationRating(int x, int y, int type, uint acceptance, int rating) |
47 /** Draw small boxes of cargo amount and ratings data at the given |
48 { |
48 * coordinates. If amount exceeds 576 units, it is shown 'full', same |
49 int color = _cargo_colours[type]; |
49 * goes for the rating: at above 90% orso (224) it is also 'full' |
50 uint w; |
50 * Each cargo-bar is 16 pixels wide and 6 pixels high |
51 |
51 * Each rating 14 pixels wide and 1 pixel high and is 1 pixel below the cargo-bar |
52 if (acceptance > 575) acceptance = 575; |
52 * @param x,y X/Y coordinate to draw the box at |
53 |
53 * @param type Cargo type |
54 acceptance = (acceptance + 7) / 8; |
54 * @param amount Cargo amount |
55 |
55 * @param rating ratings data for that particular cargo */ |
56 /* draw cargo */ |
56 static void StationsWndShowStationRating(int x, int y, CargoID type, uint amount, byte rating) |
57 w = acceptance / 8; |
57 { |
58 if (w != 0) { |
58 int colour = _cargo_colours[type]; |
59 GfxFillRect(x, y, x + w - 1, y + 6, color); |
59 uint w = (minu(amount, 576) + 5) / 36; |
60 x += w; |
60 |
61 } |
61 /* Draw total cargo (limited) on station (fits into 16 pixels) */ |
62 |
62 if (w != 0) GfxFillRect(x, y, x + w - 1, y + 6, colour); |
63 w = acceptance % 8; |
63 |
64 if (w != 0) { |
64 /* Draw a one pixel-wide bar of additional cargo meter, useful |
65 if (w == 7) w--; |
65 * for stations with only a small amount (<=30) */ |
66 GfxFillRect(x, y + (w - 1), x, y + 6, color); |
66 if (w == 0) { |
67 } |
67 uint rest = amount / 5; |
68 |
68 if (rest != 0) { |
69 x -= acceptance / 8; |
69 w += x; |
|
70 GfxFillRect(w, y + 6 - rest, w, y + 6, colour); |
|
71 } |
|
72 } |
70 |
73 |
71 DrawString(x + 1, y, _cargoc.names_short[type], 0x10); |
74 DrawString(x + 1, y, _cargoc.names_short[type], 0x10); |
72 |
75 |
73 /* draw green/red ratings bar */ |
76 /* Draw green/red ratings bar (fits into 14 pixels) */ |
74 GfxFillRect(x + 1, y + 8, x + 7, y + 8, 0xB8); |
77 y += 8; |
75 |
78 GfxFillRect(x + 1, y, x + 14, y, 0xB8); |
76 rating >>= 5; |
79 rating = minu(rating, 224) / 16; |
77 |
80 if (rating != 0) GfxFillRect(x + 1, y, x + rating, y, 0xD0); |
78 if (rating != 0) GfxFillRect(x + 1, y + 8, x + rating, y + 8, 0xD0); |
|
79 } |
81 } |
80 |
82 |
81 const StringID _station_sort_listing[] = { |
83 const StringID _station_sort_listing[] = { |
82 STR_SORT_BY_DROPDOWN_NAME, |
84 STR_SORT_BY_DROPDOWN_NAME, |
83 STR_SORT_BY_FACILITY, |
85 STR_SORT_BY_FACILITY, |
338 |
340 |
339 max = min(w->vscroll.pos + w->vscroll.cap, sl->list_length); |
341 max = min(w->vscroll.pos + w->vscroll.cap, sl->list_length); |
340 y = 40; // start of the list-widget |
342 y = 40; // start of the list-widget |
341 |
343 |
342 for (i = w->vscroll.pos; i < max; ++i) { // do until max number of stations of owner |
344 for (i = w->vscroll.pos; i < max; ++i) { // do until max number of stations of owner |
343 const Station* st = sl->sort_list[i]; |
345 const Station *st = sl->sort_list[i]; |
344 uint j; |
346 CargoID j; |
345 int x; |
347 int x; |
346 |
348 |
347 assert(st->xy); |
349 assert(st->xy != 0); |
348 assert(st->owner == owner); |
350 assert(st->owner == owner); |
349 |
351 |
350 SetDParam(0, st->index); |
352 SetDParam(0, st->index); |
351 SetDParam(1, st->facilities); |
353 SetDParam(1, st->facilities); |
352 x = DrawString(xb, y, STR_3049_0, 0) + 5; |
354 x = DrawString(xb, y, STR_3049_0, 0) + 5; |
353 |
355 |
354 // show cargo waiting and station ratings |
356 // show cargo waiting and station ratings |
355 for (j = 0; j != NUM_CARGO; j++) { |
357 for (j = 0; j != NUM_CARGO; j++) { |
356 uint acc = GB(st->goods[j].waiting_acceptance, 0, 12); |
358 uint amount = GB(st->goods[j].waiting_acceptance, 0, 12); |
357 |
359 |
358 if (acc != 0) { |
360 if (amount != 0) { |
359 StationsWndShowStationRating(x, y, j, acc, st->goods[j].rating); |
361 StationsWndShowStationRating(x, y, j, amount, st->goods[j].rating); |
360 x += 10; |
362 x += 20; |
361 } |
363 } |
362 } |
364 } |
363 y += 10; |
365 y += 10; |
364 } |
366 } |
365 } |
367 } |