@Override protected void onAssetsLoaded(View view) { screen.addActor(view); addButtonListenersRecursively(view); if (view.getName().compareTo(MenuScreen.MAIN_MENU_VIEW) == 0) { view.setVisible(true); if (getMultiplayer() != null) { screen.enableMultiplayer(true); multiplayerController.onMainMenuAssetsLoaded(); } else screen.enableMultiplayer(false); } else if (view.getName().compareTo(MenuScreen.USER_VIEW) == 0) { view.setVisible(true); initNickNameTextFieldListeners(view); getStatisticsController().addObserver((UserView) view); } else if (view.getName().compareTo(MenuScreen.NEW_GAME_VIEW) == 0) { screen.setRoomConfigFromUI(roomConfig); } else if (view.getName().compareTo(MenuScreen.COINS_VIEW) == 0) { getStatisticsController().addObserver((CoinsView) view); } else if (view.getName().compareTo(MenuScreen.STATISTICS_VIEW) == 0) { getStatisticsController().addObserver((StatisticsView) view); } else if (view.getName().compareTo(MenuScreen.SETTINGS_VIEW) == 0) { ((SettingsView) view) .initialiseLanguageButtons(getAssets().getLocalization().getLanguageKeys()); ((SettingsView) view).setEventListener(this); ((SettingsView) view).updateView(getSettings().getSettingsModel()); } }
private boolean handleBack(float stageX, float stageY) { // if (screen.isOnTop(MenuScreen.SETTINGS_VIEW, true)) getSettings().save(); if (showingDialogue || showingLoadingDialogue) return true; if (screen.isOnTop(MenuScreen.MAIN_MENU_VIEW, true)) return false; screen.goBack(stageX, stageY); return true; }
@Override void activate() { super.activate(); boolean fromSplash = checkForSplashScreen(); screen.buildViews(); screen.clearActions(); screen.setVisible(true); getScreenDirector().addActor(screen); if (fromSplash) screen.revealAnimation(); screen.startShowAnimation(); }
@Override public void hideDialogue() { if (!showingDialogue) return; screen.addActor( ((CommonView) getScreenDirector().findActor(MenuScreen.COMMON_VIEW)).hideDialogue()); showingDialogue = false; }
@Override protected void init() { super.init(); screen.setVisible(false); getScreenDirector().addActor(screen); getOSinterface().setMultiplayerControllerAndAttemptToConnect(multiplayerController); }
private boolean checkForSplashScreen() { View loadingView = getScreenDirector().findActor(LoadingView.LOADING_VIEW); if (loadingView == null) return false; screen.setSplash((MyImage) loadingView.getChildren().get(0)); loadingView.remove(); loadingView.clear(); return true; }
private void onNewGameClicked(float stageX, float stageY) { if (!checkForNickName("local")) return; if (getScreenDirector().setLocal().gameExists()) getScreenDirector().goToGame(); else { goTo(MenuScreen.NEW_GAME_VIEW, stageX, stageY); screen.chooseMode(true); } }
@Override public void showDialogue(String title, String subtitle, boolean hasYesNoButtons) { if (showingDialogue) hideDialogue(); View lv = screen.showDialogue(title, subtitle, hasYesNoButtons); getScreenDirector().addActor(lv); lv.toFront(); showingDialogue = true; }
@Override public void showLoadingDialogue(String text, float clickX, float clickY) { if (showingDialogue) hideLoadingDialogue(); View lv = screen.showLoadingDialogue(text, clickX, clickY); getScreenDirector().addActor(lv); lv.toFront(); showingLoadingDialogue = true; }
@Override public void onOnlineGameClicked(float stageX, float stageY) { if (getMultiplayer() == null) return; // desktop mode if (!checkForNickName("online")) return; if (!multiplayerController.onOnlineGameClicked()) return; goTo(MenuScreen.NEW_GAME_VIEW, stageX, stageY); screen.chooseMode(false); }
private boolean getAndValidateRoomConfig() { screen.setRoomConfigFromUI(roomConfig); if (!getStatisticsController().hasEnoughtCoins(roomConfig.bet)) { showDialogue("Not enough coins", "You can either buy, or play for a smaller bet", false); goTo(MenuScreen.COINS_VIEW, -1, -1); return false; } return true; }
@Override public void onKeyboardHidden() { TextField nameField; if (!splashDone) return; if (screen == null || screen.getStage() == null) return; try { nameField = (TextField) screen.getStage().getKeyboardFocus(); } catch (ClassCastException e) { return; } if (nameField == null || nameField.getName().compareTo(UserView.PLAYER_NAME) != 0) return; Gdx.graphics.setContinuousRendering(Config.IS_CONTINIOUS_RENDERING); getScreenDirector().unfocusAll(); if (nameField.getText().length() == 0 || nameField.getText().compareTo("nickname") == 0) { nameField.setText(getStatisticsController().getStatistics().getName()); pendingButton = null; return; } getStatisticsController().setName(nameField.getText()); onNicknameValidated(); }
@Override protected void disposeController() { super.disposeController(); screen.dispose(); }
private void goTo(String view, float stageX, float stageY) { if (!screen.isOnTop(view, true)) screen.show(view, stageX, stageY); else screen.goBack(stageX, stageY); }
@Override public void updateSettingsView(SettingsModel settingsModel) { screen.updateSettings(settingsModel); }
@Override public void hideNewGameView() { screen.removeView(MenuScreen.NEW_GAME_VIEW, -1, -1); }
private void onLogoutClicked(float stageX, float stageY) { multiplayerController.onLogoutClicked(); screen.removeView(MenuScreen.NEW_GAME_VIEW, stageX, stageY); screen.removePlayerImage(); }
private void onStartButtonClicked(float stageX, float stageY) { if (!getAndValidateRoomConfig()) return; getScreenDirector().setLocal().setGameParams(roomConfig); screen.removeView(MenuScreen.NEW_GAME_VIEW, -1, -1); getScreenDirector().goToGame(); }