예제 #1
0
  @Override
  protected void drawOnContainer(Graphics g) {
    // draw target arrows immediately above stack for active item only
    if (activeItem != null) {
      Vector2 arrowOrigin =
          new Vector2(
              activeItem.getLeft()
                  + VStack.CARD_WIDTH * FCardPanel.TARGET_ORIGIN_FACTOR_X
                  + VStack.PADDING
                  + VStack.BORDER_THICKNESS,
              activeItem.getTop()
                  + VStack.CARD_HEIGHT * FCardPanel.TARGET_ORIGIN_FACTOR_Y
                  + VStack.PADDING
                  + VStack.BORDER_THICKNESS);

      PlayerView activator = activeStackInstance.getActivatingPlayer();
      arrowOrigin = arrowOrigin.add(screenPos.x, screenPos.y);

      StackItemView instance = activeStackInstance;
      while (instance != null) {
        for (CardView c : instance.getTargetCards()) {
          TargetingOverlay.drawArrow(g, arrowOrigin, c, activator.isOpponentOf(c.getController()));
        }
        for (PlayerView p : instance.getTargetPlayers()) {
          TargetingOverlay.drawArrow(g, arrowOrigin, p, activator.isOpponentOf(p));
        }
        instance = instance.getSubInstance();
      }
    }
  }
예제 #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);
  }