Esempio n. 1
0
  private void changeMenu(int i) {
    Menu m = nxtMenu[currMenu.ordinal()][i];
    if (m != Menu.NONE) {
      this.currMenu = m;
      subMenuVisible = false;
      // Animate boxes
      for (int n = 0; n < NUM_BOXES; n++) {
        boxs[n]
            .setPos(boxStartPos)
            .setText(txt[currMenu.ordinal()][n]); // .setSize(boxStartSize[1]);
      }
    } else {
      // TODO: put in special cases for things like 'quit' and options(sound, language etc.) here
      switch (currMenu) {
        case NONE:
        case MAIN:
          // When click on find opponent
          currSubMenu = currMenu;
          submenuSelected(0);
          break;
        case NEW_GAME:
          switch (i) {
            case 1:
              game.gameType = Game.SINGLE_PLY;
              game.startNewGame();
              break;
            case 2:
              game.gameType = Game.LOCAL_MULTI;
              game.startNewGame();
              break;
          }
          break;
        case FIND_OPPONENT:
          switch (i) {
          }
          break;
        case OPTIONS:
          changeSubmenu(Menu.GENERAL.ordinal(), i);

          break;
        case CHECK:
          switch (i) {
            case 1:
              System.exit(0);
              break;
          }
          break;
      }
    }

    SoundManager.MENUCLICK.play();
  }
Esempio n. 2
0
  private void handleSubMenuClick(int i) {
    if (i == 0) {
      // back button
      centralBox.setFinalPos(new Vector2D(boxs[0].getPos().x, boxs[0].getPos().y + Box.size));
      centralBox.setFinalSize(Box.size, Box.size);
      centralBox.setImageVisible(true);
      // No longer draw submenu
      drawSubmenuScreen = -1;

      setTextBoxesVisible(false);

      // Special text cases i.e. depending on logged in/out
      // TODO: set up arrays for altTxt in different languages
      if (currSubMenu == Menu.CONNECTIVITY && DBClient.loggedIn) {
        subBoxs[0].setText("Sign out");
      }

      // If going back from find opponent screen then remove player from waiting table
      if (currSubMenu == Menu.MAIN) {
        DBClient.removeFromWaitingTable();
      }
    } else {
      switch (currMenu) {
        case MAIN:
          // Find opponent 'play' button pressed
          DBClient.createNewGame();
          game.gameType = Game.ONLINE_MULTI;
          game.rPlayerTurn = true;
          game.startNewGame();
          break;
        case OPTIONS:
          switch (currSubMenu) {
            case GENERAL:
              switch (drawSubmenuScreen) {
                  // Sound
                case 0:
                  switch (i) {
                    case 1:
                      subMenuBoxs[1].invertChecked();
                      subMenuBoxs[2].invertChecked();
                      game.sound = true;
                      SoundManager.unmute();
                      break;
                    case 2:
                      subMenuBoxs[1].invertChecked();
                      subMenuBoxs[2].invertChecked();
                      game.sound = false;
                      SoundManager.mute();
                      break;
                  }
                  break;
                  // Language
                case 1:
                  switch (i) {
                    case 1:
                      txt = english;
                      break;
                    case 2:
                      txt = french;
                      break;
                  }

                  changeLanguage();
                  break;
                  // Animation
                case 2:
                  switch (i) {
                    case 1:
                      subMenuBoxs[1].invertChecked();
                      subMenuBoxs[2].invertChecked();
                      game.animation = true;
                      break;
                    case 2:
                      subMenuBoxs[1].invertChecked();
                      subMenuBoxs[2].invertChecked();
                      game.animation = false;
                  }
                  break;
              }

              break;
            case CONNECTIVITY:
              switch (drawSubmenuScreen) {
                  // Login
                case 0:
                  // TODO: encrpyt pass in db
                  switch (i) {
                      // Checkbox
                    case 1:
                      subMenuBoxs[1].invertChecked();
                      break;
                    case 2:
                      if (subMenuBoxs[1].isChecked()) {
                        if (DBClient.newUser(textFields[0].getText(), textFields[1].getText()))
                          handleSubMenuClick(0);
                      } else {
                        if (DBClient.tryLogin(textFields[0].getText(), textFields[1].getText()))
                          handleSubMenuClick(0);
                      }
                      break;
                  }
                  break;
              }
              break;
          }
          break;
      }
    }
  }