2005-07-24 15:12:37 +01:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 21:21:05 +01:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 16:11:33 +01:00
|
|
|
/** @file train_gui.cpp GUI for trains. */
|
2007-04-04 04:21:14 +01:00
|
|
|
|
2004-08-09 18:04:08 +01:00
|
|
|
#include "stdafx.h"
|
2007-12-19 20:45:46 +00:00
|
|
|
#include "window_gui.h"
|
2008-01-09 09:45:45 +00:00
|
|
|
#include "gfx_func.h"
|
2007-12-21 21:50:46 +00:00
|
|
|
#include "command_func.h"
|
2004-12-10 18:16:08 +00:00
|
|
|
#include "vehicle_gui.h"
|
2005-11-18 23:41:03 +00:00
|
|
|
#include "train.h"
|
2007-12-21 19:49:27 +00:00
|
|
|
#include "strings_func.h"
|
2007-12-27 13:35:39 +00:00
|
|
|
#include "vehicle_func.h"
|
2008-04-29 22:31:29 +01:00
|
|
|
#include "engine_base.h"
|
2008-05-18 17:51:44 +01:00
|
|
|
#include "window_func.h"
|
2004-08-09 18:04:08 +01:00
|
|
|
|
2008-01-13 01:21:35 +00:00
|
|
|
#include "table/sprites.h"
|
|
|
|
#include "table/strings.h"
|
|
|
|
|
2005-06-24 13:38:35 +01:00
|
|
|
void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
2004-08-09 18:04:08 +01:00
|
|
|
{
|
2006-06-27 22:25:53 +01:00
|
|
|
if (!success) return;
|
2004-08-09 18:04:08 +01:00
|
|
|
|
2007-04-04 04:21:14 +01:00
|
|
|
/* find a locomotive in the depot. */
|
2008-05-25 10:40:44 +01:00
|
|
|
const Vehicle *found = NULL;
|
2009-05-26 23:45:48 +01:00
|
|
|
const Train *t;
|
|
|
|
FOR_ALL_TRAINS(t) {
|
2009-07-01 23:22:01 +01:00
|
|
|
if (t->IsFrontEngine() && t->tile == tile &&
|
2009-05-26 23:45:48 +01:00
|
|
|
t->track == TRACK_BIT_DEPOT) {
|
2006-06-27 22:25:53 +01:00
|
|
|
if (found != NULL) return; // must be exactly one.
|
2009-05-26 23:45:48 +01:00
|
|
|
found = t;
|
2004-08-09 18:04:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-04 04:21:14 +01:00
|
|
|
/* if we found a loco, */
|
2004-08-09 18:04:08 +01:00
|
|
|
if (found != NULL) {
|
2009-07-20 20:58:33 +01:00
|
|
|
found = found->Last();
|
2007-04-04 04:21:14 +01:00
|
|
|
/* put the new wagon at the end of the loco. */
|
2008-12-28 14:37:19 +00:00
|
|
|
DoCommandP(0, _new_vehicle_id | (found->index << 16), 0, CMD_MOVE_RAIL_VEHICLE);
|
2008-05-18 17:51:44 +01:00
|
|
|
InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
|
2004-08-09 18:04:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-12 17:00:11 +01:00
|
|
|
/**
|
|
|
|
* Draws an image of a whole train
|
2009-11-16 22:25:01 +00:00
|
|
|
* @param v Front vehicle
|
|
|
|
* @param left The minimum horizontal position
|
|
|
|
* @param right The maximum horizontal position
|
|
|
|
* @param y Vertical position to draw at
|
2009-09-19 10:51:14 +01:00
|
|
|
* @param selection Selected vehicle to draw a frame around
|
2009-11-16 22:25:01 +00:00
|
|
|
* @param skip Number of pixels to skip at the front (for scrolling)
|
2009-07-12 17:00:11 +01:00
|
|
|
*/
|
2009-11-16 22:25:01 +00:00
|
|
|
void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID selection, int skip)
|
2004-08-09 18:04:08 +01:00
|
|
|
{
|
2009-11-17 11:36:36 +00:00
|
|
|
bool rtl = _dynlang.text_dir == TD_RTL;
|
|
|
|
Direction dir = rtl ? DIR_E : DIR_W;
|
|
|
|
|
2006-05-30 22:19:46 +01:00
|
|
|
DrawPixelInfo tmp_dpi, *old_dpi;
|
2006-06-20 08:07:28 +01:00
|
|
|
/* Position of highlight box */
|
|
|
|
int highlight_l = 0;
|
|
|
|
int highlight_r = 0;
|
2009-11-16 22:25:01 +00:00
|
|
|
int max_width = right - left + 1;
|
2006-05-30 22:19:46 +01:00
|
|
|
|
2009-11-16 22:25:01 +00:00
|
|
|
if (!FillDrawPixelInfo(&tmp_dpi, left, y, max_width, 14)) return;
|
2006-05-30 22:19:46 +01:00
|
|
|
|
|
|
|
old_dpi = _cur_dpi;
|
|
|
|
_cur_dpi = &tmp_dpi;
|
2005-06-06 23:44:11 +01:00
|
|
|
|
2009-11-17 11:36:36 +00:00
|
|
|
int px = rtl ? max_width + skip : -skip;
|
2009-07-13 20:34:43 +01:00
|
|
|
bool sel_articulated = false;
|
2009-11-17 11:36:36 +00:00
|
|
|
for (; v != NULL && (rtl ? px > 0 : px < max_width); v = v->Next()) {
|
2009-07-17 23:00:13 +01:00
|
|
|
Point offset;
|
|
|
|
int width = Train::From(v)->GetDisplayImageWidth(&offset);
|
2009-07-13 20:30:37 +01:00
|
|
|
|
2009-11-17 11:36:36 +00:00
|
|
|
if (rtl ? px + width > 0 : px - width < max_width) {
|
2009-07-13 20:30:37 +01:00
|
|
|
SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
|
2009-11-17 11:36:36 +00:00
|
|
|
DrawSprite(v->GetImage(dir), pal, px + (rtl ? -offset.x : offset.x), 7 + offset.y);
|
2004-08-09 18:04:08 +01:00
|
|
|
}
|
|
|
|
|
2009-07-13 20:34:43 +01:00
|
|
|
if (!v->IsArticulatedPart()) sel_articulated = false;
|
|
|
|
|
2009-07-13 20:30:37 +01:00
|
|
|
if (v->index == selection) {
|
|
|
|
/* Set the highlight position */
|
2009-11-18 10:45:33 +00:00
|
|
|
highlight_l = rtl ? px - width : px;
|
|
|
|
highlight_r = rtl ? px - 1 : px + width - 1;
|
2009-07-13 20:34:43 +01:00
|
|
|
sel_articulated = true;
|
|
|
|
} else if ((_cursor.vehchain && highlight_r != 0) || sel_articulated) {
|
2009-11-17 11:36:36 +00:00
|
|
|
if (rtl) {
|
|
|
|
highlight_l -= width;
|
2009-11-18 10:45:33 +00:00
|
|
|
} else {
|
|
|
|
highlight_r += width;
|
2009-11-17 11:36:36 +00:00
|
|
|
}
|
2009-07-13 20:30:37 +01:00
|
|
|
}
|
|
|
|
|
2009-11-17 11:36:36 +00:00
|
|
|
px += rtl ? -width : width;
|
2009-07-13 20:30:37 +01:00
|
|
|
}
|
2006-05-30 22:19:46 +01:00
|
|
|
|
2006-06-20 08:07:28 +01:00
|
|
|
if (highlight_l != highlight_r) {
|
|
|
|
/* Draw the highlight. Now done after drawing all the engines, as
|
|
|
|
* the next engine after the highlight could overlap it. */
|
2008-08-01 04:43:53 +01:00
|
|
|
DrawFrameRect(highlight_l, 0, highlight_r, 13, COLOUR_WHITE, FR_BORDERONLY);
|
2006-06-20 08:07:28 +01:00
|
|
|
}
|
|
|
|
|
2006-05-30 22:19:46 +01:00
|
|
|
_cur_dpi = old_dpi;
|
2004-08-09 18:04:08 +01:00
|
|
|
}
|
|
|
|
|
2009-11-29 19:31:23 +00:00
|
|
|
/** Helper struct for the cargo details information */
|
|
|
|
struct CargoSummaryItem {
|
|
|
|
CargoID cargo; ///< The cargo that is carried
|
|
|
|
StringID subtype; ///< STR_EMPTY if none
|
|
|
|
uint capacity; ///< Amount that can be carried
|
|
|
|
uint amount; ///< Amount that is carried
|
|
|
|
StationID source; ///< One of the source stations
|
|
|
|
|
|
|
|
/** Used by CargoSummary::Find() and similiar functions */
|
|
|
|
FORCEINLINE bool operator != (const CargoSummaryItem &other) const
|
|
|
|
{
|
|
|
|
return this->cargo != other.cargo || this->subtype != other.subtype;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
TRAIN_DETAILS_MIN_INDENT = 32, ///< Minimum indent level in the train details window
|
|
|
|
TRAIN_DETAILS_MAX_INDENT = 72, ///< Maximum indent level in the train details window; wider than this and we start on a new line
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Container for the cargo summary information. */
|
|
|
|
typedef SmallVector<CargoSummaryItem, 2> CargoSummary;
|
|
|
|
/** Reused container of cargo details */
|
|
|
|
static CargoSummary _cargo_summary;
|
|
|
|
|
2009-03-22 10:37:51 +00:00
|
|
|
/**
|
|
|
|
* Draw the details cargo tab for the given vehicle at the given position
|
|
|
|
*
|
2009-11-29 19:31:23 +00:00
|
|
|
* @param item Data to draw
|
2009-03-22 10:37:51 +00:00
|
|
|
* @param left The left most coordinate to draw
|
|
|
|
* @param right The right most coordinate to draw
|
|
|
|
* @param y The y coordinate
|
|
|
|
*/
|
2009-11-29 19:31:23 +00:00
|
|
|
static void TrainDetailsCargoTab(const CargoSummaryItem *item, int left, int right, int y)
|
2004-08-09 18:04:08 +01:00
|
|
|
{
|
2009-11-29 19:31:23 +00:00
|
|
|
StringID str = STR_VEHICLE_DETAILS_CARGO_EMPTY;
|
|
|
|
|
|
|
|
if (item->amount > 0) {
|
|
|
|
SetDParam(0, item->cargo);
|
|
|
|
SetDParam(1, item->amount);
|
|
|
|
SetDParam(2, item->source);
|
|
|
|
SetDParam(3, _settings_game.vehicle.freight_trains);
|
|
|
|
str = FreightWagonMult(item->cargo) > 1 ? STR_VEHICLE_DETAILS_CARGO_FROM_MULT : STR_VEHICLE_DETAILS_CARGO_FROM;
|
2004-08-09 18:04:08 +01:00
|
|
|
}
|
2009-11-29 19:31:23 +00:00
|
|
|
|
|
|
|
DrawString(left, right, y, str);
|
2004-08-09 18:04:08 +01:00
|
|
|
}
|
|
|
|
|
2009-03-22 10:37:51 +00:00
|
|
|
/**
|
|
|
|
* Draw the details info tab for the given vehicle at the given position
|
|
|
|
*
|
|
|
|
* @param v current vehicle
|
|
|
|
* @param left The left most coordinate to draw
|
|
|
|
* @param right The right most coordinate to draw
|
|
|
|
* @param y The y coordinate
|
|
|
|
*/
|
|
|
|
static void TrainDetailsInfoTab(const Vehicle *v, int left, int right, int y)
|
2004-08-09 18:04:08 +01:00
|
|
|
{
|
2007-01-30 11:53:35 +00:00
|
|
|
if (RailVehInfo(v->engine_type)->railveh_type == RAILVEH_WAGON) {
|
2007-06-25 15:46:32 +01:00
|
|
|
SetDParam(0, v->engine_type);
|
2007-06-21 18:25:17 +01:00
|
|
|
SetDParam(1, v->value);
|
2009-11-17 15:26:46 +00:00
|
|
|
DrawString(left, right, y, STR_VEHICLE_DETAILS_TRAIN_WAGON_VALUE, TC_FROMSTRING, SA_LEFT | SA_STRIP);
|
2006-08-31 16:22:03 +01:00
|
|
|
} else {
|
2007-06-25 15:46:32 +01:00
|
|
|
SetDParam(0, v->engine_type);
|
2006-08-20 20:05:28 +01:00
|
|
|
SetDParam(1, v->build_year);
|
2007-06-21 18:25:17 +01:00
|
|
|
SetDParam(2, v->value);
|
2009-11-17 15:26:46 +00:00
|
|
|
DrawString(left, right, y, STR_VEHICLE_DETAILS_TRAIN_ENGINE_BUILT_AND_VALUE, TC_FROMSTRING, SA_LEFT | SA_STRIP);
|
2004-09-10 20:02:27 +01:00
|
|
|
}
|
2004-08-09 18:04:08 +01:00
|
|
|
}
|
|
|
|
|
2009-03-22 10:37:51 +00:00
|
|
|
/**
|
|
|
|
* Draw the details capacity tab for the given vehicle at the given position
|
|
|
|
*
|
2009-11-29 19:31:23 +00:00
|
|
|
* @param item Data to draw
|
2009-03-22 10:37:51 +00:00
|
|
|
* @param left The left most coordinate to draw
|
|
|
|
* @param right The right most coordinate to draw
|
|
|
|
* @param y The y coordinate
|
|
|
|
*/
|
2009-11-29 19:31:23 +00:00
|
|
|
static void TrainDetailsCapacityTab(const CargoSummaryItem *item, int left, int right, int y)
|
2004-08-09 18:04:08 +01:00
|
|
|
{
|
2009-11-29 19:31:23 +00:00
|
|
|
SetDParam(0, item->cargo);
|
|
|
|
SetDParam(1, item->capacity);
|
|
|
|
SetDParam(4, item->subtype);
|
|
|
|
SetDParam(5, _settings_game.vehicle.freight_trains);
|
|
|
|
DrawString(left, right, y, FreightWagonMult(item->cargo) > 1 ? STR_VEHICLE_INFO_CAPACITY_MULT : STR_VEHICLE_INFO_CAPACITY);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Collects the cargo transportet
|
|
|
|
* @param v Vehicle to process
|
|
|
|
* @param summary Space for the result
|
|
|
|
*/
|
|
|
|
static void GetCargoSummaryOfArticulatedVehicle(const Train *v, CargoSummary *summary)
|
|
|
|
{
|
|
|
|
summary->Clear();
|
|
|
|
do {
|
|
|
|
if (v->cargo_cap == 0) continue;
|
|
|
|
|
|
|
|
CargoSummaryItem new_item;
|
|
|
|
new_item.cargo = v->cargo_type;
|
|
|
|
new_item.subtype = GetCargoSubtypeText(v);
|
|
|
|
|
|
|
|
CargoSummaryItem *item = summary->Find(new_item);
|
|
|
|
if (item == summary->End()) {
|
|
|
|
item = summary->Append();
|
|
|
|
item->cargo = new_item.cargo;
|
|
|
|
item->subtype = new_item.subtype;
|
|
|
|
item->capacity = 0;
|
|
|
|
item->amount = 0;
|
|
|
|
item->source = INVALID_STATION;
|
|
|
|
}
|
|
|
|
|
|
|
|
item->capacity += v->cargo_cap;
|
|
|
|
item->amount += v->cargo.Count();
|
|
|
|
if (item->source == INVALID_STATION) item->source = v->cargo.Source();
|
|
|
|
} while ((v = v->Next()) != NULL && v->IsArticulatedPart());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the length of an articulated vehicle.
|
|
|
|
* @param v the vehicle to get the length of.
|
|
|
|
* @return the length in pixels.
|
|
|
|
*/
|
|
|
|
static uint GetLengthOfArticulatedVehicle(const Train *v)
|
|
|
|
{
|
|
|
|
uint length = 0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
length += v->GetDisplayImageWidth();
|
|
|
|
} while ((v = v->Next()) != NULL && v->IsArticulatedPart());
|
|
|
|
|
|
|
|
return length;
|
2004-08-09 18:04:08 +01:00
|
|
|
}
|
|
|
|
|
2009-05-31 15:04:19 +01:00
|
|
|
/**
|
|
|
|
* Determines the number of lines in the train details window
|
|
|
|
* @param veh_id Train
|
|
|
|
* @param det_tab Selected details tab
|
|
|
|
* @return Number of line
|
|
|
|
*/
|
|
|
|
int GetTrainDetailsWndVScroll(VehicleID veh_id, TrainDetailsWindowTabs det_tab)
|
2004-08-09 18:04:08 +01:00
|
|
|
{
|
2007-09-06 00:26:45 +01:00
|
|
|
int num = 0;
|
2004-08-09 18:04:08 +01:00
|
|
|
|
2009-05-31 15:04:19 +01:00
|
|
|
if (det_tab == TDW_TAB_TOTALS) { // Total cargo tab
|
2009-06-27 22:06:58 +01:00
|
|
|
CargoArray act_cargo;
|
|
|
|
CargoArray max_cargo;
|
2009-11-29 19:20:39 +00:00
|
|
|
for (const Vehicle *v = Vehicle::Get(veh_id); v != NULL; v = v->Next()) {
|
2007-09-06 00:26:45 +01:00
|
|
|
act_cargo[v->cargo_type] += v->cargo.Count();
|
|
|
|
max_cargo[v->cargo_type] += v->cargo_cap;
|
|
|
|
}
|
2006-08-31 16:22:03 +01:00
|
|
|
|
|
|
|
/* Set scroll-amount seperately from counting, as to not compute num double
|
|
|
|
* for more carriages of the same type
|
|
|
|
*/
|
2007-03-21 13:19:01 +00:00
|
|
|
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
2006-08-31 16:22:03 +01:00
|
|
|
if (max_cargo[i] > 0) num++; // only count carriages that the train has
|
2004-08-09 18:04:08 +01:00
|
|
|
}
|
2006-08-28 19:53:03 +01:00
|
|
|
num++; // needs one more because first line is description string
|
2006-08-31 16:22:03 +01:00
|
|
|
} else {
|
2009-11-29 19:31:23 +00:00
|
|
|
for (const Train *v = Train::Get(veh_id); v != NULL; v = v->GetNextVehicle()) {
|
|
|
|
GetCargoSummaryOfArticulatedVehicle(v, &_cargo_summary);
|
|
|
|
num += max(1u, _cargo_summary.Length());
|
|
|
|
|
|
|
|
uint length = GetLengthOfArticulatedVehicle(v);
|
|
|
|
if (length > TRAIN_DETAILS_MAX_INDENT) num++;
|
2007-09-06 00:26:45 +01:00
|
|
|
}
|
2004-08-09 18:04:08 +01:00
|
|
|
}
|
|
|
|
|
2007-09-06 00:26:45 +01:00
|
|
|
return num;
|
|
|
|
}
|
2004-09-10 20:02:27 +01:00
|
|
|
|
2009-03-22 10:37:51 +00:00
|
|
|
/**
|
|
|
|
* Draw the details for the given vehicle at the given position
|
|
|
|
*
|
|
|
|
* @param v current vehicle
|
|
|
|
* @param left The left most coordinate to draw
|
|
|
|
* @param right The right most coordinate to draw
|
|
|
|
* @param y The y coordinate
|
2009-05-31 15:04:19 +01:00
|
|
|
* @param vscroll_pos Position of scrollbar
|
|
|
|
* @param vscroll_cap Number of lines currently displayed
|
|
|
|
* @param det_tab Selected details tab
|
2009-03-22 10:37:51 +00:00
|
|
|
*/
|
2009-07-02 00:57:20 +01:00
|
|
|
void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_pos, uint16 vscroll_cap, TrainDetailsWindowTabs det_tab)
|
2007-09-06 00:26:45 +01:00
|
|
|
{
|
2007-04-04 04:21:14 +01:00
|
|
|
/* draw the first 3 details tabs */
|
2009-05-31 15:04:19 +01:00
|
|
|
if (det_tab != TDW_TAB_TOTALS) {
|
2009-11-17 15:05:12 +00:00
|
|
|
bool rtl = _dynlang.text_dir == TD_RTL;
|
|
|
|
Direction dir = rtl ? DIR_E : DIR_W;
|
|
|
|
int x = rtl ? right : left;
|
2009-11-23 16:18:01 +00:00
|
|
|
int sprite_y_offset = 4 + (FONT_HEIGHT_NORMAL - 10) / 2;
|
2009-11-29 19:31:23 +00:00
|
|
|
int line_height = WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM;
|
|
|
|
for (; v != NULL && vscroll_pos > -vscroll_cap; v = v->GetNextVehicle()) {
|
|
|
|
GetCargoSummaryOfArticulatedVehicle(v, &_cargo_summary);
|
|
|
|
|
|
|
|
/* Draw sprites */
|
|
|
|
int dx = 0;
|
|
|
|
int px = x;
|
|
|
|
const Train *u = v;
|
|
|
|
do {
|
|
|
|
Point offset;
|
|
|
|
int width = u->GetDisplayImageWidth(&offset);
|
|
|
|
if (vscroll_pos <= 0 && vscroll_pos > -vscroll_cap) {
|
|
|
|
SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
|
|
|
|
DrawSprite(u->GetImage(dir), pal, px + (rtl ? -offset.x : offset.x), y - line_height * vscroll_pos + sprite_y_offset + offset.y);
|
2006-08-31 16:22:03 +01:00
|
|
|
}
|
2009-11-29 19:31:23 +00:00
|
|
|
px += rtl ? -width : width;
|
|
|
|
dx += width;
|
|
|
|
u = u->Next();
|
|
|
|
} while (u != NULL && u->IsArticulatedPart());
|
|
|
|
|
|
|
|
bool separate_sprite_row = (dx > TRAIN_DETAILS_MAX_INDENT);
|
|
|
|
if (separate_sprite_row) {
|
|
|
|
vscroll_pos--;
|
|
|
|
dx = 0;
|
|
|
|
}
|
2006-10-17 08:33:05 +01:00
|
|
|
|
2009-11-29 19:31:23 +00:00
|
|
|
uint num_lines = max(1u, _cargo_summary.Length());
|
|
|
|
for (uint i = 0; i < num_lines; i++) {
|
|
|
|
int sprite_width = max<int>(dx, TRAIN_DETAILS_MIN_INDENT) + 3;
|
|
|
|
int data_left = left + (rtl ? 0 : sprite_width);
|
|
|
|
int data_right = right - (rtl ? sprite_width : 0);
|
|
|
|
if (vscroll_pos <= 0 && vscroll_pos > -vscroll_cap) {
|
|
|
|
int py = y - line_height * vscroll_pos;
|
|
|
|
if (i > 0 || separate_sprite_row) {
|
|
|
|
if (vscroll_pos != 0) GfxFillRect(left, py - WD_MATRIX_TOP - 1, right, py - WD_MATRIX_TOP, _colour_gradient[COLOUR_GREY][5]);
|
|
|
|
}
|
|
|
|
switch (det_tab) {
|
|
|
|
case TDW_TAB_CARGO:
|
|
|
|
if (i < _cargo_summary.Length()) {
|
|
|
|
TrainDetailsCargoTab(&_cargo_summary[i], data_left, data_right, py);
|
|
|
|
} else {
|
|
|
|
DrawString(data_left, data_right, py, STR_QUANTITY_N_A, TC_LIGHT_BLUE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TDW_TAB_INFO:
|
|
|
|
if (i == 0) TrainDetailsInfoTab(v, data_left, data_right, py);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TDW_TAB_CAPACITY:
|
|
|
|
if (i < _cargo_summary.Length()) {
|
|
|
|
TrainDetailsCapacityTab(&_cargo_summary[i], data_left, data_right, py);
|
|
|
|
} else {
|
|
|
|
DrawString(data_left, data_right, py, STR_VEHICLE_INFO_NO_CAPACITY);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
vscroll_pos--;
|
2004-08-09 18:04:08 +01:00
|
|
|
}
|
|
|
|
}
|
2006-02-02 08:03:10 +00:00
|
|
|
} else {
|
2009-06-27 19:26:50 +01:00
|
|
|
CargoArray act_cargo;
|
|
|
|
CargoArray max_cargo;
|
2009-06-27 22:06:58 +01:00
|
|
|
Money feeder_share = 0;
|
2007-09-06 00:26:45 +01:00
|
|
|
|
2009-11-29 19:20:39 +00:00
|
|
|
for (const Vehicle *u = v; u != NULL; u = u->Next()) {
|
2007-09-06 00:26:45 +01:00
|
|
|
act_cargo[u->cargo_type] += u->cargo.Count();
|
|
|
|
max_cargo[u->cargo_type] += u->cargo_cap;
|
2008-08-18 17:52:40 +01:00
|
|
|
feeder_share += u->cargo.FeederShare();
|
2007-09-06 00:26:45 +01:00
|
|
|
}
|
|
|
|
|
2007-04-04 04:21:14 +01:00
|
|
|
/* draw total cargo tab */
|
2009-11-16 21:10:23 +00:00
|
|
|
DrawString(left, right, y, STR_VEHICLE_DETAILS_TRAIN_TOTAL_CAPACITY_TEXT);
|
|
|
|
y += WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM;
|
|
|
|
|
2007-03-21 13:19:01 +00:00
|
|
|
for (CargoID i = 0; i < NUM_CARGO; i++) {
|
2007-09-06 00:26:45 +01:00
|
|
|
if (max_cargo[i] > 0 && --vscroll_pos < 0 && vscroll_pos > -vscroll_cap) {
|
2006-08-31 16:22:03 +01:00
|
|
|
SetDParam(0, i); // {CARGO} #1
|
|
|
|
SetDParam(1, act_cargo[i]); // {CARGO} #2
|
|
|
|
SetDParam(2, i); // {SHORTCARGO} #1
|
|
|
|
SetDParam(3, max_cargo[i]); // {SHORTCARGO} #2
|
2008-05-29 16:13:28 +01:00
|
|
|
SetDParam(4, _settings_game.vehicle.freight_trains);
|
2009-11-16 21:10:23 +00:00
|
|
|
DrawString(left, right, y, FreightWagonMult(i) > 1 ? STR_VEHICLE_DETAILS_TRAIN_TOTAL_CAPACITY_MULT : STR_VEHICLE_DETAILS_TRAIN_TOTAL_CAPACITY);
|
|
|
|
y += WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM;
|
2004-08-09 18:04:08 +01:00
|
|
|
}
|
2006-02-02 08:03:10 +00:00
|
|
|
}
|
2008-08-18 17:52:40 +01:00
|
|
|
SetDParam(0, feeder_share);
|
2009-11-16 21:10:23 +00:00
|
|
|
DrawString(left, right, y, STR_VEHICLE_INFO_FEEDER_CARGO_VALUE);
|
2004-08-09 18:04:08 +01:00
|
|
|
}
|
|
|
|
}
|