display alert icon in stats titlebar if deck contains invalid cards.
parent
78888c8151
commit
ac7271cd65
Binary file not shown.
After Width: | Height: | Size: 492 B |
|
@ -8,6 +8,7 @@ public enum MagicIcon {
|
|||
//
|
||||
// ../ui/... icons.
|
||||
//
|
||||
ALERT("ui/alert-16.png"),
|
||||
CHECKBOX_OFF("ui/checkbox-16.png"),
|
||||
CHECKBOX_ON("ui/checkbox-selected-16.png"),
|
||||
ARROWDOWN("ui/w_arrowdown.png"),
|
||||
|
|
|
@ -188,4 +188,8 @@ public class MagicDeck extends ArrayList<MagicCardDefinition> {
|
|||
public boolean isNotValid() {
|
||||
return !isValid();
|
||||
}
|
||||
|
||||
public boolean isNotEmpty() {
|
||||
return !isEmpty();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package magic.ui.widget;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import magic.ui.ScreenController;
|
||||
|
@ -39,4 +40,9 @@ public class TitleBar extends JPanel {
|
|||
public JLabel getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setIcon(Icon icon) {
|
||||
label.setIcon(icon);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.awt.event.ActionEvent;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
@ -30,6 +31,7 @@ public class DeckStatisticsViewer extends JPanel implements ChangeListener {
|
|||
private static final String _S1 = "Deck Statistics";
|
||||
private static final String _S2 = "%d card deck";
|
||||
|
||||
public static final ImageIcon ALERT_ICON = MagicImages.getIcon(MagicIcon.ALERT);
|
||||
private static boolean isStatsVisible = true;
|
||||
|
||||
private final ActionButtonTitleBar titleBar;
|
||||
|
@ -111,10 +113,23 @@ public class DeckStatisticsViewer extends JPanel implements ChangeListener {
|
|||
|| thisDeck.getDeckType() != aDeck.getDeckType();
|
||||
}
|
||||
|
||||
private void setInvalidDeckIcon(MagicDeck deck) {
|
||||
if (deck.isNotValid() && deck.isNotEmpty()) {
|
||||
titleBar.setIcon(ALERT_ICON);
|
||||
titleBar.setToolTipText(
|
||||
String.format("<html><b>Invalid deck</b><br>%s</html>",
|
||||
deck.getDescription().replace("\n", "<br>")
|
||||
)
|
||||
);
|
||||
} else {
|
||||
titleBar.setIcon(null);
|
||||
titleBar.setToolTipText(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void setDeck(MagicDeck aDeck) {
|
||||
statistics = new CardStatistics(
|
||||
aDeck == null ? new MagicDeck() : aDeck
|
||||
);
|
||||
setInvalidDeckIcon(aDeck);
|
||||
statistics = new CardStatistics(aDeck == null ? new MagicDeck() : aDeck);
|
||||
statsTable.setStats(statistics);
|
||||
manaCurvePanel.setStats(statistics);
|
||||
if (isNewDeck(aDeck)) {
|
||||
|
|
Loading…
Reference in New Issue