mirror of https://github.com/OpenRCT2/OpenRCT2.git
Simplify setting existing text
This commit is contained in:
parent
3448926251
commit
bd3ae5cbb9
|
@ -25,7 +25,6 @@
|
|||
#include <openrct2/entity/EntityRegistry.h>
|
||||
#include <openrct2/interface/Widget.h>
|
||||
#include <openrct2/localisation/Formatter.h>
|
||||
#include <openrct2/localisation/Formatting.h>
|
||||
#include <openrct2/localisation/StringIds.h>
|
||||
#include <openrct2/sprites.h>
|
||||
#include <openrct2/ui/UiContext.h>
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -653,8 +653,7 @@ namespace OpenRCT2::Ui::Windows
|
|||
}
|
||||
else if (widgetDesc->Type == "textbox")
|
||||
{
|
||||
auto* text = const_cast<char*>(widgetDesc->Text.c_str());
|
||||
WindowStartTextbox(*this, widgetIndex, STR_STRING, text, widgetDesc->MaxLength + 1);
|
||||
WindowStartTextbox(*this, widgetIndex, widgetDesc->Text, widgetDesc->MaxLength + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -422,7 +422,7 @@ static std::vector<Widget> _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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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:
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue