diff --git a/forge-m-base/src/forge/screens/match/views/VStack.java b/forge-m-base/src/forge/screens/match/views/VStack.java index 8472714f509..20d1bdf6dc1 100644 --- a/forge-m-base/src/forge/screens/match/views/VStack.java +++ b/forge-m-base/src/forge/screens/match/views/VStack.java @@ -1,5 +1,8 @@ package forge.screens.match.views; +import java.util.ArrayList; +import java.util.List; + import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; @@ -66,13 +69,25 @@ public class VStack extends FDropDown { float y = 0; float width = maxWidth / 2; StackInstanceDisplay display; - float height; + float height = 0; + float scale = 1; //scale size down as you go from top to bottom + List displays = new ArrayList(); for (final SpellAbilityStackInstance stackInstance : stack) { - display = add(new StackInstanceDisplay(stackInstance)); + if (y > 0) { + y -= CARD_HEIGHT * scale / 4; //allow partial overlap between layers of stack + } + display = new StackInstanceDisplay(stackInstance); + display.scale = scale; height = display.getMinHeight(width); - display.setBounds(0, y, width, height); + display.setBounds(width - width * scale, y, width * scale, height); y += height; + scale *= 0.85f; + displays.add(display); + } + //add in reverse order so top of stack appears on top + for (int i = displays.size() - 1; i >= 0; i--) { + add(displays.get(i)); } return new ScrollBounds(width, y); } @@ -80,6 +95,7 @@ public class VStack extends FDropDown { private class StackInstanceDisplay extends FDisplayObject { private final SpellAbilityStackInstance stackInstance; private FSkinColor foreColor, backColor; + private float scale; private String text; private StackInstanceDisplay(SpellAbilityStackInstance stackInstance0) { @@ -130,13 +146,15 @@ public class VStack extends FDropDown { } foreColor = foreColor.alphaColor(0.9f); - backColor = backColor.alphaColor(0.8f); + backColor = backColor.alphaColor(0.9f); } private float getMinHeight(float width) { width -= CARD_WIDTH; //account for card picture width -= 3 * PADDING; //account for left and right insets and gap between picture and text - return Math.max(CARD_HEIGHT, FONT.getFont().getWrappedBounds(text, width).height) + 2 * PADDING; + float height = Math.max(CARD_HEIGHT, FONT.getFont().getWrappedBounds(text, width).height); + height += 2 * PADDING; + return height * scale; } @Override @@ -148,13 +166,17 @@ public class VStack extends FDropDown { g.fillRect(backColor, 0, 0, w, h); g.drawRect(2, foreColor, 0, 0, w, h); - float x = PADDING; - float y = PADDING; - g.drawImage(ImageCache.getImage(stackInstance.getSourceCard()), x, y, CARD_WIDTH, CARD_HEIGHT); + float padding = PADDING * scale; + float cardWidth = CARD_WIDTH * scale; + float cardHeight = CARD_HEIGHT * scale; + + float x = padding; + float y = padding; + g.drawImage(ImageCache.getImage(stackInstance.getSourceCard()), x, y, cardWidth, cardHeight); - x += CARD_WIDTH + PADDING; - w -= x + PADDING; - h -= y + PADDING; + x += cardWidth + padding; + w -= x + padding; + h -= y + padding; g.drawText(text, FONT, foreColor, x, y, w, h, true, HAlignment.LEFT, true); diff --git a/forge-m-base/src/forge/toolbox/GuiChoose.java b/forge-m-base/src/forge/toolbox/GuiChoose.java index 8b4b73ca4a9..bd4c933b348 100644 --- a/forge-m-base/src/forge/toolbox/GuiChoose.java +++ b/forge-m-base/src/forge/toolbox/GuiChoose.java @@ -4,6 +4,7 @@ import com.google.common.base.Function; import com.google.common.collect.Iterables; import forge.game.card.Card; + import org.apache.commons.lang3.StringUtils; import java.util.*; @@ -173,14 +174,28 @@ public class GuiChoose { } public static List getChoices(final String message, final int min, final int max, final Collection choices, final T selected, final Function display) { - /*if (choices == null || choices.isEmpty()) { + if (choices == null || choices.isEmpty()) { if (min == 0) { return new ArrayList(); } throw new RuntimeException("choice required from empty list"); } - Callable> showChoice = new Callable>() { + //TODO: Remove this temporary code and uncomment below + int resultCount = min; + if (resultCount == 0 && max > 0) { + resultCount = 1; + } + List result = new ArrayList(); + for (T choice : choices) { + result.add(choice); + if (result.size() == resultCount) { + break; + } + } + return result; + + /*Callable> showChoice = new Callable>() { @Override public List call() { ListChooser c = new ListChooser(message, min, max, choices, display); @@ -225,7 +240,6 @@ public class GuiChoose { } catch (Exception e) { // should be no exception here e.printStackTrace(); }*/ - return null; } public static List many(final String title, final String topCaption, int cnt, final List sourceChoices, Card referenceCard) { @@ -303,15 +317,14 @@ public class GuiChoose { } final List choice = GuiChoose.sortedGetChoices(message, 0, 1, choices, comparer); return choice.isEmpty() ? null : choice.get(0); - } // getChoiceOptional(String,T...) - + } // If comparer is NULL, T has to be comparable. Otherwise you'll get an exception from inside the Arrays.sort() routine public static T sortedOne(final String message, final T[] choices, Comparator comparer) { final List choice = GuiChoose.sortedGetChoices(message, 1, 1, choices, comparer); assert choice.size() == 1; return choice.get(0); - } // getChoice() + } // If comparer is NULL, T has to be comparable. Otherwise you'll get an exception from inside the Arrays.sort() routine public static T sortedOne(final String message, final List choices, Comparator comparer) { @@ -341,6 +354,5 @@ public class GuiChoose { Collections.sort(choices, comparer); return getChoices(message, min, max, choices); } - }