src/train_gui.cpp
author rubidium
Sun, 26 Aug 2007 21:21:59 +0000
changeset 7974 6fcdebd75c19
parent 7973 ce69b7781d4a
child 7980 9b12784cc39c
permissions -rw-r--r--
(svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
6918
5589c415e28f (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6676
diff changeset
     3
/** @file train_gui.cpp */
5589c415e28f (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6676
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1820
diff changeset
     6
#include "openttd.h"
1299
0a6510cc889b (svn r1803) Move debugging stuff into files of it's own
tron
parents: 1294
diff changeset
     7
#include "debug.h"
2163
637ec3c361f5 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2147
diff changeset
     8
#include "functions.h"
1922
797081e56d13 (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
8aa8100b0b22 (svn r815) Include strings.h only in the files which need it.
tron
parents: 460
diff changeset
    10
#include "table/strings.h"
7762
03721db0ac1c (svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents: 7630
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
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 573
diff changeset
    17
#include "vehicle_gui.h"
1313
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents: 1299
diff changeset
    18
#include "depot.h"
2676
2ba71e034d97 (svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents: 2639
diff changeset
    19
#include "train.h"
2962
dbd168a4703a (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
4392ae3d8e31 (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
3fadda3afe70 (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
d3022f976946 (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
6918
5589c415e28f (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6676
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) {
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6524
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 &&
6319
27e68b914d3d (svn r8701) -Codechange: replace magic numbers with enums for u.rail.track.
rubidium
parents: 6144
diff changeset
    33
				v->u.rail.track == TRACK_BIT_DEPOT) {
4077
d3022f976946 (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
6918
5589c415e28f (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6676
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);
6918
5589c415e28f (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6676
diff changeset
    42
		/* put the new wagon at the end of the loco. */
3948
95f9fa0ac551 (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
1b60458bdc29 (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
4392ae3d8e31 (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
3fadda3afe70 (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
8a7342eb3a78 (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
95f9fa0ac551 (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
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
	ShowTrainViewWindow(v);
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
a9f7d3d70639 (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
/**
a9f7d3d70639 (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.
a9f7d3d70639 (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.
a9f7d3d70639 (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.
a9f7d3d70639 (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
 */
7817
f24498d934ac (svn r10684) -Codechange: some more coding style related changes. Primarily moving { to a new line.
rubidium
parents: 7762
diff changeset
    67
int WagonLengthToPixels(int len)
f24498d934ac (svn r10684) -Codechange: some more coding style related changes. Primarily moving { to a new line.
rubidium
parents: 7762
diff changeset
    68
{
3845
c3cd4b825c2f (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
a9f7d3d70639 (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
}
a9f7d3d70639 (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
8d8d0c2df7cb (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
1ba6c2e9b46d (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;
1ba6c2e9b46d (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
dd384acac472 (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 */
dd384acac472 (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;
dd384acac472 (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
1ba6c2e9b46d (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
1bb01569940c (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
1ba6c2e9b46d (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
1ba6c2e9b46d (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;
1ba6c2e9b46d (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
1ba6c2e9b46d (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;
1ba6c2e9b46d (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
797081e56d13 (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
1ba6c2e9b46d (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
797081e56d13 (svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents: 1908
diff changeset
    89
3919
1ba6c2e9b46d (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) {
1ba6c2e9b46d (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) {
5919
2b58160d667d (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5852
diff changeset
    92
				SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
7630
2cd754d7dfa4 (svn r10408) -Codechange: make GetImage a class method of Vehicle instead of Get(Aircraft|RoadVeh|Ship|Train)Image.
rubidium
parents: 7559
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
dd384acac472 (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) {
dd384acac472 (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 */
dd384acac472 (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;
dd384acac472 (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;
dd384acac472 (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
797081e56d13 (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
1ba6c2e9b46d (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
a9f7d3d70639 (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
1ba6c2e9b46d (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);
1ba6c2e9b46d (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
dd384acac472 (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) {
dd384acac472 (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
dd384acac472 (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. */
dd384acac472 (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);
dd384acac472 (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
	}
dd384acac472 (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
1ba6c2e9b46d (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
2275
cbaeb07740b1 (svn r2799) Make the only two non-const widget lists const
tron
parents: 2261
diff changeset
   115
static const Widget _train_view_widgets[] = {
4937
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4933
diff changeset
   116
{   WWT_CLOSEBOX,  RESIZE_NONE, 14,   0,  10,   0,  13, STR_00C5,                STR_018B_CLOSE_WINDOW },
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4933
diff changeset
   117
{    WWT_CAPTION, RESIZE_RIGHT, 14,  11, 237,   0,  13, STR_882E,                STR_018C_WINDOW_TITLE_DRAG_THIS },
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4933
diff changeset
   118
{  WWT_STICKYBOX,    RESIZE_LR, 14, 238, 249,   0,  13, 0x0,                     STR_STICKY_BUTTON },
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4933
diff changeset
   119
{      WWT_PANEL,    RESIZE_RB, 14,   0, 231,  14, 121, 0x0,                     STR_NULL },
4939
ede0f6777b3c (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4938
diff changeset
   120
{      WWT_INSET,    RESIZE_RB, 14,   2, 229,  16, 119, 0x0,                     STR_NULL },
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   121
{    WWT_PUSHBTN,   RESIZE_RTB, 14,   0, 237, 122, 133, 0x0,                     STR_8846_CURRENT_TRAIN_ACTION_CLICK },
4937
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4933
diff changeset
   122
{ WWT_PUSHIMGBTN,    RESIZE_LR, 14, 232, 249,  14,  31, SPR_CENTRE_VIEW_VEHICLE, STR_8848_CENTER_MAIN_VIEW_ON_TRAIN },
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4933
diff changeset
   123
{ WWT_PUSHIMGBTN,    RESIZE_LR, 14, 232, 249,  32,  49, SPR_SEND_TRAIN_TODEPOT,  STR_8849_SEND_TRAIN_TO_DEPOT },
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4933
diff changeset
   124
{ WWT_PUSHIMGBTN,    RESIZE_LR, 14, 232, 249,  50,  67, SPR_IGNORE_SIGNALS,      STR_884A_FORCE_TRAIN_TO_PROCEED },
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4933
diff changeset
   125
{ WWT_PUSHIMGBTN,    RESIZE_LR, 14, 232, 249,  68,  85, SPR_FORCE_VEHICLE_TURN,  STR_884B_REVERSE_DIRECTION_OF_TRAIN },
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4933
diff changeset
   126
{ WWT_PUSHIMGBTN,    RESIZE_LR, 14, 232, 249,  86, 103, SPR_SHOW_ORDERS,         STR_8847_SHOW_TRAIN_S_ORDERS },
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4933
diff changeset
   127
{ WWT_PUSHIMGBTN,    RESIZE_LR, 14, 232, 249, 104, 121, SPR_SHOW_VEHICLE_DETAILS,STR_884C_SHOW_TRAIN_DETAILS },
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4933
diff changeset
   128
{ WWT_PUSHIMGBTN,    RESIZE_LR, 14, 232, 249,  68,  85, SPR_REFIT_VEHICLE,       STR_RAIL_REFIT_VEHICLE_TO_CARRY },
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4933
diff changeset
   129
{ WWT_PUSHIMGBTN,    RESIZE_LR, 14, 232, 249,  32,  49, SPR_CLONE_TRAIN,         STR_CLONE_TRAIN_INFO },
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4933
diff changeset
   130
{      WWT_PANEL,   RESIZE_LRB, 14, 232, 249, 122, 121, 0x0,                     STR_NULL },
a525d56a8d40 (svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents: 4933
diff changeset
   131
{  WWT_RESIZEBOX,  RESIZE_LRTB, 14, 238, 249, 122, 133, 0x0,                     STR_NULL },
1485
a2f36708c260 (svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents: 1402
diff changeset
   132
{ WIDGETS_END }
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   134
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4088
diff changeset
   135
static void ShowTrainDetailsWindow(const Vehicle *v);
2561
c78c3d248897 (svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents: 2549
diff changeset
   136
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   137
static void TrainViewWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   138
{
1802
448f187042d3 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1790
diff changeset
   139
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   140
	case WE_PAINT: {
1802
448f187042d3 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater
parents: 1790
diff changeset
   141
		const Vehicle *v, *u;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   142
		StringID str;
4709
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   143
		bool is_localplayer;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   144
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 914
diff changeset
   145
		v = GetVehicle(w->window_number);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   146
4709
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   147
		is_localplayer = v->owner == _local_player;
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   148
		SetWindowWidgetDisabledState(w,  7, !is_localplayer);
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   149
		SetWindowWidgetDisabledState(w,  8, !is_localplayer);
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   150
		SetWindowWidgetDisabledState(w,  9, !is_localplayer);
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   151
		SetWindowWidgetDisabledState(w, 13, !is_localplayer);
1387
eff794048d92 (svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents: 1330
diff changeset
   152
4871
f79dbad27b47 (svn r6801) - Fix (r6619): Always disable the train refit button. It will be enabled later if refitting is possible.
peter1138
parents: 4868
diff changeset
   153
		/* Disable cargo refit button, until we know we can enable it below. */
f79dbad27b47 (svn r6801) - Fix (r6619): Always disable the train refit button. It will be enabled later if refitting is possible.
peter1138
parents: 4868
diff changeset
   154
		DisableWindowWidget(w, 12);
f79dbad27b47 (svn r6801) - Fix (r6619): Always disable the train refit button. It will be enabled later if refitting is possible.
peter1138
parents: 4868
diff changeset
   155
4709
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   156
		if (is_localplayer) {
2867
66a9c4e27e34 (svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
peter1138
parents: 2840
diff changeset
   157
			/* See if any vehicle can be refitted */
66a9c4e27e34 (svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
peter1138
parents: 2840
diff changeset
   158
			for (u = v; u != NULL; u = u->next) {
3393
48ce4c723a76 (svn r4201) - Codechange: Do for _engine_info[] what we do for _*_vehicle_info[]; create and use a function to retrieve data, and ensure constness.
peter1138
parents: 3384
diff changeset
   159
				if (EngInfo(u->engine_type)->refit_mask != 0 ||
6119
b47985557d1e (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: 6075
diff changeset
   160
						(RailVehInfo(v->engine_type)->railveh_type != RAILVEH_WAGON && v->cargo_cap != 0)) {
4709
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   161
					EnableWindowWidget(w, 12);
2867
66a9c4e27e34 (svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
peter1138
parents: 2840
diff changeset
   162
					/* We have a refittable carriage, bail out */
66a9c4e27e34 (svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
peter1138
parents: 2840
diff changeset
   163
					break;
66a9c4e27e34 (svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
peter1138
parents: 2840
diff changeset
   164
				}
1387
eff794048d92 (svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents: 1330
diff changeset
   165
			}
eff794048d92 (svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents: 1330
diff changeset
   166
		}
eff794048d92 (svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents: 1330
diff changeset
   167
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
		/* draw widgets & caption */
7545
9a4834d48970 (svn r10314) -Codechange: Refer to vehicle names by index
peter1138
parents: 7506
diff changeset
   169
		SetDParam(0, v->index);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   170
		DrawWindowWidgets(w);
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
		if (v->u.rail.crash_anim_pos != 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   173
			str = STR_8863_CRASHED;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   174
		} else if (v->breakdown_ctr == 1) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
			str = STR_885C_BROKEN_DOWN;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   176
		} else if (v->vehstatus & VS_STOPPED) {
7973
ce69b7781d4a (svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents: 7837
diff changeset
   177
			if (v->cur_speed == 0) {
4251
85befcd5f435 (svn r5853) -Fix: [elrails] FS#178 Electric Trains can leave Conventional Depot
bjarni
parents: 4171
diff changeset
   178
				if (v->u.rail.cached_power == 0) {
85befcd5f435 (svn r5853) -Fix: [elrails] FS#178 Electric Trains can leave Conventional Depot
bjarni
parents: 4171
diff changeset
   179
					str = STR_TRAIN_NO_POWER;
85befcd5f435 (svn r5853) -Fix: [elrails] FS#178 Electric Trains can leave Conventional Depot
bjarni
parents: 4171
diff changeset
   180
				} else {
85befcd5f435 (svn r5853) -Fix: [elrails] FS#178 Electric Trains can leave Conventional Depot
bjarni
parents: 4171
diff changeset
   181
					str = STR_8861_STOPPED;
85befcd5f435 (svn r5853) -Fix: [elrails] FS#178 Electric Trains can leave Conventional Depot
bjarni
parents: 4171
diff changeset
   182
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
			} else {
7973
ce69b7781d4a (svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents: 7837
diff changeset
   184
				SetDParam(0, v->GetDisplaySpeed());
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
				str = STR_TRAIN_STOPPING + _patches.vehicle_speed;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   186
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
		} else {
555
eec6c0294435 (svn r955) Replace uint16 for orders with struct Order
tron
parents: 543
diff changeset
   188
			switch (v->current_order.type) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
			case OT_GOTO_STATION: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   190
				str = STR_HEADING_FOR_STATION + _patches.vehicle_speed;
4527
b18634a31a4a (svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents: 4524
diff changeset
   191
				SetDParam(0, v->current_order.dest);
7973
ce69b7781d4a (svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents: 7837
diff changeset
   192
				SetDParam(1, v->GetDisplaySpeed());
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   193
			} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   194
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   195
			case OT_GOTO_DEPOT: {
4527
b18634a31a4a (svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents: 4524
diff changeset
   196
				Depot *dep = GetDepot(v->current_order.dest);
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   197
				SetDParam(0, dep->town_index);
4633
fae5d85ef53d (svn r6497) -Fix r6165: Vehicles heading for depots when their orders contained "service in depot" displayed the stopping in depot string
bjarni
parents: 4547
diff changeset
   198
				if (HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT) && !HASBIT(v->current_order.flags, OFB_PART_OF_ORDERS)) {
4412
945e8a9bb89a (svn r6165) -Feature: control click Goto Depot will now make the vehicle service
bjarni
parents: 4408
diff changeset
   199
					str = STR_HEADING_FOR_TRAIN_DEPOT + _patches.vehicle_speed;
945e8a9bb89a (svn r6165) -Feature: control click Goto Depot will now make the vehicle service
bjarni
parents: 4408
diff changeset
   200
				} else {
945e8a9bb89a (svn r6165) -Feature: control click Goto Depot will now make the vehicle service
bjarni
parents: 4408
diff changeset
   201
					str = STR_HEADING_FOR_TRAIN_DEPOT_SERVICE + _patches.vehicle_speed;
945e8a9bb89a (svn r6165) -Feature: control click Goto Depot will now make the vehicle service
bjarni
parents: 4408
diff changeset
   202
				}
7973
ce69b7781d4a (svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents: 7837
diff changeset
   203
				SetDParam(1, v->GetDisplaySpeed());
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
			} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   205
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   206
			case OT_LOADING:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
			case OT_LEAVESTATION:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
				str = STR_882F_LOADING_UNLOADING;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   209
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   210
395
4c990f33dab7 (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents: 382
diff changeset
   211
			case OT_GOTO_WAYPOINT: {
4527
b18634a31a4a (svn r6353) -Codechange: Make DestinationID a typedef of uin16, which is as large as any type of destinataion (StationID, DepotID, WaypointID) it can hold
tron
parents: 4524
diff changeset
   212
				SetDParam(0, v->current_order.dest);
395
4c990f33dab7 (svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents: 382
diff changeset
   213
				str = STR_HEADING_FOR_WAYPOINT + _patches.vehicle_speed;
7973
ce69b7781d4a (svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents: 7837
diff changeset
   214
				SetDParam(1, v->GetDisplaySpeed());
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   215
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   216
			}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   217
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   218
			default:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   219
				if (v->num_orders == 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   220
					str = STR_NO_ORDERS + _patches.vehicle_speed;
7973
ce69b7781d4a (svn r10984) -Codechange: unify the way one can get the current speed in the same forwat so we can display it.
rubidium
parents: 7837
diff changeset
   221
					SetDParam(0, v->GetDisplaySpeed());
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4049
diff changeset
   222
				} else {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   223
					str = STR_EMPTY;
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4049
diff changeset
   224
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   225
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   226
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   228
2103
9266bb2ac29d (svn r2613) - Truncate savegames, and vehicle-texts in their window.
Darkvater
parents: 2084
diff changeset
   229
		/* draw the flag plus orders */
5919
2b58160d667d (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5852
diff changeset
   230
		DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, 2, w->widget[5].top + 1);
2113
f228b399da01 (svn r2623) - CodeChange: rework DrawStringCenteredTruncated() a bit. Instead of giving center + width you give the coordinates of the bounding box (left, right) it has to fit in (ludde)
Darkvater
parents: 2103
diff changeset
   231
		DrawStringCenteredTruncated(w->widget[5].left + 8, w->widget[5].right, w->widget[5].top + 1, str, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   232
		DrawWindowViewport(w);
6988
76eba6a9cc6f (svn r9673) -Cleanup: remove spaces before tabs and replace non-indenting tabs with spaces.
rubidium
parents: 6918
diff changeset
   233
	} break;
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
	case WE_CLICK: {
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4633
diff changeset
   236
		int wid = e->we.click.widget;
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 914
diff changeset
   237
		Vehicle *v = GetVehicle(w->window_number);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   238
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2951
diff changeset
   239
		switch (wid) {
755
823358e83abf (svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents: 727
diff changeset
   240
		case 5: /* start/stop train */
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   241
			DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   242
			break;
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4429
diff changeset
   243
		case 6: /* center main view */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   244
			ScrollMainWindowTo(v->x_pos, v->y_pos);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   245
			break;
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4429
diff changeset
   246
		case 7: /* goto depot */
601
952c0295f79a (svn r1025) -Fix: [Network] [ 1083687 ] Sending to depot caused desync because the
truelight
parents: 588
diff changeset
   247
			/* TrainGotoDepot has a nice randomizer in the pathfinder, which causes desyncs... */
4506
0d8fcc0a4e49 (svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents: 4495
diff changeset
   248
			DoCommandP(v->tile, v->index, _ctrl_pressed ? DEPOT_SERVICE : 0, NULL, CMD_SEND_TRAIN_TO_DEPOT | CMD_NO_TEST_IF_IN_NETWORK | CMD_MSG(STR_8830_CAN_T_SEND_TRAIN_TO_DEPOT));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   249
			break;
755
823358e83abf (svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents: 727
diff changeset
   250
		case 8: /* force proceed */
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   251
			DoCommandP(v->tile, v->index, 0, NULL, CMD_FORCE_TRAIN_PROCEED | CMD_MSG(STR_8862_CAN_T_MAKE_TRAIN_PASS_SIGNAL));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   252
			break;
755
823358e83abf (svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents: 727
diff changeset
   253
		case 9: /* reverse direction */
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   254
			DoCommandP(v->tile, v->index, 0, NULL, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_8869_CAN_T_REVERSE_DIRECTION));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   255
			break;
755
823358e83abf (svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents: 727
diff changeset
   256
		case 10: /* show train orders */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   257
			ShowOrdersWindow(v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   258
			break;
755
823358e83abf (svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents: 727
diff changeset
   259
		case 11: /* show train details */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   260
			ShowTrainDetailsWindow(v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   261
			break;
755
823358e83abf (svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents: 727
diff changeset
   262
		case 12:
4712
273ec3b182bf (svn r6624) -Feature: added ability to add refit commands to vehicle orders (can only be done in goto depot orders)
bjarni
parents: 4709
diff changeset
   263
			ShowVehicleRefitWindow(v, INVALID_VEH_ORDER_ID);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   264
			break;
2244
e6b5ef68406d (svn r2764) -Feature: Clone vehicles
bjarni
parents: 2186
diff changeset
   265
		case 13:
7974
6fcdebd75c19 (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium
parents: 7973
diff changeset
   266
			DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, CcCloneVehicle, CMD_CLONE_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE));
2244
e6b5ef68406d (svn r2764) -Feature: Clone vehicles
bjarni
parents: 2186
diff changeset
   267
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   269
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   270
1485
a2f36708c260 (svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents: 1402
diff changeset
   271
	case WE_RESIZE:
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4633
diff changeset
   272
		w->viewport->width          += e->we.sizing.diff.x;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4633
diff changeset
   273
		w->viewport->height         += e->we.sizing.diff.y;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4633
diff changeset
   274
		w->viewport->virtual_width  += e->we.sizing.diff.x;
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4633
diff changeset
   275
		w->viewport->virtual_height += e->we.sizing.diff.y;
1485
a2f36708c260 (svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents: 1402
diff changeset
   276
		break;
a2f36708c260 (svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents: 1402
diff changeset
   277
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   278
	case WE_DESTROY:
338
04ad3e897bf8 (svn r514) -Fix: [1053397] Refit Train Window Stays Open
tron
parents: 243
diff changeset
   279
		DeleteWindowById(WC_VEHICLE_REFIT, w->window_number);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   280
		DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
		DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number);
7559
8e7ef897f126 (svn r10328) -Codechange: Close the timetable window when closing the vehicle window.
maedhros
parents: 7555
diff changeset
   282
		DeleteWindowById(WC_VEHICLE_TIMETABLE, w->window_number);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   283
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   284
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   285
	case WE_MOUSELOOP: {
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4088
diff changeset
   286
		const Vehicle *v = GetVehicle(w->window_number);
4702
5179f9adc5b3 (svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents: 4668
diff changeset
   287
		bool train_stopped = CheckTrainStoppedInDepot(v)  >= 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   288
4702
5179f9adc5b3 (svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents: 4668
diff changeset
   289
		/* Widget 7 (send to depot) must be hidden if the train is already stopped in hangar.
5179f9adc5b3 (svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents: 4668
diff changeset
   290
		 * Widget 13 (clone) should then be shown, since cloning is allowed only while in depot and stopped.
5179f9adc5b3 (svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents: 4668
diff changeset
   291
		 * This sytem allows to have two buttons, on top of each other.
5179f9adc5b3 (svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents: 4668
diff changeset
   292
		 * The same system applies to widget 9 and 12, reverse direction and refit*/
5179f9adc5b3 (svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents: 4668
diff changeset
   293
		if (train_stopped != IsWindowWidgetHidden(w, 7) || train_stopped == IsWindowWidgetHidden(w, 13)) {
5179f9adc5b3 (svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents: 4668
diff changeset
   294
			SetWindowWidgetHiddenState(w,  7, train_stopped);  // send to depot
5179f9adc5b3 (svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents: 4668
diff changeset
   295
			SetWindowWidgetHiddenState(w,  9, train_stopped);  // reverse direction
5179f9adc5b3 (svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents: 4668
diff changeset
   296
			SetWindowWidgetHiddenState(w, 12, !train_stopped); // refit
5179f9adc5b3 (svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents: 4668
diff changeset
   297
			SetWindowWidgetHiddenState(w, 13, !train_stopped); // clone
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   299
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   300
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   301
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   302
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   303
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   304
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   306
static const WindowDesc _train_view_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7817
diff changeset
   307
	WDP_AUTO, WDP_AUTO, 250, 134, 250, 134,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6125
diff changeset
   308
	WC_VEHICLE_VIEW, WC_NONE,
1485
a2f36708c260 (svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents: 1402
diff changeset
   309
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   310
	_train_view_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   311
	TrainViewWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   312
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   313
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4088
diff changeset
   314
void ShowTrainViewWindow(const Vehicle *v)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
{
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4088
diff changeset
   316
	Window *w = AllocateWindowDescFront(&_train_view_desc,v->index);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   317
2561
c78c3d248897 (svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents: 2549
diff changeset
   318
	if (w != NULL) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   319
		w->caption_color = v->owner;
7120
e31767effc16 (svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents: 6988
diff changeset
   320
		AssignWindowViewport(w, 3, 17, 0xE2, 0x66, w->window_number | (1 << 31), ZOOM_LVL_TRAIN);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   321
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   322
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
1790
4afb4b4e4278 (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
   324
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
   325
{
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   326
	if (v->cargo_cap != 0) {
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   327
		StringID str = STR_8812_EMPTY;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   328
7506
e52d89f5c7c1 (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: 7498
diff changeset
   329
		if (!v->cargo.Empty()) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   330
			SetDParam(0, v->cargo_type);
7506
e52d89f5c7c1 (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: 7498
diff changeset
   331
			SetDParam(1, v->cargo.Count());
e52d89f5c7c1 (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: 7498
diff changeset
   332
			SetDParam(2, v->cargo.Source());
5163
83acad83bbdd (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
   333
			SetDParam(3, _patches.freight_trains);
5316
b04421921eae (svn r7473) -Fix (r7269): Pass a cargo type to determine the freight weight
peter1138
parents: 5273
diff changeset
   334
			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
   335
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   336
		DrawString(x, y, str, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   337
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   338
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   339
1790
4afb4b4e4278 (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
   340
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
   341
{
6119
b47985557d1e (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: 6075
diff changeset
   342
	if (RailVehInfo(v->engine_type)->railveh_type == RAILVEH_WAGON) {
7555
e20900912fa2 (svn r10324) -Codechange: reference engine names by index
peter1138
parents: 7545
diff changeset
   343
		SetDParam(0, v->engine_type);
7498
ce6588257e8d (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: 7487
diff changeset
   344
		SetDParam(1, v->value);
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   345
		DrawString(x, y, STR_882D_VALUE, 0x10);
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   346
	} else {
7555
e20900912fa2 (svn r10324) -Codechange: reference engine names by index
peter1138
parents: 7545
diff changeset
   347
		SetDParam(0, v->engine_type);
4329
9759d5c52010 (svn r6002) -Cleanup: remove the now redundant BASE_YEAR constant.
rubidium
parents: 4299
diff changeset
   348
		SetDParam(1, v->build_year);
7498
ce6588257e8d (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: 7487
diff changeset
   349
		SetDParam(2, v->value);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   350
		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
   351
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   352
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   353
1790
4afb4b4e4278 (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
   354
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
   355
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   356
	if (v->cargo_cap != 0) {
4896
72d7a8614580 (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
   357
		SetDParam(0, v->cargo_type);
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   358
		SetDParam(1, v->cargo_cap);
5163
83acad83bbdd (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
   359
		SetDParam(2, _patches.freight_trains);
5316
b04421921eae (svn r7473) -Fix (r7269): Pass a cargo type to determine the freight weight
peter1138
parents: 5273
diff changeset
   360
		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
   361
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   362
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   363
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   364
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   365
static void DrawTrainDetailsWindow(Window *w)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   366
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   367
	byte det_tab = WP(w, traindetails_d).tab;
5187
d1f4e447a7eb (svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents: 5163
diff changeset
   368
	const Vehicle *v;
d1f4e447a7eb (svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents: 5163
diff changeset
   369
	const Vehicle *u;
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   370
	AcceptedCargo act_cargo;
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   371
	AcceptedCargo max_cargo;
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   372
	int num;
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   373
	int x;
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   374
	int y;
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   375
	int sel;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   376
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   377
	num = 0;
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 914
diff changeset
   378
	u = v = GetVehicle(w->window_number);
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   379
	if (det_tab == 3) { // Total cargo tab
6676
30aea9ac89bc (svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138
parents: 6585
diff changeset
   380
		for (CargoID i = 0; i < lengthof(act_cargo); i++) {
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   381
			act_cargo[i] = 0;
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   382
			max_cargo[i] = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   383
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   384
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   385
		do {
7506
e52d89f5c7c1 (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: 7498
diff changeset
   386
			act_cargo[u->cargo_type] += u->cargo.Count();
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   387
			max_cargo[u->cargo_type] += u->cargo_cap;
4868
e9478d949505 (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
   388
		} while ((u = u->next) != NULL);
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   389
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   390
		/* Set scroll-amount seperately from counting, as to not compute num double
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   391
		 * for more carriages of the same type
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   392
		 */
6676
30aea9ac89bc (svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138
parents: 6585
diff changeset
   393
		for (CargoID i = 0; i < NUM_CARGO; i++) {
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   394
			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
   395
		}
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4429
diff changeset
   396
		num++; // needs one more because first line is description string
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   397
	} else {
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   398
		do {
4868
e9478d949505 (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
   399
			if (!IsArticulatedPart(u) || u->cargo_cap != 0) num++;
e9478d949505 (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
   400
		} while ((u = u->next) != NULL);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   401
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   402
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
	SetVScrollCount(w, num);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
4709
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   405
	DisableWindowWidget(w, det_tab + 9);
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   406
	SetWindowWidgetDisabledState(w, 2, v->owner != _local_player);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   407
4709
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   408
	/* disable service-scroller when interval is set to disabled */
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   409
	SetWindowWidgetDisabledState(w, 6, !_patches.servint_trains);
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   410
	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
   411
7545
9a4834d48970 (svn r10314) -Codechange: Refer to vehicle names by index
peter1138
parents: 7506
diff changeset
   412
	SetDParam(0, v->index);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   413
	DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   414
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   415
	SetDParam(1, v->age / 366);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   416
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   417
	x = 2;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   418
2252
37e3ca7014e0 (svn r2772) Simplify the age notice in the vehicle details window
tron
parents: 2244
diff changeset
   419
	SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED);
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   420
	SetDParam(2, v->max_age / 366);
7498
ce6588257e8d (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: 7487
diff changeset
   421
	SetDParam(3, GetTrainRunningCost(v) >> 8);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
	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
   423
6125
492a1c0440af (svn r8464) -Revert (r4322): Change back to converting to mph in the GUI code, as 1 mph == 1.6 km/h is too far out for some people.
peter1138
parents: 6119
diff changeset
   424
	SetDParam(2, v->u.rail.cached_max_speed * 10 / 16);
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   425
	SetDParam(1, v->u.rail.cached_power);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   426
	SetDParam(0, v->u.rail.cached_weight);
5588
1bcb6b4c01d8 (svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents: 5316
diff changeset
   427
	SetDParam(3, v->u.rail.cached_max_te / 1000);
1bcb6b4c01d8 (svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents: 5316
diff changeset
   428
	DrawString(x, 25, (_patches.realistic_acceleration && v->u.rail.railtype != RAILTYPE_MAGLEV) ?
1bcb6b4c01d8 (svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents: 5316
diff changeset
   429
		STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE :
1bcb6b4c01d8 (svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents: 5316
diff changeset
   430
		STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   431
7498
ce6588257e8d (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: 7487
diff changeset
   432
	SetDParam(0, v->profit_this_year);
ce6588257e8d (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: 7487
diff changeset
   433
	SetDParam(1, v->profit_last_year);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   434
	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
   435
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   436
	SetDParam(0, 100 * (v->reliability>>8) >> 8);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   437
	SetDParam(1, v->breakdowns_since_last_service);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   438
	DrawString(x, 45, STR_8860_RELIABILITY_BREAKDOWNS, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   439
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   440
	SetDParam(0, v->service_interval);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   441
	SetDParam(1, v->date_of_last_service);
2959
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   442
	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
   443
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   444
	y = 57;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   445
	sel = w->vscroll.pos;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   446
6918
5589c415e28f (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6676
diff changeset
   447
	/* draw the first 3 details tabs */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   448
	if (det_tab != 3) {
2822
ff15d6f947ed (svn r3370) Improve alignment of text within total cargo tab of train view window
peter1138
parents: 2819
diff changeset
   449
		x = 1;
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2951
diff changeset
   450
		for (;;) {
2959
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   451
			if (--sel < 0 && sel >= -w->vscroll.cap) {
2602
f0e2dcce3695 (svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
peter1138
parents: 2593
diff changeset
   452
				int dx = 0;
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   453
				int px;
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   454
				int py;
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   455
2602
f0e2dcce3695 (svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
peter1138
parents: 2593
diff changeset
   456
				u = v;
f0e2dcce3695 (svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
peter1138
parents: 2593
diff changeset
   457
				do {
5919
2b58160d667d (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5852
diff changeset
   458
					SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
7630
2cd754d7dfa4 (svn r10408) -Codechange: make GetImage a class method of Vehicle instead of Get(Aircraft|RoadVeh|Ship|Train)Image.
rubidium
parents: 7559
diff changeset
   459
					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
f0e2dcce3695 (svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
peter1138
parents: 2593
diff changeset
   460
					dx += u->u.rail.cached_veh_length;
f0e2dcce3695 (svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
peter1138
parents: 2593
diff changeset
   461
					u = u->next;
4868
e9478d949505 (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
   462
				} while (u != NULL && IsArticulatedPart(u) && u->cargo_cap == 0);
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   463
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   464
				px = x + WagonLengthToPixels(dx) + 2;
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   465
				py = y + 2;
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   466
				switch (det_tab) {
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   467
					default: NOT_REACHED();
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   468
					case 0: TrainDetailsCargoTab(   v, px, py); break;
4868
e9478d949505 (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
   469
					case 1:
6918
5589c415e28f (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6676
diff changeset
   470
						/* Only show name and value for the 'real' part */
4868
e9478d949505 (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
   471
						if (!IsArticulatedPart(v)) {
e9478d949505 (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
   472
							TrainDetailsInfoTab(v, px, py);
e9478d949505 (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
   473
						}
e9478d949505 (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
   474
						break;
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   475
					case 2: TrainDetailsCapacityTab(v, px, py); break;
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   476
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   477
				y += 14;
4868
e9478d949505 (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
   478
e9478d949505 (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
   479
				v = u;
e9478d949505 (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
   480
			} else {
6918
5589c415e28f (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6676
diff changeset
   481
				/* Move to the next line */
4868
e9478d949505 (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
   482
				do {
e9478d949505 (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
   483
					v = v->next;
e9478d949505 (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
   484
				} 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
   485
			}
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   486
			if (v == NULL) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   487
		}
2959
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   488
	} else {
6918
5589c415e28f (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6676
diff changeset
   489
		/* draw total cargo tab */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   490
		DrawString(x, y + 2, STR_013F_TOTAL_CAPACITY_TEXT, 0);
6676
30aea9ac89bc (svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138
parents: 6585
diff changeset
   491
		for (CargoID i = 0; i < NUM_CARGO; i++) {
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   492
			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
   493
				y += 14;
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   494
				SetDParam(0, i);            // {CARGO} #1
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   495
				SetDParam(1, act_cargo[i]); // {CARGO} #2
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   496
				SetDParam(2, i);            // {SHORTCARGO} #1
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   497
				SetDParam(3, max_cargo[i]); // {SHORTCARGO} #2
5163
83acad83bbdd (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
   498
				SetDParam(4, _patches.freight_trains);
5316
b04421921eae (svn r7473) -Fix (r7269): Pass a cargo type to determine the freight weight
peter1138
parents: 5273
diff changeset
   499
				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
   500
			}
2959
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   501
		}
7506
e52d89f5c7c1 (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: 7498
diff changeset
   502
		SetDParam(0, v->cargo.FeederShare());
6524
44e22a9b2c97 (svn r8978) -Feature: Rewrite of transfer system.
richk
parents: 6319
diff changeset
   503
		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
   504
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   505
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   506
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   507
static void TrainDetailsWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   508
{
1790
4afb4b4e4278 (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
   509
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   510
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   511
		DrawTrainDetailsWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   512
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   513
	case WE_CLICK: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   514
		int mod;
1790
4afb4b4e4278 (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
   515
		const Vehicle *v;
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4633
diff changeset
   516
		switch (e->we.click.widget) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   517
		case 2: /* name train */
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 914
diff changeset
   518
			v = GetVehicle(w->window_number);
7545
9a4834d48970 (svn r10314) -Codechange: Refer to vehicle names by index
peter1138
parents: 7506
diff changeset
   519
			SetDParam(0, v->index);
9a4834d48970 (svn r10314) -Codechange: Refer to vehicle names by index
peter1138
parents: 7506
diff changeset
   520
			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
   521
			break;
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4429
diff changeset
   522
		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
   523
			mod = _ctrl_pressed? 5 : 10;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   524
			goto do_change_service_int;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   525
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   526
		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
   527
			mod = _ctrl_pressed? -5 : -10;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   528
do_change_service_int:
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 914
diff changeset
   529
			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
   530
1790
4afb4b4e4278 (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
   531
			mod = GetServiceIntervalClamped(mod + v->service_interval);
4afb4b4e4278 (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
   532
			if (mod == v->service_interval) return;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   533
2819
710436dd4288 (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
   534
			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
   535
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   536
		/* details buttons*/
4434
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4429
diff changeset
   537
		case 9:  // Cargo
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4429
diff changeset
   538
		case 10: // Information
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4429
diff changeset
   539
		case 11: // Capacities
4175805666a5 (svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents: 4429
diff changeset
   540
		case 12: // Total cargo
4709
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   541
			EnableWindowWidget(w,  9);
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   542
			EnableWindowWidget(w, 10);
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   543
			EnableWindowWidget(w, 11);
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   544
			EnableWindowWidget(w, 12);
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   545
			EnableWindowWidget(w, e->we.click.widget);
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4633
diff changeset
   546
			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
   547
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   548
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   549
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   550
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   551
2548
97ada3bd2702 (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2520
diff changeset
   552
	case WE_ON_EDIT_TEXT:
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4633
diff changeset
   553
		if (e->we.edittext.str[0] != '\0') {
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4633
diff changeset
   554
			_cmd_text = e->we.edittext.str;
1820
9b6458526480 (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
   555
			DoCommandP(0, w->window_number, 0, NULL,
9b6458526480 (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
   556
				CMD_NAME_VEHICLE | CMD_MSG(STR_8866_CAN_T_NAME_TRAIN));
9b6458526480 (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
   557
		}
2548
97ada3bd2702 (svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents: 2520
diff changeset
   558
		break;
2959
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   559
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   560
	case WE_RESIZE:
6075
33cdb35f9af5 (svn r8390) -Codechange (r8384): Rewrote ResizeButtons()
bjarni
parents: 6073
diff changeset
   561
		if (e->we.sizing.diff.x != 0) ResizeButtons(w, 9, 12);
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4633
diff changeset
   562
		if (e->we.sizing.diff.y == 0) break;
2959
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   563
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4633
diff changeset
   564
		w->vscroll.cap += e->we.sizing.diff.y / 14;
4547
9786a24c4102 (svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents: 4541
diff changeset
   565
		w->widget[4].data = (w->vscroll.cap << 8) + 1;
2959
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   566
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   567
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   568
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   569
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   570
static const Widget _train_details_widgets[] = {
2959
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   571
{   WWT_CLOSEBOX, RESIZE_NONE,   14,   0,  10,   0,  13, STR_00C5,             STR_018B_CLOSE_WINDOW},
6072
0088b58f1ce6 (svn r8383) -Feature: train detail window is now resizable horizontally (requested by Wolf01)
bjarni
parents: 6030
diff changeset
   572
{    WWT_CAPTION, RESIZE_RIGHT,  14,  11, 329,   0,  13, STR_8802_DETAILS,     STR_018C_WINDOW_TITLE_DRAG_THIS},
0088b58f1ce6 (svn r8383) -Feature: train detail window is now resizable horizontally (requested by Wolf01)
bjarni
parents: 6030
diff changeset
   573
{ WWT_PUSHTXTBTN, RESIZE_LR,     14, 330, 369,   0,  13, STR_01AA_NAME,        STR_8867_NAME_TRAIN},
0088b58f1ce6 (svn r8383) -Feature: train detail window is now resizable horizontally (requested by Wolf01)
bjarni
parents: 6030
diff changeset
   574
{      WWT_PANEL, RESIZE_RIGHT,  14,   0, 369,  14,  55, 0x0,                  STR_NULL},
0088b58f1ce6 (svn r8383) -Feature: train detail window is now resizable horizontally (requested by Wolf01)
bjarni
parents: 6030
diff changeset
   575
{     WWT_MATRIX, RESIZE_RB,     14,   0, 357,  56, 139, 0x601,                STR_NULL},
0088b58f1ce6 (svn r8383) -Feature: train detail window is now resizable horizontally (requested by Wolf01)
bjarni
parents: 6030
diff changeset
   576
{  WWT_SCROLLBAR, RESIZE_LRB,    14, 358, 369,  56, 139, 0x0,                  STR_0190_SCROLL_BAR_SCROLLS_LIST},
2959
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   577
{ WWT_PUSHTXTBTN, RESIZE_TB,     14,   0,  10, 140, 145, STR_0188,             STR_884D_INCREASE_SERVICING_INTERVAL},
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   578
{ WWT_PUSHTXTBTN, RESIZE_TB,     14,   0,  10, 146, 151, STR_0189,             STR_884E_DECREASE_SERVICING_INTERVAL},
6072
0088b58f1ce6 (svn r8383) -Feature: train detail window is now resizable horizontally (requested by Wolf01)
bjarni
parents: 6030
diff changeset
   579
{      WWT_PANEL, RESIZE_RTB,    14,  11, 369, 140, 151, 0x0,                  STR_NULL},
2959
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   580
{ WWT_PUSHTXTBTN, RESIZE_TB,     14,   0,  89, 152, 163, STR_013C_CARGO,       STR_884F_SHOW_DETAILS_OF_CARGO_CARRIED},
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   581
{ WWT_PUSHTXTBTN, RESIZE_TB,     14,  90, 178, 152, 163, STR_013D_INFORMATION, STR_8850_SHOW_DETAILS_OF_TRAIN_VEHICLES},
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   582
{ WWT_PUSHTXTBTN, RESIZE_TB,     14, 179, 268, 152, 163, STR_013E_CAPACITIES,  STR_8851_SHOW_CAPACITIES_OF_EACH},
6075
33cdb35f9af5 (svn r8390) -Codechange (r8384): Rewrote ResizeButtons()
bjarni
parents: 6073
diff changeset
   583
{ WWT_PUSHTXTBTN, RESIZE_RTB,    14, 269, 357, 152, 163, STR_013E_TOTAL_CARGO, STR_8852_SHOW_TOTAL_CARGO},
6072
0088b58f1ce6 (svn r8383) -Feature: train detail window is now resizable horizontally (requested by Wolf01)
bjarni
parents: 6030
diff changeset
   584
{  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
   585
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   586
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   587
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   588
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   589
static const WindowDesc _train_details_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7817
diff changeset
   590
	WDP_AUTO, WDP_AUTO, 370, 164, 370, 164,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   591
	WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW,
2959
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   592
	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
   593
	_train_details_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   594
	TrainDetailsWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   595
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   596
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   597
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4088
diff changeset
   598
static void ShowTrainDetailsWindow(const Vehicle *v)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   599
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   600
	Window *w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   601
	VehicleID veh = v->index;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   602
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   603
	DeleteWindowById(WC_VEHICLE_ORDERS, veh);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   604
	DeleteWindowById(WC_VEHICLE_DETAILS, veh);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   605
5071
14f432b47034 (svn r7129) -Codechange: Get rid of a global variable that only sets a window's number.
Darkvater
parents: 5070
diff changeset
   606
	w = AllocateWindowDescFront(&_train_details_desc, veh);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   607
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   608
	w->caption_color = v->owner;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   609
	w->vscroll.cap = 6;
4547
9786a24c4102 (svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents: 4541
diff changeset
   610
	w->widget[4].data = (w->vscroll.cap << 8) + 1;
2959
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   611
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   612
	w->resize.step_height = 14;
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   613
	w->resize.height = w->height - 14 * 2; /* Minimum of 4 wagons in the display */
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   614
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   615
	WP(w,traindetails_d).tab = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   616
}