55 const Order *order; |
55 const Order *order; |
56 StringID str; |
56 StringID str; |
57 int sel; |
57 int sel; |
58 int y, i; |
58 int y, i; |
59 bool shared_orders; |
59 bool shared_orders; |
60 bool not_localplayer; |
|
61 byte color; |
60 byte color; |
62 |
61 |
63 v = GetVehicle(w->window_number); |
62 v = GetVehicle(w->window_number); |
64 not_localplayer = v->owner != _local_player; |
|
65 |
63 |
66 shared_orders = IsOrderListShared(v); |
64 shared_orders = IsOrderListShared(v); |
67 |
65 |
68 SetVScrollCount(w, v->num_orders + 1); |
66 SetVScrollCount(w, v->num_orders + 1); |
69 |
67 |
70 sel = OrderGetSel(w); |
68 sel = OrderGetSel(w); |
71 SetDParam(2, STR_8827_FULL_LOAD); |
69 SetDParam(2, STR_8827_FULL_LOAD); |
72 |
70 |
73 order = GetVehicleOrder(v, sel); |
71 order = GetVehicleOrder(v, sel); |
74 |
72 |
75 /* skip */ |
73 if (v->owner == _local_player) { |
76 SetWindowWidgetDisabledState(w, 4, not_localplayer || v->num_orders == 0); |
74 /* skip */ |
77 |
75 SetWindowWidgetDisabledState(w, 4, v->num_orders == 0); |
78 /* delete */ |
76 |
79 SetWindowWidgetDisabledState(w, 5, not_localplayer || |
77 /* delete */ |
80 (uint)v->num_orders + (shared_orders ? 1 : 0) <= (uint)WP(w, order_d).sel); |
78 SetWindowWidgetDisabledState(w, 5, |
81 |
79 (uint)v->num_orders + (shared_orders ? 1 : 0) <= (uint)WP(w, order_d).sel); |
82 /* non-stop only for trains */ |
80 |
83 SetWindowWidgetDisabledState(w, 6, not_localplayer || v->type != VEH_Train |
81 /* non-stop only for trains */ |
84 || order == NULL); |
82 SetWindowWidgetDisabledState(w, 6, v->type != VEH_Train || order == NULL); |
85 SetWindowWidgetDisabledState(w, 7, not_localplayer); // go-to |
83 SetWindowWidgetDisabledState(w, 8, order == NULL); // full load |
86 SetWindowWidgetDisabledState(w, 8, not_localplayer || order == NULL); // full load |
84 SetWindowWidgetDisabledState(w, 9, order == NULL); // unload |
87 SetWindowWidgetDisabledState(w, 9, not_localplayer || order == NULL); // unload |
85 SetWindowWidgetDisabledState(w, 10, order == NULL); // transfer |
88 SetWindowWidgetDisabledState(w, 10, not_localplayer || order == NULL); // transfer |
86 /* Disable list of vehicles with the same shared orders if there is no list */ |
89 SetWindowWidgetDisabledState(w, 11, !shared_orders || v->orders == NULL); // Disable list of vehicles with the same shared orders if there are no list |
87 SetWindowWidgetDisabledState(w, 11, !shared_orders || v->orders == NULL); |
90 SetWindowWidgetDisabledState(w, 12, not_localplayer || order == NULL); // Refit |
88 SetWindowWidgetDisabledState(w, 12, order == NULL); // Refit |
91 |
89 } else { |
|
90 DisableWindowWidget(w, 10); |
|
91 } |
92 |
92 |
93 ShowWindowWidget(w, 9); // Unload |
93 ShowWindowWidget(w, 9); // Unload |
94 HideWindowWidget(w, 12); // Refit |
94 HideWindowWidget(w, 12); // Refit |
95 |
95 |
96 if (order != NULL) { |
96 if (order != NULL) { |
97 switch (order->type) { |
97 switch (order->type) { |
98 case OT_GOTO_STATION: |
98 case OT_GOTO_STATION: break; |
99 break; |
|
100 |
99 |
101 case OT_GOTO_DEPOT: |
100 case OT_GOTO_DEPOT: |
102 DisableWindowWidget(w, 10); |
101 DisableWindowWidget(w, 10); |
103 |
102 |
104 /* Remove unload and replace it with refit */ |
103 /* Remove unload and replace it with refit */ |
493 |
492 |
494 case WE_KEYPRESS: { |
493 case WE_KEYPRESS: { |
495 Vehicle *v = GetVehicle(w->window_number); |
494 Vehicle *v = GetVehicle(w->window_number); |
496 uint i; |
495 uint i; |
497 |
496 |
|
497 if (v->owner != _local_player) break; |
|
498 |
498 for (i = 0; i < lengthof(_order_keycodes); i++) { |
499 for (i = 0; i < lengthof(_order_keycodes); i++) { |
499 if (e->we.keypress.keycode == _order_keycodes[i]) { |
500 if (e->we.keypress.keycode == _order_keycodes[i]) { |
500 e->we.keypress.cont = false; |
501 e->we.keypress.cont = false; |
501 //see if the button is disabled |
502 //see if the button is disabled |
502 if (!IsWindowWidgetDisabled(w, i + 4)) _order_button_proc[i](w, v); |
503 if (!IsWindowWidgetDisabled(w, i + 4)) _order_button_proc[i](w, v); |
534 * Check if we clicked on a vehicle |
535 * Check if we clicked on a vehicle |
535 * and if the GOTO button of this window is pressed |
536 * and if the GOTO button of this window is pressed |
536 * This is because of all open order windows WE_MOUSELOOP is called |
537 * This is because of all open order windows WE_MOUSELOOP is called |
537 * and if you have 3 windows open, and this check is not done |
538 * and if you have 3 windows open, and this check is not done |
538 * the order is copied to the last open window instead of the |
539 * the order is copied to the last open window instead of the |
539 * one where GOTO is enalbed |
540 * one where GOTO is enabled |
540 */ |
541 */ |
541 if (v != NULL && IsWindowWidgetLowered(w, 7)) { |
542 if (v != NULL && IsWindowWidgetLowered(w, 7)) { |
542 _place_clicked_vehicle = NULL; |
543 _place_clicked_vehicle = NULL; |
543 HandleOrderVehClick(GetVehicle(w->window_number), v, w); |
544 HandleOrderVehClick(GetVehicle(w->window_number), v, w); |
544 } |
545 } |