equal
deleted
inserted
replaced
216 /* Set the row and number of boxes in each row based on the number of boxes drawn in the matrix */ |
216 /* Set the row and number of boxes in each row based on the number of boxes drawn in the matrix */ |
217 uint16 rows_in_display = w->widget[DEPOT_WIDGET_MATRIX].data >> 8; |
217 uint16 rows_in_display = w->widget[DEPOT_WIDGET_MATRIX].data >> 8; |
218 uint16 boxes_in_each_row = w->widget[DEPOT_WIDGET_MATRIX].data & 0xFF; |
218 uint16 boxes_in_each_row = w->widget[DEPOT_WIDGET_MATRIX].data & 0xFF; |
219 |
219 |
220 /* setup disabled buttons */ |
220 /* setup disabled buttons */ |
221 SetWindowWidgetsDisabledState(w, !IsTileOwner(tile, _local_player), |
221 w->SetWidgetsDisabledState(!IsTileOwner(tile, _local_player), |
222 DEPOT_WIDGET_STOP_ALL, |
222 DEPOT_WIDGET_STOP_ALL, |
223 DEPOT_WIDGET_START_ALL, |
223 DEPOT_WIDGET_START_ALL, |
224 DEPOT_WIDGET_SELL, |
224 DEPOT_WIDGET_SELL, |
225 DEPOT_WIDGET_SELL_CHAIN, |
225 DEPOT_WIDGET_SELL_CHAIN, |
226 DEPOT_WIDGET_SELL_ALL, |
226 DEPOT_WIDGET_SELL_ALL, |
443 case VEH_Aircraft: image = GetAircraftImage(v, DIR_W); break; |
443 case VEH_Aircraft: image = GetAircraftImage(v, DIR_W); break; |
444 default: NOT_REACHED(); image = 0; |
444 default: NOT_REACHED(); image = 0; |
445 } |
445 } |
446 |
446 |
447 WP(w, depot_d).sel = v->index; |
447 WP(w, depot_d).sel = v->index; |
448 SetWindowDirty(w); |
448 w->SetDirty(); |
449 SetObjectToPlaceWnd(image, GetVehiclePalette(v), 4, w); |
449 SetObjectToPlaceWnd(image, GetVehiclePalette(v), 4, w); |
450 } |
450 } |
451 } |
451 } |
452 break; |
452 break; |
453 |
453 |
731 w->widget[DEPOT_WIDGET_MATRIX].data = |
731 w->widget[DEPOT_WIDGET_MATRIX].data = |
732 (w->vscroll.cap * 0x100) // number of rows to draw on the background |
732 (w->vscroll.cap * 0x100) // number of rows to draw on the background |
733 + (type == VEH_Train ? 1 : w->hscroll.cap); // number of boxes in each row. Trains always have just one |
733 + (type == VEH_Train ? 1 : w->hscroll.cap); // number of boxes in each row. Trains always have just one |
734 |
734 |
735 |
735 |
736 SetWindowWidgetsHiddenState(w, type != VEH_Train, |
736 w->SetWidgetsHiddenState(type != VEH_Train, |
737 DEPOT_WIDGET_H_SCROLL, |
737 DEPOT_WIDGET_H_SCROLL, |
738 DEPOT_WIDGET_SELL_CHAIN, |
738 DEPOT_WIDGET_SELL_CHAIN, |
739 WIDGET_LIST_END); |
739 WIDGET_LIST_END); |
740 |
740 |
741 ResizeDepotButtons(w); |
741 ResizeDepotButtons(w); |
890 case DEPOT_WIDGET_MATRIX: { |
890 case DEPOT_WIDGET_MATRIX: { |
891 Vehicle *v; |
891 Vehicle *v; |
892 VehicleID sel = WP(w, depot_d).sel; |
892 VehicleID sel = WP(w, depot_d).sel; |
893 |
893 |
894 WP(w, depot_d).sel = INVALID_VEHICLE; |
894 WP(w, depot_d).sel = INVALID_VEHICLE; |
895 SetWindowDirty(w); |
895 w->SetDirty(); |
896 |
896 |
897 if (WP(w, depot_d).type == VEH_Train) { |
897 if (WP(w, depot_d).type == VEH_Train) { |
898 GetDepotVehiclePtData gdvp; |
898 GetDepotVehiclePtData gdvp; |
899 |
899 |
900 if (GetVehicleFromDepotWndPt(w, e->we.dragdrop.pt.x, e->we.dragdrop.pt.y, &v, &gdvp) == MODE_DRAG_VEHICLE && |
900 if (GetVehicleFromDepotWndPt(w, e->we.dragdrop.pt.x, e->we.dragdrop.pt.y, &v, &gdvp) == MODE_DRAG_VEHICLE && |
923 bool is_engine; |
923 bool is_engine; |
924 |
924 |
925 if (IsWindowWidgetDisabled(w, e->we.click.widget)) return; |
925 if (IsWindowWidgetDisabled(w, e->we.click.widget)) return; |
926 if (WP(w, depot_d).sel == INVALID_VEHICLE) return; |
926 if (WP(w, depot_d).sel == INVALID_VEHICLE) return; |
927 |
927 |
928 HandleButtonClick(w, e->we.click.widget); |
928 w->HandleButtonClick(e->we.click.widget); |
929 |
929 |
930 v = GetVehicle(WP(w, depot_d).sel); |
930 v = GetVehicle(WP(w, depot_d).sel); |
931 WP(w, depot_d).sel = INVALID_VEHICLE; |
931 WP(w, depot_d).sel = INVALID_VEHICLE; |
932 SetWindowDirty(w); |
932 w->SetDirty(); |
933 |
933 |
934 sell_cmd = (v->type == VEH_Train && (e->we.click.widget == DEPOT_WIDGET_SELL_CHAIN || _ctrl_pressed)) ? 1 : 0; |
934 sell_cmd = (v->type == VEH_Train && (e->we.click.widget == DEPOT_WIDGET_SELL_CHAIN || _ctrl_pressed)) ? 1 : 0; |
935 |
935 |
936 is_engine = (!(v->type == VEH_Train && !IsFrontEngine(v))); |
936 is_engine = (!(v->type == VEH_Train && !IsFrontEngine(v))); |
937 |
937 |
951 if (!DoCommandP(v->tile, v->index, sell_cmd, NULL, command) && is_engine) _backup_orders_tile = 0; |
951 if (!DoCommandP(v->tile, v->index, sell_cmd, NULL, command) && is_engine) _backup_orders_tile = 0; |
952 } |
952 } |
953 break; |
953 break; |
954 default: |
954 default: |
955 WP(w, depot_d).sel = INVALID_VEHICLE; |
955 WP(w, depot_d).sel = INVALID_VEHICLE; |
956 SetWindowDirty(w); |
956 w->SetDirty(); |
957 } |
957 } |
958 break; |
958 break; |
959 |
959 |
960 case WE_RESIZE: |
960 case WE_RESIZE: |
961 w->vscroll.cap += e->we.sizing.diff.y / (int)w->resize.step_height; |
961 w->vscroll.cap += e->we.sizing.diff.y / (int)w->resize.step_height; |
1001 |
1001 |
1002 /* If we haven't got any vehicles on the mouse pointer, we haven't got any highlighted in any depots either |
1002 /* If we haven't got any vehicles on the mouse pointer, we haven't got any highlighted in any depots either |
1003 * If that is the case, we can skip looping though the windows and save time */ |
1003 * If that is the case, we can skip looping though the windows and save time */ |
1004 if (_special_mouse_mode != WSM_DRAGDROP) return; |
1004 if (_special_mouse_mode != WSM_DRAGDROP) return; |
1005 |
1005 |
1006 w = FindWindowById(WC_VEHICLE_DEPOT, v->tile); |
1006 w = Window::FindById(WC_VEHICLE_DEPOT, v->tile); |
1007 if (w != NULL) { |
1007 if (w != NULL) { |
1008 WP(w, depot_d).sel = INVALID_VEHICLE; |
1008 WP(w, depot_d).sel = INVALID_VEHICLE; |
1009 ResetObjectToPlace(); |
1009 ResetObjectToPlace(); |
1010 } |
1010 } |
1011 } |
1011 } |