Skip to content

Commit

Permalink
auto trim hostname and port when joining host (#2286)
Browse files Browse the repository at this point in the history
  • Loading branch information
mercury233 authored Apr 24, 2020
1 parent c49cf7a commit f1969f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gframe/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ class Game {
return focus && focus->hasType(type);
}

void TrimText(irr::gui::IGUIElement* editbox) const {
irr::core::stringw text(editbox->getText());
text.trim();
editbox->setText(text.c_str());
}

void OnResize();
recti Resize(s32 x, s32 y, s32 x2, s32 y2);
recti Resize(s32 x, s32 y, s32 x2, s32 y2, s32 dx, s32 dy, s32 dx2, s32 dy2);
Expand Down
2 changes: 2 additions & 0 deletions gframe/menu_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
}
case BUTTON_JOIN_HOST: {
bot_mode = false;
mainGame->TrimText(mainGame->ebJoinHost);
mainGame->TrimText(mainGame->ebJoinPort);
char ip[20];
const wchar_t* pstr = mainGame->ebJoinHost->getText();
BufferIO::CopyWStr(pstr, ip, 16);
Expand Down

0 comments on commit f1969f7

Please sign in to comment.