17 #include "vehicle_gui.h" |
17 #include "vehicle_gui.h" |
18 #include "newgrf_engine.h" |
18 #include "newgrf_engine.h" |
19 |
19 |
20 void DrawShipImage(const Vehicle *v, int x, int y, VehicleID selection) |
20 void DrawShipImage(const Vehicle *v, int x, int y, VehicleID selection) |
21 { |
21 { |
22 DrawSprite(GetShipImage(v, DIR_W), GetVehiclePalette(v), x + 32, y + 10); |
22 DrawSprite(v->GetImage(DIR_W), GetVehiclePalette(v), x + 32, y + 10); |
23 |
23 |
24 if (v->index == selection) { |
24 if (v->index == selection) { |
25 DrawFrameRect(x - 5, y - 1, x + 67, y + 21, 15, FR_BORDERONLY); |
25 DrawFrameRect(x - 5, y - 1, x + 67, y + 21, 15, FR_BORDERONLY); |
26 } |
26 } |
27 } |
27 } |
36 SetWindowWidgetDisabledState(w, 2, v->owner != _local_player); |
36 SetWindowWidgetDisabledState(w, 2, v->owner != _local_player); |
37 /* disable service-scroller when interval is set to disabled */ |
37 /* disable service-scroller when interval is set to disabled */ |
38 SetWindowWidgetDisabledState(w, 5, !_patches.servint_ships); |
38 SetWindowWidgetDisabledState(w, 5, !_patches.servint_ships); |
39 SetWindowWidgetDisabledState(w, 6, !_patches.servint_ships); |
39 SetWindowWidgetDisabledState(w, 6, !_patches.servint_ships); |
40 |
40 |
41 SetDParam(0, v->string_id); |
41 SetDParam(0, v->index); |
42 SetDParam(1, v->unitnumber); |
|
43 DrawWindowWidgets(w); |
42 DrawWindowWidgets(w); |
44 |
43 |
45 /* Draw running cost */ |
44 /* Draw running cost */ |
46 { |
45 { |
47 int year = v->age / 366; |
46 int year = v->age / 366; |
81 DrawString(13, 102, _patches.servint_ispercent ? STR_SERVICING_INTERVAL_PERCENT : STR_883C_SERVICING_INTERVAL_DAYS, 0); |
80 DrawString(13, 102, _patches.servint_ispercent ? STR_SERVICING_INTERVAL_PERCENT : STR_883C_SERVICING_INTERVAL_DAYS, 0); |
82 } |
81 } |
83 |
82 |
84 DrawShipImage(v, 3, 57, INVALID_VEHICLE); |
83 DrawShipImage(v, 3, 57, INVALID_VEHICLE); |
85 |
84 |
|
85 SetDParam(0, v->engine_type); |
86 SetDParam(1, v->build_year); |
86 SetDParam(1, v->build_year); |
87 SetDParam(0, GetCustomEngineName(v->engine_type)); |
|
88 SetDParam(2, v->value); |
87 SetDParam(2, v->value); |
89 DrawString(74, 57, STR_9816_BUILT_VALUE, 0); |
88 DrawString(74, 57, STR_9816_BUILT_VALUE, 0); |
90 |
89 |
91 SetDParam(0, v->cargo_type); |
90 SetDParam(0, v->cargo_type); |
92 SetDParam(1, v->cargo_cap); |
91 SetDParam(1, v->cargo_cap); |
93 DrawString(74, 67, STR_9817_CAPACITY, 0); |
92 DrawString(74, 67, STR_9817_CAPACITY, 0); |
94 |
93 |
95 str = STR_8812_EMPTY; |
94 str = STR_8812_EMPTY; |
96 if (v->cargo_count != 0) { |
95 if (!v->cargo.Empty()) { |
97 SetDParam(0, v->cargo_type); |
96 SetDParam(0, v->cargo_type); |
98 SetDParam(1, v->cargo_count); |
97 SetDParam(1, v->cargo.Count()); |
99 SetDParam(2, v->cargo_source); |
98 SetDParam(2, v->cargo.Source()); |
100 str = STR_8813_FROM; |
99 str = STR_8813_FROM; |
101 } |
100 } |
102 DrawString(74, 78, str, 0); |
101 DrawString(74, 78, str, 0); |
103 |
102 |
104 /* Draw Transfer credits text */ |
103 /* Draw Transfer credits text */ |
105 SetDParam(0, v->cargo_feeder_share); |
104 SetDParam(0, v->cargo.FeederShare()); |
106 DrawString(74, 89, STR_FEEDER_CARGO_VALUE, 0); |
105 DrawString(74, 89, STR_FEEDER_CARGO_VALUE, 0); |
107 |
106 |
108 } break; |
107 } break; |
109 |
108 |
110 case WE_CLICK: { |
109 case WE_CLICK: { |
111 int mod; |
110 int mod; |
112 const Vehicle *v; |
111 const Vehicle *v; |
113 switch (e->we.click.widget) { |
112 switch (e->we.click.widget) { |
114 case 2: /* rename */ |
113 case 2: /* rename */ |
115 v = GetVehicle(w->window_number); |
114 v = GetVehicle(w->window_number); |
116 SetDParam(0, v->unitnumber); |
115 SetDParam(0, v->index); |
117 ShowQueryString(v->string_id, STR_9831_NAME_SHIP, 31, 150, w, CS_ALPHANUMERAL); |
116 ShowQueryString(STR_VEHICLE_NAME, STR_9831_NAME_SHIP, 31, 150, w, CS_ALPHANUMERAL); |
118 break; |
117 break; |
119 case 5: /* increase int */ |
118 case 5: /* increase int */ |
120 mod = _ctrl_pressed? 5 : 10; |
119 mod = _ctrl_pressed? 5 : 10; |
121 goto do_change_service_int; |
120 goto do_change_service_int; |
122 case 6: /* decrease int */ |
121 case 6: /* decrease int */ |
206 !is_localplayer || // Disable if owner is not local player |
205 !is_localplayer || // Disable if owner is not local player |
207 !refitable_and_stopped_in_depot); // Disable if the ship is not refitable or stopped in a depot |
206 !refitable_and_stopped_in_depot); // Disable if the ship is not refitable or stopped in a depot |
208 SetWindowWidgetDisabledState(w, 11, !is_localplayer); |
207 SetWindowWidgetDisabledState(w, 11, !is_localplayer); |
209 |
208 |
210 /* draw widgets & caption */ |
209 /* draw widgets & caption */ |
211 SetDParam(0, v->string_id); |
210 SetDParam(0, v->index); |
212 SetDParam(1, v->unitnumber); |
|
213 DrawWindowWidgets(w); |
211 DrawWindowWidgets(w); |
214 |
212 |
215 if (v->breakdown_ctr == 1) { |
213 if (v->breakdown_ctr == 1) { |
216 str = STR_885C_BROKEN_DOWN; |
214 str = STR_885C_BROKEN_DOWN; |
217 } else if (v->vehstatus & VS_STOPPED) { |
215 } else if (v->vehstatus & VS_STOPPED) { |