MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / onTextInput

Method onTextInput

src/openrct2-ui/windows/Map.cpp:503–536  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

501 }
502
503 void onTextInput(WidgetIndex widgetIndex, std::string_view text) override
504 {
505 if (text.empty())
506 return;
507
508 switch (widgetIndex)
509 {
510 case WIDX_MAP_SIZE_SPINNER_Y:
511 case WIDX_MAP_SIZE_SPINNER_X:
512 {
513 char* end;
514 std::string textStr = std::string(text);
515 int32_t size = strtol(textStr.c_str(), &end, 10);
516 if (*end == '\0')
517 {
518 // The practical size is 2 lower than the technical size
519 size += 2;
520 size = std::clamp(
521 size, static_cast<int>(kMinimumMapSizeTechnical), static_cast<int>(kMaximumMapSizeTechnical));
522
523 TileCoordsXY newMapSize = getGameState().mapSize;
524 if (_resizeDirection != ResizeDirection::X)
525 newMapSize.y = size;
526 if (_resizeDirection != ResizeDirection::Y)
527 newMapSize.x = size;
528
529 auto mapChangeSizeAction = GameActions::MapChangeSizeAction(newMapSize);
530 GameActions::Execute(&mapChangeSizeAction, getGameState());
531 invalidate();
532 }
533 break;
534 }
535 }
536 }
537
538 ScreenSize onScrollGetSize(int32_t scrollIndex) override
539 {

Callers 2

WindowUpdateTextboxFunction · 0.45
ExecuteCallbackMethod · 0.45

Calls 4

MapChangeSizeActionClass · 0.85
ExecuteFunction · 0.50
invalidateFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected