From 8271813a47b4c81cd30e980b029bdf5e5d0a8eef Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sat, 6 Jan 2024 19:22:09 +0000 Subject: [PATCH] Timetable window: Use checked items for extra/leave early dropdown --- src/timetable_gui.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index 96b8061a26..22ce0d626a 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -1038,12 +1038,13 @@ struct TimetableWindow : GeneralVehicleWindow { bool leave_type_disabled = (order == nullptr) || ((!(order->IsType(OT_GOTO_STATION) || (order->IsType(OT_GOTO_DEPOT) && !(order->GetDepotActionType() & ODATFB_HALT))) || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION)) && !order->IsType(OT_CONDITIONAL)); + OrderLeaveType current = order != nullptr ? order->GetLeaveType() : OLT_END; DropDownList list; - list.emplace_back(new DropDownListStringItem(STR_TIMETABLE_LEAVE_NORMAL, OLT_NORMAL, leave_type_disabled)); - list.emplace_back(new DropDownListStringItem(STR_TIMETABLE_LEAVE_EARLY, OLT_LEAVE_EARLY, leave_type_disabled)); - list.emplace_back(new DropDownListStringItem(STR_TIMETABLE_LEAVE_EARLY_FULL_ANY, OLT_LEAVE_EARLY_FULL_ANY, leave_type_disabled || !order->IsType(OT_GOTO_STATION))); - list.emplace_back(new DropDownListStringItem(STR_TIMETABLE_LEAVE_EARLY_FULL_ALL, OLT_LEAVE_EARLY_FULL_ALL, leave_type_disabled || !order->IsType(OT_GOTO_STATION))); - ShowDropDownList(this, std::move(list), order != nullptr ? order->GetLeaveType() : -1, WID_VT_EXTRA); + list.emplace_back(std::make_unique(current == OLT_NORMAL, STR_TIMETABLE_LEAVE_NORMAL, OLT_NORMAL, leave_type_disabled)); + list.emplace_back(std::make_unique(current == OLT_LEAVE_EARLY, STR_TIMETABLE_LEAVE_EARLY, OLT_LEAVE_EARLY, leave_type_disabled)); + list.emplace_back(std::make_unique(current == OLT_LEAVE_EARLY_FULL_ANY, STR_TIMETABLE_LEAVE_EARLY_FULL_ANY, OLT_LEAVE_EARLY_FULL_ANY, leave_type_disabled || !order->IsType(OT_GOTO_STATION))); + list.emplace_back(std::make_unique(current == OLT_LEAVE_EARLY_FULL_ALL, STR_TIMETABLE_LEAVE_EARLY_FULL_ALL, OLT_LEAVE_EARLY_FULL_ALL, leave_type_disabled || !order->IsType(OT_GOTO_STATION))); + ShowDropDownList(this, std::move(list), -1, widget, 0, false, DDSF_LOST_FOCUS); break; }