forked from mirrors/kolyah35-minecraft-pe-0.6.1
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:
parent
470509ee52
commit
2e9a9b810c
2 changed files with 15 additions and 8 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ protected:
|
|||
virtual void buttonClicked(Button* button);
|
||||
|
||||
private:
|
||||
Button _btnDone;
|
||||
Touch::TButton _btnDone;
|
||||
TextBox tUsername;
|
||||
std::string _input;
|
||||
int _cursorBlink;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue