src/train_gui.cpp
author KUDr
Sat, 21 Apr 2007 08:23:57 +0000
branchcpp_gui
changeset 6308 646711c5feaa
parent 6307 f40e88cff863
permissions -rw-r--r--
(svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
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
6307
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6303
diff changeset
     3
/** @file train_gui.cpp */
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6303
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"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    11
#include "window.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
#include "gui.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
#include "vehicle.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
#include "viewport.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
#include "command.h"
588
1b60458bdc29 (svn r1009) -Feature: per-station vehicle lists
tron
parents: 573
diff changeset
    16
#include "vehicle_gui.h"
1313
bba6afb8a995 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents: 1299
diff changeset
    17
#include "depot.h"
2676
2ba71e034d97 (svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents: 2639
diff changeset
    18
#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
    19
#include "newgrf_engine.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    20
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
    21
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
    22
{
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4088
diff changeset
    23
	Vehicle *v, *found;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    24
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4049
diff changeset
    25
	if (!success) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    26
6307
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6303
diff changeset
    27
	/* find a locomotive in the depot. */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    28
	found = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    29
	FOR_ALL_VEHICLES(v) {
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
    30
		if (v->type == VEH_TRAIN && IsFrontEngine(v) &&
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    31
				v->tile == tile &&
6253
23983700e3d7 (svn r8731) [cpp_gui] -Sync: r8730 from trunk
bjarni
parents: 6250
diff changeset
    32
				v->u.rail.track == TRACK_BIT_DEPOT) {
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4049
diff changeset
    33
			if (found != NULL) return; // must be exactly one.
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
			found = v;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
		}
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
6307
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6303
diff changeset
    38
	/* if we found a loco, */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
	if (found != NULL) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
		found = GetLastVehicleInChain(found);
6307
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6303
diff changeset
    41
		/* 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
    42
		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
    43
		RebuildVehicleLists();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
	}
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
1977
4392ae3d8e31 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents: 1962
diff changeset
    47
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
    48
{
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4088
diff changeset
    49
	const Vehicle *v;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2630
diff changeset
    51
	if (!success) return;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
    52
3948
95f9fa0ac551 (svn r5094) Remove _new_{aircraft,roadveh,ship,train,wagon}_id. _new_vehicle_id is enough.
tron
parents: 3919
diff changeset
    53
	v = GetVehicle(_new_vehicle_id);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
	if (tile == _backup_orders_tile) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
		_backup_orders_tile = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
		RestoreVehicleOrders(v, _backup_orders_data);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
	ShowTrainViewWindow(v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
3887
3e44ae3b1e7c (svn r4943) uint tile -> TileIndex tile, byte player -> PlayerID player
tron
parents: 3884
diff changeset
    61
void CcCloneTrain(bool success, TileIndex tile, uint32 p1, uint32 p2)
2244
e6b5ef68406d (svn r2764) -Feature: Clone vehicles
bjarni
parents: 2186
diff changeset
    62
{
3948
95f9fa0ac551 (svn r5094) Remove _new_{aircraft,roadveh,ship,train,wagon}_id. _new_vehicle_id is enough.
tron
parents: 3919
diff changeset
    63
	if (success) ShowTrainViewWindow(GetVehicle(_new_vehicle_id));
2244
e6b5ef68406d (svn r2764) -Feature: Clone vehicles
bjarni
parents: 2186
diff changeset
    64
}
5187
d1f4e447a7eb (svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents: 5163
diff changeset
    65
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
    66
/**
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
    67
 * 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
    68
 * @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
    69
 * @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
    70
 */
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents: 4635
diff changeset
    71
int WagonLengthToPixels(int len) {
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
    72
	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
    73
}
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
    74
4442
8d8d0c2df7cb (svn r6215) -Codechange: [vehicle list windows] unified Player(vehicle)WndProc into PlayerVehWndProc
bjarni
parents: 4434
diff changeset
    75
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
    76
{
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
    77
	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
    78
	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
    79
	/* 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
    80
	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
    81
	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
    82
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
    83
	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
    84
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
	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
    86
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
    87
	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
    88
	_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
    89
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
	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
    91
		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
    92
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
    93
		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
    94
			if (dx <= count) {
5919
2b58160d667d (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5852
diff changeset
    95
				SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
2b58160d667d (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5852
diff changeset
    96
				DrawSprite(GetTrainImage(v, 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
    97
				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
    98
					/* 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
    99
					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
   100
					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
   101
				}
1922
797081e56d13 (svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents: 1908
diff changeset
   102
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
		}
3919
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
		dx += width;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
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
   106
		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
   107
	} 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
   108
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
   109
	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
   110
		/* 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
   111
		 * 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
   112
		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
   113
	}
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
   114
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
   115
	_cur_dpi = old_dpi;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6253
diff changeset
   118
static const OldWidget _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
   119
{   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
   120
{    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
   121
{  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
   122
{      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
   123
{      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
   124
{    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
   125
{ 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
   126
{ 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
   127
{ 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
   128
{ 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
   129
{ 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
   130
{ 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
   131
{ 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
   132
{ 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
   133
{      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
   134
{  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
   135
{ WIDGETS_END }
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   136
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   137
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4088
diff changeset
   138
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
   139
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6253
diff changeset
   140
static void TrainViewWndProc(BaseWindow *w, WindowEvent *e)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   141
{
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
   142
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
	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
   144
		const Vehicle *v, *u;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   145
		StringID str;
4709
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   146
		bool is_localplayer;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 914
diff changeset
   148
		v = GetVehicle(w->window_number);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   149
4709
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   150
		is_localplayer = v->owner == _local_player;
6246
2a4c2c4d66f0 (svn r8713) [cpp_gui] -Codechange: SetWindowWidgetDisabledState turned into Window method
KUDr
parents: 6245
diff changeset
   151
		w->SetWidgetDisabledState( 7, !is_localplayer);
2a4c2c4d66f0 (svn r8713) [cpp_gui] -Codechange: SetWindowWidgetDisabledState turned into Window method
KUDr
parents: 6245
diff changeset
   152
		w->SetWidgetDisabledState( 8, !is_localplayer);
2a4c2c4d66f0 (svn r8713) [cpp_gui] -Codechange: SetWindowWidgetDisabledState turned into Window method
KUDr
parents: 6245
diff changeset
   153
		w->SetWidgetDisabledState( 9, !is_localplayer);
2a4c2c4d66f0 (svn r8713) [cpp_gui] -Codechange: SetWindowWidgetDisabledState turned into Window method
KUDr
parents: 6245
diff changeset
   154
		w->SetWidgetDisabledState(13, !is_localplayer);
1387
eff794048d92 (svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents: 1330
diff changeset
   155
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
   156
		/* Disable cargo refit button, until we know we can enable it below. */
6247
67e881450cf3 (svn r8714) [cpp_gui] -Codechange: DisableWindowWidget() and EnableWindowWidget() turned into Window methods
KUDr
parents: 6246
diff changeset
   157
		w->DisableWidget(12);
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
   158
4709
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   159
		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
   160
			/* 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
   161
			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
   162
				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
   163
						(RailVehInfo(v->engine_type)->railveh_type != RAILVEH_WAGON && v->cargo_cap != 0)) {
6247
67e881450cf3 (svn r8714) [cpp_gui] -Codechange: DisableWindowWidget() and EnableWindowWidget() turned into Window methods
KUDr
parents: 6246
diff changeset
   164
					w->EnableWidget(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
   165
					/* 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
   166
					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
   167
				}
1387
eff794048d92 (svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents: 1330
diff changeset
   168
			}
eff794048d92 (svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents: 1330
diff changeset
   169
		}
eff794048d92 (svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents: 1330
diff changeset
   170
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   171
		/* draw widgets & caption */
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   172
		SetDParam(0, v->string_id);
2261
3f78323707bb (svn r2781) Fix some of the issues with variables in .h files.
ludde
parents: 2252
diff changeset
   173
		SetDParam(1, v->unitnumber);
6241
6a7a41b0cd32 (svn r8702) [cpp_gui] -Codechange: changed the 3 window functions in widget.cpp into Window methods
bjarni
parents: 6235
diff changeset
   174
		w->DrawWidgets();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   176
		if (v->u.rail.crash_anim_pos != 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
			str = STR_8863_CRASHED;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   178
		} else if (v->breakdown_ctr == 1) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   179
			str = STR_885C_BROKEN_DOWN;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
		} else if (v->vehstatus & VS_STOPPED) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
			if (v->u.rail.last_speed == 0) {
4251
85befcd5f435 (svn r5853) -Fix: [elrails] FS#178 Electric Trains can leave Conventional Depot
bjarni
parents: 4171
diff changeset
   182
				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
   183
					str = STR_TRAIN_NO_POWER;
85befcd5f435 (svn r5853) -Fix: [elrails] FS#178 Electric Trains can leave Conventional Depot
bjarni
parents: 4171
diff changeset
   184
				} else {
85befcd5f435 (svn r5853) -Fix: [elrails] FS#178 Electric Trains can leave Conventional Depot
bjarni
parents: 4171
diff changeset
   185
					str = STR_8861_STOPPED;
85befcd5f435 (svn r5853) -Fix: [elrails] FS#178 Electric Trains can leave Conventional Depot
bjarni
parents: 4171
diff changeset
   186
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
			} else {
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
   188
				SetDParam(0, v->u.rail.last_speed * 10 / 16);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
				str = STR_TRAIN_STOPPING + _patches.vehicle_speed;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   190
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
		} else {
555
eec6c0294435 (svn r955) Replace uint16 for orders with struct Order
tron
parents: 543
diff changeset
   192
			switch (v->current_order.type) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   193
			case OT_GOTO_STATION: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   194
				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
   195
				SetDParam(0, v->current_order.dest);
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
   196
				SetDParam(1, v->u.rail.last_speed * 10 / 16);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   197
			} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   198
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   199
			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
   200
				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
   201
				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
   202
				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
   203
					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
   204
				} else {
945e8a9bb89a (svn r6165) -Feature: control click Goto Depot will now make the vehicle service
bjarni
parents: 4408
diff changeset
   205
					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
   206
				}
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
   207
				SetDParam(1, v->u.rail.last_speed * 10 / 16);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
			} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   209
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   210
			case OT_LOADING:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   211
			case OT_LEAVESTATION:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   212
				str = STR_882F_LOADING_UNLOADING;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   213
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   214
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
   215
			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
   216
				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
   217
				str = STR_HEADING_FOR_WAYPOINT + _patches.vehicle_speed;
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
   218
				SetDParam(1, v->u.rail.last_speed * 10 / 16);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   219
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   220
			}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   221
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
			default:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   223
				if (v->num_orders == 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   224
					str = STR_NO_ORDERS + _patches.vehicle_speed;
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
   225
					SetDParam(0, v->u.rail.last_speed * 10 / 16);
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4049
diff changeset
   226
				} else {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
					str = STR_EMPTY;
4077
d3022f976946 (svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents: 4049
diff changeset
   228
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   229
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   230
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   231
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   232
2103
9266bb2ac29d (svn r2613) - Truncate savegames, and vehicle-texts in their window.
Darkvater
parents: 2084
diff changeset
   233
		/* 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
   234
		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
   235
		DrawStringCenteredTruncated(w->widget[5].left + 8, w->widget[5].right, w->widget[5].top + 1, str, 0);
6244
4b42fb40e6d2 (svn r8710) [cpp_gui] -Codechange: yet another two functions are turned into Window methods
bjarni
parents: 6241
diff changeset
   236
		w->DrawViewport();
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6307
diff changeset
   237
	} break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   238
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   239
	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
   240
		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
   241
		Vehicle *v = GetVehicle(w->window_number);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   242
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2951
diff changeset
   243
		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
   244
		case 5: /* start/stop train */
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   245
			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
   246
			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
   247
		case 6: /* center main view */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   248
			ScrollMainWindowTo(v->x_pos, v->y_pos);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   249
			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
   250
		case 7: /* goto depot */
601
952c0295f79a (svn r1025) -Fix: [Network] [ 1083687 ] Sending to depot caused desync because the
truelight
parents: 588
diff changeset
   251
			/* 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
   252
			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
   253
			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
   254
		case 8: /* force proceed */
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   255
			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
   256
			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
   257
		case 9: /* reverse direction */
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   258
			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
   259
			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
   260
		case 10: /* show train orders */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   261
			ShowOrdersWindow(v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   262
			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
   263
		case 11: /* show train details */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   264
			ShowTrainDetailsWindow(v);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   265
			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
   266
		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
   267
			ShowVehicleRefitWindow(v, INVALID_VEH_ORDER_ID);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
			break;
2244
e6b5ef68406d (svn r2764) -Feature: Clone vehicles
bjarni
parents: 2186
diff changeset
   269
		case 13:
e6b5ef68406d (svn r2764) -Feature: Clone vehicles
bjarni
parents: 2186
diff changeset
   270
			DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, NULL, CMD_CLONE_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE));
e6b5ef68406d (svn r2764) -Feature: Clone vehicles
bjarni
parents: 2186
diff changeset
   271
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   272
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   273
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   274
1485
a2f36708c260 (svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents: 1402
diff changeset
   275
	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
   276
		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
   277
		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
   278
		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
   279
		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
   280
		break;
a2f36708c260 (svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents: 1402
diff changeset
   281
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   282
	case WE_DESTROY:
338
04ad3e897bf8 (svn r514) -Fix: [1053397] Refit Train Window Stays Open
tron
parents: 243
diff changeset
   283
		DeleteWindowById(WC_VEHICLE_REFIT, w->window_number);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   284
		DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   285
		DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   286
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   287
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   288
	case WE_MOUSELOOP: {
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4088
diff changeset
   289
		const Vehicle *v = GetVehicle(w->window_number);
4702
5179f9adc5b3 (svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents: 4668
diff changeset
   290
		bool train_stopped = CheckTrainStoppedInDepot(v)  >= 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6253
diff changeset
   292
		/* OldWidget 7 (send to depot) must be hidden if the train is already stopped in hangar.
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6253
diff changeset
   293
		 * OldWidget 13 (clone) should then be shown, since cloning is allowed only while in depot and stopped.
4702
5179f9adc5b3 (svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents: 4668
diff changeset
   294
		 * 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
   295
		 * The same system applies to widget 9 and 12, reverse direction and refit*/
6250
5135b200b376 (svn r8718) [cpp_gui] -Codechange: SetWindowWidgetHiddenState(), HideWindowWidget(), ShowWindowWidget() and IsWindowWidgetHidden() turned into Window methods
KUDr
parents: 6247
diff changeset
   296
		if (train_stopped != w->IsWidgetHidden(7) || train_stopped == w->IsWidgetHidden(13)) {
5135b200b376 (svn r8718) [cpp_gui] -Codechange: SetWindowWidgetHiddenState(), HideWindowWidget(), ShowWindowWidget() and IsWindowWidgetHidden() turned into Window methods
KUDr
parents: 6247
diff changeset
   297
			w->SetWidgetHiddenState( 7, train_stopped);  // send to depot
5135b200b376 (svn r8718) [cpp_gui] -Codechange: SetWindowWidgetHiddenState(), HideWindowWidget(), ShowWindowWidget() and IsWindowWidgetHidden() turned into Window methods
KUDr
parents: 6247
diff changeset
   298
			w->SetWidgetHiddenState( 9, train_stopped);  // reverse direction
5135b200b376 (svn r8718) [cpp_gui] -Codechange: SetWindowWidgetHiddenState(), HideWindowWidget(), ShowWindowWidget() and IsWindowWidgetHidden() turned into Window methods
KUDr
parents: 6247
diff changeset
   299
			w->SetWidgetHiddenState(12, !train_stopped); // refit
5135b200b376 (svn r8718) [cpp_gui] -Codechange: SetWindowWidgetHiddenState(), HideWindowWidget(), ShowWindowWidget() and IsWindowWidgetHidden() turned into Window methods
KUDr
parents: 6247
diff changeset
   300
			w->SetWidgetHiddenState(13, !train_stopped); // clone
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6144
diff changeset
   301
			w->SetDirty();
0
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
		break;
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
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   307
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   308
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   309
static const WindowDesc _train_view_desc = {
5070
0bbf5264bfb7 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 4939
diff changeset
   310
	WDP_AUTO, WDP_AUTO, 250, 134,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6125
diff changeset
   311
	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
   312
	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
   313
	_train_view_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   314
	TrainViewWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4088
diff changeset
   317
void ShowTrainViewWindow(const Vehicle *v)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   318
{
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6253
diff changeset
   319
	BaseWindow *w = BaseWindow::AllocateFront(&_train_view_desc,v->index);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   320
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
   321
	if (w != NULL) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   322
		w->caption_color = v->owner;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
		AssignWindowViewport(w, 3, 17, 0xE2, 0x66, w->window_number | (1 << 31), 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   324
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   326
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
   327
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
   328
{
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   329
	if (v->cargo_cap != 0) {
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   330
		uint num = v->cargo_count;
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   331
		StringID str = STR_8812_EMPTY;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   332
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   333
		if (num != 0) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   334
			SetDParam(0, v->cargo_type);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   335
			SetDParam(1, num);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   336
			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
   337
			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
   338
			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
   339
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   340
		DrawString(x, y, str, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   341
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   342
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   343
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
   344
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
   345
{
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
   346
	if (RailVehInfo(v->engine_type)->railveh_type == RAILVEH_WAGON) {
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   347
		SetDParam(0, GetCustomEngineName(v->engine_type));
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   348
		SetDParam(1, v->value);
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   349
		DrawString(x, y, STR_882D_VALUE, 0x10);
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   350
	} else {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   351
		SetDParam(0, GetCustomEngineName(v->engine_type));
4329
9759d5c52010 (svn r6002) -Cleanup: remove the now redundant BASE_YEAR constant.
rubidium
parents: 4299
diff changeset
   352
		SetDParam(1, v->build_year);
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   353
		SetDParam(2, v->value);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   354
		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
   355
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   356
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   357
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
   358
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
   359
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   360
	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
   361
		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
   362
		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
   363
		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
   364
		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
   365
	}
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   368
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6253
diff changeset
   369
static void DrawTrainDetailsWindow(BaseWindow *w)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   370
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   371
	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
   372
	const Vehicle *v;
d1f4e447a7eb (svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents: 5163
diff changeset
   373
	const Vehicle *u;
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   374
	AcceptedCargo act_cargo;
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   375
	AcceptedCargo max_cargo;
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   376
	int num;
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   377
	int x;
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   378
	int y;
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   379
	int sel;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   380
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   381
	num = 0;
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 914
diff changeset
   382
	u = v = GetVehicle(w->window_number);
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   383
	if (det_tab == 3) { // Total cargo tab
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   384
		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
   385
			act_cargo[i] = 0;
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   386
			max_cargo[i] = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   387
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   388
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   389
		do {
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   390
			act_cargo[u->cargo_type] += u->cargo_count;
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   391
			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
   392
		} while ((u = u->next) != NULL);
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   393
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   394
		/* 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
   395
		 * for more carriages of the same type
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   396
		 */
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   397
		for (CargoID i = 0; i < NUM_CARGO; i++) {
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   398
			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
   399
		}
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
   400
		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
   401
	} else {
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   402
		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
   403
			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
   404
		} while ((u = u->next) != NULL);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   405
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   406
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   407
	SetVScrollCount(w, num);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   408
6247
67e881450cf3 (svn r8714) [cpp_gui] -Codechange: DisableWindowWidget() and EnableWindowWidget() turned into Window methods
KUDr
parents: 6246
diff changeset
   409
	w->DisableWidget(det_tab + 9);
6246
2a4c2c4d66f0 (svn r8713) [cpp_gui] -Codechange: SetWindowWidgetDisabledState turned into Window method
KUDr
parents: 6245
diff changeset
   410
	w->SetWidgetDisabledState(2, v->owner != _local_player);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   411
4709
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4702
diff changeset
   412
	/* disable service-scroller when interval is set to disabled */
6246
2a4c2c4d66f0 (svn r8713) [cpp_gui] -Codechange: SetWindowWidgetDisabledState turned into Window method
KUDr
parents: 6245
diff changeset
   413
	w->SetWidgetDisabledState(6, !_patches.servint_trains);
2a4c2c4d66f0 (svn r8713) [cpp_gui] -Codechange: SetWindowWidgetDisabledState turned into Window method
KUDr
parents: 6245
diff changeset
   414
	w->SetWidgetDisabledState(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
   415
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   416
	SetDParam(0, v->string_id);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   417
	SetDParam(1, v->unitnumber);
6241
6a7a41b0cd32 (svn r8702) [cpp_gui] -Codechange: changed the 3 window functions in widget.cpp into Window methods
bjarni
parents: 6235
diff changeset
   418
	w->DrawWidgets();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   419
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   420
	SetDParam(1, v->age / 366);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   421
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
	x = 2;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   423
2252
37e3ca7014e0 (svn r2772) Simplify the age notice in the vehicle details window
tron
parents: 2244
diff changeset
   424
	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
   425
	SetDParam(2, v->max_age / 366);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   426
	SetDParam(3, GetTrainRunningCost(v) >> 8);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   427
	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
   428
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
   429
	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
   430
	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
   431
	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
   432
	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
   433
	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
   434
		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
   435
		STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   436
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   437
	SetDParam(0, v->profit_this_year);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   438
	SetDParam(1, v->profit_last_year);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   439
	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
   440
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   441
	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
   442
	SetDParam(1, v->breakdowns_since_last_service);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   443
	DrawString(x, 45, STR_8860_RELIABILITY_BREAKDOWNS, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   444
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   445
	SetDParam(0, v->service_interval);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   446
	SetDParam(1, v->date_of_last_service);
2959
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   447
	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
   448
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   449
	y = 57;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   450
	sel = w->vscroll.pos;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   451
6307
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6303
diff changeset
   452
	/* draw the first 3 details tabs */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   453
	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
   454
		x = 1;
2952
6a26eeda9679 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2951
diff changeset
   455
		for (;;) {
2959
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   456
			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
   457
				int dx = 0;
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   458
				int px;
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   459
				int py;
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   460
2602
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 = v;
f0e2dcce3695 (svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
peter1138
parents: 2593
diff changeset
   462
				do {
5919
2b58160d667d (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5852
diff changeset
   463
					SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
2b58160d667d (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5852
diff changeset
   464
					DrawSprite(GetTrainImage(u, 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
   465
					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
   466
					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
   467
				} 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
   468
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   469
				px = x + WagonLengthToPixels(dx) + 2;
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   470
				py = y + 2;
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   471
				switch (det_tab) {
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   472
					default: NOT_REACHED();
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   473
					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
   474
					case 1:
6307
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6303
diff changeset
   475
						/* 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
   476
						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
   477
							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
   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
						break;
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   480
					case 2: TrainDetailsCapacityTab(v, px, py); break;
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   481
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   482
				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
   483
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
				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
   485
			} else {
6307
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6303
diff changeset
   486
				/* 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
   487
				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
   488
					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
   489
				} 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
   490
			}
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   491
			if (v == NULL) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   492
		}
2959
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   493
	} else {
6307
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6303
diff changeset
   494
		/* draw total cargo tab */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   495
		DrawString(x, y + 2, STR_013F_TOTAL_CAPACITY_TEXT, 0);
6303
84c215fc8eb8 (svn r9486) [cpp_gui] -Sync with trunk (r9100:9476)
KUDr
parents: 6298
diff changeset
   496
		for (CargoID i = 0; i < NUM_CARGO; i++) {
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   497
			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
   498
				y += 14;
4492
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   499
				SetDParam(0, i);            // {CARGO} #1
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   500
				SetDParam(1, act_cargo[i]); // {CARGO} #2
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   501
				SetDParam(2, i);            // {SHORTCARGO} #1
f73138c71092 (svn r6277) Clean up the train details drawing routine
tron
parents: 4456
diff changeset
   502
				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
   503
				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
   504
				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
   505
			}
2959
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   506
		}
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   507
		SetDParam(0, v->cargo_feeder_share);
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6263
diff changeset
   508
		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
   509
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   510
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   511
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6253
diff changeset
   512
static void TrainDetailsWndProc(BaseWindow *w, WindowEvent *e)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   513
{
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
   514
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   515
	case WE_PAINT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   516
		DrawTrainDetailsWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   517
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   518
	case WE_CLICK: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   519
		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
   520
		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
   521
		switch (e->we.click.widget) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   522
		case 2: /* name train */
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 914
diff changeset
   523
			v = GetVehicle(w->window_number);
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 524
diff changeset
   524
			SetDParam(0, v->unitnumber);
5682
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5588
diff changeset
   525
			ShowQueryString(v->string_id, 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
   526
			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
   527
		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
   528
			mod = _ctrl_pressed? 5 : 10;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   529
			goto do_change_service_int;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   530
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   531
		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
   532
			mod = _ctrl_pressed? -5 : -10;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   533
do_change_service_int:
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 914
diff changeset
   534
			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
   535
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
   536
			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
   537
			if (mod == v->service_interval) return;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 176
diff changeset
   538
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
   539
			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
   540
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   541
		/* 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
   542
		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
   543
		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
   544
		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
   545
		case 12: // Total cargo
6247
67e881450cf3 (svn r8714) [cpp_gui] -Codechange: DisableWindowWidget() and EnableWindowWidget() turned into Window methods
KUDr
parents: 6246
diff changeset
   546
			w->EnableWidget( 9);
67e881450cf3 (svn r8714) [cpp_gui] -Codechange: DisableWindowWidget() and EnableWindowWidget() turned into Window methods
KUDr
parents: 6246
diff changeset
   547
			w->EnableWidget(10);
67e881450cf3 (svn r8714) [cpp_gui] -Codechange: DisableWindowWidget() and EnableWindowWidget() turned into Window methods
KUDr
parents: 6246
diff changeset
   548
			w->EnableWidget(11);
67e881450cf3 (svn r8714) [cpp_gui] -Codechange: DisableWindowWidget() and EnableWindowWidget() turned into Window methods
KUDr
parents: 6246
diff changeset
   549
			w->EnableWidget(12);
67e881450cf3 (svn r8714) [cpp_gui] -Codechange: DisableWindowWidget() and EnableWindowWidget() turned into Window methods
KUDr
parents: 6246
diff changeset
   550
			w->EnableWidget(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
   551
			WP(w,traindetails_d).tab = e->we.click.widget - 9;
6235
5077e6ed3788 (svn r8683) [cpp_gui] -Codechange: first steps towards OO GUI (together with Bjarni) without changes in the logic
KUDr
parents: 6144
diff changeset
   552
			w->SetDirty();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   553
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   554
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   555
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   556
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
   557
	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
   558
		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
   559
			_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
   560
			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
   561
				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
   562
		}
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
   563
		break;
2959
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   564
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   565
	case WE_RESIZE:
6245
6fa82c6ee8ca (svn r8711) [cpp_gui] -Codechange: even more funktion->method conversions
bjarni
parents: 6244
diff changeset
   566
		if (e->we.sizing.diff.x != 0) w->ResizeButtons(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
   567
		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
   568
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4633
diff changeset
   569
		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
   570
		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
   571
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   572
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   573
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   574
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6253
diff changeset
   575
static const OldWidget _train_details_widgets[] = {
2959
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   576
{   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
   577
{    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
   578
{ 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
   579
{      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
   580
{     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
   581
{  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
   582
{ 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
   583
{ 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
   584
{      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
   585
{ 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
   586
{ 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
   587
{ 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
   588
{ 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
   589
{  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
   590
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   591
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   592
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   593
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   594
static const WindowDesc _train_details_desc = {
5070
0bbf5264bfb7 (svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents: 4939
diff changeset
   595
	WDP_AUTO, WDP_AUTO, 370, 164,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   596
	WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW,
2959
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   597
	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
   598
	_train_details_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   599
	TrainDetailsWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   600
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   601
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   602
4171
3fadda3afe70 (svn r5609) CodeChange : Apply coding style
belugas
parents: 4088
diff changeset
   603
static void ShowTrainDetailsWindow(const Vehicle *v)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   604
{
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6253
diff changeset
   605
	BaseWindow *w;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   606
	VehicleID veh = v->index;
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
	DeleteWindowById(WC_VEHICLE_ORDERS, veh);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   609
	DeleteWindowById(WC_VEHICLE_DETAILS, veh);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   610
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents: 6253
diff changeset
   611
	w = BaseWindow::AllocateFront(&_train_details_desc, veh);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   612
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   613
	w->caption_color = v->owner;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   614
	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
   615
	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
   616
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   617
	w->resize.step_height = 14;
6263
19dab6a68886 (svn r8913) [cpp_gui] -Codechange: use BaseWindow accessors instead of accessing window size/position directly
KUDr
parents: 6258
diff changeset
   618
	w->resize.height = w->Height() - 14 * 2; /* Minimum of 4 wagons in the display */
2959
940962dab788 (svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents: 2958
diff changeset
   619
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   620
	WP(w,traindetails_d).tab = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   621
}