src/train_gui.cpp
author rubidium
Wed, 29 Aug 2007 20:50:58 +0000
changeset 7486 bf6a94009823
parent 7484 7734e4119e70
child 7488 6f51ddf4c225
permissions -rw-r--r--
(svn r10997) -Codechange: unify the vehicle view window. Patch by PhilSophus.
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
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6350
diff changeset
     3
/** @file train_gui.cpp */
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"
2163
b17b313113a0 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2147
diff changeset
     8
#include "functions.h"
1922
bda6f85eefaa (svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents: 1908
diff changeset
     9
#include "table/sprites.h"
507
04b5403aaf6b (svn r815) Include strings.h only in the files which need it.
tron
parents: 460
diff changeset
    10
#include "table/strings.h"
7266
b16e67e992b4 (svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents: 7134
diff changeset
    11
#include "strings.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
#include "window.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
#include "gui.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
#include "vehicle.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
#include "viewport.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
#include "command.h"
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 573
diff changeset
    17
#include "vehicle_gui.h"
1313
f1013ec3d318 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents: 1299
diff changeset
    18
#include "depot.h"
2676
59b65b4fb480 (svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents: 2639
diff changeset
    19
#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
    20
#include "newgrf_engine.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    21
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
    22
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
    23
{
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4088
diff changeset
    24
	Vehicle *v, *found;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    25
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4049
diff changeset
    26
	if (!success) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    27
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6350
diff changeset
    28
	/* find a locomotive in the depot. */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    29
	found = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    30
	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
    31
		if (v->type == VEH_TRAIN && IsFrontEngine(v) &&
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
				v->tile == tile &&
5993
956d341d930e (svn r8701) -Codechange: replace magic numbers with enums for u.rail.track.
rubidium
parents: 5893
diff changeset
    33
				v->u.rail.track == TRACK_BIT_DEPOT) {
4077
d4d440dd8925 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4049
diff changeset
    34
			if (found != NULL) return; // must be exactly one.
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
			found = v;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    36
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    38
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6350
diff changeset
    39
	/* if we found a loco, */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
	if (found != NULL) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
		found = GetLastVehicleInChain(found);
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6350
diff changeset
    42
		/* 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
    43
		DoCommandP(0, _new_vehicle_id | (found->index << 16), 0, NULL, CMD_MOVE_RAIL_VEHICLE);
588
03521b270f62 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 573
diff changeset
    44
		RebuildVehicleLists();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
1977
37bbebf94434 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
    48
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
    49
{
4171
5c6e60c392c3 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4088
diff changeset
    50
	const Vehicle *v;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2630
diff changeset
    52
	if (!success) return;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    53
3948
a09379beffd5 (svn r5094) Remove _new_{aircraft,roadveh,ship,train,wagon}_id. _new_vehicle_id is enough.
tron
parents: 3919
diff changeset
    54
	v = GetVehicle(_new_vehicle_id);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
	if (tile == _backup_orders_tile) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
		_backup_orders_tile = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
		RestoreVehicleOrders(v, _backup_orders_data);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
	}
7486
bf6a94009823 (svn r10997) -Codechange: unify the vehicle view window. Patch by PhilSophus.
rubidium
parents: 7484
diff changeset
    59
	ShowVehicleViewWindow(v);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
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
    62
/**
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
 * 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
    64
 * @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
    65
 * @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
    66
 */
7321
f91bdca345e8 (svn r10684) -Codechange: some more coding style related changes. Primarily moving { to a new line.
rubidium
parents: 7266
diff changeset
    67
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
    68
{
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
    69
	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
    70
}
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
4442
9f8bb348d58f (svn r6215) -Codechange: [vehicle list windows] unified Player(vehicle)WndProc into PlayerVehWndProc
bjarni
parents: 4434
diff changeset
    72
void DrawTrainImage(const Vehicle *v, int x, int y, int count, int skip, VehicleID selection)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    73
{
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
    74
	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
    75
	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
    76
	/* 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
    77
	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
    78
	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
    79
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
    80
	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
    81
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
	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
    83
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
	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
    85
	_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
    86
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
	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
    88
		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
    89
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
    90
		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
    91
			if (dx <= count) {
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5601
diff changeset
    92
				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
    93
				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
    94
				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
    95
					/* 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
    96
					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
    97
					highlight_r = WagonLengthToPixels(dx + width) + 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
				}
1922
bda6f85eefaa (svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents: 1908
diff changeset
    99
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
		}
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
   101
		dx += width;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
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
   103
		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
   104
	} 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
   105
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
   106
	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
   107
		/* 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
   108
		 * the next engine after the highlight could overlap it. */
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
		DrawFrameRect(highlight_l, 0, highlight_r, 13, 15, FR_BORDERONLY);
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
	}
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
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
   112
	_cur_dpi = old_dpi;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
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
   115
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
   116
{
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   117
	if (v->cargo_cap != 0) {
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   118
		StringID str = STR_8812_EMPTY;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
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
   120
		if (!v->cargo.Empty()) {
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   121
			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
   122
			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
   123
			SetDParam(2, v->cargo.Source());
5163
459b243f8413 (svn r7269) -Feature: Add freight trains patch option. This option is a multiplier for the weight of cargo on freight trains, to simulate longer heavier trains. The default value of 1 behaves as before.
peter1138
parents: 5124
diff changeset
   124
			SetDParam(3, _patches.freight_trains);
5316
27fa85736f8a (svn r7473) -Fix (r7269): Pass a cargo type to determine the freight weight
peter1138
parents: 5273
diff changeset
   125
			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
   126
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
		DrawString(x, y, str, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   130
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
   131
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
   132
{
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
   133
	if (RailVehInfo(v->engine_type)->railveh_type == RAILVEH_WAGON) {
7059
c6d12e3de0dc (svn r10324) -Codechange: reference engine names by index
peter1138
parents: 7049
diff changeset
   134
		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
   135
		SetDParam(1, v->value);
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   136
		DrawString(x, y, STR_882D_VALUE, 0x10);
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   137
	} else {
7059
c6d12e3de0dc (svn r10324) -Codechange: reference engine names by index
peter1138
parents: 7049
diff changeset
   138
		SetDParam(0, v->engine_type);
4329
0e6e689f66e7 (svn r6002) -Cleanup: remove the now redundant BASE_YEAR constant.
rubidium
parents: 4299
diff changeset
   139
		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
   140
		SetDParam(2, v->value);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   141
		DrawString(x, y, STR_882C_BUILT_VALUE, 0x10);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   142
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   144
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
   145
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
   146
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
	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
   148
		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
   149
		SetDParam(1, v->cargo_cap);
5163
459b243f8413 (svn r7269) -Feature: Add freight trains patch option. This option is a multiplier for the weight of cargo on freight trains, to simulate longer heavier trains. The default value of 1 behaves as before.
peter1138
parents: 5124
diff changeset
   150
		SetDParam(2, _patches.freight_trains);
5316
27fa85736f8a (svn r7473) -Fix (r7269): Pass a cargo type to determine the freight weight
peter1138
parents: 5273
diff changeset
   151
		DrawString(x, y, FreightWagonMult(v->cargo_type) > 1 ? STR_CAPACITY_MULT : STR_013F_CAPACITY, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   152
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   153
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
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
static void DrawTrainDetailsWindow(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   157
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
	byte det_tab = WP(w, traindetails_d).tab;
5187
12dc9dfa6af6 (svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents: 5163
diff changeset
   159
	const Vehicle *v;
12dc9dfa6af6 (svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents: 5163
diff changeset
   160
	const Vehicle *u;
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   161
	AcceptedCargo act_cargo;
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   162
	AcceptedCargo max_cargo;
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   163
	int num;
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   164
	int x;
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   165
	int y;
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   166
	int sel;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
	num = 0;
919
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 914
diff changeset
   169
	u = v = GetVehicle(w->window_number);
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   170
	if (det_tab == 3) { // Total cargo tab
6350
04b19f551aec (svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138
parents: 6259
diff changeset
   171
		for (CargoID i = 0; i < lengthof(act_cargo); i++) {
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   172
			act_cargo[i] = 0;
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   173
			max_cargo[i] = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   174
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   176
		do {
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
   177
			act_cargo[u->cargo_type] += u->cargo.Count();
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   178
			max_cargo[u->cargo_type] += u->cargo_cap;
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
   179
		} while ((u = u->next) != NULL);
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   180
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   181
		/* 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
   182
		 * for more carriages of the same type
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   183
		 */
6350
04b19f551aec (svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138
parents: 6259
diff changeset
   184
		for (CargoID i = 0; i < NUM_CARGO; i++) {
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   185
			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
   186
		}
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
   187
		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
   188
	} else {
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   189
		do {
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
   190
			if (!IsArticulatedPart(u) || u->cargo_cap != 0) num++;
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
   191
		} while ((u = u->next) != NULL);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   192
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   193
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   194
	SetVScrollCount(w, num);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   195
4709
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   196
	DisableWindowWidget(w, det_tab + 9);
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   197
	SetWindowWidgetDisabledState(w, 2, v->owner != _local_player);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   198
4709
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   199
	/* disable service-scroller when interval is set to disabled */
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   200
	SetWindowWidgetDisabledState(w, 6, !_patches.servint_trains);
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   201
	SetWindowWidgetDisabledState(w, 7, !_patches.servint_trains);
156
8fef5e5752d6 (svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents: 22
diff changeset
   202
7049
0ebe47348074 (svn r10314) -Codechange: Refer to vehicle names by index
peter1138
parents: 7010
diff changeset
   203
	SetDParam(0, v->index);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
	DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   205
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   206
	SetDParam(1, v->age / 366);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   207
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
	x = 2;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   209
2252
6df2bfd7a077 (svn r2772) Simplify the age notice in the vehicle details window
tron
parents: 2244
diff changeset
   210
	SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED);
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   211
	SetDParam(2, v->max_age / 366);
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
   212
	SetDParam(3, GetTrainRunningCost(v) >> 8);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   213
	DrawString(x, 15, STR_885D_AGE_RUNNING_COST_YR, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   214
7484
7734e4119e70 (svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
rubidium
parents: 7478
diff changeset
   215
	SetDParam(2, v->GetDisplayMaxSpeed());
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   216
	SetDParam(1, v->u.rail.cached_power);
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   217
	SetDParam(0, v->u.rail.cached_weight);
5400
bba42ad3223b (svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents: 5316
diff changeset
   218
	SetDParam(3, v->u.rail.cached_max_te / 1000);
bba42ad3223b (svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents: 5316
diff changeset
   219
	DrawString(x, 25, (_patches.realistic_acceleration && v->u.rail.railtype != RAILTYPE_MAGLEV) ?
bba42ad3223b (svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents: 5316
diff changeset
   220
		STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE :
bba42ad3223b (svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents: 5316
diff changeset
   221
		STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
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
   223
	SetDParam(0, v->profit_this_year);
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
   224
	SetDParam(1, v->profit_last_year);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   225
	DrawString(x, 35, STR_885F_PROFIT_THIS_YEAR_LAST_YEAR, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   226
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   227
	SetDParam(0, 100 * (v->reliability>>8) >> 8);
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   228
	SetDParam(1, v->breakdowns_since_last_service);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   229
	DrawString(x, 45, STR_8860_RELIABILITY_BREAKDOWNS, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   230
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   231
	SetDParam(0, v->service_interval);
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   232
	SetDParam(1, v->date_of_last_service);
2959
0a9e35c5d7a3 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   233
	DrawString(x + 11, 57 + (w->vscroll.cap * 14), _patches.servint_ispercent ? STR_SERVICING_INTERVAL_PERCENT : STR_883C_SERVICING_INTERVAL_DAYS, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   234
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
	y = 57;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   236
	sel = w->vscroll.pos;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   237
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6350
diff changeset
   238
	/* draw the first 3 details tabs */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   239
	if (det_tab != 3) {
2822
3685b5c83c57 (svn r3370) Improve alignment of text within total cargo tab of train view window
peter1138
parents: 2819
diff changeset
   240
		x = 1;
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2951
diff changeset
   241
		for (;;) {
2959
0a9e35c5d7a3 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   242
			if (--sel < 0 && sel >= -w->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
   243
				int dx = 0;
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   244
				int px;
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   245
				int py;
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   246
2602
1a6561c9a408 (svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
peter1138
parents: 2593
diff changeset
   247
				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
   248
				do {
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5601
diff changeset
   249
					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
   250
					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
   251
					dx += u->u.rail.cached_veh_length;
1a6561c9a408 (svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
peter1138
parents: 2593
diff changeset
   252
					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
   253
				} 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
   254
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   255
				px = x + WagonLengthToPixels(dx) + 2;
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   256
				py = y + 2;
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   257
				switch (det_tab) {
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   258
					default: NOT_REACHED();
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   259
					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
   260
					case 1:
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6350
diff changeset
   261
						/* 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
   262
						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
   263
							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
   264
						}
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
   265
						break;
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   266
					case 2: TrainDetailsCapacityTab(v, px, py); break;
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   267
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
				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
   269
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
   270
				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
   271
			} else {
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6350
diff changeset
   272
				/* 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
   273
				do {
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
   274
					v = v->next;
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
   275
				} 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
   276
			}
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   277
			if (v == NULL) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   278
		}
2959
0a9e35c5d7a3 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   279
	} else {
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6350
diff changeset
   280
		/* draw total cargo tab */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
		DrawString(x, y + 2, STR_013F_TOTAL_CAPACITY_TEXT, 0);
6350
04b19f551aec (svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138
parents: 6259
diff changeset
   282
		for (CargoID i = 0; i < NUM_CARGO; i++) {
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   283
			if (max_cargo[i] > 0 && --sel < 0 && sel > -w->vscroll.cap) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   284
				y += 14;
4492
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   285
				SetDParam(0, i);            // {CARGO} #1
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   286
				SetDParam(1, act_cargo[i]); // {CARGO} #2
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   287
				SetDParam(2, i);            // {SHORTCARGO} #1
7c67249f083c (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   288
				SetDParam(3, max_cargo[i]); // {SHORTCARGO} #2
5163
459b243f8413 (svn r7269) -Feature: Add freight trains patch option. This option is a multiplier for the weight of cargo on freight trains, to simulate longer heavier trains. The default value of 1 behaves as before.
peter1138
parents: 5124
diff changeset
   289
				SetDParam(4, _patches.freight_trains);
5316
27fa85736f8a (svn r7473) -Fix (r7269): Pass a cargo type to determine the freight weight
peter1138
parents: 5273
diff changeset
   290
				DrawString(x, y + 2, FreightWagonMult(i) > 1 ? STR_TOTAL_CAPACITY_MULT : STR_013F_TOTAL_CAPACITY, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
			}
2959
0a9e35c5d7a3 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   292
		}
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
   293
		SetDParam(0, v->cargo.FeederShare());
6198
5e278ec7c0f9 (svn r8978) -Feature: Rewrite of transfer system.
richk
parents: 5993
diff changeset
   294
		DrawString(x, y + 15, STR_FEEDER_CARGO_VALUE, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   295
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   297
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
static void TrainDetailsWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   299
{
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
   300
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   301
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   302
		DrawTrainDetailsWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   303
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   304
	case WE_CLICK: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
		int mod;
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
   306
		const Vehicle *v;
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4633
diff changeset
   307
		switch (e->we.click.widget) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   308
		case 2: /* name train */
919
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 914
diff changeset
   309
			v = GetVehicle(w->window_number);
7049
0ebe47348074 (svn r10314) -Codechange: Refer to vehicle names by index
peter1138
parents: 7010
diff changeset
   310
			SetDParam(0, v->index);
0ebe47348074 (svn r10314) -Codechange: Refer to vehicle names by index
peter1138
parents: 7010
diff changeset
   311
			ShowQueryString(STR_VEHICLE_NAME, STR_8865_NAME_TRAIN, 31, 150, w, CS_ALPHANUMERAL);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   312
			break;
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
   313
		case 6: /* inc serv interval */
156
8fef5e5752d6 (svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents: 22
diff changeset
   314
			mod = _ctrl_pressed? 5 : 10;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
			goto do_change_service_int;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   317
		case 7: /* dec serv interval */
156
8fef5e5752d6 (svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents: 22
diff changeset
   318
			mod = _ctrl_pressed? -5 : -10;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   319
do_change_service_int:
919
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 914
diff changeset
   320
			v = GetVehicle(w->window_number);
156
8fef5e5752d6 (svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents: 22
diff changeset
   321
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
   322
			mod = GetServiceIntervalClamped(mod + v->service_interval);
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
   323
			if (mod == v->service_interval) return;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   324
2819
f25fb6ee397f (svn r3367) Unify the 4 distinct CMD_CHANGE_{AIRCRAFT,ROADVEH,SHIP,TRAIN}_SERVICE_INT commands into one CMD_CHANGE_SERVICE_INT command.
tron
parents: 2806
diff changeset
   325
			DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   326
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   327
		/* details buttons*/
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
   328
		case 9:  // Cargo
a08cb4b5c179 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4429
diff changeset
   329
		case 10: // Information
a08cb4b5c179 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4429
diff changeset
   330
		case 11: // Capacities
a08cb4b5c179 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4429
diff changeset
   331
		case 12: // Total cargo
4709
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   332
			EnableWindowWidget(w,  9);
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   333
			EnableWindowWidget(w, 10);
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   334
			EnableWindowWidget(w, 11);
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   335
			EnableWindowWidget(w, 12);
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   336
			EnableWindowWidget(w, e->we.click.widget);
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4633
diff changeset
   337
			WP(w,traindetails_d).tab = e->we.click.widget - 9;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   338
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   339
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   340
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   341
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   342
2548
49c8a096033f (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2520
diff changeset
   343
	case WE_ON_EDIT_TEXT:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4633
diff changeset
   344
		if (e->we.edittext.str[0] != '\0') {
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4633
diff changeset
   345
			_cmd_text = e->we.edittext.str;
1820
d03c56850dc2 (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents: 1802
diff changeset
   346
			DoCommandP(0, w->window_number, 0, NULL,
d03c56850dc2 (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents: 1802
diff changeset
   347
				CMD_NAME_VEHICLE | CMD_MSG(STR_8866_CAN_T_NAME_TRAIN));
d03c56850dc2 (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents: 1802
diff changeset
   348
		}
2548
49c8a096033f (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2520
diff changeset
   349
		break;
2959
0a9e35c5d7a3 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   350
0a9e35c5d7a3 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   351
	case WE_RESIZE:
5824
8398b44ad3bc (svn r8390) -Codechange (r8384): Rewrote ResizeButtons()
bjarni
parents: 5822
diff changeset
   352
		if (e->we.sizing.diff.x != 0) ResizeButtons(w, 9, 12);
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4633
diff changeset
   353
		if (e->we.sizing.diff.y == 0) break;
2959
0a9e35c5d7a3 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   354
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4633
diff changeset
   355
		w->vscroll.cap += e->we.sizing.diff.y / 14;
4547
d37c2d172ad4 (svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents: 4541
diff changeset
   356
		w->widget[4].data = (w->vscroll.cap << 8) + 1;
2959
0a9e35c5d7a3 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   357
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   358
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   359
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   360
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
static const Widget _train_details_widgets[] = {
2959
0a9e35c5d7a3 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   362
{   WWT_CLOSEBOX, RESIZE_NONE,   14,   0,  10,   0,  13, STR_00C5,             STR_018B_CLOSE_WINDOW},
5821
31fa8234ebc6 (svn r8383) -Feature: train detail window is now resizable horizontally (requested by Wolf01)
bjarni
parents: 5779
diff changeset
   363
{    WWT_CAPTION, RESIZE_RIGHT,  14,  11, 329,   0,  13, STR_8802_DETAILS,     STR_018C_WINDOW_TITLE_DRAG_THIS},
31fa8234ebc6 (svn r8383) -Feature: train detail window is now resizable horizontally (requested by Wolf01)
bjarni
parents: 5779
diff changeset
   364
{ WWT_PUSHTXTBTN, RESIZE_LR,     14, 330, 369,   0,  13, STR_01AA_NAME,        STR_8867_NAME_TRAIN},
31fa8234ebc6 (svn r8383) -Feature: train detail window is now resizable horizontally (requested by Wolf01)
bjarni
parents: 5779
diff changeset
   365
{      WWT_PANEL, RESIZE_RIGHT,  14,   0, 369,  14,  55, 0x0,                  STR_NULL},
31fa8234ebc6 (svn r8383) -Feature: train detail window is now resizable horizontally (requested by Wolf01)
bjarni
parents: 5779
diff changeset
   366
{     WWT_MATRIX, RESIZE_RB,     14,   0, 357,  56, 139, 0x601,                STR_NULL},
31fa8234ebc6 (svn r8383) -Feature: train detail window is now resizable horizontally (requested by Wolf01)
bjarni
parents: 5779
diff changeset
   367
{  WWT_SCROLLBAR, RESIZE_LRB,    14, 358, 369,  56, 139, 0x0,                  STR_0190_SCROLL_BAR_SCROLLS_LIST},
2959
0a9e35c5d7a3 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   368
{ WWT_PUSHTXTBTN, RESIZE_TB,     14,   0,  10, 140, 145, STR_0188,             STR_884D_INCREASE_SERVICING_INTERVAL},
0a9e35c5d7a3 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   369
{ WWT_PUSHTXTBTN, RESIZE_TB,     14,   0,  10, 146, 151, STR_0189,             STR_884E_DECREASE_SERVICING_INTERVAL},
5821
31fa8234ebc6 (svn r8383) -Feature: train detail window is now resizable horizontally (requested by Wolf01)
bjarni
parents: 5779
diff changeset
   370
{      WWT_PANEL, RESIZE_RTB,    14,  11, 369, 140, 151, 0x0,                  STR_NULL},
2959
0a9e35c5d7a3 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   371
{ WWT_PUSHTXTBTN, RESIZE_TB,     14,   0,  89, 152, 163, STR_013C_CARGO,       STR_884F_SHOW_DETAILS_OF_CARGO_CARRIED},
0a9e35c5d7a3 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   372
{ WWT_PUSHTXTBTN, RESIZE_TB,     14,  90, 178, 152, 163, STR_013D_INFORMATION, STR_8850_SHOW_DETAILS_OF_TRAIN_VEHICLES},
0a9e35c5d7a3 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   373
{ WWT_PUSHTXTBTN, RESIZE_TB,     14, 179, 268, 152, 163, STR_013E_CAPACITIES,  STR_8851_SHOW_CAPACITIES_OF_EACH},
5824
8398b44ad3bc (svn r8390) -Codechange (r8384): Rewrote ResizeButtons()
bjarni
parents: 5822
diff changeset
   374
{ WWT_PUSHTXTBTN, RESIZE_RTB,    14, 269, 357, 152, 163, STR_013E_TOTAL_CARGO, STR_8852_SHOW_TOTAL_CARGO},
5821
31fa8234ebc6 (svn r8383) -Feature: train detail window is now resizable horizontally (requested by Wolf01)
bjarni
parents: 5779
diff changeset
   375
{  WWT_RESIZEBOX, RESIZE_LRTB,   14, 358, 369, 152, 163, 0x0,                  STR_RESIZE_BUTTON},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 174
diff changeset
   376
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   377
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   378
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   379
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   380
static const WindowDesc _train_details_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7321
diff changeset
   381
	WDP_AUTO, WDP_AUTO, 370, 164, 370, 164,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   382
	WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW,
2959
0a9e35c5d7a3 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   383
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   384
	_train_details_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   385
	TrainDetailsWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   386
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   387
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   388
7486
bf6a94009823 (svn r10997) -Codechange: unify the vehicle view window. Patch by PhilSophus.
rubidium
parents: 7484
diff changeset
   389
void ShowTrainDetailsWindow(const Vehicle *v)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   390
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   391
	Window *w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   392
	VehicleID veh = v->index;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   393
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   394
	DeleteWindowById(WC_VEHICLE_ORDERS, veh);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   395
	DeleteWindowById(WC_VEHICLE_DETAILS, veh);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   396
5071
e28106dfcb6f (svn r7129) -Codechange: Get rid of a global variable that only sets a window's number.
Darkvater
parents: 5070
diff changeset
   397
	w = AllocateWindowDescFront(&_train_details_desc, veh);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   398
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   399
	w->caption_color = v->owner;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   400
	w->vscroll.cap = 6;
4547
d37c2d172ad4 (svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents: 4541
diff changeset
   401
	w->widget[4].data = (w->vscroll.cap << 8) + 1;
2959
0a9e35c5d7a3 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   402
0a9e35c5d7a3 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   403
	w->resize.step_height = 14;
0a9e35c5d7a3 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   404
	w->resize.height = w->height - 14 * 2; /* Minimum of 4 wagons in the display */
0a9e35c5d7a3 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   405
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   406
	WP(w,traindetails_d).tab = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   407
}