Esempio n. 1
0
  void update() {
    avatarLabel.setEnabled(mayEdit);
    avatarLabel.setIcon(
        FSkin.getAvatars().get(Integer.valueOf(type == LobbySlotType.OPEN ? -1 : avatarIndex)));
    avatarLabel.repaintSelf();

    txtPlayerName.setEnabled(mayEdit);
    txtPlayerName.setText(type == LobbySlotType.OPEN ? StringUtils.EMPTY : playerName);
    nameRandomiser.setEnabled(mayEdit);
    deckLabel.setVisible(mayEdit);
    deckBtn.setVisible(mayEdit);
    chkReady.setVisible(type == LobbySlotType.LOCAL || type == LobbySlotType.REMOTE);
    chkReady.setEnabled(mayEdit);

    closeBtn.setVisible(mayRemove);

    if (mayRemove) {
      radioHuman.setEnabled(mayControl);
      radioAi.setEnabled(mayControl);
      radioOpen.setEnabled(mayControl);
    } else {
      radioHuman.setVisible(mayControl);
      radioAi.setVisible(mayControl);
      radioOpen.setVisible(mayControl);
    }

    radioHuman.setSelected(type == LobbySlotType.LOCAL);
    radioAi.setSelected(type == LobbySlotType.AI);
    radioOpen.setSelected(type == LobbySlotType.OPEN);

    updateVariantControlsVisibility();
  }
Esempio n. 2
0
  @Override
  protected void doLayout(float width, float height) {
    float x = PADDING;
    float y = PADDING;
    float fieldHeight = txtPlayerName.getHeight();
    float avatarSize = 2 * fieldHeight + PADDING;
    float dy = fieldHeight + PADDING;

    avatarLabel.setBounds(x, y, avatarSize, avatarSize);
    x += avatarSize + PADDING;
    float w = width - x - fieldHeight - 2 * PADDING;
    txtPlayerName.setBounds(x, y, w, fieldHeight);
    x += w + PADDING;
    nameRandomiser.setBounds(x, y, fieldHeight, fieldHeight);

    y += dy;
    humanAiSwitch.setSize(humanAiSwitch.getAutoSizeWidth(fieldHeight), fieldHeight);
    x = width - humanAiSwitch.getWidth() - PADDING;
    humanAiSwitch.setPosition(x, y);
    w = x - avatarSize - 3 * PADDING;
    x = avatarSize + 2 * PADDING;
    if (cbArchenemyTeam.isVisible()) {
      cbArchenemyTeam.setBounds(x, y, w, fieldHeight);
    } else {
      cbTeam.setBounds(x, y, w, fieldHeight);
    }

    y += dy;
    x = PADDING;
    w = width - 2 * PADDING;
    if (btnCommanderDeck.isVisible()) {
      btnCommanderDeck.setBounds(x, y, w, fieldHeight);
      y += dy;
    } else if (btnTinyLeadersDeck.isVisible()) {
      btnTinyLeadersDeck.setBounds(x, y, w, fieldHeight);
      y += dy;
    } else if (btnDeck.isVisible()) {
      btnDeck.setBounds(x, y, w, fieldHeight);
      y += dy;
    }
    if (btnSchemeDeck.isVisible()) {
      btnSchemeDeck.setBounds(x, y, w, fieldHeight);
      y += dy;
    }
    if (btnPlanarDeck.isVisible()) {
      btnPlanarDeck.setBounds(x, y, w, fieldHeight);
      y += dy;
    }
    if (btnVanguardAvatar.isVisible()) {
      btnVanguardAvatar.setBounds(x, y, w, fieldHeight);
    }
  }
Esempio n. 3
0
  private void createNameEditor() {
    String name;
    if (index == 0) {
      name = FModel.getPreferences().getPref(FPref.PLAYER_NAME);
      if (name.isEmpty()) {
        name = "Human";
      }
    } else {
      name = NameGenerator.getRandomName("Any", "Any", screen.getPlayerNames());
    }

    txtPlayerName.setText(name);
    txtPlayerName.setFont(LABEL_FONT);
    txtPlayerName.setChangedHandler(nameChangedHandler);
  }
Esempio n. 4
0
 @Override
 public void focusLost(final FocusEvent e) {
   final Object source = e.getSource();
   if (source instanceof FTextField) { // the text box
     final FTextField nField = (FTextField) source;
     final String newName = nField.getText().trim();
     if (index == 0
         && !StringUtils.isBlank(newName)
         && StringUtils.isAlphanumericSpace(newName)
         && prefs.getPref(FPref.PLAYER_NAME) != newName) {
       prefs.setPref(FPref.PLAYER_NAME, newName);
       prefs.save();
     }
     lobby.firePlayerChangeListener(index);
   }
 }
Esempio n. 5
0
  /**
   * @param index
   * @return
   */
  private void createNameEditor() {
    String name;
    if (index == 0) {
      name = FModel.getPreferences().getPref(FPref.PLAYER_NAME);
      if (name.isEmpty()) {
        name = "Human";
      }
    } else {
      name = NameGenerator.getRandomName("Any", "Any", lobby.getPlayerNames());
    }

    txtPlayerName.setText(name);
    txtPlayerName.setFocusable(true);
    txtPlayerName.setFont(FSkin.getFont(14));
    txtPlayerName.addActionListener(lobby.nameListener);
    txtPlayerName.addFocusListener(nameFocusListener);
  }
Esempio n. 6
0
 @Override
 public void handleEvent(FEvent e) {
   final Object source = e.getSource();
   if (source instanceof FTextField) { // the text box
     FTextField nField = (FTextField) source;
     String newName = nField.getText().trim();
     if (index == 0
         && !StringUtils.isBlank(newName)
         && StringUtils.isAlphanumericSpace(newName)
         && prefs.getPref(FPref.PLAYER_NAME) != newName) {
       prefs.setPref(FPref.PLAYER_NAME, newName);
       prefs.save();
       if (allowNetworking) {
         screen.firePlayerChangeListener(index);
       }
     }
   }
 }
Esempio n. 7
0
  public void setMayEdit(boolean mayEdit0) {
    if (mayEdit == mayEdit0) {
      return;
    }
    mayEdit = mayEdit0;
    avatarLabel.setEnabled(mayEdit);
    txtPlayerName.setEnabled(mayEdit);
    nameRandomiser.setEnabled(mayEdit);
    humanAiSwitch.setEnabled(mayEdit);
    updateVariantControlsVisibility();

    // if panel has height already, ensure height updated to account for button visibility changes
    if (getHeight() > 0) {
      screen.getPlayersScroll().revalidate();
    }
  }
Esempio n. 8
0
 public float getPreferredHeight() {
   int rows = 3;
   if (!btnDeck.isVisible()) {
     rows--;
   }
   if (btnCommanderDeck.isVisible() || btnTinyLeadersDeck.isVisible()) {
     rows++;
   }
   if (btnSchemeDeck.isVisible()) {
     rows++;
   }
   if (btnPlanarDeck.isVisible()) {
     rows++;
   }
   if (btnVanguardAvatar.isVisible()) {
     rows++;
   }
   return rows * (txtPlayerName.getHeight() + PADDING) + PADDING;
 }
Esempio n. 9
0
 public void setPlayerName(final String string) {
   playerName = string;
   txtPlayerName.setText(string);
 }
Esempio n. 10
0
 String getPlayerName() {
   return txtPlayerName.getText();
 }
Esempio n. 11
0
 public void setPlayerName(String string) {
   txtPlayerName.setText(string);
 }