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

Method OnQueryTextFinished

src/settings_gui.cpp:1372–1395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1370 }
1371
1372 void OnQueryTextFinished(std::optional<std::string> str) override
1373 {
1374 /* The user pressed cancel */
1375 if (!str.has_value()) return;
1376
1377 assert(this->valuewindow_entry != nullptr);
1378 const IntSettingDesc *sd = this->valuewindow_entry->setting;
1379
1380 int32_t value;
1381 if (!str->empty()) {
1382 auto llvalue = ParseInteger<int64_t>(*str, 10, true);
1383 if (!llvalue.has_value()) return;
1384
1385 /* Save the correct currency-translated value */
1386 if (sd->flags.Test(SettingFlag::GuiCurrency)) llvalue = *llvalue / GetCurrency().rate;
1387
1388 value = ClampTo<int32_t>(*llvalue);
1389 } else {
1390 value = sd->GetDefaultValue();
1391 }
1392
1393 SetSettingValue(this->valuewindow_entry->setting, value);
1394 this->SetDirty();
1395 }
1396
1397 void OnMouseLoop() override
1398 {

Callers

nothing calls this directly

Calls 5

SetSettingValueFunction · 0.85
TestMethod · 0.80
GetDefaultValueMethod · 0.80
emptyMethod · 0.45
SetDirtyMethod · 0.45

Tested by

no test coverage detected