Esempio n. 1
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();
  }