|
|
|
@ -34,45 +34,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
|
|
|
|
@ -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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|