From c3feb79f42ac79175b750114ce5207f5848c05be Mon Sep 17 00:00:00 2001 From: drdev Date: Sun, 13 Dec 2015 04:14:40 +0000 Subject: [PATCH] Add button to AEther screen --- .../planarconquest/ConquestAEtherScreen.java | 53 ++++++++++++++++++- .../src/forge/toolbox/FLabel.java | 11 ++-- 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java b/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java index f05134bb3fe..495f7f331c7 100644 --- a/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java +++ b/forge-gui-mobile/src/forge/screens/planarconquest/ConquestAEtherScreen.java @@ -1,5 +1,10 @@ package forge.screens.planarconquest; +import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment; + +import forge.Graphics; +import forge.assets.FSkinFont; +import forge.assets.FSkinImage; import forge.deck.CardPool; import forge.item.PaperCard; import forge.itemmanager.CardManager; @@ -13,9 +18,18 @@ import forge.planarconquest.ConquestController; import forge.planarconquest.ConquestData; import forge.planarconquest.ConquestPlane; import forge.screens.FScreen; +import forge.toolbox.FEvent; +import forge.toolbox.FLabel; +import forge.toolbox.FEvent.FEventHandler; +import forge.util.Utils; public class ConquestAEtherScreen extends FScreen { + private static final float PULL_BTN_HEIGHT = 1.2f * Utils.AVG_FINGER_HEIGHT; + private final AEtherManager lstAEther = add(new AEtherManager()); + private final FLabel btnPull = add(new PullButton()); + + private int shardCost; public ConquestAEtherScreen() { super("", ConquestMenu.getMenu()); @@ -40,14 +54,20 @@ public class ConquestAEtherScreen extends FScreen { lstAEther.setPool(pool, true); } + private void calculateShardCost() { + shardCost = 100; + btnPull.setText(String.valueOf(shardCost)); + } + @Override protected void doLayout(float startY, float width, float height) { float x = ItemFilter.PADDING; float w = width - 2 * x; - lstAEther.setBounds(x, startY, w, height - startY - ItemFilter.PADDING); + lstAEther.setBounds(x, startY, w, height - startY - PULL_BTN_HEIGHT - 2 * ItemFilter.PADDING); + btnPull.setBounds(x, height - PULL_BTN_HEIGHT - ItemFilter.PADDING, w, PULL_BTN_HEIGHT); } - private static class AEtherManager extends CardManager { + private class AEtherManager extends CardManager { public AEtherManager() { super(false); setCaption("The AEther"); @@ -59,5 +79,34 @@ public class ConquestAEtherScreen extends FScreen { addFilter(new CardRarityFilter(this)); addFilter(new CardTypeFilter(this)); } + + @Override + public void updateView(final boolean forceFilter, final Iterable itemsToSelect) { + super.updateView(forceFilter, itemsToSelect); + calculateShardCost(); + } + } + + private class PullButton extends FLabel { + protected PullButton() { + super(new FLabel.ButtonBuilder().font(FSkinFont.forHeight(PULL_BTN_HEIGHT * 0.45f)) + .icon(FSkinImage.QUEST_COIN).iconScaleFactor(1f).command(new FEventHandler() { + @Override + public void handleEvent(FEvent e) { + } + })); + } + + @Override + protected void drawContent(Graphics g, float x, float y, float w, float h) { + FSkinFont font = getFont(); + float textHeight = font.getCapHeight() * 1.25f; + y += h / 2 - textHeight; + g.drawText("Pull from the AEther", font, getTextColor(), x, y, w, textHeight, false, HAlignment.CENTER, false); + y += textHeight; + + //draw shard icon and cost + super.drawContent(g, x, y, w, textHeight * 1.25f); + } } } diff --git a/forge-gui-mobile/src/forge/toolbox/FLabel.java b/forge-gui-mobile/src/forge/toolbox/FLabel.java index 24784b723d2..19031b363d3 100644 --- a/forge-gui-mobile/src/forge/toolbox/FLabel.java +++ b/forge-gui-mobile/src/forge/toolbox/FLabel.java @@ -313,8 +313,12 @@ public class FLabel extends FDisplayObject implements IButton { x += Utils.scale(1); y += Utils.scale(1); } + drawContent(g, x, y, w, h); + } + protected void drawContent(Graphics g, float x, float y, float w, float h) { if (icon != null) { + float textY = y; float iconWidth = icon.getWidth(); float iconHeight = icon.getHeight(); float aspectRatio = iconWidth / iconHeight; @@ -367,14 +371,9 @@ public class FLabel extends FDisplayObject implements IButton { g.drawImage(icon, x, y, iconWidth, iconHeight); if (!text.isEmpty()) { - y = insets.y; - if (pressed) { - y++; - } x += iconOffset; w -= iconOffset; - - drawText(g, x, y, w, h, HAlignment.LEFT); + drawText(g, x, textY, w, h, HAlignment.LEFT); } } else if (!text.isEmpty()) {