示例#1
0
  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
  public void updateVariantControlsVisibility() {
    boolean isCommanderApplied = false;
    boolean isTinyLeadersApplied = false;
    boolean isPlanechaseApplied = false;
    boolean isVanguardApplied = false;
    boolean isArchenemyApplied = false;
    boolean archenemyVisiblity = false;
    boolean isDeckBuildingAllowed = mayEdit;

    for (GameType variant : screen.getLobby().getAppliedVariants()) {
      switch (variant) {
        case Archenemy:
          isArchenemyApplied = true;
          if (isArchenemy()) {
            archenemyVisiblity = true;
          }
          break;
        case ArchenemyRumble:
          archenemyVisiblity = true;
          break;
        case Commander:
          isCommanderApplied = true;
          isDeckBuildingAllowed = false; // Commander deck replaces basic deck, so hide that
          break;
        case TinyLeaders:
          isTinyLeadersApplied = true;
          isDeckBuildingAllowed = false; // Tiny Leaders deck replaces basic deck, so hide that
          break;
        case Planechase:
          isPlanechaseApplied = true;
          break;
        case Vanguard:
          isVanguardApplied = true;
          break;
        default:
          if (variant.isAutoGenerated()) {
            isDeckBuildingAllowed = false;
          }
          break;
      }
    }

    btnDeck.setVisible(isDeckBuildingAllowed);
    btnCommanderDeck.setVisible(isCommanderApplied && mayEdit);
    btnTinyLeadersDeck.setVisible(isTinyLeadersApplied && mayEdit);

    btnSchemeDeck.setVisible(archenemyVisiblity && mayEdit);

    cbTeam.setVisible(!isArchenemyApplied);
    cbArchenemyTeam.setVisible(isArchenemyApplied);

    btnPlanarDeck.setVisible(isPlanechaseApplied && mayEdit);
    btnVanguardAvatar.setVisible(isVanguardApplied && mayEdit);
  }
示例#3
0
        @SuppressWarnings("unchecked")
        @Override
        public final void actionPerformed(final ActionEvent e) {
          final FComboBox<Object> cb = (FComboBox<Object>) e.getSource();
          cb.requestFocusInWindow();
          final Object selection = cb.getSelectedItem();

          if (null != selection) {
            lobby.changePlayerFocus(index);
            lobby.firePlayerChangeListener(index);
          }
        }
 private void initializeCloseActionComboBox() {
   final FComboBoxPanel<CloseAction> panel = this.view.getCloseActionComboBoxPanel();
   final FComboBox<CloseAction> comboBox = new FComboBox<>(CloseAction.values());
   comboBox.addItemListener(
       new ItemListener() {
         @Override
         public void itemStateChanged(final ItemEvent e) {
           Singletons.getControl().setCloseAction(comboBox.getSelectedItem());
         }
       });
   panel.setComboBox(comboBox, Singletons.getControl().getCloseAction());
 }
示例#5
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);
    }
  }
示例#6
0
 @Override
 public void handleEvent(FEvent e) {
   @SuppressWarnings("unchecked")
   FComboBox<Object> cb = (FComboBox<Object>) e.getSource();
   if (cb.getSelectedIndex() == -1) {
     return;
   }
   if (screen.hasVariant(GameType.Archenemy)) {
     String sel = (String) cb.getSelectedItem();
     if (sel.contains("Archenemy")) {
       screen.lastArchenemy = index;
       for (PlayerPanel pp : screen.getPlayerPanels()) {
         int i = pp.index;
         int team = i == screen.lastArchenemy ? 0 : 1;
         pp.setArchenemyTeam(team);
         pp.toggleIsPlayerArchenemy();
       }
     }
   }
 }
 private <E> void addComboBoxListener(
     final FComboBox<E> comboBox, final ForgePreferences.FPref setting) {
   comboBox.addItemListener(
       new ItemListener() {
         @Override
         public void itemStateChanged(final ItemEvent e) {
           final E selectedType = comboBox.getSelectedItem();
           CSubmenuPreferences.this.prefs.setPref(setting, selectedType.toString());
           CSubmenuPreferences.this.prefs.save();
         }
       });
 }
示例#8
0
  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);
  }
示例#9
0
 public void setArchenemyTeam(int team0) {
   cbTeam.setSelectedIndex(team0);
 }
示例#10
0
 public int getArchenemyTeam() {
   return cbTeam.getSelectedIndex();
 }
示例#11
0
 public void setTeam(int team0) {
   cbTeam.setSelectedIndex(team0);
 }
示例#12
0
 public int getTeam() {
   return cbTeam.getSelectedIndex();
 }
示例#13
0
 public void setIsArchenemy(boolean isArchenemy0) {
   cbArchenemyTeam.setSelectedIndex(isArchenemy0 ? 0 : 1);
 }
示例#14
0
 public boolean isArchenemy() {
   return cbArchenemyTeam.getSelectedIndex() == 0;
 }