Support showing zones on right side

This commit is contained in:
drdev
2015-05-24 22:02:25 +00:00
parent 72cfc3a379
commit 2dfa0b9d58
3 changed files with 50 additions and 10 deletions

View File

@@ -153,6 +153,9 @@ public abstract class VCardDisplayArea extends VDisplayArea implements ActivateH
protected float getCardWidth(float cardHeight) {
return (cardHeight - 2 * FCardPanel.PADDING) / FCardPanel.ASPECT_RATIO + 2 * FCardPanel.PADDING; //ensure aspect ratio maintained after padding applied
}
protected float getCardHeight(float cardWidth) {
return (cardWidth - 2 * FCardPanel.PADDING) * FCardPanel.ASPECT_RATIO + 2 * FCardPanel.PADDING; //ensure aspect ratio maintained after padding applied
}
@Override
protected ScrollBounds layoutAndGetScrollBounds(float visibleWidth, float visibleHeight) {

View File

@@ -21,6 +21,7 @@ import forge.model.FModel;
import forge.properties.ForgePreferences.FPref;
import forge.screens.match.MatchController;
import forge.screens.match.MatchScreen;
import forge.toolbox.FCardPanel;
import forge.toolbox.FContainer;
import forge.toolbox.FDisplayObject;
import forge.util.Utils;
@@ -267,18 +268,12 @@ public class VPlayerPanel extends FContainer {
phaseIndicator.resetFont();
phaseIndicator.setBounds(x, 0, avatar.getWidth() * 0.6f, height);
x += phaseIndicator.getWidth();
width -= x;
field.setBounds(x, 0, width, height);
field.setBounds(x, 0, width - x, height);
float displayAreaHeight = getHeight() / 3;
if (isFlipped()) {
y = 0;
}
else {
y = height - displayAreaHeight;
}
float displayAreaWidth = height / FCardPanel.ASPECT_RATIO;
x = width - displayAreaWidth;
for (InfoTab tab : tabs) {
tab.displayArea.setBounds(x, y, width, displayAreaHeight);
tab.displayArea.setBounds(x, 0, displayAreaWidth, height);
}
}

View File

@@ -2,6 +2,7 @@ package forge.screens.match.views;
import java.util.List;
import forge.Forge;
import forge.game.player.PlayerView;
import forge.game.zone.ZoneType;
import forge.toolbox.FCardPanel;
@@ -101,6 +102,10 @@ public class VZoneDisplay extends VCardDisplayArea {
orderedCards.clear();
if (Forge.isLandscapeMode()) {
return layoutAndGetScrollBoundsLandscape(visibleWidth, visibleHeight);
}
float x = 0;
float y = 0;
float cardHeight = visibleHeight;
@@ -129,4 +134,41 @@ public class VZoneDisplay extends VCardDisplayArea {
return new ScrollBounds(x, visibleHeight);
}
private ScrollBounds layoutAndGetScrollBoundsLandscape(float visibleWidth, float visibleHeight) {
float x = 0;
float y = 0;
float cardWidth = visibleWidth / 2;
float cardHeight = getCardHeight(cardWidth);
float dy = cardHeight;
int rowCount = (int)Math.ceil((float)cardPanels.size() / 2f);
float totalHeight = cardHeight * rowCount;
if (totalHeight > visibleHeight && totalHeight <= visibleHeight * 3) {
//allow overlapping cards up to one third of the card,
//otherwise don't overlap and allow scrolling vertically
dy *= (visibleHeight - cardHeight) / (totalHeight - cardHeight);
dy += FCardPanel.PADDING / rowCount; //make final card go right up to right edge of screen
if (revealedPanel == null) {
revealedPanel = cardPanels.get(cardPanels.size() - 1);
}
}
else {
revealedPanel = null;
}
for (CardAreaPanel cardPanel : cardPanels) {
orderedCards.add(cardPanel.getCard());
cardPanel.setBounds(x, y, cardWidth, cardHeight);
if (orderedCards.size() % 2 == 0) {
x = 0;
y += dy;
}
else {
x += cardWidth;
}
}
return new ScrollBounds(visibleWidth, cardHeight + (rowCount - 1) * dy);
}
}