displays shield, poison, energy and experience counters in player panel (see #850).
parent
c7e0b8a817
commit
7c690939da
Binary file not shown.
After Width: | Height: | Size: 333 B |
Binary file not shown.
After Width: | Height: | Size: 287 B |
Binary file not shown.
After Width: | Height: | Size: 342 B |
|
@ -24,6 +24,7 @@ public enum MagicIcon {
|
|||
DECK("ui/w_deck.png"),
|
||||
EDIT("ui/w_edit.png"),
|
||||
ENCHANTMENTS("ui/w_enchantments.png"),
|
||||
EXPERIENCE("ui/rank-16.png"),
|
||||
FAST_FORWARD("ui/fast-forward-16.png"),
|
||||
FIREMIND("ui/w_firemind.png"),
|
||||
GO_BACK("ui/w_back.png"),
|
||||
|
@ -47,11 +48,13 @@ public enum MagicIcon {
|
|||
OPTION_MENU("ui/options-menu-24.png"),
|
||||
PLANESWALKERS("ui/w_planeswalkers.png"),
|
||||
PLUS_ICON("ui/w_plus28.png"),
|
||||
POISON("ui/poison-16.png"),
|
||||
RANDOM("ui/w_random32.png"),
|
||||
REFRESH("ui/w_refresh.png"),
|
||||
RESTRICTED("ui/card_restricted.png"),
|
||||
SAVE("ui/w_save.png"),
|
||||
SCROLL("ui/w_scroll.png"),
|
||||
SHIELD("ui/shield-16.png"),
|
||||
SORCERIES("ui/w_sorceries.png"),
|
||||
STATS("ui/w_stats.png"),
|
||||
SWAP("ui/w_swap.png"),
|
||||
|
|
|
@ -7,11 +7,12 @@ import java.awt.Font;
|
|||
import java.awt.Rectangle;
|
||||
import java.util.Set;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import magic.data.GeneralConfig;
|
||||
import magic.model.MagicPlayerZone;
|
||||
import magic.ui.screen.duel.game.SwingGameController;
|
||||
import magic.ui.IChoiceViewer;
|
||||
import magic.ui.duel.viewerinfo.PlayerViewerInfo;
|
||||
import magic.ui.screen.duel.game.SwingGameController;
|
||||
import magic.ui.theme.ThemeFactory;
|
||||
import magic.ui.widget.PanelButton;
|
||||
import magic.ui.widget.TexturedPanel;
|
||||
|
@ -20,17 +21,20 @@ import net.miginfocom.swing.MigLayout;
|
|||
@SuppressWarnings("serial")
|
||||
public class GamePlayerPanel extends TexturedPanel implements IChoiceViewer {
|
||||
|
||||
private static final int PANEL_HEIGHT = 100;
|
||||
|
||||
private PlayerViewerInfo playerInfo;
|
||||
private PlayerZoneButtonsPanel zoneButtonsPanel;
|
||||
private PlayerImagePanel avatarPanel;
|
||||
private final PanelButton avatarButton;
|
||||
private final PlayerCountersPanel countersPanel;
|
||||
|
||||
public GamePlayerPanel(final SwingGameController controller, final PlayerViewerInfo playerInfo) {
|
||||
|
||||
this.playerInfo = playerInfo;
|
||||
|
||||
setOpaque(false);
|
||||
setPreferredSize(new Dimension(0, 80));
|
||||
setPreferredSize(new Dimension(0, PANEL_HEIGHT));
|
||||
setMinimumSize(getPreferredSize());
|
||||
|
||||
zoneButtonsPanel = new PlayerZoneButtonsPanel(playerInfo, controller);
|
||||
|
@ -50,10 +54,17 @@ public class GamePlayerPanel extends TexturedPanel implements IChoiceViewer {
|
|||
};
|
||||
avatarButton.setComponent(avatarPanel);
|
||||
|
||||
setLayout(new MigLayout("flowy, insets 0, gap 4 1, wrap 2"));
|
||||
add(avatarButton, "w 80!, h 80!, spany 2");
|
||||
add(getPlayerLabel(), "gaptop 3");
|
||||
add(zoneButtonsPanel, "w 100%, h 100%");
|
||||
JPanel panel1 = new JPanel(new MigLayout("flowy, insets 0, gap 4 1, wrap 2"));
|
||||
panel1.setOpaque(false);
|
||||
panel1.add(avatarButton, "w 80!, h 80!, spany 2");
|
||||
panel1.add(getPlayerLabel(), "gaptop 3");
|
||||
panel1.add(zoneButtonsPanel, "w 100%, h 100%");
|
||||
|
||||
countersPanel = new PlayerCountersPanel();
|
||||
|
||||
setLayout(new MigLayout("flowy, insets 0, gap 0"));
|
||||
add(panel1, "w 100%");
|
||||
add(countersPanel, "w 100%, h 20!");
|
||||
|
||||
if (controller != null) {
|
||||
controller.registerChoiceViewer(this);
|
||||
|
@ -86,6 +97,7 @@ public class GamePlayerPanel extends TexturedPanel implements IChoiceViewer {
|
|||
this.playerInfo = playerInfo;
|
||||
avatarPanel.updateDisplay(playerInfo);
|
||||
zoneButtonsPanel.updateDisplay(playerInfo);
|
||||
countersPanel.updateDisplay(playerInfo);
|
||||
}
|
||||
|
||||
public void setActiveZone(MagicPlayerZone zone) {
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
package magic.ui.widget.duel.player;
|
||||
|
||||
import java.awt.Font;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingConstants;
|
||||
import magic.data.MagicIcon;
|
||||
import magic.ui.MagicImages;
|
||||
import magic.ui.duel.viewerinfo.PlayerViewerInfo;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class PlayerCountersPanel extends JPanel {
|
||||
|
||||
private static final ImageIcon shieldIcon = MagicImages.getIcon(MagicIcon.SHIELD);
|
||||
private static final ImageIcon poisonIcon = MagicImages.getIcon(MagicIcon.POISON);
|
||||
private static final ImageIcon energyIcon = MagicImages.getIcon(MagicIcon.ENERGY);
|
||||
private static final ImageIcon xpIcon = MagicImages.getIcon(MagicIcon.EXPERIENCE);
|
||||
|
||||
private static final Font ZONE_FONT = new Font("Dialog", Font.BOLD, 12);
|
||||
|
||||
private final JLabel shieldLabel = new JLabel(shieldIcon);
|
||||
private final JLabel poisonLabel = new JLabel(poisonIcon);
|
||||
private final JLabel energyLabel = new JLabel(energyIcon);
|
||||
private final JLabel xpLabel = new JLabel(xpIcon);
|
||||
|
||||
public PlayerCountersPanel() {
|
||||
setOpaque(false);
|
||||
setLayout(new MigLayout("insets 1 4 0 4, gapx 6", "[40!]"));
|
||||
add(shieldLabel);
|
||||
add(poisonLabel);
|
||||
add(energyLabel);
|
||||
add(xpLabel);
|
||||
}
|
||||
|
||||
void updateDisplay(PlayerViewerInfo playerInfo) {
|
||||
|
||||
shieldLabel.setIcon(shieldIcon);
|
||||
shieldLabel.setText(String.valueOf(playerInfo.preventDamage));
|
||||
shieldLabel.setFont(ZONE_FONT);
|
||||
shieldLabel.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
shieldLabel.setToolTipText("Shield counters");
|
||||
|
||||
poisonLabel.setIcon(poisonIcon);
|
||||
poisonLabel.setText(String.valueOf(playerInfo.poison));
|
||||
poisonLabel.setFont(ZONE_FONT);
|
||||
poisonLabel.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
poisonLabel.setToolTipText("Poison counters");
|
||||
|
||||
energyLabel.setIcon(energyIcon);
|
||||
energyLabel.setText(String.valueOf(playerInfo.energy));
|
||||
energyLabel.setFont(ZONE_FONT);
|
||||
energyLabel.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
energyLabel.setToolTipText("Energy counters");
|
||||
|
||||
xpLabel.setIcon(xpIcon);
|
||||
xpLabel.setText(String.valueOf(playerInfo.experience));
|
||||
xpLabel.setFont(ZONE_FONT);
|
||||
xpLabel.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
xpLabel.setToolTipText("Experience counters");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue