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

Method OnQueryTextFinished

src/order_gui.cpp:1322–1345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1320 }
1321
1322 void OnQueryTextFinished(std::optional<std::string> str) override
1323 {
1324 if (!str.has_value() || str->empty()) return;
1325
1326 VehicleOrderID sel = this->OrderGetSel();
1327 auto value = ParseInteger(*str, 10, true);
1328 if (!value.has_value()) return;
1329
1330 switch (this->vehicle->GetOrder(sel)->GetConditionVariable()) {
1331 case OrderConditionVariable::MaxSpeed:
1332 value = ConvertDisplaySpeedToSpeed(*value, this->vehicle->type);
1333 break;
1334
1335 case OrderConditionVariable::Reliability:
1336 case OrderConditionVariable::MaxReliability:
1337 case OrderConditionVariable::LoadPercentage:
1338 value = Clamp(*value, 0, 100);
1339 break;
1340
1341 default:
1342 break;
1343 }
1344 Command<CMD_MODIFY_ORDER>::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, sel, MOF_COND_VALUE, Clamp(*value, 0, 2047));
1345 }
1346
1347 void OnDropdownSelect(WidgetID widget, int index, int) override
1348 {

Callers

nothing calls this directly

Calls 7

OrderGetSelMethod · 0.95
ParseIntegerFunction · 0.85
ClampFunction · 0.85
GetConditionVariableMethod · 0.80
GetOrderMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected