* Handle click in the depot matrix. * @param x Horizontal position in the matrix widget in pixels. * @param y Vertical position in the matrix widget in pixels. */
| 569 | * @param y Vertical position in the matrix widget in pixels. |
| 570 | */ |
| 571 | void DepotClick(int x, int y) |
| 572 | { |
| 573 | GetDepotVehiclePtData gdvp = { nullptr, nullptr }; |
| 574 | const Vehicle *v = nullptr; |
| 575 | DepotGUIAction mode = this->GetVehicleFromDepotWndPt(x, y, &v, &gdvp); |
| 576 | |
| 577 | if (this->type == VEH_TRAIN) v = gdvp.wagon; |
| 578 | |
| 579 | switch (mode) { |
| 580 | case MODE_ERROR: // invalid |
| 581 | return; |
| 582 | |
| 583 | case MODE_DRAG_VEHICLE: { // start dragging of vehicle |
| 584 | if (v != nullptr && VehicleClicked(v)) return; |
| 585 | |
| 586 | VehicleID sel = this->sel; |
| 587 | |
| 588 | if (this->type == VEH_TRAIN && sel != VehicleID::Invalid()) { |
| 589 | this->sel = VehicleID::Invalid(); |
| 590 | TrainDepotMoveVehicle(v, sel, gdvp.head); |
| 591 | } else if (v != nullptr) { |
| 592 | SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this); |
| 593 | SetMouseCursorVehicle(v, EIT_IN_DEPOT); |
| 594 | _cursor.vehchain = _ctrl_pressed; |
| 595 | |
| 596 | this->sel = v->index; |
| 597 | this->SetDirty(); |
| 598 | } |
| 599 | break; |
| 600 | } |
| 601 | |
| 602 | case MODE_SHOW_VEHICLE: // show info window |
| 603 | ShowVehicleViewWindow(v); |
| 604 | break; |
| 605 | |
| 606 | case MODE_START_STOP: // click start/stop flag |
| 607 | StartStopVehicle(v, false); |
| 608 | break; |
| 609 | |
| 610 | default: NOT_REACHED(); |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | /** |
| 615 | * Function to set up vehicle specific widgets (mainly sprites and strings). |
no test coverage detected