Files
forge/forge-gui-mobile/src/forge/card/CardZoom.java
drdev 89fd88ad1d Allow all overlays to face top human player if needed
Allow top human player to concede
2014-09-30 18:23:42 +00:00

103 lines
3.1 KiB
Java

package forge.card;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import forge.Graphics;
import forge.assets.FSkinColor;
import forge.assets.FSkinFont;
import forge.item.IPaperCard;
import forge.toolbox.FList;
import forge.toolbox.FOverlay;
import forge.util.Utils;
import forge.view.CardView;
import forge.view.ViewUtil;
public class CardZoom extends FOverlay {
private static final float TAB_HEIGHT = Utils.AVG_FINGER_HEIGHT;
private static final FSkinFont FONT = FSkinFont.get(14);
private static final CardZoom cardZoom = new CardZoom();
private static CardView card;
private static boolean zoomMode = true;
public static <T> void show(final IPaperCard pc0) {
card = ViewUtil.getCardForUi(pc0);
cardZoom.show();
}
public static <T> void show(final CardView card0) {
card = card0;
cardZoom.show();
}
public static boolean isOpen() {
return cardZoom.isVisible();
}
public static void hideZoom() {
cardZoom.hide();
}
private CardZoom() {
}
@Override
public boolean tap(float x, float y, int count) {
if (y >= getHeight() - TAB_HEIGHT && zoomMode != (x < getWidth() / 2)) {
zoomMode = !zoomMode; //handle toggling between zoom and details
return true;
}
hide(); //hide if uncovered area tapped
return true;
}
@Override
public boolean fling(float velocityX, float velocityY) {
//toggle between Zoom and Details with a quick horizontal fling action
if (Math.abs(velocityX) > Math.abs(velocityY)) {
zoomMode = !zoomMode;
return true;
}
return false;
}
@Override
public void drawOverlay(Graphics g) {
float w = getWidth();
float h = TAB_HEIGHT;
float x = w / 2;
float y = getHeight() - h;
//draw zoom/details options
FSkinColor foreColor;
if (zoomMode) {
if (!CardRenderer.drawZoom(g, card, w, y)) {
CardRenderer.drawDetails(g, card, w, y); //draw details if can't draw zoom
}
g.fillRect(FList.PRESSED_COLOR, 0, y, x, h);
foreColor = FList.FORE_COLOR;
}
else {
foreColor = FList.FORE_COLOR.alphaColor(ALPHA_COMPOSITE);
}
g.drawText("Zoom", FONT, foreColor, 0, y, x, h, false, HAlignment.CENTER, true);
if (!zoomMode) {
CardRenderer.drawDetails(g, card, w, y);
g.fillRect(FList.PRESSED_COLOR, x, y, w - x, h);
foreColor = FList.FORE_COLOR;
}
else {
foreColor = FList.FORE_COLOR.alphaColor(ALPHA_COMPOSITE);
}
g.drawText("Details", FONT, foreColor, x, y, w - x, h, false, HAlignment.CENTER, true);
g.drawLine(1, FList.LINE_COLOR, 0, y, w, y);
g.drawLine(1, FList.LINE_COLOR, x, y, x, y + h);
y += h;
g.drawLine(1, FList.LINE_COLOR, 0, y, w, y);
}
@Override
protected void doLayout(float width, float height) {
}
}