| 615 | } |
| 616 | |
| 617 | void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override |
| 618 | { |
| 619 | const Vehicle *v = this->vehicle; |
| 620 | |
| 621 | switch (widget) { |
| 622 | case WID_VT_ORDER_VIEW: // Order view button |
| 623 | ShowOrdersWindow(v); |
| 624 | break; |
| 625 | |
| 626 | case WID_VT_TIMETABLE_PANEL: { // Main panel. |
| 627 | int selected = GetOrderFromTimetableWndPt(pt.y, v); |
| 628 | |
| 629 | this->CloseChildWindows(); |
| 630 | this->sel_index = (selected == INT32_MAX || selected == this->sel_index) ? -1 : selected; |
| 631 | break; |
| 632 | } |
| 633 | |
| 634 | case WID_VT_START_DATE: // Change the date that the timetable starts. |
| 635 | if (_settings_client.gui.timetable_mode == TimetableMode::Seconds) { |
| 636 | this->query_widget = WID_VT_START_DATE; |
| 637 | this->change_timetable_all = _ctrl_pressed; |
| 638 | ShowQueryString({}, STR_TIMETABLE_START_SECONDS_QUERY, 6, this, CS_NUMERAL, QueryStringFlag::AcceptUnchanged); |
| 639 | } else { |
| 640 | ShowSetDateWindow(this, v->index.base(), TimerGameEconomy::date, TimerGameEconomy::year, TimerGameEconomy::year + MAX_TIMETABLE_START_YEARS, |
| 641 | [ctrl=_ctrl_pressed](const Window *w, TimerGameEconomy::Date date) { |
| 642 | Command<CMD_SET_TIMETABLE_START>::Post(STR_ERROR_CAN_T_TIMETABLE_VEHICLE, w->window_number, ctrl, GetStartTickFromDate(date)); |
| 643 | } |
| 644 | ); |
| 645 | } |
| 646 | break; |
| 647 | |
| 648 | case WID_VT_CHANGE_TIME: { // "Wait For" button. |
| 649 | this->query_widget = WID_VT_CHANGE_TIME; |
| 650 | int selected = this->sel_index; |
| 651 | VehicleOrderID real = (selected + 1) / 2; |
| 652 | |
| 653 | if (real >= v->GetNumOrders()) real = 0; |
| 654 | |
| 655 | const Order *order = v->GetOrder(real); |
| 656 | std::string current; |
| 657 | |
| 658 | if (order != nullptr) { |
| 659 | uint time = (selected % 2 != 0) ? order->GetTravelTime() : order->GetWaitTime(); |
| 660 | time /= TicksPerTimetableUnit(); |
| 661 | |
| 662 | if (time != 0) { |
| 663 | current = GetString(STR_JUST_INT, time); |
| 664 | } |
| 665 | } |
| 666 | |
| 667 | this->change_timetable_all = _ctrl_pressed && (order != nullptr); |
| 668 | ShowQueryString(current, STR_TIMETABLE_CHANGE_TIME_QUERY, 31, this, CS_NUMERAL, QueryStringFlag::AcceptUnchanged); |
| 669 | break; |
| 670 | } |
| 671 | |
| 672 | case WID_VT_CHANGE_SPEED: { // Change max speed button. |
| 673 | this->query_widget = WID_VT_CHANGE_SPEED; |
| 674 | int selected = this->sel_index; |
nothing calls this directly
no test coverage detected