diff --git a/lib/game/components/backbox/displays/initials_input_display.dart b/lib/game/components/backbox/displays/initials_input_display.dart index fd286d62..f4900891 100644 --- a/lib/game/components/backbox/displays/initials_input_display.dart +++ b/lib/game/components/backbox/displays/initials_input_display.dart @@ -59,7 +59,7 @@ class InitialsInputDisplay extends Component with HasGameRef { await add( InitialsLetterPrompt( position: Vector2( - 11.4 + (2.3 * i), + 10.8 + (2.5 * i), -20, ), hasFocus: i == 0, @@ -138,7 +138,7 @@ class _NameLabelTextComponent extends TextComponent _NameLabelTextComponent() : super( anchor: Anchor.center, - position: Vector2(11.4, -24), + position: Vector2(10.8, -24), textRenderer: _bodyTextPaint.copyWith( (style) => style.copyWith( color: PinballColors.red, @@ -158,7 +158,7 @@ class _CharacterIconSpriteComponent extends SpriteComponent with HasGameRef { : _characterIconPath = characterIconPath, super( anchor: Anchor.center, - position: Vector2(8.4, -20), + position: Vector2(7.6, -20), ); final String _characterIconPath; @@ -241,8 +241,9 @@ class InitialsLetterPrompt extends PositionComponent { bool _cycle(bool up) { if (_hasFocus) { - final newCharCode = - min(max(_charIndex + (up ? 1 : -1), 0), _alphabetLength); + var newCharCode = _charIndex + (up ? -1 : 1); + if (newCharCode < 0) newCharCode = _alphabetLength; + if (newCharCode > _alphabetLength) newCharCode = 0; _input.text = String.fromCharCode(_alphabetCode + newCharCode); _charIndex = newCharCode; diff --git a/test/game/components/backbox/displays/initials_input_display_test.dart b/test/game/components/backbox/displays/initials_input_display_test.dart index 993e0678..e2a3c58c 100644 --- a/test/game/components/backbox/displays/initials_input_display_test.dart +++ b/test/game/components/backbox/displays/initials_input_display_test.dart @@ -76,26 +76,26 @@ void main() { ); await game.ensureAdd(initialsInputDisplay); - // Focus is already on the first letter - await tester.sendKeyEvent(LogicalKeyboardKey.arrowUp); + // Focus is on the first letter + await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown); await tester.pump(); - // Move to the next an press up again + // Move to the next an press down again await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight); await tester.pump(); - await tester.sendKeyEvent(LogicalKeyboardKey.arrowUp); + await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown); await tester.pump(); // One more time await tester.sendKeyEvent(LogicalKeyboardKey.arrowRight); await tester.pump(); - await tester.sendKeyEvent(LogicalKeyboardKey.arrowUp); + await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown); await tester.pump(); - // Back to the previous and increase one more + // Back to the previous and press down again await tester.sendKeyEvent(LogicalKeyboardKey.arrowLeft); await tester.pump(); - await tester.sendKeyEvent(LogicalKeyboardKey.arrowUp); + await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown); await tester.pump(); }, verify: (game, tester) async { @@ -136,14 +136,14 @@ void main() { await game.ensureAdd( InitialsLetterPrompt(hasFocus: true, position: Vector2.zero()), ); - await tester.sendKeyEvent(LogicalKeyboardKey.arrowUp); - await tester.pump(); - await tester.sendKeyEvent(LogicalKeyboardKey.arrowUp); + await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown); await tester.pump(); - await tester.sendKeyEvent(LogicalKeyboardKey.arrowUp); + await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown); await tester.pump(); await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown); await tester.pump(); + await tester.sendKeyEvent(LogicalKeyboardKey.arrowUp); + await tester.pump(); }, verify: (game, tester) async { final prompt = game.firstChild();