summaryrefslogtreecommitdiff
path: root/src/station_gui.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2012-03-10 19:18:04 +0000
committerrubidium <rubidium@openttd.org>2012-03-10 19:18:04 +0000
commitbf6434abaf306272d14019a628af972ce181652c (patch)
tree661db86c626e8555034ce84ff833c2c14648c01f /src/station_gui.cpp
parent19923e81f97fe560ba102ebcbaf116634c68ccb6 (diff)
downloadopenttd-bf6434abaf306272d14019a628af972ce181652c.tar.xz
(svn r24023) -Fix [FS#5090]: pass cases down into the list of cargos
Diffstat (limited to 'src/station_gui.cpp')
-rw-r--r--src/station_gui.cpp47
1 files changed, 4 insertions, 43 deletions
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index 44945158f..e3610c2cc 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -35,45 +35,6 @@
#include "table/strings.h"
/**
- * Draw a (multi)line of cargoes seperated by commas, and prefixed with a string.
- * @param cargo_mask Mask of cargoes to include in the list.
- * @param r Rectangle to draw the cargoes in.
- * @param prefix String to use as prefix for the list of cargoes.
- * @return Bottom position of the last line used for drawing the cargoes.
- */
-static int DrawCargoListText(uint32 cargo_mask, const Rect &r, StringID prefix)
-{
- bool first = true;
- char string[512];
- char *b = string;
-
- CargoID i;
- FOR_EACH_SET_CARGO_ID(i, cargo_mask) {
- if (b >= lastof(string) - (1 + 2 * 4)) break; // ',' or ' ' and two calls to Utf8Encode()
-
- if (first) {
- first = false;
- } else {
- /* Add a comma if this is not the first item */
- *b++ = ',';
- *b++ = ' ';
- }
- b = InlineString(b, CargoSpec::Get(i)->name);
- }
-
- /* If first is still true then no cargo is accepted */
- if (first) b = InlineString(b, STR_JUST_NOTHING);
-
- *b = '\0';
-
- /* Make sure we detect any buffer overflow */
- assert(b < endof(string));
-
- SetDParamStr(0, string);
- return DrawStringMultiLine(r.left, r.right, r.top, r.bottom, prefix);
-}
-
-/**
* Calculates and draws the accepted or supplied cargo around the selected tile(s)
* @param left x position where the string is to be drawn
* @param right the right most position to draw on
@@ -106,8 +67,8 @@ int DrawStationCoverageAreaText(int left, int right, int top, StationCoverageTyp
if (cargoes[i] >= (supplies ? 1U : 8U)) SetBit(cargo_mask, i);
}
}
- Rect r = {left, top, right, INT32_MAX};
- return DrawCargoListText(cargo_mask, r, supplies ? STR_STATION_BUILD_SUPPLIES_CARGO : STR_STATION_BUILD_ACCEPTS_CARGO);
+ SetDParam(0, cargo_mask);
+ return DrawStringMultiLine(left, right, top, INT32_MAX, supplies ? STR_STATION_BUILD_SUPPLIES_CARGO : STR_STATION_BUILD_ACCEPTS_CARGO);
}
/**
@@ -1091,8 +1052,8 @@ struct StationViewWindow : public Window {
for (CargoID i = 0; i < NUM_CARGO; i++) {
if (HasBit(st->goods[i].acceptance_pickup, GoodsEntry::GES_ACCEPTANCE)) SetBit(cargo_mask, i);
}
- Rect s = {r.left + WD_FRAMERECT_LEFT, r.top + WD_FRAMERECT_TOP, r.right - WD_FRAMERECT_RIGHT, INT32_MAX};
- int bottom = DrawCargoListText(cargo_mask, s, STR_STATION_VIEW_ACCEPTS_CARGO);
+ SetDParam(0, cargo_mask);
+ int bottom = DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, INT32_MAX, STR_STATION_VIEW_ACCEPTS_CARGO);
return CeilDiv(bottom - r.top - WD_FRAMERECT_TOP, FONT_HEIGHT_NORMAL);
}