diff --git a/src/client/gui/screens/UsernameScreen.cpp b/src/client/gui/screens/UsernameScreen.cpp index c1455d9..ddf84c5 100644 --- a/src/client/gui/screens/UsernameScreen.cpp +++ b/src/client/gui/screens/UsernameScreen.cpp @@ -33,15 +33,16 @@ void UsernameScreen::setupPositions() int cx = width / 2; int cy = height / 2; - _btnDone.width = 120; - _btnDone.height = 20; + // Make the done button match the touch-style option tabs + _btnDone.width = 66; + _btnDone.height = 26; _btnDone.x = (width - _btnDone.width) / 2; _btnDone.y = height / 2 + 52; - tUsername.x = _btnDone.x; - tUsername.y = _btnDone.y - 60; tUsername.width = 120; tUsername.height = 20; + tUsername.x = (width - tUsername.width) / 2; + tUsername.y = _btnDone.y - 60; } void UsernameScreen::tick() @@ -58,14 +59,20 @@ void UsernameScreen::keyPressed(int eventKey) } // deliberately do NOT call super::keyPressed — that would close the screen on Escape - _btnDone.active = !tUsername.text.empty(); - Screen::keyPressed(eventKey); + + // enable the Done button only when there is some text (and ensure it updates after backspace) + _btnDone.active = !tUsername.text.empty(); } void UsernameScreen::keyboardNewChar(char inputChar) { - for (auto* tb : textBoxes) tb->handleChar(inputChar); + // limit username length to 12 characters + if (tUsername.text.size() < 12) { + for (auto* tb : textBoxes) tb->handleChar(inputChar); + } + + _btnDone.active = !tUsername.text.empty(); } void UsernameScreen::mouseClicked(int x, int y, int button) diff --git a/src/client/gui/screens/UsernameScreen.h b/src/client/gui/screens/UsernameScreen.h index 3f94f54..04b1a1b 100644 --- a/src/client/gui/screens/UsernameScreen.h +++ b/src/client/gui/screens/UsernameScreen.h @@ -30,7 +30,7 @@ protected: virtual void buttonClicked(Button* button); private: - Button _btnDone; + Touch::TButton _btnDone; TextBox tUsername; std::string _input; int _cursorBlink;