author | tron |
Tue, 29 Aug 2006 06:03:26 +0000 | |
changeset 4436 | af7043215494 |
parent 4435 | cde1d8fc5c8f |
child 4442 | 8d8d0c2df7cb |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1820
diff
changeset
|
4 |
#include "openttd.h" |
1299
0a6510cc889b
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1294
diff
changeset
|
5 |
#include "debug.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
6 |
#include "functions.h" |
3961
e2783f244ac6
(svn r5120) Add IsShipInDepot{Stopped,}() and remove some redundant checks
tron
parents:
3948
diff
changeset
|
7 |
#include "ship.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
243
diff
changeset
|
8 |
#include "table/strings.h" |
2187
2a51f8925eeb
(svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar
parents:
2186
diff
changeset
|
9 |
#include "table/sprites.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
|
10 |
#include "map.h" |
0 | 11 |
#include "window.h" |
12 |
#include "gui.h" |
|
13 |
#include "gfx.h" |
|
14 |
#include "vehicle.h" |
|
15 |
#include "viewport.h" |
|
16 |
#include "station.h" |
|
17 |
#include "command.h" |
|
18 |
#include "player.h" |
|
19 |
#include "engine.h" |
|
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
20 |
#include "depot.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2113
diff
changeset
|
21 |
#include "vehicle_gui.h" |
2962
dbd168a4703a
(svn r3524) - Split newgrf features from engine.[ch] into newgrf_engine.[ch], and add the new files to project files.
peter1138
parents:
2958
diff
changeset
|
22 |
#include "newgrf_engine.h" |
4261
2ec8f5a9747b
(svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents:
4248
diff
changeset
|
23 |
#include "date.h" |
0 | 24 |
|
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
|
25 |
/** |
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
26 |
* 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
|
27 |
* @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
|
28 |
* @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
|
29 |
*/ |
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 |
void DrawShipPurchaseInfo(int x, int y, EngineID engine_number) |
842 | 31 |
{ |
32 |
YearMonthDay ymd; |
|
33 |
const ShipVehicleInfo *svi = ShipVehInfo(engine_number); |
|
4171 | 34 |
const Engine *e; |
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 |
/* Purchase cost - Max speed */ |
842 | 37 |
SetDParam(0, svi->base_cost * (_price.ship_base>>3)>>5); |
3477
80c3465b38ee
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3157
diff
changeset
|
38 |
SetDParam(1, svi->max_speed / 2); |
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
|
39 |
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
|
40 |
y += 10; |
842 | 41 |
|
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
|
42 |
/* Cargo type + capacity */ |
2084
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
1986
diff
changeset
|
43 |
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
|
44 |
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
|
45 |
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
|
46 |
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
|
47 |
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
|
48 |
|
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
49 |
/* 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
|
50 |
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
|
51 |
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
|
52 |
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
|
53 |
|
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 |
/* Design date - Life length */ |
1926
68d60188a22f
(svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron
parents:
1907
diff
changeset
|
55 |
e = GetEngine(engine_number); |
4288
60398d0e64ee
(svn r5918) -Cleanup: rename ConvertDayToYMD/ConvertYMDToDay as they really convert a Date to/from a YearMonthDay.
rubidium
parents:
4286
diff
changeset
|
56 |
ConvertDateToYMD(e->intro_date, &ymd); |
4293
2c24234a7aec
(svn r5926) -Codechange: make _cur_year contain the full year, instead of the offset since 1920
rubidium
parents:
4288
diff
changeset
|
57 |
SetDParam(0, ymd.year); |
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
|
58 |
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
|
59 |
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
|
60 |
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
|
61 |
|
cebdef7a1c8a
(svn r2413) - Codechange: Rewrite the displaying of purchase details a bit, make it easyer to add lines later.
hackykid
parents:
1906
diff
changeset
|
62 |
/* 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
|
63 |
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
|
64 |
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
|
65 |
y += 10; |
4243
900826bcac92
(svn r5820) - NewGRF: Add support for extra vehicle text in the purchase list for road vehicles, aircraft and ships.
peter1138
parents:
4171
diff
changeset
|
66 |
|
900826bcac92
(svn r5820) - NewGRF: Add support for extra vehicle text in the purchase list for road vehicles, aircraft and ships.
peter1138
parents:
4171
diff
changeset
|
67 |
/* Additional text from NewGRF */ |
900826bcac92
(svn r5820) - NewGRF: Add support for extra vehicle text in the purchase list for road vehicles, aircraft and ships.
peter1138
parents:
4171
diff
changeset
|
68 |
// XXX 227 will become a calculated width... |
900826bcac92
(svn r5820) - NewGRF: Add support for extra vehicle text in the purchase list for road vehicles, aircraft and ships.
peter1138
parents:
4171
diff
changeset
|
69 |
y += ShowAdditionalText(x, y, 227, engine_number); |
842 | 70 |
} |
0 | 71 |
|
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
|
72 |
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
|
73 |
{ |
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3049
diff
changeset
|
74 |
DrawSprite(GetShipImage(v, DIR_W) | GetVehiclePalette(v), x + 32, y + 10); |
0 | 75 |
|
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
|
76 |
if (v->index == selection) { |
2639 | 77 |
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
|
78 |
} |
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
|
79 |
} |
0 | 80 |
|
81 |
static void ShipRefitWndProc(Window *w, WindowEvent *e) |
|
82 |
{ |
|
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
|
83 |
switch (e->event) { |
0 | 84 |
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
|
85 |
const Vehicle *v = GetVehicle(w->window_number); |
0 | 86 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
87 |
SetDParam(0, v->string_id); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
88 |
SetDParam(1, v->unitnumber); |
0 | 89 |
DrawWindowWidgets(w); |
90 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
91 |
|
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
|
92 |
/* 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
|
93 |
WP(w,refit_d).cargo = DrawVehicleRefitWindow(v, WP(w, refit_d).sel);; |
0 | 94 |
|
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
|
95 |
if (WP(w,refit_d).cargo != CT_INVALID) { |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3477
diff
changeset
|
96 |
int32 cost = DoCommand(v->tile, v->index, WP(w,refit_d).cargo, DC_QUERY_COST, CMD_REFIT_SHIP); |
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 |
if (!CmdFailed(cost)) { |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
98 |
SetDParam(2, cost); |
2084
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
1986
diff
changeset
|
99 |
SetDParam(0, _cargoc.names_long[WP(w,refit_d).cargo]); |
3989
a5d50d90fd21
(svn r5188) - NewGRF: check refit capacity callback when refitting a ship
peter1138
parents:
3961
diff
changeset
|
100 |
SetDParam(1, _returned_refit_capacity); |
0 | 101 |
DrawString(1, 137, STR_9840_NEW_CAPACITY_COST_OF_REFIT, 0); |
102 |
} |
|
103 |
} |
|
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
|
104 |
} break; |
0 | 105 |
|
106 |
case WE_CLICK: |
|
2639 | 107 |
switch (e->click.widget) { |
0 | 108 |
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
|
109 |
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
|
110 |
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
|
111 |
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
|
112 |
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
|
113 |
} |
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
|
114 |
} break; |
0 | 115 |
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
|
116 |
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
|
117 |
const Vehicle *v = GetVehicle(w->window_number); |
0 | 118 |
if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo, NULL, CMD_REFIT_SHIP | CMD_MSG(STR_9841_CAN_T_REFIT_SHIP))) |
119 |
DeleteWindow(w); |
|
120 |
} |
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
121 |
break; |
0 | 122 |
} |
123 |
break; |
|
124 |
} |
|
125 |
} |
|
126 |
||
127 |
||
128 |
static const Widget _ship_refit_widgets[] = { |
|
4345
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
129 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
130 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 239, 0, 13, STR_983B_REFIT, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
131 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 239, 14, 135, 0x0, STR_983D_SELECT_TYPE_OF_CARGO_FOR}, |
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
132 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 239, 136, 157, 0x0, STR_NULL}, |
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
133 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 239, 158, 169, STR_983C_REFIT_SHIP, STR_983E_REFIT_SHIP_TO_CARRY_HIGHLIGHTED}, |
dd12549ad473
(svn r6046) CodeChange : Rename WWT_5 Widget type to WWT_LABEL : a centered label
belugas
parents:
4344
diff
changeset
|
134 |
{ WWT_LABEL, RESIZE_NONE, 0, 0, 239, 13, 26, STR_983F_SELECT_CARGO_TYPE_TO_CARRY, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
135 |
{ WIDGETS_END}, |
0 | 136 |
}; |
137 |
||
138 |
static const WindowDesc _ship_refit_desc = { |
|
139 |
-1,-1, 240, 170, |
|
140 |
WC_VEHICLE_REFIT,WC_VEHICLE_VIEW, |
|
141 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
142 |
_ship_refit_widgets, |
|
143 |
ShipRefitWndProc, |
|
144 |
}; |
|
145 |
||
4171 | 146 |
static void ShowShipRefitWindow(const Vehicle *v) |
0 | 147 |
{ |
148 |
Window *w; |
|
149 |
||
150 |
DeleteWindowById(WC_VEHICLE_REFIT, v->index); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
151 |
|
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
152 |
_alloc_wnd_parent_num = v->index; |
0 | 153 |
w = AllocateWindowDesc(&_ship_refit_desc); |
154 |
w->window_number = v->index; |
|
155 |
w->caption_color = v->owner; |
|
156 |
WP(w,refit_d).sel = -1; |
|
157 |
} |
|
158 |
||
159 |
static void ShipDetailsWndProc(Window *w, WindowEvent *e) |
|
160 |
{ |
|
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
|
161 |
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
|
162 |
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
|
163 |
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
|
164 |
StringID str; |
0 | 165 |
|
166 |
w->disabled_state = v->owner == _local_player ? 0 : (1 << 2); |
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
167 |
// disable service-scroller when interval is set to disabled |
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
168 |
if (!_patches.servint_ships) w->disabled_state |= (1 << 5) | (1 << 6); |
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
|
169 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
170 |
SetDParam(0, v->string_id); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
171 |
SetDParam(1, v->unitnumber); |
0 | 172 |
DrawWindowWidgets(w); |
173 |
||
174 |
/* Draw running cost */ |
|
175 |
{ |
|
176 |
int year = v->age / 366; |
|
177 |
||
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
178 |
SetDParam(1, year); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
179 |
|
2252
37e3ca7014e0
(svn r2772) Simplify the age notice in the vehicle details window
tron
parents:
2244
diff
changeset
|
180 |
SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
181 |
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
|
182 |
SetDParam(3, ShipVehInfo(v->engine_type)->running_cost * _price.ship_running >> 8); |
0 | 183 |
DrawString(2, 15, STR_9812_AGE_RUNNING_COST_YR, 0); |
184 |
} |
|
185 |
||
186 |
/* Draw max speed */ |
|
187 |
{ |
|
3477
80c3465b38ee
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3157
diff
changeset
|
188 |
SetDParam(0, v->max_speed / 2); |
0 | 189 |
DrawString(2, 25, STR_9813_MAX_SPEED, 0); |
190 |
} |
|
191 |
||
192 |
/* Draw profit */ |
|
193 |
{ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
194 |
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
|
195 |
SetDParam(1, v->profit_last_year); |
0 | 196 |
DrawString(2, 35, STR_9814_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
197 |
} |
|
198 |
||
199 |
/* Draw breakdown & reliability */ |
|
200 |
{ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
201 |
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
|
202 |
SetDParam(1, v->breakdowns_since_last_service); |
0 | 203 |
DrawString(2, 45, STR_9815_RELIABILITY_BREAKDOWNS, 0); |
204 |
} |
|
205 |
||
206 |
/* Draw service interval text */ |
|
207 |
{ |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
208 |
SetDParam(0, v->service_interval); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
209 |
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
|
210 |
DrawString(13, 90, _patches.servint_ispercent?STR_SERVICING_INTERVAL_PERCENT:STR_883C_SERVICING_INTERVAL_DAYS, 0); |
0 | 211 |
} |
212 |
||
213 |
DrawShipImage(v, 3, 57, INVALID_VEHICLE); |
|
214 |
||
4329
9759d5c52010
(svn r6002) -Cleanup: remove the now redundant BASE_YEAR constant.
rubidium
parents:
4299
diff
changeset
|
215 |
SetDParam(1, v->build_year); |
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
216 |
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
|
217 |
SetDParam(2, v->value); |
0 | 218 |
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
|
219 |
|
2084
d67790a49f78
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
1986
diff
changeset
|
220 |
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
|
221 |
SetDParam(1, v->cargo_cap); |
0 | 222 |
DrawString(74, 67, STR_9817_CAPACITY, 0); |
223 |
||
224 |
str = STR_8812_EMPTY; |
|
225 |
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
|
226 |
SetDParam(0, v->cargo_type); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
227 |
SetDParam(1, v->cargo_count); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
228 |
SetDParam(2, v->cargo_source); |
0 | 229 |
str = STR_8813_FROM; |
230 |
} |
|
231 |
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
|
232 |
} break; |
0 | 233 |
|
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
|
234 |
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
|
235 |
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
|
236 |
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
|
237 |
switch (e->click.widget) { |
0 | 238 |
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
|
239 |
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
|
240 |
SetDParam(0, v->unitnumber); |
4299
b86602eaaff1
(svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents:
4293
diff
changeset
|
241 |
ShowQueryString(v->string_id, STR_9831_NAME_SHIP, 31, 150, w->window_class, w->window_number, CS_ALPHANUMERAL); |
0 | 242 |
break; |
243 |
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
|
244 |
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
|
245 |
goto do_change_service_int; |
0 | 246 |
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
|
247 |
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
|
248 |
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
|
249 |
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
|
250 |
|
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
|
251 |
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
|
252 |
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
|
253 |
|
2819
710436dd4288
(svn r3367) Unify the 4 distinct CMD_CHANGE_{AIRCRAFT,ROADVEH,SHIP,TRAIN}_SERVICE_INT commands into one CMD_CHANGE_SERVICE_INT command.
tron
parents:
2806
diff
changeset
|
254 |
DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); |
0 | 255 |
break; |
256 |
} |
|
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
|
257 |
} break; |
0 | 258 |
|
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2517
diff
changeset
|
259 |
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
|
260 |
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
|
261 |
_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
|
262 |
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
|
263 |
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
|
264 |
} |
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2517
diff
changeset
|
265 |
break; |
0 | 266 |
} |
267 |
} |
|
268 |
||
269 |
||
270 |
static const Widget _ship_details_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
271 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
272 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 364, 0, 13, STR_9811_DETAILS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
273 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 365, 404, 0, 13, STR_01AA_NAME, STR_982F_NAME_SHIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
274 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 404, 14, 55, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
275 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 404, 56, 88, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
276 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 10, 89, 94, STR_0188, STR_884D_INCREASE_SERVICING_INTERVAL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
277 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 10, 95, 100, STR_0189, STR_884E_DECREASE_SERVICING_INTERVAL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
278 |
{ 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
|
279 |
{ WIDGETS_END}, |
0 | 280 |
}; |
281 |
||
282 |
static const WindowDesc _ship_details_desc = { |
|
283 |
-1,-1, 405, 101, |
|
284 |
WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW, |
|
285 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
286 |
_ship_details_widgets, |
|
287 |
ShipDetailsWndProc |
|
288 |
}; |
|
289 |
||
4171 | 290 |
static void ShowShipDetailsWindow(const Vehicle *v) |
0 | 291 |
{ |
292 |
Window *w; |
|
293 |
VehicleID veh = v->index; |
|
2639 | 294 |
|
0 | 295 |
DeleteWindowById(WC_VEHICLE_ORDERS, veh); |
296 |
DeleteWindowById(WC_VEHICLE_DETAILS, veh); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
297 |
_alloc_wnd_parent_num = veh; |
0 | 298 |
w = AllocateWindowDesc(&_ship_details_desc); |
299 |
w->window_number = veh; |
|
300 |
w->caption_color = v->owner; |
|
301 |
} |
|
302 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
303 |
void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2) |
0 | 304 |
{ |
4171 | 305 |
const Vehicle *v; |
0 | 306 |
if (!success) return; |
307 |
||
3948
95f9fa0ac551
(svn r5094) Remove _new_{aircraft,roadveh,ship,train,wagon}_id. _new_vehicle_id is enough.
tron
parents:
3887
diff
changeset
|
308 |
v = GetVehicle(_new_vehicle_id); |
0 | 309 |
if (v->tile == _backup_orders_tile) { |
310 |
_backup_orders_tile = 0; |
|
311 |
RestoreVehicleOrders(v, _backup_orders_data); |
|
312 |
} |
|
313 |
ShowShipViewWindow(v); |
|
314 |
} |
|
315 |
||
3887
3e44ae3b1e7c
(svn r4943) uint tile -> TileIndex tile, byte player -> PlayerID player
tron
parents:
3884
diff
changeset
|
316 |
void CcCloneShip(bool success, TileIndex tile, uint32 p1, uint32 p2) |
2244 | 317 |
{ |
3948
95f9fa0ac551
(svn r5094) Remove _new_{aircraft,roadveh,ship,train,wagon}_id. _new_vehicle_id is enough.
tron
parents:
3887
diff
changeset
|
318 |
if (success) ShowShipViewWindow(GetVehicle(_new_vehicle_id)); |
2244 | 319 |
} |
320 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
321 |
static void NewShipWndProc(Window *w, WindowEvent *e) |
0 | 322 |
{ |
2639 | 323 |
switch (e->event) { |
4436
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
324 |
case WE_PAINT: { |
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
325 |
EngineID selected_id; |
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
326 |
EngineID eid; |
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
327 |
int count; |
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
328 |
int pos; |
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
329 |
int sel; |
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
330 |
int y; |
0 | 331 |
|
4436
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
332 |
if (w->window_number == 0) w->disabled_state = 1 << 5; |
0 | 333 |
|
4436
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
334 |
count = 0; |
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
335 |
for (eid = SHIP_ENGINES_INDEX; eid < SHIP_ENGINES_INDEX + NUM_SHIP_ENGINES; eid++) { |
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
336 |
if (HASBIT(GetEngine(eid)->player_avail, _local_player)) count++; |
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
337 |
} |
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
338 |
SetVScrollCount(w, count); |
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
339 |
|
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
340 |
DrawWindowWidgets(w); |
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
341 |
|
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
342 |
y = 15; |
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
343 |
sel = WP(w,buildtrain_d).sel_index; |
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
344 |
pos = w->vscroll.pos; |
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
345 |
selected_id = INVALID_ENGINE; |
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
346 |
for (eid = SHIP_ENGINES_INDEX; eid < SHIP_ENGINES_INDEX + NUM_SHIP_ENGINES; eid++) { |
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
347 |
if (!HASBIT(GetEngine(eid)->player_avail, _local_player)) continue; |
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
348 |
if (sel == 0) selected_id = eid; |
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
349 |
if (IS_INT_INSIDE(--pos, -w->vscroll.cap, 0)) { |
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
350 |
DrawString(77, y + 7, GetCustomEngineName(eid), sel == 0 ? 0xC : 0x10); |
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
351 |
DrawShipEngine(37, y + 10, eid, GetEnginePalette(eid, _local_player)); |
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
352 |
y += 24; |
0 | 353 |
} |
4436
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
354 |
sel--; |
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
355 |
} |
0 | 356 |
|
357 |
WP(w,buildtrain_d).sel_engine = selected_id; |
|
358 |
||
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
359 |
if (selected_id != INVALID_ENGINE) { |
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
|
360 |
DrawShipPurchaseInfo(2, w->widget[4].top + 1, selected_id); |
0 | 361 |
} |
4436
af7043215494
(svn r6208) Reduce the number of induction variables for clarity
tron
parents:
4435
diff
changeset
|
362 |
break; |
0 | 363 |
} |
364 |
||
365 |
case WE_CLICK: |
|
2952 | 366 |
switch (e->click.widget) { |
0 | 367 |
case 2: { /* listbox */ |
368 |
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
|
369 |
if (i < w->vscroll.cap) { |
0 | 370 |
WP(w,buildtrain_d).sel_index = i + w->vscroll.pos; |
371 |
SetWindowDirty(w); |
|
372 |
} |
|
373 |
} break; |
|
374 |
case 5: { /* build */ |
|
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
375 |
EngineID sel_eng = WP(w,buildtrain_d).sel_engine; |
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
376 |
if (sel_eng != INVALID_ENGINE) |
0 | 377 |
DoCommandP(w->window_number, sel_eng, 0, CcBuildShip, CMD_BUILD_SHIP | CMD_MSG(STR_980D_CAN_T_BUILD_SHIP)); |
378 |
} break; |
|
379 |
||
4434
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4427
diff
changeset
|
380 |
case 6: { /* rename */ |
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
381 |
EngineID sel_eng = WP(w,buildtrain_d).sel_engine; |
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2477
diff
changeset
|
382 |
if (sel_eng != INVALID_ENGINE) { |
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
|
383 |
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
|
384 |
ShowQueryString(GetCustomEngineName(sel_eng), |
4299
b86602eaaff1
(svn r5944) -Merge TGP (r5578, r5579, r5724, r5726): -Feature: filter for textboxes to only
truelight
parents:
4293
diff
changeset
|
385 |
STR_9838_RENAME_SHIP_TYPE, 31, 160, w->window_class, w->window_number, CS_ALPHANUMERAL); |
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
|
386 |
} |
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 |
} break; |
0 | 388 |
} |
389 |
break; |
|
390 |
||
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2517
diff
changeset
|
391 |
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
|
392 |
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
|
393 |
_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
|
394 |
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
|
395 |
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
|
396 |
} |
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2517
diff
changeset
|
397 |
break; |
0 | 398 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
399 |
case WE_RESIZE: |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
400 |
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
|
401 |
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
|
402 |
break; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
403 |
|
0 | 404 |
} |
405 |
} |
|
406 |
||
407 |
static const Widget _new_ship_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
408 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
409 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 254, 0, 13, STR_9808_NEW_SHIPS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
410 |
{ WWT_MATRIX, RESIZE_BOTTOM, 14, 0, 242, 14, 109, 0x401, STR_9825_SHIP_SELECTION_LIST_CLICK}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
411 |
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 14, 243, 254, 14, 109, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
412 |
{ WWT_IMGBTN, RESIZE_TB, 14, 0, 254, 110, 161, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
413 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 121, 162, 173, STR_9809_BUILD_SHIP, STR_9826_BUILD_THE_HIGHLIGHTED_SHIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
414 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 122, 242, 162, 173, STR_9836_RENAME, STR_9837_RENAME_SHIP_TYPE}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
415 |
{ 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
|
416 |
{ WIDGETS_END}, |
0 | 417 |
}; |
418 |
||
419 |
static const WindowDesc _new_ship_desc = { |
|
420 |
-1, -1, 255, 174, |
|
421 |
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
|
422 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, |
0 | 423 |
_new_ship_widgets, |
424 |
NewShipWndProc |
|
425 |
}; |
|
426 |
||
427 |
||
428 |
static void ShowBuildShipWindow(TileIndex tile) |
|
429 |
{ |
|
430 |
Window *w; |
|
431 |
||
432 |
DeleteWindowById(WC_BUILD_VEHICLE, tile); |
|
433 |
||
434 |
w = AllocateWindowDesc(&_new_ship_desc); |
|
435 |
w->window_number = tile; |
|
436 |
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
|
437 |
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
|
438 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
439 |
w->resize.step_height = 24; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
440 |
|
0 | 441 |
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
|
442 |
w->caption_color = GetTileOwner(tile); |
0 | 443 |
} else { |
444 |
w->caption_color = _local_player; |
|
445 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
446 |
|
0 | 447 |
} |
448 |
||
449 |
||
4171 | 450 |
static void ShipViewWndProc(Window *w, WindowEvent *e) |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
451 |
{ |
2952 | 452 |
switch (e->event) { |
2244 | 453 |
case WE_PAINT: { |
454 |
Vehicle *v = GetVehicle(w->window_number); |
|
455 |
uint32 disabled = 1<<8; |
|
456 |
StringID str; |
|
0 | 457 |
|
2244 | 458 |
// Possible to refit? |
3961
e2783f244ac6
(svn r5120) Add IsShipInDepot{Stopped,}() and remove some redundant checks
tron
parents:
3948
diff
changeset
|
459 |
if (ShipVehInfo(v->engine_type)->refittable && IsShipInDepotStopped(v)) { |
2244 | 460 |
disabled = 0; |
3961
e2783f244ac6
(svn r5120) Add IsShipInDepot{Stopped,}() and remove some redundant checks
tron
parents:
3948
diff
changeset
|
461 |
} |
0 | 462 |
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
463 |
if (v->owner != _local_player) disabled |= 1<<8 | 1<<7; |
2244 | 464 |
w->disabled_state = disabled; |
0 | 465 |
|
2244 | 466 |
/* draw widgets & caption */ |
467 |
SetDParam(0, v->string_id); |
|
468 |
SetDParam(1, v->unitnumber); |
|
469 |
DrawWindowWidgets(w); |
|
0 | 470 |
|
2244 | 471 |
if (v->breakdown_ctr == 1) { |
472 |
str = STR_885C_BROKEN_DOWN; |
|
473 |
} else if (v->vehstatus & VS_STOPPED) { |
|
474 |
str = STR_8861_STOPPED; |
|
475 |
} else { |
|
476 |
switch (v->current_order.type) { |
|
477 |
case OT_GOTO_STATION: { |
|
4389
e4555522d257
(svn r6142) -Codechange: added WaypointID (sorry DV, couldn't splits it anymore)
truelight
parents:
4345
diff
changeset
|
478 |
SetDParam(0, v->current_order.dest.station); |
3477
80c3465b38ee
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3157
diff
changeset
|
479 |
SetDParam(1, v->cur_speed / 2); |
2244 | 480 |
str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; |
481 |
} break; |
|
0 | 482 |
|
2244 | 483 |
case OT_GOTO_DEPOT: { |
4389
e4555522d257
(svn r6142) -Codechange: added WaypointID (sorry DV, couldn't splits it anymore)
truelight
parents:
4345
diff
changeset
|
484 |
Depot *depot = GetDepot(v->current_order.dest.depot); |
2244 | 485 |
SetDParam(0, depot->town_index); |
3477
80c3465b38ee
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3157
diff
changeset
|
486 |
SetDParam(1, v->cur_speed / 2); |
4412
945e8a9bb89a
(svn r6165) -Feature: control click Goto Depot will now make the vehicle service
bjarni
parents:
4408
diff
changeset
|
487 |
if (HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) { |
945e8a9bb89a
(svn r6165) -Feature: control click Goto Depot will now make the vehicle service
bjarni
parents:
4408
diff
changeset
|
488 |
str = STR_HEADING_FOR_SHIP_DEPOT + _patches.vehicle_speed; |
945e8a9bb89a
(svn r6165) -Feature: control click Goto Depot will now make the vehicle service
bjarni
parents:
4408
diff
changeset
|
489 |
} else { |
945e8a9bb89a
(svn r6165) -Feature: control click Goto Depot will now make the vehicle service
bjarni
parents:
4408
diff
changeset
|
490 |
str = STR_HEADING_FOR_SHIP_DEPOT_SERVICE + _patches.vehicle_speed; |
945e8a9bb89a
(svn r6165) -Feature: control click Goto Depot will now make the vehicle service
bjarni
parents:
4408
diff
changeset
|
491 |
} |
2244 | 492 |
} break; |
493 |
||
494 |
case OT_LOADING: |
|
495 |
case OT_LEAVESTATION: |
|
496 |
str = STR_882F_LOADING_UNLOADING; |
|
497 |
break; |
|
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2252
diff
changeset
|
498 |
|
2244 | 499 |
default: |
500 |
if (v->num_orders == 0) { |
|
501 |
str = STR_NO_ORDERS + _patches.vehicle_speed; |
|
3477
80c3465b38ee
(svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again.
peter1138
parents:
3157
diff
changeset
|
502 |
SetDParam(0, v->cur_speed / 2); |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
503 |
} else { |
2244 | 504 |
str = STR_EMPTY; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
505 |
} |
2244 | 506 |
break; |
507 |
} |
|
0 | 508 |
} |
509 |
||
2103
9266bb2ac29d
(svn r2613) - Truncate savegames, and vehicle-texts in their window.
Darkvater
parents:
2084
diff
changeset
|
510 |
/* draw the flag plus orders */ |
2517
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2498
diff
changeset
|
511 |
DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, 2, w->widget[5].top + 1); |
2113
f228b399da01
(svn r2623) - CodeChange: rework DrawStringCenteredTruncated() a bit. Instead of giving center + width you give the coordinates of the bounding box (left, right) it has to fit in (ludde)
Darkvater
parents:
2103
diff
changeset
|
512 |
DrawStringCenteredTruncated(w->widget[5].left + 8, w->widget[5].right, w->widget[5].top + 1, str, 0); |
0 | 513 |
DrawWindowViewport(w); |
514 |
} break; |
|
515 |
||
2244 | 516 |
case WE_CLICK: { |
4171 | 517 |
const Vehicle *v = GetVehicle(w->window_number); |
0 | 518 |
|
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
519 |
switch (e->click.widget) { |
2244 | 520 |
case 5: /* start stop */ |
521 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_SHIP | CMD_MSG(STR_9818_CAN_T_STOP_START_SHIP)); |
|
522 |
break; |
|
523 |
case 6: /* center main view */ |
|
524 |
ScrollMainWindowTo(v->x_pos, v->y_pos); |
|
525 |
break; |
|
526 |
case 7: /* goto hangar */ |
|
4412
945e8a9bb89a
(svn r6165) -Feature: control click Goto Depot will now make the vehicle service
bjarni
parents:
4408
diff
changeset
|
527 |
DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, NULL, CMD_SEND_SHIP_TO_DEPOT | CMD_MSG(STR_9819_CAN_T_SEND_SHIP_TO_DEPOT)); |
2244 | 528 |
break; |
529 |
case 8: /* refit */ |
|
530 |
ShowShipRefitWindow(v); |
|
531 |
break; |
|
532 |
case 9: /* show orders */ |
|
533 |
ShowOrdersWindow(v); |
|
534 |
break; |
|
535 |
case 10: /* show details */ |
|
536 |
ShowShipDetailsWindow(v); |
|
537 |
break; |
|
538 |
case 11: { |
|
539 |
/* clone vehicle */ |
|
540 |
DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, CcCloneShip, CMD_CLONE_VEHICLE | CMD_MSG(STR_980D_CAN_T_BUILD_SHIP)); |
|
541 |
} break; |
|
542 |
} |
|
543 |
} break; |
|
544 |
||
545 |
case WE_RESIZE: |
|
546 |
w->viewport->width += e->sizing.diff.x; |
|
547 |
w->viewport->height += e->sizing.diff.y; |
|
548 |
w->viewport->virtual_width += e->sizing.diff.x; |
|
549 |
w->viewport->virtual_height += e->sizing.diff.y; |
|
0 | 550 |
break; |
551 |
||
2244 | 552 |
case WE_DESTROY: |
553 |
DeleteWindowById(WC_VEHICLE_ORDERS, w->window_number); |
|
554 |
DeleteWindowById(WC_VEHICLE_REFIT, w->window_number); |
|
555 |
DeleteWindowById(WC_VEHICLE_DETAILS, w->window_number); |
|
556 |
break; |
|
1485
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
557 |
|
2244 | 558 |
case WE_MOUSELOOP: |
559 |
{ |
|
4171 | 560 |
const Vehicle *v = GetVehicle(w->window_number); |
4248
5dc4cb2f45b0
(svn r5839) Fix : A ship in a depot must be stopped before allowed to be cloned.
belugas
parents:
4243
diff
changeset
|
561 |
uint32 h = IsShipInDepotStopped(v) ? 1 << 7 : 1 << 11; |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3989
diff
changeset
|
562 |
|
2244 | 563 |
if (h != w->hidden_state) { |
564 |
w->hidden_state = h; |
|
565 |
SetWindowDirty(w); |
|
566 |
} |
|
567 |
} |
|
0 | 568 |
} |
569 |
} |
|
570 |
||
571 |
static const Widget _ship_view_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
572 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
573 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 237, 0, 13, STR_980F, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
574 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 238, 249, 0, 13, 0x0, STR_STICKY_BUTTON}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
575 |
{ WWT_IMGBTN, RESIZE_RB, 14, 0, 231, 14, 103, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
576 |
{ WWT_6, RESIZE_RB, 14, 2, 229, 16, 101, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
577 |
{ WWT_PUSHIMGBTN, RESIZE_RTB, 14, 0, 237, 104, 115, 0x0, STR_9827_CURRENT_SHIP_ACTION_CLICK}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
578 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 14, 31, 0x2AB, STR_9829_CENTER_MAIN_VIEW_ON_SHIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
579 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, 0x2B0, STR_982A_SEND_SHIP_TO_DEPOT}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
580 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 50, 67, 0x2B4, STR_983A_REFIT_CARGO_SHIP_TO_CARRY}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
581 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 68, 85, 0x2B2, STR_9828_SHOW_SHIP_S_ORDERS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
582 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 86, 103, 0x2B3, STR_982B_SHOW_SHIP_DETAILS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
583 |
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, SPR_CLONE_SHIP, STR_CLONE_SHIP_INFO}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
584 |
{ WWT_PANEL, RESIZE_LRB, 14, 232, 249, 104, 103, 0x0, STR_NULL }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
585 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 238, 249, 104, 115, 0x0, STR_NULL }, |
1485
a2f36708c260
(svn r1989) -Feature: Resizable vehicle view windows; this is based on a patch by tmesisbob
tron
parents:
1330
diff
changeset
|
586 |
{ WIDGETS_END } |
0 | 587 |
}; |
588 |
||
589 |
static const WindowDesc _ship_view_desc = { |
|
590 |
-1,-1, 250, 116, |
|
591 |
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
|
592 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 593 |
_ship_view_widgets, |
594 |
ShipViewWndProc |
|
595 |
}; |
|
596 |
||
4171 | 597 |
void ShowShipViewWindow(const Vehicle *v) |
0 | 598 |
{ |
4171 | 599 |
Window *w = AllocateWindowDescFront(&_ship_view_desc, v->index); |
0 | 600 |
|
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
601 |
if (w != NULL) { |
0 | 602 |
w->caption_color = v->owner; |
603 |
AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0); |
|
604 |
} |
|
605 |
} |
|
606 |
||
607 |
static void DrawShipDepotWindow(Window *w) |
|
608 |
{ |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
609 |
TileIndex tile; |
0 | 610 |
Vehicle *v; |
611 |
int num,x,y; |
|
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
612 |
Depot *depot; |
0 | 613 |
|
614 |
tile = w->window_number; |
|
615 |
||
616 |
/* 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
|
617 |
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
|
618 |
IsTileOwner(tile, _local_player) ? 0 : ((1 << 4) | (1 << 7)); |
0 | 619 |
|
620 |
/* determine amount of items for scroller */ |
|
621 |
num = 0; |
|
622 |
FOR_ALL_VEHICLES(v) { |
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
623 |
if (v->type == VEH_Ship && IsShipInDepot(v) && v->tile == tile) num++; |
0 | 624 |
} |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
625 |
SetVScrollCount(w, (num + w->hscroll.cap - 1) / w->hscroll.cap); |
0 | 626 |
|
627 |
/* locate the depot struct */ |
|
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
628 |
depot = GetDepotByTile(tile); |
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
629 |
assert(depot != NULL); |
0 | 630 |
|
1313
bba6afb8a995
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1299
diff
changeset
|
631 |
SetDParam(0, depot->town_index); |
0 | 632 |
DrawWindowWidgets(w); |
633 |
||
634 |
x = 2; |
|
635 |
y = 15; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
636 |
num = w->vscroll.pos * w->hscroll.cap; |
0 | 637 |
|
638 |
FOR_ALL_VEHICLES(v) { |
|
3961
e2783f244ac6
(svn r5120) Add IsShipInDepot{Stopped,}() and remove some redundant checks
tron
parents:
3948
diff
changeset
|
639 |
if (v->type == VEH_Ship && IsShipInDepot(v) && v->tile == tile && |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
640 |
--num < 0 && num >= -w->vscroll.cap * w->hscroll.cap) { |
0 | 641 |
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
|
642 |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
643 |
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
|
644 |
DrawString(x, y+2, (uint16)(v->max_age-366) >= v->age ? STR_00E2 : STR_00E3, 0); |
0 | 645 |
|
2517
b90693227193
(svn r3046) Replace some numbers with sprite names and fix a typo in the sprite list
tron
parents:
2498
diff
changeset
|
646 |
DrawSprite((v->vehstatus & VS_STOPPED) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, x, y + 9); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
647 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
648 |
if ((x+=90) == 2 + 90 * w->hscroll.cap) { |
0 | 649 |
x = 2; |
650 |
y += 24; |
|
651 |
} |
|
652 |
} |
|
653 |
} |
|
654 |
} |
|
655 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2406
diff
changeset
|
656 |
static int GetVehicleFromShipDepotWndPt(const Window *w, int x, int y, Vehicle **veh) |
0 | 657 |
{ |
969
8c4bede35fcc
(svn r1464) -Fix: [1099106] Resizeable portion of bus/air/rail depots window unclickable
darkvater
parents:
968
diff
changeset
|
658 |
uint xt,row,xm,ym; |
0 | 659 |
TileIndex tile; |
660 |
Vehicle *v; |
|
661 |
int pos; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
662 |
|
0 | 663 |
xt = x / 90; |
664 |
xm = x % 90; |
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
665 |
if (xt >= w->hscroll.cap) return 1; |
0 | 666 |
|
969
8c4bede35fcc
(svn r1464) -Fix: [1099106] Resizeable portion of bus/air/rail depots window unclickable
darkvater
parents:
968
diff
changeset
|
667 |
row = (y - 14) / 24; |
0 | 668 |
ym = (y - 14) % 24; |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
669 |
if (row >= w->vscroll.cap) return 1; |
0 | 670 |
|
971
1b6f956d8ac5
(svn r1466) -Fix: oops, depot windows can of course also scroll horizontally. Thanks si-m1.
darkvater
parents:
969
diff
changeset
|
671 |
pos = (row + w->vscroll.pos) * w->hscroll.cap + xt; |
0 | 672 |
|
673 |
tile = w->window_number; |
|
674 |
FOR_ALL_VEHICLES(v) { |
|
1986
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
675 |
if (v->type == VEH_Ship && v->vehstatus & VS_HIDDEN && v->tile == tile && |
0 | 676 |
--pos < 0) { |
1986
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
677 |
*veh = v; |
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
678 |
if (xm >= 19) return 0; |
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
679 |
if (ym <= 10) return -1; /* show window */ |
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
680 |
return -2; /* start stop */ |
5dd3db2b86d7
(svn r2492) Remove some pointless casts and fix some nearby indentation
tron
parents:
1977
diff
changeset
|
681 |
} |
0 | 682 |
} |
683 |
||
684 |
return 1; /* outside */ |
|
685 |
} |
|
686 |
||
687 |
static void ShipDepotClick(Window *w, int x, int y) |
|
688 |
{ |
|
689 |
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
|
690 |
int mode = GetVehicleFromShipDepotWndPt(w, x, y, &v); |
0 | 691 |
|
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
|
692 |
// share / copy orders |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
693 |
if (_thd.place_mode && mode <= 0) { |
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
694 |
_place_clicked_vehicle = v; |
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
695 |
return; |
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
696 |
} |
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
|
697 |
|
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 |
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
|
699 |
case 1: // invalid |
0 | 700 |
return; |
701 |
||
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
|
702 |
case 0: // start dragging of vehicle |
0 | 703 |
if (v != NULL) { |
704 |
WP(w,traindepot_d).sel = v->index; |
|
705 |
SetWindowDirty(w); |
|
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3049
diff
changeset
|
706 |
SetObjectToPlaceWnd(GetVehiclePalette(v) | GetShipImage(v, DIR_W), 4, w); |
0 | 707 |
} |
708 |
break; |
|
709 |
||
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
|
710 |
case -1: // show info window |
0 | 711 |
ShowShipViewWindow(v); |
712 |
break; |
|
713 |
||
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
|
714 |
case -2: // click start/stop flag |
0 | 715 |
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_SHIP | CMD_MSG(STR_9818_CAN_T_STOP_START_SHIP)); |
716 |
break; |
|
717 |
||
718 |
default: |
|
719 |
NOT_REACHED(); |
|
720 |
} |
|
721 |
} |
|
722 |
||
2244 | 723 |
/** |
724 |
* Clones a ship |
|
725 |
* @param *v is the original vehicle to clone |
|
726 |
* @param *w is the window of the depot where the clone is build |
|
727 |
*/ |
|
4171 | 728 |
static void HandleCloneVehClick(const Vehicle *v, const Window *w) |
2244 | 729 |
{ |
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
730 |
if (v == NULL || v->type != VEH_Ship) return; |
2244 | 731 |
|
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
732 |
DoCommandP(w->window_number, v->index, _ctrl_pressed ? 1 : 0, CcCloneShip, |
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
733 |
CMD_CLONE_VEHICLE | CMD_MSG(STR_980D_CAN_T_BUILD_SHIP) |
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
734 |
); |
2244 | 735 |
|
736 |
ResetObjectToPlace(); |
|
737 |
} |
|
738 |
||
4171 | 739 |
static void ClonePlaceObj(const Window *w) |
2244 | 740 |
{ |
4171 | 741 |
const Vehicle *v = CheckMouseOverVehicle(); |
2244 | 742 |
|
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
743 |
if (v != NULL) HandleCloneVehClick(v, w); |
2244 | 744 |
} |
745 |
||
4171 | 746 |
static void ShipDepotWndProc(Window *w, WindowEvent *e) |
2639 | 747 |
{ |
748 |
switch (e->event) { |
|
0 | 749 |
case WE_PAINT: |
750 |
DrawShipDepotWindow(w); |
|
751 |
break; |
|
752 |
||
753 |
case WE_CLICK: |
|
2952 | 754 |
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
|
755 |
case 5: |
0 | 756 |
ShipDepotClick(w, e->click.pt.x, e->click.pt.y); |
757 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
758 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
759 |
case 7: |
2244 | 760 |
ResetObjectToPlace(); |
0 | 761 |
ShowBuildShipWindow(w->window_number); |
762 |
break; |
|
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2252
diff
changeset
|
763 |
|
2244 | 764 |
case 8: /* clone button */ |
765 |
InvalidateWidget(w, 8); |
|
766 |
TOGGLEBIT(w->click_state, 8); |
|
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2252
diff
changeset
|
767 |
|
2244 | 768 |
if (HASBIT(w->click_state, 8)) { |
769 |
_place_clicked_vehicle = NULL; |
|
770 |
SetObjectToPlaceWnd(SPR_CURSOR_CLONE, VHM_RECT, w); |
|
771 |
} else { |
|
772 |
ResetObjectToPlace(); |
|
773 |
} |
|
774 |
break; |
|
0 | 775 |
|
2244 | 776 |
case 9: /* scroll to tile */ |
777 |
ResetObjectToPlace(); |
|
0 | 778 |
ScrollMainWindowToTile(w->window_number); |
779 |
break; |
|
780 |
} |
|
781 |
break; |
|
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2252
diff
changeset
|
782 |
|
2244 | 783 |
case WE_PLACE_OBJ: { |
2958
3f8946daf55f
(svn r3520) Remove unused parameters from some functions
tron
parents:
2952
diff
changeset
|
784 |
ClonePlaceObj(w); |
2244 | 785 |
} break; |
786 |
||
787 |
case WE_ABORT_PLACE_OBJ: { |
|
788 |
CLRBIT(w->click_state, 8); |
|
789 |
InvalidateWidget(w, 8); |
|
790 |
} break; |
|
2261
3f78323707bb
(svn r2781) Fix some of the issues with variables in .h files.
ludde
parents:
2252
diff
changeset
|
791 |
|
2244 | 792 |
// check if a vehicle in a depot was clicked.. |
793 |
case WE_MOUSELOOP: { |
|
4171 | 794 |
const Vehicle *v = _place_clicked_vehicle; |
2244 | 795 |
|
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2549
diff
changeset
|
796 |
// since OTTD checks all open depot windows, we will make sure that it triggers the one with a clicked clone button |
2244 | 797 |
if (v != NULL && HASBIT(w->click_state, 8)) { |
798 |
_place_clicked_vehicle = NULL; |
|
799 |
HandleCloneVehClick(v, w); |
|
800 |
} |
|
801 |
} break; |
|
0 | 802 |
|
803 |
case WE_DESTROY: |
|
804 |
DeleteWindowById(WC_BUILD_VEHICLE, w->window_number); |
|
805 |
break; |
|
806 |
||
2755
3098984d08c8
(svn r3300) Remove unreachable code - in this case some duplicate breaks
tron
parents:
2725
diff
changeset
|
807 |
case WE_DRAGDROP: |
2952 | 808 |
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
|
809 |
case 5: { |
0 | 810 |
Vehicle *v; |
811 |
VehicleID sel = WP(w,traindepot_d).sel; |
|
812 |
||
813 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
814 |
SetWindowDirty(w); |
|
815 |
||
816 |
if (GetVehicleFromShipDepotWndPt(w, e->dragdrop.pt.x, e->dragdrop.pt.y, &v) == 0 && |
|
817 |
v != NULL && |
|
818 |
sel == v->index) { |
|
819 |
ShowShipViewWindow(v); |
|
820 |
} |
|
821 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
822 |
|
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
|
823 |
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
|
824 |
if (!HASBIT(w->disabled_state, 4) && |
4434
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4427
diff
changeset
|
825 |
WP(w,traindepot_d).sel != INVALID_VEHICLE) { |
0 | 826 |
Vehicle *v; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
827 |
|
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
|
828 |
HandleButtonClick(w, 4); |
0 | 829 |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
830 |
v = GetVehicle(WP(w,traindepot_d).sel); |
0 | 831 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
832 |
||
833 |
_backup_orders_tile = v->tile; |
|
834 |
BackupVehicleOrders(v, _backup_orders_data); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
835 |
|
0 | 836 |
if (!DoCommandP(v->tile, v->index, 0, NULL, CMD_SELL_SHIP | CMD_MSG(STR_980C_CAN_T_SELL_SHIP))) |
837 |
_backup_orders_tile = 0; |
|
838 |
} |
|
839 |
break; |
|
840 |
default: |
|
841 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
|
842 |
SetWindowDirty(w); |
|
843 |
} |
|
844 |
break; |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
845 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
846 |
case WE_RESIZE: |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
847 |
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
|
848 |
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
|
849 |
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
|
850 |
break; |
0 | 851 |
} |
852 |
} |
|
853 |
||
854 |
static const Widget _ship_depot_widgets[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
855 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
856 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 292, 0, 13, STR_9803_SHIP_DEPOT, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
857 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 293, 304, 0, 13, 0x0, STR_STICKY_BUTTON}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
858 |
{ WWT_PANEL, RESIZE_LRB, 14, 270, 292, 14, 13, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
859 |
{ WWT_IMGBTN, RESIZE_LRTB, 14, 270, 292, 14, 61, 0x2A9, STR_9821_DRAG_SHIP_TO_HERE_TO_SELL}, |
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
|
860 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
861 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 269, 14, 61, 0x203, STR_981F_SHIPS_CLICK_ON_SHIP_FOR}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
862 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 293, 304, 14, 61, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
863 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 96, 62, 73, STR_9804_NEW_SHIPS, STR_9820_BUILD_NEW_SHIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
864 |
{WWT_NODISTXTBTN, RESIZE_TB, 14, 97, 194, 62, 73, STR_CLONE_SHIP, STR_CLONE_SHIP_DEPOT_INFO}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
865 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 195, 292, 62, 73, STR_00E4_LOCATION, STR_9822_CENTER_MAIN_VIEW_ON_SHIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
866 |
{ WWT_PANEL, RESIZE_RTB, 14, 293, 292, 62, 73, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
867 |
{ 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
|
868 |
{ WIDGETS_END}, |
0 | 869 |
}; |
870 |
||
871 |
static const WindowDesc _ship_depot_desc = { |
|
872 |
-1, -1, 305, 74, |
|
873 |
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
|
874 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 875 |
_ship_depot_widgets, |
876 |
ShipDepotWndProc |
|
877 |
}; |
|
878 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
879 |
void ShowShipDepotWindow(TileIndex tile) |
0 | 880 |
{ |
4171 | 881 |
Window *w = AllocateWindowDescFront(&_ship_depot_desc,tile); |
0 | 882 |
|
2639 | 883 |
if (w != NULL) { |
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
|
884 |
w->caption_color = GetTileOwner(w->window_number); |
0 | 885 |
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
|
886 |
w->hscroll.cap = 3; |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
887 |
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
|
888 |
w->resize.step_height = 24; |
0 | 889 |
WP(w,traindepot_d).sel = INVALID_VEHICLE; |
890 |
_backup_orders_tile = 0; |
|
891 |
} |
|
892 |
} |
|
893 |
||
894 |
||
4171 | 895 |
static void DrawSmallOrderList(const Vehicle *v, int x, int y) |
2639 | 896 |
{ |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
982
diff
changeset
|
897 |
const Order *order; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
982
diff
changeset
|
898 |
int sel, i = 0; |
0 | 899 |
|
900 |
sel = v->cur_order_index; |
|
901 |
||
1108
6c05bdeb9d41
(svn r1609) -Codechange: converted the last order-loop with FOR_VEHICLE_ORDERS
truelight
parents:
1055
diff
changeset
|
902 |
FOR_VEHICLE_ORDERS(v, order) { |
3732
84cadfb100ed
(svn r4709) - Codechange: avoid messing around with globals, magic numbers and literal strings by using a string ID, when drawing the small right arrow for the small order lists (aircraft and ships)
peter1138
parents:
3491
diff
changeset
|
903 |
if (sel == 0) DrawString(x - 6, y, STR_SMALL_RIGHT_ARROW, 16); |
0 | 904 |
sel--; |
905 |
||
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
982
diff
changeset
|
906 |
if (order->type == OT_GOTO_STATION) { |
4389
e4555522d257
(svn r6142) -Codechange: added WaypointID (sorry DV, couldn't splits it anymore)
truelight
parents:
4345
diff
changeset
|
907 |
if (!IsBuoy(GetStation(order->dest.station))){ |
e4555522d257
(svn r6142) -Codechange: added WaypointID (sorry DV, couldn't splits it anymore)
truelight
parents:
4345
diff
changeset
|
908 |
SetDParam(0, order->dest.station); |
0 | 909 |
DrawString(x, y, STR_A036, 0); |
910 |
||
911 |
y += 6; |
|
2639 | 912 |
if (++i == 4) break; |
0 | 913 |
} |
914 |
} |
|
915 |
} |
|
916 |
} |
|
917 |
||
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
918 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
919 |
static const Widget _player_ships_widgets[] = { |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
920 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
921 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_9805_SHIPS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
922 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
923 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, STR_SORT_BY, STR_SORT_ORDER_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
924 |
{ WWT_PANEL, RESIZE_NONE, 14, 81, 235, 14, 25, 0x0, STR_SORT_CRITERIA_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
925 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 236, 247, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
926 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 248, 259, 14, 25, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
927 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 247, 26, 169, 0x401, STR_9823_SHIPS_CLICK_ON_SHIP_FOR}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
928 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 248, 259, 26, 169, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
929 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 124, 170, 181, STR_9804_NEW_SHIPS, STR_9824_BUILD_NEW_SHIPS_REQUIRES}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
930 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 125, 247, 170, 181, STR_REPLACE_VEHICLES, STR_REPLACE_HELP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
931 |
{ WWT_PANEL, RESIZE_RTB, 14, 248, 247, 170, 181, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
932 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 248, 259, 170, 181, 0x0, STR_RESIZE_BUTTON}, |
588 | 933 |
{ WIDGETS_END}, |
934 |
}; |
|
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
|
935 |
|
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
936 |
static const Widget _other_player_ships_widgets[] = { |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
937 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
938 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 247, 0, 13, STR_9805_SHIPS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
939 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
940 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 80, 14, 25, STR_SORT_BY, STR_SORT_ORDER_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
941 |
{ WWT_PANEL, RESIZE_NONE, 14, 81, 235, 14, 25, 0x0, STR_SORT_CRITERIA_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
942 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 236, 247, 14, 25, STR_0225, STR_SORT_CRITERIA_TIP}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
943 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 248, 259, 14, 25, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
944 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 247, 26, 169, 0x401, STR_9823_SHIPS_CLICK_ON_SHIP_FOR}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
945 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 248, 259, 26, 169, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
946 |
{ WWT_PANEL, RESIZE_RTB, 14, 0, 247, 170, 181, 0x0, STR_NULL}, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4329
diff
changeset
|
947 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 248, 259, 170, 181, 0x0, STR_RESIZE_BUTTON}, |
588 | 948 |
{ WIDGETS_END}, |
949 |
}; |
|
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
|
950 |
|
0 | 951 |
static void PlayerShipsWndProc(Window *w, WindowEvent *e) |
952 |
{ |
|
4426
291490691472
(svn r6181) -Fix r6161: The list of vehicles using a certain station got a bit of display code mixed up with the list of vehicles with shared orders (nycom)
bjarni
parents:
4414
diff
changeset
|
953 |
OrderID order = INVALID_ORDER; |
291490691472
(svn r6181) -Fix r6161: The list of vehicles using a certain station got a bit of display code mixed up with the list of vehicles with shared orders (nycom)
bjarni
parents:
4414
diff
changeset
|
954 |
StationID station = INVALID_STATION; |
2466
2774132ebb9a
(svn r2992) Use PlayerID, StationID and INVALID_STATION instead of int, int and -1
tron
parents:
2436
diff
changeset
|
955 |
PlayerID owner = GB(w->window_number, 0, 8); |
588 | 956 |
vehiclelist_d *vl = &WP(w, vehiclelist_d); |
957 |
||
4426
291490691472
(svn r6181) -Fix r6161: The list of vehicles using a certain station got a bit of display code mixed up with the list of vehicles with shared orders (nycom)
bjarni
parents:
4414
diff
changeset
|
958 |
if (w->window_number & SHARE_FLAG) { |
291490691472
(svn r6181) -Fix r6161: The list of vehicles using a certain station got a bit of display code mixed up with the list of vehicles with shared orders (nycom)
bjarni
parents:
4414
diff
changeset
|
959 |
order = GB(w->window_number, 16, 16); |
291490691472
(svn r6181) -Fix r6161: The list of vehicles using a certain station got a bit of display code mixed up with the list of vehicles with shared orders (nycom)
bjarni
parents:
4414
diff
changeset
|
960 |
} else { |
291490691472
(svn r6181) -Fix r6161: The list of vehicles using a certain station got a bit of display code mixed up with the list of vehicles with shared orders (nycom)
bjarni
parents:
4414
diff
changeset
|
961 |
station = GB(w->window_number, 16, 16); |
291490691472
(svn r6181) -Fix r6161: The list of vehicles using a certain station got a bit of display code mixed up with the list of vehicles with shared orders (nycom)
bjarni
parents:
4414
diff
changeset
|
962 |
} |
291490691472
(svn r6181) -Fix r6161: The list of vehicles using a certain station got a bit of display code mixed up with the list of vehicles with shared orders (nycom)
bjarni
parents:
4414
diff
changeset
|
963 |
|
2952 | 964 |
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
|
965 |
case WE_PAINT: { |
588 | 966 |
int x = 2; |
967 |
int y = PLY_WND_PRC__OFFSET_TOP_WIDGET; |
|
968 |
int max; |
|
969 |
int i; |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
193
diff
changeset
|
970 |
|
4408
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
971 |
BuildVehicleList(vl, VEH_Ship, owner, station, order); |
588 | 972 |
SortVehicleList(vl); |
973 |
SetVScrollCount(w, vl->list_length); |
|
974 |
||
975 |
// disable 'Sort By' tooltip on Unsorted sorting criteria |
|
976 |
if (vl->sort_type == SORT_BY_UNSORTED) |
|
757 | 977 |
w->disabled_state |= (1 << 3); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
978 |
|
0 | 979 |
/* draw the widgets */ |
980 |
{ |
|
1962
51ee4f459268
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents:
1938
diff
changeset
|
981 |
const Player *p = GetPlayer(owner); |
4408
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
982 |
if (order != INVALID_ORDER) { |
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
983 |
/* Shared Orders -- (###) Ships */ |
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
984 |
SetDParam(0, w->vscroll.count); |
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
985 |
w->widget[1].unkA = STR_VEH_WITH_SHARED_ORDERS_LIST; |
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
986 |
w->widget[9].unkA = STR_EMPTY; |
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
987 |
w->widget[10].unkA = STR_EMPTY; |
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
988 |
SETBIT(w->disabled_state, 9); |
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
989 |
SETBIT(w->disabled_state, 10); |
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
990 |
} else if (station == INVALID_STATION) { |
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
991 |
/* Company Name -- (###) Ships */ |
588 | 992 |
SetDParam(0, p->name_1); |
993 |
SetDParam(1, p->name_2); |
|
994 |
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
|
995 |
w->widget[1].unkA = STR_9805_SHIPS; |
588 | 996 |
} else { |
4408
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
997 |
/* Station Name -- (###) Ships */ |
1294
bc831562148e
(svn r1798) GetFoo(i)->index is per definition i, so replace the former with the latter
tron
parents:
1246
diff
changeset
|
998 |
SetDParam(0, station); |
588 | 999 |
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
|
1000 |
w->widget[1].unkA = STR_SCHEDULED_SHIPS; |
588 | 1001 |
} |
0 | 1002 |
DrawWindowWidgets(w); |
1003 |
} |
|
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1004 |
/* draw sorting criteria string */ |
588 | 1005 |
DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10); |
1006 |
/* draw arrow pointing up/down for ascending/descending sorting */ |
|
2406
be5cfb8cd20d
(svn r2932) Give the strings consisting of an up/a down arrow symbolic names
tron
parents:
2273
diff
changeset
|
1007 |
DoDrawString(vl->flags & VL_DESC ? DOWNARROW : UPARROW, 69, 15, 0x10); |
0 | 1008 |
|
588 | 1009 |
max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length); |
1010 |
for (i = w->vscroll.pos; i < max; ++i) { |
|
4266
57a72ad31925
(svn r5894) Remove a totally unnecessary indirection in the vehicle sorter code. Less code, less data, simply better
tron
parents:
4261
diff
changeset
|
1011 |
const Vehicle* v = vl->sort_list[i]; |
588 | 1012 |
StringID str; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1013 |
|
588 | 1014 |
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
|
1015 |
|
588 | 1016 |
DrawShipImage(v, x + 19, y + 6, INVALID_VEHICLE); |
1017 |
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
|
1018 |
|
588 | 1019 |
SetDParam(0, v->unitnumber); |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3989
diff
changeset
|
1020 |
if (IsShipInDepot(v)) { |
588 | 1021 |
str = STR_021F; |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3989
diff
changeset
|
1022 |
} else { |
588 | 1023 |
str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2; |
4000
bab1ebc37da0
(svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents:
3989
diff
changeset
|
1024 |
} |
588 | 1025 |
DrawString(x, y + 2, str, 0); |
1026 |
||
1027 |
SetDParam(0, v->profit_this_year); |
|
1028 |
SetDParam(1, v->profit_last_year); |
|
1029 |
DrawString(x + 12, y + 28, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0); |
|
1030 |
||
1031 |
if (v->string_id != STR_SV_SHIP_NAME) { |
|
1032 |
SetDParam(0, v->string_id); |
|
1033 |
DrawString(x + 12, y, STR_01AB, 0); |
|
0 | 1034 |
} |
588 | 1035 |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
982
diff
changeset
|
1036 |
DrawSmallOrderList(v, x + 138, y); |
588 | 1037 |
|
1038 |
y += PLY_WND_PRC__SIZE_OF_ROW_BIG; |
|
0 | 1039 |
} |
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 |
} break; |
0 | 1041 |
|
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
|
1042 |
case WE_CLICK: { |
2952 | 1043 |
switch (e->click.widget) { |
757 | 1044 |
case 3: /* Flip sorting method ascending/descending */ |
588 | 1045 |
vl->flags ^= VL_DESC; |
1046 |
vl->flags |= VL_RESORT; |
|
1246
45f15251412b
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1108
diff
changeset
|
1047 |
_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
|
1048 |
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
|
1049 |
break; |
757 | 1050 |
case 4: case 5:/* Select sorting criteria dropdown menu */ |
842 | 1051 |
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
|
1052 |
return; |
757 | 1053 |
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
|
1054 |
uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_BIG; |
4171 | 1055 |
const Vehicle *v; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
1056 |
|
2549 | 1057 |
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
|
1058 |
|
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 |
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
|
1060 |
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
1061 |
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
|
1062 |
|
4434
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4427
diff
changeset
|
1063 |
v = vl->sort_list[id_v]; |
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
|
1064 |
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
1065 |
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
|
1066 |
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
1067 |
ShowShipViewWindow(v); |
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
|
1068 |
} 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
|
1069 |
|
3884
475989407ceb
(svn r4940) Remove the dubious feature of remembering the last built depot. It serves no real purpose except causing confusion
tron
parents:
3732
diff
changeset
|
1070 |
case 9: /* Build new Vehicle */ |
2639 | 1071 |
if (!IsWindowOfPrototype(w, _player_ships_widgets)) break; |
0 | 1072 |
ShowBuildShipWindow(0); |
3884
475989407ceb
(svn r4940) Remove the dubious feature of remembering the last built depot. It serves no real purpose except causing confusion
tron
parents:
3732
diff
changeset
|
1073 |
break; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1074 |
|
842 | 1075 |
case 10: { |
2639 | 1076 |
if (!IsWindowOfPrototype(w, _player_ships_widgets)) break; |
886
4442d7859ea7
(svn r1372) -Fix: fixed some GUI glitches introduced with resize-buttons
truelight
parents:
878
diff
changeset
|
1077 |
|
842 | 1078 |
ShowReplaceVehicleWindow(VEH_Ship); |
1079 |
break; |
|
0 | 1080 |
} |
842 | 1081 |
} |
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
|
1082 |
} 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
|
1083 |
|
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
|
1084 |
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ |
588 | 1085 |
if (vl->sort_type != e->dropdown.index) { |
1086 |
// value has changed -> resort |
|
1087 |
vl->flags |= VL_RESORT; |
|
1088 |
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
|
1089 |
_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
|
1090 |
|
588 | 1091 |
// enable 'Sort By' if a sorter criteria is chosen |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4012
diff
changeset
|
1092 |
if (vl->sort_type != SORT_BY_UNSORTED) CLRBIT(w->disabled_state, 3); |
588 | 1093 |
} |
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
|
1094 |
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
|
1095 |
break; |
588 | 1096 |
|
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
|
1097 |
case WE_CREATE: /* set up resort timer */ |
588 | 1098 |
vl->sort_list = NULL; |
1246
45f15251412b
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
darkvater
parents:
1108
diff
changeset
|
1099 |
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
|
1100 |
vl->sort_type = _sorting.ship.criteria; |
588 | 1101 |
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
|
1102 |
break; |
588 | 1103 |
|
767 | 1104 |
case WE_DESTROY: |
4280
3265e76b7016
(svn r5910) Fix some more warnings on MSVC by using (void*) casts. Followup of r5907.
Darkvater
parents:
4266
diff
changeset
|
1105 |
free((void*)vl->sort_list); |
767 | 1106 |
break; |
1107 |
||
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
|
1108 |
case WE_TICK: /* resort the list every 20 seconds orso (10 days) */ |
588 | 1109 |
if (--vl->resort_timer == 0) { |
1110 |
DEBUG(misc, 1) ("Periodic resort ships list player %d station %d", |
|
1111 |
owner, station); |
|
1112 |
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; |
|
1113 |
vl->flags |= VL_RESORT; |
|
1114 |
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
|
1115 |
} |
0 | 1116 |
break; |
867
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1117 |
|
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1118 |
case WE_RESIZE: |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1119 |
/* Update the scroll + matrix */ |
581154a08a78
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
842
diff
changeset
|
1120 |
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
|
1121 |
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
|
1122 |
break; |
0 | 1123 |
} |
1124 |
} |
|
168
79f9ed5b23e6
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
darkvater
parents:
164
diff
changeset
|
1125 |
|
0 | 1126 |
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
|
1127 |
-1, -1, 260, 182, |
0 | 1128 |
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
|
1129 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 1130 |
_player_ships_widgets, |
1131 |
PlayerShipsWndProc |
|
1132 |
}; |
|
1133 |
||
1134 |
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
|
1135 |
-1, -1, 260, 182, |
0 | 1136 |
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
|
1137 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 1138 |
_other_player_ships_widgets, |
1139 |
PlayerShipsWndProc |
|
1140 |
}; |
|
1141 |
||
1142 |
||
4414
ed5b85ff5b0a
(svn r6167) -Code cleanup r6161: replaced some uint16 with OrderID and (1 << 8) with SHARE_FLAG
bjarni
parents:
4412
diff
changeset
|
1143 |
static void ShowPlayerShipsLocal(PlayerID player, StationID station, OrderID order, bool show_shared) |
0 | 1144 |
{ |
1145 |
Window *w; |
|
1146 |
||
4408
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
1147 |
if (show_shared) { |
4427
cacdecf56fdf
(svn r6182) -Code cleanup: replaced one (1 << 8) with SHARE_FLAG (missed in r6167)
bjarni
parents:
4426
diff
changeset
|
1148 |
w = AllocateWindowDescFront(&_player_ships_desc, (order << 16) | SHARE_FLAG); |
4408
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
1149 |
} else { |
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
1150 |
if (player == _local_player) { |
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
1151 |
w = AllocateWindowDescFront(&_player_ships_desc, (station << 16) | player); |
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
1152 |
} else { |
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
1153 |
w = AllocateWindowDescFront(&_other_player_ships_desc, (station << 16) | player); |
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
1154 |
} |
0 | 1155 |
} |
4408
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
1156 |
|
2639 | 1157 |
if (w != NULL) { |
4408
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
1158 |
w->caption_color = player; |
0 | 1159 |
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
|
1160 |
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
|
1161 |
w->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_BIG; |
0 | 1162 |
} |
1163 |
} |
|
4408
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
1164 |
|
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
1165 |
void ShowPlayerShips(PlayerID player, StationID station) |
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
1166 |
{ |
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
1167 |
ShowPlayerShipsLocal(player, station, 0, false); |
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
1168 |
} |
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
1169 |
|
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
1170 |
void ShowVehWithSharedOrdersShips(Vehicle *v) |
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
1171 |
{ |
4434
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4427
diff
changeset
|
1172 |
if (v->orders == NULL) return; // no shared list to show |
4408
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
1173 |
ShowPlayerShipsLocal(v->owner, INVALID_STATION, v->orders->index, true); |
84ec2899adfa
(svn r6161) -Feature: List of vehicles with the same shared orders
bjarni
parents:
4389
diff
changeset
|
1174 |
} |