src/train_gui.cpp
author translators
Wed, 17 Dec 2008 18:01:19 +0000
changeset 10433 45f92593bd6e
parent 9943 ccea23aec951
permissions -rw-r--r--
(svn r14686) -Update: WebTranslator2 update to 2008-12-17 18:01:03
arabic_egypt - 200 fixed, 28 changed by Azoo4oozi (228)
czech - 3 changed by Hadez (3)
indonesian - 1 fixed, 4 changed by fanioz (5)
korean - 1 changed by leejaeuk5 (1)
latvian - 299 fixed, 3 changed by marismols (302)
lithuanian - 79 fixed by Zogg (79)
serbian - 25 fixed by Jenraux (25)
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
9111
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 9070
diff changeset
     3
/** @file train_gui.cpp GUI for trains. */
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6350
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
862800791170 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1820
diff changeset
     6
#include "openttd.h"
1299
39c06aba09aa (svn r1803) Move debugging stuff into files of it's own
tron
parents: 1294
diff changeset
     7
#include "debug.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     8
#include "gui.h"
8107
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
     9
#include "window_gui.h"
8224
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8211
diff changeset
    10
#include "gfx_func.h"
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8114
diff changeset
    11
#include "command_func.h"
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 573
diff changeset
    12
#include "vehicle_gui.h"
2676
59b65b4fb480 (svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents: 2639
diff changeset
    13
#include "train.h"
2962
f0a49b646c48 (svn r3524) - Split newgrf features from engine.[ch] into newgrf_engine.[ch], and add the new files to project files.
peter1138
parents: 2959
diff changeset
    14
#include "newgrf_engine.h"
8114
dd6d21dc99c1 (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8107
diff changeset
    15
#include "strings_func.h"
8144
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8131
diff changeset
    16
#include "vehicle_func.h"
8211
29a8510dfd62 (svn r11774) -Change: do not include variables.h in a header when it is not needed.
rubidium
parents: 8144
diff changeset
    17
#include "settings_type.h"
8784
c2e9d649a9ce (svn r12488) -Codechange: split order.h into order_base.h and order_func.h.
rubidium
parents: 8424
diff changeset
    18
#include "order_func.h"
8786
1823ff88a054 (svn r12490) -Codechange: rename engine.h to engine_func.h and remove unneeded inclusions of engine.h and/or replace them with engine_type.h.
rubidium
parents: 8784
diff changeset
    19
#include "engine_func.h"
9070
dd0121143eba (svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents: 8962
diff changeset
    20
#include "engine_base.h"
9297
1cb8d7bbdc8a (svn r13165) -Codechange: replace some RebuildXXXList/ResortXXXList+InvalidateWindowXXX with InvalidateWindowXXXData.
rubidium
parents: 9111
diff changeset
    21
#include "window_func.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    22
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8224
diff changeset
    23
#include "table/sprites.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8224
diff changeset
    24
#include "table/strings.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8224
diff changeset
    25
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
    26
void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    27
{
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4049
diff changeset
    28
	if (!success) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    29
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6350
diff changeset
    30
	/* find a locomotive in the depot. */
9344
d3b1b1fbbad9 (svn r13240) -Codechange: More const-ness for GUI code.
peter1138
parents: 9297
diff changeset
    31
	const Vehicle *found = NULL;
d3b1b1fbbad9 (svn r13240) -Codechange: More const-ness for GUI code.
peter1138
parents: 9297
diff changeset
    32
	const Vehicle *v;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
	FOR_ALL_VEHICLES(v) {
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6198
diff changeset
    34
		if (v->type == VEH_TRAIN && IsFrontEngine(v) &&
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
				v->tile == tile &&
5993
956d341d930e (svn r8701) -Codechange: replace magic numbers with enums for u.rail.track.
rubidium
parents: 5893
diff changeset
    36
				v->u.rail.track == TRACK_BIT_DEPOT) {
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4049
diff changeset
    37
			if (found != NULL) return; // must be exactly one.
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    38
			found = v;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6350
diff changeset
    42
	/* if we found a loco, */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
	if (found != NULL) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
		found = GetLastVehicleInChain(found);
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6350
diff changeset
    45
		/* put the new wagon at the end of the loco. */
3948
a09379beffd5 (svn r5094) Remove _new_{aircraft,roadveh,ship,train,wagon}_id. _new_vehicle_id is enough.
tron
parents: 3919
diff changeset
    46
		DoCommandP(0, _new_vehicle_id | (found->index << 16), 0, NULL, CMD_MOVE_RAIL_VEHICLE);
9297
1cb8d7bbdc8a (svn r13165) -Codechange: replace some RebuildXXXList/ResortXXXList+InvalidateWindowXXX with InvalidateWindowXXXData.
rubidium
parents: 9111
diff changeset
    47
		InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
    51
void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
{
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2630
diff changeset
    53
	if (!success) return;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    54
8850
415cd31f7e42 (svn r12605) -Cleanup: variable scope and coding style in train*
smatz
parents: 8828
diff changeset
    55
	const Vehicle *v = GetVehicle(_new_vehicle_id);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
	if (tile == _backup_orders_tile) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
		_backup_orders_tile = 0;
7653
dd252420d9c2 (svn r11184) -Codechange: cleanup the code related to backup orders.
rubidium
parents: 7530
diff changeset
    58
		RestoreVehicleOrders(v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
	}
7486
bf6a94009823 (svn r10997) -Codechange: unify the vehicle view window. Patch by PhilSophus.
rubidium
parents: 7484
diff changeset
    60
	ShowVehicleViewWindow(v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
2593
ccb101f0439c (svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
peter1138
parents: 2570
diff changeset
    63
/**
ccb101f0439c (svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
peter1138
parents: 2570
diff changeset
    64
 * Get the number of pixels for the given wagon length.
ccb101f0439c (svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
peter1138
parents: 2570
diff changeset
    65
 * @param len Length measured in 1/8ths of a standard wagon.
ccb101f0439c (svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
peter1138
parents: 2570
diff changeset
    66
 * @return Number of pixels across.
ccb101f0439c (svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
peter1138
parents: 2570
diff changeset
    67
 */
7321
f91bdca345e8 (svn r10684) -Codechange: some more coding style related changes. Primarily moving { to a new line.
rubidium
parents: 7266
diff changeset
    68
int WagonLengthToPixels(int len)
f91bdca345e8 (svn r10684) -Codechange: some more coding style related changes. Primarily moving { to a new line.
rubidium
parents: 7266
diff changeset
    69
{
3845
af6eb0103fed (svn r4869) - NewGRF: support setting train list vehicle width to 32 instead of 29 pixels, for sets which use 32 pixel long engines/wagons.
peter1138
parents: 3844
diff changeset
    70
	return (len * _traininfo_vehicle_width) / 8;
2593
ccb101f0439c (svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
peter1138
parents: 2570
diff changeset
    71
}
ccb101f0439c (svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
peter1138
parents: 2570
diff changeset
    72
8144
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8131
diff changeset
    73
void DrawTrainImage(const Vehicle *v, int x, int y, VehicleID selection, int count, int skip)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
{
3919
b64f70fcca85 (svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents: 3887
diff changeset
    75
	DrawPixelInfo tmp_dpi, *old_dpi;
b64f70fcca85 (svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents: 3887
diff changeset
    76
	int dx = -(skip * 8) / _traininfo_vehicle_width;
4049
d65bf8f154bc (svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents: 4041
diff changeset
    77
	/* Position of highlight box */
d65bf8f154bc (svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents: 4041
diff changeset
    78
	int highlight_l = 0;
d65bf8f154bc (svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents: 4041
diff changeset
    79
	int highlight_r = 0;
3919
b64f70fcca85 (svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents: 3887
diff changeset
    80
4429
b4eb6d97996f (svn r6184) Remove the unused (because it was NULL in all callers) second parameter of FillDrawPixelInfo() and simplify some expressions
tron
parents: 4426
diff changeset
    81
	if (!FillDrawPixelInfo(&tmp_dpi, x - 2, y - 1, count + 1, 14)) return;
3919
b64f70fcca85 (svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents: 3887
diff changeset
    82
b64f70fcca85 (svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents: 3887
diff changeset
    83
	count = (count * 8) / _traininfo_vehicle_width;
b64f70fcca85 (svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents: 3887
diff changeset
    84
b64f70fcca85 (svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents: 3887
diff changeset
    85
	old_dpi = _cur_dpi;
b64f70fcca85 (svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents: 3887
diff changeset
    86
	_cur_dpi = &tmp_dpi;
1922
bda6f85eefaa (svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents: 1908
diff changeset
    87
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
	do {
3919
b64f70fcca85 (svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents: 3887
diff changeset
    89
		int width = v->u.rail.cached_veh_length;
1922
bda6f85eefaa (svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents: 1908
diff changeset
    90
3919
b64f70fcca85 (svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents: 3887
diff changeset
    91
		if (dx + width > 0) {
b64f70fcca85 (svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents: 3887
diff changeset
    92
			if (dx <= count) {
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5601
diff changeset
    93
				SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
7134
5b2d47128d05 (svn r10408) -Codechange: make GetImage a class method of Vehicle instead of Get(Aircraft|RoadVeh|Ship|Train)Image.
rubidium
parents: 7063
diff changeset
    94
				DrawSprite(v->GetImage(DIR_W), pal, 16 + WagonLengthToPixels(dx), 7 + (is_custom_sprite(RailVehInfo(v->engine_type)->image_index) ? _traininfo_vehicle_pitch : 0));
4049
d65bf8f154bc (svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents: 4041
diff changeset
    95
				if (v->index == selection) {
d65bf8f154bc (svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents: 4041
diff changeset
    96
					/* Set the highlight position */
d65bf8f154bc (svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents: 4041
diff changeset
    97
					highlight_l = WagonLengthToPixels(dx) + 1;
d65bf8f154bc (svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents: 4041
diff changeset
    98
					highlight_r = WagonLengthToPixels(dx + width) + 1;
8828
28784a133c57 (svn r12576) -Feature(tte) [FS#337]: highlight vehicle chain when dragging in the group and depot GUI if appropriate
smatz
parents: 8786
diff changeset
    99
				} else if (_cursor.vehchain && highlight_r != 0) {
28784a133c57 (svn r12576) -Feature(tte) [FS#337]: highlight vehicle chain when dragging in the group and depot GUI if appropriate
smatz
parents: 8786
diff changeset
   100
					highlight_r += WagonLengthToPixels(width);
4049
d65bf8f154bc (svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents: 4041
diff changeset
   101
				}
1922
bda6f85eefaa (svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents: 1908
diff changeset
   102
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
		}
3919
b64f70fcca85 (svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents: 3887
diff changeset
   104
		dx += width;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
7492
35acee076719 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7488
diff changeset
   106
		v = v->Next();
3919
b64f70fcca85 (svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents: 3887
diff changeset
   107
	} while (dx < count && v != NULL);
b64f70fcca85 (svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents: 3887
diff changeset
   108
4049
d65bf8f154bc (svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents: 4041
diff changeset
   109
	if (highlight_l != highlight_r) {
d65bf8f154bc (svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents: 4041
diff changeset
   110
		/* Draw the highlight. Now done after drawing all the engines, as
d65bf8f154bc (svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents: 4041
diff changeset
   111
		 * the next engine after the highlight could overlap it. */
9770
8c260fb382f8 (svn r13907) -Codechange: Replace a number with Colours enum on DrawFrameRect usage
belugas
parents: 9413
diff changeset
   112
		DrawFrameRect(highlight_l, 0, highlight_r, 13, COLOUR_WHITE, FR_BORDERONLY);
4049
d65bf8f154bc (svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents: 4041
diff changeset
   113
	}
d65bf8f154bc (svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents: 4041
diff changeset
   114
3919
b64f70fcca85 (svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents: 3887
diff changeset
   115
	_cur_dpi = old_dpi;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
1790
47963a0cfca3 (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents: 1658
diff changeset
   118
static void TrainDetailsCargoTab(const Vehicle *v, int x, int y)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
{
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   120
	if (v->cargo_cap != 0) {
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   121
		StringID str = STR_8812_EMPTY;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
7010
6f0d9f03180d (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents: 7002
diff changeset
   123
		if (!v->cargo.Empty()) {
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   124
			SetDParam(0, v->cargo_type);
7010
6f0d9f03180d (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents: 7002
diff changeset
   125
			SetDParam(1, v->cargo.Count());
6f0d9f03180d (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents: 7002
diff changeset
   126
			SetDParam(2, v->cargo.Source());
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9354
diff changeset
   127
			SetDParam(3, _settings_game.vehicle.freight_trains);
5316
27fa85736f8a (svn r7473) -Fix (r7269): Pass a cargo type to determine the freight weight
peter1138
parents: 5273
diff changeset
   128
			str = FreightWagonMult(v->cargo_type) > 1 ? STR_FROM_MULT : STR_8813_FROM;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
		}
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7653
diff changeset
   130
		DrawString(x, y, str, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   132
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
1790
47963a0cfca3 (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents: 1658
diff changeset
   134
static void TrainDetailsInfoTab(const Vehicle *v, int x, int y)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
{
5868
94430141c189 (svn r8455) -Codechange: Give a more meaningful name (railveh_type)to member flags of RailVehInfo, as well as changing the code to reflect the fact that it was not a flag but rather a one value only variable. Doing so, some evaluations have been simplified.
belugas
parents: 5824
diff changeset
   136
	if (RailVehInfo(v->engine_type)->railveh_type == RAILVEH_WAGON) {
7059
c6d12e3de0dc (svn r10324) -Codechange: reference engine names by index
peter1138
parents: 7049
diff changeset
   137
		SetDParam(0, v->engine_type);
7002
1bf6a62b0fcb (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents: 6991
diff changeset
   138
		SetDParam(1, v->value);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7653
diff changeset
   139
		DrawString(x, y, STR_882D_VALUE, TC_BLACK);
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   140
	} else {
7059
c6d12e3de0dc (svn r10324) -Codechange: reference engine names by index
peter1138
parents: 7049
diff changeset
   141
		SetDParam(0, v->engine_type);
4329
0e6e689f66e7 (svn r6002) -Cleanup: remove the now redundant BASE_YEAR constant.
rubidium
parents: 4299
diff changeset
   142
		SetDParam(1, v->build_year);
7002
1bf6a62b0fcb (svn r10258) -Codechange: as we are now using int64 all over the place, it's better to use int64 variables in the string generating too instead of packing them into two int32s.
rubidium
parents: 6991
diff changeset
   143
		SetDParam(2, v->value);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7653
diff changeset
   144
		DrawString(x, y, STR_882C_BUILT_VALUE, TC_BLACK);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   145
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   146
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
1790
47963a0cfca3 (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents: 1658
diff changeset
   148
static void TrainDetailsCapacityTab(const Vehicle *v, int x, int y)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
	if (v->cargo_cap != 0) {
4896
f86350aaaaa5 (svn r6855) - Codechange: When displaying a "quantity of cargo" string, use the {CARGO} command and supply the cargo type and quantity, instead of manually looking up the cargo type's string.
peter1138
parents: 4871
diff changeset
   151
		SetDParam(0, v->cargo_type);
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   152
		SetDParam(1, v->cargo_cap);
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9354
diff changeset
   153
		SetDParam(2, _settings_game.vehicle.freight_trains);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7653
diff changeset
   154
		DrawString(x, y, FreightWagonMult(v->cargo_type) > 1 ? STR_CAPACITY_MULT : STR_013F_CAPACITY, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   155
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   157
7530
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   158
int GetTrainDetailsWndVScroll(VehicleID veh_id, byte det_tab)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
{
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   160
	AcceptedCargo act_cargo;
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   161
	AcceptedCargo max_cargo;
7530
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   162
	int num = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   164
	if (det_tab == 3) { // Total cargo tab
7530
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   165
		memset(max_cargo, 0, sizeof(max_cargo));
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   166
		memset(act_cargo, 0, sizeof(act_cargo));
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   167
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   168
		for (const Vehicle *v = GetVehicle(veh_id) ; v != NULL ; v = v->Next()) {
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   169
			act_cargo[v->cargo_type] += v->cargo.Count();
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   170
			max_cargo[v->cargo_type] += v->cargo_cap;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   171
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   172
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   173
		/* Set scroll-amount seperately from counting, as to not compute num double
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   174
		 * for more carriages of the same type
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   175
		 */
6350
04b19f551aec (svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138
parents: 6259
diff changeset
   176
		for (CargoID i = 0; i < NUM_CARGO; i++) {
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   177
			if (max_cargo[i] > 0) num++; // only count carriages that the train has
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   178
		}
4434
a08cb4b5c179 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4429
diff changeset
   179
		num++; // needs one more because first line is description string
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   180
	} else {
7530
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   181
		for (const Vehicle *v = GetVehicle(veh_id) ; v != NULL ; v = v->Next()) {
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   182
			if (!IsArticulatedPart(v) || v->cargo_cap != 0) num++;
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   183
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
7530
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   186
	return num;
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   187
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
7530
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   189
void DrawTrainDetails(const Vehicle *v, int x, int y, int vscroll_pos, uint16 vscroll_cap, byte det_tab)
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   190
{
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6350
diff changeset
   191
	/* draw the first 3 details tabs */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   192
	if (det_tab != 3) {
7530
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   193
		const Vehicle *u = v;
2822
3685b5c83c57 (svn r3370) Improve alignment of text within total cargo tab of train view window
peter1138
parents: 2819
diff changeset
   194
		x = 1;
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2951
diff changeset
   195
		for (;;) {
7530
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   196
			if (--vscroll_pos < 0 && vscroll_pos >= -vscroll_cap) {
2602
1a6561c9a408 (svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
peter1138
parents: 2593
diff changeset
   197
				int dx = 0;
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   198
2602
1a6561c9a408 (svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
peter1138
parents: 2593
diff changeset
   199
				u = v;
1a6561c9a408 (svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
peter1138
parents: 2593
diff changeset
   200
				do {
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5601
diff changeset
   201
					SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
7134
5b2d47128d05 (svn r10408) -Codechange: make GetImage a class method of Vehicle instead of Get(Aircraft|RoadVeh|Ship|Train)Image.
rubidium
parents: 7063
diff changeset
   202
					DrawSprite(u->GetImage(DIR_W), pal, x + WagonLengthToPixels(4 + dx), y + 6 + (is_custom_sprite(RailVehInfo(u->engine_type)->image_index) ? _traininfo_vehicle_pitch : 0));
2602
1a6561c9a408 (svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
peter1138
parents: 2593
diff changeset
   203
					dx += u->u.rail.cached_veh_length;
7492
35acee076719 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7488
diff changeset
   204
					u = u->Next();
4868
846811004d30 (svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents: 4836
diff changeset
   205
				} while (u != NULL && IsArticulatedPart(u) && u->cargo_cap == 0);
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   206
8850
415cd31f7e42 (svn r12605) -Cleanup: variable scope and coding style in train*
smatz
parents: 8828
diff changeset
   207
				int px = x + WagonLengthToPixels(dx) + 2;
415cd31f7e42 (svn r12605) -Cleanup: variable scope and coding style in train*
smatz
parents: 8828
diff changeset
   208
				int py = y + 2;
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   209
				switch (det_tab) {
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   210
					default: NOT_REACHED();
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   211
					case 0: TrainDetailsCargoTab(   v, px, py); break;
4868
846811004d30 (svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents: 4836
diff changeset
   212
					case 1:
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6350
diff changeset
   213
						/* Only show name and value for the 'real' part */
4868
846811004d30 (svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents: 4836
diff changeset
   214
						if (!IsArticulatedPart(v)) {
846811004d30 (svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents: 4836
diff changeset
   215
							TrainDetailsInfoTab(v, px, py);
846811004d30 (svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents: 4836
diff changeset
   216
						}
846811004d30 (svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents: 4836
diff changeset
   217
						break;
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   218
					case 2: TrainDetailsCapacityTab(v, px, py); break;
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   219
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   220
				y += 14;
4868
846811004d30 (svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents: 4836
diff changeset
   221
846811004d30 (svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents: 4836
diff changeset
   222
				v = u;
846811004d30 (svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents: 4836
diff changeset
   223
			} else {
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6350
diff changeset
   224
				/* Move to the next line */
4868
846811004d30 (svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents: 4836
diff changeset
   225
				do {
7492
35acee076719 (svn r11003) -Codechange: replace Vehicle->next to Vehicle->Next() and Vehicle->SetNext() so we can trap instances that change a next pointer and (in the future) update the first/previous pointers based on that.
rubidium
parents: 7488
diff changeset
   226
					v = v->Next();
4868
846811004d30 (svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents: 4836
diff changeset
   227
				} while (v != NULL && IsArticulatedPart(v) && v->cargo_cap == 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   228
			}
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   229
			if (v == NULL) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   230
		}
2959
0a9e35c5d7a3 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   231
	} else {
7530
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   232
		AcceptedCargo act_cargo;
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   233
		AcceptedCargo max_cargo;
9943
ccea23aec951 (svn r14098) -Fix: Make the 'Transfer Credit' display aware of the entire consist, not only the first vehicle
celestar
parents: 9770
diff changeset
   234
		Money         feeder_share = 0;
7530
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   235
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   236
		memset(max_cargo, 0, sizeof(max_cargo));
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   237
		memset(act_cargo, 0, sizeof(act_cargo));
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   238
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   239
		for (const Vehicle *u = v; u != NULL ; u = u->Next()) {
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   240
			act_cargo[u->cargo_type] += u->cargo.Count();
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   241
			max_cargo[u->cargo_type] += u->cargo_cap;
9943
ccea23aec951 (svn r14098) -Fix: Make the 'Transfer Credit' display aware of the entire consist, not only the first vehicle
celestar
parents: 9770
diff changeset
   242
			feeder_share             += u->cargo.FeederShare();
7530
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   243
		}
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   244
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6350
diff changeset
   245
		/* draw total cargo tab */
8424
c3477565c975 (svn r11994) -Codechange: Remove numbers from string names where the strings aren't present in TTD, since they don't correspond to either TTD's TextIDs or OpenTTD's StringIDs.
maedhros
parents: 8264
diff changeset
   246
		DrawString(x, y + 2, STR_TOTAL_CAPACITY_TEXT, TC_FROMSTRING);
6350
04b19f551aec (svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138
parents: 6259
diff changeset
   247
		for (CargoID i = 0; i < NUM_CARGO; i++) {
7530
bfeada535347 (svn r11049) -Codechange: unify a large part of the vehicle details window. Based on a patch by nycom.
rubidium
parents: 7492
diff changeset
   248
			if (max_cargo[i] > 0 && --vscroll_pos < 0 && vscroll_pos > -vscroll_cap) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   249
				y += 14;
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   250
				SetDParam(0, i);            // {CARGO} #1
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   251
				SetDParam(1, act_cargo[i]); // {CARGO} #2
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   252
				SetDParam(2, i);            // {SHORTCARGO} #1
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   253
				SetDParam(3, max_cargo[i]); // {SHORTCARGO} #2
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9354
diff changeset
   254
				SetDParam(4, _settings_game.vehicle.freight_trains);
8424
c3477565c975 (svn r11994) -Codechange: Remove numbers from string names where the strings aren't present in TTD, since they don't correspond to either TTD's TextIDs or OpenTTD's StringIDs.
maedhros
parents: 8264
diff changeset
   255
				DrawString(x, y + 2, FreightWagonMult(i) > 1 ? STR_TOTAL_CAPACITY_MULT : STR_TOTAL_CAPACITY, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   256
			}
2959
0a9e35c5d7a3 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   257
		}
9943
ccea23aec951 (svn r14098) -Fix: Make the 'Transfer Credit' display aware of the entire consist, not only the first vehicle
celestar
parents: 9770
diff changeset
   258
		SetDParam(0, feeder_share);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7653
diff changeset
   259
		DrawString(x, y + 15, STR_FEEDER_CARGO_VALUE, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   260
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   261
}