diff --git a/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java b/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java index fbc312d1cb2..b8fc759ed43 100644 --- a/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java +++ b/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java @@ -61,6 +61,10 @@ public class ConquestAEtherScreen extends FScreen { private void calculateShardCost() { shardCost = FModel.getConquest().calculateShardCost(lstAEther.getFilteredItems(), lstAEther.getPool().countDistinct()); + updatePullButton(); + } + + private void updatePullButton() { int availableShards = FModel.getConquest().getModel().getAEtherShards(); btnPull.setEnabled(shardCost > 0 && shardCost <= availableShards); btnPull.setText((shardCost > 0 ? String.valueOf(shardCost) : "---") + " / " + String.valueOf(availableShards)); @@ -71,10 +75,11 @@ public class ConquestAEtherScreen extends FScreen { PaperCard card = Aggregates.random(lstAEther.getFilteredItems()).getKey(); lstAEther.removeItem(card, 1); - ConquestRewardDialog.show("Card pull from the AEther", card); + ConquestRewardDialog.show("Card pulled from the AEther", card); model.spendAEtherShards(shardCost); model.unlockCard(card); + updatePullButton(); } @Override diff --git a/forge-gui-mobile/src/forge/screens/planarconquest/ConquestRewardDialog.java b/forge-gui-mobile/src/forge/screens/planarconquest/ConquestRewardDialog.java index cb18966b7d6..d1921f0ff67 100644 --- a/forge-gui-mobile/src/forge/screens/planarconquest/ConquestRewardDialog.java +++ b/forge-gui-mobile/src/forge/screens/planarconquest/ConquestRewardDialog.java @@ -2,16 +2,18 @@ package forge.screens.planarconquest; import java.util.ArrayList; import java.util.List; - import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; + import forge.Graphics; import forge.animation.ForgeAnimation; import forge.assets.FSkinFont; import forge.assets.FSkinImage; import forge.card.CardRenderer; +import forge.card.CardZoom; import forge.card.CardRenderer.CardStackPosition; import forge.item.PaperCard; import forge.planarconquest.ConquestReward; +import forge.toolbox.FCardPanel; import forge.toolbox.FDialog; import forge.toolbox.FEvent; import forge.toolbox.FEvent.FEventHandler; @@ -20,6 +22,8 @@ import forge.toolbox.FScrollPane; import forge.util.Utils; public class ConquestRewardDialog extends FScrollPane { + private static final float PADDING = Utils.scale(5); + public static void show(String title, PaperCard card) { List rewards = new ArrayList(1); rewards.add(new ConquestReward(card, 0)); @@ -62,8 +66,34 @@ public class ConquestRewardDialog extends FScrollPane { @Override protected ScrollBounds layoutAndGetScrollBounds(float visibleWidth, float visibleHeight) { - float y = 0; - return new ScrollBounds(visibleWidth, y); + float x = PADDING; + float y = PADDING; + float cardWidth = (visibleWidth - (columnCount + 1) * PADDING) / columnCount; + float cardHeight = cardWidth * FCardPanel.ASPECT_RATIO; + + //ensure card height doesn't exceed max allowed height + float maxHeight = visibleHeight - 2 * PADDING; + if (cardHeight > maxHeight) { + cardHeight = maxHeight; + float newCardWidth = cardHeight / FCardPanel.ASPECT_RATIO; + x += (cardWidth - newCardWidth) * columnCount / 2; + cardWidth = newCardWidth; + } + + float startX = x; + int cardCount = cardRevealers.size(); + cardRevealers.get(0).setBounds(x, y, cardWidth, cardHeight); + for (int i = 1; i < cardCount; i++) { + if (i % columnCount == 0) { + x = startX; + y += cardHeight + PADDING; + } + else { + x += cardWidth + PADDING; + } + cardRevealers.get(i).setBounds(x, y, cardWidth, cardHeight); + } + return new ScrollBounds(visibleWidth, y + cardHeight + PADDING); } @Override @@ -126,19 +156,25 @@ public class ConquestRewardDialog extends FScrollPane { private class RevealDialog extends FDialog { private RevealDialog(String title) { super(title, 2); + + add(ConquestRewardDialog.this); + initButton(0, "OK", new FEventHandler() { @Override public void handleEvent(FEvent e) { hide(); } }); - setButtonEnabled(0, false); //disable OK button initButton(1, "Skip", new FEventHandler() { @Override public void handleEvent(FEvent e) { animation.skip(); } }); + + //disable both buttons initially + setButtonEnabled(0, false); + setButtonEnabled(1, false); } @Override @@ -146,6 +182,16 @@ public class ConquestRewardDialog extends FScrollPane { ConquestRewardDialog.this.setBounds(0, 0, width, maxHeight); return maxHeight; } + + @Override + public boolean fling(float velocityX, float velocityY) { + return false; //disable ability to hide dialog since it's animated + } + + protected void onRevealFinished() { + animation.start(); //start animation when dialog finished opening + setButtonEnabled(1, true); //enable Skip button + } } private class CardRevealAnimation extends ForgeAnimation { @@ -202,7 +248,7 @@ public class ConquestRewardDialog extends FScrollPane { } } - private static class CardRevealer extends FLabel { + private class CardRevealer extends FLabel { private static final float DUPLICATE_ALPHA_COMPOSITE = 0.35f; private final ConquestReward reward; @@ -219,6 +265,21 @@ public class ConquestRewardDialog extends FScrollPane { } } + @Override + public boolean longPress(float x, float y) { + int index = 0; + List cards = new ArrayList(); + for (int i = 0; i < cardRevealers.size(); i++) { + CardRevealer revealer = cardRevealers.get(i); + if (revealer == this) { + index = i; + } + cards.add(revealer.reward.getCard()); + } + CardZoom.show(cards, index, null); + return true; + } + @Override public void draw(Graphics g) { float w = getWidth(); diff --git a/forge-gui-mobile/src/forge/toolbox/FDialog.java b/forge-gui-mobile/src/forge/toolbox/FDialog.java index 16f7d3e6bf2..28a4fa192c9 100644 --- a/forge-gui-mobile/src/forge/toolbox/FDialog.java +++ b/forge-gui-mobile/src/forge/toolbox/FDialog.java @@ -256,6 +256,10 @@ public abstract class FDialog extends FOverlay { } } + protected void onRevealFinished() { + //provide ability to handle when first reveal finished + } + private RevealAnimation activeRevealAnimation; private class RevealAnimation extends ForgeAnimation { @@ -292,7 +296,10 @@ public abstract class FDialog extends FOverlay { @Override protected void onEnd(boolean endingAll) { activeRevealAnimation = null; - finishedFirstReveal = true; + if (!finishedFirstReveal) { + finishedFirstReveal = true; + onRevealFinished(); + } } } }