コード例 #1
0
ファイル: PlayerPanel.java プロジェクト: diab0l/mtg-forge
  private void populateTeamsComboBoxes() {
    cbArchenemyTeam.addItem("Archenemy");
    cbArchenemyTeam.addItem("Heroes");

    for (int i = 1; i <= LobbyScreen.MAX_PLAYERS; i++) {
      cbTeam.addItem("Team " + i);
    }
    cbTeam.setEnabled(true);
  }
コード例 #2
0
ファイル: PlayerPanel.java プロジェクト: diab0l/mtg-forge
  public PlayerPanel(
      final LobbyScreen screen0,
      final boolean allowNetworking0,
      final int index0,
      final LobbySlot slot,
      final boolean mayEdit0,
      final boolean mayControl0) {
    super();
    screen = screen0;
    allowNetworking = allowNetworking0;
    if (allowNetworking) {
      humanAiSwitch = new FToggleSwitch("Not Ready", "Ready");
    } else {
      humanAiSwitch = new FToggleSwitch("Human", "AI");
    }
    index = index0;
    populateTeamsComboBoxes();
    setTeam(slot.getTeam());
    setIsArchenemy(slot.isArchenemy());
    setType(slot.getType());
    setPlayerName(slot.getName());
    setAvatarIndex(slot.getAvatarIndex());

    btnDeck.setEnabled(false); // disable deck button until done loading decks

    boolean isAi = isAi();
    deckChooser =
        new FDeckChooser(
            GameType.Constructed,
            isAi,
            new FEventHandler() {
              @Override
              public void handleEvent(FEvent e) {
                btnDeck.setEnabled(true);
                btnDeck.setText(
                    deckChooser.getSelectedDeckType().toString()
                        + ": "
                        + Lang.joinHomogenous(
                            ((DeckManager) e.getSource()).getSelectedItems(),
                            DeckProxy.FN_GET_NAME));
              }
            });
    lstCommanderDecks =
        new FDeckChooser(
            GameType.Commander,
            isAi,
            new FEventHandler() {
              @Override
              public void handleEvent(FEvent e) {
                btnCommanderDeck.setText(
                    "Commander Deck: " + ((DeckManager) e.getSource()).getSelectedItem().getName());
              }
            });
    lstTinyLeadersDecks =
        new FDeckChooser(
            GameType.TinyLeaders,
            isAi,
            new FEventHandler() {
              @Override
              public void handleEvent(FEvent e) {
                btnTinyLeadersDeck.setText(
                    "Tiny Leaders Deck: "
                        + ((DeckManager) e.getSource()).getSelectedItem().getName());
              }
            });
    lstSchemeDecks =
        new FDeckChooser(
            GameType.Archenemy,
            isAi,
            new FEventHandler() {
              @Override
              public void handleEvent(FEvent e) {
                btnSchemeDeck.setText(
                    "Scheme Deck: " + ((DeckManager) e.getSource()).getSelectedItem().getName());
              }
            });
    lstPlanarDecks =
        new FDeckChooser(
            GameType.Planechase,
            isAi,
            new FEventHandler() {
              @Override
              public void handleEvent(FEvent e) {
                btnPlanarDeck.setText(
                    "Planar Deck: " + ((DeckManager) e.getSource()).getSelectedItem().getName());
              }
            });
    lstVanguardAvatars =
        new FVanguardChooser(
            isAi,
            new FEventHandler() {
              @Override
              public void handleEvent(FEvent e) {
                btnVanguardAvatar.setText(
                    "Vanguard: " + ((CardManager) e.getSource()).getSelectedItem().getName());
              }
            });

    createAvatar();
    add(avatarLabel);

    createNameEditor();
    add(newLabel("Name:"));
    add(txtPlayerName);

    nameRandomiser = createNameRandomizer();
    add(nameRandomiser);

    humanAiSwitch.setChangedHandler(humanAiSwitched);
    add(humanAiSwitch);

    add(newLabel("Team:"));
    cbTeam.setChangedHandler(teamChangedHandler);
    cbArchenemyTeam.setChangedHandler(teamChangedHandler);
    add(cbTeam);
    add(cbArchenemyTeam);

    add(btnDeck);
    btnDeck.setCommand(
        new FEventHandler() {
          @Override
          public void handleEvent(FEvent e) {
            deckChooser.setHeaderCaption("Select Deck for " + txtPlayerName.getText());
            Forge.openScreen(deckChooser);
          }
        });
    add(btnCommanderDeck);
    btnCommanderDeck.setCommand(
        new FEventHandler() {
          @Override
          public void handleEvent(FEvent e) {
            lstCommanderDecks.setHeaderCaption(
                "Select Commander Deck for " + txtPlayerName.getText());
            Forge.openScreen(lstCommanderDecks);
          }
        });
    add(btnTinyLeadersDeck);
    btnTinyLeadersDeck.setCommand(
        new FEventHandler() {
          @Override
          public void handleEvent(FEvent e) {
            lstTinyLeadersDecks.setHeaderCaption(
                "Select Tiny Leaders Deck for " + txtPlayerName.getText());
            Forge.openScreen(lstTinyLeadersDecks);
          }
        });
    add(btnSchemeDeck);
    btnSchemeDeck.setCommand(
        new FEventHandler() {
          @Override
          public void handleEvent(FEvent e) {
            lstSchemeDecks.setHeaderCaption("Select Scheme Deck for " + txtPlayerName.getText());
            Forge.openScreen(lstSchemeDecks);
          }
        });
    add(btnPlanarDeck);
    btnPlanarDeck.setCommand(
        new FEventHandler() {
          @Override
          public void handleEvent(FEvent e) {
            lstPlanarDecks.setHeaderCaption("Select Planar Deck for " + txtPlayerName.getText());
            Forge.openScreen(lstPlanarDecks);
          }
        });
    add(btnVanguardAvatar);
    btnVanguardAvatar.setCommand(
        new FEventHandler() {
          @Override
          public void handleEvent(FEvent e) {
            lstVanguardAvatars.setHeaderCaption("Select Vanguard for " + txtPlayerName.getText());
            Forge.openScreen(lstVanguardAvatars);
          }
        });

    if (mayEdit == mayEdit0) {
      updateVariantControlsVisibility();
    } else {
      setMayEdit(false);
    }
    setMayControl(mayControl0);

    // disable team combo boxes for now
    cbTeam.setEnabled(false);
  }