示例#1
0
 @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());
   }
 }
示例#2
0
 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;
 }
示例#3
0
 @Override
 void activate() {
   super.activate();
   boolean fromSplash = checkForSplashScreen();
   screen.buildViews();
   screen.clearActions();
   screen.setVisible(true);
   getScreenDirector().addActor(screen);
   if (fromSplash) screen.revealAnimation();
   screen.startShowAnimation();
 }
示例#4
0
 @Override
 public void hideDialogue() {
   if (!showingDialogue) return;
   screen.addActor(
       ((CommonView) getScreenDirector().findActor(MenuScreen.COMMON_VIEW)).hideDialogue());
   showingDialogue = false;
 }
示例#5
0
 @Override
 protected void init() {
   super.init();
   screen.setVisible(false);
   getScreenDirector().addActor(screen);
   getOSinterface().setMultiplayerControllerAndAttemptToConnect(multiplayerController);
 }
示例#6
0
 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;
 }
示例#7
0
 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);
   }
 }
示例#8
0
 @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;
 }
示例#9
0
 @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;
 }
示例#10
0
 @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);
 }
示例#11
0
 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;
 }
示例#12
0
  @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();
  }
示例#13
0
 @Override
 protected void disposeController() {
   super.disposeController();
   screen.dispose();
 }
示例#14
0
 private void goTo(String view, float stageX, float stageY) {
   if (!screen.isOnTop(view, true)) screen.show(view, stageX, stageY);
   else screen.goBack(stageX, stageY);
 }
示例#15
0
 @Override
 public void updateSettingsView(SettingsModel settingsModel) {
   screen.updateSettings(settingsModel);
 }
示例#16
0
 @Override
 public void hideNewGameView() {
   screen.removeView(MenuScreen.NEW_GAME_VIEW, -1, -1);
 }
示例#17
0
 private void onLogoutClicked(float stageX, float stageY) {
   multiplayerController.onLogoutClicked();
   screen.removeView(MenuScreen.NEW_GAME_VIEW, stageX, stageY);
   screen.removePlayerImage();
 }
示例#18
0
 private void onStartButtonClicked(float stageX, float stageY) {
   if (!getAndValidateRoomConfig()) return;
   getScreenDirector().setLocal().setGameParams(roomConfig);
   screen.removeView(MenuScreen.NEW_GAME_VIEW, -1, -1);
   getScreenDirector().goToGame();
 }