* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file station_gui.cpp The GUI for stations. */
#include "stdafx.h"
#include "debug.h"
#include "gui.h"
#include "textbuf_gui.h"
#include "company_func.h"
#include "command_func.h"
#include "vehicle_gui.h"
#include "cargotype.h"
#include "station_gui.h"
#include "strings_func.h"
#include "window_func.h"
#include "viewport_func.h"
#include "widgets/dropdown_func.h"
#include "station_base.h"
#include "waypoint_base.h"
#include "tilehighlight_func.h"
#include "company_base.h"
#include "sortlist_type.h"
#include "core/geometry_func.hpp"
#include "vehiclelist.h"
#include "table/strings.h"
/**
* Draw a (multi)line of cargos seperated by commas, and prefixed with a string.
* @param cargo_mask Mask of cargos to include in the list.
* @param r Rectangle to draw the cargos in.
* @param prefix String to use as prefix for the list of cargos.
* @return Bottom position of the last line used for drawing the cargos.
*/
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 */