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