From 2dfa0b9d58e9e90eb2dc0a8a9c2758551f85c74a Mon Sep 17 00:00:00 2001 From: drdev Date: Sun, 24 May 2015 22:02:25 +0000 Subject: [PATCH] Support showing zones on right side --- .../screens/match/views/VCardDisplayArea.java | 3 ++ .../screens/match/views/VPlayerPanel.java | 15 +++---- .../screens/match/views/VZoneDisplay.java | 42 +++++++++++++++++++ 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/forge-gui-mobile/src/forge/screens/match/views/VCardDisplayArea.java b/forge-gui-mobile/src/forge/screens/match/views/VCardDisplayArea.java index 5b7942c8331..d97f1abed41 100644 --- a/forge-gui-mobile/src/forge/screens/match/views/VCardDisplayArea.java +++ b/forge-gui-mobile/src/forge/screens/match/views/VCardDisplayArea.java @@ -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) { diff --git a/forge-gui-mobile/src/forge/screens/match/views/VPlayerPanel.java b/forge-gui-mobile/src/forge/screens/match/views/VPlayerPanel.java index 1c0911807a0..808985323c0 100644 --- a/forge-gui-mobile/src/forge/screens/match/views/VPlayerPanel.java +++ b/forge-gui-mobile/src/forge/screens/match/views/VPlayerPanel.java @@ -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); } } diff --git a/forge-gui-mobile/src/forge/screens/match/views/VZoneDisplay.java b/forge-gui-mobile/src/forge/screens/match/views/VZoneDisplay.java index ba6ca5f9d8e..549f66c287f 100644 --- a/forge-gui-mobile/src/forge/screens/match/views/VZoneDisplay.java +++ b/forge-gui-mobile/src/forge/screens/match/views/VZoneDisplay.java @@ -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); + } }