mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Add button to AEther screen
This commit is contained in:
@@ -1,5 +1,10 @@
|
|||||||
package forge.screens.planarconquest;
|
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.deck.CardPool;
|
||||||
import forge.item.PaperCard;
|
import forge.item.PaperCard;
|
||||||
import forge.itemmanager.CardManager;
|
import forge.itemmanager.CardManager;
|
||||||
@@ -13,9 +18,18 @@ import forge.planarconquest.ConquestController;
|
|||||||
import forge.planarconquest.ConquestData;
|
import forge.planarconquest.ConquestData;
|
||||||
import forge.planarconquest.ConquestPlane;
|
import forge.planarconquest.ConquestPlane;
|
||||||
import forge.screens.FScreen;
|
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 {
|
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 AEtherManager lstAEther = add(new AEtherManager());
|
||||||
|
private final FLabel btnPull = add(new PullButton());
|
||||||
|
|
||||||
|
private int shardCost;
|
||||||
|
|
||||||
public ConquestAEtherScreen() {
|
public ConquestAEtherScreen() {
|
||||||
super("", ConquestMenu.getMenu());
|
super("", ConquestMenu.getMenu());
|
||||||
@@ -40,14 +54,20 @@ public class ConquestAEtherScreen extends FScreen {
|
|||||||
lstAEther.setPool(pool, true);
|
lstAEther.setPool(pool, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void calculateShardCost() {
|
||||||
|
shardCost = 100;
|
||||||
|
btnPull.setText(String.valueOf(shardCost));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doLayout(float startY, float width, float height) {
|
protected void doLayout(float startY, float width, float height) {
|
||||||
float x = ItemFilter.PADDING;
|
float x = ItemFilter.PADDING;
|
||||||
float w = width - 2 * x;
|
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() {
|
public AEtherManager() {
|
||||||
super(false);
|
super(false);
|
||||||
setCaption("The AEther");
|
setCaption("The AEther");
|
||||||
@@ -59,5 +79,34 @@ public class ConquestAEtherScreen extends FScreen {
|
|||||||
addFilter(new CardRarityFilter(this));
|
addFilter(new CardRarityFilter(this));
|
||||||
addFilter(new CardTypeFilter(this));
|
addFilter(new CardTypeFilter(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateView(final boolean forceFilter, final Iterable<PaperCard> 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -313,8 +313,12 @@ public class FLabel extends FDisplayObject implements IButton {
|
|||||||
x += Utils.scale(1);
|
x += Utils.scale(1);
|
||||||
y += 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) {
|
if (icon != null) {
|
||||||
|
float textY = y;
|
||||||
float iconWidth = icon.getWidth();
|
float iconWidth = icon.getWidth();
|
||||||
float iconHeight = icon.getHeight();
|
float iconHeight = icon.getHeight();
|
||||||
float aspectRatio = iconWidth / iconHeight;
|
float aspectRatio = iconWidth / iconHeight;
|
||||||
@@ -367,14 +371,9 @@ public class FLabel extends FDisplayObject implements IButton {
|
|||||||
g.drawImage(icon, x, y, iconWidth, iconHeight);
|
g.drawImage(icon, x, y, iconWidth, iconHeight);
|
||||||
|
|
||||||
if (!text.isEmpty()) {
|
if (!text.isEmpty()) {
|
||||||
y = insets.y;
|
|
||||||
if (pressed) {
|
|
||||||
y++;
|
|
||||||
}
|
|
||||||
x += iconOffset;
|
x += iconOffset;
|
||||||
w -= iconOffset;
|
w -= iconOffset;
|
||||||
|
drawText(g, x, textY, w, h, HAlignment.LEFT);
|
||||||
drawText(g, x, y, w, h, HAlignment.LEFT);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!text.isEmpty()) {
|
else if (!text.isEmpty()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user