Mercurial > hg > openttd
annotate src/autoreplace_gui.cpp @ 6259:4a39d6291d58 draft
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
author | rubidium <rubidium@openttd.org> |
---|---|
date | Thu, 08 Mar 2007 16:27:54 +0000 |
parents | 57363e064324 |
children | e8a93d125d69 |
rev | line source |
---|---|
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
2 |
6117
6def6ecb1bf7
(svn r8853) -Cleanup: doxygen changes. Correct forgotten c files to cpp files with the @file tag as well as a few general comments style
belugas <belugas@openttd.org>
parents:
5955
diff
changeset
|
3 /** @file autoreplace_gui.cpp */ |
6def6ecb1bf7
(svn r8853) -Cleanup: doxygen changes. Correct forgotten c files to cpp files with the @file tag as well as a few general comments style
belugas <belugas@openttd.org>
parents:
5955
diff
changeset
|
4 |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
5 #include "stdafx.h" |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
6 #include "openttd.h" |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
7 #include "debug.h" |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
8 #include "functions.h" |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
9 #include "table/sprites.h" |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
10 #include "table/strings.h" |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
11 #include "window.h" |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
12 #include "gui.h" |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
13 #include "command.h" |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
14 #include "variables.h" |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
15 #include "vehicle_gui.h" |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
16 #include "newgrf_engine.h" |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
17 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
18 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
19 static RailType _railtype_selected_in_replace_gui; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
20 |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
21 static bool _rebuild_left_list; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
22 static bool _rebuild_right_list; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
23 |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
24 static const StringID _rail_types_list[] = { |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
25 STR_RAIL_VEHICLES, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
26 STR_ELRAIL_VEHICLES, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
27 STR_MONORAIL_VEHICLES, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
28 STR_MAGLEV_VEHICLES, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
29 INVALID_STRING_ID |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
30 }; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
31 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
32 /* General Vehicle GUI based procedures that are independent of vehicle types */ |
6247
57363e064324
(svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents:
6117
diff
changeset
|
33 void InitializeVehiclesGuiList() |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
34 { |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
35 _railtype_selected_in_replace_gui = RAILTYPE_RAIL; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
36 } |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
37 |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
38 /** Rebuild the left autoreplace list if an engine is removed or added |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
39 * @param e Engine to check if it is removed or added |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
40 * Note: this function only works if it is called either |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
41 * - when a new vehicle is build, but before it's counted in num_engines |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
42 * - when a vehicle is deleted and after it's substracted from num_engines |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
43 * - when not changing the count (used when changing replace orders) |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
44 */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
45 void InvalidateAutoreplaceWindow(EngineID e) |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
46 { |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
47 Player *p = GetPlayer(_local_player); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
48 byte type = GetEngine(e)->type; |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
49 |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
50 if (p->num_engines[e] == 0) { |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
51 /* We don't have any of this engine type. |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
52 * Either we just sold the last one, we build a new one or we stopped replacing it. |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
53 * In all cases, we need to update the left list */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
54 _rebuild_left_list = true; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
55 } else { |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
56 _rebuild_left_list = false; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
57 } |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
58 _rebuild_right_list = false; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
59 InvalidateWindowData(WC_REPLACE_VEHICLE, type); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
60 } |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
61 |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
62 /** When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
63 * @param type The type of engine |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
64 */ |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
65 void AddRemoveEngineFromAutoreplaceAndBuildWindows(byte type) |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
66 { |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
67 _rebuild_left_list = false; // left list is only for the vehicles the player owns and is not related to being buildable |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
68 _rebuild_right_list = true; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
69 InvalidateWindowData(WC_REPLACE_VEHICLE, type); // Update the autoreplace window |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
70 InvalidateWindowClassesData(WC_BUILD_VEHICLE); // The build windows needs updating as well |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
71 } |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
72 |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
73 /** Get the default cargo type for an engine |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
74 * @param engine the EngineID to get the cargo for |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
75 * @return the cargo type carried by the engine (CT_INVALID if engine got no cargo capacity) |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
76 */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
77 static CargoID EngineCargo(EngineID engine) |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
78 { |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
79 if (engine == INVALID_ENGINE) return CT_INVALID; // surely INVALID_ENGINE can't carry anything but CT_INVALID |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
80 |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
81 switch (GetEngine(engine)->type) { |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
82 default: NOT_REACHED(); |
6259
4a39d6291d58
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
83 case VEH_TRAIN: |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
84 if (RailVehInfo(engine)->capacity == 0) return CT_INVALID; // no capacity -> can't carry cargo |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
85 return RailVehInfo(engine)->cargo_type; |
6259
4a39d6291d58
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
86 case VEH_ROAD: return RoadVehInfo(engine)->cargo_type; |
4a39d6291d58
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
87 case VEH_SHIP: return ShipVehInfo(engine)->cargo_type; |
4a39d6291d58
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
88 case VEH_AIRCRAFT: return CT_PASSENGERS; // all planes are build with passengers by default |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
89 } |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
90 } |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
91 |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
92 /** Figure out if an engine should be added to a list |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
93 * @param e The EngineID |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
94 * @param draw_left If true, then the left list is drawn (the engines specific to the railtype you selected) |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
95 * @param show_engines if truem then locomotives are drawn, else wagons (never both) |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
96 * @return true if the engine should be in the list (based on this check) |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
97 */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
98 static bool GenerateReplaceRailList(EngineID e, bool draw_left, bool show_engines) |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
99 { |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
100 const RailVehicleInfo *rvi = RailVehInfo(e); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
101 |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
102 /* Ensure that the wagon/engine selection fits the engine. */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
103 if ((rvi->railveh_type == RAILVEH_WAGON) == show_engines) return false; |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
104 |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
105 if (draw_left && show_engines) { |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
106 /* Ensure that the railtype is specific to the selected one */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
107 if (rvi->railtype != _railtype_selected_in_replace_gui) return false; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
108 } else { |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
109 /* Ensure that it's a compatible railtype to the selected one (like electric <-> diesel) |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
110 * The vehicle do not have to have power on the railtype in question, only able to drive (pulled if needed) */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
111 if (!IsCompatibleRail(rvi->railtype, _railtype_selected_in_replace_gui)) return false; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
112 } |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
113 return true; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
114 } |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
115 |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
116 /** Figure out if two engines got at least one type of cargo in common (refitting if needed) |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
117 * @param engine_a one of the EngineIDs |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
118 * @param engine_b the other EngineID |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
119 * @return true if they can both carry the same type of cargo (or at least one of them got no capacity at all) |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
120 */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
121 static bool EnginesGotCargoInCommon(EngineID engine_a, EngineID engine_b) |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
122 { |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
123 CargoID a = EngineCargo(engine_a); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
124 CargoID b = EngineCargo(engine_b); |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
125 |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
126 /* we should always be able to refit to/from locomotives without capacity |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
127 * Because of that, CT_INVALID shoudl always return true */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
128 if (a == CT_INVALID || b == CT_INVALID || a == b) return true; // they carry no ro the same type by default |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
129 if (EngInfo(engine_a)->refit_mask & EngInfo(engine_b)->refit_mask) return true; // both can refit to the same |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
130 if (CanRefitTo(engine_a, b) || CanRefitTo(engine_b, a)) return true; // one can refit to what the other one carries |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
131 return false; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
132 } |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
133 |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
134 /** Generate a list |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
135 * @param w Window, that contains the list |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
136 * @param draw_left true if generating the left list, otherwise false |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
137 */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
138 static void GenerateReplaceVehList(Window *w, bool draw_left) |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
139 { |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
140 Player *p = GetPlayer(_local_player); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
141 EngineID e; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
142 EngineID selected_engine = INVALID_ENGINE; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
143 byte type = w->window_number; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
144 byte i = draw_left ? 0 : 1; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
145 |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
146 EngineList *list = &WP(w, replaceveh_d).list[i]; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
147 EngList_RemoveAll(list); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
148 |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
149 FOR_ALL_ENGINEIDS_OF_TYPE(e, type) { |
6259
4a39d6291d58
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
150 if (type == VEH_TRAIN && !GenerateReplaceRailList(e, draw_left, WP(w, replaceveh_d).wagon_btnstate)) continue; // special rules for trains |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
151 |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
152 if (draw_left) { |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
153 /* Skip drawing the engines we don't have any of and haven't set for replacement */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
154 if (p->num_engines[e] == 0 && EngineReplacementForPlayer(GetPlayer(_local_player), e) == INVALID_ENGINE) continue; |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
155 } else { |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
156 /* This is for engines we can replace to and they should depend on what we selected to replace from */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
157 if (!IsEngineBuildable(e, type, _local_player)) continue; // we need to be able to build the engine |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
158 if (!EnginesGotCargoInCommon(e, WP(w, replaceveh_d).sel_engine[0])) continue; // the engines needs to be able to carry the same cargo |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
159 if (e == WP(w, replaceveh_d).sel_engine[0]) continue; // we can't replace an engine into itself (that would be autorenew) |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
160 } |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
161 |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
162 EngList_Add(list, e); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
163 if (e == WP(w, replaceveh_d).sel_engine[i]) selected_engine = e; // The selected engine is still in the list |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
164 } |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
165 WP(w, replaceveh_d).sel_engine[i] = selected_engine; // update which engine we selected (the same or none, if it's not in the list anymore) |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
166 } |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
167 |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
168 /** Generate the lists |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
169 * @param w Window containing the lists |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
170 */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
171 static void GenerateLists(Window *w) |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
172 { |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
173 EngineID e = WP(w, replaceveh_d).sel_engine[0]; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
174 |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
175 if (WP(w, replaceveh_d).update_left == true) { |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
176 /* We need to rebuild the left list */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
177 GenerateReplaceVehList(w, true); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
178 SetVScrollCount(w, EngList_Count(&WP(w, replaceveh_d).list[0])); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
179 if (WP(w, replaceveh_d).init_lists && WP(w, replaceveh_d).sel_engine[0] == INVALID_ENGINE && EngList_Count(&WP(w, replaceveh_d).list[0]) != 0) { |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
180 WP(w, replaceveh_d).sel_engine[0] = WP(w, replaceveh_d).list[0][0]; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
181 } |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
182 } |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
183 |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
184 if (WP(w, replaceveh_d).update_right || e != WP(w, replaceveh_d).sel_engine[0]) { |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
185 /* Either we got a request to rebuild the right list or the left list selected a different engine */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
186 if (WP(w, replaceveh_d).sel_engine[0] == INVALID_ENGINE) { |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
187 /* Always empty the right list when nothing is selected in the left list */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
188 EngList_RemoveAll(&WP(w, replaceveh_d).list[1]); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
189 WP(w, replaceveh_d).sel_engine[1] = INVALID_ENGINE; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
190 } else { |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
191 GenerateReplaceVehList(w, false); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
192 SetVScroll2Count(w, EngList_Count(&WP(w, replaceveh_d).list[1])); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
193 if (WP(w, replaceveh_d).init_lists && WP(w, replaceveh_d).sel_engine[1] == INVALID_ENGINE && EngList_Count(&WP(w, replaceveh_d).list[1]) != 0) { |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
194 WP(w, replaceveh_d).sel_engine[1] = WP(w, replaceveh_d).list[1][0]; |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
195 } |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
196 } |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
197 } |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
198 /* Reset the flags about needed updates */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
199 WP(w, replaceveh_d).update_left = false; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
200 WP(w, replaceveh_d).update_right = false; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
201 WP(w, replaceveh_d).init_lists = false; |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
202 } |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
203 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
204 |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
205 void DrawEngineList(byte type, int x, int y, const EngineList eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count); |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
206 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
207 static void ReplaceVehicleWndProc(Window *w, WindowEvent *e) |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
208 { |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
209 /* Strings for the pulldown menu */ |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
210 static const StringID _vehicle_type_names[] = { |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
211 STR_019F_TRAIN, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
212 STR_019C_ROAD_VEHICLE, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
213 STR_019E_SHIP, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
214 STR_019D_AIRCRAFT |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
215 }; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
216 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
217 switch (e->event) { |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
218 case WE_CREATE: |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
219 WP(w, replaceveh_d).wagon_btnstate = true; // start with locomotives (all other vehicles will not read this bool) |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
220 EngList_Create(&WP(w, replaceveh_d).list[0]); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
221 EngList_Create(&WP(w, replaceveh_d).list[1]); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
222 WP(w, replaceveh_d).update_left = true; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
223 WP(w, replaceveh_d).update_right = true; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
224 WP(w, replaceveh_d).init_lists = true; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
225 WP(w, replaceveh_d).sel_engine[0] = INVALID_ENGINE; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
226 WP(w, replaceveh_d).sel_engine[1] = INVALID_ENGINE; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
227 break; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
228 |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
229 case WE_PAINT: { |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
230 if (WP(w, replaceveh_d).update_left || WP(w, replaceveh_d).update_right) GenerateLists(w); |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
231 |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
232 Player *p = GetPlayer(_local_player); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
233 EngineID selected_id[2]; |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
234 |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
235 selected_id[0] = WP(w, replaceveh_d).sel_engine[0]; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
236 selected_id[1] = WP(w, replaceveh_d).sel_engine[1]; |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
237 |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
238 /* Disable the "Start Replacing" button if: |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
239 * Either list is empty |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
240 * or The selected replacement engine has a replacement (to prevent loops) |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
241 * or The right list (new replacement) has the existing replacement vehicle selected */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
242 SetWindowWidgetDisabledState(w, 4, |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
243 selected_id[0] == INVALID_ENGINE || |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
244 selected_id[1] == INVALID_ENGINE || |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
245 EngineReplacementForPlayer(p, selected_id[1]) != INVALID_ENGINE || |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
246 EngineReplacementForPlayer(p, selected_id[0]) == selected_id[1]); |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
247 |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
248 /* Disable the "Stop Replacing" button if: |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
249 * The left list (existing vehicle) is empty |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
250 * or The selected vehicle has no replacement set up */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
251 SetWindowWidgetDisabledState(w, 6, |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
252 selected_id[0] == INVALID_ENGINE || |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
253 !EngineHasReplacementForPlayer(p, selected_id[0])); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
254 |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
255 /* now the actual drawing of the window itself takes place */ |
5955
1bc5a8fab0c9
(svn r8621) -Codechange: assigned new numbers to the VEH_(type) enum so that VEH_Train is 0, VEH_Road is 1 and so on
bjarni <bjarni@openttd.org>
parents:
5944
diff
changeset
|
256 SetDParam(0, _vehicle_type_names[w->window_number]); |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
257 |
6259
4a39d6291d58
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
258 if (w->window_number == VEH_TRAIN) { |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
259 /* set on/off for renew_keep_length */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
260 SetDParam(1, p->renew_keep_length ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF); |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
261 |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
262 /* set wagon/engine button */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
263 SetDParam(2, WP(w, replaceveh_d).wagon_btnstate ? STR_ENGINES : STR_WAGONS); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
264 } |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
265 |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
266 w->widget[13].color = _player_colors[_local_player]; // sets the colour of that art thing |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
267 w->widget[16].color = _player_colors[_local_player]; // sets the colour of that art thing |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
268 |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
269 DrawWindowWidgets(w); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
270 |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
271 |
6259
4a39d6291d58
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
272 if (w->window_number == VEH_TRAIN) { |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
273 /* Draw the selected railtype in the pulldown menu */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
274 RailType railtype = _railtype_selected_in_replace_gui; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
275 DrawString(157, w->widget[14].top + 1, _rail_types_list[railtype], 0x10); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
276 } |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
277 |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
278 /* sets up the string for the vehicle that is being replaced to */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
279 if (selected_id[0] != INVALID_ENGINE) { |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
280 if (!EngineHasReplacementForPlayer(p, selected_id[0])) { |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
281 SetDParam(0, STR_NOT_REPLACING); |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
282 } else { |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
283 SetDParam(0, GetCustomEngineName(EngineReplacementForPlayer(p, selected_id[0]))); |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
284 } |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
285 } else { |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
286 SetDParam(0, STR_NOT_REPLACING_VEHICLE_SELECTED); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
287 } |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
288 |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
289 DrawString(145, w->widget[5].top + 1, STR_02BD, 0x10); |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
290 |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
291 /* Draw the lists */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
292 for(byte i = 0; i < 2; i++) { |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
293 uint16 x = i == 0 ? 2 : 230; // at what X offset |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
294 EngineList list = WP(w, replaceveh_d).list[i]; // which list to draw |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
295 EngineID start = i == 0 ? w->vscroll.pos : w->vscroll2.pos; // what is the offset for the start (scrolling) |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
296 EngineID end = min((i == 0 ? w->vscroll.cap : w->vscroll2.cap) + start, EngList_Count(&list)); |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
297 |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
298 /* Do the actual drawing */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
299 DrawEngineList(w->window_number, x, 15, list, start, end, WP(w, replaceveh_d).sel_engine[i], i == 0); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
300 |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
301 /* Also draw the details if an engine is selected */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
302 if (WP(w, replaceveh_d).sel_engine[i] != INVALID_ENGINE) { |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
303 const Widget *wi = &w->widget[i == 0 ? 3 : 11]; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
304 DrawVehiclePurchaseInfo(wi->left + 2, wi->top + 1, wi->right - wi->left - 2, WP(w, replaceveh_d).sel_engine[i]); |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
305 } |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
306 } |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
307 |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
308 } break; // end of paint |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
309 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
310 case WE_CLICK: { |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
311 switch (e->we.click.widget) { |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
312 case 12: |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
313 WP(w, replaceveh_d).wagon_btnstate = !(WP(w, replaceveh_d).wagon_btnstate); |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
314 WP(w, replaceveh_d).update_left = true; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
315 WP(w, replaceveh_d).init_lists = true; |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
316 SetWindowDirty(w); |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
317 break; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
318 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
319 case 14: |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
320 case 15: /* Railtype selection dropdown menu */ |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
321 ShowDropDownMenu(w, _rail_types_list, _railtype_selected_in_replace_gui, 15, 0, ~GetPlayer(_local_player)->avail_railtypes); |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
322 break; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
323 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
324 case 17: /* toggle renew_keep_length */ |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
325 DoCommandP(0, 5, GetPlayer(_local_player)->renew_keep_length ? 0 : 1, NULL, CMD_SET_AUTOREPLACE); |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
326 break; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
327 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
328 case 4: { /* Start replacing */ |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
329 EngineID veh_from = WP(w, replaceveh_d).sel_engine[0]; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
330 EngineID veh_to = WP(w, replaceveh_d).sel_engine[1]; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
331 DoCommandP(0, 3, veh_from + (veh_to << 16), NULL, CMD_SET_AUTOREPLACE); |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
332 } break; |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
333 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
334 case 6: { /* Stop replacing */ |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
335 EngineID veh_from = WP(w, replaceveh_d).sel_engine[0]; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
336 DoCommandP(0, 3, veh_from + (INVALID_ENGINE << 16), NULL, CMD_SET_AUTOREPLACE); |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
337 } break; |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
338 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
339 case 7: |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
340 case 9: { |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
341 uint i = (e->we.click.pt.y - 14) / w->resize.step_height; |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
342 uint16 click_scroll_pos = e->we.click.widget == 7 ? w->vscroll.pos : w->vscroll2.pos; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
343 uint16 click_scroll_cap = e->we.click.widget == 7 ? w->vscroll.cap : w->vscroll2.cap; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
344 byte click_side = e->we.click.widget == 7 ? 0 : 1; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
345 uint16 engine_count = EngList_Count(&WP(w, replaceveh_d).list[click_side]); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
346 |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
347 if (i < click_scroll_cap) { |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
348 i += click_scroll_pos; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
349 EngineID e = engine_count > i ? WP(w, replaceveh_d).list[click_side][i] : INVALID_ENGINE; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
350 if (e == WP(w, replaceveh_d).sel_engine[click_side]) break; // we clicked the one we already selected |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
351 WP(w, replaceveh_d).sel_engine[click_side] = e; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
352 if (click_side == 0) { |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
353 WP(w, replaceveh_d).update_right = true; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
354 WP(w, replaceveh_d).init_lists = true; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
355 } |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
356 SetWindowDirty(w); |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
357 } |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
358 break; |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
359 } |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
360 } |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
361 break; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
362 } |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
363 |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
364 case WE_DROPDOWN_SELECT: { /* we have selected a dropdown item in the list */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
365 RailType temp = (RailType)e->we.dropdown.index; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
366 if (temp == _railtype_selected_in_replace_gui) break; // we didn't select a new one. No need to change anything |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
367 _railtype_selected_in_replace_gui = temp; |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
368 /* Reset scrollbar positions */ |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
369 w->vscroll.pos = 0; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
370 w->vscroll2.pos = 0; |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
371 /* Rebuild the lists */ |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
372 WP(w, replaceveh_d).update_left = true; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
373 WP(w, replaceveh_d).update_right = true; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
374 WP(w, replaceveh_d).init_lists = true; |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
375 SetWindowDirty(w); |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
376 } break; |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
377 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
378 case WE_RESIZE: |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
379 w->vscroll.cap += e->we.sizing.diff.y / (int)w->resize.step_height; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
380 w->vscroll2.cap += e->we.sizing.diff.y / (int)w->resize.step_height; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
381 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
382 w->widget[7].data = (w->vscroll.cap << 8) + 1; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
383 w->widget[9].data = (w->vscroll2.cap << 8) + 1; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
384 break; |
5944
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
385 |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
386 case WE_INVALIDATE_DATA: |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
387 if (_rebuild_left_list) WP(w, replaceveh_d).update_left = true; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
388 if (_rebuild_right_list) WP(w, replaceveh_d).update_right = true; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
389 SetWindowDirty(w); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
390 break; |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
391 |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
392 case WE_DESTROY: |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
393 EngList_RemoveAll(&WP(w, replaceveh_d).list[0]); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
394 EngList_RemoveAll(&WP(w, replaceveh_d).list[1]); |
ca95cde4d1b4
(svn r8610) -Codechange/Feature: rewrote the list handling in the autoreplace window
bjarni <bjarni@openttd.org>
parents:
5893
diff
changeset
|
395 break; |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
396 } |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
397 } |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
398 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
399 static const Widget _replace_rail_vehicle_widgets[] = { |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
400 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
401 { WWT_CAPTION, RESIZE_NONE, 14, 11, 443, 0, 13, STR_REPLACE_VEHICLES_WHITE, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
402 { WWT_STICKYBOX, RESIZE_NONE, 14, 444, 455, 0, 13, STR_NULL, STR_STICKY_BUTTON}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
403 { WWT_PANEL, RESIZE_TB, 14, 0, 227, 126, 227, 0x0, STR_NULL}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
404 { WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 138, 240, 251, STR_REPLACE_VEHICLES_START, STR_REPLACE_HELP_START_BUTTON}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
405 { WWT_PANEL, RESIZE_TB, 14, 139, 316, 228, 239, 0x0, STR_REPLACE_HELP_REPLACE_INFO_TAB}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
406 { WWT_PUSHTXTBTN, RESIZE_TB, 14, 306, 443, 240, 251, STR_REPLACE_VEHICLES_STOP, STR_REPLACE_HELP_STOP_BUTTON}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
407 { WWT_MATRIX, RESIZE_BOTTOM, 14, 0, 215, 14, 125, 0x801, STR_REPLACE_HELP_LEFT_ARRAY}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
408 { WWT_SCROLLBAR, RESIZE_BOTTOM, 14, 216, 227, 14, 125, STR_NULL, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
409 { WWT_MATRIX, RESIZE_BOTTOM, 14, 228, 443, 14, 125, 0x801, STR_REPLACE_HELP_RIGHT_ARRAY}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
410 { WWT_SCROLL2BAR, RESIZE_BOTTOM, 14, 444, 455, 14, 125, STR_NULL, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
411 { WWT_PANEL, RESIZE_TB, 14, 228, 455, 126, 227, 0x0, STR_NULL}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
412 // train specific stuff |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
413 { WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 138, 228, 239, STR_REPLACE_ENGINE_WAGON_SELECT, STR_REPLACE_ENGINE_WAGON_SELECT_HELP}, // widget 12 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
414 { WWT_PANEL, RESIZE_TB, 14, 139, 153, 240, 251, 0x0, STR_NULL}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
415 { WWT_PANEL, RESIZE_TB, 14, 154, 277, 240, 251, 0x0, STR_REPLACE_HELP_RAILTYPE}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
416 { WWT_TEXTBTN, RESIZE_TB, 14, 278, 289, 240, 251, STR_0225, STR_REPLACE_HELP_RAILTYPE}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
417 { WWT_PANEL, RESIZE_TB, 14, 290, 305, 240, 251, 0x0, STR_NULL}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
418 { WWT_PUSHTXTBTN, RESIZE_TB, 14, 317, 455, 228, 239, STR_REPLACE_REMOVE_WAGON, STR_REPLACE_REMOVE_WAGON_HELP}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
419 // end of train specific stuff |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
420 { WWT_RESIZEBOX, RESIZE_TB, 14, 444, 455, 240, 251, STR_NULL, STR_RESIZE_BUTTON}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
421 { WIDGETS_END}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
422 }; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
423 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
424 static const Widget _replace_road_vehicle_widgets[] = { |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
425 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
426 { WWT_CAPTION, RESIZE_NONE, 14, 11, 443, 0, 13, STR_REPLACE_VEHICLES_WHITE, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
427 { WWT_STICKYBOX, RESIZE_NONE, 14, 444, 455, 0, 13, STR_NULL, STR_STICKY_BUTTON}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
428 { WWT_PANEL, RESIZE_TB, 14, 0, 227, 126, 217, 0x0, STR_NULL}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
429 { WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 138, 218, 229, STR_REPLACE_VEHICLES_START, STR_REPLACE_HELP_START_BUTTON}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
430 { WWT_PANEL, RESIZE_TB, 14, 139, 305, 218, 229, 0x0, STR_REPLACE_HELP_REPLACE_INFO_TAB}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
431 { WWT_PUSHTXTBTN, RESIZE_TB, 14, 306, 443, 218, 229, STR_REPLACE_VEHICLES_STOP, STR_REPLACE_HELP_STOP_BUTTON}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
432 { WWT_MATRIX, RESIZE_BOTTOM, 14, 0, 215, 14, 125, 0x801, STR_REPLACE_HELP_LEFT_ARRAY}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
433 { WWT_SCROLLBAR, RESIZE_BOTTOM, 14, 216, 227, 14, 125, STR_NULL, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
434 { WWT_MATRIX, RESIZE_BOTTOM, 14, 228, 443, 14, 125, 0x801, STR_REPLACE_HELP_RIGHT_ARRAY}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
435 { WWT_SCROLL2BAR, RESIZE_BOTTOM, 14, 444, 455, 14, 125, STR_NULL, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
436 { WWT_PANEL, RESIZE_TB, 14, 228, 455, 126, 217, 0x0, STR_NULL}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
437 { WWT_RESIZEBOX, RESIZE_TB, 14, 444, 455, 218, 229, STR_NULL, STR_RESIZE_BUTTON}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
438 { WIDGETS_END}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
439 }; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
440 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
441 static const Widget _replace_ship_aircraft_vehicle_widgets[] = { |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
442 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
443 { WWT_CAPTION, RESIZE_NONE, 14, 11, 443, 0, 13, STR_REPLACE_VEHICLES_WHITE, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
444 { WWT_STICKYBOX, RESIZE_NONE, 14, 444, 455, 0, 13, STR_NULL, STR_STICKY_BUTTON}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
445 { WWT_PANEL, RESIZE_TB, 14, 0, 227, 110, 201, 0x0, STR_NULL}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
446 { WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 138, 202, 213, STR_REPLACE_VEHICLES_START, STR_REPLACE_HELP_START_BUTTON}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
447 { WWT_PANEL, RESIZE_TB, 14, 139, 305, 202, 213, 0x0, STR_REPLACE_HELP_REPLACE_INFO_TAB}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
448 { WWT_PUSHTXTBTN, RESIZE_TB, 14, 306, 443, 202, 213, STR_REPLACE_VEHICLES_STOP, STR_REPLACE_HELP_STOP_BUTTON}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
449 { WWT_MATRIX, RESIZE_BOTTOM, 14, 0, 215, 14, 109, 0x401, STR_REPLACE_HELP_LEFT_ARRAY}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
450 { WWT_SCROLLBAR, RESIZE_BOTTOM, 14, 216, 227, 14, 109, STR_NULL, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
451 { WWT_MATRIX, RESIZE_BOTTOM, 14, 228, 443, 14, 109, 0x401, STR_REPLACE_HELP_RIGHT_ARRAY}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
452 { WWT_SCROLL2BAR, RESIZE_BOTTOM, 14, 444, 455, 14, 109, STR_NULL, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
453 { WWT_PANEL, RESIZE_TB, 14, 228, 455, 110, 201, 0x0, STR_NULL}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
454 { WWT_RESIZEBOX, RESIZE_TB, 14, 444, 455, 202, 213, STR_NULL, STR_RESIZE_BUTTON}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
455 { WIDGETS_END}, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
456 }; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
457 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
458 static const WindowDesc _replace_rail_vehicle_desc = { |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
459 WDP_AUTO, WDP_AUTO, 456, 252, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5868
diff
changeset
|
460 WC_REPLACE_VEHICLE, WC_NONE, |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
461 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
462 _replace_rail_vehicle_widgets, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
463 ReplaceVehicleWndProc |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
464 }; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
465 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
466 static const WindowDesc _replace_road_vehicle_desc = { |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
467 WDP_AUTO, WDP_AUTO, 456, 230, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5868
diff
changeset
|
468 WC_REPLACE_VEHICLE, WC_NONE, |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
469 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
470 _replace_road_vehicle_widgets, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
471 ReplaceVehicleWndProc |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
472 }; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
473 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
474 static const WindowDesc _replace_ship_aircraft_vehicle_desc = { |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
475 WDP_AUTO, WDP_AUTO, 456, 214, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5868
diff
changeset
|
476 WC_REPLACE_VEHICLE, WC_NONE, |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
477 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
478 _replace_ship_aircraft_vehicle_widgets, |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
479 ReplaceVehicleWndProc |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
480 }; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
481 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
482 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
483 void ShowReplaceVehicleWindow(byte vehicletype) |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
484 { |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
485 Window *w; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
486 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
487 DeleteWindowById(WC_REPLACE_VEHICLE, vehicletype); |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
488 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
489 switch (vehicletype) { |
6259
4a39d6291d58
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
490 case VEH_TRAIN: |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
491 w = AllocateWindowDescFront(&_replace_rail_vehicle_desc, vehicletype); |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
492 w->vscroll.cap = 8; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
493 w->resize.step_height = 14; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
494 WP(w, replaceveh_d).wagon_btnstate = true; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
495 break; |
6259
4a39d6291d58
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
496 case VEH_ROAD: |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
497 w = AllocateWindowDescFront(&_replace_road_vehicle_desc, vehicletype); |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
498 w->vscroll.cap = 8; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
499 w->resize.step_height = 14; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
500 break; |
6259
4a39d6291d58
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
501 case VEH_SHIP: |
4a39d6291d58
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents:
6247
diff
changeset
|
502 case VEH_AIRCRAFT: |
5801
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
503 w = AllocateWindowDescFront(&_replace_ship_aircraft_vehicle_desc, vehicletype); |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
504 w->vscroll.cap = 4; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
505 w->resize.step_height = 24; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
506 break; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
507 default: return; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
508 } |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
509 |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
510 w->caption_color = _local_player; |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
511 w->vscroll2.cap = w->vscroll.cap; // these two are always the same |
0bfadf996941
(svn r8363) -Codechange: [autoreplace GUI] moved the autoreplace GUI to a file of it's own
bjarni <bjarni@openttd.org>
parents:
diff
changeset
|
512 } |