author | bjarni |
Wed, 24 Jan 2007 14:32:20 +0000 | |
changeset 5824 | 8398b44ad3bc |
parent 5822 | f71317de4ab6 |
child 5868 | 94430141c189 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1820
diff
changeset
|
4 |
#include "openttd.h" |
1299
39c06aba09aa
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1294
diff
changeset
|
5 |
#include "debug.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2147
diff
changeset
|
6 |
#include "functions.h" |
1922
bda6f85eefaa
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
7 |
#include "table/sprites.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
460
diff
changeset
|
8 |
#include "table/strings.h" |
0 | 9 |
#include "window.h" |
10 |
#include "gui.h" |
|
11 |
#include "vehicle.h" |
|
12 |
#include "viewport.h" |
|
13 |
#include "command.h" |
|
588 | 14 |
#include "vehicle_gui.h" |
1313
f1013ec3d318
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
15 |
#include "depot.h" |
2676
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
2639
diff
changeset
|
16 |
#include "train.h" |
2962
f0a49b646c48
(svn r3524) - Split newgrf features from engine.[ch] into newgrf_engine.[ch], and add the new files to project files.
peter1138
parents:
2959
diff
changeset
|
17 |
#include "newgrf_engine.h" |
0 | 18 |
|
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
19 |
void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 20 |
{ |
4171 | 21 |
Vehicle *v, *found; |
0 | 22 |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4049
diff
changeset
|
23 |
if (!success) return; |
0 | 24 |
|
25 |
// find a locomotive in the depot. |
|
26 |
found = NULL; |
|
27 |
FOR_ALL_VEHICLES(v) { |
|
2676
59b65b4fb480
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
2639
diff
changeset
|
28 |
if (v->type == VEH_Train && IsFrontEngine(v) && |
0 | 29 |
v->tile == tile && |
30 |
v->u.rail.track == 0x80) { |
|
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4049
diff
changeset
|
31 |
if (found != NULL) return; // must be exactly one. |
0 | 32 |
found = v; |
33 |
} |
|
34 |
} |
|
35 |
||
36 |
// if we found a loco, |
|
37 |
if (found != NULL) { |
|
38 |
found = GetLastVehicleInChain(found); |
|
39 |
// put the new wagon at the end of the loco. |
|
3948
a09379beffd5
(svn r5094) Remove _new_{aircraft,roadveh,ship,train,wagon}_id. _new_vehicle_id is enough.
tron
parents:
3919
diff
changeset
|
40 |
DoCommandP(0, _new_vehicle_id | (found->index << 16), 0, NULL, CMD_MOVE_RAIL_VEHICLE); |
588 | 41 |
RebuildVehicleLists(); |
0 | 42 |
} |
43 |
} |
|
44 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
45 |
void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 46 |
{ |
4171 | 47 |
const Vehicle *v; |
0 | 48 |
|
2639 | 49 |
if (!success) return; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
50 |
|
3948
a09379beffd5
(svn r5094) Remove _new_{aircraft,roadveh,ship,train,wagon}_id. _new_vehicle_id is enough.
tron
parents:
3919
diff
changeset
|
51 |
v = GetVehicle(_new_vehicle_id); |
0 | 52 |
if (tile == _backup_orders_tile) { |
53 |
_backup_orders_tile = 0; |
|
54 |
RestoreVehicleOrders(v, _backup_orders_data); |
|
55 |
} |
|
56 |
ShowTrainViewWindow(v); |
|
57 |
} |
|
58 |
||
3887
ece644bbf459
(svn r4943) uint tile -> TileIndex tile, byte player -> PlayerID player
tron
parents:
3884
diff
changeset
|
59 |
void CcCloneTrain(bool success, TileIndex tile, uint32 p1, uint32 p2) |
2244 | 60 |
{ |
3948
a09379beffd5
(svn r5094) Remove _new_{aircraft,roadveh,ship,train,wagon}_id. _new_vehicle_id is enough.
tron
parents:
3919
diff
changeset
|
61 |
if (success) ShowTrainViewWindow(GetVehicle(_new_vehicle_id)); |
2244 | 62 |
} |
5187
12dc9dfa6af6
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5163
diff
changeset
|
63 |
|
2593
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
peter1138
parents:
2570
diff
changeset
|
64 |
/** |
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
peter1138
parents:
2570
diff
changeset
|
65 |
* Get the number of pixels for the given wagon length. |
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
peter1138
parents:
2570
diff
changeset
|
66 |
* @param len Length measured in 1/8ths of a standard wagon. |
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
peter1138
parents:
2570
diff
changeset
|
67 |
* @return Number of pixels across. |
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
peter1138
parents:
2570
diff
changeset
|
68 |
*/ |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
4635
diff
changeset
|
69 |
int WagonLengthToPixels(int len) { |
3845
af6eb0103fed
(svn r4869) - NewGRF: support setting train list vehicle width to 32 instead of 29 pixels, for sets which use 32 pixel long engines/wagons.
peter1138
parents:
3844
diff
changeset
|
70 |
return (len * _traininfo_vehicle_width) / 8; |
2593
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
peter1138
parents:
2570
diff
changeset
|
71 |
} |
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
peter1138
parents:
2570
diff
changeset
|
72 |
|
4442
9f8bb348d58f
(svn r6215) -Codechange: [vehicle list windows] unified Player(vehicle)WndProc into PlayerVehWndProc
bjarni
parents:
4434
diff
changeset
|
73 |
void DrawTrainImage(const Vehicle *v, int x, int y, int count, int skip, VehicleID selection) |
0 | 74 |
{ |
3919
b64f70fcca85
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
75 |
DrawPixelInfo tmp_dpi, *old_dpi; |
b64f70fcca85
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
76 |
int dx = -(skip * 8) / _traininfo_vehicle_width; |
4049
d65bf8f154bc
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
77 |
/* Position of highlight box */ |
d65bf8f154bc
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
78 |
int highlight_l = 0; |
d65bf8f154bc
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
79 |
int highlight_r = 0; |
3919
b64f70fcca85
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
80 |
|
4429
b4eb6d97996f
(svn r6184) Remove the unused (because it was NULL in all callers) second parameter of FillDrawPixelInfo() and simplify some expressions
tron
parents:
4426
diff
changeset
|
81 |
if (!FillDrawPixelInfo(&tmp_dpi, x - 2, y - 1, count + 1, 14)) return; |
3919
b64f70fcca85
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
82 |
|
b64f70fcca85
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
83 |
count = (count * 8) / _traininfo_vehicle_width; |
b64f70fcca85
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
84 |
|
b64f70fcca85
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
85 |
old_dpi = _cur_dpi; |
b64f70fcca85
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
86 |
_cur_dpi = &tmp_dpi; |
1922
bda6f85eefaa
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
87 |
|
0 | 88 |
do { |
3919
b64f70fcca85
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
89 |
int width = v->u.rail.cached_veh_length; |
1922
bda6f85eefaa
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
90 |
|
3919
b64f70fcca85
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
91 |
if (dx + width > 0) { |
b64f70fcca85
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
92 |
if (dx <= count) { |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
93 |
SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
94 |
DrawSprite(GetTrainImage(v, DIR_W), pal, 16 + WagonLengthToPixels(dx), 7 + (is_custom_sprite(RailVehInfo(v->engine_type)->image_index) ? _traininfo_vehicle_pitch : 0)); |
4049
d65bf8f154bc
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
95 |
if (v->index == selection) { |
d65bf8f154bc
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
96 |
/* Set the highlight position */ |
d65bf8f154bc
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
97 |
highlight_l = WagonLengthToPixels(dx) + 1; |
d65bf8f154bc
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
98 |
highlight_r = WagonLengthToPixels(dx + width) + 1; |
d65bf8f154bc
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
99 |
} |
1922
bda6f85eefaa
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
100 |
} |
0 | 101 |
} |
3919
b64f70fcca85
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
102 |
dx += width; |
0 | 103 |
|
2593
ccb101f0439c
(svn r3130) Calculate shorter wagon lengths more precisely in train depot window. This affects wagon position, the scroll bar, and the train length counter. No trial and error is required to get the correct length now.
peter1138
parents:
2570
diff
changeset
|
104 |
v = v->next; |
3919
b64f70fcca85
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
105 |
} while (dx < count && v != NULL); |
b64f70fcca85
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
106 |
|
4049
d65bf8f154bc
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
107 |
if (highlight_l != highlight_r) { |
d65bf8f154bc
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
108 |
/* Draw the highlight. Now done after drawing all the engines, as |
d65bf8f154bc
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
109 |
* the next engine after the highlight could overlap it. */ |
d65bf8f154bc
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
110 |
DrawFrameRect(highlight_l, 0, highlight_r, 13, 15, FR_BORDERONLY); |
d65bf8f154bc
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
111 |
} |
d65bf8f154bc
(svn r5318) - Allow room for a single pixel overflow on the first engine when drawing a train's image.
peter1138
parents:
4041
diff
changeset
|
112 |
|
3919
b64f70fcca85
(svn r5046) - Implement smooth horizontal depot scrolling by setting up a clipping area to draw the train image. This fixes a couple of usability issues when shorter wagons are used in the depot; shorter wagons scrolled at a different speed, and not all wagons were visible sometimes.
peter1138
parents:
3887
diff
changeset
|
113 |
_cur_dpi = old_dpi; |
0 | 114 |
} |
115 |
||
2275
11a1dac70c45
(svn r2799) Make the only two non-const widget lists const
tron
parents:
2261
diff
changeset
|
116 |
static const Widget _train_view_widgets[] = { |
4937
8cfdd86fd709
(svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents:
4933
diff
changeset
|
117 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW }, |
8cfdd86fd709
(svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents:
4933
diff
changeset
|
118 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 237, 0, 13, STR_882E, STR_018C_WINDOW_TITLE_DRAG_THIS }, |
8cfdd86fd709
(svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents:
4933
diff
changeset
|
119 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 238, 249, 0, 13, 0x0, STR_STICKY_BUTTON }, |
8cfdd86fd709
(svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents:
4933
diff
changeset
|
120 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 231, 14, 121, 0x0, STR_NULL }, |
4939
bef7c24a6027
(svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents:
4938
diff
changeset
|
121 |
{ WWT_INSET, RESIZE_RB, 14, 2, 229, 16, 119, 0x0, STR_NULL }, |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4937
diff
changeset
|
122 |
{ WWT_PUSHBTN, RESIZE_RTB, 14, 0, 237, 122, 133, 0x0, STR_8846_CURRENT_TRAIN_ACTION_CLICK }, |
4937
8cfdd86fd709
(svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents:
4933
diff
changeset
|
123 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 14, 31, SPR_CENTRE_VIEW_VEHICLE, STR_8848_CENTER_MAIN_VIEW_ON_TRAIN }, |
8cfdd86fd709
(svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents:
4933
diff
changeset
|
124 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, SPR_SEND_TRAIN_TODEPOT, STR_8849_SEND_TRAIN_TO_DEPOT }, |
8cfdd86fd709
(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, 50, 67, SPR_IGNORE_SIGNALS, STR_884A_FORCE_TRAIN_TO_PROCEED }, |
8cfdd86fd709
(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, 68, 85, SPR_FORCE_VEHICLE_TURN, STR_884B_REVERSE_DIRECTION_OF_TRAIN }, |
8cfdd86fd709
(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, 86, 103, SPR_SHOW_ORDERS, STR_8847_SHOW_TRAIN_S_ORDERS }, |
8cfdd86fd709
(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, 104, 121, SPR_SHOW_VEHICLE_DETAILS,STR_884C_SHOW_TRAIN_DETAILS }, |
8cfdd86fd709
(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, 68, 85, SPR_REFIT_VEHICLE, STR_RAIL_REFIT_VEHICLE_TO_CARRY }, |
8cfdd86fd709
(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, 32, 49, SPR_CLONE_TRAIN, STR_CLONE_TRAIN_INFO }, |
8cfdd86fd709
(svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents:
4933
diff
changeset
|
131 |
{ WWT_PANEL, RESIZE_LRB, 14, 232, 249, 122, 121, 0x0, STR_NULL }, |
8cfdd86fd709
(svn r6924) -Codechange: Give the last (in the widget arrays at least) sprites meaningful names.
Darkvater
parents:
4933
diff
changeset
|
132 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 238, 249, 122, 133, 0x0, STR_NULL }, |
1485
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
133 |
{ WIDGETS_END } |
0 | 134 |
}; |
135 |
||
4171 | 136 |
static void ShowTrainDetailsWindow(const Vehicle *v); |
2561
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
137 |
|
0 | 138 |
static void TrainViewWndProc(Window *w, WindowEvent *e) |
139 |
{ |
|
1802
da61740cc1e7
(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
|
140 |
switch (e->event) { |
0 | 141 |
case WE_PAINT: { |
1802
da61740cc1e7
(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 |
const Vehicle *v, *u; |
0 | 143 |
StringID str; |
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
144 |
bool is_localplayer; |
0 | 145 |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
146 |
v = GetVehicle(w->window_number); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
147 |
|
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
148 |
is_localplayer = v->owner == _local_player; |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
149 |
SetWindowWidgetDisabledState(w, 7, !is_localplayer); |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
150 |
SetWindowWidgetDisabledState(w, 8, !is_localplayer); |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
151 |
SetWindowWidgetDisabledState(w, 9, !is_localplayer); |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
152 |
SetWindowWidgetDisabledState(w, 13, !is_localplayer); |
1387
bc0131072af9
(svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents:
1330
diff
changeset
|
153 |
|
4871
5cc1ccb6e43f
(svn r6801) - Fix (r6619): Always disable the train refit button. It will be enabled later if refitting is possible.
peter1138
parents:
4868
diff
changeset
|
154 |
/* Disable cargo refit button, until we know we can enable it below. */ |
5cc1ccb6e43f
(svn r6801) - Fix (r6619): Always disable the train refit button. It will be enabled later if refitting is possible.
peter1138
parents:
4868
diff
changeset
|
155 |
DisableWindowWidget(w, 12); |
5cc1ccb6e43f
(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 |
|
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
157 |
if (is_localplayer) { |
2867
91ee491df4ec
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
peter1138
parents:
2840
diff
changeset
|
158 |
/* See if any vehicle can be refitted */ |
91ee491df4ec
(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
|
159 |
for (u = v; u != NULL; u = u->next) { |
3393
c40975f04842
(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
|
160 |
if (EngInfo(u->engine_type)->refit_mask != 0 || |
2867
91ee491df4ec
(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 |
(!(RailVehInfo(v->engine_type)->flags & RVI_WAGON) && v->cargo_cap != 0)) { |
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
162 |
EnableWindowWidget(w, 12); |
2867
91ee491df4ec
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
peter1138
parents:
2840
diff
changeset
|
163 |
/* We have a refittable carriage, bail out */ |
91ee491df4ec
(svn r3415) - Fix: Disable the clone and refit buttons in the train view when viewing another player's vehicles, or as a spectator. (thanks to UnderBuilder for pointing this out)
peter1138
parents:
2840
diff
changeset
|
164 |
break; |
91ee491df4ec
(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 |
} |
1387
bc0131072af9
(svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents:
1330
diff
changeset
|
166 |
} |
bc0131072af9
(svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents:
1330
diff
changeset
|
167 |
} |
bc0131072af9
(svn r1891) -Fix: [ 1143587 ] carriages of newgrfs can be refitted again
celestar
parents:
1330
diff
changeset
|
168 |
|
0 | 169 |
/* draw widgets & caption */ |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
170 |
SetDParam(0, v->string_id); |
2261
d3554e5d3e86
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2252
diff
changeset
|
171 |
SetDParam(1, v->unitnumber); |
0 | 172 |
DrawWindowWidgets(w); |
173 |
||
174 |
if (v->u.rail.crash_anim_pos != 0) { |
|
175 |
str = STR_8863_CRASHED; |
|
176 |
} else if (v->breakdown_ctr == 1) { |
|
177 |
str = STR_885C_BROKEN_DOWN; |
|
178 |
} else if (v->vehstatus & VS_STOPPED) { |
|
179 |
if (v->u.rail.last_speed == 0) { |
|
4251
e8f69de723e1
(svn r5853) -Fix: [elrails] FS#178 Electric Trains can leave Conventional Depot
bjarni
parents:
4171
diff
changeset
|
180 |
if (v->u.rail.cached_power == 0) { |
e8f69de723e1
(svn r5853) -Fix: [elrails] FS#178 Electric Trains can leave Conventional Depot
bjarni
parents:
4171
diff
changeset
|
181 |
str = STR_TRAIN_NO_POWER; |
e8f69de723e1
(svn r5853) -Fix: [elrails] FS#178 Electric Trains can leave Conventional Depot
bjarni
parents:
4171
diff
changeset
|
182 |
} else { |
e8f69de723e1
(svn r5853) -Fix: [elrails] FS#178 Electric Trains can leave Conventional Depot
bjarni
parents:
4171
diff
changeset
|
183 |
str = STR_8861_STOPPED; |
e8f69de723e1
(svn r5853) -Fix: [elrails] FS#178 Electric Trains can leave Conventional Depot
bjarni
parents:
4171
diff
changeset
|
184 |
} |
0 | 185 |
} else { |
3477
4a686a43af8a
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3401
diff
changeset
|
186 |
SetDParam(0, v->u.rail.last_speed); |
0 | 187 |
str = STR_TRAIN_STOPPING + _patches.vehicle_speed; |
188 |
} |
|
189 |
} else { |
|
555
02df8a1b7f33
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
543
diff
changeset
|
190 |
switch (v->current_order.type) { |
0 | 191 |
case OT_GOTO_STATION: { |
192 |
str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; |
|
4527
fa30d19685c2
(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
|
193 |
SetDParam(0, v->current_order.dest); |
3477
4a686a43af8a
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3401
diff
changeset
|
194 |
SetDParam(1, v->u.rail.last_speed); |
0 | 195 |
} break; |
196 |
||
197 |
case OT_GOTO_DEPOT: { |
|
4527
fa30d19685c2
(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
|
198 |
Depot *dep = GetDepot(v->current_order.dest); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
199 |
SetDParam(0, dep->town_index); |
4633
cf6c2f173030
(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
|
200 |
if (HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT) && !HASBIT(v->current_order.flags, OFB_PART_OF_ORDERS)) { |
4412
cae52239a576
(svn r6165) -Feature: control click Goto Depot will now make the vehicle service
bjarni
parents:
4408
diff
changeset
|
201 |
str = STR_HEADING_FOR_TRAIN_DEPOT + _patches.vehicle_speed; |
cae52239a576
(svn r6165) -Feature: control click Goto Depot will now make the vehicle service
bjarni
parents:
4408
diff
changeset
|
202 |
} else { |
cae52239a576
(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_SERVICE + _patches.vehicle_speed; |
cae52239a576
(svn r6165) -Feature: control click Goto Depot will now make the vehicle service
bjarni
parents:
4408
diff
changeset
|
204 |
} |
3477
4a686a43af8a
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3401
diff
changeset
|
205 |
SetDParam(1, v->u.rail.last_speed); |
0 | 206 |
} break; |
207 |
||
208 |
case OT_LOADING: |
|
209 |
case OT_LEAVESTATION: |
|
210 |
str = STR_882F_LOADING_UNLOADING; |
|
211 |
break; |
|
212 |
||
395
788a9bba0889
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
382
diff
changeset
|
213 |
case OT_GOTO_WAYPOINT: { |
4527
fa30d19685c2
(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
|
214 |
SetDParam(0, v->current_order.dest); |
395
788a9bba0889
(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 |
str = STR_HEADING_FOR_WAYPOINT + _patches.vehicle_speed; |
3477
4a686a43af8a
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3401
diff
changeset
|
216 |
SetDParam(1, v->u.rail.last_speed); |
0 | 217 |
break; |
218 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
219 |
|
0 | 220 |
default: |
221 |
if (v->num_orders == 0) { |
|
222 |
str = STR_NO_ORDERS + _patches.vehicle_speed; |
|
3477
4a686a43af8a
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3401
diff
changeset
|
223 |
SetDParam(0, v->u.rail.last_speed); |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4049
diff
changeset
|
224 |
} else { |
0 | 225 |
str = STR_EMPTY; |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4049
diff
changeset
|
226 |
} |
0 | 227 |
break; |
228 |
} |
|
229 |
} |
|
230 |
||
2103
a2b3106d33d5
(svn r2613) - Truncate savegames, and vehicle-texts in their window.
Darkvater
parents:
2084
diff
changeset
|
231 |
/* draw the flag plus orders */ |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
232 |
DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, 2, w->widget[5].top + 1); |
2113
be2f07df0dfa
(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
|
233 |
DrawStringCenteredTruncated(w->widget[5].left + 8, w->widget[5].right, w->widget[5].top + 1, str, 0); |
0 | 234 |
DrawWindowViewport(w); |
235 |
} break; |
|
236 |
||
237 |
case WE_CLICK: { |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
238 |
int wid = e->we.click.widget; |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
239 |
Vehicle *v = GetVehicle(w->window_number); |
0 | 240 |
|
2952 | 241 |
switch (wid) { |
755
80091de50044
(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
|
242 |
case 5: /* start/stop train */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
243 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN)); |
0 | 244 |
break; |
4434
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4429
diff
changeset
|
245 |
case 6: /* center main view */ |
0 | 246 |
ScrollMainWindowTo(v->x_pos, v->y_pos); |
247 |
break; |
|
4434
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4429
diff
changeset
|
248 |
case 7: /* goto depot */ |
601
3d15c18e3a8e
(svn r1025) -Fix: [Network] [ 1083687 ] Sending to depot caused desync because the
truelight
parents:
588
diff
changeset
|
249 |
/* TrainGotoDepot has a nice randomizer in the pathfinder, which causes desyncs... */ |
4506
e6a56518135c
(svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents:
4495
diff
changeset
|
250 |
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 | 251 |
break; |
755
80091de50044
(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
|
252 |
case 8: /* force proceed */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
253 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_FORCE_TRAIN_PROCEED | CMD_MSG(STR_8862_CAN_T_MAKE_TRAIN_PASS_SIGNAL)); |
0 | 254 |
break; |
755
80091de50044
(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
|
255 |
case 9: /* reverse direction */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
256 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_8869_CAN_T_REVERSE_DIRECTION)); |
0 | 257 |
break; |
755
80091de50044
(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
|
258 |
case 10: /* show train orders */ |
0 | 259 |
ShowOrdersWindow(v); |
260 |
break; |
|
755
80091de50044
(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
|
261 |
case 11: /* show train details */ |
0 | 262 |
ShowTrainDetailsWindow(v); |
263 |
break; |
|
755
80091de50044
(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
|
264 |
case 12: |
4712
4335ad42e163
(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
|
265 |
ShowVehicleRefitWindow(v, INVALID_VEH_ORDER_ID); |
0 | 266 |
break; |
2244 | 267 |
case 13: |
268 |
DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, NULL, CMD_CLONE_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE)); |
|
269 |
break; |
|
0 | 270 |
} |
271 |
} break; |
|
272 |
||
1485
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
273 |
case WE_RESIZE: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
274 |
w->viewport->width += e->we.sizing.diff.x; |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
275 |
w->viewport->height += e->we.sizing.diff.y; |
07699ac2bf37
(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->virtual_width += e->we.sizing.diff.x; |
07699ac2bf37
(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->virtual_height += e->we.sizing.diff.y; |
1485
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
278 |
break; |
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
279 |
|
0 | 280 |
case WE_DESTROY: |
338
37500d4214f3
(svn r514) -Fix: [1053397] Refit Train Window Stays Open
tron
parents:
243
diff
changeset
|
281 |
DeleteWindowById(WC_VEHICLE_REFIT, w->window_number); |
0 | 282 |
DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number); |
283 |
DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number); |
|
284 |
break; |
|
285 |
||
286 |
case WE_MOUSELOOP: { |
|
4171 | 287 |
const Vehicle *v = GetVehicle(w->window_number); |
4702
c79e9d9f27b3
(svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents:
4668
diff
changeset
|
288 |
bool train_stopped = CheckTrainStoppedInDepot(v) >= 0; |
0 | 289 |
|
4702
c79e9d9f27b3
(svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents:
4668
diff
changeset
|
290 |
/* Widget 7 (send to depot) must be hidden if the train is already stopped in hangar. |
c79e9d9f27b3
(svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents:
4668
diff
changeset
|
291 |
* Widget 13 (clone) should then be shown, since cloning is allowed only while in depot and stopped. |
c79e9d9f27b3
(svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents:
4668
diff
changeset
|
292 |
* This sytem allows to have two buttons, on top of each other. |
c79e9d9f27b3
(svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents:
4668
diff
changeset
|
293 |
* The same system applies to widget 9 and 12, reverse direction and refit*/ |
c79e9d9f27b3
(svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents:
4668
diff
changeset
|
294 |
if (train_stopped != IsWindowWidgetHidden(w, 7) || train_stopped == IsWindowWidgetHidden(w, 13)) { |
c79e9d9f27b3
(svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents:
4668
diff
changeset
|
295 |
SetWindowWidgetHiddenState(w, 7, train_stopped); // send to depot |
c79e9d9f27b3
(svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents:
4668
diff
changeset
|
296 |
SetWindowWidgetHiddenState(w, 9, train_stopped); // reverse direction |
c79e9d9f27b3
(svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents:
4668
diff
changeset
|
297 |
SetWindowWidgetHiddenState(w, 12, !train_stopped); // refit |
c79e9d9f27b3
(svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents:
4668
diff
changeset
|
298 |
SetWindowWidgetHiddenState(w, 13, !train_stopped); // clone |
0 | 299 |
SetWindowDirty(w); |
300 |
} |
|
301 |
break; |
|
302 |
} |
|
303 |
||
304 |
} |
|
305 |
} |
|
306 |
||
307 |
static const WindowDesc _train_view_desc = { |
|
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
4939
diff
changeset
|
308 |
WDP_AUTO, WDP_AUTO, 250, 134, |
0 | 309 |
WC_VEHICLE_VIEW,0, |
1485
34545d21c656
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1402
diff
changeset
|
310 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 311 |
_train_view_widgets, |
312 |
TrainViewWndProc |
|
313 |
}; |
|
314 |
||
4171 | 315 |
void ShowTrainViewWindow(const Vehicle *v) |
0 | 316 |
{ |
4171 | 317 |
Window *w = AllocateWindowDescFront(&_train_view_desc,v->index); |
0 | 318 |
|
2561
233dafd7cf6c
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
319 |
if (w != NULL) { |
0 | 320 |
w->caption_color = v->owner; |
321 |
AssignWindowViewport(w, 3, 17, 0xE2, 0x66, w->window_number | (1 << 31), 0); |
|
322 |
} |
|
323 |
} |
|
324 |
||
1790
47963a0cfca3
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1658
diff
changeset
|
325 |
static void TrainDetailsCargoTab(const Vehicle *v, int x, int y) |
0 | 326 |
{ |
4492
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
327 |
if (v->cargo_cap != 0) { |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
328 |
uint num = v->cargo_count; |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
329 |
StringID str = STR_8812_EMPTY; |
0 | 330 |
|
331 |
if (num != 0) { |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
332 |
SetDParam(0, v->cargo_type); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
333 |
SetDParam(1, num); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
334 |
SetDParam(2, v->cargo_source); |
5163
459b243f8413
(svn r7269) -Feature: Add freight trains patch option. This option is a multiplier for the weight of cargo on freight trains, to simulate longer heavier trains. The default value of 1 behaves as before.
peter1138
parents:
5124
diff
changeset
|
335 |
SetDParam(3, _patches.freight_trains); |
5316
27fa85736f8a
(svn r7473) -Fix (r7269): Pass a cargo type to determine the freight weight
peter1138
parents:
5273
diff
changeset
|
336 |
str = FreightWagonMult(v->cargo_type) > 1 ? STR_FROM_MULT : STR_8813_FROM; |
0 | 337 |
} |
338 |
DrawString(x, y, str, 0); |
|
339 |
} |
|
340 |
} |
|
341 |
||
1790
47963a0cfca3
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1658
diff
changeset
|
342 |
static void TrainDetailsInfoTab(const Vehicle *v, int x, int y) |
0 | 343 |
{ |
4492
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
344 |
if (RailVehInfo(v->engine_type)->flags & RVI_WAGON) { |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
345 |
SetDParam(0, GetCustomEngineName(v->engine_type)); |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
346 |
SetDParam(1, v->value); |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
347 |
DrawString(x, y, STR_882D_VALUE, 0x10); |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
348 |
} else { |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
349 |
SetDParam(0, GetCustomEngineName(v->engine_type)); |
4329
0e6e689f66e7
(svn r6002) -Cleanup: remove the now redundant BASE_YEAR constant.
rubidium
parents:
4299
diff
changeset
|
350 |
SetDParam(1, v->build_year); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
351 |
SetDParam(2, v->value); |
0 | 352 |
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
|
353 |
} |
0 | 354 |
} |
355 |
||
1790
47963a0cfca3
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1658
diff
changeset
|
356 |
static void TrainDetailsCapacityTab(const Vehicle *v, int x, int y) |
0 | 357 |
{ |
358 |
if (v->cargo_cap != 0) { |
|
4896
f86350aaaaa5
(svn r6855) - Codechange: When displaying a "quantity of cargo" string, use the {CARGO} command and supply the cargo type and quantity, instead of manually looking up the cargo type's string.
peter1138
parents:
4871
diff
changeset
|
359 |
SetDParam(0, v->cargo_type); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
360 |
SetDParam(1, v->cargo_cap); |
5163
459b243f8413
(svn r7269) -Feature: Add freight trains patch option. This option is a multiplier for the weight of cargo on freight trains, to simulate longer heavier trains. The default value of 1 behaves as before.
peter1138
parents:
5124
diff
changeset
|
361 |
SetDParam(2, _patches.freight_trains); |
5316
27fa85736f8a
(svn r7473) -Fix (r7269): Pass a cargo type to determine the freight weight
peter1138
parents:
5273
diff
changeset
|
362 |
DrawString(x, y, FreightWagonMult(v->cargo_type) > 1 ? STR_CAPACITY_MULT : STR_013F_CAPACITY, 0); |
0 | 363 |
} |
364 |
} |
|
365 |
||
366 |
||
367 |
static void DrawTrainDetailsWindow(Window *w) |
|
368 |
{ |
|
369 |
byte det_tab = WP(w, traindetails_d).tab; |
|
5187
12dc9dfa6af6
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5163
diff
changeset
|
370 |
const Vehicle *v; |
12dc9dfa6af6
(svn r7299) -CodeChange: Train and Aircraft Build window GUI code simplified a bit:
KUDr
parents:
5163
diff
changeset
|
371 |
const Vehicle *u; |
4492
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
372 |
AcceptedCargo act_cargo; |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
373 |
AcceptedCargo max_cargo; |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
374 |
uint i; |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
375 |
int num; |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
376 |
int x; |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
377 |
int y; |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
378 |
int sel; |
0 | 379 |
|
380 |
num = 0; |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
381 |
u = v = GetVehicle(w->window_number); |
4492
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
382 |
if (det_tab == 3) { // Total cargo tab |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
383 |
for (i = 0; i < lengthof(act_cargo); i++) { |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
384 |
act_cargo[i] = 0; |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
385 |
max_cargo[i] = 0; |
0 | 386 |
} |
387 |
||
4492
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
388 |
do { |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
389 |
act_cargo[u->cargo_type] += u->cargo_count; |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
390 |
max_cargo[u->cargo_type] += u->cargo_cap; |
4868
846811004d30
(svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents:
4836
diff
changeset
|
391 |
} while ((u = u->next) != NULL); |
4492
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
392 |
|
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
393 |
/* Set scroll-amount seperately from counting, as to not compute num double |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
394 |
* for more carriages of the same type |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
395 |
*/ |
0 | 396 |
for (i = 0; i != NUM_CARGO; i++) { |
4492
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
397 |
if (max_cargo[i] > 0) num++; // only count carriages that the train has |
0 | 398 |
} |
4434
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4429
diff
changeset
|
399 |
num++; // needs one more because first line is description string |
4492
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
400 |
} else { |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
401 |
do { |
4868
846811004d30
(svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents:
4836
diff
changeset
|
402 |
if (!IsArticulatedPart(u) || u->cargo_cap != 0) num++; |
846811004d30
(svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents:
4836
diff
changeset
|
403 |
} while ((u = u->next) != NULL); |
0 | 404 |
} |
405 |
||
406 |
SetVScrollCount(w, num); |
|
407 |
||
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
408 |
DisableWindowWidget(w, det_tab + 9); |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
409 |
SetWindowWidgetDisabledState(w, 2, v->owner != _local_player); |
0 | 410 |
|
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
411 |
/* disable service-scroller when interval is set to disabled */ |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
412 |
SetWindowWidgetDisabledState(w, 6, !_patches.servint_trains); |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
413 |
SetWindowWidgetDisabledState(w, 7, !_patches.servint_trains); |
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
22
diff
changeset
|
414 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
415 |
SetDParam(0, v->string_id); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
416 |
SetDParam(1, v->unitnumber); |
0 | 417 |
DrawWindowWidgets(w); |
418 |
||
4492
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
419 |
SetDParam(1, v->age / 366); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
420 |
|
0 | 421 |
x = 2; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
422 |
|
2252
6df2bfd7a077
(svn r2772) Simplify the age notice in the vehicle details window
tron
parents:
2244
diff
changeset
|
423 |
SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
424 |
SetDParam(2, v->max_age / 366); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
425 |
SetDParam(3, GetTrainRunningCost(v) >> 8); |
0 | 426 |
DrawString(x, 15, STR_885D_AGE_RUNNING_COST_YR, 0); |
427 |
||
3477
4a686a43af8a
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3401
diff
changeset
|
428 |
SetDParam(2, v->u.rail.cached_max_speed); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
429 |
SetDParam(1, v->u.rail.cached_power); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
430 |
SetDParam(0, v->u.rail.cached_weight); |
5400
bba42ad3223b
(svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents:
5316
diff
changeset
|
431 |
SetDParam(3, v->u.rail.cached_max_te / 1000); |
bba42ad3223b
(svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents:
5316
diff
changeset
|
432 |
DrawString(x, 25, (_patches.realistic_acceleration && v->u.rail.railtype != RAILTYPE_MAGLEV) ? |
bba42ad3223b
(svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents:
5316
diff
changeset
|
433 |
STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE : |
bba42ad3223b
(svn r7592) -Feature: Add support for tractive effort to 'realistic' acceleration.
peter1138
parents:
5316
diff
changeset
|
434 |
STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED, 0); |
0 | 435 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
436 |
SetDParam(0, v->profit_this_year); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
437 |
SetDParam(1, v->profit_last_year); |
0 | 438 |
DrawString(x, 35, STR_885F_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
439 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
440 |
SetDParam(0, 100 * (v->reliability>>8) >> 8); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
441 |
SetDParam(1, v->breakdowns_since_last_service); |
0 | 442 |
DrawString(x, 45, STR_8860_RELIABILITY_BREAKDOWNS, 0); |
443 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
444 |
SetDParam(0, v->service_interval); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
445 |
SetDParam(1, v->date_of_last_service); |
2959
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
446 |
DrawString(x + 11, 57 + (w->vscroll.cap * 14), _patches.servint_ispercent ? STR_SERVICING_INTERVAL_PERCENT : STR_883C_SERVICING_INTERVAL_DAYS, 0); |
0 | 447 |
|
448 |
y = 57; |
|
449 |
sel = w->vscroll.pos; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
450 |
|
0 | 451 |
// draw the first 3 details tabs |
452 |
if (det_tab != 3) { |
|
2822
3685b5c83c57
(svn r3370) Improve alignment of text within total cargo tab of train view window
peter1138
parents:
2819
diff
changeset
|
453 |
x = 1; |
2952 | 454 |
for (;;) { |
2959
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
455 |
if (--sel < 0 && sel >= -w->vscroll.cap) { |
2602
1a6561c9a408
(svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
peter1138
parents:
2593
diff
changeset
|
456 |
int dx = 0; |
4492
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
457 |
int px; |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
458 |
int py; |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
459 |
|
2602
1a6561c9a408
(svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
peter1138
parents:
2593
diff
changeset
|
460 |
u = v; |
1a6561c9a408
(svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
peter1138
parents:
2593
diff
changeset
|
461 |
do { |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
462 |
SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5601
diff
changeset
|
463 |
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
1a6561c9a408
(svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
peter1138
parents:
2593
diff
changeset
|
464 |
dx += u->u.rail.cached_veh_length; |
1a6561c9a408
(svn r3139) -NewGRF, Feature: support for articulated rail vehicles. This is used, for example, by coal tenders.
peter1138
parents:
2593
diff
changeset
|
465 |
u = u->next; |
4868
846811004d30
(svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents:
4836
diff
changeset
|
466 |
} while (u != NULL && IsArticulatedPart(u) && u->cargo_cap == 0); |
4492
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
467 |
|
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
468 |
px = x + WagonLengthToPixels(dx) + 2; |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
469 |
py = y + 2; |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
470 |
switch (det_tab) { |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
471 |
default: NOT_REACHED(); |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
472 |
case 0: TrainDetailsCargoTab( v, px, py); break; |
4868
846811004d30
(svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents:
4836
diff
changeset
|
473 |
case 1: |
846811004d30
(svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents:
4836
diff
changeset
|
474 |
// Only show name and value for the 'real' part |
846811004d30
(svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents:
4836
diff
changeset
|
475 |
if (!IsArticulatedPart(v)) { |
846811004d30
(svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents:
4836
diff
changeset
|
476 |
TrainDetailsInfoTab(v, px, py); |
846811004d30
(svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents:
4836
diff
changeset
|
477 |
} |
846811004d30
(svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents:
4836
diff
changeset
|
478 |
break; |
4492
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
479 |
case 2: TrainDetailsCapacityTab(v, px, py); break; |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
480 |
} |
0 | 481 |
y += 14; |
4868
846811004d30
(svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents:
4836
diff
changeset
|
482 |
|
846811004d30
(svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents:
4836
diff
changeset
|
483 |
v = u; |
846811004d30
(svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents:
4836
diff
changeset
|
484 |
} else { |
846811004d30
(svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents:
4836
diff
changeset
|
485 |
// Move to the next line |
846811004d30
(svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents:
4836
diff
changeset
|
486 |
do { |
846811004d30
(svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents:
4836
diff
changeset
|
487 |
v = v->next; |
846811004d30
(svn r6794) - Fix: In the train detail window, split up articulated parts if they can contain cargo. This allows us to show the full cargo contents.
peter1138
parents:
4836
diff
changeset
|
488 |
} while (v != NULL && IsArticulatedPart(v) && v->cargo_cap == 0); |
0 | 489 |
} |
4492
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
490 |
if (v == NULL) return; |
0 | 491 |
} |
2959
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
492 |
} else { |
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
493 |
// draw total cargo tab |
0 | 494 |
DrawString(x, y + 2, STR_013F_TOTAL_CAPACITY_TEXT, 0); |
2959
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
495 |
for (i = 0; i != NUM_CARGO; i++) { |
4492
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
496 |
if (max_cargo[i] > 0 && --sel < 0 && sel > -w->vscroll.cap) { |
0 | 497 |
y += 14; |
4492
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
498 |
SetDParam(0, i); // {CARGO} #1 |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
499 |
SetDParam(1, act_cargo[i]); // {CARGO} #2 |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
500 |
SetDParam(2, i); // {SHORTCARGO} #1 |
7c67249f083c
(svn r6277) Clean up the train details drawing routine
tron
parents:
4456
diff
changeset
|
501 |
SetDParam(3, max_cargo[i]); // {SHORTCARGO} #2 |
5163
459b243f8413
(svn r7269) -Feature: Add freight trains patch option. This option is a multiplier for the weight of cargo on freight trains, to simulate longer heavier trains. The default value of 1 behaves as before.
peter1138
parents:
5124
diff
changeset
|
502 |
SetDParam(4, _patches.freight_trains); |
5316
27fa85736f8a
(svn r7473) -Fix (r7269): Pass a cargo type to determine the freight weight
peter1138
parents:
5273
diff
changeset
|
503 |
DrawString(x, y + 2, FreightWagonMult(i) > 1 ? STR_TOTAL_CAPACITY_MULT : STR_013F_TOTAL_CAPACITY, 0); |
0 | 504 |
} |
2959
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
505 |
} |
0 | 506 |
} |
507 |
} |
|
508 |
||
509 |
static void TrainDetailsWndProc(Window *w, WindowEvent *e) |
|
510 |
{ |
|
1790
47963a0cfca3
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1658
diff
changeset
|
511 |
switch (e->event) { |
0 | 512 |
case WE_PAINT: |
513 |
DrawTrainDetailsWindow(w); |
|
514 |
break; |
|
515 |
case WE_CLICK: { |
|
516 |
int mod; |
|
1790
47963a0cfca3
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1658
diff
changeset
|
517 |
const Vehicle *v; |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
518 |
switch (e->we.click.widget) { |
0 | 519 |
case 2: /* name train */ |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
520 |
v = GetVehicle(w->window_number); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
524
diff
changeset
|
521 |
SetDParam(0, v->unitnumber); |
5431
6e56b4f13dd7
(svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents:
5400
diff
changeset
|
522 |
ShowQueryString(v->string_id, STR_8865_NAME_TRAIN, 31, 150, w, CS_ALPHANUMERAL); |
0 | 523 |
break; |
4434
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4429
diff
changeset
|
524 |
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
|
525 |
mod = _ctrl_pressed? 5 : 10; |
0 | 526 |
goto do_change_service_int; |
527 |
||
528 |
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
|
529 |
mod = _ctrl_pressed? -5 : -10; |
0 | 530 |
do_change_service_int: |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
914
diff
changeset
|
531 |
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
|
532 |
|
1790
47963a0cfca3
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1658
diff
changeset
|
533 |
mod = GetServiceIntervalClamped(mod + v->service_interval); |
47963a0cfca3
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1658
diff
changeset
|
534 |
if (mod == v->service_interval) return; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
535 |
|
2819
f25fb6ee397f
(svn r3367) Unify the 4 distinct CMD_CHANGE_{AIRCRAFT,ROADVEH,SHIP,TRAIN}_SERVICE_INT commands into one CMD_CHANGE_SERVICE_INT command.
tron
parents:
2806
diff
changeset
|
536 |
DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); |
0 | 537 |
break; |
538 |
/* details buttons*/ |
|
4434
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4429
diff
changeset
|
539 |
case 9: // Cargo |
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4429
diff
changeset
|
540 |
case 10: // Information |
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4429
diff
changeset
|
541 |
case 11: // Capacities |
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4429
diff
changeset
|
542 |
case 12: // Total cargo |
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
543 |
EnableWindowWidget(w, 9); |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
544 |
EnableWindowWidget(w, 10); |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
545 |
EnableWindowWidget(w, 11); |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
546 |
EnableWindowWidget(w, 12); |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
547 |
EnableWindowWidget(w, e->we.click.widget); |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
548 |
WP(w,traindetails_d).tab = e->we.click.widget - 9; |
0 | 549 |
SetWindowDirty(w); |
550 |
break; |
|
551 |
} |
|
552 |
} break; |
|
553 |
||
2548
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2520
diff
changeset
|
554 |
case WE_ON_EDIT_TEXT: |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
555 |
if (e->we.edittext.str[0] != '\0') { |
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
556 |
_cmd_text = e->we.edittext.str; |
1820
d03c56850dc2
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
557 |
DoCommandP(0, w->window_number, 0, NULL, |
d03c56850dc2
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
558 |
CMD_NAME_VEHICLE | CMD_MSG(STR_8866_CAN_T_NAME_TRAIN)); |
d03c56850dc2
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
559 |
} |
2548
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2520
diff
changeset
|
560 |
break; |
2959
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
561 |
|
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
562 |
case WE_RESIZE: |
5824
8398b44ad3bc
(svn r8390) -Codechange (r8384): Rewrote ResizeButtons()
bjarni
parents:
5822
diff
changeset
|
563 |
if (e->we.sizing.diff.x != 0) ResizeButtons(w, 9, 12); |
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
564 |
if (e->we.sizing.diff.y == 0) break; |
2959
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
565 |
|
4634
07699ac2bf37
(svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents:
4633
diff
changeset
|
566 |
w->vscroll.cap += e->we.sizing.diff.y / 14; |
4547
d37c2d172ad4
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4541
diff
changeset
|
567 |
w->widget[4].data = (w->vscroll.cap << 8) + 1; |
2959
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
568 |
break; |
0 | 569 |
} |
570 |
} |
|
571 |
||
572 |
static const Widget _train_details_widgets[] = { |
|
2959
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
573 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5821
31fa8234ebc6
(svn r8383) -Feature: train detail window is now resizable horizontally (requested by Wolf01)
bjarni
parents:
5779
diff
changeset
|
574 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 329, 0, 13, STR_8802_DETAILS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
31fa8234ebc6
(svn r8383) -Feature: train detail window is now resizable horizontally (requested by Wolf01)
bjarni
parents:
5779
diff
changeset
|
575 |
{ WWT_PUSHTXTBTN, RESIZE_LR, 14, 330, 369, 0, 13, STR_01AA_NAME, STR_8867_NAME_TRAIN}, |
31fa8234ebc6
(svn r8383) -Feature: train detail window is now resizable horizontally (requested by Wolf01)
bjarni
parents:
5779
diff
changeset
|
576 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 0, 369, 14, 55, 0x0, STR_NULL}, |
31fa8234ebc6
(svn r8383) -Feature: train detail window is now resizable horizontally (requested by Wolf01)
bjarni
parents:
5779
diff
changeset
|
577 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 357, 56, 139, 0x601, STR_NULL}, |
31fa8234ebc6
(svn r8383) -Feature: train detail window is now resizable horizontally (requested by Wolf01)
bjarni
parents:
5779
diff
changeset
|
578 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 358, 369, 56, 139, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
2959
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
579 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 10, 140, 145, STR_0188, STR_884D_INCREASE_SERVICING_INTERVAL}, |
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
580 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 10, 146, 151, STR_0189, STR_884E_DECREASE_SERVICING_INTERVAL}, |
5821
31fa8234ebc6
(svn r8383) -Feature: train detail window is now resizable horizontally (requested by Wolf01)
bjarni
parents:
5779
diff
changeset
|
581 |
{ WWT_PANEL, RESIZE_RTB, 14, 11, 369, 140, 151, 0x0, STR_NULL}, |
2959
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
582 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 89, 152, 163, STR_013C_CARGO, STR_884F_SHOW_DETAILS_OF_CARGO_CARRIED}, |
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
583 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 90, 178, 152, 163, STR_013D_INFORMATION, STR_8850_SHOW_DETAILS_OF_TRAIN_VEHICLES}, |
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
584 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 179, 268, 152, 163, STR_013E_CAPACITIES, STR_8851_SHOW_CAPACITIES_OF_EACH}, |
5824
8398b44ad3bc
(svn r8390) -Codechange (r8384): Rewrote ResizeButtons()
bjarni
parents:
5822
diff
changeset
|
585 |
{ WWT_PUSHTXTBTN, RESIZE_RTB, 14, 269, 357, 152, 163, STR_013E_TOTAL_CARGO, STR_8852_SHOW_TOTAL_CARGO}, |
5821
31fa8234ebc6
(svn r8383) -Feature: train detail window is now resizable horizontally (requested by Wolf01)
bjarni
parents:
5779
diff
changeset
|
586 |
{ 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
|
587 |
{ WIDGETS_END}, |
0 | 588 |
}; |
589 |
||
590 |
||
591 |
static const WindowDesc _train_details_desc = { |
|
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
4939
diff
changeset
|
592 |
WDP_AUTO, WDP_AUTO, 370, 164, |
0 | 593 |
WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW, |
2959
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
594 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 595 |
_train_details_widgets, |
596 |
TrainDetailsWndProc |
|
597 |
}; |
|
598 |
||
599 |
||
4171 | 600 |
static void ShowTrainDetailsWindow(const Vehicle *v) |
0 | 601 |
{ |
602 |
Window *w; |
|
603 |
VehicleID veh = v->index; |
|
604 |
||
605 |
DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
|
606 |
DeleteWindowById(WC_VEHICLE_DETAILS, veh); |
|
607 |
||
5071
e28106dfcb6f
(svn r7129) -Codechange: Get rid of a global variable that only sets a window's number.
Darkvater
parents:
5070
diff
changeset
|
608 |
w = AllocateWindowDescFront(&_train_details_desc, veh); |
0 | 609 |
|
610 |
w->caption_color = v->owner; |
|
611 |
w->vscroll.cap = 6; |
|
4547
d37c2d172ad4
(svn r6379) -Codechange: cast 'remove babel' on widget's unkA and rename it to 'data'.
Darkvater
parents:
4541
diff
changeset
|
612 |
w->widget[4].data = (w->vscroll.cap << 8) + 1; |
2959
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
613 |
|
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
614 |
w->resize.step_height = 14; |
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
615 |
w->resize.height = w->height - 14 * 2; /* Minimum of 4 wagons in the display */ |
0a9e35c5d7a3
(svn r3521) - Feature: Allow trains details view to be resized.
peter1138
parents:
2958
diff
changeset
|
616 |
|
0 | 617 |
WP(w,traindetails_d).tab = 0; |
618 |
} |