예제 #1
0
  /**
   * @param index
   * @return
   */
  private FLabel createNameRandomizer() {
    final FLabel newNameBtn =
        new FLabel.Builder()
            .tooltip("Get a new random name")
            .iconInBackground(false)
            .icon(FSkin.getIcon(FSkinProp.ICO_EDIT))
            .hoverable(true)
            .opaque(false)
            .unhoveredAlpha(0.9f)
            .build();
    newNameBtn.setCommand(
        new UiCommand() {
          @Override
          public void run() {
            final String newName = lobby.getNewName();
            if (null == newName) {
              return;
            }
            txtPlayerName.setText(newName);

            if (index == 0) {
              prefs.setPref(FPref.PLAYER_NAME, newName);
              prefs.save();
            }
            txtPlayerName.requestFocus();
            lobby.changePlayerFocus(index);
          }
        });
    newNameBtn.addFocusListener(nameFocusListener);
    return newNameBtn;
  }
예제 #2
0
        @Override
        public final void onLeftClick(final MouseEvent e) {
          if (!avatarLabel.isEnabled()) {
            return;
          }

          final FLabel avatar = (FLabel) e.getSource();

          lobby.changePlayerFocus(index);
          avatar.requestFocusInWindow();

          final AvatarSelector aSel =
              new AvatarSelector(playerName, avatarIndex, lobby.getUsedAvatars());
          for (final FLabel lbl : aSel.getSelectables()) {
            lbl.setCommand(
                new UiCommand() {
                  @Override
                  public void run() {
                    setAvatarIndex(Integer.valueOf(lbl.getName().substring(11)));
                    aSel.setVisible(false);
                  }
                });
          }

          aSel.setVisible(true);
          aSel.dispose();

          if (index < 2) {
            lobby.updateAvatarPrefs();
          }

          lobby.firePlayerChangeListener(index);
        }
예제 #3
0
  private FLabel createNameRandomizer() {
    final FLabel newNameBtn =
        new FLabel.Builder().iconInBackground(false).icon(FSkinImage.EDIT).opaque(false).build();
    newNameBtn.setCommand(
        new FEventHandler() {
          @Override
          public void handleEvent(FEvent e) {
            getNewName(
                new Callback<String>() {
                  @Override
                  public void run(String newName) {
                    if (newName == null) {
                      return;
                    }

                    txtPlayerName.setText(newName);

                    if (index == 0) {
                      prefs.setPref(FPref.PLAYER_NAME, newName);
                      prefs.save();
                    }
                    if (allowNetworking) {
                      screen.firePlayerChangeListener(index);
                    }
                  }
                });
          }
        });
    return newNameBtn;
  }
예제 #4
0
  protected FLabel addToggleButton(JPanel widget, SkinImage icon, String tooltip) {
    final FLabel button =
        new FLabel.Builder()
            .icon(icon)
            .iconScaleAuto(false)
            .fontSize(11)
            .tooltip(tooltip)
            .hoverable()
            .selectable(true)
            .selected(true)
            .build();

    button.setCommand(
        new UiCommand() {
          @Override
          public void run() {
            if (lockFiltering) {
              return;
            }
            applyChange();
          }
        });

    this.buttons.add(button);
    widget.add(button);
    return button;
  }
예제 #5
0
 public void setAvatarIndex(int newAvatarIndex) {
   avatarIndex = newAvatarIndex;
   if (avatarIndex != -1) {
     avatarLabel.setIcon(new FTextureRegionImage(FSkin.getAvatars().get(newAvatarIndex)));
   } else {
     avatarLabel.setIcon(null);
   }
 }
  private void populateTournamentActive() {

    lblTitle.setText(
        "Quest Mode: Draft Tournament - "
            + FModel.getQuest().getAchievements().getCurrentDraft().getTitle());
    VHomeUI.SINGLETON_INSTANCE
        .getPnlDisplay()
        .setLayout(new MigLayout("insets 0, gap 0, ax center, wrap 1"));
    VHomeUI.SINGLETON_INSTANCE
        .getPnlDisplay()
        .add(lblTitle, "w 80%!, h 40px!, gap 20% 0 15px 10px, ax right, span 2");

    FScrollPanel panel =
        new FScrollPanel(
            new MigLayout("insets 0, gap 0, wrap 4, ax center"),
            true,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    String constraintsLeft = "w 350px!, h 196px!, gap 0px 0px 0px 0px, ay center";
    String constraintsMiddle = "w 350px!, h 392px!, gap 0px 0px 0px 0px, ay center";
    String constraintsRight = "w 350px!, h 784px!, gap 0px 0px 0px 0px, ay center";

    panel.add(matchups[0], constraintsLeft);
    panel.add(matchups[4], constraintsMiddle + ", span 1 2");
    panel.add(matchups[6], constraintsRight + ", span 1 4");
    panel.add(matchups[7], constraintsRight + ", span 1 4");
    panel.add(matchups[1], constraintsLeft);
    panel.add(matchups[2], constraintsLeft);
    panel.add(matchups[5], constraintsMiddle + ", span 1 2");
    panel.add(matchups[3], constraintsLeft);

    VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(panel, "gap 0 0 0 0, ax center");

    btnEditDeck.setFontSize(12);

    JPanel bottomButtons = new JPanel(new MigLayout("insets 0, gap 0, wrap 2, ax center"));

    if (FModel.getQuest().getAchievements().getCurrentDraft().playerHasMatchesLeft()) {

      VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(btnStartMatch, "gap 0 0 0 20px, ax center");
      bottomButtons.add(btnEditDeck, "w 135px!, h 25px!, gap 0 25px 10px 10px, ax right");
      bottomButtons.add(btnLeaveTournament, "w 135px!, h 25px!, gap 25px 0 10px 10px, ax right");
      btnLeaveTournament.setFontSize(12);

    } else {

      VHomeUI.SINGLETON_INSTANCE
          .getPnlDisplay()
          .add(btnLeaveTournament, "w 250px!, h 60px!, gap 0 0 20px 20px, ax center");
      bottomButtons.add(btnEditDeck, "w 135px!, h 25px!, gap 0 25px 10px 10px, ax right");
      bottomButtons.add(btnStartMatchSmall, "w 135px!, h 25px!, gap 25px 0 10px 10px, ax right");
      btnLeaveTournament.setFontSize(24);
    }

    VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(bottomButtons, "w 100%!");
    bottomButtons.setOpaque(false);
  }
예제 #7
0
 @Override
 public final boolean isEmpty() {
   for (FLabel button : buttons) { // consider filter empty if any button isn't selected
     if (!button.isSelected()) {
       return false;
     }
   }
   return true;
 }
예제 #8
0
  private void createAvatar() {
    final String[] currentPrefs = FModel.getPreferences().getPref(FPref.UI_AVATARS).split(",");
    if (index < currentPrefs.length) {
      avatarIndex = Integer.parseInt(currentPrefs[index]);
      avatarLabel.setIcon(FSkin.getAvatars().get(avatarIndex));
    } else {
      setRandomAvatar(false);
    }

    avatarLabel.setToolTipText("L-click: Select avatar. R-click: Randomize avatar.");
    avatarLabel.addFocusListener(avatarFocusListener);
    avatarLabel.addMouseListener(avatarMouseListener);
  }
예제 #9
0
        @Override
        public final void onRightClick(final MouseEvent e) {
          if (!avatarLabel.isEnabled()) {
            return;
          }

          lobby.changePlayerFocus(index);
          avatarLabel.requestFocusInWindow();

          setRandomAvatar();

          if (index < 2) {
            lobby.updateAvatarPrefs();
          }
        }
 public PnlMatchup(LineDirection dir, LineSide side, BoxSize size, boolean singleBox) {
   this.setLayout(new MigLayout("insets 0, gap 0, wrap"));
   if (!singleBox) {
     this.add(name1, "w 100%!, h 50% - 30px!, gap 135px 0 0 30px, ax right");
     this.add(name2, "w 100%!, h 50% - 30px!, gap 135px 0 31px 0, ax right");
   } else {
     this.add(name1, "w 100%!, h 50%!, gap 135px 0 11px 0, ax right");
   }
   this.lineDir = dir;
   this.lineSide = side;
   this.size = size;
   this.singleBox = singleBox;
   name1.setVerticalAlignment(SwingConstants.BOTTOM);
   name2.setVerticalAlignment(SwingConstants.TOP);
 }
예제 #11
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();
    }
  }
예제 #12
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();
  }
예제 #13
0
 private void createAvatar() {
   String[] currentPrefs = prefs.getPref(FPref.UI_AVATARS).split(",");
   if (index < currentPrefs.length) {
     setAvatarIndex(Integer.parseInt(currentPrefs[index]));
   } else {
     setAvatarIndex(AvatarSelector.getRandomAvatar(screen.getUsedAvatars()));
   }
   avatarLabel.setCommand(avatarCommand);
 }
예제 #14
0
 /** @param index */
 private void addHandlersDeckSelector() {
   deckBtn.setCommand(
       new Runnable() {
         @Override
         public void run() {
           lobby.setCurrentGameMode(GameType.Constructed);
           deckBtn.requestFocusInWindow();
           lobby.changePlayerFocus(index, GameType.Constructed);
         }
       });
 }
예제 #15
0
  @Override
  protected void doWidgetLayout(LayoutHelper helper) {
    int availableWidth = helper.getParentWidth() - (buttons.size() - 1) * 2; // account for gaps
    int buttonWidth = availableWidth / buttons.size();
    Graphics g = buttons.get(0).getGraphics();
    if (buttonWidth <= 0 || g == null) {
      return;
    }

    int maxTextWidth = buttonWidth - 8; // account for padding

    for (FLabel btn : buttons) {
      if (btn.getText() != null && !btn.getText().isEmpty()) {
        int max = maxTextWidth;
        Icon icon = btn.getIcon();
        if (icon != null) {
          max -= icon.getIconWidth() + 4;
        }
        for (int fs = 11; fs > 5; fs--) {
          SkinFont skinFont = FSkin.getFont(fs);
          if (skinFont.measureTextWidth(g, btn.getText()) <= max) {
            btn.setFont(skinFont);
            break;
          }
        }
      }
      helper.include(btn, buttonWidth, 25);
      helper.offset(-1, 0); // keep buttons tighter together
    }
  }
 private void populatePrepareDeck() {
   lblTitle.setText(
       "Quest Mode: Draft Tournament - "
           + FModel.getQuest().getAchievements().getCurrentDraft().getTitle());
   VHomeUI.SINGLETON_INSTANCE
       .getPnlDisplay()
       .setLayout(new MigLayout("insets 0, gap 0, ax center, wrap", "", "[][grow, center][][][]"));
   VHomeUI.SINGLETON_INSTANCE
       .getPnlDisplay()
       .add(lblTitle, "w 80%!, h 40px!, gap 20% 0 15px 35px, ax right");
   pnlDeckImage.setMaximumSize(new Dimension(680, 475));
   VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(pnlDeckImage, "ax center, grow");
   VHomeUI.SINGLETON_INSTANCE
       .getPnlDisplay()
       .add(btnEditDeck, "w 150px, h 50px, gap 0 0 15px 0, ax center");
   VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(btnStartTournament, "gap 0 0 0 15px, ax center");
   VHomeUI.SINGLETON_INSTANCE
       .getPnlDisplay()
       .add(btnLeaveTournament, "w 150px, h 35px, gap 0 0 25px 10%, ax center");
   btnEditDeck.setFontSize(24);
   btnLeaveTournament.setFontSize(12);
 }
예제 #17
0
 private FLabel createCloseButton() {
   final FLabel closeBtn =
       new FLabel.Builder()
           .tooltip("Remove")
           .iconInBackground(false)
           .icon(FSkin.getIcon(FSkinProp.ICO_CLOSE))
           .hoverable(true)
           .build();
   closeBtn.setCommand(
       new Runnable() {
         @Override
         public final void run() {
           if (type == LobbySlotType.REMOTE
               && !SOptionPane.showConfirmDialog(
                   String.format("Really kick %s?", playerName), "Kick", false)) {
             return;
           }
           lobby.removePlayer(index);
         }
       });
   return closeBtn;
 }
예제 #18
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);
  }
예제 #19
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;
 }
예제 #20
0
 public void setAvatarIndex(final int avatarIndex0) {
   avatarIndex = avatarIndex0;
   final SkinImage icon = FSkin.getAvatars().get(avatarIndex);
   avatarLabel.setIcon(icon);
   avatarLabel.repaintSelf();
 }
예제 #21
0
 public void setFocused(final boolean focused) {
   avatarLabel.setBorder(focused ? focusedBorder : defaultBorder);
 }
예제 #22
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);
    }
  }
예제 #23
0
 public void setDeckSelectorButtonText(String text) {
   btnDeck.setText(text);
 }
예제 #24
0
  /** @param index */
  private void addHandlersToVariantsControls() {
    // Archenemy buttons
    scmDeckSelectorBtn.setCommand(
        new Runnable() {
          @Override
          public final void run() {
            lobby.setCurrentGameMode(
                lobby.hasVariant(GameType.Archenemy)
                    ? GameType.Archenemy
                    : GameType.ArchenemyRumble);
            scmDeckSelectorBtn.requestFocusInWindow();
            lobby.changePlayerFocus(index);
          }
        });

    scmDeckEditor.setCommand(
        new UiCommand() {
          @Override
          public void run() {
            lobby.setCurrentGameMode(
                lobby.hasVariant(GameType.Archenemy)
                    ? GameType.Archenemy
                    : GameType.ArchenemyRumble);
            final Predicate<PaperCard> predSchemes =
                new Predicate<PaperCard>() {
                  @Override
                  public final boolean apply(final PaperCard arg0) {
                    return arg0.getRules().getType().isScheme();
                  }
                };

            Singletons.getControl().setCurrentScreen(FScreen.DECK_EDITOR_ARCHENEMY);
            CDeckEditorUI.SINGLETON_INSTANCE.setEditorController(
                new CEditorVariant(
                    FModel.getDecks().getScheme(),
                    predSchemes,
                    DeckSection.Schemes,
                    FScreen.DECK_EDITOR_ARCHENEMY,
                    CDeckEditorUI.SINGLETON_INSTANCE.getCDetailPicture()));
          }
        });

    // Commander buttons
    cmdDeckSelectorBtn.setCommand(
        new Runnable() {
          @Override
          public void run() {
            lobby.setCurrentGameMode(
                lobby.hasVariant(GameType.TinyLeaders) ? GameType.TinyLeaders : GameType.Commander);
            cmdDeckSelectorBtn.requestFocusInWindow();
            lobby.changePlayerFocus(index);
          }
        });

    cmdDeckEditor.setCommand(
        new UiCommand() {
          @Override
          public void run() {
            if (lobby.hasVariant(GameType.TinyLeaders)) {
              lobby.setCurrentGameMode(GameType.TinyLeaders);
              Singletons.getControl().setCurrentScreen(FScreen.DECK_EDITOR_TINY_LEADERS);
              CDeckEditorUI.SINGLETON_INSTANCE.setEditorController(
                  new CEditorCommander(CDeckEditorUI.SINGLETON_INSTANCE.getCDetailPicture(), true));
            } else {
              lobby.setCurrentGameMode(GameType.Commander);
              Singletons.getControl().setCurrentScreen(FScreen.DECK_EDITOR_COMMANDER);
              CDeckEditorUI.SINGLETON_INSTANCE.setEditorController(
                  new CEditorCommander(
                      CDeckEditorUI.SINGLETON_INSTANCE.getCDetailPicture(), false));
            }
          }
        });

    // Planechase buttons
    pchDeckSelectorBtn.setCommand(
        new Runnable() {
          @Override
          public void run() {
            lobby.setCurrentGameMode(GameType.Planechase);
            pchDeckSelectorBtn.requestFocusInWindow();
            lobby.changePlayerFocus(index, GameType.Planechase);
          }
        });

    pchDeckEditor.setCommand(
        new UiCommand() {
          @Override
          public void run() {
            lobby.setCurrentGameMode(GameType.Planechase);
            final Predicate<PaperCard> predPlanes =
                new Predicate<PaperCard>() {
                  @Override
                  public boolean apply(final PaperCard arg0) {
                    return arg0.getRules().getType().isPlane()
                        || arg0.getRules().getType().isPhenomenon();
                  }
                };

            Singletons.getControl().setCurrentScreen(FScreen.DECK_EDITOR_PLANECHASE);
            CDeckEditorUI.SINGLETON_INSTANCE.setEditorController(
                new CEditorVariant(
                    FModel.getDecks().getPlane(),
                    predPlanes,
                    DeckSection.Planes,
                    FScreen.DECK_EDITOR_PLANECHASE,
                    CDeckEditorUI.SINGLETON_INSTANCE.getCDetailPicture()));
          }
        });

    // Vanguard buttons
    vgdSelectorBtn.setCommand(
        new Runnable() {
          @Override
          public void run() {
            lobby.setCurrentGameMode(GameType.Vanguard);
            vgdSelectorBtn.requestFocusInWindow();
            lobby.changePlayerFocus(index, GameType.Vanguard);
          }
        });
  }
예제 #25
0
 public void focusOnAvatar() {
   avatarLabel.requestFocusInWindow();
 }
예제 #26
0
 public void setCommanderDeckSelectorButtonText(final String text) {
   cmdDeckSelectorBtn.setText(text);
 }
예제 #27
0
 public void setDeckSelectorButtonText(final String text) {
   deckBtn.setText(text);
 }
예제 #28
0
 public void setVanguardButtonText(final String text) {
   vgdSelectorBtn.setText(text);
 }
예제 #29
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);
  }
예제 #30
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);
  }