@Override
    public void onLoad(OnLoadCallback pOnLoadCallback) throws Exception {
        final Font defaultFont32 = ResourceManager.getInstance().getDefaultFont32();

        // Username
        this.mUserNameLabel = new Text(LoginLayer.PADDING_DEFAULT,
                LoginLayer.PADDING_DEFAULT * 4, defaultFont32, Constants.ORANGE_COLOR_DEFAULT, Constants.USERNAME_LABEL_TEXT);
        this.mUsernameInput = new TextInput(this.mUserNameLabel.getX(), this.mUserNameLabel.getY() + this.mUserNameLabel.getHeight() + LoginLayer.PADDING_DEFAULT,
                this.mEntity.getWidth() - LoginLayer.PADDING_DEFAULT * 2, LoginLayer.TEXTBOX_HEIGHT_DEFAULT,
                Color.BLACK, defaultFont32) {
            @Override
            public void onMouseEvent(final MouseEvent pMouseEvent, final int pMouseAreaLocalX, final int pMouseAreaLocalY) {
                if (pMouseEvent.getID() == MouseEvent.MOUSE_CLICKED) {
                    LoginLayer.this.mUsernameInput.setFocus(true);
                    LoginLayer.this.mPasswordInput.setFocus(false);
                }
            }
        };

        // Password
        this.mPasswordLabel = new Text(this.mUserNameLabel.getX(),
                this.mUsernameInput.getEntity().getY() + this.mUsernameInput.getEntity().getHeight() + LoginLayer.PADDING_DEFAULT * 4,
                defaultFont32, Constants.ORANGE_COLOR_DEFAULT, Constants.PASSWORD_LABEL_TEXT);
        this.mPasswordInput = new PasswordInput(this.mUserNameLabel.getX(), this.mPasswordLabel.getY() + this.mPasswordLabel.getHeight() + LoginLayer.PADDING_DEFAULT,
                this.mEntity.getWidth() - LoginLayer.PADDING_DEFAULT * 2, LoginLayer.TEXTBOX_HEIGHT_DEFAULT,
                Color.BLACK, defaultFont32) {
            @Override
            public void onMouseEvent(final MouseEvent pMouseEvent, final int pMouseAreaLocalX, final int pMouseAreaLocalY) {
                if (pMouseEvent.getID() == MouseEvent.MOUSE_CLICKED) {
                    LoginLayer.this.mPasswordInput.setFocus(true);
                    LoginLayer.this.mUsernameInput.setFocus(false);
                }
            }
        };

        // Button 1P
        this.mButton1P = new ImageButton(0, 0, ResourceManager.getInstance().getButton1PTextureRegion()) {
            @Override
            public void onClick() {
                GameManager.getInstance().setCurrentGameMode(GameMode.OFFLINE);
                GameManager.getInstance().setCurrentPlayer(Player.HUMAN);
                GameManager.getInstance().setMyPiece(Piece.WHITE);
                
                NetworkManager.getInstance().stopListener();
                
                LoginLayer.this.hide();

                ScreenManager.getInstance().getBaseGameActivity().getEngine().registerUpdateHandler(new IUpdateHandler() {
                    @Override
                    public void onUpdate(float pSecondElapsed) {
                        if (!LoginLayer.this.mIsShown) {
                            ScreenManager.getInstance().getBaseGameActivity().getEngine().unregisterUpdateHandler(this);
                            ScreenManager.getInstance().showOfflineScene();
                        }
                    }
                });
            }

            @Override
            public void onKeyEvent(KeyEvent pKeyEvent) {
            }
        };
        this.mButton1P.getEntity().setPosition(-this.mButton1P.getEntity().getWidth(), (this.mEntity.getHeight() - this.mButton1P.getEntity().getHeight()) / 2);

        // Button 2P
        this.mButton2P = new ImageButton(0, 0, ResourceManager.getInstance().getButton2PTextureRegion()) {
            @Override
            public void onClick() {
                GameManager.getInstance().setCurrentGameMode(GameMode.ONLINE);
                LoginLayer.this.hide();
                if (isValidText(mUsernameInput.getText()) && isValidText(mPasswordInput.getText())) {
                    NetworkManager.getInstance().startListener();
                    NetworkUtilities.sendLoginRequest(mUsernameInput.getText(), mPasswordInput.getText());
                    GameManager.getInstance().setFirstPlayerName(mUsernameInput.getText());
                } else {
                    final BaseDialog.IOnButtonClickedEvent event = new BaseDialog.IOnButtonClickedEvent() {
                        @Override
                        public void onButtonClicked() {
                            ScreenManager.getInstance().showLoginLayer();
                        }
                    };
                    if (!isValidText(mUsernameInput.getText())) {
                        ScreenManager.getInstance().showDialog(Constants.DIALOG_USERNAME_INVALID_TEXT, event);
                    } else if (!isValidText(mPasswordInput.getText())) {
                        ScreenManager.getInstance().showDialog(Constants.DIALOG_PASSWORD_INVALID_TEXT, event);
                    }
                }
            }

            @Override
            public void onKeyEvent(KeyEvent pKeyEvent) {
            }
        };
        this.mButton2P.getEntity().setPosition(this.mEntity.getWidth(), (this.mEntity.getHeight() - this.mButton2P.getEntity().getHeight()) / 2);


        // Register
        this.mButtonRegister = new TextButton(0, 0, Constants.BUTTON_REGISTER_TEXT, ResourceManager.getInstance().getOrangeButtonTextureRegion()) {
            @Override
            public void onClick() {
                ScreenManager.getInstance().showRegistryLayer();
            }

            @Override
            public void onKeyEvent(KeyEvent pKeyEvent) {
            }
        };

        this.mButtonRegister.getEntity().setPosition(LoginLayer.PADDING_DEFAULT,
                this.mEntity.getHeight() - this.mButtonRegister.getEntity().getHeight() - LoginLayer.PADDING_DEFAULT);

        // Registry Mouse Area
        this.mMainScene.registryMouseArea(this.mUsernameInput.getEntity());
        this.mMainScene.registryMouseArea(this.mPasswordInput.getEntity());
        this.mMainScene.registryMouseArea(this.mButtonRegister.getEntity());
        this.mMainScene.registryMouseArea(this.mButton1P.getEntity());
        this.mMainScene.registryMouseArea(this.mButton2P.getEntity());

        // Set Position
        this.mEntity.setPosition(Constants.SCREEN_WIDTH + this.mButton1P.getEntity().getWidth(),
                Constants.SCREEN_HEIGHT - this.getEntity().getHeight() - BaseLayer.PADDING_DEFAULT);

        pOnLoadCallback.onLoadFinish();
    }