Mercurial > hg > openttd
comparison src/station_gui.cpp @ 18678:5604c42fa1ce draft
(svn r23526) -Codechange: unify cargos vs cargoes
author | rubidium <rubidium@openttd.org> |
---|---|
date | Thu, 15 Dec 2011 21:56:00 +0000 |
parents | 7077d1f6763b |
children | e87c7c30e606 |
comparison
equal
deleted
inserted
replaced
18677:7077d1f6763b | 18678:5604c42fa1ce |
---|---|
31 #include "vehiclelist.h" | 31 #include "vehiclelist.h" |
32 | 32 |
33 #include "table/strings.h" | 33 #include "table/strings.h" |
34 | 34 |
35 /** | 35 /** |
36 * Draw a (multi)line of cargos seperated by commas, and prefixed with a string. | 36 * Draw a (multi)line of cargoes seperated by commas, and prefixed with a string. |
37 * @param cargo_mask Mask of cargos to include in the list. | 37 * @param cargo_mask Mask of cargoes to include in the list. |
38 * @param r Rectangle to draw the cargos in. | 38 * @param r Rectangle to draw the cargoes in. |
39 * @param prefix String to use as prefix for the list of cargos. | 39 * @param prefix String to use as prefix for the list of cargoes. |
40 * @return Bottom position of the last line used for drawing the cargos. | 40 * @return Bottom position of the last line used for drawing the cargoes. |
41 */ | 41 */ |
42 static int DrawCargoListText(uint32 cargo_mask, const Rect &r, StringID prefix) | 42 static int DrawCargoListText(uint32 cargo_mask, const Rect &r, StringID prefix) |
43 { | 43 { |
44 bool first = true; | 44 bool first = true; |
45 char string[512]; | 45 char string[512]; |
76 * @param left x position where the string is to be drawn | 76 * @param left x position where the string is to be drawn |
77 * @param right the right most position to draw on | 77 * @param right the right most position to draw on |
78 * @param top y position where the string is to be drawn | 78 * @param top y position where the string is to be drawn |
79 * @param sct which type of cargo is to be displayed (passengers/non-passengers) | 79 * @param sct which type of cargo is to be displayed (passengers/non-passengers) |
80 * @param rad radius around selected tile(s) to be searched | 80 * @param rad radius around selected tile(s) to be searched |
81 * @param supplies if supplied cargos should be drawn, else accepted cargos | 81 * @param supplies if supplied cargoes should be drawn, else accepted cargoes |
82 * @return Returns the y value below the string that was drawn | 82 * @return Returns the y value below the string that was drawn |
83 */ | 83 */ |
84 int DrawStationCoverageAreaText(int left, int right, int top, StationCoverageType sct, int rad, bool supplies) | 84 int DrawStationCoverageAreaText(int left, int right, int top, StationCoverageType sct, int rad, bool supplies) |
85 { | 85 { |
86 TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y); | 86 TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y); |
87 uint32 cargo_mask = 0; | 87 uint32 cargo_mask = 0; |
88 if (_thd.drawstyle == HT_RECT && tile < MapSize()) { | 88 if (_thd.drawstyle == HT_RECT && tile < MapSize()) { |
89 CargoArray cargos; | 89 CargoArray cargoes; |
90 if (supplies) { | 90 if (supplies) { |
91 cargos = GetProductionAroundTiles(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE, rad); | 91 cargoes = GetProductionAroundTiles(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE, rad); |
92 } else { | 92 } else { |
93 cargos = GetAcceptanceAroundTiles(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE, rad); | 93 cargoes = GetAcceptanceAroundTiles(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE, rad); |
94 } | 94 } |
95 | 95 |
96 /* Convert cargo counts to a set of cargo bits, and draw the result. */ | 96 /* Convert cargo counts to a set of cargo bits, and draw the result. */ |
97 for (CargoID i = 0; i < NUM_CARGO; i++) { | 97 for (CargoID i = 0; i < NUM_CARGO; i++) { |
98 switch (sct) { | 98 switch (sct) { |
99 case SCT_PASSENGERS_ONLY: if (!IsCargoInClass(i, CC_PASSENGERS)) continue; break; | 99 case SCT_PASSENGERS_ONLY: if (!IsCargoInClass(i, CC_PASSENGERS)) continue; break; |
100 case SCT_NON_PASSENGERS_ONLY: if (IsCargoInClass(i, CC_PASSENGERS)) continue; break; | 100 case SCT_NON_PASSENGERS_ONLY: if (IsCargoInClass(i, CC_PASSENGERS)) continue; break; |
101 case SCT_ALL: break; | 101 case SCT_ALL: break; |
102 default: NOT_REACHED(); | 102 default: NOT_REACHED(); |
103 } | 103 } |
104 if (cargos[i] >= (supplies ? 1U : 8U)) SetBit(cargo_mask, i); | 104 if (cargoes[i] >= (supplies ? 1U : 8U)) SetBit(cargo_mask, i); |
105 } | 105 } |
106 } | 106 } |
107 Rect r = {left, top, right, INT32_MAX}; | 107 Rect r = {left, top, right, INT32_MAX}; |
108 return DrawCargoListText(cargo_mask, r, supplies ? STR_STATION_BUILD_SUPPLIES_CARGO : STR_STATION_BUILD_ACCEPTS_CARGO); | 108 return DrawCargoListText(cargo_mask, r, supplies ? STR_STATION_BUILD_SUPPLIES_CARGO : STR_STATION_BUILD_ACCEPTS_CARGO); |
109 } | 109 } |
998 *transfers = 0; | 998 *transfers = 0; |
999 | 999 |
1000 StationID station_id = this->window_number; | 1000 StationID station_id = this->window_number; |
1001 const Station *st = Station::Get(station_id); | 1001 const Station *st = Station::Get(station_id); |
1002 | 1002 |
1003 /* count types of cargos waiting in station */ | 1003 /* count types of cargoes waiting in station */ |
1004 for (CargoID i = 0; i < NUM_CARGO; i++) { | 1004 for (CargoID i = 0; i < NUM_CARGO; i++) { |
1005 if (st->goods[i].cargo.Empty()) { | 1005 if (st->goods[i].cargo.Empty()) { |
1006 this->cargo_rows[i] = 0; | 1006 this->cargo_rows[i] = 0; |
1007 } else { | 1007 } else { |
1008 /* Add an entry for total amount of cargo of this type waiting. */ | 1008 /* Add an entry for total amount of cargo of this type waiting. */ |