Beispiel #1
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);
    }
  }
Beispiel #2
0
  @Override
  protected ScrollBounds updateAndGetPaneSize(float maxWidth, float maxVisibleHeight) {
    clear();

    float x = MARGINS;
    float y = MARGINS;
    float totalWidth;
    if (Forge.isLandscapeMode()) {
      totalWidth = Forge.getScreenWidth() * 0.35f;
    } else {
      totalWidth =
          maxWidth
              - MatchController.getView()
                  .getTopPlayerPanel()
                  .getTabs()
                  .iterator()
                  .next()
                  .getRight(); // keep avatar, life total, and hand tab visible to left of stack
    }
    float width = totalWidth - 2 * MARGINS;

    final FCollectionView<StackItemView> stack = MatchController.instance.getGameView().getStack();
    if (stack.isEmpty()) { // show label if stack empty
      FLabel label =
          add(new FLabel.Builder().text("[Empty]").font(FONT).align(HAlignment.CENTER).build());

      float height = Math.round(label.getAutoSizeBounds().height) + 2 * PADDING;
      label.setBounds(x, y, width, height);
      return new ScrollBounds(totalWidth, y + height + MARGINS);
    } else {
      // iterate stack in reverse so most recent items appear on bottom
      StackItemView stackInstance = null;
      StackInstanceDisplay display = null;
      float overlap = Math.round(CARD_HEIGHT / 2 + PADDING + BORDER_THICKNESS);
      for (int i = stack.size() - 1; i >= 0; i--) {
        stackInstance = stack.get(i);
        display = new StackInstanceDisplay(stackInstance, width);
        if (activeStackInstance == stackInstance) {
          activeItem = display;
        } else { // only add non-active items here
          add(display);
        }
        // use full preferred height of display for topmost item on stack, overlap amount for other
        // items
        display.setBounds(x, y, width, i > 0 ? overlap : display.preferredHeight);
        y += display.getHeight();
      }
      if (activeStackInstance == null) {
        activeStackInstance = stackInstance; // use topmost item on stack as default active item
        activeItem = display;
      } else {
        activeItem.setHeight(
            display.preferredHeight); // increase active item height to preferred height if needed
        if (activeItem.getBottom() > y) {
          y = activeItem.getBottom(); // ensure stack height increases if needed
        }
        add(activeItem);
      }
      scrollIntoView(activeItem); // scroll active display into view
      revealTargetZones();
    }
    return new ScrollBounds(totalWidth, y + MARGINS);
  }