annotate ship_gui.c @ 2444:c1145552a533 draft

(svn r2970) - Newgrf: Allocate spritegroups dynamically; this allows a cargo ID to reference the previous definition of the same cargo ID, instead of causing loops.
author peter1138 <peter1138@openttd.org>
date Thu, 22 Sep 2005 20:35:20 +0000
parents 027bdc04f0ed
children d5434f9d0c5f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2186
042e6d005cb0 (svn r2701) Insert Id tags into all source files
tron <tron@openttd.org>
parents: 2163
diff changeset
1 /* $Id$ */
042e6d005cb0 (svn r2701) Insert Id tags into all source files
tron <tron@openttd.org>
parents: 2163
diff changeset
2
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
3 #include "stdafx.h"
1891
81b2cb2fc036 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater <Darkvater@openttd.org>
parents: 1820
diff changeset
4 #include "openttd.h"
1299
14b802fe0f85 (svn r1803) Move debugging stuff into files of it's own
tron <tron@openttd.org>
parents: 1294
diff changeset
5 #include "debug.h"
2163
acad95b3c4a2 (svn r2673) Include functions.h directly, not globally via openttd.h
tron <tron@openttd.org>
parents: 2159
diff changeset
6 #include "functions.h"
507
9dcc34b8887e (svn r815) Include strings.h only in the files which need it.
tron <tron@openttd.org>
parents: 243
diff changeset
7 #include "table/strings.h"
2187
ec59060e9c43 (svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar <celestar@openttd.org>
parents: 2186
diff changeset
8 #include "table/sprites.h"
679
21e658645b32 (svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron <tron@openttd.org>
parents: 588
diff changeset
9 #include "map.h"
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
10 #include "window.h"
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
11 #include "gui.h"
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
12 #include "gfx.h"
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
13 #include "vehicle.h"
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
14 #include "viewport.h"
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
15 #include "station.h"
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
16 #include "command.h"
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
17 #include "player.h"
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
18 #include "engine.h"
1313
cc5956ea3da8 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight <truelight@openttd.org>
parents: 1299
diff changeset
19 #include "depot.h"
2159
a832c39b4afe (svn r2669) Shuffle some more stuff around to reduce dependencies
tron <tron@openttd.org>
parents: 2113
diff changeset
20 #include "vehicle_gui.h"
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
21
1907
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
22 /**
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
23 * Draw the purchase info details of a ship at a given location.
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
24 * @param x,y location where to draw the info
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
25 * @param engine_number the engine of which to draw the info of
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
26 */
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
27 void DrawShipPurchaseInfo(int x, int y, EngineID engine_number)
842
a71aeb1cfa97 (svn r1323) Adding autoreplace feature
bjarni <bjarni@openttd.org>
parents: 767
diff changeset
28 {
a71aeb1cfa97 (svn r1323) Adding autoreplace feature
bjarni <bjarni@openttd.org>
parents: 767
diff changeset
29 YearMonthDay ymd;
a71aeb1cfa97 (svn r1323) Adding autoreplace feature
bjarni <bjarni@openttd.org>
parents: 767
diff changeset
30 const ShipVehicleInfo *svi = ShipVehInfo(engine_number);
a71aeb1cfa97 (svn r1323) Adding autoreplace feature
bjarni <bjarni@openttd.org>
parents: 767
diff changeset
31 Engine *e;
a71aeb1cfa97 (svn r1323) Adding autoreplace feature
bjarni <bjarni@openttd.org>
parents: 767
diff changeset
32
1907
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
33 /* Purchase cost - Max speed */
842
a71aeb1cfa97 (svn r1323) Adding autoreplace feature
bjarni <bjarni@openttd.org>
parents: 767
diff changeset
34 SetDParam(0, svi->base_cost * (_price.ship_base>>3)>>5);
a71aeb1cfa97 (svn r1323) Adding autoreplace feature
bjarni <bjarni@openttd.org>
parents: 767
diff changeset
35 SetDParam(1, svi->max_speed * 10 >> 5);
1907
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
36 DrawString(x,y, STR_PURCHASE_INFO_COST_SPEED, 0);
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
37 y += 10;
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
38
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
39 /* Cargo type + capacity */
2084
8e2162bf7fba (svn r2594) Fix: [strgen] Misc updates to the string system.
ludde <ludde@openttd.org>
parents: 1986
diff changeset
40 SetDParam(0, _cargoc.names_long[svi->cargo_type]);
1907
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
41 SetDParam(1, svi->capacity);
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
42 SetDParam(2, svi->refittable ? STR_9842_REFITTABLE : STR_EMPTY);
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
43 DrawString(x,y, STR_PURCHASE_INFO_CAPACITY, 0);
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
44 y += 10;
842
a71aeb1cfa97 (svn r1323) Adding autoreplace feature
bjarni <bjarni@openttd.org>
parents: 767
diff changeset
45
1907
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
46 /* Running cost */
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
47 SetDParam(0, svi->running_cost * _price.ship_running >> 8);
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
48 DrawString(x,y, STR_PURCHASE_INFO_RUNNINGCOST, 0);
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
49 y += 10;
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
50
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
51 /* Design date - Life length */
1926
ae98b5ce63ee (svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron <tron@openttd.org>
parents: 1907
diff changeset
52 e = GetEngine(engine_number);
842
a71aeb1cfa97 (svn r1323) Adding autoreplace feature
bjarni <bjarni@openttd.org>
parents: 767
diff changeset
53 ConvertDayToYMD(&ymd, e->intro_date);
1907
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
54 SetDParam(0, ymd.year + 1920);
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
55 SetDParam(1, e->lifelength);
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
56 DrawString(x,y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0);
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
57 y += 10;
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
58
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
59 /* Reliability */
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
60 SetDParam(0, e->reliability * 100 >> 16);
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
61 DrawString(x,y, STR_PURCHASE_INFO_RELIABILITY, 0);
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
62 y += 10;
842
a71aeb1cfa97 (svn r1323) Adding autoreplace feature
bjarni <bjarni@openttd.org>
parents: 767
diff changeset
63 }
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
64
1790
1fb831153f4a (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater <Darkvater@openttd.org>
parents: 1751
diff changeset
65 static void DrawShipImage(const Vehicle *v, int x, int y, VehicleID selection)
1fb831153f4a (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater <Darkvater@openttd.org>
parents: 1751
diff changeset
66 {
1fb831153f4a (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater <Darkvater@openttd.org>
parents: 1751
diff changeset
67 int image = GetShipImage(v, 6);
1fb831153f4a (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater <Darkvater@openttd.org>
parents: 1751
diff changeset
68 uint32 ormod = SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner));
1fb831153f4a (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater <Darkvater@openttd.org>
parents: 1751
diff changeset
69 DrawSprite(image | ormod, x+32, y+10);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
70
1790
1fb831153f4a (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater <Darkvater@openttd.org>
parents: 1751
diff changeset
71 if (v->index == selection) {
1938
62c54dfb8ffa (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid <hackykid@openttd.org>
parents: 1926
diff changeset
72 DrawFrameRect(x-5, y-1, x+67, y+21, 15, FR_BORDERONLY);
1790
1fb831153f4a (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater <Darkvater@openttd.org>
parents: 1751
diff changeset
73 }
1fb831153f4a (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater <Darkvater@openttd.org>
parents: 1751
diff changeset
74 }
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
75
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
76 static void ShipRefitWndProc(Window *w, WindowEvent *e)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
77 {
1802
e800fe388111 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater <Darkvater@openttd.org>
parents: 1790
diff changeset
78 switch (e->event) {
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
79 case WE_PAINT: {
1802
e800fe388111 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater <Darkvater@openttd.org>
parents: 1790
diff changeset
80 const Vehicle *v = GetVehicle(w->window_number);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
81
534
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
82 SetDParam(0, v->string_id);
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
83 SetDParam(1, v->unitnumber);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
84 DrawWindowWidgets(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
85
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
86 DrawString(1, 15, STR_983F_SELECT_CARGO_TYPE_TO_CARRY, 0);
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
87
1802
e800fe388111 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater <Darkvater@openttd.org>
parents: 1790
diff changeset
88 /* TODO: Support for custom GRFSpecial-specified refitting! --pasky */
e800fe388111 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater <Darkvater@openttd.org>
parents: 1790
diff changeset
89 WP(w,refit_d).cargo = DrawVehicleRefitWindow(v, WP(w, refit_d).sel);;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
90
1802
e800fe388111 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater <Darkvater@openttd.org>
parents: 1790
diff changeset
91 if (WP(w,refit_d).cargo != CT_INVALID) {
e800fe388111 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater <Darkvater@openttd.org>
parents: 1790
diff changeset
92 int32 cost = DoCommandByTile(v->tile, v->index, WP(w,refit_d).cargo, DC_QUERY_COST, CMD_REFIT_SHIP);
e800fe388111 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater <Darkvater@openttd.org>
parents: 1790
diff changeset
93 if (!CmdFailed(cost)) {
534
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
94 SetDParam(2, cost);
2084
8e2162bf7fba (svn r2594) Fix: [strgen] Misc updates to the string system.
ludde <ludde@openttd.org>
parents: 1986
diff changeset
95 SetDParam(0, _cargoc.names_long[WP(w,refit_d).cargo]);
534
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
96 SetDParam(1, v->cargo_cap);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
97 DrawString(1, 137, STR_9840_NEW_CAPACITY_COST_OF_REFIT, 0);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
98 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
99 }
1802
e800fe388111 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater <Darkvater@openttd.org>
parents: 1790
diff changeset
100 } break;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
101
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
102 case WE_CLICK:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
103 switch(e->click.widget) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
104 case 2: { /* listbox */
1802
e800fe388111 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater <Darkvater@openttd.org>
parents: 1790
diff changeset
105 int y = e->click.pt.y - 25;
e800fe388111 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater <Darkvater@openttd.org>
parents: 1790
diff changeset
106 if (y >= 0) {
e800fe388111 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater <Darkvater@openttd.org>
parents: 1790
diff changeset
107 WP(w,refit_d).sel = y / 10;
e800fe388111 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater <Darkvater@openttd.org>
parents: 1790
diff changeset
108 SetWindowDirty(w);
e800fe388111 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater <Darkvater@openttd.org>
parents: 1790
diff changeset
109 }
e800fe388111 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater <Darkvater@openttd.org>
parents: 1790
diff changeset
110 } break;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
111 case 4: /* refit button */
1802
e800fe388111 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater <Darkvater@openttd.org>
parents: 1790
diff changeset
112 if (WP(w,refit_d).cargo != CT_INVALID) {
e800fe388111 (svn r2306) - CodeChange: Check the last commands; refits. This needed an extensive rewrite and global/local-cargo ID juggling and bitmasking. However with this done it looks better as well and is compatible with newgrf handling. Big thanks to HackyKid for doing most of the work. This also closes patch "[ 1199277 ] Command checks"
Darkvater <Darkvater@openttd.org>
parents: 1790
diff changeset
113 const Vehicle *v = GetVehicle(w->window_number);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
114 if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo, NULL, CMD_REFIT_SHIP | CMD_MSG(STR_9841_CAN_T_REFIT_SHIP)))
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
115 DeleteWindow(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
116 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
117 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
118 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
119 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
120 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
121 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
122
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
123
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
124 static const Widget _ship_refit_widgets[] = {
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
125 { WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
126 { WWT_CAPTION, RESIZE_NONE, 14, 11, 239, 0, 13, STR_983B_REFIT, STR_018C_WINDOW_TITLE_DRAG_THIS},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
127 { WWT_IMGBTN, RESIZE_NONE, 14, 0, 239, 14, 135, 0x0, STR_983D_SELECT_TYPE_OF_CARGO_FOR},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
128 { WWT_IMGBTN, RESIZE_NONE, 14, 0, 239, 136, 157, 0x0, STR_NULL},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
129 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 239, 158, 169, STR_983C_REFIT_SHIP, STR_983E_REFIT_SHIP_TO_CARRY_HIGHLIGHTED},
176
5ff3972188b5 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater <darkvater@openttd.org>
parents: 174
diff changeset
130 { WIDGETS_END},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
131 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
132
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
133 static const WindowDesc _ship_refit_desc = {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
134 -1,-1, 240, 170,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
135 WC_VEHICLE_REFIT,WC_VEHICLE_VIEW,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
136 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
137 _ship_refit_widgets,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
138 ShipRefitWndProc,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
139 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
140
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
141 static void ShowShipRefitWindow(Vehicle *v)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
142 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
143 Window *w;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
144
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
145 DeleteWindowById(WC_VEHICLE_REFIT, v->index);
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
146
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
147 _alloc_wnd_parent_num = v->index;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
148 w = AllocateWindowDesc(&_ship_refit_desc);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
149 w->window_number = v->index;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
150 w->caption_color = v->owner;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
151 WP(w,refit_d).sel = -1;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
152 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
153
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
154 static void ShipDetailsWndProc(Window *w, WindowEvent *e)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
155 {
1790
1fb831153f4a (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater <Darkvater@openttd.org>
parents: 1751
diff changeset
156 switch (e->event) {
1fb831153f4a (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater <Darkvater@openttd.org>
parents: 1751
diff changeset
157 case WE_PAINT: {
1fb831153f4a (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater <Darkvater@openttd.org>
parents: 1751
diff changeset
158 const Vehicle *v = GetVehicle(w->window_number);
1fb831153f4a (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater <Darkvater@openttd.org>
parents: 1751
diff changeset
159 StringID str;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
160
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
161 w->disabled_state = v->owner == _local_player ? 0 : (1 << 2);
156
951f85b8a32b (svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater <darkvater@openttd.org>
parents: 10
diff changeset
162 if (!_patches.servint_ships) // disable service-scroller when interval is set to disabled
951f85b8a32b (svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater <darkvater@openttd.org>
parents: 10
diff changeset
163 w->disabled_state |= (1 << 5) | (1 << 6);
951f85b8a32b (svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater <darkvater@openttd.org>
parents: 10
diff changeset
164
534
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
165 SetDParam(0, v->string_id);
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
166 SetDParam(1, v->unitnumber);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
167 DrawWindowWidgets(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
168
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
169 /* Draw running cost */
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
170 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
171 int year = v->age / 366;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
172
534
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
173 SetDParam(1, year);
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
174
2252
e4d167236881 (svn r2772) Simplify the age notice in the vehicle details window
tron <tron@openttd.org>
parents: 2244
diff changeset
175 SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED);
534
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
176 SetDParam(2, v->max_age / 366);
538
fea9e39c6625 (svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron <tron@openttd.org>
parents: 534
diff changeset
177 SetDParam(3, ShipVehInfo(v->engine_type)->running_cost * _price.ship_running >> 8);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
178 DrawString(2, 15, STR_9812_AGE_RUNNING_COST_YR, 0);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
179 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
180
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
181 /* Draw max speed */
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
182 {
534
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
183 SetDParam(0, v->max_speed * 10 >> 5);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
184 DrawString(2, 25, STR_9813_MAX_SPEED, 0);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
185 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
186
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
187 /* Draw profit */
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
188 {
534
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
189 SetDParam(0, v->profit_this_year);
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
190 SetDParam(1, v->profit_last_year);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
191 DrawString(2, 35, STR_9814_PROFIT_THIS_YEAR_LAST_YEAR, 0);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
192 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
193
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
194 /* Draw breakdown & reliability */
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
195 {
534
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
196 SetDParam(0, v->reliability * 100 >> 16);
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
197 SetDParam(1, v->breakdowns_since_last_service);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
198 DrawString(2, 45, STR_9815_RELIABILITY_BREAKDOWNS, 0);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
199 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
200
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
201 /* Draw service interval text */
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
202 {
534
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
203 SetDParam(0, v->service_interval);
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
204 SetDParam(1, v->date_of_last_service);
156
951f85b8a32b (svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater <darkvater@openttd.org>
parents: 10
diff changeset
205 DrawString(13, 90, _patches.servint_ispercent?STR_SERVICING_INTERVAL_PERCENT:STR_883C_SERVICING_INTERVAL_DAYS, 0);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
206 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
207
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
208 DrawShipImage(v, 3, 57, INVALID_VEHICLE);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
209
534
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
210 SetDParam(1, 1920 + v->build_year);
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
211 SetDParam(0, GetCustomEngineName(v->engine_type));
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
212 SetDParam(2, v->value);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
213 DrawString(74, 57, STR_9816_BUILT_VALUE, 0);
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
214
2084
8e2162bf7fba (svn r2594) Fix: [strgen] Misc updates to the string system.
ludde <ludde@openttd.org>
parents: 1986
diff changeset
215 SetDParam(0, _cargoc.names_long[v->cargo_type]);
534
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
216 SetDParam(1, v->cargo_cap);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
217 DrawString(74, 67, STR_9817_CAPACITY, 0);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
218
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
219 str = STR_8812_EMPTY;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
220 if (v->cargo_count != 0) {
534
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
221 SetDParam(0, v->cargo_type);
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
222 SetDParam(1, v->cargo_count);
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
223 SetDParam(2, v->cargo_source);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
224 str = STR_8813_FROM;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
225 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
226 DrawString(74, 78, str, 0);
1790
1fb831153f4a (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater <Darkvater@openttd.org>
parents: 1751
diff changeset
227 } break;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
228
1790
1fb831153f4a (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater <Darkvater@openttd.org>
parents: 1751
diff changeset
229 case WE_CLICK: {
1fb831153f4a (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater <Darkvater@openttd.org>
parents: 1751
diff changeset
230 int mod;
1fb831153f4a (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater <Darkvater@openttd.org>
parents: 1751
diff changeset
231 const Vehicle *v;
1fb831153f4a (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater <Darkvater@openttd.org>
parents: 1751
diff changeset
232 switch (e->click.widget) {
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
233 case 2: /* rename */
1790
1fb831153f4a (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater <Darkvater@openttd.org>
parents: 1751
diff changeset
234 v = GetVehicle(w->window_number);
534
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
235 SetDParam(0, v->unitnumber);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
236 ShowQueryString(v->string_id, STR_9831_NAME_SHIP, 31, 150, w->window_class, w->window_number);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
237 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
238 case 5: /* increase int */
156
951f85b8a32b (svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater <darkvater@openttd.org>
parents: 10
diff changeset
239 mod = _ctrl_pressed? 5 : 10;
1790
1fb831153f4a (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater <Darkvater@openttd.org>
parents: 1751
diff changeset
240 goto do_change_service_int;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
241 case 6: /* decrease int */
156
951f85b8a32b (svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater <darkvater@openttd.org>
parents: 10
diff changeset
242 mod = _ctrl_pressed?- 5 : -10;
1790
1fb831153f4a (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater <Darkvater@openttd.org>
parents: 1751
diff changeset
243 do_change_service_int:
1fb831153f4a (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater <Darkvater@openttd.org>
parents: 1751
diff changeset
244 v = GetVehicle(w->window_number);
156
951f85b8a32b (svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater <darkvater@openttd.org>
parents: 10
diff changeset
245
1790
1fb831153f4a (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater <Darkvater@openttd.org>
parents: 1751
diff changeset
246 mod = GetServiceIntervalClamped(mod + v->service_interval);
1fb831153f4a (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater <Darkvater@openttd.org>
parents: 1751
diff changeset
247 if (mod == v->service_interval) return;
156
951f85b8a32b (svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater <darkvater@openttd.org>
parents: 10
diff changeset
248
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
249 DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_SHIP_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING));
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
250 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
251 }
1790
1fb831153f4a (svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater <Darkvater@openttd.org>
parents: 1751
diff changeset
252 } break;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
253
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
254 case WE_4:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
255 if (FindWindowById(WC_VEHICLE_VIEW, w->window_number) == NULL)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
256 DeleteWindow(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
257 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
258
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
259 case WE_ON_EDIT_TEXT: {
1820
bda7198fe6ba (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron <tron@openttd.org>
parents: 1802
diff changeset
260 if (e->edittext.str[0] != '\0') {
bda7198fe6ba (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron <tron@openttd.org>
parents: 1802
diff changeset
261 _cmd_text = e->edittext.str;
bda7198fe6ba (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron <tron@openttd.org>
parents: 1802
diff changeset
262 DoCommandP(0, w->window_number, 0, NULL,
bda7198fe6ba (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron <tron@openttd.org>
parents: 1802
diff changeset
263 CMD_NAME_VEHICLE | CMD_MSG(STR_9832_CAN_T_NAME_SHIP));
bda7198fe6ba (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron <tron@openttd.org>
parents: 1802
diff changeset
264 }
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
265 } break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
266
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
267 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
268 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
269
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
270
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
271 static const Widget _ship_details_widgets[] = {
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
272 { WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
273 { WWT_CAPTION, RESIZE_NONE, 14, 11, 364, 0, 13, STR_9811_DETAILS,STR_018C_WINDOW_TITLE_DRAG_THIS},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
274 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 365, 404, 0, 13, STR_01AA_NAME, STR_982F_NAME_SHIP},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
275 { WWT_IMGBTN, RESIZE_NONE, 14, 0, 404, 14, 55, 0x0, STR_NULL},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
276 { WWT_IMGBTN, RESIZE_NONE, 14, 0, 404, 56, 88, 0x0, STR_NULL},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
277 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 10, 89, 94, STR_0188, STR_884D_INCREASE_SERVICING_INTERVAL},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
278 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 10, 95, 100, STR_0189, STR_884E_DECREASE_SERVICING_INTERVAL},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
279 { WWT_IMGBTN, RESIZE_NONE, 14, 11, 404, 89, 100, 0x0, STR_NULL},
176
5ff3972188b5 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater <darkvater@openttd.org>
parents: 174
diff changeset
280 { WIDGETS_END},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
281 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
282
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
283 static const WindowDesc _ship_details_desc = {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
284 -1,-1, 405, 101,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
285 WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
286 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
287 _ship_details_widgets,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
288 ShipDetailsWndProc
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
289 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
290
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
291 static void ShowShipDetailsWindow(Vehicle *v)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
292 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
293 Window *w;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
294 VehicleID veh = v->index;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
295 DeleteWindowById(WC_VEHICLE_ORDERS, veh);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
296 DeleteWindowById(WC_VEHICLE_DETAILS, veh);
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
297 _alloc_wnd_parent_num = veh;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
298 w = AllocateWindowDesc(&_ship_details_desc);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
299 w->window_number = veh;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
300 w->caption_color = v->owner;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
301 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
302
1977
77a4977c3286 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron <tron@openttd.org>
parents: 1962
diff changeset
303 void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
304 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
305 Vehicle *v;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
306 if (!success) return;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
307
919
a2d3299a67ee (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight <truelight@openttd.org>
parents: 893
diff changeset
308 v = GetVehicle(_new_ship_id);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
309 if (v->tile == _backup_orders_tile) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
310 _backup_orders_tile = 0;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
311 RestoreVehicleOrders(v, _backup_orders_data);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
312 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
313 ShowShipViewWindow(v);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
314 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
315
2244
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
316 void CcCloneShip(bool success, uint tile, uint32 p1, uint32 p2)
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
317 {
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
318 Vehicle *v;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
319 if (!success) return;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
320
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
321 v = GetVehicle(_new_ship_id);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
322 ShowShipViewWindow(v);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
323 }
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
324
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
325 static void NewShipWndProc(Window *w, WindowEvent *e)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
326 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
327 switch(e->event) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
328 case WE_PAINT:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
329 if (w->window_number == 0)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
330 w->disabled_state = 1 << 5;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
331
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
332 // Setup scroll count
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
333 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
334 int count = 0;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
335 int num = NUM_SHIP_ENGINES;
1926
ae98b5ce63ee (svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron <tron@openttd.org>
parents: 1907
diff changeset
336 const Engine* e = GetEngine(SHIP_ENGINES_INDEX);
ae98b5ce63ee (svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron <tron@openttd.org>
parents: 1907
diff changeset
337
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
338 do {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
339 if (HASBIT(e->player_avail, _local_player))
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
340 count++;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
341 } while (++e,--num);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
342 SetVScrollCount(w, count);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
343 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
344
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
345 DrawWindowWidgets(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
346
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
347 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
348 int num = NUM_SHIP_ENGINES;
1926
ae98b5ce63ee (svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron <tron@openttd.org>
parents: 1907
diff changeset
349 const Engine* e = GetEngine(SHIP_ENGINES_INDEX);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
350 int x = 2;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
351 int y = 15;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
352 int sel = WP(w,buildtrain_d).sel_index;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
353 int pos = w->vscroll.pos;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
354 int engine_id = SHIP_ENGINES_INDEX;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
355 int selected_id = -1;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
356
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
357 do {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
358 if (HASBIT(e->player_avail, _local_player)) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
359 if (sel==0) selected_id = engine_id;
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
360 if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) {
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
361 DrawString(x+75, y+7, GetCustomEngineName(engine_id), sel==0 ? 0xC : 0x10);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
362 DrawShipEngine(x+35, y+10, engine_id, SPRITE_PALETTE(PLAYER_SPRITE_COLOR(_local_player)));
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
363 y += 24;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
364 }
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
365 sel--;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
366 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
367 } while (++engine_id, ++e,--num);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
368
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
369 WP(w,buildtrain_d).sel_engine = selected_id;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
370
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
371 if (selected_id != -1) {
1907
08ea04495b3b (svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid <hackykid@openttd.org>
parents: 1906
diff changeset
372 DrawShipPurchaseInfo(2, w->widget[4].top + 1, selected_id);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
373 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
374 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
375 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
376
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
377 case WE_CLICK:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
378 switch(e->click.widget) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
379 case 2: { /* listbox */
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
380 uint i = (e->click.pt.y - 14) / 24;
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
381 if (i < w->vscroll.cap) {
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
382 WP(w,buildtrain_d).sel_index = i + w->vscroll.pos;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
383 SetWindowDirty(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
384 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
385 } break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
386 case 5: { /* build */
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
387 int sel_eng = WP(w,buildtrain_d).sel_engine;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
388 if (sel_eng != -1)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
389 DoCommandP(w->window_number, sel_eng, 0, CcBuildShip, CMD_BUILD_SHIP | CMD_MSG(STR_980D_CAN_T_BUILD_SHIP));
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
390 } break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
391
968
37409fe6c801 (svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater <darkvater@openttd.org>
parents: 919
diff changeset
392 case 6: { /* rename */
37409fe6c801 (svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater <darkvater@openttd.org>
parents: 919
diff changeset
393 int sel_eng = WP(w,buildtrain_d).sel_engine;
37409fe6c801 (svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater <darkvater@openttd.org>
parents: 919
diff changeset
394 if (sel_eng != -1) {
37409fe6c801 (svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater <darkvater@openttd.org>
parents: 919
diff changeset
395 WP(w,buildtrain_d).rename_engine = sel_eng;
37409fe6c801 (svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater <darkvater@openttd.org>
parents: 919
diff changeset
396 ShowQueryString(GetCustomEngineName(sel_eng),
37409fe6c801 (svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater <darkvater@openttd.org>
parents: 919
diff changeset
397 STR_9838_RENAME_SHIP_TYPE, 31, 160, w->window_class, w->window_number);
37409fe6c801 (svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater <darkvater@openttd.org>
parents: 919
diff changeset
398 }
37409fe6c801 (svn r1463) -Fix: [1099451] Game crashes after the click on Rename (see also Bug 10992). There was no check for non-selected engine
darkvater <darkvater@openttd.org>
parents: 919
diff changeset
399 } break;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
400 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
401 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
402
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
403 case WE_4:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
404 if (w->window_number != 0 && !FindWindowById(WC_VEHICLE_DEPOT, w->window_number)) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
405 DeleteWindow(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
406 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
407 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
408
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
409 case WE_ON_EDIT_TEXT: {
1820
bda7198fe6ba (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron <tron@openttd.org>
parents: 1802
diff changeset
410 if (e->edittext.str[0] != '\0') {
bda7198fe6ba (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron <tron@openttd.org>
parents: 1802
diff changeset
411 _cmd_text = e->edittext.str;
bda7198fe6ba (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron <tron@openttd.org>
parents: 1802
diff changeset
412 DoCommandP(0, WP(w, buildtrain_d).rename_engine, 0, NULL,
bda7198fe6ba (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron <tron@openttd.org>
parents: 1802
diff changeset
413 CMD_RENAME_ENGINE | CMD_MSG(STR_9839_CAN_T_RENAME_SHIP_TYPE));
bda7198fe6ba (svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron <tron@openttd.org>
parents: 1802
diff changeset
414 }
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
415 } break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
416
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
417 case WE_RESIZE:
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
418 w->vscroll.cap += e->sizing.diff.y / 24;
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
419 w->widget[2].unkA = (w->vscroll.cap << 8) + 1;
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
420 break;
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
421
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
422 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
423 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
424
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
425 static const Widget _new_ship_widgets[] = {
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
426 { WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
427 { WWT_CAPTION, RESIZE_NONE, 14, 11, 254, 0, 13, STR_9808_NEW_SHIPS, STR_018C_WINDOW_TITLE_DRAG_THIS},
893
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 886
diff changeset
428 { WWT_MATRIX, RESIZE_BOTTOM, 14, 0, 242, 14, 109, 0x401, STR_9825_SHIP_SELECTION_LIST_CLICK},
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 886
diff changeset
429 { WWT_SCROLLBAR, RESIZE_BOTTOM, 14, 243, 254, 14, 109, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
430 { WWT_IMGBTN, RESIZE_TB, 14, 0, 254, 110, 161, 0x0, STR_NULL},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
431 { WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 121, 162, 173, STR_9809_BUILD_SHIP, STR_9826_BUILD_THE_HIGHLIGHTED_SHIP},
893
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 886
diff changeset
432 { WWT_PUSHTXTBTN, RESIZE_TB, 14, 122, 242, 162, 173, STR_9836_RENAME, STR_9837_RENAME_SHIP_TYPE},
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 886
diff changeset
433 { WWT_RESIZEBOX, RESIZE_TB, 14, 243, 254, 162, 173, 0x0, STR_RESIZE_BUTTON},
176
5ff3972188b5 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater <darkvater@openttd.org>
parents: 174
diff changeset
434 { WIDGETS_END},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
435 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
436
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
437 static const WindowDesc _new_ship_desc = {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
438 -1, -1, 255, 174,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
439 WC_BUILD_VEHICLE,0,
893
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 886
diff changeset
440 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
441 _new_ship_widgets,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
442 NewShipWndProc
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
443 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
444
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
445
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
446 static void ShowBuildShipWindow(TileIndex tile)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
447 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
448 Window *w;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
449
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
450 DeleteWindowById(WC_BUILD_VEHICLE, tile);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
451
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
452 w = AllocateWindowDesc(&_new_ship_desc);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
453 w->window_number = tile;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
454 w->vscroll.cap = 4;
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
455 w->widget[2].unkA = (w->vscroll.cap << 8) + 1;
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
456
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
457 w->resize.step_height = 24;
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
458
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
459 if (tile != 0) {
1901
74e0d3101dfb (svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron <tron@openttd.org>
parents: 1891
diff changeset
460 w->caption_color = GetTileOwner(tile);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
461 } else {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
462 w->caption_color = _local_player;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
463 }
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
464
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
465 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
466
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
467
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
468 static void ShipViewWndProc(Window *w, WindowEvent *e) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
469 switch(e->event) {
2244
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
470 case WE_PAINT: {
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
471 Vehicle *v = GetVehicle(w->window_number);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
472 uint32 disabled = 1<<8;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
473 StringID str;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
474
2244
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
475 // Possible to refit?
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
476 if (ShipVehInfo(v->engine_type)->refittable &&
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
477 v->vehstatus&VS_STOPPED &&
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
478 v->u.ship.state == 0x80 &&
1330
173a680c6b5f (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs <matthijs@openttd.org>
parents: 1323
diff changeset
479 IsTileDepotType(v->tile, TRANSPORT_WATER))
2244
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
480 disabled = 0;
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
481
2244
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
482 if (v->owner != _local_player)
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
483 disabled |= 1<<8 | 1<<7;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
484 w->disabled_state = disabled;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
485
2244
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
486 /* draw widgets & caption */
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
487 SetDParam(0, v->string_id);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
488 SetDParam(1, v->unitnumber);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
489 DrawWindowWidgets(w);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
490
2244
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
491 if (v->breakdown_ctr == 1) {
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
492 str = STR_885C_BROKEN_DOWN;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
493 } else if (v->vehstatus & VS_STOPPED) {
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
494 str = STR_8861_STOPPED;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
495 } else {
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
496 switch (v->current_order.type) {
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
497 case OT_GOTO_STATION: {
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
498 SetDParam(0, v->current_order.station);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
499 SetDParam(1, v->cur_speed * 10 >> 5);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
500 str = STR_HEADING_FOR_STATION + _patches.vehicle_speed;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
501 } break;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
502
2244
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
503 case OT_GOTO_DEPOT: {
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
504 Depot *depot = GetDepot(v->current_order.station);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
505 SetDParam(0, depot->town_index);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
506 SetDParam(1, v->cur_speed * 10 >> 5);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
507 str = STR_HEADING_FOR_SHIP_DEPOT + _patches.vehicle_speed;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
508 } break;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
509
2244
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
510 case OT_LOADING:
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
511 case OT_LEAVESTATION:
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
512 str = STR_882F_LOADING_UNLOADING;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
513 break;
2261
f51e788f7b9c (svn r2781) Fix some of the issues with variables in .h files.
ludde <ludde@openttd.org>
parents: 2252
diff changeset
514
2244
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
515 default:
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
516 if (v->num_orders == 0) {
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
517 str = STR_NO_ORDERS + _patches.vehicle_speed;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
518 SetDParam(0, v->cur_speed * 10 >> 5);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
519 } else
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
520 str = STR_EMPTY;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
521 break;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
522 }
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
523 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
524
2103
08b71e16627b (svn r2613) - Truncate savegames, and vehicle-texts in their window.
Darkvater <Darkvater@openttd.org>
parents: 2084
diff changeset
525 /* draw the flag plus orders */
2113
8f88dc2df50e (svn r2623) - CodeChange: rework DrawStringCenteredTruncated() a bit. Instead of giving center + width you give the coordinates of the bounding box (left, right) it has to fit in (ludde)
Darkvater <Darkvater@openttd.org>
parents: 2103
diff changeset
526 DrawSprite(v->vehstatus & VS_STOPPED ? 0xC12 : 0xC13, 2, w->widget[5].top + 1);
8f88dc2df50e (svn r2623) - CodeChange: rework DrawStringCenteredTruncated() a bit. Instead of giving center + width you give the coordinates of the bounding box (left, right) it has to fit in (ludde)
Darkvater <Darkvater@openttd.org>
parents: 2103
diff changeset
527 DrawStringCenteredTruncated(w->widget[5].left + 8, w->widget[5].right, w->widget[5].top + 1, str, 0);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
528 DrawWindowViewport(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
529 } break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
530
2244
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
531 case WE_CLICK: {
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
532 Vehicle *v = GetVehicle(w->window_number);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
533
2244
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
534 switch(e->click.widget) {
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
535 case 5: /* start stop */
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
536 DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_SHIP | CMD_MSG(STR_9818_CAN_T_STOP_START_SHIP));
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
537 break;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
538 case 6: /* center main view */
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
539 ScrollMainWindowTo(v->x_pos, v->y_pos);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
540 break;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
541 case 7: /* goto hangar */
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
542 DoCommandP(v->tile, v->index, 0, NULL, CMD_SEND_SHIP_TO_DEPOT | CMD_MSG(STR_9819_CAN_T_SEND_SHIP_TO_DEPOT));
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
543 break;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
544 case 8: /* refit */
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
545 ShowShipRefitWindow(v);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
546 break;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
547 case 9: /* show orders */
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
548 ShowOrdersWindow(v);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
549 break;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
550 case 10: /* show details */
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
551 ShowShipDetailsWindow(v);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
552 break;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
553 case 11: {
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
554 /* clone vehicle */
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
555 Vehicle *v;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
556 v = GetVehicle(w->window_number);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
557 DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, CcCloneShip, CMD_CLONE_VEHICLE | CMD_MSG(STR_980D_CAN_T_BUILD_SHIP));
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
558 } break;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
559 }
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
560 } break;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
561
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
562 case WE_RESIZE:
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
563 w->viewport->width += e->sizing.diff.x;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
564 w->viewport->height += e->sizing.diff.y;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
565 w->viewport->virtual_width += e->sizing.diff.x;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
566 w->viewport->virtual_height += e->sizing.diff.y;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
567 break;
2244
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
568
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
569 case WE_DESTROY:
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
570 DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
571 DeleteWindowById(WC_VEHICLE_REFIT, w->window_number);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
572 DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
573 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
574
2244
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
575 case WE_MOUSELOOP:
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
576 {
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
577 Vehicle *v;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
578 uint32 h;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
579 v = GetVehicle(w->window_number);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
580 h = IsTileDepotType(v->tile, TRANSPORT_WATER) && v->vehstatus & VS_HIDDEN ? (1<< 7) : (1 << 11);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
581 if (h != w->hidden_state) {
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
582 w->hidden_state = h;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
583 SetWindowDirty(w);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
584 }
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
585 }
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
586 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
587 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
588
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
589 static const Widget _ship_view_widgets[] = {
1485
c670741d3ada (svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron <tron@openttd.org>
parents: 1330
diff changeset
590 { WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
c670741d3ada (svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron <tron@openttd.org>
parents: 1330
diff changeset
591 { WWT_CAPTION, RESIZE_RIGHT, 14, 11, 237, 0, 13, STR_980F, STR_018C_WINDOW_TITLE_DRAG_THIS},
c670741d3ada (svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron <tron@openttd.org>
parents: 1330
diff changeset
592 { WWT_STICKYBOX, RESIZE_LR, 14, 238, 249, 0, 13, 0x0, STR_STICKY_BUTTON},
c670741d3ada (svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron <tron@openttd.org>
parents: 1330
diff changeset
593 { WWT_IMGBTN, RESIZE_RB, 14, 0, 231, 14, 103, 0x0, STR_NULL},
c670741d3ada (svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron <tron@openttd.org>
parents: 1330
diff changeset
594 { WWT_6, RESIZE_RB, 14, 2, 229, 16, 101, 0x0, STR_NULL},
c670741d3ada (svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron <tron@openttd.org>
parents: 1330
diff changeset
595 { WWT_PUSHIMGBTN, RESIZE_RTB, 14, 0, 237, 104, 115, 0x0, STR_9827_CURRENT_SHIP_ACTION_CLICK},
c670741d3ada (svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron <tron@openttd.org>
parents: 1330
diff changeset
596 { WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 14, 31, 0x2AB, STR_9829_CENTER_MAIN_VIEW_ON_SHIP},
c670741d3ada (svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron <tron@openttd.org>
parents: 1330
diff changeset
597 { WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, 0x2B0, STR_982A_SEND_SHIP_TO_DEPOT},
c670741d3ada (svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron <tron@openttd.org>
parents: 1330
diff changeset
598 { WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 50, 67, 0x2B4, STR_983A_REFIT_CARGO_SHIP_TO_CARRY},
c670741d3ada (svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron <tron@openttd.org>
parents: 1330
diff changeset
599 { WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 68, 85, 0x2B2, STR_9828_SHOW_SHIP_S_ORDERS},
c670741d3ada (svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron <tron@openttd.org>
parents: 1330
diff changeset
600 { WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 86, 103, 0x2B3, STR_982B_SHOW_SHIP_DETAILS},
2244
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
601 { WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, SPR_CLONE_SHIP, STR_CLONE_SHIP_INFO},
1485
c670741d3ada (svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron <tron@openttd.org>
parents: 1330
diff changeset
602 { WWT_PANEL, RESIZE_LRB, 14, 232, 249, 104, 103, 0x0, STR_NULL },
c670741d3ada (svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron <tron@openttd.org>
parents: 1330
diff changeset
603 { WWT_RESIZEBOX, RESIZE_LRTB, 14, 238, 249, 104, 115, 0x0, STR_NULL },
c670741d3ada (svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron <tron@openttd.org>
parents: 1330
diff changeset
604 { WIDGETS_END }
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
605 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
606
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
607 static const WindowDesc _ship_view_desc = {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
608 -1,-1, 250, 116,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
609 WC_VEHICLE_VIEW,0,
1485
c670741d3ada (svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron <tron@openttd.org>
parents: 1330
diff changeset
610 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
611 _ship_view_widgets,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
612 ShipViewWndProc
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
613 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
614
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
615 void ShowShipViewWindow(Vehicle *v)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
616 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
617 Window *w;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
618
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
619 w = AllocateWindowDescFront(&_ship_view_desc, v->index);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
620 if (w) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
621 w->caption_color = v->owner;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
622 AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
623 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
624 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
625
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
626 static void DrawShipDepotWindow(Window *w)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
627 {
1977
77a4977c3286 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron <tron@openttd.org>
parents: 1962
diff changeset
628 TileIndex tile;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
629 Vehicle *v;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
630 int num,x,y;
1313
cc5956ea3da8 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight <truelight@openttd.org>
parents: 1299
diff changeset
631 Depot *depot;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
632
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
633 tile = w->window_number;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
634
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
635 /* setup disabled buttons */
1901
74e0d3101dfb (svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron <tron@openttd.org>
parents: 1891
diff changeset
636 w->disabled_state =
74e0d3101dfb (svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron <tron@openttd.org>
parents: 1891
diff changeset
637 IsTileOwner(tile, _local_player) ? 0 : ((1 << 4) | (1 << 7));
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
638
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
639 /* determine amount of items for scroller */
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
640 num = 0;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
641 FOR_ALL_VEHICLES(v) {
1986
f76b751f081c (svn r2492) Remove some pointless casts and fix some nearby indentation
tron <tron@openttd.org>
parents: 1977
diff changeset
642 if (v->type == VEH_Ship && v->u.ship.state == 0x80 && v->tile == tile)
f76b751f081c (svn r2492) Remove some pointless casts and fix some nearby indentation
tron <tron@openttd.org>
parents: 1977
diff changeset
643 num++;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
644 }
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
645 SetVScrollCount(w, (num + w->hscroll.cap - 1) / w->hscroll.cap);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
646
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
647 /* locate the depot struct */
1313
cc5956ea3da8 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight <truelight@openttd.org>
parents: 1299
diff changeset
648 depot = GetDepotByTile(tile);
cc5956ea3da8 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight <truelight@openttd.org>
parents: 1299
diff changeset
649 assert(depot != NULL);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
650
1313
cc5956ea3da8 (svn r1817) -Codechange: Moved depot-functions to depot.c
truelight <truelight@openttd.org>
parents: 1299
diff changeset
651 SetDParam(0, depot->town_index);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
652 DrawWindowWidgets(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
653
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
654 x = 2;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
655 y = 15;
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
656 num = w->vscroll.pos * w->hscroll.cap;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
657
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
658 FOR_ALL_VEHICLES(v) {
1986
f76b751f081c (svn r2492) Remove some pointless casts and fix some nearby indentation
tron <tron@openttd.org>
parents: 1977
diff changeset
659 if (v->type == VEH_Ship && v->u.ship.state == 0x80 && v->tile == tile &&
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
660 --num < 0 && num >= -w->vscroll.cap * w->hscroll.cap) {
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
661 DrawShipImage(v, x+19, y, WP(w,traindepot_d).sel);
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
662
534
6de858608a45 (svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents: 507
diff changeset
663 SetDParam(0, v->unitnumber);
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
664 DrawString(x, y+2, (uint16)(v->max_age-366) >= v->age ? STR_00E2 : STR_00E3, 0);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
665
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
666 DrawSprite( (v->vehstatus & VS_STOPPED) ? 0xC12 : 0xC13, x, y + 9);
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
667
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
668 if ((x+=90) == 2 + 90 * w->hscroll.cap) {
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
669 x = 2;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
670 y += 24;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
671 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
672 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
673 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
674 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
675
2436
027bdc04f0ed (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater <Darkvater@openttd.org>
parents: 2406
diff changeset
676 static int GetVehicleFromShipDepotWndPt(const Window *w, int x, int y, Vehicle **veh)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
677 {
969
c44e08bc8213 (svn r1464) -Fix: [1099106] Resizeable portion of bus/air/rail depots window unclickable
darkvater <darkvater@openttd.org>
parents: 968
diff changeset
678 uint xt,row,xm,ym;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
679 TileIndex tile;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
680 Vehicle *v;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
681 int pos;
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
682
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
683 xt = x / 90;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
684 xm = x % 90;
971
508de8c64965 (svn r1466) -Fix: oops, depot windows can of course also scroll horizontally. Thanks si-m1.
darkvater <darkvater@openttd.org>
parents: 969
diff changeset
685 if (xt >= w->hscroll.cap)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
686 return 1;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
687
969
c44e08bc8213 (svn r1464) -Fix: [1099106] Resizeable portion of bus/air/rail depots window unclickable
darkvater <darkvater@openttd.org>
parents: 968
diff changeset
688 row = (y - 14) / 24;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
689 ym = (y - 14) % 24;
969
c44e08bc8213 (svn r1464) -Fix: [1099106] Resizeable portion of bus/air/rail depots window unclickable
darkvater <darkvater@openttd.org>
parents: 968
diff changeset
690 if (row >= w->vscroll.cap)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
691 return 1;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
692
971
508de8c64965 (svn r1466) -Fix: oops, depot windows can of course also scroll horizontally. Thanks si-m1.
darkvater <darkvater@openttd.org>
parents: 969
diff changeset
693 pos = (row + w->vscroll.pos) * w->hscroll.cap + xt;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
694
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
695 tile = w->window_number;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
696 FOR_ALL_VEHICLES(v) {
1986
f76b751f081c (svn r2492) Remove some pointless casts and fix some nearby indentation
tron <tron@openttd.org>
parents: 1977
diff changeset
697 if (v->type == VEH_Ship && v->vehstatus & VS_HIDDEN && v->tile == tile &&
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
698 --pos < 0) {
1986
f76b751f081c (svn r2492) Remove some pointless casts and fix some nearby indentation
tron <tron@openttd.org>
parents: 1977
diff changeset
699 *veh = v;
f76b751f081c (svn r2492) Remove some pointless casts and fix some nearby indentation
tron <tron@openttd.org>
parents: 1977
diff changeset
700 if (xm >= 19) return 0;
f76b751f081c (svn r2492) Remove some pointless casts and fix some nearby indentation
tron <tron@openttd.org>
parents: 1977
diff changeset
701 if (ym <= 10) return -1; /* show window */
f76b751f081c (svn r2492) Remove some pointless casts and fix some nearby indentation
tron <tron@openttd.org>
parents: 1977
diff changeset
702 return -2; /* start stop */
f76b751f081c (svn r2492) Remove some pointless casts and fix some nearby indentation
tron <tron@openttd.org>
parents: 1977
diff changeset
703 }
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
704 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
705
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
706 return 1; /* outside */
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
707
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
708 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
709
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
710 static void ShipDepotClick(Window *w, int x, int y)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
711 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
712 Vehicle *v;
10
c4dee32d5f22 (svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik <dominik@openttd.org>
parents: 0
diff changeset
713 int mode = GetVehicleFromShipDepotWndPt(w, x, y, &v);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
714
10
c4dee32d5f22 (svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik <dominik@openttd.org>
parents: 0
diff changeset
715 // share / copy orders
c4dee32d5f22 (svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik <dominik@openttd.org>
parents: 0
diff changeset
716 if (_thd.place_mode && mode <= 0) { _place_clicked_vehicle = v; return; }
c4dee32d5f22 (svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik <dominik@openttd.org>
parents: 0
diff changeset
717
c4dee32d5f22 (svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik <dominik@openttd.org>
parents: 0
diff changeset
718 switch (mode) {
c4dee32d5f22 (svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik <dominik@openttd.org>
parents: 0
diff changeset
719 case 1: // invalid
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
720 return;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
721
10
c4dee32d5f22 (svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik <dominik@openttd.org>
parents: 0
diff changeset
722 case 0: // start dragging of vehicle
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
723 if (v != NULL) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
724 WP(w,traindepot_d).sel = v->index;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
725 SetWindowDirty(w);
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
726 SetObjectToPlaceWnd( SPRITE_PALETTE(PLAYER_SPRITE_COLOR(v->owner)) +
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
727 GetShipImage(v, 6), 4, w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
728 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
729 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
730
10
c4dee32d5f22 (svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik <dominik@openttd.org>
parents: 0
diff changeset
731 case -1: // show info window
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
732 ShowShipViewWindow(v);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
733 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
734
10
c4dee32d5f22 (svn r11) Feature: Copy/share orders now works from ship depot window for ships and hangar window for aircraft
dominik <dominik@openttd.org>
parents: 0
diff changeset
735 case -2: // click start/stop flag
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
736 DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_SHIP | CMD_MSG(STR_9818_CAN_T_STOP_START_SHIP));
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
737 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
738
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
739 default:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
740 NOT_REACHED();
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
741 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
742 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
743
2244
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
744 /**
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
745 * Clones a ship
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
746 * @param *v is the original vehicle to clone
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
747 * @param *w is the window of the depot where the clone is build
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
748 */
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
749 static bool HandleCloneVehClick(Vehicle *v, Window *w)
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
750 {
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
751
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
752 if (!v){
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
753 return false;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
754 }
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
755
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
756 if (v->type != VEH_Ship) {
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
757 // it's not a ship, do nothing
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
758 return false;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
759 }
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
760
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
761
2273
38ac04f2976a (svn r2795) -Fix: [Clone vehilcle] all error messages should now tell the right vehicle type (chrishuebsch)
bjarni <bjarni@openttd.org>
parents: 2261
diff changeset
762 DoCommandP(w->window_number, v->index, _ctrl_pressed ? 1 : 0,CcCloneShip,CMD_CLONE_VEHICLE | CMD_MSG(STR_980D_CAN_T_BUILD_SHIP));
2244
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
763
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
764 ResetObjectToPlace();
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
765
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
766 return true;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
767 }
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
768
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
769 static void ClonePlaceObj(uint tile, Window *w)
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
770 {
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
771 Vehicle *v;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
772
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
773
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
774 v = CheckMouseOverVehicle();
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
775 if (v && HandleCloneVehClick(v, w))
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
776 return;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
777 }
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
778
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
779 static void ShipDepotWndProc(Window *w, WindowEvent *e) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
780 switch(e->event) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
781 case WE_PAINT:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
782 DrawShipDepotWindow(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
783 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
784
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
785 case WE_CLICK:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
786 switch(e->click.widget) {
982
1e71101f219c (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater <darkvater@openttd.org>
parents: 971
diff changeset
787 case 5:
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
788 ShipDepotClick(w, e->click.pt.x, e->click.pt.y);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
789 break;
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
790
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
791 case 7:
2244
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
792 ResetObjectToPlace();
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
793 ShowBuildShipWindow(w->window_number);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
794 break;
2261
f51e788f7b9c (svn r2781) Fix some of the issues with variables in .h files.
ludde <ludde@openttd.org>
parents: 2252
diff changeset
795
2244
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
796 case 8: /* clone button */
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
797 InvalidateWidget(w, 8);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
798 TOGGLEBIT(w->click_state, 8);
2261
f51e788f7b9c (svn r2781) Fix some of the issues with variables in .h files.
ludde <ludde@openttd.org>
parents: 2252
diff changeset
799
2244
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
800 if (HASBIT(w->click_state, 8)) {
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
801 _place_clicked_vehicle = NULL;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
802 SetObjectToPlaceWnd(SPR_CURSOR_CLONE, VHM_RECT, w);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
803 } else {
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
804 ResetObjectToPlace();
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
805 }
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
806 break;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
807
2244
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
808 case 9: /* scroll to tile */
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
809 ResetObjectToPlace();
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
810 ScrollMainWindowToTile(w->window_number);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
811 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
812 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
813 break;
2261
f51e788f7b9c (svn r2781) Fix some of the issues with variables in .h files.
ludde <ludde@openttd.org>
parents: 2252
diff changeset
814
2244
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
815 case WE_PLACE_OBJ: {
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
816 //ClonePlaceObj(e->place.tile, w);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
817 ClonePlaceObj(w->window_number, w);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
818 } break;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
819
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
820 case WE_ABORT_PLACE_OBJ: {
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
821 CLRBIT(w->click_state, 8);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
822 InvalidateWidget(w, 8);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
823 } break;
2261
f51e788f7b9c (svn r2781) Fix some of the issues with variables in .h files.
ludde <ludde@openttd.org>
parents: 2252
diff changeset
824
2244
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
825 // check if a vehicle in a depot was clicked..
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
826 case WE_MOUSELOOP: {
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
827 Vehicle *v = _place_clicked_vehicle;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
828
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
829 // since OTTD checks all open depot windows, we will make sure that it triggers the one with a clicked clone button
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
830 if (v != NULL && HASBIT(w->click_state, 8)) {
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
831 _place_clicked_vehicle = NULL;
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
832 HandleCloneVehClick(v, w);
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
833 }
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
834 } break;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
835
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
836 case WE_DESTROY:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
837 DeleteWindowById(WC_BUILD_VEHICLE, w->window_number);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
838 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
839
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
840 case WE_DRAGDROP: {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
841 switch(e->click.widget) {
982
1e71101f219c (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater <darkvater@openttd.org>
parents: 971
diff changeset
842 case 5: {
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
843 Vehicle *v;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
844 VehicleID sel = WP(w,traindepot_d).sel;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
845
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
846 WP(w,traindepot_d).sel = INVALID_VEHICLE;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
847 SetWindowDirty(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
848
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
849 if (GetVehicleFromShipDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &v) == 0 &&
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
850 v != NULL &&
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
851 sel == v->index) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
852 ShowShipViewWindow(v);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
853 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
854 } break;
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
855
982
1e71101f219c (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater <darkvater@openttd.org>
parents: 971
diff changeset
856 case 4:
1e71101f219c (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater <darkvater@openttd.org>
parents: 971
diff changeset
857 if (!HASBIT(w->disabled_state, 4) &&
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
858 WP(w,traindepot_d).sel != INVALID_VEHICLE) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
859 Vehicle *v;
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
860
982
1e71101f219c (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater <darkvater@openttd.org>
parents: 971
diff changeset
861 HandleButtonClick(w, 4);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
862
919
a2d3299a67ee (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight <truelight@openttd.org>
parents: 893
diff changeset
863 v = GetVehicle(WP(w,traindepot_d).sel);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
864 WP(w,traindepot_d).sel = INVALID_VEHICLE;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
865
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
866 _backup_orders_tile = v->tile;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
867 BackupVehicleOrders(v, _backup_orders_data);
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
868
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
869 if (!DoCommandP(v->tile, v->index, 0, NULL, CMD_SELL_SHIP | CMD_MSG(STR_980C_CAN_T_SELL_SHIP)))
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
870 _backup_orders_tile = 0;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
871 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
872 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
873 default:
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
874 WP(w,traindepot_d).sel = INVALID_VEHICLE;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
875 SetWindowDirty(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
876 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
877 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
878 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
879 break;
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
880
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
881 case WE_RESIZE:
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
882 w->vscroll.cap += e->sizing.diff.y / 24;
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
883 w->hscroll.cap += e->sizing.diff.x / 90;
982
1e71101f219c (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater <darkvater@openttd.org>
parents: 971
diff changeset
884 w->widget[5].unkA = (w->vscroll.cap << 8) + w->hscroll.cap;
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
885 break;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
886 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
887 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
888
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
889 static const Widget _ship_depot_widgets[] = {
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
890 { WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
891 { WWT_CAPTION, RESIZE_RIGHT, 14, 11, 292, 0, 13, STR_9803_SHIP_DEPOT, STR_018C_WINDOW_TITLE_DRAG_THIS},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
892 { WWT_STICKYBOX, RESIZE_LR, 14, 293, 304, 0, 13, 0x0, STR_STICKY_BUTTON},
982
1e71101f219c (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater <darkvater@openttd.org>
parents: 971
diff changeset
893 { WWT_PANEL, RESIZE_LRB, 14, 270, 292, 14, 13, 0x0, STR_NULL},
1e71101f219c (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater <darkvater@openttd.org>
parents: 971
diff changeset
894 { WWT_IMGBTN, RESIZE_LRTB, 14, 270, 292, 14, 61, 0x2A9, STR_9821_DRAG_SHIP_TO_HERE_TO_SELL},
1e71101f219c (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater <darkvater@openttd.org>
parents: 971
diff changeset
895
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
896 { WWT_MATRIX, RESIZE_RB, 14, 0, 269, 14, 61, 0x203, STR_981F_SHIPS_CLICK_ON_SHIP_FOR},
893
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 886
diff changeset
897 { WWT_SCROLLBAR, RESIZE_LRB, 14, 293, 304, 14, 61, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
2244
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
898 { WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 96, 62, 73, STR_9804_NEW_SHIPS, STR_9820_BUILD_NEW_SHIP},
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
899 {WWT_NODISTXTBTN, RESIZE_TB, 14, 97, 194, 62, 73, STR_CLONE_SHIP, STR_CLONE_SHIP_DEPOT_INFO},
eba7ec7edf28 (svn r2764) -Feature: Clone vehicles
bjarni <bjarni@openttd.org>
parents: 2187
diff changeset
900 { WWT_PUSHTXTBTN, RESIZE_TB, 14, 195, 292, 62, 73, STR_00E4_LOCATION, STR_9822_CENTER_MAIN_VIEW_ON_SHIP},
893
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 886
diff changeset
901 { WWT_PANEL, RESIZE_RTB, 14, 293, 292, 62, 73, 0x0, STR_NULL},
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 886
diff changeset
902 { WWT_RESIZEBOX, RESIZE_LRTB, 14, 293, 304, 62, 73, 0x0, STR_RESIZE_BUTTON},
176
5ff3972188b5 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater <darkvater@openttd.org>
parents: 174
diff changeset
903 { WIDGETS_END},
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
904 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
905
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
906 static const WindowDesc _ship_depot_desc = {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
907 -1, -1, 305, 74,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
908 WC_VEHICLE_DEPOT,0,
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
909 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
910 _ship_depot_widgets,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
911 ShipDepotWndProc
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
912 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
913
1977
77a4977c3286 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron <tron@openttd.org>
parents: 1962
diff changeset
914 void ShowShipDepotWindow(TileIndex tile)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
915 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
916 Window *w;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
917
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
918 w = AllocateWindowDescFront(&_ship_depot_desc,tile);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
919 if (w) {
1901
74e0d3101dfb (svn r2407) Use {Get,Is}TileOwner to get/check the owner of a tile and fix some bogus reads of _map_owner
tron <tron@openttd.org>
parents: 1891
diff changeset
920 w->caption_color = GetTileOwner(w->window_number);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
921 w->vscroll.cap = 2;
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
922 w->hscroll.cap = 3;
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
923 w->resize.step_width = 90;
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
924 w->resize.step_height = 24;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
925 WP(w,traindepot_d).sel = INVALID_VEHICLE;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
926 _backup_orders_tile = 0;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
927 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
928 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
929
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
930
2436
027bdc04f0ed (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater <Darkvater@openttd.org>
parents: 2406
diff changeset
931 static void DrawSmallOrderList(const Vehicle *v, int x, int y) {
1024
fc72cf555e80 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight <truelight@openttd.org>
parents: 982
diff changeset
932 const Order *order;
fc72cf555e80 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight <truelight@openttd.org>
parents: 982
diff changeset
933 int sel, i = 0;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
934
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
935 sel = v->cur_order_index;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
936
1108
3002e3d36119 (svn r1609) -Codechange: converted the last order-loop with FOR_VEHICLE_ORDERS
truelight <truelight@openttd.org>
parents: 1055
diff changeset
937 FOR_VEHICLE_ORDERS(v, order) {
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
938 if (sel == 0) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
939 _stringwidth_base = 0xE0;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
940 DoDrawString( "\xAF", x-6, y, 16);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
941 _stringwidth_base = 0;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
942 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
943 sel--;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
944
1024
fc72cf555e80 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight <truelight@openttd.org>
parents: 982
diff changeset
945 if (order->type == OT_GOTO_STATION) {
1751
ae5bf77adcae (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs <matthijs@openttd.org>
parents: 1485
diff changeset
946 if (!IsBuoy(GetStation(order->station))){
1024
fc72cf555e80 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight <truelight@openttd.org>
parents: 982
diff changeset
947 SetDParam(0, order->station);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
948 DrawString(x, y, STR_A036, 0);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
949
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
950 y += 6;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
951 if (++i == 4)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
952 break;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
953 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
954 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
955 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
956 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
957
243
827b0d059794 (svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater <darkvater@openttd.org>
parents: 193
diff changeset
958
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
959 static const Widget _player_ships_widgets[] = {
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
960 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
961 { WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_9805_SHIPS, STR_018C_WINDOW_TITLE_DRAG_THIS},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
962 { WWT_STICKYBOX, RESIZE_LR, 14, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
963 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_ORDER_TIP},
893
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 886
diff changeset
964 { WWT_PANEL, RESIZE_NONE, 14, 81, 235, 14, 25, 0x0, STR_SORT_CRITERIA_TIP},
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 886
diff changeset
965 { WWT_CLOSEBOX, RESIZE_NONE, 14, 236, 247, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP},
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 886
diff changeset
966 { WWT_PANEL, RESIZE_RIGHT, 14, 248, 259, 14, 25, 0x0, STR_NULL},
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
967 { WWT_MATRIX, RESIZE_RB, 14, 0, 248, 26, 169, 0x401, STR_9823_SHIPS_CLICK_ON_SHIP_FOR},
893
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 886
diff changeset
968 { WWT_SCROLLBAR, RESIZE_LRB, 14, 248, 259, 26, 169, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
969 { WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 124, 170, 181, STR_9804_NEW_SHIPS, STR_9824_BUILD_NEW_SHIPS_REQUIRES},
893
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 886
diff changeset
970 { WWT_PUSHTXTBTN, RESIZE_TB, 14, 125, 247, 170, 181, STR_REPLACE_VEHICLES, STR_REPLACE_HELP},
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 886
diff changeset
971 { WWT_PANEL, RESIZE_RTB, 14, 248, 247, 170, 181, 0x0, STR_NULL},
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 886
diff changeset
972 { WWT_RESIZEBOX, RESIZE_LRTB, 14, 248, 259, 170, 181, 0x0, STR_RESIZE_BUTTON},
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
973 { WIDGETS_END},
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
974 };
164
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
975
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
976 static const Widget _other_player_ships_widgets[] = {
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
977 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
978 { WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_9805_SHIPS, STR_018C_WINDOW_TITLE_DRAG_THIS},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
979 { WWT_STICKYBOX, RESIZE_LR, 14, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON},
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
980 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_ORDER_TIP},
893
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 886
diff changeset
981 { WWT_PANEL, RESIZE_NONE, 14, 81, 235, 14, 25, 0x0, STR_SORT_CRITERIA_TIP},
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 886
diff changeset
982 { WWT_CLOSEBOX, RESIZE_NONE, 14, 236, 247, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP},
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 886
diff changeset
983 { WWT_PANEL, RESIZE_RIGHT, 14, 248, 259, 14, 25, 0x0, STR_NULL},
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 886
diff changeset
984 { WWT_MATRIX, RESIZE_RB, 14, 0, 247, 26, 169, 0x401, STR_9823_SHIPS_CLICK_ON_SHIP_FOR},
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 886
diff changeset
985 { WWT_SCROLLBAR, RESIZE_LRB, 14, 248, 259, 26, 169, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 886
diff changeset
986 { WWT_PANEL, RESIZE_RTB, 14, 0, 247, 170, 181, 0x0, STR_NULL},
6803b1ba0116 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater <darkvater@openttd.org>
parents: 886
diff changeset
987 { WWT_RESIZEBOX, RESIZE_LRTB, 14, 248, 259, 170, 181, 0x0, STR_RESIZE_BUTTON},
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
988 { WIDGETS_END},
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
989 };
164
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
990
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
991 static void PlayerShipsWndProc(Window *w, WindowEvent *e)
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
992 {
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
993 int station = (int)w->window_number >> 16;
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
994 int owner = w->window_number & 0xff;
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
995 vehiclelist_d *vl = &WP(w, vehiclelist_d);
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
996
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
997 switch(e->event) {
164
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
998 case WE_PAINT: {
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
999 int x = 2;
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1000 int y = PLY_WND_PRC__OFFSET_TOP_WIDGET;
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1001 int max;
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1002 int i;
243
827b0d059794 (svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater <darkvater@openttd.org>
parents: 193
diff changeset
1003
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1004 BuildVehicleList(vl, VEH_Ship, owner, station);
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1005 SortVehicleList(vl);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1006
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1007 SetVScrollCount(w, vl->list_length);
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1008
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1009 // disable 'Sort By' tooltip on Unsorted sorting criteria
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1010 if (vl->sort_type == SORT_BY_UNSORTED)
757
640102936d2f (svn r1213) -Feature: Stickified vehicle lists
darkvater <darkvater@openttd.org>
parents: 755
diff changeset
1011 w->disabled_state |= (1 << 3);
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
1012
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1013 /* draw the widgets */
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1014 {
1962
24ee3f699d48 (svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar <celestar@openttd.org>
parents: 1938
diff changeset
1015 const Player *p = GetPlayer(owner);
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1016 if (station == -1) {
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1017 /* Company Name -- (###) Trains */
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1018 SetDParam(0, p->name_1);
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1019 SetDParam(1, p->name_2);
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1020 SetDParam(2, w->vscroll.count);
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
1021 w->widget[1].unkA = STR_9805_SHIPS;
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1022 } else {
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1023 /* Station Name -- (###) Trains */
1294
8de2c9504eb3 (svn r1798) GetFoo(i)->index is per definition i, so replace the former with the latter
tron <tron@openttd.org>
parents: 1246
diff changeset
1024 SetDParam(0, station);
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1025 SetDParam(1, w->vscroll.count);
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
1026 w->widget[1].unkA = STR_SCHEDULED_SHIPS;
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1027 }
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1028 DrawWindowWidgets(w);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1029 }
168
76ede0c80f43 (svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
1030 /* draw sorting criteria string */
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1031 DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10);
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1032 /* draw arrow pointing up/down for ascending/descending sorting */
2406
90730a4ce5bc (svn r2932) Give the strings consisting of an up/a down arrow symbolic names
tron <tron@openttd.org>
parents: 2273
diff changeset
1033 DoDrawString(vl->flags & VL_DESC ? DOWNARROW : UPARROW, 69, 15, 0x10);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1034
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1035 max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length);
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1036 for (i = w->vscroll.pos; i < max; ++i) {
919
a2d3299a67ee (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight <truelight@openttd.org>
parents: 893
diff changeset
1037 Vehicle *v = GetVehicle(vl->sort_list[i].index);
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1038 StringID str;
164
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1039
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1040 assert(v->type == VEH_Ship);
164
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1041
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1042 DrawShipImage(v, x + 19, y + 6, INVALID_VEHICLE);
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1043 DrawVehicleProfitButton(v, x, y + 13);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1044
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1045 SetDParam(0, v->unitnumber);
1330
173a680c6b5f (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs <matthijs@openttd.org>
parents: 1323
diff changeset
1046 if (IsTileDepotType(v->tile, TRANSPORT_WATER) && (v->vehstatus & VS_HIDDEN))
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1047 str = STR_021F;
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1048 else
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1049 str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2;
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1050 DrawString(x, y + 2, str, 0);
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
1051
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1052 SetDParam(0, v->profit_this_year);
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1053 SetDParam(1, v->profit_last_year);
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1054 DrawString(x + 12, y + 28, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1055
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1056 if (v->string_id != STR_SV_SHIP_NAME) {
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1057 SetDParam(0, v->string_id);
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1058 DrawString(x + 12, y, STR_01AB, 0);
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1059 }
164
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1060
1024
fc72cf555e80 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight <truelight@openttd.org>
parents: 982
diff changeset
1061 DrawSmallOrderList(v, x + 138, y);
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1062
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1063 y += PLY_WND_PRC__SIZE_OF_ROW_BIG;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1064 }
164
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1065 } break;
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1066
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1067 case WE_CLICK: {
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1068 switch(e->click.widget) {
757
640102936d2f (svn r1213) -Feature: Stickified vehicle lists
darkvater <darkvater@openttd.org>
parents: 755
diff changeset
1069 case 3: /* Flip sorting method ascending/descending */
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1070 vl->flags ^= VL_DESC;
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1071 vl->flags |= VL_RESORT;
1246
74bd4555f518 (svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater <darkvater@openttd.org>
parents: 1108
diff changeset
1072 _sorting.ship.order = !!(vl->flags & VL_DESC);
164
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1073 SetWindowDirty(w);
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1074 break;
757
640102936d2f (svn r1213) -Feature: Stickified vehicle lists
darkvater <darkvater@openttd.org>
parents: 755
diff changeset
1075 case 4: case 5:/* Select sorting criteria dropdown menu */
842
a71aeb1cfa97 (svn r1323) Adding autoreplace feature
bjarni <bjarni@openttd.org>
parents: 767
diff changeset
1076 ShowDropDownMenu(w, _vehicle_sort_listing, vl->sort_type, 5, 0, 0);
164
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1077 return;
757
640102936d2f (svn r1213) -Feature: Stickified vehicle lists
darkvater <darkvater@openttd.org>
parents: 755
diff changeset
1078 case 7: { /* Matrix to show vehicles */
174
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 168
diff changeset
1079 uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_BIG;
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
1080
174
ae0888779e46 (svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater <darkvater@openttd.org>
parents: 168
diff changeset
1081 if (id_v >= w->vscroll.cap) { return;} // click out of bounds
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1082
164
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1083 id_v += w->vscroll.pos;
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1084
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1085 {
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1086 Vehicle *v;
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1087
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1088 if (id_v >= vl->list_length) return; // click out of list bound
164
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1089
919
a2d3299a67ee (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight <truelight@openttd.org>
parents: 893
diff changeset
1090 v = GetVehicle(vl->sort_list[id_v].index);
164
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1091
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1092 assert(v->type == VEH_Ship);
164
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1093
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1094 ShowShipViewWindow(v);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1095 }
164
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1096 } break;
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1097
757
640102936d2f (svn r1213) -Feature: Stickified vehicle lists
darkvater <darkvater@openttd.org>
parents: 755
diff changeset
1098 case 9: { /* Build new Vehicle */
1977
77a4977c3286 (svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron <tron@openttd.org>
parents: 1962
diff changeset
1099 TileIndex tile;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1100
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
1101 if (!IsWindowOfPrototype(w, _player_ships_widgets))
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
1102 break;
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
1103
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
1104
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1105 tile = _last_built_ship_depot_tile;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1106 do {
1906
c0f2f61bd5bc (svn r2412) - Fix: [ 1214948 ] building vehicles without depot crashes game. (Chris Huebsch)
hackykid <hackykid@openttd.org>
parents: 1901
diff changeset
1107 if (IsTileDepotType(tile, TRANSPORT_WATER) && IsTileOwner(tile, _local_player)) {
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1108 ShowShipDepotWindow(tile);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1109 ShowBuildShipWindow(tile);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1110 return;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1111 }
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
1112
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1113 tile = TILE_MASK(tile + 1);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1114 } while(tile != _last_built_ship_depot_tile);
193
d9c55f0bc5ec (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight <truelight@openttd.org>
parents: 176
diff changeset
1115
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1116 ShowBuildShipWindow(0);
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1117 } break;
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
1118
842
a71aeb1cfa97 (svn r1323) Adding autoreplace feature
bjarni <bjarni@openttd.org>
parents: 767
diff changeset
1119 case 10: {
886
164bb535c49f (svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight <truelight@openttd.org>
parents: 878
diff changeset
1120 if (!IsWindowOfPrototype(w, _player_ships_widgets))
164bb535c49f (svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight <truelight@openttd.org>
parents: 878
diff changeset
1121 break;
164bb535c49f (svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight <truelight@openttd.org>
parents: 878
diff changeset
1122
842
a71aeb1cfa97 (svn r1323) Adding autoreplace feature
bjarni <bjarni@openttd.org>
parents: 767
diff changeset
1123 ShowReplaceVehicleWindow(VEH_Ship);
a71aeb1cfa97 (svn r1323) Adding autoreplace feature
bjarni <bjarni@openttd.org>
parents: 767
diff changeset
1124 break;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1125 }
842
a71aeb1cfa97 (svn r1323) Adding autoreplace feature
bjarni <bjarni@openttd.org>
parents: 767
diff changeset
1126 }
164
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1127 } break;
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1128
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1129 case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1130 if (vl->sort_type != e->dropdown.index) {
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1131 // value has changed -> resort
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1132 vl->flags |= VL_RESORT;
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1133 vl->sort_type = e->dropdown.index;
1246
74bd4555f518 (svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater <darkvater@openttd.org>
parents: 1108
diff changeset
1134 _sorting.ship.criteria = vl->sort_type;
164
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1135
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1136 // enable 'Sort By' if a sorter criteria is chosen
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1137 if (vl->sort_type != SORT_BY_UNSORTED)
1246
74bd4555f518 (svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater <darkvater@openttd.org>
parents: 1108
diff changeset
1138 CLRBIT(w->disabled_state, 3);
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1139 }
164
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1140 SetWindowDirty(w);
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1141 break;
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1142
164
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1143 case WE_CREATE: /* set up resort timer */
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1144 vl->sort_list = NULL;
1246
74bd4555f518 (svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater <darkvater@openttd.org>
parents: 1108
diff changeset
1145 vl->flags = VL_REBUILD | (_sorting.ship.order << (VL_DESC - 1));
74bd4555f518 (svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater <darkvater@openttd.org>
parents: 1108
diff changeset
1146 vl->sort_type = _sorting.ship.criteria;
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1147 vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
164
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1148 break;
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1149
767
0f4fd9d03890 (svn r1232) Plug memory leak
tron <tron@openttd.org>
parents: 757
diff changeset
1150 case WE_DESTROY:
0f4fd9d03890 (svn r1232) Plug memory leak
tron <tron@openttd.org>
parents: 757
diff changeset
1151 free(vl->sort_list);
0f4fd9d03890 (svn r1232) Plug memory leak
tron <tron@openttd.org>
parents: 757
diff changeset
1152 break;
0f4fd9d03890 (svn r1232) Plug memory leak
tron <tron@openttd.org>
parents: 757
diff changeset
1153
164
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1154 case WE_TICK: /* resort the list every 20 seconds orso (10 days) */
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1155 if (--vl->resort_timer == 0) {
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1156 DEBUG(misc, 1) ("Periodic resort ships list player %d station %d",
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1157 owner, station);
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1158 vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1159 vl->flags |= VL_RESORT;
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1160 SetWindowDirty(w);
164
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1161 }
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1162 break;
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
1163
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
1164 case WE_RESIZE:
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
1165 /* Update the scroll + matrix */
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
1166 w->vscroll.cap += e->sizing.diff.y / PLY_WND_PRC__SIZE_OF_ROW_BIG;
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
1167 w->widget[7].unkA = (w->vscroll.cap << 8) + 1;
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
1168 break;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1169 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1170 }
168
76ede0c80f43 (svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater <darkvater@openttd.org>
parents: 164
diff changeset
1171
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1172 static const WindowDesc _player_ships_desc = {
164
1d9de926a503 (svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater <darkvater@openttd.org>
parents: 156
diff changeset
1173 -1, -1, 260, 182,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1174 WC_SHIPS_LIST,0,
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
1175 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1176 _player_ships_widgets,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1177 PlayerShipsWndProc
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1178 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1179
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1180 static const WindowDesc _other_player_ships_desc = {
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
1181 -1, -1, 260, 182,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1182 WC_SHIPS_LIST,0,
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
1183 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1184 _other_player_ships_widgets,
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1185 PlayerShipsWndProc
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1186 };
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1187
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1188
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1189 void ShowPlayerShips(int player, int station)
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1190 {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1191 Window *w;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1192
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1193 if ( player == _local_player) {
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1194 w = AllocateWindowDescFront(&_player_ships_desc, (station << 16) | player);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1195 } else {
588
8efbed92db68 (svn r1009) -Feature: per-station vehicle lists
tron <tron@openttd.org>
parents: 555
diff changeset
1196 w = AllocateWindowDescFront(&_other_player_ships_desc, (station << 16) | player);
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1197 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1198 if (w) {
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1199 w->caption_color = w->window_number;
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1200 w->vscroll.cap = 4;
867
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
1201 w->widget[7].unkA = (w->vscroll.cap << 8) + 1;
1aec4e551f7a (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight <truelight@openttd.org>
parents: 842
diff changeset
1202 w->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_BIG;
0
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1203 }
fa6ee4d75c8a (svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff changeset
1204 }