FIX: improved the validation from localstorage for username and characterLayers
This commit is contained in:
parent
575c1a9f23
commit
8e467f3e10
8 changed files with 84 additions and 9 deletions
|
@ -4,6 +4,7 @@ import {TextInput} from "../Components/TextInput";
|
|||
import Image = Phaser.GameObjects.Image;
|
||||
import {SelectCharacterSceneName} from "./SelectCharacterScene";
|
||||
import {ResizableScene} from "./ResizableScene";
|
||||
import {isUserNameValid, maxUserNameLength} from "../../Connexion/LocalUser";
|
||||
|
||||
//todo: put this constants in a dedicated file
|
||||
export const LoginSceneName = "LoginScene";
|
||||
|
@ -37,7 +38,7 @@ export class LoginScene extends ResizableScene {
|
|||
create() {
|
||||
|
||||
this.textField = new TextField(this, this.game.renderer.width / 2, 50, 'Enter your name:');
|
||||
this.nameInput = new TextInput(this, this.game.renderer.width / 2, 70, 8, this.name,(text: string) => {
|
||||
this.nameInput = new TextInput(this, this.game.renderer.width / 2, 70, maxUserNameLength, this.name,(text: string) => {
|
||||
this.name = text;
|
||||
});
|
||||
|
||||
|
@ -50,10 +51,9 @@ export class LoginScene extends ResizableScene {
|
|||
this.infoTextField = new TextField(this, 10, this.game.renderer.height - 35, infoText, false);
|
||||
|
||||
this.input.keyboard.on('keyup-ENTER', () => {
|
||||
if (this.name === '') {
|
||||
return
|
||||
if (isUserNameValid(this.name)) {
|
||||
this.login(this.name);
|
||||
}
|
||||
this.login(this.name);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue