Limit username to 12 chars and adjusted the Done button to go more with the rest of the games UI.

This commit is contained in:
mschiller890
2026-03-13 08:22:54 +01:00
parent 470509ee52
commit 2e9a9b810c
2 changed files with 15 additions and 8 deletions

View File

@@ -33,15 +33,16 @@ void UsernameScreen::setupPositions()
int cx = width / 2; int cx = width / 2;
int cy = height / 2; int cy = height / 2;
_btnDone.width = 120; // Make the done button match the touch-style option tabs
_btnDone.height = 20; _btnDone.width = 66;
_btnDone.height = 26;
_btnDone.x = (width - _btnDone.width) / 2; _btnDone.x = (width - _btnDone.width) / 2;
_btnDone.y = height / 2 + 52; _btnDone.y = height / 2 + 52;
tUsername.x = _btnDone.x;
tUsername.y = _btnDone.y - 60;
tUsername.width = 120; tUsername.width = 120;
tUsername.height = 20; tUsername.height = 20;
tUsername.x = (width - tUsername.width) / 2;
tUsername.y = _btnDone.y - 60;
} }
void UsernameScreen::tick() 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 // deliberately do NOT call super::keyPressed — that would close the screen on Escape
_btnDone.active = !tUsername.text.empty();
Screen::keyPressed(eventKey); 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) 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) void UsernameScreen::mouseClicked(int x, int y, int button)

View File

@@ -30,7 +30,7 @@ protected:
virtual void buttonClicked(Button* button); virtual void buttonClicked(Button* button);
private: private:
Button _btnDone; Touch::TButton _btnDone;
TextBox tUsername; TextBox tUsername;
std::string _input; std::string _input;
int _cursorBlink; int _cursorBlink;