summaryrefslogtreecommitdiff
path: root/src/misc_gui.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-04-06 22:32:20 +0000
committerrubidium <rubidium@openttd.org>2008-04-06 22:32:20 +0000
commit1bd5a29df5db4d1b6d3925f7f291bfae7688a6cd (patch)
tree397ef733d88fb8d1a2ef21941b6a693ad03870e0 /src/misc_gui.cpp
parentd90a0412301c7f2288914f13086e19283d5c039c (diff)
downloadopenttd-1bd5a29df5db4d1b6d3925f7f291bfae7688a6cd.tar.xz
(svn r12596) -Feature: show what cargos a station could be supplied with. Patch by Roujin.
Diffstat (limited to 'src/misc_gui.cpp')
-rw-r--r--src/misc_gui.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 59d3d779c..518c36864 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -763,12 +763,12 @@ void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint64 params[
}
-static int DrawStationCoverageText(const AcceptedCargo accepts,
- int str_x, int str_y, StationCoverageType sct)
+static int DrawStationCoverageText(const AcceptedCargo cargo,
+ int str_x, int str_y, StationCoverageType sct, bool supplies)
{
bool first = true;
- char *b = InlineString(_userstring, STR_000D_ACCEPTS);
+ char *b = InlineString(_userstring, supplies ? STR_SUPPLIES : STR_000D_ACCEPTS);
for (CargoID i = 0; i < NUM_CARGO; i++) {
if (b >= lastof(_userstring) - (1 + 2 * 4)) break; // ',' or ' ' and two calls to Utf8Encode()
@@ -778,7 +778,7 @@ static int DrawStationCoverageText(const AcceptedCargo accepts,
case SCT_ALL: break;
default: NOT_REACHED();
}
- if (accepts[i] >= 8) {
+ if (cargo[i] >= (supplies ? 1 : 8)) {
if (first) {
first = false;
} else {
@@ -801,13 +801,26 @@ static int DrawStationCoverageText(const AcceptedCargo accepts,
return DrawStringMultiLine(str_x, str_y, STR_SPEC_USERSTRING, 144);
}
-int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad)
+/**
+ * Calculates and draws the accepted or supplied cargo around the selected tile(s)
+ * @param sx x position where the string is to be drawn
+ * @param sy y position where the string is to be drawn
+ * @param sct which type of cargo is to be displayed (passengers/non-passengers)
+ * @param rad radius around selected tile(s) to be searched
+ * @param supplies if supplied cargos should be drawn, else accepted cargos
+ * @return Returns the y value below the string that was drawn
+ */
+int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad, bool supplies)
{
TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y);
- AcceptedCargo accepts;
+ AcceptedCargo cargo;
if (tile < MapSize()) {
- GetAcceptanceAroundTiles(accepts, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad);
- return sy + DrawStationCoverageText(accepts, sx, sy, sct);
+ if (supplies) {
+ GetProductionAroundTiles(cargo, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad);
+ } else {
+ GetAcceptanceAroundTiles(cargo, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad);
+ }
+ return sy + DrawStationCoverageText(cargo, sx, sy, sct, supplies);
}
return sy;