MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / OnDropdownSelect

Method OnDropdownSelect

src/group_gui.cpp:1033–1083  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1031 }
1032
1033 void OnDropdownSelect(WidgetID widget, int index, int) override
1034 {
1035 switch (widget) {
1036 case WID_GL_GROUP_BY_DROPDOWN:
1037 this->UpdateVehicleGroupBy(static_cast<GroupBy>(index));
1038 break;
1039
1040 case WID_GL_SORT_BY_DROPDOWN:
1041 this->vehgroups.SetSortType(index);
1042 break;
1043
1044 case WID_GL_FILTER_BY_CARGO: // Select a cargo filter criteria
1045 this->SetCargoFilter(index);
1046 break;
1047
1048 case WID_GL_MANAGE_VEHICLES_DROPDOWN:
1049 assert(!this->vehicles.empty());
1050
1051 switch (index) {
1052 case ADI_REPLACE: // Replace window
1053 ShowReplaceGroupVehicleWindow(this->vli.ToGroupID(), this->vli.vtype);
1054 break;
1055 case ADI_SERVICE: // Send for servicing
1056 case ADI_DEPOT: { // Send to Depots
1057 Command<CMD_SEND_VEHICLE_TO_DEPOT>::Post(GetCmdSendToDepotMsg(this->vli.vtype), VehicleID::Invalid(), (index == ADI_SERVICE ? DepotCommandFlag::Service : DepotCommandFlags{}) | DepotCommandFlag::MassSend, this->vli);
1058 break;
1059 }
1060
1061 case ADI_CREATE_GROUP: // Create group
1062 Command<CMD_ADD_VEHICLE_GROUP>::Post(CcAddVehicleNewGroup, NEW_GROUP, VehicleID::Invalid(), false, this->vli);
1063 break;
1064
1065 case ADI_ADD_SHARED: // Add shared Vehicles
1066 assert(Group::IsValidID(this->vli.ToGroupID()));
1067
1068 Command<CMD_ADD_SHARED_VEHICLE_GROUP>::Post(STR_ERROR_GROUP_CAN_T_ADD_SHARED_VEHICLE, this->vli.ToGroupID(), this->vli.vtype);
1069 break;
1070 case ADI_REMOVE_ALL: // Remove all Vehicles from the selected group
1071 assert(Group::IsValidID(this->vli.ToGroupID()));
1072
1073 Command<CMD_REMOVE_ALL_VEHICLES_GROUP>::Post(STR_ERROR_GROUP_CAN_T_REMOVE_ALL_VEHICLES, this->vli.ToGroupID());
1074 break;
1075 default: NOT_REACHED();
1076 }
1077 break;
1078
1079 default: NOT_REACHED();
1080 }
1081
1082 this->SetDirty();
1083 }
1084
1085 void OnGameTick() override
1086 {

Callers

nothing calls this directly

Calls 10

GetCmdSendToDepotMsgFunction · 0.85
InvalidFunction · 0.85
NOT_REACHEDFunction · 0.85
UpdateVehicleGroupByMethod · 0.80
SetSortTypeMethod · 0.80
SetCargoFilterMethod · 0.80
ToGroupIDMethod · 0.80
emptyMethod · 0.45
SetDirtyMethod · 0.45

Tested by

no test coverage detected