4 |
4 |
5 #include "stdafx.h" |
5 #include "stdafx.h" |
6 #include "openttd.h" |
6 #include "openttd.h" |
7 #include "debug.h" |
7 #include "debug.h" |
8 #include "player_func.h" |
8 #include "player_func.h" |
9 #include "station.h" |
|
10 #include "engine.h" |
|
11 #include "gui.h" |
9 #include "gui.h" |
12 #include "window_gui.h" |
10 #include "window_gui.h" |
13 #include "textbuf_gui.h" |
11 #include "textbuf_gui.h" |
14 #include "command_func.h" |
12 #include "command_func.h" |
15 #include "variables.h" |
13 #include "variables.h" |
34 #include "autoreplace_gui.h" |
32 #include "autoreplace_gui.h" |
35 #include "core/alloc_func.hpp" |
33 #include "core/alloc_func.hpp" |
36 #include "string_func.h" |
34 #include "string_func.h" |
37 #include "settings_type.h" |
35 #include "settings_type.h" |
38 #include "widgets/dropdown_func.h" |
36 #include "widgets/dropdown_func.h" |
|
37 #include "order_func.h" |
39 |
38 |
40 #include "table/sprites.h" |
39 #include "table/sprites.h" |
41 #include "table/strings.h" |
40 #include "table/strings.h" |
|
41 |
|
42 struct refit_d { |
|
43 int sel; |
|
44 struct RefitOption *cargo; |
|
45 struct RefitList *list; |
|
46 uint length; |
|
47 VehicleOrderID order; |
|
48 }; |
|
49 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(refit_d)); |
42 |
50 |
43 struct Sorting { |
51 struct Sorting { |
44 Listing aircraft; |
52 Listing aircraft; |
45 Listing roadveh; |
53 Listing roadveh; |
46 Listing ship; |
54 Listing ship; |
907 |
915 |
908 FOR_VEHICLE_ORDERS(v, order) { |
916 FOR_VEHICLE_ORDERS(v, order) { |
909 if (sel == 0) DrawString(x - 6, y, STR_SMALL_RIGHT_ARROW, TC_BLACK); |
917 if (sel == 0) DrawString(x - 6, y, STR_SMALL_RIGHT_ARROW, TC_BLACK); |
910 sel--; |
918 sel--; |
911 |
919 |
912 if (order->type == OT_GOTO_STATION) { |
920 if (order->IsType(OT_GOTO_STATION)) { |
913 if (v->type == VEH_SHIP && GetStation(order->dest)->IsBuoy()) continue; |
921 if (v->type == VEH_SHIP && GetStation(order->GetDestination())->IsBuoy()) continue; |
914 |
922 |
915 SetDParam(0, order->dest); |
923 SetDParam(0, order->GetDestination()); |
916 DrawString(x, y, STR_A036, TC_FROMSTRING); |
924 DrawString(x, y, STR_A036, TC_FROMSTRING); |
917 |
925 |
918 y += 6; |
926 y += 6; |
919 if (++i == 4) break; |
927 if (++i == 4) break; |
920 } |
928 } |
1942 } |
1950 } |
1943 } else { // no train |
1951 } else { // no train |
1944 str = STR_8861_STOPPED; |
1952 str = STR_8861_STOPPED; |
1945 } |
1953 } |
1946 } else { // vehicle is in a "normal" state, show current order |
1954 } else { // vehicle is in a "normal" state, show current order |
1947 switch (v->current_order.type) { |
1955 switch (v->current_order.GetType()) { |
1948 case OT_GOTO_STATION: { |
1956 case OT_GOTO_STATION: { |
1949 SetDParam(0, v->current_order.dest); |
1957 SetDParam(0, v->current_order.GetDestination()); |
1950 SetDParam(1, v->GetDisplaySpeed()); |
1958 SetDParam(1, v->GetDisplaySpeed()); |
1951 str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; |
1959 str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; |
1952 } break; |
1960 } break; |
1953 |
1961 |
1954 case OT_GOTO_DEPOT: { |
1962 case OT_GOTO_DEPOT: { |
1955 if (v->type == VEH_AIRCRAFT) { |
1963 if (v->type == VEH_AIRCRAFT) { |
1956 /* Aircrafts always go to a station, even if you say depot */ |
1964 /* Aircrafts always go to a station, even if you say depot */ |
1957 SetDParam(0, v->current_order.dest); |
1965 SetDParam(0, v->current_order.GetDestination()); |
1958 SetDParam(1, v->GetDisplaySpeed()); |
1966 SetDParam(1, v->GetDisplaySpeed()); |
1959 } else { |
1967 } else { |
1960 Depot *depot = GetDepot(v->current_order.dest); |
1968 Depot *depot = GetDepot(v->current_order.GetDestination()); |
1961 SetDParam(0, depot->town_index); |
1969 SetDParam(0, depot->town_index); |
1962 SetDParam(1, v->GetDisplaySpeed()); |
1970 SetDParam(1, v->GetDisplaySpeed()); |
1963 } |
1971 } |
1964 if (HasBit(v->current_order.flags, OF_HALT_IN_DEPOT) && !HasBit(v->current_order.flags, OF_PART_OF_ORDERS)) { |
1972 if ((v->current_order.GetDepotActionType() & ODATFB_HALT) && !(v->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS)) { |
1965 str = _heading_for_depot_strings[v->type] + _patches.vehicle_speed; |
1973 str = _heading_for_depot_strings[v->type] + _patches.vehicle_speed; |
1966 } else { |
1974 } else { |
1967 str = _heading_for_depot_service_strings[v->type] + _patches.vehicle_speed; |
1975 str = _heading_for_depot_service_strings[v->type] + _patches.vehicle_speed; |
1968 } |
1976 } |
1969 } break; |
1977 } break; |
1972 str = STR_882F_LOADING_UNLOADING; |
1980 str = STR_882F_LOADING_UNLOADING; |
1973 break; |
1981 break; |
1974 |
1982 |
1975 case OT_GOTO_WAYPOINT: { |
1983 case OT_GOTO_WAYPOINT: { |
1976 assert(v->type == VEH_TRAIN); |
1984 assert(v->type == VEH_TRAIN); |
1977 SetDParam(0, v->current_order.dest); |
1985 SetDParam(0, v->current_order.GetDestination()); |
1978 str = STR_HEADING_FOR_WAYPOINT + _patches.vehicle_speed; |
1986 str = STR_HEADING_FOR_WAYPOINT + _patches.vehicle_speed; |
1979 SetDParam(1, v->GetDisplaySpeed()); |
1987 SetDParam(1, v->GetDisplaySpeed()); |
1980 break; |
1988 break; |
1981 } |
1989 } |
1982 |
1990 |
2077 break; |
2085 break; |
2078 case VVW_WIDGET_REFIT_VEH: /* refit */ |
2086 case VVW_WIDGET_REFIT_VEH: /* refit */ |
2079 ShowVehicleRefitWindow(v, INVALID_VEH_ORDER_ID); |
2087 ShowVehicleRefitWindow(v, INVALID_VEH_ORDER_ID); |
2080 break; |
2088 break; |
2081 case VVW_WIDGET_SHOW_ORDERS: /* show orders */ |
2089 case VVW_WIDGET_SHOW_ORDERS: /* show orders */ |
2082 ShowOrdersWindow(v); |
2090 if (_ctrl_pressed) { |
|
2091 ShowTimetableWindow(v); |
|
2092 } else { |
|
2093 ShowOrdersWindow(v); |
|
2094 } |
2083 break; |
2095 break; |
2084 case VVW_WIDGET_SHOW_DETAILS: /* show details */ |
2096 case VVW_WIDGET_SHOW_DETAILS: /* show details */ |
2085 ShowVehicleDetailsWindow(v); |
2097 ShowVehicleDetailsWindow(v); |
2086 break; |
2098 break; |
2087 case VVW_WIDGET_CLONE_VEH: /* clone vehicle */ |
2099 case VVW_WIDGET_CLONE_VEH: /* clone vehicle */ |