diff --git a/src/main/java/forge/game/player/PlayerOutcome.java b/src/main/java/forge/game/player/PlayerOutcome.java index 3928adae7f6..05ce59e09f0 100644 --- a/src/main/java/forge/game/player/PlayerOutcome.java +++ b/src/main/java/forge/game/player/PlayerOutcome.java @@ -68,7 +68,7 @@ public class PlayerOutcome { switch(lossState){ case Conceded: return "conceded"; case Milled: return "lost trying to draw cards from empty library"; - case LifeReachedZero: return "lost because ran out of lives"; + case LifeReachedZero: return "lost because life total reached 0"; case Poisoned: return "lost because of obtaining 10 poison counters"; case OpponentWon: return "lost because an opponent has won by spell '" + loseConditionSpell + "'"; case SpellEffect: return "lost due to effect of spell '" + loseConditionSpell + "'"; diff --git a/src/main/java/forge/gui/deckeditor/CDeckEditorUI.java b/src/main/java/forge/gui/deckeditor/CDeckEditorUI.java index 7237311695e..ab2c6eec43e 100644 --- a/src/main/java/forge/gui/deckeditor/CDeckEditorUI.java +++ b/src/main/java/forge/gui/deckeditor/CDeckEditorUI.java @@ -107,6 +107,11 @@ public enum CDeckEditorUI implements CardContainer { private void moveSelectedCards( EditorTableView table, _MoveAction moveAction, int maxQty) { List items = table.getSelectedCards(); + + if (items.isEmpty()) { + return; + } + for (InventoryItem item : items) { moveAction.move(item, Math.min(maxQty, table.getCardCount(item))); } diff --git a/src/main/java/forge/gui/deckeditor/views/VCurrentDeck.java b/src/main/java/forge/gui/deckeditor/views/VCurrentDeck.java index ce37a4fe940..cb3efe75bdd 100644 --- a/src/main/java/forge/gui/deckeditor/views/VCurrentDeck.java +++ b/src/main/java/forge/gui/deckeditor/views/VCurrentDeck.java @@ -45,7 +45,7 @@ public enum VCurrentDeck implements IVDoc, ITableContainer { .fontSize(14) .tooltip("Save (in default directory)") .iconInBackground(true) - .iconAlignX(SwingConstants.CENTER).iconAlpha(1.0f) + .iconAlignX(SwingConstants.CENTER) .icon(FSkin.getIcon(FSkin.InterfaceIcons.ICO_SAVE)) .text(" ").hoverable(true).build(); @@ -53,7 +53,7 @@ public enum VCurrentDeck implements IVDoc, ITableContainer { .fontSize(14) .tooltip("Save As") .iconInBackground(true) - .iconAlignX(SwingConstants.CENTER).iconAlpha(1.0f) + .iconAlignX(SwingConstants.CENTER) .icon(FSkin.getIcon(FSkin.InterfaceIcons.ICO_SAVEAS)) .text(" ").hoverable(true).build(); @@ -61,7 +61,7 @@ public enum VCurrentDeck implements IVDoc, ITableContainer { .fontSize(14) .tooltip("Load") .iconInBackground(true) - .iconAlignX(SwingConstants.CENTER).iconAlpha(1.0f) + .iconAlignX(SwingConstants.CENTER) .icon(FSkin.getIcon(FSkin.InterfaceIcons.ICO_OPEN)) .text(" ").hoverable(true).build(); @@ -69,7 +69,7 @@ public enum VCurrentDeck implements IVDoc, ITableContainer { .fontSize(14) .tooltip("New Deck") .iconInBackground(true) - .iconAlignX(SwingConstants.CENTER).iconAlpha(1.0f) + .iconAlignX(SwingConstants.CENTER) .icon(FSkin.getIcon(FSkin.InterfaceIcons.ICO_NEW)) .text(" ").hoverable(true).build(); @@ -77,7 +77,7 @@ public enum VCurrentDeck implements IVDoc, ITableContainer { .fontSize(14) .tooltip("Print Proxies") .iconInBackground(true) - .iconAlignX(SwingConstants.CENTER).iconAlpha(1.0f) + .iconAlignX(SwingConstants.CENTER) .icon(FSkin.getIcon(FSkin.InterfaceIcons.ICO_PRINT)) .text(" ").hoverable(true).build(); @@ -89,21 +89,21 @@ public enum VCurrentDeck implements IVDoc, ITableContainer { .text("Remove card") .tooltip("Remove selected card from current deck (or double click the row or hit the spacebar)") .icon(FSkin.getIcon(FSkin.InterfaceIcons.ICO_MINUS)) - .iconScaleAuto(false).hoverable(true).build(); + .iconScaleAuto(false).hoverable().build(); private final FLabel btnRemove4 = new FLabel.Builder() .fontSize(14) .text("Remove 4 of card") .tooltip("Remove up to 4 of selected card to current deck") .icon(FSkin.getIcon(FSkin.InterfaceIcons.ICO_MINUS)) - .iconScaleAuto(false).hoverable(true).build(); + .iconScaleAuto(false).hoverable().build(); private final JLabel btnDoSideboard = new FLabel.Builder() .fontSize(14) .text("Deck/Sideboard") - .tooltip("Edit the sideboard for this deck") + .tooltip("Toggle between editing the deck and the sideboard for this deck") .icon(FSkin.getIcon(FSkin.InterfaceIcons.ICO_EDIT)) - .iconScaleAuto(false).hoverable(true).build(); + .iconScaleAuto(false).hoverable().build(); private final JTextField txfTitle = new FTextField.Builder().text("[New Deck]").build(); diff --git a/src/main/java/forge/gui/home/gauntlet/VSubmenuGauntletBuild.java b/src/main/java/forge/gui/home/gauntlet/VSubmenuGauntletBuild.java index 659bbebe7f1..8b10e4b5108 100644 --- a/src/main/java/forge/gui/home/gauntlet/VSubmenuGauntletBuild.java +++ b/src/main/java/forge/gui/home/gauntlet/VSubmenuGauntletBuild.java @@ -108,7 +108,7 @@ public enum VSubmenuGauntletBuild implements IVSubmenu { .fontSize(14) .tooltip("Save this gauntlet") .iconInBackground(true) - .iconAlignX(SwingConstants.CENTER).iconAlpha(1.0f) + .iconAlignX(SwingConstants.CENTER) .icon(FSkin.getIcon(FSkin.InterfaceIcons.ICO_SAVE)) .text(" ").hoverable(true).build(); @@ -116,7 +116,7 @@ public enum VSubmenuGauntletBuild implements IVSubmenu { .fontSize(14) .tooltip("Build a new gauntlet") .iconInBackground(true) - .iconAlignX(SwingConstants.CENTER).iconAlpha(1.0f) + .iconAlignX(SwingConstants.CENTER) .icon(FSkin.getIcon(FSkin.InterfaceIcons.ICO_NEW)) .text(" ").hoverable(true).build(); @@ -124,7 +124,7 @@ public enum VSubmenuGauntletBuild implements IVSubmenu { .fontSize(14) .tooltip("Load a gauntlet") .iconInBackground(true) - .iconAlignX(SwingConstants.CENTER).iconAlpha(1.0f) + .iconAlignX(SwingConstants.CENTER) .icon(FSkin.getIcon(FSkin.InterfaceIcons.ICO_OPEN)) .text(" ").hoverable(true).build(); diff --git a/src/main/java/forge/gui/home/sanctioned/VSubmenuConstructed.java b/src/main/java/forge/gui/home/sanctioned/VSubmenuConstructed.java index 28cd22c6035..c29ec99a05a 100644 --- a/src/main/java/forge/gui/home/sanctioned/VSubmenuConstructed.java +++ b/src/main/java/forge/gui/home/sanctioned/VSubmenuConstructed.java @@ -50,7 +50,7 @@ public enum VSubmenuConstructed implements IVSubmenu { lblTitle.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2)); - final String strCheckboxConstraints = "w 200px!, h 30px!, gap 0 20px 0 0"; + final String strCheckboxConstraints = "h 30px!, gap 0 20px 0 0"; pnlStart.setOpaque(false); pnlStart.add(cbSingletons, strCheckboxConstraints); pnlStart.add(btnStart, "span 1 3, growx, pushx, align center"); diff --git a/src/main/java/forge/gui/home/settings/VSubmenuAvatars.java b/src/main/java/forge/gui/home/settings/VSubmenuAvatars.java index 7cc36e1cf88..b0d5dabdde3 100644 --- a/src/main/java/forge/gui/home/settings/VSubmenuAvatars.java +++ b/src/main/java/forge/gui/home/settings/VSubmenuAvatars.java @@ -151,7 +151,7 @@ public enum VSubmenuAvatars implements IVSubmenu { @SuppressWarnings("serial") private FLabel makeAvatarLabel(final Image img0, final int index0) { final FLabel lbl = new FLabel.Builder().icon(new ImageIcon(img0)).iconScaleFactor(1.0) - .iconAlpha(0.7f).iconInBackground(true).hoverable(true).build(); + .iconInBackground(true).hoverable(true).build(); final Dimension size = new Dimension(100, 100); lbl.setPreferredSize(size); diff --git a/src/main/java/forge/gui/home/variant/VSubmenuArchenemy.java b/src/main/java/forge/gui/home/variant/VSubmenuArchenemy.java index 8ee327de36a..57d211ba5a1 100644 --- a/src/main/java/forge/gui/home/variant/VSubmenuArchenemy.java +++ b/src/main/java/forge/gui/home/variant/VSubmenuArchenemy.java @@ -165,7 +165,7 @@ public enum VSubmenuArchenemy implements IVSubmenu { } } - final String strCheckboxConstraints = "w 200px!, h 30px!, gap 0 20px 0 0"; + final String strCheckboxConstraints = "h 30px!, gap 0 20px 0 0"; pnlStart.setOpaque(false); pnlStart.add(cbSingletons, strCheckboxConstraints); pnlStart.add(btnStart, "span 1 3, growx, pushx, align center"); diff --git a/src/main/java/forge/gui/home/variant/VSubmenuPlanechase.java b/src/main/java/forge/gui/home/variant/VSubmenuPlanechase.java index 6c9e8ed7ee0..613f86d4f90 100644 --- a/src/main/java/forge/gui/home/variant/VSubmenuPlanechase.java +++ b/src/main/java/forge/gui/home/variant/VSubmenuPlanechase.java @@ -161,7 +161,7 @@ public enum VSubmenuPlanechase implements IVSubmenu { } } - final String strCheckboxConstraints = "w 200px!, h 30px!, gap 0 20px 0 0"; + final String strCheckboxConstraints = "h 30px!, gap 0 20px 0 0"; pnlStart.setOpaque(false); pnlStart.add(cbSingletons, strCheckboxConstraints); pnlStart.add(btnStart, "span 1 3, growx, pushx, align center"); diff --git a/src/main/java/forge/gui/home/variant/VSubmenuVanguard.java b/src/main/java/forge/gui/home/variant/VSubmenuVanguard.java index deb69eb96c4..0e4ead9f557 100644 --- a/src/main/java/forge/gui/home/variant/VSubmenuVanguard.java +++ b/src/main/java/forge/gui/home/variant/VSubmenuVanguard.java @@ -203,7 +203,7 @@ public enum VSubmenuVanguard implements IVSubmenu { } } - final String strCheckboxConstraints = "w 200px!, h 30px!, gap 0 20px 0 0"; + final String strCheckboxConstraints = "h 30px!, gap 0 20px 0 0"; pnlStart.setOpaque(false); pnlStart.add(cbSingletons, strCheckboxConstraints); pnlStart.add(btnStart, "span 1 3, growx, pushx, align center"); diff --git a/src/main/java/forge/gui/match/ControlWinLose.java b/src/main/java/forge/gui/match/ControlWinLose.java index 6a64d1e3144..2695e8f3ffa 100644 --- a/src/main/java/forge/gui/match/ControlWinLose.java +++ b/src/main/java/forge/gui/match/ControlWinLose.java @@ -120,7 +120,6 @@ public class ControlWinLose { for (Player p : Singletons.getModel().getGame().getRegisteredPlayers()) { if (!p.getName().equals(lastGame.getWinner().getName())) { - continue; // not a loser } diff --git a/src/main/java/forge/gui/match/nonsingleton/CField.java b/src/main/java/forge/gui/match/nonsingleton/CField.java index 3f14f9b7f96..9d569add1ea 100644 --- a/src/main/java/forge/gui/match/nonsingleton/CField.java +++ b/src/main/java/forge/gui/match/nonsingleton/CField.java @@ -192,7 +192,12 @@ public class CField implements ICDoc { ((FLabel) this.view.getLblExile()).setHoverable(true); this.view.getLblExile().addMouseListener(madExiled); + if (Preferences.DEV_MODE) { + ((FLabel) this.view.getLblLibrary()).setHoverable(true); + } this.view.getLblLibrary().addMouseListener(madLibrary); + + ((FLabel) this.view.getLblHand()).setHoverable(true); this.view.getLblHand().addMouseListener(madHand); ((FLabel) this.view.getLblFlashback()).setHoverable(true); @@ -208,11 +213,9 @@ public class CField implements ICDoc { this.view.getLblGreen().addMouseListener(madGreen); ((FLabel) this.view.getLblRed()).setHoverable(true); - this.view.getLblRed().removeMouseListener(madRed); this.view.getLblRed().addMouseListener(madRed); ((FLabel) this.view.getLblWhite()).setHoverable(true); - this.view.getLblWhite().removeMouseListener(madWhite); this.view.getLblWhite().addMouseListener(madWhite); ((FLabel) this.view.getLblColorless()).setHoverable(true); diff --git a/src/main/java/forge/gui/match/nonsingleton/VField.java b/src/main/java/forge/gui/match/nonsingleton/VField.java index fdbd03ce5c8..bfc435f4828 100644 --- a/src/main/java/forge/gui/match/nonsingleton/VField.java +++ b/src/main/java/forge/gui/match/nonsingleton/VField.java @@ -313,7 +313,7 @@ public class VField implements IVDoc { private FLabel getBuiltFLabel(SkinProp p0, String s0, String s1) { return new FLabel.Builder().icon(new ImageIcon(FSkin.getImage(p0))) .opaque(false).fontSize(14) - .fontStyle(Font.BOLD).iconAlpha(0.6f).iconInBackground(true) + .fontStyle(Font.BOLD).iconInBackground() .text(s0).tooltip(s1).fontAlign(SwingConstants.RIGHT).build(); } diff --git a/src/main/java/forge/gui/toolbox/FLabel.java b/src/main/java/forge/gui/toolbox/FLabel.java index f4bb22d8e06..5a8c1dc428c 100644 --- a/src/main/java/forge/gui/toolbox/FLabel.java +++ b/src/main/java/forge/gui/toolbox/FLabel.java @@ -14,6 +14,10 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -57,7 +61,7 @@ public class FLabel extends JLabel implements ILocalRepaint { private double bldIconScaleFactor = 0.8; private int bldFontStyle = Font.PLAIN; private int bldFontSize = 14; - private float bldIconAlpha = 1.0f; + private float bldUnhoveredAlpha = 0.7f; private int bldIconAlignX = SwingConstants.LEFT; private Point bldIconInsets = new Point(0, 0); @@ -143,10 +147,11 @@ public class FLabel extends JLabel implements ILocalRepaint { /**@param b0   boolean, icon will be drawn independent of text * @return {@link forge.gui.toolbox.Builder} */ public Builder iconInBackground(final boolean b0) { this.bldIconInBackground = b0; return this; } + public Builder iconInBackground() { iconInBackground(true); return this; } - /**@param f0   0.0f - 1.0f. If icon is in background, this alpha is applied. + /**@param f0   0.0f - 1.0f. alpha factor applied when label is hoverable but not currently hovered. * @return {@link forge.gui.toolbox.Builder} */ - public Builder iconAlpha(final float f0) { this.bldIconAlpha = f0; return this; } + public Builder unhoveredAlpha(final float f0) { this.bldUnhoveredAlpha = f0; return this; } /**@param i0   Int. Only available for background icon. * SwingConstants.HORIZONTAL .VERTICAL or .CENTER @@ -188,16 +193,33 @@ public class FLabel extends JLabel implements ILocalRepaint { this.setFontStyle(b0.bldFontStyle); this.setFontSize(b0.bldFontSize); - this.setIconAlpha(b0.bldIconAlpha); + this.setUnhoveredAlpha(b0.bldUnhoveredAlpha); this.setCommand(b0.bldCmd); this.setReactOnMouseDown(b0.reactOnMouseDown); this.setFontAlign(b0.bldFontAlign); this.setToolTipText(b0.bldToolTip); this.setHoverable(b0.bldHoverable); - + // Call this last; to allow the properties which affect icons to already be in place. this.setIcon(b0.bldIcon); + // If the label has button-like properties, interpret keypresses like a button + if (b0.bldSelectable || b0.bldHoverable) { + this.setFocusable(true); + + this.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(final KeyEvent e) { + if (e.getKeyChar() == ' ' || e.getKeyCode() == 10) { _doMouseAction(); } + } + }); + + this.addFocusListener(new FocusListener() { + @Override public void focusLost(FocusEvent arg0) { repaintSelf(); } + @Override public void focusGained(FocusEvent arg0) { repaintSelf(); } + }); + } + // Non-custom display properties this.setForeground(clrText); this.setBackground(clrMain); @@ -269,25 +291,23 @@ public class FLabel extends JLabel implements ILocalRepaint { } }; + private void _doMouseAction() { + if (selectable) { setSelected(!selected); } + if (cmdClick != null && FLabel.this.isEnabled()) { cmdClick.execute(); } + } + // Mouse event handler private final MouseAdapter madEvents = new MouseAdapter() { @Override public void mouseEntered(final MouseEvent e) { - if (hoverable) { - hovered = true; repaintSelf(); - } + hovered = true; + repaintSelf(); } @Override public void mouseExited(final MouseEvent e) { - if (hoverable) { - hovered = false; repaintSelf(); - } - } - - private void _doMouseAction() { - if (selectable) { setSelected(!selected); } - if (cmdClick != null && FLabel.this.isEnabled()) { cmdClick.execute(); } + hovered = false; + repaintSelf(); } @Override @@ -328,7 +348,7 @@ public class FLabel extends JLabel implements ILocalRepaint { /** Sets alpha if icon is in background. * @param f0   float */ // NOT public; must be set when label is built. - private void setIconAlpha(final float f0) { + private void setUnhoveredAlpha(final float f0) { this.alphaDim = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, f0); this.alphaStrong = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f); } @@ -426,6 +446,12 @@ public class FLabel extends JLabel implements ILocalRepaint { int w = getWidth(); int h = getHeight(); + boolean paintWithHover = hoverable && hovered && isEnabled(); + Composite oldComp = g2d.getComposite(); + if (hoverable) { + g2d.setComposite(paintWithHover ? alphaStrong : alphaDim); + } + if (opaque) { if (selected) { paintDown(g2d, w, h); @@ -440,10 +466,6 @@ public class FLabel extends JLabel implements ILocalRepaint { } } - if (hoverable && hovered && isEnabled()) { - paintHover(g2d, w, h); - } - // Icon in background if (iconInBackground) { int sh = (int) (h * iconScaleFactor); @@ -455,16 +477,21 @@ public class FLabel extends JLabel implements ILocalRepaint { int y = (int) (((h - sh) / 2) + iconInsets.getY()); - Composite oldComp = g2d.getComposite(); - g2d.setComposite(hoverable && hovered && !selected ? alphaStrong : alphaDim); g2d.drawImage(img, x, y, sw + x, sh + y, 0, 0, iw, ih, null); - g2d.setComposite(oldComp); } super.paintComponent(g); + + if (hoverable) { + g2d.setComposite(oldComp); + } + + if (hasFocus() && isEnabled()) { + paintFocus(g2d, w, h); + } } - private void paintHover(final Graphics2D g, int w, int h) { + private void paintFocus(final Graphics2D g, int w, int h) { g.setColor(clrHover); g.drawRect(0, 0, w - 2, h - 2); g.setColor(l30);