mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Fix so cards are displayed in reward dialog
This commit is contained in:
@@ -61,6 +61,10 @@ public class ConquestAEtherScreen extends FScreen {
|
|||||||
|
|
||||||
private void calculateShardCost() {
|
private void calculateShardCost() {
|
||||||
shardCost = FModel.getConquest().calculateShardCost(lstAEther.getFilteredItems(), lstAEther.getPool().countDistinct());
|
shardCost = FModel.getConquest().calculateShardCost(lstAEther.getFilteredItems(), lstAEther.getPool().countDistinct());
|
||||||
|
updatePullButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updatePullButton() {
|
||||||
int availableShards = FModel.getConquest().getModel().getAEtherShards();
|
int availableShards = FModel.getConquest().getModel().getAEtherShards();
|
||||||
btnPull.setEnabled(shardCost > 0 && shardCost <= availableShards);
|
btnPull.setEnabled(shardCost > 0 && shardCost <= availableShards);
|
||||||
btnPull.setText((shardCost > 0 ? String.valueOf(shardCost) : "---") + " / " + String.valueOf(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();
|
PaperCard card = Aggregates.random(lstAEther.getFilteredItems()).getKey();
|
||||||
lstAEther.removeItem(card, 1);
|
lstAEther.removeItem(card, 1);
|
||||||
|
|
||||||
ConquestRewardDialog.show("Card pull from the AEther", card);
|
ConquestRewardDialog.show("Card pulled from the AEther", card);
|
||||||
|
|
||||||
model.spendAEtherShards(shardCost);
|
model.spendAEtherShards(shardCost);
|
||||||
model.unlockCard(card);
|
model.unlockCard(card);
|
||||||
|
updatePullButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,16 +2,18 @@ package forge.screens.planarconquest;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
||||||
|
|
||||||
import forge.Graphics;
|
import forge.Graphics;
|
||||||
import forge.animation.ForgeAnimation;
|
import forge.animation.ForgeAnimation;
|
||||||
import forge.assets.FSkinFont;
|
import forge.assets.FSkinFont;
|
||||||
import forge.assets.FSkinImage;
|
import forge.assets.FSkinImage;
|
||||||
import forge.card.CardRenderer;
|
import forge.card.CardRenderer;
|
||||||
|
import forge.card.CardZoom;
|
||||||
import forge.card.CardRenderer.CardStackPosition;
|
import forge.card.CardRenderer.CardStackPosition;
|
||||||
import forge.item.PaperCard;
|
import forge.item.PaperCard;
|
||||||
import forge.planarconquest.ConquestReward;
|
import forge.planarconquest.ConquestReward;
|
||||||
|
import forge.toolbox.FCardPanel;
|
||||||
import forge.toolbox.FDialog;
|
import forge.toolbox.FDialog;
|
||||||
import forge.toolbox.FEvent;
|
import forge.toolbox.FEvent;
|
||||||
import forge.toolbox.FEvent.FEventHandler;
|
import forge.toolbox.FEvent.FEventHandler;
|
||||||
@@ -20,6 +22,8 @@ import forge.toolbox.FScrollPane;
|
|||||||
import forge.util.Utils;
|
import forge.util.Utils;
|
||||||
|
|
||||||
public class ConquestRewardDialog extends FScrollPane {
|
public class ConquestRewardDialog extends FScrollPane {
|
||||||
|
private static final float PADDING = Utils.scale(5);
|
||||||
|
|
||||||
public static void show(String title, PaperCard card) {
|
public static void show(String title, PaperCard card) {
|
||||||
List<ConquestReward> rewards = new ArrayList<ConquestReward>(1);
|
List<ConquestReward> rewards = new ArrayList<ConquestReward>(1);
|
||||||
rewards.add(new ConquestReward(card, 0));
|
rewards.add(new ConquestReward(card, 0));
|
||||||
@@ -62,8 +66,34 @@ public class ConquestRewardDialog extends FScrollPane {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ScrollBounds layoutAndGetScrollBounds(float visibleWidth, float visibleHeight) {
|
protected ScrollBounds layoutAndGetScrollBounds(float visibleWidth, float visibleHeight) {
|
||||||
float y = 0;
|
float x = PADDING;
|
||||||
return new ScrollBounds(visibleWidth, y);
|
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
|
@Override
|
||||||
@@ -126,19 +156,25 @@ public class ConquestRewardDialog extends FScrollPane {
|
|||||||
private class RevealDialog extends FDialog {
|
private class RevealDialog extends FDialog {
|
||||||
private RevealDialog(String title) {
|
private RevealDialog(String title) {
|
||||||
super(title, 2);
|
super(title, 2);
|
||||||
|
|
||||||
|
add(ConquestRewardDialog.this);
|
||||||
|
|
||||||
initButton(0, "OK", new FEventHandler() {
|
initButton(0, "OK", new FEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(FEvent e) {
|
public void handleEvent(FEvent e) {
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setButtonEnabled(0, false); //disable OK button
|
|
||||||
initButton(1, "Skip", new FEventHandler() {
|
initButton(1, "Skip", new FEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(FEvent e) {
|
public void handleEvent(FEvent e) {
|
||||||
animation.skip();
|
animation.skip();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//disable both buttons initially
|
||||||
|
setButtonEnabled(0, false);
|
||||||
|
setButtonEnabled(1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -146,6 +182,16 @@ public class ConquestRewardDialog extends FScrollPane {
|
|||||||
ConquestRewardDialog.this.setBounds(0, 0, width, maxHeight);
|
ConquestRewardDialog.this.setBounds(0, 0, width, maxHeight);
|
||||||
return 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 {
|
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 static final float DUPLICATE_ALPHA_COMPOSITE = 0.35f;
|
||||||
|
|
||||||
private final ConquestReward reward;
|
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<PaperCard> cards = new ArrayList<PaperCard>();
|
||||||
|
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
|
@Override
|
||||||
public void draw(Graphics g) {
|
public void draw(Graphics g) {
|
||||||
float w = getWidth();
|
float w = getWidth();
|
||||||
|
|||||||
@@ -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 RevealAnimation activeRevealAnimation;
|
||||||
|
|
||||||
private class RevealAnimation extends ForgeAnimation {
|
private class RevealAnimation extends ForgeAnimation {
|
||||||
@@ -292,7 +296,10 @@ public abstract class FDialog extends FOverlay {
|
|||||||
@Override
|
@Override
|
||||||
protected void onEnd(boolean endingAll) {
|
protected void onEnd(boolean endingAll) {
|
||||||
activeRevealAnimation = null;
|
activeRevealAnimation = null;
|
||||||
finishedFirstReveal = true;
|
if (!finishedFirstReveal) {
|
||||||
|
finishedFirstReveal = true;
|
||||||
|
onRevealFinished();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user