18 #include "vehicle_gui.h" |
18 #include "vehicle_gui.h" |
19 #include "date.h" |
19 #include "date.h" |
20 #include "vehicle.h" |
20 #include "vehicle.h" |
21 #include "table/sprites.h" |
21 #include "table/sprites.h" |
22 #include "helpers.hpp" |
22 #include "helpers.hpp" |
|
23 #include "cargotype.h" |
23 |
24 |
24 enum StationListWidgets { |
25 enum StationListWidgets { |
25 STATIONLIST_WIDGET_CLOSEBOX = 0, |
26 STATIONLIST_WIDGET_CLOSEBOX = 0, |
26 STATIONLIST_WIDGET_LIST = 3, |
27 STATIONLIST_WIDGET_LIST = 3, |
27 STATIONLIST_WIDGET_TRAIN =6, |
28 STATIONLIST_WIDGET_TRAIN =6, |
55 * @param type Cargo type |
56 * @param type Cargo type |
56 * @param amount Cargo amount |
57 * @param amount Cargo amount |
57 * @param rating ratings data for that particular cargo */ |
58 * @param rating ratings data for that particular cargo */ |
58 static void StationsWndShowStationRating(int x, int y, CargoID type, uint amount, byte rating) |
59 static void StationsWndShowStationRating(int x, int y, CargoID type, uint amount, byte rating) |
59 { |
60 { |
60 int colour = _cargo_colours[type]; |
61 const CargoSpec *cs = GetCargo(type); |
|
62 if (cs->bitnum == 0xFF) return; |
|
63 |
|
64 int colour = cs->rating_colour; |
61 uint w = (minu(amount, 576) + 5) / 36; |
65 uint w = (minu(amount, 576) + 5) / 36; |
62 |
66 |
63 /* Draw total cargo (limited) on station (fits into 16 pixels) */ |
67 /* Draw total cargo (limited) on station (fits into 16 pixels) */ |
64 if (w != 0) GfxFillRect(x, y, x + w - 1, y + 6, colour); |
68 if (w != 0) GfxFillRect(x, y, x + w - 1, y + 6, colour); |
65 |
69 |
71 w += x; |
75 w += x; |
72 GfxFillRect(w, y + 6 - rest, w, y + 6, colour); |
76 GfxFillRect(w, y + 6 - rest, w, y + 6, colour); |
73 } |
77 } |
74 } |
78 } |
75 |
79 |
76 DrawString(x + 1, y, _cargoc.names_short[type], 0x10); |
80 DrawString(x + 1, y, cs->abbrev, 0x10); |
77 |
81 |
78 /* Draw green/red ratings bar (fits into 14 pixels) */ |
82 /* Draw green/red ratings bar (fits into 14 pixels) */ |
79 y += 8; |
83 y += 8; |
80 GfxFillRect(x + 1, y, x + 14, y, 0xB8); |
84 GfxFillRect(x + 1, y, x + 14, y, 0xB8); |
81 rating = minu(rating, 224) / 16; |
85 rating = minu(rating, 224) / 16; |
321 y = 14; |
325 y = 14; |
322 |
326 |
323 for (i = 0; i < NUM_CARGO; i++) { |
327 for (i = 0; i < NUM_CARGO; i++) { |
324 cg_ofst = IsWindowWidgetLowered(w, i + STATIONLIST_WIDGET_CARGOSTART) ? 2 : 1; |
328 cg_ofst = IsWindowWidgetLowered(w, i + STATIONLIST_WIDGET_CARGOSTART) ? 2 : 1; |
325 |
329 |
326 GfxFillRect(x + cg_ofst, y + cg_ofst, x + cg_ofst + 10 , y + cg_ofst + 7, _cargo_colours[i]); |
330 const CargoSpec *cs = GetCargo(i); |
327 DrawStringCentered(x + 6 + cg_ofst, y + cg_ofst, _cargoc.names_short[i], 0x10); |
331 if (cs->bitnum != 0xFF) { |
|
332 GfxFillRect(x + cg_ofst, y + cg_ofst, x + cg_ofst + 10 , y + cg_ofst + 7, cs->rating_colour); |
|
333 DrawStringCentered(x + 6 + cg_ofst, y + cg_ofst, cs->abbrev, 0x10); |
|
334 } |
328 x += 14; |
335 x += 14; |
329 } |
336 } |
330 |
337 |
331 x += 6; |
338 x += 6; |
332 cg_ofst = IsWindowWidgetLowered(w, STATIONLIST_WIDGET_NOCARGOWAITING) ? 2 : 1; |
339 cg_ofst = IsWindowWidgetLowered(w, STATIONLIST_WIDGET_NOCARGOWAITING) ? 2 : 1; |
699 } else { |
706 } else { |
700 /* Add a comma if this is not the first item */ |
707 /* Add a comma if this is not the first item */ |
701 *b++ = ','; |
708 *b++ = ','; |
702 *b++ = ' '; |
709 *b++ = ' '; |
703 } |
710 } |
704 b = InlineString(b, _cargoc.names_s[i]); |
711 b = InlineString(b, GetCargo(i)->name); |
705 } |
712 } |
706 } |
713 } |
707 |
714 |
708 /* If first is still true then no cargo is accepted */ |
715 /* If first is still true then no cargo is accepted */ |
709 if (first) b = InlineString(b, STR_00D0_NOTHING); |
716 if (first) b = InlineString(b, STR_00D0_NOTHING); |
714 DrawString(2, 67, STR_3034_LOCAL_RATING_OF_TRANSPORT, 0); |
721 DrawString(2, 67, STR_3034_LOCAL_RATING_OF_TRANSPORT, 0); |
715 |
722 |
716 y = 77; |
723 y = 77; |
717 for (i = 0; i != NUM_CARGO; i++) { |
724 for (i = 0; i != NUM_CARGO; i++) { |
718 if (st->goods[i].enroute_from != INVALID_STATION) { |
725 if (st->goods[i].enroute_from != INVALID_STATION) { |
719 SetDParam(0, _cargoc.names_s[i]); |
726 SetDParam(0, GetCargo(i)->name); |
720 SetDParam(2, st->goods[i].rating * 101 >> 8); |
727 SetDParam(2, st->goods[i].rating * 101 >> 8); |
721 SetDParam(1, STR_3035_APPALLING + (st->goods[i].rating >> 5)); |
728 SetDParam(1, STR_3035_APPALLING + (st->goods[i].rating >> 5)); |
722 DrawString(8, y, STR_303D, 0); |
729 DrawString(8, y, STR_303D, 0); |
723 y += 10; |
730 y += 10; |
724 } |
731 } |