mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
Flesh out info labels
This commit is contained in:
@@ -15,7 +15,7 @@ import forge.game.Match;
|
|||||||
import forge.game.player.RegisteredPlayer;
|
import forge.game.player.RegisteredPlayer;
|
||||||
|
|
||||||
public class MatchScreen extends FScreen {
|
public class MatchScreen extends FScreen {
|
||||||
private static FSkinColor BORDER_COLOR = FSkinColor.get(Colors.CLR_BORDERS);
|
public static FSkinColor BORDER_COLOR = FSkinColor.get(Colors.CLR_BORDERS);
|
||||||
|
|
||||||
private final Match match;
|
private final Match match;
|
||||||
private final Map<RegisteredPlayer, VPlayerPanel> playerPanels;
|
private final Map<RegisteredPlayer, VPlayerPanel> playerPanels;
|
||||||
|
|||||||
@@ -3,38 +3,72 @@ package forge.screens.match.views;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
||||||
|
|
||||||
import forge.Forge.Graphics;
|
import forge.Forge.Graphics;
|
||||||
|
import forge.assets.FSkinColor;
|
||||||
|
import forge.assets.FSkinFont;
|
||||||
|
import forge.assets.FSkinImage;
|
||||||
|
import forge.assets.FSkinColor.Colors;
|
||||||
import forge.game.player.RegisteredPlayer;
|
import forge.game.player.RegisteredPlayer;
|
||||||
import forge.game.zone.Zone;
|
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
|
import forge.screens.match.MatchScreen;
|
||||||
import forge.toolbox.FContainer;
|
import forge.toolbox.FContainer;
|
||||||
import forge.toolbox.FDisplayObject;
|
import forge.toolbox.FDisplayObject;
|
||||||
import forge.toolbox.FLabel;
|
import forge.utils.Utils;
|
||||||
|
|
||||||
public class VPlayerPanel extends FContainer {
|
public class VPlayerPanel extends FContainer {
|
||||||
|
private static final FSkinFont LIFE_FONT = FSkinFont.get(16);
|
||||||
|
private static final FSkinFont INFO_FONT = FSkinFont.get(12);
|
||||||
|
private static final FSkinColor INFO_FORE_COLOR = FSkinColor.get(Colors.CLR_TEXT);
|
||||||
|
|
||||||
private final RegisteredPlayer player;
|
private final RegisteredPlayer player;
|
||||||
private final VPhases phases;
|
private final VPhases phases;
|
||||||
private final VField field;
|
private final VField field;
|
||||||
private final VAvatar avatar;
|
private final VAvatar avatar;
|
||||||
private final List<StatLabel> statLabels = new ArrayList<StatLabel>();
|
private final List<InfoLabel> infoLabels = new ArrayList<InfoLabel>();
|
||||||
private final List<VZoneDisplay> zones = new ArrayList<VZoneDisplay>();
|
private final List<VZoneDisplay> zones = new ArrayList<VZoneDisplay>();
|
||||||
|
private VZoneDisplay selectedZone;
|
||||||
|
|
||||||
public VPlayerPanel(RegisteredPlayer player0) {
|
public VPlayerPanel(RegisteredPlayer player0) {
|
||||||
player = player0;
|
player = player0;
|
||||||
phases = add(new VPhases());
|
phases = add(new VPhases());
|
||||||
field = add(new VField());
|
field = add(new VField());
|
||||||
avatar = add(new VAvatar(player.getPlayer().getAvatarIndex()));
|
avatar = add(new VAvatar(player.getPlayer().getAvatarIndex()));
|
||||||
addZoneDisplay(ZoneType.Hand);
|
infoLabels.add(add(new LifeLabel()));
|
||||||
addZoneDisplay(ZoneType.Library);
|
addZoneDisplay(ZoneType.Hand, FSkinImage.HAND);
|
||||||
addZoneDisplay(ZoneType.Graveyard);
|
addZoneDisplay(ZoneType.Graveyard, FSkinImage.GRAVEYARD);
|
||||||
addZoneDisplay(ZoneType.Exile);
|
addZoneDisplay(ZoneType.Library, FSkinImage.LIBRARY);
|
||||||
|
addZoneDisplay(ZoneType.Exile, FSkinImage.EXILE);
|
||||||
|
|
||||||
|
setSelectedZone(ZoneType.Hand);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addZoneDisplay(ZoneType zoneType) {
|
public void addZoneDisplay(ZoneType zoneType, FSkinImage tabIcon) {
|
||||||
zones.add(add(new VZoneDisplay(zoneType)));
|
VZoneDisplay zone = add(new VZoneDisplay(zoneType));
|
||||||
statLabels.add(add(new StatLabel()));
|
zone.setVisible(false);
|
||||||
|
zones.add(zone);
|
||||||
|
infoLabels.add(add(new ZoneInfoTab(tabIcon, zone)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ZoneType getSelectedZone() {
|
||||||
|
if (selectedZone != null) {
|
||||||
|
return selectedZone.getZoneType();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelectedZone(ZoneType zoneType) {
|
||||||
|
for (VZoneDisplay zone : zones) {
|
||||||
|
if (zone.getZoneType() == zoneType) {
|
||||||
|
if (selectedZone != null) {
|
||||||
|
selectedZone.setVisible(false);
|
||||||
|
}
|
||||||
|
selectedZone = zone;
|
||||||
|
selectedZone.setVisible(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFlipped() {
|
public boolean isFlipped() {
|
||||||
@@ -63,10 +97,12 @@ public class VPlayerPanel extends FContainer {
|
|||||||
|
|
||||||
y = height - VAvatar.HEIGHT;
|
y = height - VAvatar.HEIGHT;
|
||||||
avatar.setPosition(0, y);
|
avatar.setPosition(0, y);
|
||||||
float statLabelSize = VAvatar.HEIGHT - VPhases.HEIGHT;
|
float infoLabelWidth;
|
||||||
for (StatLabel statLabel : statLabels) {
|
float infoLabelHeight = VAvatar.HEIGHT - VPhases.HEIGHT;
|
||||||
statLabel.setBounds(x, y, statLabelSize, statLabelSize);
|
for (InfoLabel infoLabel : infoLabels) {
|
||||||
x += statLabelSize;
|
infoLabelWidth = infoLabel.getPreferredWidth();
|
||||||
|
infoLabel.setBounds(x, y, infoLabelWidth, infoLabelHeight);
|
||||||
|
x += infoLabelWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
field.setBounds(0, 0, width, y - zoneHeight);
|
field.setBounds(0, 0, width, y - zoneHeight);
|
||||||
@@ -78,17 +114,62 @@ public class VPlayerPanel extends FContainer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class StatLabel extends FDisplayObject {
|
private abstract class InfoLabel extends FDisplayObject {
|
||||||
private StatLabel() {
|
protected static final float PADDING = 2;
|
||||||
|
protected String value;
|
||||||
|
public abstract float getPreferredWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class LifeLabel extends InfoLabel {
|
||||||
|
private LifeLabel() {
|
||||||
|
value = "20";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getPreferredWidth() {
|
||||||
|
return Utils.AVG_FINGER_WIDTH * 0.75f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Graphics g) {
|
public void draw(Graphics g) {
|
||||||
float x = 1;
|
g.drawText(value, LIFE_FONT, INFO_FORE_COLOR, PADDING, 0, getWidth(), getHeight(), false, HAlignment.LEFT, true);
|
||||||
float w = getWidth() - 2;
|
}
|
||||||
float h = getHeight() - 1;
|
}
|
||||||
g.fillRect(Color.ORANGE, x, 0, w, h);
|
|
||||||
|
private class ZoneInfoTab extends InfoLabel {
|
||||||
|
private final FSkinImage icon;
|
||||||
|
private final VZoneDisplay zoneToOpen;
|
||||||
|
|
||||||
|
private ZoneInfoTab(FSkinImage icon0, VZoneDisplay zoneToOpen0) {
|
||||||
|
icon = icon0;
|
||||||
|
zoneToOpen = zoneToOpen0;
|
||||||
|
value = "99";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getPreferredWidth() {
|
||||||
|
return Utils.AVG_FINGER_WIDTH * 1.15f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Graphics g) {
|
||||||
|
float padding = 2;
|
||||||
|
float h = getHeight() * 0.7f;
|
||||||
|
float w = h;
|
||||||
|
float x = padding;
|
||||||
|
float y = (getHeight() - h) / 2;
|
||||||
|
g.drawImage(icon, x, y, w, h);
|
||||||
|
|
||||||
|
x += w * 1.05f;
|
||||||
|
g.drawText(value, INFO_FONT, INFO_FORE_COLOR, x, padding, getWidth() - x, getHeight(), false, HAlignment.LEFT, true);
|
||||||
|
|
||||||
|
if (selectedZone == zoneToOpen) {
|
||||||
|
w = getWidth();
|
||||||
|
h = getHeight();
|
||||||
|
g.drawLine(1, MatchScreen.BORDER_COLOR, 0, 0, 0, h);
|
||||||
|
g.drawLine(1, MatchScreen.BORDER_COLOR, 0, h, w, h);
|
||||||
|
g.drawLine(1, MatchScreen.BORDER_COLOR, w, h, w, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.zone.Zone;
|
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.model.FModel;
|
import forge.model.FModel;
|
||||||
import forge.toolbox.FCardPanel;
|
import forge.toolbox.FCardPanel;
|
||||||
@@ -24,6 +23,10 @@ public class VZoneDisplay extends FScrollPane {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ZoneType getZoneType() {
|
||||||
|
return zoneType;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doLayout(float width, float height) {
|
protected void doLayout(float width, float height) {
|
||||||
float x = 0;
|
float x = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user