diff --git a/src/openrct2-ui/interface/Window.cpp b/src/openrct2-ui/interface/Window.cpp index 2dea9a6331..bef13339fa 100644 --- a/src/openrct2-ui/interface/Window.cpp +++ b/src/openrct2-ui/interface/Window.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -867,31 +866,22 @@ namespace OpenRCT2::Ui::Windows return window.classification; } - void WindowStartTextbox( - WindowBase& call_w, WidgetIndex call_widget, StringId existing_text, const char* existing_args, int32_t maxLength) + void WindowStartTextbox(const WindowBase& callW, WidgetIndex callWidget, u8string existingText, int32_t maxLength) { if (_usingWidgetTextBox) WindowCancelTextbox(); _usingWidgetTextBox = true; - _currentTextBox.window.classification = call_w.classification; - _currentTextBox.window.number = call_w.number; - _currentTextBox.widget_index = call_widget; + _currentTextBox.window.classification = callW.classification; + _currentTextBox.window.number = callW.number; + _currentTextBox.widget_index = callWidget; _textBoxFrameNo = 0; WindowCloseByClass(WindowClass::Textinput); - // Clear the text input buffer - _textBoxInput.clear(); - // Enter in the text input buffer any existing // text. - if (existing_text != STR_NONE) - { - char tempBuf[TEXT_INPUT_SIZE]{}; - size_t len = FormatStringLegacy(tempBuf, TEXT_INPUT_SIZE, existing_text, &existing_args); - _textBoxInput.assign(tempBuf, len); - } + _textBoxInput = existingText; _textInput = ContextStartTextInput(_textBoxInput, maxLength); } diff --git a/src/openrct2-ui/interface/Window.h b/src/openrct2-ui/interface/Window.h index eae16723f2..b107f167e4 100644 --- a/src/openrct2-ui/interface/Window.h +++ b/src/openrct2-ui/interface/Window.h @@ -76,8 +76,7 @@ namespace OpenRCT2::Ui::Windows WindowBase* WindowGetListening(); WindowClass WindowGetClassification(const WindowBase& window); - void WindowStartTextbox( - WindowBase& call_w, WidgetIndex call_widget, StringId existing_text, const char* existing_args, int32_t maxLength); + void WindowStartTextbox(const WindowBase& callW, WidgetIndex callWidget, u8string existingText, int32_t maxLength); void WindowCancelTextbox(); void WindowUpdateTextboxCaret(); void WindowUpdateTextbox(); diff --git a/src/openrct2-ui/scripting/CustomWindow.cpp b/src/openrct2-ui/scripting/CustomWindow.cpp index ba513ce796..e0b8589bad 100644 --- a/src/openrct2-ui/scripting/CustomWindow.cpp +++ b/src/openrct2-ui/scripting/CustomWindow.cpp @@ -653,8 +653,7 @@ namespace OpenRCT2::Ui::Windows } else if (widgetDesc->Type == "textbox") { - auto* text = const_cast(widgetDesc->Text.c_str()); - WindowStartTextbox(*this, widgetIndex, STR_STRING, text, widgetDesc->MaxLength + 1); + WindowStartTextbox(*this, widgetIndex, widgetDesc->Text, widgetDesc->MaxLength + 1); } } } diff --git a/src/openrct2-ui/windows/EditorObjectSelection.cpp b/src/openrct2-ui/windows/EditorObjectSelection.cpp index a65dd08c4f..7110640fdc 100644 --- a/src/openrct2-ui/windows/EditorObjectSelection.cpp +++ b/src/openrct2-ui/windows/EditorObjectSelection.cpp @@ -422,7 +422,7 @@ static std::vector _window_editor_object_selection_widgets = { break; } case WIDX_FILTER_TEXT_BOX: - WindowStartTextbox(*this, widgetIndex, STR_STRING, _filter_string, sizeof(_filter_string)); + WindowStartTextbox(*this, widgetIndex, _filter_string, sizeof(_filter_string)); break; case WIDX_FILTER_CLEAR_BUTTON: std::fill_n(_filter_string, sizeof(_filter_string), 0x00); diff --git a/src/openrct2-ui/windows/NewRide.cpp b/src/openrct2-ui/windows/NewRide.cpp index c6b4b4c3ae..ca64284f5e 100644 --- a/src/openrct2-ui/windows/NewRide.cpp +++ b/src/openrct2-ui/windows/NewRide.cpp @@ -370,7 +370,7 @@ static Widget window_new_ride_widgets[] = { SetPage(_currentTab); break; case WIDX_FILTER_TEXT_BOX: - WindowStartTextbox(*this, widgetIndex, STR_STRING, _filter.data(), kTextInputSize); + WindowStartTextbox(*this, widgetIndex, _filter, kTextInputSize); break; case WIDX_FILTER_CLEAR_BUTTON: _filter.clear(); diff --git a/src/openrct2-ui/windows/Scenery.cpp b/src/openrct2-ui/windows/Scenery.cpp index 3dce046fcd..327573e92a 100644 --- a/src/openrct2-ui/windows/Scenery.cpp +++ b/src/openrct2-ui/windows/Scenery.cpp @@ -276,7 +276,7 @@ static Widget WindowSceneryBaseWidgets[] = { Invalidate(); break; case WIDX_FILTER_TEXT_BOX: - WindowStartTextbox(*this, widgetIndex, STR_STRING, _filteredSceneryTab.Filter.data(), kTextInputSize); + WindowStartTextbox(*this, widgetIndex, _filteredSceneryTab.Filter, kTextInputSize); break; case WIDX_FILTER_CLEAR_BUTTON: _tabEntries[_activeTabIndex].Filter.clear(); diff --git a/src/openrct2-ui/windows/ServerList.cpp b/src/openrct2-ui/windows/ServerList.cpp index 4c22b62fee..840fc3642a 100644 --- a/src/openrct2-ui/windows/ServerList.cpp +++ b/src/openrct2-ui/windows/ServerList.cpp @@ -131,7 +131,7 @@ static Widget _serverListWidgets[] = { Close(); break; case WIDX_PLAYER_NAME_INPUT: - WindowStartTextbox(*this, widgetIndex, STR_STRING, _playerName.c_str(), MaxPlayerNameLength); + WindowStartTextbox(*this, widgetIndex, _playerName, MaxPlayerNameLength); break; case WIDX_LIST: { diff --git a/src/openrct2-ui/windows/ServerStart.cpp b/src/openrct2-ui/windows/ServerStart.cpp index 3e45c9188c..fcad422072 100644 --- a/src/openrct2-ui/windows/ServerStart.cpp +++ b/src/openrct2-ui/windows/ServerStart.cpp @@ -95,19 +95,19 @@ static Widget _windowServerStartWidgets[] = { Close(); break; case WIDX_PORT_INPUT: - WindowStartTextbox(*this, widgetIndex, STR_STRING, _port, 6); + WindowStartTextbox(*this, widgetIndex, _port, 6); break; case WIDX_NAME_INPUT: - WindowStartTextbox(*this, widgetIndex, STR_STRING, _name, 64); + WindowStartTextbox(*this, widgetIndex, _name, 64); break; case WIDX_DESCRIPTION_INPUT: - WindowStartTextbox(*this, widgetIndex, STR_STRING, _description, MAX_SERVER_DESCRIPTION_LENGTH); + WindowStartTextbox(*this, widgetIndex, _description, MAX_SERVER_DESCRIPTION_LENGTH); break; case WIDX_GREETING_INPUT: - WindowStartTextbox(*this, widgetIndex, STR_STRING, _greeting, kChatInputSize); + WindowStartTextbox(*this, widgetIndex, _greeting, kChatInputSize); break; case WIDX_PASSWORD_INPUT: - WindowStartTextbox(*this, widgetIndex, STR_STRING, _password, 32); + WindowStartTextbox(*this, widgetIndex, _password, 32); break; case WIDX_MAXPLAYERS_INCREASE: if (gConfigNetwork.Maxplayers < 255) diff --git a/src/openrct2-ui/windows/TrackList.cpp b/src/openrct2-ui/windows/TrackList.cpp index 37245176fb..716faca1d6 100644 --- a/src/openrct2-ui/windows/TrackList.cpp +++ b/src/openrct2-ui/windows/TrackList.cpp @@ -297,8 +297,7 @@ static Widget _trackListWidgets[] = { } break; case WIDX_FILTER_STRING: - WindowStartTextbox( - *this, widgetIndex, STR_STRING, _filterString, sizeof(_filterString)); // TODO check this out + WindowStartTextbox(*this, widgetIndex, _filterString, sizeof(_filterString)); // TODO check this out break; case WIDX_FILTER_CLEAR: // Keep the highlighted item selected