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

Method onTextInput

src/openrct2-ui/windows/ServerList.cpp:269–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

267 }
268
269 void onTextInput(WidgetIndex widgetIndex, std::string_view text) override
270 {
271 if (text.empty())
272 return;
273
274 auto temp = u8string{ text };
275
276 switch (widgetIndex)
277 {
278 case WIDX_PLAYER_NAME_INPUT:
279 if (_playerName == text)
280 return;
281
282 _playerName = temp;
283 Config::Get().network.playerName = _playerName;
284 widgets[WIDX_PLAYER_NAME_INPUT].string = const_cast<utf8*>(_playerName.c_str());
285
286 invalidateWidget(WIDX_PLAYER_NAME_INPUT);
287 break;
288
289 case WIDX_ADD_SERVER:
290 {
291 Network::ServerListEntry entry;
292 entry.Address = text;
293 entry.Name = text;
294 entry.Favourite = true;
295 _serverList.Add(entry);
296 _serverList.WriteFavourites();
297 invalidate();
298 break;
299 }
300 }
301 }
302
303 StringWithArgs onTooltip(WidgetIndex widgetIndex, StringId fallback) override
304 {

Callers

nothing calls this directly

Calls 4

WriteFavouritesMethod · 0.80
invalidateFunction · 0.50
emptyMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected