replace the up/down arrow with the actual avatar of the player whose turn it is
parent
617eb69c27
commit
0948d9b8d4
|
@ -8,10 +8,12 @@ public class PlayerAvatar {
|
|||
private static final int LARGE_SIZE = 120;
|
||||
private static final int MEDIUM_SIZE = LARGE_SIZE/2;
|
||||
private static final int SMALL_SIZE = LARGE_SIZE/4;
|
||||
private static final int CUSTOM_SIZE = 40;
|
||||
|
||||
private final ImageIcon largeIcon;
|
||||
private final ImageIcon mediumIcon;
|
||||
private final ImageIcon smallIcon;
|
||||
private final ImageIcon turnIcon;
|
||||
|
||||
public PlayerAvatar(final BufferedImage image) {
|
||||
largeIcon = new ImageIcon(magic.GraphicsUtilities.scale(
|
||||
|
@ -20,6 +22,8 @@ public class PlayerAvatar {
|
|||
image,MEDIUM_SIZE,MEDIUM_SIZE));
|
||||
smallIcon = new ImageIcon(magic.GraphicsUtilities.scale(
|
||||
image,SMALL_SIZE,SMALL_SIZE));
|
||||
turnIcon = new ImageIcon(magic.GraphicsUtilities.scale(
|
||||
image,CUSTOM_SIZE,CUSTOM_SIZE));
|
||||
}
|
||||
|
||||
public ImageIcon getIcon(final int size) {
|
||||
|
@ -27,6 +31,7 @@ public class PlayerAvatar {
|
|||
case 1: return smallIcon;
|
||||
case 2: return mediumIcon;
|
||||
case 3: return largeIcon;
|
||||
case 4: return turnIcon;
|
||||
default: throw new RuntimeException("PlayerAvatar.getIcon: invalid size " + size);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,16 +5,17 @@ import magic.model.MagicDuel;
|
|||
import magic.ui.theme.Theme;
|
||||
import magic.ui.theme.ThemeFactory;
|
||||
import magic.ui.widget.FontsAndBorders;
|
||||
import magic.ui.widget.TexturedPanel;
|
||||
import magic.ui.widget.TitleBar;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
|
||||
public class DuelViewer extends TexturedPanel {
|
||||
public class DuelViewer extends JPanel {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -43,7 +44,7 @@ public class DuelViewer extends TexturedPanel {
|
|||
|
||||
final JPanel mainPanel=new JPanel(new BorderLayout(0,5));
|
||||
mainPanel.setOpaque(false);
|
||||
mainPanel.setBorder(FontsAndBorders.BLACK_BORDER_2);
|
||||
mainPanel.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 1, Color.BLACK));
|
||||
|
||||
if (duel.isFinished()) {
|
||||
final JLabel finishedLabel=new JLabel("Finished!");
|
||||
|
|
|
@ -4,9 +4,11 @@ import magic.data.IconImages;
|
|||
import magic.model.MagicGame;
|
||||
import magic.ui.GameController;
|
||||
import magic.ui.widget.TabSelector;
|
||||
import magic.ui.widget.TexturedPanel;
|
||||
import magic.ui.widget.TitleBar;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
@ -15,7 +17,7 @@ import java.awt.BorderLayout;
|
|||
import java.awt.CardLayout;
|
||||
import java.awt.Color;
|
||||
|
||||
public class GameDuelViewer extends JPanel implements ChangeListener {
|
||||
public class GameDuelViewer extends TexturedPanel implements ChangeListener {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -26,24 +28,28 @@ public class GameDuelViewer extends JPanel implements ChangeListener {
|
|||
private final TitleBar titleBar;
|
||||
private final TabSelector tabSelector;
|
||||
private final PhaseStepViewer phaseStepViewer;
|
||||
private final JLabel playerAvatar = new JLabel();
|
||||
|
||||
public GameDuelViewer(final MagicGame game,final GameController controller) {
|
||||
gameViewer=new GameViewer(game,controller);
|
||||
duelViewer=new DuelViewer(game.getDuel());
|
||||
gameViewer.setOpaque(false);
|
||||
duelViewer.setOpaque(false);
|
||||
|
||||
phaseStepViewer = new PhaseStepViewer();
|
||||
phaseStepViewer.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, Color.BLACK));
|
||||
phaseStepViewer.setOpaque(false);
|
||||
|
||||
playerAvatar.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 1, Color.BLACK));
|
||||
|
||||
setSize(320,125);
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
titleBar=new TitleBar("");
|
||||
add(titleBar,BorderLayout.NORTH);
|
||||
titleBar.setBorder(BorderFactory.createMatteBorder(1, 1, 0, 1, Color.BLACK));
|
||||
|
||||
cardLayout=new CardLayout();
|
||||
cardPanel=new JPanel(cardLayout);
|
||||
cardPanel.setOpaque(false);
|
||||
cardPanel.add(gameViewer,"0");
|
||||
cardPanel.add(duelViewer,"1");
|
||||
add(cardPanel,BorderLayout.CENTER);
|
||||
|
@ -52,10 +58,20 @@ public class GameDuelViewer extends JPanel implements ChangeListener {
|
|||
tabSelector.addTab(IconImages.MESSAGE,"Message");
|
||||
tabSelector.addTab(IconImages.PROGRESS,"Progress");
|
||||
titleBar.add(tabSelector,BorderLayout.EAST);
|
||||
titleBar.add(phaseStepViewer,BorderLayout.SOUTH);
|
||||
|
||||
JPanel titlePanel = new JPanel(new MigLayout("insets 0, gap 0"));
|
||||
titlePanel.setOpaque(false);
|
||||
titlePanel.setBorder(BorderFactory.createMatteBorder(1, 1, 0, 1, Color.BLACK));
|
||||
titlePanel.add(playerAvatar, "w 40px!, h 40px!, cell 1 1 1 2");
|
||||
titlePanel.add(titleBar, "w 100%, h 20px!, cell 2 1");
|
||||
titlePanel.add(phaseStepViewer, "w 100%, h 20px!, cell 2 2");
|
||||
|
||||
add(titlePanel, BorderLayout.NORTH);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public GameViewer getGameViewer() {
|
||||
return gameViewer;
|
||||
}
|
||||
|
@ -65,6 +81,7 @@ public class GameDuelViewer extends JPanel implements ChangeListener {
|
|||
case 0:
|
||||
gameViewer.setTitle(titleBar);
|
||||
phaseStepViewer.setPhaseStep(gameViewer.getMagicPhaseType());
|
||||
playerAvatar.setIcon(gameViewer.getTurnSizedPlayerAvatar());
|
||||
break;
|
||||
case 1:
|
||||
DuelViewer.setTitle(titleBar);
|
||||
|
|
|
@ -6,8 +6,9 @@ import magic.model.MagicCardDefinition;
|
|||
import magic.model.MagicGame;
|
||||
import magic.model.phase.MagicPhaseType;
|
||||
import magic.ui.GameController;
|
||||
import magic.ui.theme.Theme;
|
||||
import magic.ui.theme.ThemeFactory;
|
||||
import magic.ui.widget.TextLabel;
|
||||
import magic.ui.widget.TexturedPanel;
|
||||
import magic.ui.widget.TitleBar;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
|
@ -30,7 +31,7 @@ import java.awt.event.ActionListener;
|
|||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class GameViewer extends TexturedPanel implements ActionListener {
|
||||
public class GameViewer extends JPanel implements ActionListener {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -44,6 +45,7 @@ public class GameViewer extends TexturedPanel implements ActionListener {
|
|||
private final CardLayout actionCardLayout;
|
||||
private final JPanel contentPanel;
|
||||
private boolean actionEnabled;
|
||||
private final Theme theme = ThemeFactory.getInstance().getCurrentTheme();
|
||||
|
||||
public GameViewer(final MagicGame game,final GameController controller) {
|
||||
|
||||
|
@ -113,7 +115,6 @@ public class GameViewer extends TexturedPanel implements ActionListener {
|
|||
|
||||
public void setTitle(final TitleBar titleBar) {
|
||||
titleBar.setText("Turn " + game.getTurn() + " : " + game.getPhase().getType().getName());
|
||||
titleBar.setIcon(game.getTurnPlayer() == game.getVisiblePlayer() ? IconImages.YOU : IconImages.OPPONENT);
|
||||
}
|
||||
|
||||
public void clearContentPanel() {
|
||||
|
@ -178,4 +179,13 @@ public class GameViewer extends TexturedPanel implements ActionListener {
|
|||
public MagicPhaseType getMagicPhaseType() {
|
||||
return game.getPhase().getType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the avatar portrait of the current player sized specifically
|
||||
* for use with the GameDuelViewer component.
|
||||
*/
|
||||
public ImageIcon getTurnSizedPlayerAvatar() {
|
||||
return theme.getAvatarIcon(game.getTurnPlayer().getPlayerDefinition().getFace(), 4);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package magic.ui.viewer;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
@ -9,10 +11,9 @@ import magic.model.phase.MagicPhaseType;
|
|||
import magic.ui.theme.Theme;
|
||||
import magic.ui.theme.ThemeFactory;
|
||||
import magic.ui.widget.FontsAndBorders;
|
||||
import magic.ui.widget.TexturedPanel;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class PhaseStepViewer extends TexturedPanel {
|
||||
public class PhaseStepViewer extends JPanel {
|
||||
|
||||
private int currentPhaseStep = -1;
|
||||
private final Theme theme = ThemeFactory.getInstance().getCurrentTheme();
|
||||
|
@ -23,7 +24,7 @@ public class PhaseStepViewer extends TexturedPanel {
|
|||
}
|
||||
|
||||
private void setMyLayout() {
|
||||
setLayout(new MigLayout("insets 3 5 3 5"));
|
||||
setLayout(new MigLayout("insets 1 5 0 5"));
|
||||
setPhaseStepIndicator("UN", "Beginning Phase : Untap Step");
|
||||
setPhaseStepIndicator("UP", "Beginning Phase : Upkeep Step");
|
||||
setPhaseStepIndicator("DR", "Beginning Phase : Draw Step");
|
||||
|
|
Loading…
Reference in New Issue