示例#1
0
  private void updateVariantControlsVisibility() {
    final boolean isTinyLeaders = lobby.hasVariant(GameType.TinyLeaders);
    final boolean isCommanderApplied =
        mayEdit && (lobby.hasVariant(GameType.Commander) || isTinyLeaders);
    final boolean isPlanechaseApplied = mayEdit && lobby.hasVariant(GameType.Planechase);
    final boolean isVanguardApplied = mayEdit && lobby.hasVariant(GameType.Vanguard);
    final boolean isArchenemyApplied = mayEdit && lobby.hasVariant(GameType.Archenemy);
    final boolean archenemyVisiblity =
        mayEdit && lobby.hasVariant(GameType.ArchenemyRumble)
            || (isArchenemyApplied && isArchenemy());
    // Commander deck building replaces normal one, so hide it
    final boolean isDeckBuildingAllowed =
        mayEdit && !isCommanderApplied && !lobby.hasVariant(GameType.MomirBasic);

    deckLabel.setVisible(isDeckBuildingAllowed);
    deckBtn.setVisible(isDeckBuildingAllowed);
    cmdDeckSelectorBtn.setVisible(isCommanderApplied);
    cmdDeckEditor.setText(isTinyLeaders ? "TL Deck Editor" : "Commander Deck Editor");
    cmdDeckEditor.setVisible(isCommanderApplied);
    cmdLabel.setVisible(isCommanderApplied);

    scmDeckSelectorBtn.setVisible(archenemyVisiblity);
    scmDeckEditor.setVisible(archenemyVisiblity);
    scmLabel.setVisible(archenemyVisiblity);

    teamComboBox.setVisible(!isArchenemyApplied);
    aeTeamComboBox.setVisible(isArchenemyApplied);

    pchDeckSelectorBtn.setVisible(isPlanechaseApplied);
    pchDeckEditor.setVisible(isPlanechaseApplied);
    pchLabel.setVisible(isPlanechaseApplied);

    vgdSelectorBtn.setVisible(isVanguardApplied);
    vgdLabel.setVisible(isVanguardApplied);
  }
示例#2
0
  private void populateTeamsComboBoxes() {
    aeTeamComboBox.addItem("Archenemy");
    aeTeamComboBox.addItem("Heroes");

    for (int i = 1; i <= VLobby.MAX_PLAYERS; i++) {
      teamComboBox.addItem(i);
    }
    teamComboBox.setEnabled(true);
  }
示例#3
0
 public void setIsArchenemy(final boolean isArchenemy) {
   aeTeamComboBox.suppressActionListeners();
   aeTeamComboBox.setSelectedIndex(isArchenemy ? 0 : 1);
   aeTeamComboBox.unsuppressActionListeners();
 }
示例#4
0
 public int getArchenemyTeam() {
   return aeTeamComboBox.getSelectedIndex();
 }
示例#5
0
 public void setTeam(final int team) {
   teamComboBox.suppressActionListeners();
   teamComboBox.setSelectedIndex(team);
   teamComboBox.unsuppressActionListeners();
 }
示例#6
0
 public int getTeam() {
   return teamComboBox.getSelectedIndex();
 }
示例#7
0
 public boolean isArchenemy() {
   return aeTeamComboBox.getSelectedIndex() == 0;
 }
示例#8
0
  public PlayerPanel(
      final VLobby lobby,
      final boolean allowNetworking,
      final int index,
      final LobbySlot slot,
      final boolean mayEdit,
      final boolean mayControl) {
    super();

    this.lobby = lobby;
    this.index = index;
    this.mayEdit = mayEdit;
    this.mayControl = mayControl;

    this.deckLabel = lobby.newLabel("Deck:");
    this.scmLabel = lobby.newLabel("Scheme deck:");
    this.cmdLabel = lobby.newLabel("Commander deck:");
    this.pchLabel = lobby.newLabel("Planar deck:");
    this.vgdLabel = lobby.newLabel("Vanguard:");

    setLayout(new MigLayout("insets 10px, gap 5px"));

    // Add a button to players 3+ (or if server) to remove them from the setup
    closeBtn = createCloseButton();
    this.add(closeBtn, "w 20, h 20, pos (container.w-20) 0");

    createAvatar();
    this.add(avatarLabel, "spany 2, width 80px, height 80px");

    createNameEditor();
    this.add(lobby.newLabel("Name:"), "w 40px, h 30px, gaptop 5px");
    this.add(txtPlayerName, "h 30px, pushx, growx");

    nameRandomiser = createNameRandomizer();
    this.add(nameRandomiser, "h 30px, w 30px, gaptop 5px");

    createPlayerTypeOptions();
    this.add(radioHuman, "gapright 5px");
    this.add(radioAi, "wrap");

    this.add(lobby.newLabel("Team:"), "w 40px, h 30px");
    populateTeamsComboBoxes();

    // Set these before action listeners are added
    this.setTeam(slot == null ? index : slot.getTeam());
    this.setIsArchenemy(slot != null && slot.isArchenemy());

    teamComboBox.addActionListener(teamListener);
    aeTeamComboBox.addActionListener(teamListener);
    teamComboBox.addTo(this, variantBtnConstraints + ", pushx, growx, gaptop 5px");
    aeTeamComboBox.addTo(this, variantBtnConstraints + ", pushx, growx, gaptop 5px");

    createReadyButton();
    if (allowNetworking) {
      this.add(radioOpen, "cell 4 1, ax left, sx 2");
      this.add(chkReady, "cell 5 1, ax left, sx 2, wrap");
    }

    this.add(deckLabel, variantBtnConstraints + ", cell 0 2, sx 2, ax right");
    this.add(
        deckBtn,
        variantBtnConstraints + ", cell 2 2, pushx, growx, wmax 100%-153px, h 30px, spanx 4, wrap");

    addHandlersDeckSelector();

    this.add(cmdLabel, variantBtnConstraints + ", cell 0 3, sx 2, ax right");
    this.add(cmdDeckSelectorBtn, variantBtnConstraints + ", cell 2 3, growx, pushx");
    this.add(cmdDeckEditor, variantBtnConstraints + ", cell 3 3, sx 3, growx, wrap");

    this.add(scmLabel, variantBtnConstraints + ", cell 0 4, sx 2, ax right");
    this.add(scmDeckSelectorBtn, variantBtnConstraints + ", cell 2 4, growx, pushx");
    this.add(scmDeckEditor, variantBtnConstraints + ", cell 3 4, sx 3, growx, wrap");

    this.add(pchLabel, variantBtnConstraints + ", cell 0 5, sx 2, ax right");
    this.add(pchDeckSelectorBtn, variantBtnConstraints + ", cell 2 5, growx, pushx");
    this.add(pchDeckEditor, variantBtnConstraints + ", cell 3 5, sx 3, growx, wrap");

    this.add(vgdLabel, variantBtnConstraints + ", cell 0 6, sx 2, ax right");
    this.add(vgdSelectorBtn, variantBtnConstraints + ", cell 2 6, sx 4, growx, wrap");

    addHandlersToVariantsControls();

    this.addMouseListener(
        new FMouseAdapter() {
          @Override
          public final void onLeftMouseDown(final MouseEvent e) {
            avatarLabel.requestFocusInWindow();
          }
        });

    this.type = slot == null ? LobbySlotType.LOCAL : slot.getType();
    this.setPlayerName(slot == null ? "" : slot.getName());
    this.setAvatarIndex(slot == null ? 0 : slot.getAvatarIndex());

    update();
  }