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