Improve match layout and background

This commit is contained in:
drdev
2014-03-07 02:54:44 +00:00
parent 096ea8c62d
commit 7476e386c2
6 changed files with 34 additions and 55 deletions

View File

@@ -14,8 +14,7 @@ import forge.toolbox.FLabel;
import forge.utils.Utils; import forge.utils.Utils;
public abstract class FScreen extends FContainer { public abstract class FScreen extends FContainer {
public static final float BTN_HEIGHT = Math.round(Utils.AVG_FINGER_HEIGHT * 0.8f); public static final float HEADER_HEIGHT = Math.round(Utils.AVG_FINGER_HEIGHT * 0.8f);
public static final float BTN_WIDTH = BTN_HEIGHT;
private static final FSkinColor clrTheme = FSkinColor.get(Colors.CLR_THEME); private static final FSkinColor clrTheme = FSkinColor.get(Colors.CLR_THEME);
private static final FSkinColor clr = clrTheme.stepColor(0); private static final FSkinColor clr = clrTheme.stepColor(0);
@@ -77,20 +76,19 @@ public abstract class FScreen extends FContainer {
@Override @Override
protected final void doLayout(float width, float height) { protected final void doLayout(float width, float height) {
float headerX = BTN_WIDTH; float headerX = HEADER_HEIGHT;
float headerWidth = width - 2 * headerX; float headerWidth = width - 2 * headerX;
float headerHeight = BTN_HEIGHT;
if (btnBack != null) { if (btnBack != null) {
btnBack.setBounds(0, 0, BTN_WIDTH, BTN_HEIGHT); btnBack.setBounds(0, 0, HEADER_HEIGHT, HEADER_HEIGHT);
} }
if (btnMenu != null) { if (btnMenu != null) {
btnMenu.setBounds(width - BTN_WIDTH, 0, BTN_WIDTH, BTN_HEIGHT); btnMenu.setBounds(width - HEADER_HEIGHT, 0, HEADER_HEIGHT, HEADER_HEIGHT);
} }
if (lblHeader != null) { if (lblHeader != null) {
lblHeader.setBounds(headerX, 0, headerWidth, headerHeight); lblHeader.setBounds(headerX, 0, headerWidth, HEADER_HEIGHT);
doLayout(headerHeight, width, height); doLayout(HEADER_HEIGHT, width, height);
} }
else { else {
doLayout(0, width, height); doLayout(0, width, height);
@@ -107,8 +105,8 @@ public abstract class FScreen extends FContainer {
g.fillRect(clrTheme, 0, 0, w, h); g.fillRect(clrTheme, 0, 0, w, h);
if (lblHeader != null) { //draw custom background behind header label if (lblHeader != null) { //draw custom background behind header label
g.fillRect(d80, 0, 0, w, BTN_HEIGHT); g.fillRect(d80, 0, 0, w, HEADER_HEIGHT);
g.drawLine(1, d40, 0, BTN_HEIGHT, w, BTN_HEIGHT); g.drawLine(1, d40, 0, HEADER_HEIGHT, w, HEADER_HEIGHT);
} }
} }
@@ -118,12 +116,12 @@ public abstract class FScreen extends FContainer {
@Override @Override
public float getWidth() { public float getWidth() {
return BTN_WIDTH; return HEADER_HEIGHT;
} }
@Override @Override
public float getHeight() { public float getHeight() {
return BTN_HEIGHT; return HEADER_HEIGHT;
} }
@Override @Override

View File

@@ -4,10 +4,11 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import forge.screens.FScreen; import forge.screens.FScreen;
import forge.screens.match.views.VLog;
import forge.screens.match.views.VPlayerPanel; import forge.screens.match.views.VPlayerPanel;
import forge.screens.match.views.VPrompt; import forge.screens.match.views.VPrompt;
import forge.screens.match.views.VStack; import forge.screens.match.views.VStack;
import forge.Forge.Graphics;
import forge.assets.FSkinTexture;
import forge.game.Match; import forge.game.Match;
import forge.game.player.RegisteredPlayer; import forge.game.player.RegisteredPlayer;
@@ -15,14 +16,14 @@ public class MatchScreen extends FScreen {
private final Match match; private final Match match;
private final MatchController controller; private final MatchController controller;
private final Map<RegisteredPlayer, VPlayerPanel> playerPanels; private final Map<RegisteredPlayer, VPlayerPanel> playerPanels;
private final VLog log; //private final VLog log;
private final VStack stack; private final VStack stack;
private final VPrompt prompt; private final VPrompt prompt;
private VPlayerPanel bottomPlayerPanel, topPlayerPanel; private VPlayerPanel bottomPlayerPanel, topPlayerPanel;
public MatchScreen(Match match0) { public MatchScreen(Match match0) {
super(false, null, true); super(true, "Game 1 Turn 1", true);
match = match0; match = match0;
controller = new MatchController(this); controller = new MatchController(this);
@@ -34,7 +35,7 @@ public class MatchScreen extends FScreen {
topPlayerPanel = playerPanels.get(match.getPlayers().get(1)); topPlayerPanel = playerPanels.get(match.getPlayers().get(1));
topPlayerPanel.setFlipped(true); topPlayerPanel.setFlipped(true);
log = add(new VLog()); //log = add(new VLog());
stack = add(new VStack()); stack = add(new VStack());
prompt = add(new VPrompt()); prompt = add(new VPrompt());
@@ -42,12 +43,18 @@ public class MatchScreen extends FScreen {
} }
@Override @Override
protected void doLayout(float startY, float width, float height) { public void drawBackground(Graphics g) {
float playerPanelHeight = (height - startY - VPrompt.HEIGHT - VLog.HEIGHT) / 2f; super.drawBackground(g);
g.drawImage(FSkinTexture.BG_MATCH, 0, topPlayerPanel.getTop(), getWidth(), bottomPlayerPanel.getBottom() - topPlayerPanel.getTop());
}
log.setBounds(0, startY, width - FScreen.BTN_WIDTH, VLog.HEIGHT); @Override
topPlayerPanel.setBounds(0, startY + VLog.HEIGHT, width, playerPanelHeight); protected void doLayout(float startY, float width, float height) {
stack.setBounds(0, startY + VLog.HEIGHT + playerPanelHeight - VStack.HEIGHT / 2, VStack.WIDTH, VStack.HEIGHT); float playerPanelHeight = (height - startY - VPrompt.HEIGHT) / 2f;
//log.setBounds(0, startY, width - FScreen.HEADER_HEIGHT, VLog.HEIGHT);
topPlayerPanel.setBounds(0, startY, width, playerPanelHeight);
stack.setBounds(0, startY + playerPanelHeight - VStack.HEIGHT / 2, VStack.WIDTH, VStack.HEIGHT);
bottomPlayerPanel.setBounds(0, height - VPrompt.HEIGHT - playerPanelHeight, width, playerPanelHeight); bottomPlayerPanel.setBounds(0, height - VPrompt.HEIGHT - playerPanelHeight, width, playerPanelHeight);
prompt.setBounds(0, height - VPrompt.HEIGHT, width, VPrompt.HEIGHT); prompt.setBounds(0, height - VPrompt.HEIGHT, width, VPrompt.HEIGHT);
} }

View File

@@ -26,8 +26,5 @@ public class VField extends FContainer {
@Override @Override
protected void drawBackground(Graphics g) { protected void drawBackground(Graphics g) {
float w = getWidth();
float h = getHeight();
g.drawImage(FSkinTexture.BG_MATCH, 0, 0, w, h);
} }
} }

View File

@@ -1,24 +1,12 @@
package forge.screens.match.views; package forge.screens.match.views;
import com.badlogic.gdx.graphics.Color;
import forge.Forge.Graphics;
import forge.screens.FScreen; import forge.screens.FScreen;
import forge.toolbox.FContainer; import forge.toolbox.FContainer;
public class VLog extends FContainer { public class VLog extends FContainer {
public static final float HEIGHT = FScreen.BTN_HEIGHT; //TODO: Consider changing this
@Override @Override
protected void doLayout(float width, float height) { protected void doLayout(float width, float height) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
@Override
protected void drawBackground(Graphics g) {
float w = getWidth();
float h = getHeight();
g.fillRect(Color.MAGENTA, 0, 0, w, h);
}
} }

View File

@@ -15,7 +15,7 @@ import forge.toolbox.FContainer;
import forge.toolbox.FDisplayObject; import forge.toolbox.FDisplayObject;
public class VPhases extends FContainer { public class VPhases extends FContainer {
private static final FSkinFont labelFont = FSkinFont.get(12); private static final FSkinFont labelFont = FSkinFont.get(11);
private final Map<PhaseType, PhaseLabel> phaseLabels = new HashMap<PhaseType, PhaseLabel>(); private final Map<PhaseType, PhaseLabel> phaseLabels = new HashMap<PhaseType, PhaseLabel>();
@@ -23,15 +23,15 @@ public class VPhases extends FContainer {
addPhaseLabel("UP", PhaseType.UPKEEP); addPhaseLabel("UP", PhaseType.UPKEEP);
addPhaseLabel("DR", PhaseType.DRAW); addPhaseLabel("DR", PhaseType.DRAW);
addPhaseLabel("M1", PhaseType.MAIN1); addPhaseLabel("M1", PhaseType.MAIN1);
addPhaseLabel("M2", PhaseType.MAIN2);
addPhaseLabel("ET", PhaseType.END_OF_TURN);
addPhaseLabel("CL", PhaseType.CLEANUP);
addPhaseLabel("BC", PhaseType.COMBAT_BEGIN); addPhaseLabel("BC", PhaseType.COMBAT_BEGIN);
addPhaseLabel("DA", PhaseType.COMBAT_DECLARE_ATTACKERS); addPhaseLabel("DA", PhaseType.COMBAT_DECLARE_ATTACKERS);
addPhaseLabel("DB", PhaseType.COMBAT_DECLARE_BLOCKERS); addPhaseLabel("DB", PhaseType.COMBAT_DECLARE_BLOCKERS);
addPhaseLabel("FS", PhaseType.COMBAT_FIRST_STRIKE_DAMAGE); addPhaseLabel("FS", PhaseType.COMBAT_FIRST_STRIKE_DAMAGE);
addPhaseLabel("CD", PhaseType.COMBAT_DAMAGE); addPhaseLabel("CD", PhaseType.COMBAT_DAMAGE);
addPhaseLabel("EC", PhaseType.COMBAT_END); addPhaseLabel("EC", PhaseType.COMBAT_END);
addPhaseLabel("M2", PhaseType.MAIN2);
addPhaseLabel("ET", PhaseType.END_OF_TURN);
addPhaseLabel("CL", PhaseType.CLEANUP);
} }
private void addPhaseLabel(String caption, PhaseType phaseType) { private void addPhaseLabel(String caption, PhaseType phaseType) {
@@ -47,20 +47,14 @@ public class VPhases extends FContainer {
@Override @Override
protected void doLayout(float width, float height) { protected void doLayout(float width, float height) {
float y = 0; float y = 0;
float w = width - 2; w/=2;
float labelHeight = height / phaseLabels.size(); float labelHeight = height / phaseLabels.size();
for (FDisplayObject lbl : getChildren()) { for (FDisplayObject lbl : getChildren()) {
lbl.setBounds(0, y, width, labelHeight); lbl.setBounds(1, y + 1, w, labelHeight - 1);
y += labelHeight; y += labelHeight;
} }
} }
@Override
protected void drawBackground(Graphics g) {
float w = getWidth();
float h = getHeight();
g.fillRect(Color.CYAN, 0, 0, w, h);
}
private class PhaseLabel extends FDisplayObject { private class PhaseLabel extends FDisplayObject {
private final String caption; private final String caption;
private final PhaseType phaseType; private final PhaseType phaseType;
@@ -113,8 +107,8 @@ public class VPhases extends FContainer {
} }
// Center vertically and horizontally. Show border if active. // Center vertically and horizontally. Show border if active.
//g.fillRoundRect(1, 1, w - 2, h - 2, 5, 5); //g.fillRoundRect(0, 0, w, h, 5, 5);
g.fillRect(c, 1, 1, w - 2, h - 2); g.fillRect(c, 0, 0, w, h);
g.drawText(caption, labelFont, Color.BLACK, 0, 0, w, h, false, HAlignment.CENTER, true); g.drawText(caption, labelFont, Color.BLACK, 0, 0, w, h, false, HAlignment.CENTER, true);
} }
} }

View File

@@ -1,7 +1,5 @@
package forge.screens.match.views; package forge.screens.match.views;
import com.badlogic.gdx.graphics.Color;
import forge.Forge.Graphics; import forge.Forge.Graphics;
import forge.toolbox.FContainer; import forge.toolbox.FContainer;
import forge.utils.Utils; import forge.utils.Utils;
@@ -22,8 +20,5 @@ public class VStack extends FContainer {
@Override @Override
protected void drawBackground(Graphics g) { protected void drawBackground(Graphics g) {
float w = getWidth();
float h = getHeight();
g.fillRect(Color.BLUE, 0, 0, w, h);
} }
} }