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

Method onTextInput

src/openrct2-ui/windows/Themes.cpp:605–639  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

603 }
604
605 void onTextInput(WidgetIndex widgetIndex, std::string_view text) override
606 {
607 if (text.empty())
608 return;
609
610 switch (widgetIndex)
611 {
612 case WIDX_THEMES_DUPLICATE_BUTTON:
613 case WIDX_THEMES_RENAME_BUTTON:
614 if (Platform::IsFilenameValid(text))
615 {
616 if (ThemeGetIndexForName(std::string(text).c_str()) == SIZE_MAX)
617 {
618 if (widgetIndex == WIDX_THEMES_DUPLICATE_BUTTON)
619 {
620 ThemeDuplicate(std::string(text).c_str());
621 }
622 else
623 {
624 ThemeRename(std::string(text).c_str());
625 }
626 invalidate();
627 }
628 else
629 {
630 ContextShowError(STR_THEMES_ERR_NAME_ALREADY_EXISTS, kStringIdNone, {});
631 }
632 }
633 else
634 {
635 ContextShowError(STR_ERROR_INVALID_CHARACTERS, kStringIdNone, {});
636 }
637 break;
638 }
639 }
640
641 ScreenSize onScrollGetSize(int32_t scrollIndex) override
642 {

Callers

nothing calls this directly

Calls 7

IsFilenameValidFunction · 0.85
ThemeGetIndexForNameFunction · 0.85
ThemeDuplicateFunction · 0.85
ThemeRenameFunction · 0.85
ContextShowErrorFunction · 0.85
invalidateFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected