Merge origin/master

Conflicts:
	Mage.Sets/src/mage/cards/c/CogworkAssembler.java
This commit is contained in:
Ludwig.Hirth 2017-01-19 17:01:34 +01:00
commit a175ac3a1d
486 changed files with 6577 additions and 6675 deletions

View file

@ -6,7 +6,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-root</artifactId>
<version>1.4.20</version>
<version>1.4.21</version>
</parent>
<groupId>org.mage</groupId>

View file

@ -39,13 +39,9 @@ import java.awt.Image;
import java.awt.Rectangle;
import java.awt.SplashScreen;
import java.awt.Toolkit;
import java.awt.event.AWTEventListener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
@ -163,7 +159,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
private static MageFrame instance;
private ConnectDialog connectDialog;
private final ConnectDialog connectDialog;
private final ErrorDialog errorDialog;
private static CallbackClient callbackClient;
private static final Preferences PREFS = Preferences.userNodeForPackage(MageFrame.class);
@ -254,12 +250,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
});
Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
@Override
public void eventDispatched(AWTEvent event) {
handleEvent(event);
}
}, AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK);
Toolkit.getDefaultToolkit().addAWTEventListener(event -> handleEvent(event), AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK);
TConfig config = TConfig.current();
config.setArchiveDetector(new TArchiveDetector("zip"));
@ -307,12 +298,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
desktopPane.add(errorDialog, JLayeredPane.POPUP_LAYER);
UI.addComponent(MageComponents.DESKTOP_PANE, desktopPane);
PING_TASK_EXECUTOR.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
SessionHandler.ping();
}
}, 60, 60, TimeUnit.SECONDS);
PING_TASK_EXECUTOR.scheduleAtFixedRate(() -> SessionHandler.ping(), 60, 60, TimeUnit.SECONDS);
updateMemUsageTask = new UpdateMemUsageTask(jMemUsageLabel);
@ -369,24 +355,21 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
setGUISize();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
disableButtons();
if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_CHECK, "false").equals("true")) {
checkForNewImages();
}
updateMemUsageTask.execute();
LOGGER.info("Client start up time: " + ((System.currentTimeMillis() - startTime) / 1000 + " seconds"));
if (autoConnect()) {
enableButtons();
} else {
connectDialog.showDialog();
}
setWindowTitle();
SwingUtilities.invokeLater(() -> {
disableButtons();
if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_CHECK, "false").equals("true")) {
checkForNewImages();
}
updateMemUsageTask.execute();
LOGGER.info("Client start up time: " + ((System.currentTimeMillis() - startTime) / 1000 + " seconds"));
if (autoConnect()) {
enableButtons();
} else {
connectDialog.showDialog();
}
setWindowTitle();
});
if (SystemUtil.isMacOSX()) {
@ -532,12 +515,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
private AbstractButton createSwitchPanelsButton() {
final JToggleButton switchPanelsButton = new JToggleButton("Switch panels");
switchPanelsButton.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
createAndShowSwitchPanelsMenu((JComponent) e.getSource(), switchPanelsButton);
}
switchPanelsButton.addItemListener(e -> {
if (e.getStateChange() == ItemEvent.SELECTED) {
createAndShowSwitchPanelsMenu((JComponent) e.getSource(), switchPanelsButton);
}
});
switchPanelsButton.setFocusable(false);
@ -557,12 +537,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
menuItem = new MagePaneMenuItem(window);
menuItem.setFont(GUISizeHelper.menuFont);
menuItem.setState(i == 0);
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
MagePane frame = ((MagePaneMenuItem) ae.getSource()).getFrame();
setActive(frame);
}
menuItem.addActionListener(ae -> {
MagePane frame = ((MagePaneMenuItem) ae.getSource()).getFrame();
setActive(frame);
});
menuItem.setIcon(window.getFrameIcon());
menu.add(menuItem);
@ -883,11 +860,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnPreferences.setFocusable(false);
btnPreferences.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnPreferences.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnPreferences.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnPreferencesActionPerformed(evt);
}
});
btnPreferences.addActionListener(evt -> btnPreferencesActionPerformed(evt));
mageToolbar.add(btnPreferences);
mageToolbar.add(jSeparator4);
@ -896,11 +869,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnConnect.setFocusable(false);
btnConnect.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnConnect.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnConnect.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnConnectActionPerformed(evt);
}
});
btnConnect.addActionListener(evt -> btnConnectActionPerformed(evt));
mageToolbar.add(btnConnect);
lblStatus.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
@ -916,11 +885,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnDeckEditor.setFocusable(false);
btnDeckEditor.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnDeckEditor.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnDeckEditor.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnDeckEditorActionPerformed(evt);
}
});
btnDeckEditor.addActionListener(evt -> btnDeckEditorActionPerformed(evt));
mageToolbar.add(btnDeckEditor);
mageToolbar.add(jSeparator2);
@ -930,11 +895,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnCollectionViewer.setFocusable(false);
btnCollectionViewer.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnCollectionViewer.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnCollectionViewer.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCollectionViewerActionPerformed(evt);
}
});
btnCollectionViewer.addActionListener(evt -> btnCollectionViewerActionPerformed(evt));
mageToolbar.add(btnCollectionViewer);
mageToolbar.add(jSeparator5);
@ -944,11 +905,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnSendFeedback.setFocusable(false);
btnSendFeedback.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnSendFeedback.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnSendFeedback.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSendFeedbackActionPerformed(evt);
}
});
btnSendFeedback.addActionListener(evt -> btnSendFeedbackActionPerformed(evt));
mageToolbar.add(btnSendFeedback);
mageToolbar.add(jSeparator6);
@ -958,11 +915,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnSymbols.setFocusable(false);
btnSymbols.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnSymbols.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnSymbols.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSymbolsActionPerformed(evt);
}
});
btnSymbols.addActionListener(evt -> btnSymbolsActionPerformed(evt));
mageToolbar.add(btnSymbols);
mageToolbar.add(jSeparatorSymbols);
@ -972,11 +925,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnImages.setFocusable(false);
btnImages.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnImages.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnImages.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnImagesActionPerformed(evt);
}
});
btnImages.addActionListener(evt -> btnImagesActionPerformed(evt));
mageToolbar.add(btnImages);
mageToolbar.add(jSeparatorImages);
@ -986,11 +935,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnAbout.setFocusable(false);
btnAbout.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnAbout.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnAbout.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnAboutActionPerformed(evt);
}
});
btnAbout.addActionListener(evt -> btnAboutActionPerformed(evt));
mageToolbar.add(btnAbout);
mageToolbar.add(jSeparator7);
@ -1192,12 +1137,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
if (SwingUtilities.isEventDispatchThread()) {
userRequestDialog.showDialog(userRequestMessage);
} else {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
userRequestDialog.showDialog(userRequestMessage);
}
});
SwingUtilities.invokeLater(() -> userRequestDialog.showDialog(userRequestMessage));
}
}
@ -1206,12 +1146,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
if (SwingUtilities.isEventDispatchThread()) {
errorDialog.showDialog(title, message);
} else {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
errorDialog.showDialog(title, message);
}
});
SwingUtilities.invokeLater(() -> errorDialog.showDialog(title, message));
}
}
@ -1253,40 +1188,32 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
LOGGER.info("Logging level: " + LOGGER.getEffectiveLevel());
startTime = System.currentTimeMillis();
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
LOGGER.fatal(null, e);
Thread.setDefaultUncaughtExceptionHandler((t, e) -> LOGGER.fatal(null, e));
SwingUtilities.invokeLater(() -> {
for (String arg : args) {
if (arg.startsWith(LITE_MODE_ARG)) {
liteMode = true;
}
if (arg.startsWith(GRAY_MODE_ARG)) {
grayMode = true;
}
if (arg.startsWith(FILL_SCREEN_ARG)) {
fullscreenMode = true;
}
}
});
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
for (String arg : args) {
if (arg.startsWith(LITE_MODE_ARG)) {
liteMode = true;
}
if (arg.startsWith(GRAY_MODE_ARG)) {
grayMode = true;
}
if (arg.startsWith(FILL_SCREEN_ARG)) {
fullscreenMode = true;
if (!liteMode) {
final SplashScreen splash = SplashScreen.getSplashScreen();
if (splash != null) {
Graphics2D g = splash.createGraphics();
if (g != null) {
renderSplashFrame(g);
}
splash.update();
}
if (!liteMode) {
final SplashScreen splash = SplashScreen.getSplashScreen();
if (splash != null) {
Graphics2D g = splash.createGraphics();
if (g != null) {
renderSplashFrame(g);
}
splash.update();
}
}
instance = new MageFrame();
instance.setVisible(true);
}
instance = new MageFrame();
instance.setVisible(true);
}
});
}
@ -1383,12 +1310,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
setStatusText(message);
enableButtons();
} else {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
setStatusText(message);
enableButtons();
}
SwingUtilities.invokeLater(() -> {
setStatusText(message);
enableButtons();
});
}
}
@ -1403,20 +1327,17 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
hideTables();
} else {
LOGGER.info("DISCONNECTED (NO Event Dispatch Thread)");
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
setStatusText("Not connected");
disableButtons();
hideGames();
hideTables();
SessionHandler.disconnect(false);
if (errorCall) {
UserRequestMessage message = new UserRequestMessage("Connection lost", "The connection to server was lost. Reconnect to " + currentConnection.getHost() + "?");
message.setButton1("No", null);
message.setButton2("Yes", PlayerAction.CLIENT_RECONNECT);
showUserRequestDialog(message);
}
SwingUtilities.invokeLater(() -> {
setStatusText("Not connected");
disableButtons();
hideGames();
hideTables();
SessionHandler.disconnect(false);
if (errorCall) {
UserRequestMessage message = new UserRequestMessage("Connection lost", "The connection to server was lost. Reconnect to " + currentConnection.getHost() + "?");
message.setButton1("No", null);
message.setButton2("Yes", PlayerAction.CLIENT_RECONNECT);
showUserRequestDialog(message);
}
}
);

View file

@ -86,7 +86,6 @@ import mage.client.util.ImageHelper;
import mage.client.util.gui.ArrowBuilder;
import mage.constants.CardType;
import mage.constants.EnlargeMode;
import mage.remote.Session;
import mage.view.AbilityView;
import mage.view.CardView;
import mage.view.CounterView;
@ -101,10 +100,10 @@ import org.apache.log4j.Logger;
@SuppressWarnings("serial")
public class Card extends MagePermanent implements MouseMotionListener, MouseListener, FocusListener, ComponentListener {
protected static DefaultActionCallback callback = DefaultActionCallback.getInstance();
protected static final DefaultActionCallback callback = DefaultActionCallback.getInstance();
protected Point p;
protected CardDimensions dimension;
protected final CardDimensions dimension;
protected final UUID gameId;
protected final BigCard bigCard;
@ -112,10 +111,10 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
protected Popup tooltipPopup;
protected boolean tooltipShowing;
protected TextPopup tooltipText = new TextPopup();
protected final TextPopup tooltipText = new TextPopup();
protected BufferedImage background;
protected BufferedImage image = new BufferedImage(FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT, BufferedImage.TYPE_INT_RGB);
protected BufferedImage small;
protected final BufferedImage image = new BufferedImage(FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT, BufferedImage.TYPE_INT_RGB);
protected final BufferedImage small;
protected String backgroundName;
// if this is set, it's opened if the user right clicks on the card panel

View file

@ -52,7 +52,7 @@ import org.mage.card.arcane.CardPanel;
public class CardArea extends JPanel implements MouseListener {
protected CardEventSource cardEventSource = new CardEventSource();
protected final CardEventSource cardEventSource = new CardEventSource();
private boolean reloaded = false;
private final javax.swing.JLayeredPane cardArea;
@ -89,7 +89,7 @@ public class CardArea extends JPanel implements MouseListener {
setGUISize();
for (Component component : cardArea.getComponents()) {
if (component instanceof CardPanel) {
((CardPanel) component).setBounds(0, 0, cardDimension.width, cardDimension.height);
component.setBounds(0, 0, cardDimension.width, cardDimension.height);
}
}
}

View file

@ -3,7 +3,6 @@ package mage.client.cards;
import mage.cards.MageCard;
import mage.client.plugins.impl.Plugins;
import mage.view.CardView;
import org.apache.log4j.Logger;
import javax.swing.*;
import java.awt.*;
@ -11,13 +10,12 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.util.ArrayList;
import java.util.Collection;
/**
* Created by StravantUser on 2016-09-22.
*/
public class CardDraggerGlassPane implements MouseListener, MouseMotionListener {
private DragCardSource source;
private final DragCardSource source;
private Component dragComponent;
private JRootPane currentRoot;
private JComponent glassPane;

View file

@ -33,7 +33,6 @@ import mage.client.util.Event;
import mage.client.util.EventDispatcher;
import mage.client.util.EventSource;
import mage.client.util.Listener;
import mage.view.CardView;
import mage.view.SimpleCardView;
/**

View file

@ -39,7 +39,6 @@ import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
@ -64,7 +63,7 @@ import org.mage.card.arcane.CardPanel;
*/
public class CardGrid extends javax.swing.JLayeredPane implements MouseListener, ICardGrid {
protected CardEventSource cardEventSource = new CardEventSource();
protected final CardEventSource cardEventSource = new CardEventSource();
protected BigCard bigCard;
protected UUID gameId;
private final Map<UUID, MageCard> cards = new HashMap<>();
@ -154,22 +153,22 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener,
List<MageCard> sortedCards = new ArrayList<>(cards.values());
switch (sortSetting.getSortBy()) {
case NAME:
Collections.sort(sortedCards, new CardNameComparator());
sortedCards.sort(new CardNameComparator());
break;
case CARD_TYPE:
Collections.sort(sortedCards, new CardTypeComparator());
sortedCards.sort(new CardTypeComparator());
break;
case RARITY:
Collections.sort(sortedCards, new CardRarityComparator());
sortedCards.sort(new CardRarityComparator());
break;
case COLOR:
Collections.sort(sortedCards, new CardColorComparator());
sortedCards.sort(new CardColorComparator());
break;
case COLOR_IDENTITY:
Collections.sort(sortedCards, new CardColorDetailedIdentity());
sortedCards.sort(new CardColorDetailedIdentity());
break;
case CASTING_COST:
Collections.sort(sortedCards, new CardCostComparator());
sortedCards.sort(new CardCostComparator());
break;
}
@ -409,7 +408,7 @@ class CardCostComparator implements Comparator<MageCard> {
@Override
public int compare(MageCard o1, MageCard o2) {
int val = Integer.valueOf(o1.getOriginal().getConvertedManaCost()).compareTo(Integer.valueOf(o2.getOriginal().getConvertedManaCost()));
int val = Integer.valueOf(o1.getOriginal().getConvertedManaCost()).compareTo(o2.getOriginal().getConvertedManaCost());
if (val == 0) {
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
} else {

View file

@ -37,8 +37,6 @@ import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
@ -210,7 +208,7 @@ public class Cards extends javax.swing.JPanel {
tmp.setIsAbility(true);
tmp.overrideTargets(card.getTargets());
tmp.overrideId(card.getId());
tmp.setAbilityType(((StackAbilityView) card).getAbilityType());
tmp.setAbilityType(card.getAbilityType());
card = tmp;
} else {
card.setAbilityType(null);
@ -258,7 +256,7 @@ public class Cards extends javax.swing.JPanel {
this.cardDimension = dimension;
for (Component component : cardArea.getComponents()) {
if (component instanceof CardPanel) {
((CardPanel) component).setBounds(0, 0, dimension.width, dimension.height);
component.setBounds(0, 0, dimension.width, dimension.height);
}
}
layoutCards();
@ -358,12 +356,7 @@ public class Cards extends javax.swing.JPanel {
}
}
// sort the cards
Collections.sort(cardsToLayout, new Comparator<CardPanel>() {
@Override
public int compare(CardPanel cp1, CardPanel cp2) {
return Integer.valueOf(cp1.getLocation().x).compareTo(cp2.getLocation().x);
}
});
cardsToLayout.sort((cp1, cp2) -> Integer.valueOf(cp1.getLocation().x).compareTo(cp2.getLocation().x));
// relocate the cards
int dx = 0;
for (Component component : cardsToLayout) {

View file

@ -83,7 +83,7 @@ import org.mage.card.arcane.CardPanel;
*/
public class CardsList extends javax.swing.JPanel implements MouseListener, ICardGrid {
protected CardEventSource cardEventSource = new CardEventSource();
protected final CardEventSource cardEventSource = new CardEventSource();
private Dimension cardDimension;
private int rowHeight;
private CardsView cards;
@ -346,8 +346,8 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
break;
}
if (comparator != null) {
Collections.sort(sortedCards, new CardViewNameComparator());
Collections.sort(sortedCards, comparator);
sortedCards.sort(new CardViewNameComparator());
sortedCards.sort(comparator);
}
CardView lastCard = null;
for (CardView card : sortedCards) {
@ -536,11 +536,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
chkPiles.setText("Piles");
chkPiles.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
chkPiles.setMargin(new java.awt.Insets(3, 2, 2, 2));
chkPiles.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
chkPilesActionPerformed(evt);
}
});
chkPiles.addActionListener(evt -> chkPilesActionPerformed(evt));
cbSortBy.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SortBy" }));
cbSortBy.setToolTipText("Sort the cards if card view is active.");
@ -549,11 +545,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
cbSortBy.setName("SortBy"); // NOI18N
cbSortBy.setOpaque(false);
cbSortBy.setPreferredSize(new java.awt.Dimension(120, 20));
cbSortBy.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbSortByActionPerformed(evt);
}
});
cbSortBy.addActionListener(evt -> cbSortByActionPerformed(evt));
bgView.add(jToggleListView);
jToggleListView.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/list_panel.png"))); // NOI18N
@ -564,11 +556,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
jToggleListView.setMaximumSize(new java.awt.Dimension(37, 25));
jToggleListView.setMinimumSize(new java.awt.Dimension(37, 25));
jToggleListView.setPreferredSize(new java.awt.Dimension(44, 22));
jToggleListView.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jToggleListViewActionPerformed(evt);
}
});
jToggleListView.addActionListener(evt -> jToggleListViewActionPerformed(evt));
bgView.add(jToggleCardView);
jToggleCardView.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/card_panel.png"))); // NOI18N
@ -576,11 +564,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
jToggleCardView.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
jToggleCardView.setMargin(new java.awt.Insets(2, 6, 2, 6));
jToggleCardView.setPreferredSize(new java.awt.Dimension(40, 22));
jToggleCardView.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jToggleCardViewActionPerformed(evt);
}
});
jToggleCardView.addActionListener(evt -> jToggleCardViewActionPerformed(evt));
javax.swing.GroupLayout panelControlLayout = new javax.swing.GroupLayout(panelControl);
panelControl.setLayout(panelControlLayout);

View file

@ -40,7 +40,6 @@ import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import mage.cards.CardDimensions;
import mage.cards.MageCard;
@ -62,7 +61,7 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
private static final Logger logger = Logger.getLogger(DraftGrid.class);
protected CardEventSource cardEventSource = new CardEventSource();
protected final CardEventSource cardEventSource = new CardEventSource();
protected BigCard bigCard;
protected MageCard markedCard;
protected boolean emptyGrid;
@ -126,7 +125,7 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
Dimension dimension = new Dimension(cardDimension.frameWidth, cardDimension.frameHeight);
List<CardView> sortedCards = new ArrayList<>(booster.values());
Collections.sort(sortedCards, new CardViewRarityComparator());
sortedCards.sort(new CardViewRarityComparator());
for (CardView card: sortedCards) {
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, dimension, null, true, true);
cardImg.addMouseListener(this);

View file

@ -7,15 +7,12 @@ import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
@ -40,9 +37,11 @@ import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import mage.cards.Card;
import javax.swing.JSlider;
import javax.swing.JTextField;
import javax.swing.JToggleButton;
@ -52,6 +51,9 @@ import javax.swing.SwingUtilities;
import mage.cards.MageCard;
import mage.cards.decks.DeckCardInfo;
import mage.cards.decks.DeckCardLayout;
import mage.cards.repository.CardCriteria;
import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository;
import mage.client.MageFrame;
import mage.client.constants.Constants;
import mage.client.dialog.PreferencesDialog;
@ -66,6 +68,7 @@ import mage.client.util.Event;
import mage.client.util.GUISizeHelper;
import mage.client.util.Listener;
import mage.constants.CardType;
import mage.util.RandomUtil;
import mage.view.CardView;
import mage.view.CardsView;
import org.apache.log4j.Logger;
@ -455,12 +458,9 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
}
public enum Sort {
NONE("No Sort", new Comparator<CardView>() {
@Override
public int compare(CardView o1, CardView o2) {
// Always equal, sort into the first row
return 0;
}
NONE("No Sort", (o1, o2) -> {
// Always equal, sort into the first row
return 0;
}),
CARD_TYPE("Card Type", new CardViewCardTypeComparator()),
CMC("Converted Mana Cost", new CardViewCostComparator()),
@ -508,44 +508,44 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
}
// Counters we use
private CardTypeCounter creatureCounter = new CardTypeCounter() {
private final CardTypeCounter creatureCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.CREATURE);
}
};
private CardTypeCounter landCounter = new CardTypeCounter() {
private final CardTypeCounter landCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.LAND);
}
};
private CardTypeCounter artifactCounter = new CardTypeCounter() {
private final CardTypeCounter artifactCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.ARTIFACT);
}
};
private CardTypeCounter enchantmentCounter = new CardTypeCounter() {
private final CardTypeCounter enchantmentCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.ENCHANTMENT);
}
};
private CardTypeCounter instantCounter = new CardTypeCounter() {
private final CardTypeCounter instantCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.INSTANT);
}
};
private CardTypeCounter sorceryCounter = new CardTypeCounter() {
private final CardTypeCounter sorceryCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.SORCERY);
}
};
private CardTypeCounter planeswalkerCounter = new CardTypeCounter() {
private final CardTypeCounter planeswalkerCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.PLANESWALKER);
@ -577,15 +577,15 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
void hideCards(Collection<CardView> card);
void duplicateCards(Collection<CardView> cards);
void invertCardSelection(Collection<CardView> cards);
void showAll();
};
}
// Constants
public static int COUNT_LABEL_HEIGHT = 20;
public static int GRID_PADDING = 10;
public static final int COUNT_LABEL_HEIGHT = 20;
public static final int GRID_PADDING = 10;
private final static ImageIcon INSERT_ROW_ICON = new ImageIcon(DragCardGrid.class.getClassLoader().getResource("editor_insert_row.png"));
private final static ImageIcon INSERT_COL_ICON = new ImageIcon(DragCardGrid.class.getClassLoader().getResource("editor_insert_col.png"));
@ -606,36 +606,38 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
JButton visibilityButton;
JButton selectByButton;
JButton analyseButton;
JButton blingButton;
// Popup for toolbar
JPopupMenu filterPopup;
final JPopupMenu filterPopup;
JPopupMenu selectByTypePopup;
JPopupMenu sortPopup;
JPopupMenu selectByPopup;
JCheckBox separateCreaturesCb;
JTextField searchByTextField;
final JPopupMenu sortPopup;
final JPopupMenu selectByPopup;
final JCheckBox separateCreaturesCb;
final JTextField searchByTextField;
JToggleButton multiplesButton;
JSlider cardSizeSlider;
JLabel cardSizeSliderLabel;
final JSlider cardSizeSlider;
final JLabel cardSizeSliderLabel;
Map<Sort, AbstractButton> sortButtons = new HashMap<>();
HashMap<CardType, AbstractButton> selectByTypeButtons = new HashMap<>();
final Map<Sort, AbstractButton> sortButtons = new HashMap<>();
final HashMap<CardType, AbstractButton> selectByTypeButtons = new HashMap<>();
JLabel deckNameAndCountLabel;
JLabel landCountLabel;
JLabel creatureCountLabel;
final JLabel deckNameAndCountLabel;
final JLabel landCountLabel;
final JLabel creatureCountLabel;
// Main two controls holding the scrollable card grid
JScrollPane cardScroll;
final JScrollPane cardScroll;
JLayeredPane cardContent;
// Drag onto insert arrow
JLabel insertArrow;
final JLabel insertArrow;
// Card area selection panel
SelectionBox selectionPanel;
final SelectionBox selectionPanel;
Set<CardView> selectionDragStartCards;
int selectionDragStartX;
int selectionDragStartY;
@ -672,7 +674,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
return name;
}
private String name;
private final String name;
}
public static class Settings {
@ -756,9 +758,10 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
// Toolbar
sortButton = new JButton("Sort");
filterButton = new JButton("Filter");
visibilityButton = new JButton("Visibility");
visibilityButton = new JButton("V"); // "Visibility" button
selectByButton = new JButton("Select By");
analyseButton = new JButton("Mana");
analyseButton = new JButton("M"); // "Mana" button
blingButton = new JButton("B"); // "Bling" button
// Name and count label
deckNameAndCountLabel = new JLabel();
@ -779,9 +782,10 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
toolbarInner.add(creatureCountLabel);
toolbarInner.add(sortButton);
toolbarInner.add(filterButton);
toolbarInner.add(visibilityButton);
toolbarInner.add(selectByButton);
toolbarInner.add(visibilityButton);
toolbarInner.add(analyseButton);
toolbarInner.add(blingButton);
toolbar.add(toolbarInner, BorderLayout.WEST);
JPanel sliderPanel = new JPanel(new GridBagLayout());
sliderPanel.setOpaque(false);
@ -929,6 +933,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
JMenuItem showAll = new JMenuItem("Show all");
showAll.addActionListener(e -> showAll());
visPopup.add(showAll);
visibilityButton.setToolTipText("Visibility of cards. Right click to get the same options this provides");
visibilityButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
@ -956,15 +961,15 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
ButtonGroup selectByTypeModeGroup = new ButtonGroup();
for (final CardType cardType : CardType.values()) {
if (cardType == cardType.CONSPIRACY) {
if (cardType == cardType.CONSPIRACY) {
multiplesButton = new JToggleButton("Multiples");
selectByTypeButtons.put(cardType, multiplesButton);
selectByTypeMode.add(multiplesButton);
selectByTypeModeGroup.add(multiplesButton);
multiplesButton.addActionListener(e -> {
multiplesButton.setSelected(!multiplesButton.isSelected());
reselectBy();
});
multiplesButton.setSelected(!multiplesButton.isSelected());
reselectBy();
});
continue;
}
@ -1011,13 +1016,14 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
}
// Analyse Mana (aka #blue pips, #islands, #white pips, #plains etc.)
analyseButton.setToolTipText("Counts coloured/colourless mana costs. Counts land types.");
analyseButton.setToolTipText("Mana Analyser! Counts coloured/colourless mana costs. Counts land types.");
analyseButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
analyseDeck();
}
});
analyseButton.addActionListener(evt -> analyseDeck());
// Bling button - aka Add in a premium 'JR', 'MBP', 'CS' etc card
blingButton.setToolTipText("Bling your deck! Select the original and added cards by selecting 'Multiples' in the selection options");
blingButton.addActionListener(evt -> blingDeck());
// Filter popup
filterPopup = new JPopupMenu();
@ -1108,7 +1114,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
l.duplicateCards(toDuplicate);
}
}
private void invertSelection() {
Collection<CardView> toInvert = allCards;
for (DragCardGridListener l : listeners) {
@ -1229,7 +1235,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
trimGrid();
// First sort all cards by name
Collections.sort(allCards, new CardViewNameComparator());
allCards.sort(new CardViewNameComparator());
// Now re-insert all of the cards using the current sort
for (CardView card : allCards) {
@ -1478,6 +1484,84 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
MageFrame.getInstance().showMessage(finalInfo);
}
public void blingDeck() {
if (!(this.mode == Constants.DeckEditorMode.FREE_BUILDING)) {
return;
}
if (JOptionPane.showConfirmDialog(null, "Are you sure you want to bling your deck? This process will add cards!", "WARNING",
JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) {
return;
}
HashMap<String, Integer> pimpedSets = new HashMap<>();
HashMap<CardView, Integer> pimpedCards = new HashMap<>();
pimpedSets.put("CP", 1);
pimpedSets.put("JR", 1);
pimpedSets.put("MPS", 1);
pimpedSets.put("CLASH", 1);
pimpedSets.put("ARENA", 1);
pimpedSets.put("UGIN", 1);
pimpedSets.put("WMCQ", 1);
pimpedSets.put("APAC", 1);
pimpedSets.put("EURO", 1);
pimpedSets.put("FNMP", 1);
pimpedSets.put("MGDC", 1);
pimpedSets.put("MPRP", 1);
pimpedSets.put("EXP", 1);
pimpedSets.put("GPX", 1);
pimpedSets.put("GRC", 1);
pimpedSets.put("MBP", 1);
pimpedSets.put("MLP", 1);
pimpedSets.put("PLS", 1);
pimpedSets.put("PTC", 1);
pimpedSets.put("SUS", 1);
String[] sets = pimpedSets.keySet().toArray(new String[pimpedSets.keySet().size()]);
Boolean didModify = false;
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) {
for (ArrayList<CardView> stack : gridRow) {
for (CardView card : stack) {
if (card.getSuperTypes().contains("Basic")) {
continue;
}
if (!pimpedSets.containsKey(card.getExpansionSetCode())) {
final CardCriteria cardCriteria = new CardCriteria();
cardCriteria.setCodes(sets);
cardCriteria.name(card.getName());
List<CardInfo> cardPool = CardRepository.instance.findCards(cardCriteria);
if (cardPool.size() > 0) {
Card acard = cardPool.get(RandomUtil.nextInt(cardPool.size())).getMockCard();
if (acard.getName().equals(card.getName())) {
CardView pimpedCard = new CardView(acard);
addCardView(pimpedCard, false);
eventSource.addSpecificCard(pimpedCard, "add-specific-card");
pimpedCards.put(pimpedCard, 1);
didModify = true;
}
}
}
}
}
if (didModify) {
for (CardView c : pimpedCards.keySet()) {
sortIntoGrid(c);
}
layoutGrid();
cardScroll.revalidate();
repaint();
JOptionPane.showMessageDialog(null, "Added " + pimpedCards.size() + " cards. You can select them and the originals by choosing 'Multiples'");
}
}
}
// Update the contents of the card grid
public void setCards(CardsView cardsView, DeckCardLayout layout, BigCard bigCard) {
if (bigCard != null) {
@ -1640,10 +1724,10 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
AbstractButton button = selectByTypeButtons.get(cardType);
String text = cardType.toString();
int numCards = getCount(cardType);
if (cardType == cardType.CONSPIRACY) {
if (cardType == cardType.CONSPIRACY) {
continue;
}
if (numCards > 0) {
button.setForeground(Color.BLACK);
text = text + " - " + numCards;
@ -1659,7 +1743,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
JMenuItem hide = new JMenuItem("Hide");
hide.addActionListener(e2 -> hideSelection());
menu.add(hide);
JMenuItem invertSelection = new JMenuItem("Invert Selection");
invertSelection.addActionListener(e2 -> invertSelection());
menu.add(invertSelection);

View file

@ -2,7 +2,6 @@ package mage.client.cards;
import mage.view.CardView;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.util.Collection;

View file

@ -52,11 +52,9 @@ import mage.cards.Sets;
import static mage.client.constants.Constants.DAMAGE_MAX_LEFT;
import static mage.client.constants.Constants.POWBOX_TEXT_MAX_TOP;
import mage.client.util.Config;
import mage.client.util.ImageHelper;
import mage.constants.CardType;
import mage.view.CounterView;
import mage.view.PermanentView;
import org.mage.plugins.card.images.ImageCache;
import mage.client.util.TransformedImageCache;
/**
@ -67,9 +65,9 @@ public class Permanent extends Card {
protected PermanentView permanent;
protected List<MagePermanent> links = new ArrayList<>();
protected final List<MagePermanent> links = new ArrayList<>();
protected boolean linked;
protected BufferedImage tappedImage;
protected final BufferedImage tappedImage;
protected BufferedImage flippedImage;
/** Creates new form Permanent

View file

@ -13,9 +13,7 @@ import javax.swing.JEditorPane;
import javax.swing.JPanel;
import javax.swing.JTextPane;
import javax.swing.SwingUtilities;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkEvent.EventType;
import javax.swing.event.HyperlinkListener;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLEditorKit;
@ -35,8 +33,8 @@ import mage.view.CardView;
*/
public class ColorPane extends JEditorPane {
HTMLEditorKit kit = new HTMLEditorKit();
HTMLDocument doc = new HTMLDocument();
final HTMLEditorKit kit = new HTMLEditorKit();
final HTMLDocument doc = new HTMLDocument();
private int tooltipDelay;
private int tooltipCounter;
private boolean hyperlinkEnabled = false;
@ -47,39 +45,28 @@ public class ColorPane extends JEditorPane {
}
private void addHyperlinkHandlers() {
addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(final HyperlinkEvent e) {
ThreadUtils.threadPool2.submit(new Runnable() {
@Override
public void run() {
tooltipDelay = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_TOOLTIPS_DELAY, 300);
if (tooltipDelay == 0) {
return;
}
String name = e.getDescription().substring(1);
CardInfo card = CardRepository.instance.findCard(name);
try {
final Component container = MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER);
if (e.getEventType() == EventType.EXITED) {
setPopupVisibility(container, false);
}
if (e.getEventType() == EventType.ENTERED && card != null) {
CardInfoPane cardInfoPane = (CardInfoPane) MageFrame.getUI().getComponent(MageComponents.CARD_INFO_PANE);
cardInfoPane.setCard(new CardView(card.getMockCard()), container);
setPopupVisibility(container, true);
}
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
});
addHyperlinkListener(e -> ThreadUtils.threadPool2.submit(() -> {
tooltipDelay = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_TOOLTIPS_DELAY, 300);
if (tooltipDelay == 0) {
return;
}
String name = e.getDescription().substring(1);
CardInfo card = CardRepository.instance.findCard(name);
try {
final Component container = MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER);
if (e.getEventType() == EventType.EXITED) {
setPopupVisibility(container, false);
}
if (e.getEventType() == EventType.ENTERED && card != null) {
CardInfoPane cardInfoPane = (CardInfoPane) MageFrame.getUI().getComponent(MageComponents.CARD_INFO_PANE);
cardInfoPane.setCard(new CardView(card.getMockCard()), container);
setPopupVisibility(container, true);
}
} catch (InterruptedException e1) {
e1.printStackTrace();
}
});
}));
addMouseListener(new MouseAdapter() {
@Override
@ -96,22 +83,19 @@ public class ColorPane extends JEditorPane {
private void setPopupVisibility(final Component container, final boolean show) throws InterruptedException {
final Component c = MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
tooltipCounter += show ? 1 : -1;
if (tooltipCounter < 0) {
tooltipCounter = 0;
}
if (tooltipCounter > 0) {
Point location = new Point(getLocationOnScreen().x - container.getWidth(), MouseInfo.getPointerInfo().getLocation().y);
Component parentComponent = MageFrame.getInstance();
location = GuiDisplayUtil.keepComponentInsideParent(location, parentComponent.getLocationOnScreen(), container, parentComponent);
container.setLocation(location);
}
container.setVisible(tooltipCounter > 0);
c.repaint();
SwingUtilities.invokeLater(() -> {
tooltipCounter += show ? 1 : -1;
if (tooltipCounter < 0) {
tooltipCounter = 0;
}
if (tooltipCounter > 0) {
Point location = new Point(getLocationOnScreen().x - container.getWidth(), MouseInfo.getPointerInfo().getLocation().y);
Component parentComponent = MageFrame.getInstance();
location = GuiDisplayUtil.keepComponentInsideParent(location, parentComponent.getLocationOnScreen(), container, parentComponent);
container.setLocation(location);
}
container.setVisible(tooltipCounter > 0);
c.repaint();
});
}

View file

@ -6,12 +6,8 @@
package mage.client.components;
import java.awt.BorderLayout;
import javax.swing.DefaultDesktopManager;
import javax.swing.DesktopManager;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.SwingUtilities;
import javax.swing.*;
import mage.client.dialog.CardInfoWindowDialog;
/**
@ -41,24 +37,21 @@ public class MageDesktopManager extends DefaultDesktopManager {
}
public static void main(String args[]) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
SwingUtilities.invokeLater(() -> {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
JDesktopPane desktopPane = new JDesktopPane();
DesktopManager dm = new MageDesktopManager();
desktopPane.setDesktopManager(dm);
JInternalFrame internalFrame = new JInternalFrame("Test Internal Frame", true, false, true, true);
internalFrame.setSize(200, 150);
internalFrame.setVisible(true);
desktopPane.add(internalFrame);
JDesktopPane desktopPane = new JDesktopPane();
DesktopManager dm = new MageDesktopManager();
desktopPane.setDesktopManager(dm);
JInternalFrame internalFrame = new JInternalFrame("Test Internal Frame", true, false, true, true);
internalFrame.setSize(200, 150);
internalFrame.setVisible(true);
desktopPane.add(internalFrame);
frame.add(desktopPane, BorderLayout.CENTER);
frame.setSize(800, 600);
frame.setVisible(true);
}
frame.add(desktopPane, BorderLayout.CENTER);
frame.setSize(800, 600);
frame.setVisible(true);
});
}
}

View file

@ -24,7 +24,7 @@ public class MageJDesktop extends JDesktopPane {
UIDefaults map = new UIDefaults();
Painter painter = new Painter() {
Color color = null;
final Color color = null;
@Override
public void paint(Graphics2D g, Object c, int w, int h) {

View file

@ -27,23 +27,13 @@ public class MageRoundPane extends JPanel {
private final Color defaultBackgroundColor = new Color(141, 130, 112, 200);
private Color backgroundColor = defaultBackgroundColor;
private final int alpha = 0;
private static Map<ShadowKey, BufferedImage> SHADOW_IMAGE_CACHE;
private static final Map<ShadowKey, BufferedImage> SHADOW_IMAGE_CACHE;
private static final Map<Key, BufferedImage> IMAGE_CACHE;
static {
SHADOW_IMAGE_CACHE = ImageCaches.register(new MapMaker().softValues().makeComputingMap(new Function<ShadowKey, BufferedImage>() {
@Override
public BufferedImage apply(ShadowKey key) {
return createShadowImage(key);
}
}));
SHADOW_IMAGE_CACHE = ImageCaches.register(new MapMaker().softValues().makeComputingMap((Function<ShadowKey, BufferedImage>) key -> createShadowImage(key)));
IMAGE_CACHE = ImageCaches.register(new MapMaker().softValues().makeComputingMap(new Function<Key, BufferedImage>() {
@Override
public BufferedImage apply(Key key) {
return createImage(key);
}
}));
IMAGE_CACHE = ImageCaches.register(new MapMaker().softValues().makeComputingMap((Function<Key, BufferedImage>) key -> createImage(key)));
}
private final static class ShadowKey {

View file

@ -14,7 +14,7 @@ import javax.swing.plaf.synth.SynthStyleFactory;
* @author nantuko
*/
public class MageSynthStyleFactory extends SynthStyleFactory {
private SynthStyleFactory wrappedFactory;
private final SynthStyleFactory wrappedFactory;
public MageSynthStyleFactory(SynthStyleFactory factory) {
this.wrappedFactory = factory;

View file

@ -57,22 +57,19 @@ public class MageTextArea extends JEditorPane {
buffer.append("</b></center></body></html>");
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
String promptText = buffer.toString();
MageTextArea.super.setText(promptText);
// in case the text don't fit in the panel a tooltip with the text is added
if (panelWidth > 0 && MageTextArea.this.getPreferredSize().getWidth() > panelWidth) {
String tooltip = "<html><center><body style='font-family:Dialog;font-size:"
+ GUISizeHelper.gameDialogAreaFontSizeBig
+ ";color: #FFFFFF'><p width='500'>" + basicText + "</p></body></html>";
MageTextArea.super.setToolTipText(tooltip);
} else {
MageTextArea.super.setToolTipText(null);
}
setCaretPosition(0);
SwingUtilities.invokeLater(() -> {
String promptText = buffer.toString();
MageTextArea.super.setText(promptText);
// in case the text don't fit in the panel a tooltip with the text is added
if (panelWidth > 0 && MageTextArea.this.getPreferredSize().getWidth() > panelWidth) {
String tooltip = "<html><center><body style='font-family:Dialog;font-size:"
+ GUISizeHelper.gameDialogAreaFontSizeBig
+ ";color: #FFFFFF'><p width='500'>" + basicText + "</p></body></html>";
MageTextArea.super.setToolTipText(tooltip);
} else {
MageTextArea.super.setToolTipText(null);
}
setCaretPosition(0);
});
}
}

View file

@ -96,12 +96,7 @@ public class MageUI {
while (!j.isEnabled()) {
Thread.sleep(10);
}
Thread t = new Thread(new Runnable() {
@Override
public void run() {
j.doClick();
}
});
Thread t = new Thread(() -> j.doClick());
t.start();
}
}

View file

@ -49,7 +49,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
private static final String IMAGE_RIGHT_PATH = "/game/right.png";
private static final String IMAGE_RIGHT_HOVERED_PATH = "/game/right_hovered.png";
private static Color SELECTED_COLOR = new Color(64, 147, 208);
private static final Color SELECTED_COLOR = new Color(64, 147, 208);
private static Color BORDER_COLOR = new Color(0, 0, 0, 50);
private boolean selected = false;

View file

@ -14,9 +14,9 @@ import java.awt.geom.RoundRectangle2D;
*/
public class BackgroundPainter extends AbstractPainter {
private Color bgColor = Color.black;
private final Color bgColor = Color.black;
float bgalpha = 0.6f;
final float bgalpha = 0.6f;
public BackgroundPainter() {
super();

View file

@ -16,10 +16,10 @@ import javax.swing.plaf.metal.MetalScrollButton;
*/
public class MageScrollButton extends MetalScrollButton {
private static ImageIcon buttonLeft;
private static ImageIcon buttonRight;
private static ImageIcon buttonUp;
private static ImageIcon buttonDown;
private static final ImageIcon buttonLeft;
private static final ImageIcon buttonRight;
private static final ImageIcon buttonUp;
private static final ImageIcon buttonDown;
private int width;

View file

@ -27,7 +27,7 @@ import javax.swing.plaf.metal.MetalScrollBarUI;
*/
public class MageScrollbarUI extends MetalScrollBarUI {
private static int ANTI_WIDTH = -3;
private static final int ANTI_WIDTH = -3;
@Override
public void installUI(JComponent c) {

View file

@ -21,11 +21,9 @@ public class MageFloatPane extends JEditorPane {
}
public void setCard(final String text) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
setText(text);
setCaretPosition(0);
}
SwingUtilities.invokeLater(() -> {
setText(text);
setCaretPosition(0);
});
}
}

View file

@ -279,7 +279,7 @@ public class DialogManager extends JComponent implements MouseListener,
@Override
public void mouseDragged(MouseEvent e) {
if (bDragged == true) {
if (bDragged) {
dx = e.getX() - mx;
dy = e.getY() - my;

View file

@ -184,11 +184,7 @@ public class ChoiceDialog extends IDialogPanel {
jButtonOK.setBounds(new Rectangle(w / 2 - 40, h - 50, 60, 60));
jButtonOK.setToolTipText("Ok");
jButtonOK.setObserver(new Command() {
public void execute() {
DialogManager.getManager(gameId).fadeOut((DialogContainer) getParent());
}
});
jButtonOK.setObserver(() -> DialogManager.getManager(gameId).fadeOut((DialogContainer) getParent()));
}
return jButtonOK;
}
@ -204,27 +200,24 @@ public class ChoiceDialog extends IDialogPanel {
jButtonPrevPage.setBounds(new Rectangle(w / 2 - 125, h - 50, 60, 60));
jButtonPrevPage.setVisible(false);
jButtonPrevPage.setObserver(new Command() {
public void execute() {
if (page == 1) {
return;
}
AudioManager.playPrevPage();
page--;
getJButtonPrevPage().setVisible(false);
getJButtonOK().setVisible(false);
getJButtonNextPage().setVisible(false);
revalidate();
displayCards(params.getCards(), params.gameId, params.bigCard);
if (page != 1) {
getJButtonPrevPage().setVisible(true);
}
getJButtonOK().setVisible(true);
getJButtonNextPage().setVisible(true);
jButtonPrevPage.setObserver(() -> {
if (page == 1) {
return;
}
AudioManager.playPrevPage();
page--;
getJButtonPrevPage().setVisible(false);
getJButtonOK().setVisible(false);
getJButtonNextPage().setVisible(false);
revalidate();
displayCards(params.getCards(), params.gameId, params.bigCard);
if (page != 1) {
getJButtonPrevPage().setVisible(true);
}
getJButtonOK().setVisible(true);
getJButtonNextPage().setVisible(true);
});
}
return jButtonPrevPage;

View file

@ -32,9 +32,9 @@ public class StackDialog extends IDialogPanel {
private HoverButton jButtonResponse = null;
private JLayeredPane jLayeredPane;
private FeedbackPanel feedbackPanel;
private final FeedbackPanel feedbackPanel;
private UUID gameId;
private final UUID gameId;
private class CustomLabel extends JLabel {
@ -51,7 +51,7 @@ public class StackDialog extends IDialogPanel {
}
private static final long serialVersionUID = 1L;
};
}
/**
* This is the default constructor

View file

@ -1,8 +1,7 @@
package mage.client.components.tray;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import mage.client.MageFrame;
import org.apache.log4j.Logger;
import org.mage.plugins.card.utils.impl.ImageManagerImpl;
@ -38,14 +37,11 @@ public class MageTray {
trayIcon = new TrayIcon(mainImage);
trayIcon.setImageAutoSize(true);
trayIcon.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
stopBlink();
MageFrame frame = MageFrame.getInstance();
frame.setVisible(true);
frame.setState(Frame.NORMAL);
}
trayIcon.addActionListener(e -> {
stopBlink();
MageFrame frame = MageFrame.getInstance();
frame.setVisible(true);
frame.setState(Frame.NORMAL);
});
final SystemTray tray = SystemTray.getSystemTray();
@ -59,47 +55,17 @@ public class MageTray {
MenuItem aboutItem = new MenuItem("About Mage");
MenuItem exitItem = new MenuItem("Exit");
imagesItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
MageFrame.getInstance().downloadImages();
}
});
imagesItem.addActionListener(e -> MageFrame.getInstance().downloadImages());
iconsItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
MageFrame.getInstance().downloadAdditionalResources();
}
});
iconsItem.addActionListener(e -> MageFrame.getInstance().downloadAdditionalResources());
stopBlinkItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
stopBlink();
}
});
stopBlinkItem.addActionListener(e -> stopBlink());
preferencesItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
MageFrame.getInstance().btnPreferencesActionPerformed(null);
}
});
preferencesItem.addActionListener(e -> MageFrame.getInstance().btnPreferencesActionPerformed(null));
aboutItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
MageFrame.getInstance().btnAboutActionPerformed(null);
}
});
aboutItem.addActionListener(e -> MageFrame.getInstance().btnAboutActionPerformed(null));
exitItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
MageFrame.getInstance().exitApp();
}
});
exitItem.addActionListener(e -> MageFrame.getInstance().exitApp());
popup.add(imagesItem);
popup.add(iconsItem);
@ -129,23 +95,20 @@ public class MageTray {
synchronized (MageTray.class) {
if (state == 0) {
state = 1;
new Thread(new Runnable() {
@Override
public void run() {
try {
int i = 0;
while (state != 3) {
trayIcon.setImage(i == 0 ? mainImage : flashedImage);
Thread.sleep(600);
i = i == 0 ? 1 : 0;
}
trayIcon.setImage(mainImage);
state = 0;
} catch (InterruptedException e) {
e.printStackTrace();
new Thread(() -> {
try {
int i = 0;
while (state != 3) {
trayIcon.setImage(i == 0 ? mainImage : flashedImage);
Thread.sleep(600);
i = i == 0 ? 1 : 0;
}
trayIcon.setImage(mainImage);
state = 0;
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
}
}

View file

@ -31,7 +31,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import mage.cards.Card;
import mage.cards.decks.Deck;

View file

@ -69,7 +69,8 @@ public enum DeckGeneratorCMC {
add(new CMC(7, 100, 0.15f));
}});
private ArrayList<CMC> poolCMCs60, poolCMCs40;
private final ArrayList<CMC> poolCMCs60;
private final ArrayList<CMC> poolCMCs40;
DeckGeneratorCMC(ArrayList<CMC> CMCs60, ArrayList<CMC> CMCs40) {
this.poolCMCs60 = CMCs60;

View file

@ -28,9 +28,7 @@
package mage.client.deck.generator;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.File;
import java.text.SimpleDateFormat;
@ -193,12 +191,9 @@ public class DeckGeneratorDialog {
// Advanced checkbox (enable/disable advanced configuration)
cAdvanced = new JCheckBox("Advanced");
cAdvanced.setToolTipText("Enable advanced configuration options");
cAdvanced.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent itemEvent) {
boolean enable = cAdvanced.isSelected();
enableAdvancedPanel(enable);
}
cAdvanced.addItemListener(itemEvent -> {
boolean enable = cAdvanced.isSelected();
enableAdvancedPanel(enable);
});
// Advanced Checkbox
@ -216,23 +211,17 @@ public class DeckGeneratorDialog {
mainPanel.add(advancedPanel, c);
btnGenerate = new JButton("Ok");
btnGenerate.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
btnGenerate.setEnabled(false);
colorsChooser.setEnabled(false);
selectedColors = (String) colorsChooser.getSelectedItem();
dlg.setVisible(false);
MageFrame.getPreferences().put("genDeckColor", selectedColors);
}
btnGenerate.addActionListener(e -> {
btnGenerate.setEnabled(false);
colorsChooser.setEnabled(false);
selectedColors = (String) colorsChooser.getSelectedItem();
dlg.setVisible(false);
MageFrame.getPreferences().put("genDeckColor", selectedColors);
});
btnCancel = new JButton("Cancel");
btnCancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dlg.setVisible(false);
selectedColors = null;
}
btnCancel.addActionListener(e -> {
dlg.setVisible(false);
selectedColors = null;
});
JButton[] options = {btnGenerate, btnCancel};
JOptionPane optionPane = new JOptionPane(mainPanel, JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, options, options[1]);
@ -308,12 +297,9 @@ public class DeckGeneratorDialog {
c.gridy = 2;
btnReset = new JButton("Reset");
btnReset.setToolTipText("Reset advanced dialog to default values");
btnReset.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
cbCMC.setSelectedItem(DeckGeneratorCMC.Default);
adjustingSliderPanel.resetValues();
}
btnReset.addActionListener(actionEvent -> {
cbCMC.setSelectedItem(DeckGeneratorCMC.Default);
adjustingSliderPanel.resetValues();
});
advancedPanel.add(btnReset, c);

View file

@ -44,12 +44,12 @@ public class DeckGeneratorPool
{
public static int DEFAULT_CREATURE_PERCENTAGE = 38;
public static int DEFAULT_NON_CREATURE_PERCENTAGE = 21;
public static int DEFAULT_LAND_PERCENTAGE = 41;
public static final int DEFAULT_CREATURE_PERCENTAGE = 38;
public static final int DEFAULT_NON_CREATURE_PERCENTAGE = 21;
public static final int DEFAULT_LAND_PERCENTAGE = 41;
private final List<ColoredManaSymbol> allowedColors;
private boolean colorlessAllowed;
private final boolean colorlessAllowed;
private final List<DeckGeneratorCMC.CMC> poolCMCs;
private final int creatureCount;
private final int nonCreatureCount;
@ -58,14 +58,14 @@ public class DeckGeneratorPool
private final int deckSize;
// Count how many copies of the card exists in the deck to check we don't go over 4 copies (or 1 for singleton)
private Map<String, Integer> cardCounts = new HashMap<>();
private final Map<String, Integer> cardCounts = new HashMap<>();
// If there is only a single color selected to generate a deck
private boolean monoColored = false;
// List of cards so far in the deck
private List<Card> deckCards = new ArrayList<>();
private final List<Card> deckCards = new ArrayList<>();
// List of reserve cards found to fix up undersized decks
private List<Card> reserveSpells = new ArrayList<>();
private Deck deck;
private final List<Card> reserveSpells = new ArrayList<>();
private final Deck deck;
/**
* Creates a card pool with specified criterea used when generating a deck.

View file

@ -29,8 +29,6 @@
package mage.client.deck.generator;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.util.*;
import java.util.List;
@ -41,13 +39,13 @@ import java.util.List;
public class RatioAdjustingSliderPanel extends JPanel {
private JStorageSlider creatureSlider, nonCreatureSlider, landSlider;
private List<JLabel> textLabels = new ArrayList<>();
private final List<JLabel> textLabels = new ArrayList<>();
private AdjustingSliderGroup sg;
private class JStorageSlider extends JSlider {
// Slider stores its initial value to revert to when reset
private int defaultValue;
private final int defaultValue;
private int previousValue;
public JStorageSlider(int min, int max, int value) {
@ -86,12 +84,7 @@ public class RatioAdjustingSliderPanel extends JPanel {
storageSliders = new ArrayList<>();
for(JStorageSlider slider: sliders) {
storageSliders.add(slider);
slider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
fireSliderChangedEvent((JStorageSlider) e.getSource());
}
});
slider.addChangeListener(e -> fireSliderChangedEvent((JStorageSlider) e.getSource()));
}
}
public void fireSliderChangedEvent(JStorageSlider source) {
@ -177,19 +170,16 @@ public class RatioAdjustingSliderPanel extends JPanel {
final JLabel label = new JLabel(" " + String.valueOf(slider.getValue()) + "%");
slider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
String value = String.valueOf(slider.getValue());
StringBuilder labelBuilder = new StringBuilder();
// Pad with spaces so all percentage labels are of equal size
for(int i = 0; i < (5-value.length()); i++) {
labelBuilder.append(" ");
}
labelBuilder.append(value);
labelBuilder.append("%");
label.setText(labelBuilder.toString());
slider.addChangeListener(e -> {
String value = String.valueOf(slider.getValue());
StringBuilder labelBuilder = new StringBuilder();
// Pad with spaces so all percentage labels are of equal size
for(int i = 0; i < (5-value.length()); i++) {
labelBuilder.append(" ");
}
labelBuilder.append(value);
labelBuilder.append("%");
label.setText(labelBuilder.toString());
});
return label;
}

View file

@ -83,12 +83,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
private boolean limited = false;
private final SortSetting sortSetting;
private final ActionListener searchAction = new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
jButtonSearchActionPerformed(evt);
}
};
private final ActionListener searchAction = evt -> jButtonSearchActionPerformed(evt);
/**
* Creates new form CardSelector
@ -494,11 +489,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbRed.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
tbRed.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/color_red.png"))); // NOI18N
tbRed.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
tbRed.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tbRedActionPerformed(evt);
}
});
tbRed.addActionListener(evt -> tbRedActionPerformed(evt));
tbColor.add(tbRed);
tbGreen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/color_green_off.png"))); // NOI18N
@ -510,11 +501,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbGreen.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/color_green.png"))); // NOI18N
tbGreen.setVerifyInputWhenFocusTarget(false);
tbGreen.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
tbGreen.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tbGreenActionPerformed(evt);
}
});
tbGreen.addActionListener(evt -> tbGreenActionPerformed(evt));
tbColor.add(tbGreen);
tbBlue.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/color_blueOff.png"))); // NOI18N
@ -525,11 +512,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbBlue.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
tbBlue.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/color_blue.png"))); // NOI18N
tbBlue.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
tbBlue.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tbBlueActionPerformed(evt);
}
});
tbBlue.addActionListener(evt -> tbBlueActionPerformed(evt));
tbColor.add(tbBlue);
tbBlack.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/color_black_off.png"))); // NOI18N
@ -540,11 +523,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbBlack.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
tbBlack.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/color_black.png"))); // NOI18N
tbBlack.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
tbBlack.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tbBlackActionPerformed(evt);
}
});
tbBlack.addActionListener(evt -> tbBlackActionPerformed(evt));
tbColor.add(tbBlack);
tbWhite.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/color_white_off.png"))); // NOI18N
@ -555,11 +534,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbWhite.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
tbWhite.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/color_white.png"))); // NOI18N
tbWhite.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
tbWhite.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tbWhiteActionPerformed(evt);
}
});
tbWhite.addActionListener(evt -> tbWhiteActionPerformed(evt));
tbColor.add(tbWhite);
tbColorless.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/colorless_off.png"))); // NOI18N
@ -570,11 +545,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbColorless.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
tbColorless.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/colorless.png"))); // NOI18N
tbColorless.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
tbColorless.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tbColorlessActionPerformed(evt);
}
});
tbColorless.addActionListener(evt -> tbColorlessActionPerformed(evt));
tbColor.add(tbColorless);
tbColor.add(jSeparator1);
@ -583,11 +554,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
cbExpansionSet.setMinimumSize(new java.awt.Dimension(250, 25));
cbExpansionSet.setName("cbExpansionSet"); // NOI18N
cbExpansionSet.setPreferredSize(new java.awt.Dimension(250, 25));
cbExpansionSet.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbExpansionSetActionPerformed(evt);
}
});
cbExpansionSet.addActionListener(evt -> cbExpansionSetActionPerformed(evt));
tbColor.add(cbExpansionSet);
tbColor.add(jSeparator2);
@ -596,22 +563,14 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
btnBooster.setFocusable(false);
btnBooster.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnBooster.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnBooster.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnBoosterActionPerformed(evt);
}
});
btnBooster.addActionListener(evt -> btnBoosterActionPerformed(evt));
tbColor.add(btnBooster);
btnClear.setText("Clear");
btnClear.setFocusable(false);
btnClear.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnClear.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnClear.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnClearActionPerformed(evt);
}
});
btnClear.addActionListener(evt -> btnClearActionPerformed(evt));
tbColor.add(btnClear);
tbTypes.setFloatable(false);
@ -627,11 +586,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbLand.setFocusable(false);
tbLand.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
tbLand.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
tbLand.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tbLandActionPerformed(evt);
}
});
tbLand.addActionListener(evt -> tbLandActionPerformed(evt));
tbTypes.add(tbLand);
tbCreatures.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/type_creatures.png"))); // NOI18N
@ -642,11 +597,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbCreatures.setFocusable(false);
tbCreatures.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
tbCreatures.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
tbCreatures.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tbCreaturesActionPerformed(evt);
}
});
tbCreatures.addActionListener(evt -> tbCreaturesActionPerformed(evt));
tbTypes.add(tbCreatures);
tbArifiacts.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/type_artifact.png"))); // NOI18N
@ -657,11 +608,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbArifiacts.setFocusable(false);
tbArifiacts.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
tbArifiacts.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
tbArifiacts.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tbArifiactsActionPerformed(evt);
}
});
tbArifiacts.addActionListener(evt -> tbArifiactsActionPerformed(evt));
tbTypes.add(tbArifiacts);
tbSorceries.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/type_sorcery.png"))); // NOI18N
@ -672,11 +619,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbSorceries.setFocusable(false);
tbSorceries.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
tbSorceries.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
tbSorceries.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tbSorceriesActionPerformed(evt);
}
});
tbSorceries.addActionListener(evt -> tbSorceriesActionPerformed(evt));
tbTypes.add(tbSorceries);
tbInstants.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/type_instant.png"))); // NOI18N
@ -687,11 +630,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbInstants.setFocusable(false);
tbInstants.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
tbInstants.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
tbInstants.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tbInstantsActionPerformed(evt);
}
});
tbInstants.addActionListener(evt -> tbInstantsActionPerformed(evt));
tbTypes.add(tbInstants);
tbEnchantments.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/type_enchantment.png"))); // NOI18N
@ -702,11 +641,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbEnchantments.setFocusable(false);
tbEnchantments.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
tbEnchantments.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
tbEnchantments.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tbEnchantmentsActionPerformed(evt);
}
});
tbEnchantments.addActionListener(evt -> tbEnchantmentsActionPerformed(evt));
tbTypes.add(tbEnchantments);
tbPlaneswalkers.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/type_planeswalker.png"))); // NOI18N
@ -717,11 +652,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
tbPlaneswalkers.setFocusable(false);
tbPlaneswalkers.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
tbPlaneswalkers.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
tbPlaneswalkers.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tbPlaneswalkersActionPerformed(evt);
}
});
tbPlaneswalkers.addActionListener(evt -> tbPlaneswalkersActionPerformed(evt));
tbTypes.add(tbPlaneswalkers);
tbTypes.add(jSeparator6);
@ -730,11 +661,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
chkPiles.setFocusable(false);
chkPiles.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
chkPiles.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
chkPiles.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
chkPilesActionPerformed(evt);
}
});
chkPiles.addActionListener(evt -> chkPilesActionPerformed(evt));
tbTypes.add(chkPiles);
tbTypes.add(jSeparator3);
@ -742,11 +669,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
cbSortBy.setMaximumSize(new java.awt.Dimension(120, 20));
cbSortBy.setMinimumSize(new java.awt.Dimension(120, 20));
cbSortBy.setPreferredSize(new java.awt.Dimension(120, 20));
cbSortBy.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbSortByActionPerformed(evt);
}
});
cbSortBy.addActionListener(evt -> cbSortByActionPerformed(evt));
tbTypes.add(cbSortBy);
tbTypes.add(jSeparator4);
@ -761,11 +684,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
jToggleListView.setMaximumSize(new java.awt.Dimension(37, 22));
jToggleListView.setMinimumSize(new java.awt.Dimension(37, 22));
jToggleListView.setPreferredSize(new java.awt.Dimension(37, 22));
jToggleListView.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jToggleListViewActionPerformed(evt);
}
});
jToggleListView.addActionListener(evt -> jToggleListViewActionPerformed(evt));
tbTypes.add(jToggleListView);
bgView.add(jToggleCardView);
@ -780,11 +699,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
jToggleCardView.setName(""); // NOI18N
jToggleCardView.setPreferredSize(new java.awt.Dimension(37, 22));
jToggleCardView.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
jToggleCardView.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jToggleCardViewActionPerformed(evt);
}
});
jToggleCardView.addActionListener(evt -> jToggleCardViewActionPerformed(evt));
tbTypes.add(jToggleCardView);
cardSelectorScrollPane.setToolTipText("<HTML>Double click to add the card to the main deck.<br/>\nALT + Double click to add the card to the sideboard.");
@ -798,11 +713,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
jButtonAddToMain.setMaximumSize(new java.awt.Dimension(42, 23));
jButtonAddToMain.setMinimumSize(new java.awt.Dimension(42, 23));
jButtonAddToMain.setPreferredSize(new java.awt.Dimension(40, 28));
jButtonAddToMain.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonAddToMainActionPerformed(evt);
}
});
jButtonAddToMain.addActionListener(evt -> jButtonAddToMainActionPerformed(evt));
jButtonAddToSideboard.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/sideboard_in.png"))); // NOI18N
jButtonAddToSideboard.setToolTipText("<html>Add selected cards to sideboard.<br/>\nAlternative: <strong>ALT key + Double click</strong> the card in card selector to move a card to the sideboard.");
@ -810,11 +721,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
jButtonAddToSideboard.setMaximumSize(new java.awt.Dimension(100, 30));
jButtonAddToSideboard.setMinimumSize(new java.awt.Dimension(10, 30));
jButtonAddToSideboard.setPreferredSize(new java.awt.Dimension(40, 28));
jButtonAddToSideboard.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonAddToSideboardActionPerformed(evt);
}
});
jButtonAddToSideboard.addActionListener(evt -> jButtonAddToSideboardActionPerformed(evt));
jLabelSearch.setText("Search:");
jLabelSearch.setToolTipText("Searches for card names and in the rule text of the card.");
@ -823,19 +730,11 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
jButtonSearch.setText("Search");
jButtonSearch.setToolTipText("Performs the search.");
jButtonSearch.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonSearchActionPerformed(evt);
}
});
jButtonSearch.addActionListener(evt -> jButtonSearchActionPerformed(evt));
jButtonClean.setText("Clear");
jButtonClean.setToolTipText("Clears the search field.");
jButtonClean.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonCleanActionPerformed(evt);
}
});
jButtonClean.addActionListener(evt -> jButtonCleanActionPerformed(evt));
cardCountLabel.setText("Card count:");
cardCountLabel.setToolTipText("Number of cards currently shown.");
@ -848,11 +747,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
jButtonRemoveFromMain.setMaximumSize(new java.awt.Dimension(42, 23));
jButtonRemoveFromMain.setMinimumSize(new java.awt.Dimension(42, 23));
jButtonRemoveFromMain.setPreferredSize(new java.awt.Dimension(40, 28));
jButtonRemoveFromMain.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonRemoveFromMainActionPerformed(evt);
}
});
jButtonRemoveFromMain.addActionListener(evt -> jButtonRemoveFromMainActionPerformed(evt));
jButtonRemoveFromSideboard.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/sideboard_out.png"))); // NOI18N
jButtonRemoveFromSideboard.setToolTipText("Remove selected cards from sideboard.");
@ -860,11 +755,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
jButtonRemoveFromSideboard.setMaximumSize(new java.awt.Dimension(10, 30));
jButtonRemoveFromSideboard.setMinimumSize(new java.awt.Dimension(100, 30));
jButtonRemoveFromSideboard.setPreferredSize(new java.awt.Dimension(40, 28));
jButtonRemoveFromSideboard.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonRemoveFromSideboardActionPerformed(evt);
}
});
jButtonRemoveFromSideboard.addActionListener(evt -> jButtonRemoveFromSideboardActionPerformed(evt));
javax.swing.GroupLayout cardSelectorBottomPanelLayout = new javax.swing.GroupLayout(cardSelectorBottomPanel);
cardSelectorBottomPanel.setLayout(cardSelectorBottomPanelLayout);
@ -1132,12 +1023,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
}
public void refresh() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
currentView.refresh();
}
});
SwingUtilities.invokeLater(() -> currentView.refresh());
}
private TableModel mainModel;

View file

@ -55,9 +55,9 @@ import mage.view.CardsView;
*/
public class DeckArea extends javax.swing.JPanel {
private CardEventSource maindeckVirtualEvent = new CardEventSource();
private CardEventSource sideboardVirtualEvent = new CardEventSource();
private Set<UUID> hiddenCards = new HashSet<>();
private final CardEventSource maindeckVirtualEvent = new CardEventSource();
private final CardEventSource sideboardVirtualEvent = new CardEventSource();
private final Set<UUID> hiddenCards = new HashSet<>();
private Deck lastDeck = new Deck();
private BigCard lastBigCard = null;
private int dividerLocationNormal = 0;

View file

@ -44,6 +44,7 @@ import java.util.concurrent.TimeUnit;
import javax.swing.*;
import javax.swing.Timer;
import javax.swing.filechooser.FileFilter;
import mage.cards.Card;
import mage.cards.Sets;
import mage.cards.decks.Deck;
@ -73,7 +74,6 @@ import mage.view.SimpleCardView;
import org.apache.log4j.Logger;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class DeckEditorPanel extends javax.swing.JPanel {
@ -82,7 +82,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
private final JFileChooser fcSelectDeck;
private final JFileChooser fcImportDeck;
private Deck deck = new Deck();
private Map<UUID, Card> temporaryCards = new HashMap<>(); // Cards dragged out of one part of the view into another
private final Map<UUID, Card> temporaryCards = new HashMap<>(); // Cards dragged out of one part of the view into another
private boolean isShowCardInfo = false;
private UUID tableId;
private DeckEditorMode mode;
@ -108,21 +108,18 @@ public class DeckEditorPanel extends javax.swing.JPanel {
jSplitPane1.setOpaque(false);
restoreDividerLocationsAndDeckAreaSettings();
countdown = new Timer(1000,
new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (--timeout > 0) {
setTimeout(timeout);
} else {
if (updateDeckTask != null) {
updateDeckTask.cancel(true);
e -> {
if (--timeout > 0) {
setTimeout(timeout);
} else {
if (updateDeckTask != null) {
updateDeckTask.cancel(true);
}
setTimeout(0);
countdown.stop();
removeDeckEditor();
}
setTimeout(0);
countdown.stop();
removeDeckEditor();
}
}
});
});
// Set up tracking to save the deck editor settings when the deck editor is hidden.
addHierarchyListener((HierarchyEvent e) -> {
@ -265,213 +262,204 @@ public class DeckEditorPanel extends javax.swing.JPanel {
for (ICardGrid component : this.cardSelector.getCardGridComponents()) {
component.clearCardEventListeners();
component.addCardEventListener(
new Listener<Event>() {
@Override
public void event(Event event) {
switch (event.getEventName()) {
case "double-click":
moveSelectorCardToDeck(event);
break;
case "alt-double-click":
if (mode == DeckEditorMode.FREE_BUILDING) {
moveSelectorCardToSideboard(event);
} else {
// because in match mode selector is used as sideboard the card goes to deck also for shift click
(Listener<Event>) event -> {
switch (event.getEventName()) {
case "double-click":
moveSelectorCardToDeck(event);
}
break;
case "remove-main":
DeckEditorPanel.this.deckArea.getDeckList().removeSelection();
break;
case "remove-sideboard":
DeckEditorPanel.this.deckArea.getSideboardList().removeSelection();
break;
}
refreshDeck();
}
});
break;
case "alt-double-click":
if (mode == DeckEditorMode.FREE_BUILDING) {
moveSelectorCardToSideboard(event);
} else {
// because in match mode selector is used as sideboard the card goes to deck also for shift click
moveSelectorCardToDeck(event);
}
break;
case "remove-main":
DeckEditorPanel.this.deckArea.getDeckList().removeSelection();
break;
case "remove-sideboard":
DeckEditorPanel.this.deckArea.getSideboardList().removeSelection();
break;
}
refreshDeck();
});
}
this.deckArea.clearDeckEventListeners();
this.deckArea.addDeckEventListener(
new Listener<Event>() {
@Override
public void event(Event event) {
if (mode.equals(DeckEditorMode.FREE_BUILDING)) {
switch (event.getEventName()) {
case "double-click": {
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getCards()) {
if (card.getId().equals(cardView.getId())) {
deck.getCards().remove(card);
break;
(Listener<Event>) event -> {
if (mode == DeckEditorMode.FREE_BUILDING){
switch (event.getEventName()) {
case "double-click": {
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getCards()) {
if (card.getId().equals(cardView.getId())) {
deck.getCards().remove(card);
break;
}
}
hidePopup();
refreshDeck();
break;
}
hidePopup();
refreshDeck();
break;
}
case "alt-double-click": {
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getCards()) {
if (card.getId().equals(cardView.getId())) {
deck.getCards().remove(card);
deck.getSideboard().add(card);
break;
case "alt-double-click": {
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getCards()) {
if (card.getId().equals(cardView.getId())) {
deck.getCards().remove(card);
deck.getSideboard().add(card);
break;
}
}
hidePopup();
refreshDeck();
break;
}
hidePopup();
refreshDeck();
break;
}
case "set-number": {
setCardNumberToCardsList(event, deck.getCards());
break;
}
case "remove-specific-card": {
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getCards()) {
if (card.getId().equals(cardView.getId())) {
deck.getCards().remove(card);
storeTemporaryCard(card);
break;
case "set-number": {
setCardNumberToCardsList(event, deck.getCards());
break;
}
case "remove-specific-card": {
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getCards()) {
if (card.getId().equals(cardView.getId())) {
deck.getCards().remove(card);
storeTemporaryCard(card);
break;
}
}
break;
}
case "add-specific-card": {
SimpleCardView cardView = (CardView) event.getSource();
deck.getCards().add(retrieveTemporaryCard(cardView));
break;
}
break;
}
case "add-specific-card": {
SimpleCardView cardView = (CardView) event.getSource();
deck.getCards().add(retrieveTemporaryCard(cardView));
break;
}else{
// constructing phase or sideboarding during match -> card goes always to sideboard
switch (event.getEventName()) {
case "double-click":
case "alt-double-click": {
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getCards()) {
if (card.getId().equals(cardView.getId())) {
deck.getCards().remove(card);
deck.getSideboard().add(card);
cardSelector.loadSideboard(new ArrayList<>(deck.getSideboard()), getBigCard());
break;
}
}
hidePopup();
refreshDeck();
break;
}
case "remove-specific-card": {
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getCards()) {
if (card.getId().equals(cardView.getId())) {
deck.getCards().remove(card);
storeTemporaryCard(card);
break;
}
}
break;
}
case "add-specific-card": {
SimpleCardView cardView = (CardView) event.getSource();
deck.getCards().add(retrieveTemporaryCard(cardView));
break;
}
}
}
} else {
// constructing phase or sideboarding during match -> card goes always to sideboard
switch (event.getEventName()) {
case "double-click":
case "alt-double-click": {
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getCards()) {
if (card.getId().equals(cardView.getId())) {
deck.getCards().remove(card);
deck.getSideboard().add(card);
cardSelector.loadSideboard(new ArrayList<>(deck.getSideboard()), getBigCard());
break;
}
}
hidePopup();
refreshDeck();
break;
}
case "remove-specific-card": {
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getCards()) {
if (card.getId().equals(cardView.getId())) {
deck.getCards().remove(card);
storeTemporaryCard(card);
break;
}
}
break;
}
case "add-specific-card": {
SimpleCardView cardView = (CardView) event.getSource();
deck.getCards().add(retrieveTemporaryCard(cardView));
break;
}
}
}
}
});
});
this.deckArea.clearSideboardEventListeners();
this.deckArea.addSideboardEventListener(
new Listener<Event>() {
@Override
public void event(Event event) {
if (mode.equals(DeckEditorMode.FREE_BUILDING)) {
// normal edit mode
switch (event.getEventName()) {
case "double-click":
// remove card from sideboard (don't add it to deck)
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getSideboard()) {
if (card.getId().equals(cardView.getId())) {
deck.getSideboard().remove(card);
break;
(Listener<Event>) event -> {
if (mode == DeckEditorMode.FREE_BUILDING) {
// normal edit mode
switch (event.getEventName()) {
case "double-click":
// remove card from sideboard (don't add it to deck)
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getSideboard()) {
if (card.getId().equals(cardView.getId())) {
deck.getSideboard().remove(card);
break;
}
}
}
hidePopup();
refreshDeck();
break;
case "alt-double-click":
// remove card from sideboard
cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getSideboard()) {
if (card.getId().equals(cardView.getId())) {
deck.getSideboard().remove(card);
deck.getCards().add(card);
break;
hidePopup();
refreshDeck();
break;
case "alt-double-click":
// remove card from sideboard
cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getSideboard()) {
if (card.getId().equals(cardView.getId())) {
deck.getSideboard().remove(card);
deck.getCards().add(card);
break;
}
}
hidePopup();
refreshDeck();
break;
case "set-number": {
setCardNumberToCardsList(event, deck.getSideboard());
break;
}
case "remove-specific-card": {
cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getSideboard()) {
if (card.getId().equals(cardView.getId())) {
deck.getSideboard().remove(card);
storeTemporaryCard(card);
break;
}
}
break;
}
case "add-specific-card": {
cardView = (CardView) event.getSource();
deck.getSideboard().add(retrieveTemporaryCard(cardView));
break;
}
hidePopup();
refreshDeck();
break;
case "set-number": {
setCardNumberToCardsList(event, deck.getSideboard());
break;
}
case "remove-specific-card": {
cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getSideboard()) {
if (card.getId().equals(cardView.getId())) {
deck.getSideboard().remove(card);
storeTemporaryCard(card);
break;
} else {
// construct phase or sideboarding during match
switch (event.getEventName()) {
case "remove-specific-card": {
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getSideboard()) {
if (card.getId().equals(cardView.getId())) {
deck.getSideboard().remove(card);
storeTemporaryCard(card);
break;
}
}
break;
}
break;
}
case "add-specific-card": {
cardView = (CardView) event.getSource();
deck.getSideboard().add(retrieveTemporaryCard(cardView));
break;
case "add-specific-card": {
SimpleCardView cardView = (CardView) event.getSource();
deck.getSideboard().add(retrieveTemporaryCard(cardView));
break;
}
case "double-click":
case "alt-double-click":
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getSideboard()) {
if (card.getId().equals(cardView.getId())) {
deck.getSideboard().remove(card);
deck.getCards().add(card);
break;
}
}
hidePopup();
refreshDeck();
break;
}
}
} else {
// construct phase or sideboarding during match
switch (event.getEventName()) {
case "remove-specific-card": {
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getSideboard()) {
if (card.getId().equals(cardView.getId())) {
deck.getSideboard().remove(card);
storeTemporaryCard(card);
break;
}
}
break;
}
case "add-specific-card": {
SimpleCardView cardView = (CardView) event.getSource();
deck.getSideboard().add(retrieveTemporaryCard(cardView));
break;
}
case "double-click":
case "alt-double-click":
SimpleCardView cardView = (SimpleCardView) event.getSource();
for (Card card : deck.getSideboard()) {
if (card.getId().equals(cardView.getId())) {
deck.getSideboard().remove(card);
deck.getCards().add(card);
break;
}
}
hidePopup();
refreshDeck();
break;
}
}
}
});
});
refreshDeck();
this.setVisible(true);
@ -485,7 +473,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
List<Card> toDelete = new ArrayList<>();
for (Card card : cards) {
if (card.getName().equals(cardView.getName())
&& card.getCardNumber() == cardView.getCardNumber()
&& Objects.equals(card.getCardNumber(), cardView.getCardNumber())
&& card.getExpansionSetCode().equals(cardView.getExpansionSetCode())) {
cardsFound++;
if (cardsFound > numberToSet) {
@ -515,9 +503,8 @@ public class DeckEditorPanel extends javax.swing.JPanel {
CardInfo cardInfo = CardRepository.instance.findCard(cardView.getExpansionSetCode(), cardView.getCardNumber());
Card card = null;
if (mode == DeckEditorMode.SIDEBOARDING || mode == DeckEditorMode.LIMITED_BUILDING) {
Iterator sideboard = deck.getSideboard().iterator();
while (sideboard.hasNext()) {
card = (Card) sideboard.next();
for (Object o : deck.getSideboard()) {
card = (Card) o;
if (card.getId().equals(cardView.getId())) {
break;
}
@ -611,7 +598,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
AudioManager.playOnCountdown1();
}
if (timeToSubmit > 0) {
timeToSubmit --;
timeToSubmit--;
btnSubmitTimer.setText("Submit (" + timeToSubmit + ")");
btnSubmitTimer.setToolTipText("Submit your deck in " + timeToSubmit + " seconds!");
}
@ -658,105 +645,62 @@ public class DeckEditorPanel extends javax.swing.JPanel {
lblDeckName.setText("Deck Name:");
btnSave.setText("Save");
btnSave.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSaveActionPerformed(evt);
}
});
btnSave.addActionListener(evt -> btnSaveActionPerformed(evt));
btnLoad.setText("Load");
btnLoad.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnLoadActionPerformed(evt);
}
});
btnLoad.addActionListener(evt -> btnLoadActionPerformed(evt));
btnNew.setText("New");
btnNew.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNewActionPerformed(evt);
}
});
btnNew.addActionListener(evt -> btnNewActionPerformed(evt));
btnExit.setText("Exit");
btnExit.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnExitActionPerformed(evt);
}
});
btnExit.addActionListener(evt -> btnExitActionPerformed(evt));
btnImport.setText("Import");
btnImport.setName("btnImport"); // NOI18N
btnImport.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
Object[] options = {"File", "Clipboard", "Append from Clipboard"};
btnImport.addActionListener(evt -> {
Object[] options = {"File", "Clipboard", "Append from Clipboard"};
int n = JOptionPane.showOptionDialog(MageFrame.getDesktop(),
"Where would you like to import from?",
"Deck import",
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
options,
options[0]
);
int n = JOptionPane.showOptionDialog(MageFrame.getDesktop(),
"Where would you like to import from?",
"Deck import",
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
options,
options[0]
);
logger.info(n);
logger.info(n);
switch (n) {
case 0:
btnImportActionPerformed(evt);
break;
case 1:
btnImportFromClipboardActionPerformed(evt);
case 2:
btnImportFromClipboardActionWAppendPerformed(evt);
}
switch (n) {
case 0:
btnImportActionPerformed(evt);
break;
case 1:
btnImportFromClipboardActionPerformed(evt);
case 2:
btnImportFromClipboardActionWAppendPerformed(evt);
}
});
btnSubmit.setText("Submit");
btnSubmitTimer.setToolTipText("Submit your deck now!");
btnSubmit.setName("btnSubmit"); // NOI18N
btnSubmit.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSubmitActionPerformed(evt);
}
});
btnSubmit.addActionListener(evt -> btnSubmitActionPerformed(evt));
btnSubmitTimer.setText("Submit (60s)");
btnSubmitTimer.setToolTipText("Submit your deck in one minute!");
btnSubmitTimer.setName("btnSubmitTimer");
btnSubmitTimer.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSubmitTimerActionPerformed(evt);
}
});
btnSubmitTimer.addActionListener(evt -> btnSubmitTimerActionPerformed(evt));
btnAddLand.setText("Add Land");
btnAddLand.setName("btnAddLand"); // NOI18N
btnAddLand.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnAddLandActionPerformed(evt);
}
});
btnAddLand.addActionListener(evt -> btnAddLandActionPerformed(evt));
btnGenDeck.setText("Generate");
btnGenDeck.setName("btnGenDeck");
btnGenDeck.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnGenDeckActionPerformed(evt);
}
});
btnGenDeck.addActionListener(evt -> btnGenDeckActionPerformed(evt));
txtTimeRemaining.setEditable(false);
txtTimeRemaining.setForeground(java.awt.Color.red);
@ -767,84 +711,84 @@ public class DeckEditorPanel extends javax.swing.JPanel {
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
/*.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE))*/
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(lblDeckName)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtDeckName, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE))
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(btnSave)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnLoad)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnNew)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnExit))
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(btnImport)
.addContainerGap()
.addComponent(btnGenDeck)
.addContainerGap()
.addComponent(btnAddLand)
.addContainerGap()
.addComponent(btnSubmit)
.addContainerGap()
.addComponent(btnSubmitTimer))
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(txtTimeRemaining))
)
.addContainerGap()));
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(lblDeckName)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtDeckName, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE))
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(btnSave)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnLoad)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnNew)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnExit))
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(btnImport)
.addContainerGap()
.addComponent(btnGenDeck)
.addContainerGap()
.addComponent(btnAddLand)
.addContainerGap()
.addComponent(btnSubmit)
.addContainerGap()
.addComponent(btnSubmitTimer))
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(txtTimeRemaining))
)
.addContainerGap()));
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtDeckName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblDeckName))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnSave)
.addComponent(btnLoad)
.addComponent(btnNew)
.addComponent(btnExit))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnImport)
.addComponent(btnGenDeck)
.addComponent(btnAddLand)
.addComponent(btnSubmit)
.addComponent(btnSubmitTimer))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtTimeRemaining))
//.addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, isShowCardInfo ? 30 : 159, Short.MAX_VALUE)
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 104, Short.MAX_VALUE)
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)));
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtDeckName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblDeckName))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnSave)
.addComponent(btnLoad)
.addComponent(btnNew)
.addComponent(btnExit))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnImport)
.addComponent(btnGenDeck)
.addComponent(btnAddLand)
.addComponent(btnSubmit)
.addComponent(btnSubmitTimer))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtTimeRemaining))
//.addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, isShowCardInfo ? 30 : 159, Short.MAX_VALUE)
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 104, Short.MAX_VALUE)
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 604, Short.MAX_VALUE)));
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 604, Short.MAX_VALUE)));
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 615, Short.MAX_VALUE));
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 615, Short.MAX_VALUE));
}
/**
@ -1054,17 +998,15 @@ public class DeckEditorPanel extends javax.swing.JPanel {
timeToSubmit = 60;
this.btnSubmitTimer.setEnabled(false);
ScheduledFuture scheduledFuture = scheduledExecutorService.schedule(new Callable() {
public Object call() throws Exception {
if (updateDeckTask != null) {
updateDeckTask.cancel(true);
}
if (SessionHandler.submitDeck(tableId, deck.getDeckCardLists())) {
removeDeckEditor();
}
return null;
ScheduledFuture scheduledFuture = scheduledExecutorService.schedule((Callable) () -> {
if (updateDeckTask != null) {
updateDeckTask.cancel(true);
}
if (SessionHandler.submitDeck(tableId, deck.getDeckCardLists())) {
removeDeckEditor();
}
return null;
}, 60, TimeUnit.SECONDS);
}//GEN-LAST:event_btnSubmitTimerActionPerformed
@ -1081,7 +1023,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
deck = Deck.load(DeckImporterUtil.importDeck(path), true, true);
} catch (GameException ex) {
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Error loading generated deck", JOptionPane.ERROR_MESSAGE);
}catch (DeckGeneratorException ex) {
} catch (DeckGeneratorException ex) {
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Generator error", JOptionPane.ERROR_MESSAGE);
} finally {
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));

View file

@ -23,18 +23,8 @@ public class DeckImportFromClipboardDialog extends JDialog {
setModal(true);
getRootPane().setDefaultButton(buttonOK);
buttonOK.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
onOK();
}
});
buttonCancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
onCancel();
}
});
buttonOK.addActionListener(e -> onOK());
buttonCancel.addActionListener(e -> onCancel());
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
@ -45,12 +35,7 @@ public class DeckImportFromClipboardDialog extends JDialog {
});
// Close on "ESC"
contentPane.registerKeyboardAction(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
onCancel();
}
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
}
private void onOK() {
@ -94,21 +79,15 @@ public class DeckImportFromClipboardDialog extends JDialog {
javax.swing.border.TitledBorder.TOP, new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12),
java.awt.Color.BLACK), contentPane.getBorder()));
contentPane.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
@Override
public void propertyChange(java.beans.PropertyChangeEvent e) {
if ("border".equals(e.getPropertyName())) {
throw new RuntimeException();
}
contentPane.addPropertyChangeListener(e -> {
if ("border".equals(e.getPropertyName())) {
throw new RuntimeException();
}
});
contentPane.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
@Override
public void propertyChange(java.beans.PropertyChangeEvent e) {
if ("border".equals(e.getPropertyName())) {
throw new RuntimeException();
}
contentPane.addPropertyChangeListener(e -> {
if ("border".equals(e.getPropertyName())) {
throw new RuntimeException();
}
});

View file

@ -41,10 +41,10 @@ public abstract class SortSetting {
boolean ascending;
boolean pilesToggle;
String prefSortBy;
String prefSortIndex;
String prefSortAscending;
String prefPilesToggle;
final String prefSortBy;
final String prefSortIndex;
final String prefSortAscending;
final String prefPilesToggle;
public SortSetting(String prefSortBy, String prefSortIndex, String prefSortAscending, String prefPilesToggle) {
this.prefSortBy = prefSortBy;

View file

@ -31,8 +31,6 @@ import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
@ -58,8 +56,8 @@ public final class CollectionViewerPanel extends JPanel {
private static final Logger logger = Logger.getLogger(CollectionViewerPanel.class);
protected static String LAYOYT_CONFIG_KEY = "collectionViewerLayoutConfig";
protected static String FORMAT_CONFIG_KEY = "collectionViewerFormat";
protected static final String LAYOYT_CONFIG_KEY = "collectionViewerLayoutConfig";
protected static final String FORMAT_CONFIG_KEY = "collectionViewerFormat";
public CollectionViewerPanel() {
initComponents();
@ -107,26 +105,20 @@ public final class CollectionViewerPanel extends JPanel {
small3x3.setForeground(Color.white);
boolean selected3x3 = MageFrame.getPreferences().get(LAYOYT_CONFIG_KEY, MageBook.LAYOUT_3x3).equals(MageBook.LAYOUT_3x3);
small3x3.setSelected(selected3x3);
small3x3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
big4x4.setSelected(false);
mageBook.updateSize(MageBook.LAYOUT_3x3);
MageFrame.getPreferences().put(LAYOYT_CONFIG_KEY, MageBook.LAYOUT_3x3);
}
small3x3.addActionListener(e -> {
big4x4.setSelected(false);
mageBook.updateSize(MageBook.LAYOUT_3x3);
MageFrame.getPreferences().put(LAYOYT_CONFIG_KEY, MageBook.LAYOUT_3x3);
});
jPanel1.add(small3x3);
big4x4 = new JRadioButton("4x4");
big4x4.setForeground(Color.white);
big4x4.setSelected(!selected3x3);
big4x4.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
small3x3.setSelected(false);
mageBook.updateSize(MageBook.LAYOUT_4x4);
MageFrame.getPreferences().put(LAYOYT_CONFIG_KEY, MageBook.LAYOUT_4x4);
}
big4x4.addActionListener(e -> {
small3x3.setSelected(false);
mageBook.updateSize(MageBook.LAYOUT_4x4);
MageFrame.getPreferences().put(LAYOYT_CONFIG_KEY, MageBook.LAYOUT_4x4);
});
jPanel1.add(big4x4);
@ -143,31 +135,18 @@ public final class CollectionViewerPanel extends JPanel {
jPanel1.add(buttonPanel);
JButton prev = new JButton("Prev");
prev.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
mageBook.prev();
}
});
prev.addActionListener(e -> mageBook.prev());
buttonPanel.add(prev);
JButton next = new JButton("Next");
next.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
mageBook.next();
}
});
next.addActionListener(e -> mageBook.next());
buttonPanel.add(next);
formats.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (mageBook != null) {
String format = (String)formats.getSelectedItem();
MageFrame.getPreferences().put(CollectionViewerPanel.FORMAT_CONFIG_KEY, format);
mageBook.updateDispayedSets(format);
}
formats.addActionListener(e -> {
if (mageBook != null) {
String format = (String)formats.getSelectedItem();
MageFrame.getPreferences().put(CollectionViewerPanel.FORMAT_CONFIG_KEY, format);
mageBook.updateDispayedSets(format);
}
});
@ -197,12 +176,7 @@ public final class CollectionViewerPanel extends JPanel {
);
btnExit.setText("Exit");
btnExit.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnExitActionPerformed(evt);
}
});
btnExit.addActionListener(evt -> btnExitActionPerformed(evt));
}

View file

@ -36,7 +36,6 @@ import java.awt.image.BufferedImage;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import javax.imageio.ImageIO;
@ -52,7 +51,6 @@ import mage.client.MageFrame;
import mage.client.cards.BigCard;
import mage.client.components.HoverButton;
import mage.client.plugins.impl.Plugins;
import mage.client.util.Command;
import mage.client.util.Config;
import mage.client.util.ImageHelper;
import mage.client.util.NaturalOrderCardNumberComparator;
@ -110,32 +108,26 @@ public class MageBook extends JComponent {
pageLeft = new HoverButton(null, image, image, image, new Rectangle(64, 64));
pageLeft.setBounds(0, 0, 64, 64);
pageLeft.setVisible(false);
pageLeft.setObserver(new Command() {
@Override
public void execute() {
currentPage--;
if (currentPage == 0) {
pageLeft.setVisible(false);
}
pageRight.setVisible(true);
AudioManager.playPrevPage();
showCards();
pageLeft.setObserver(() -> {
currentPage--;
if (currentPage == 0) {
pageLeft.setVisible(false);
}
pageRight.setVisible(true);
AudioManager.playPrevPage();
showCards();
});
image = ImageHelper.loadImage(RIGHT_PAGE_BUTTON_IMAGE_PATH);
pageRight = new HoverButton(null, image, image, image, new Rectangle(64, 64));
pageRight.setBounds(conf.WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH - 64, 0, 64, 64);
pageRight.setVisible(false);
pageRight.setObserver(new Command() {
@Override
public void execute() {
currentPage++;
pageLeft.setVisible(true);
pageRight.setVisible(false);
AudioManager.playNextPage();
showCards();
}
pageRight.setObserver(() -> {
currentPage++;
pageLeft.setVisible(true);
pageRight.setVisible(false);
AudioManager.playNextPage();
showCards();
});
addSetTabs();
@ -179,21 +171,18 @@ public class MageBook extends JComponent {
tab.setBounds(0, y, 39, 120);
final String _set = set;
final int _index = count;
tab.setObserver(new Command() {
@Override
public void execute() {
if (!currentSet.equals(_set) || currentPage != 0) {
AudioManager.playAnotherTab();
synchronized (MageBook.this) {
selectedTab = _index;
}
currentPage = 0;
currentSet = _set;
pageLeft.setVisible(false);
pageRight.setVisible(false);
addSetTabs();
showCards();
tab.setObserver(() -> {
if (!currentSet.equals(_set) || currentPage != 0) {
AudioManager.playAnotherTab();
synchronized (MageBook.this) {
selectedTab = _index;
}
currentPage = 0;
currentSet = _set;
pageLeft.setVisible(false);
pageRight.setVisible(false);
addSetTabs();
showCards();
}
});
tabs.add(tab);
@ -269,7 +258,7 @@ public class MageBook extends JComponent {
CardCriteria criteria = new CardCriteria();
criteria.setCodes(set);
List<CardInfo> cards = CardRepository.instance.findCards(criteria);
Collections.sort(cards, new NaturalOrderCardNumberComparator());
cards.sort(new NaturalOrderCardNumberComparator());
int start = page * conf.CARDS_PER_PAGE;
int end = page * conf.CARDS_PER_PAGE + conf.CARDS_PER_PAGE;
if (end > cards.size()) {
@ -334,12 +323,15 @@ public class MageBook extends JComponent {
}
public void updateSize(String size) {
if (size.equals(LAYOUT_3x3)) {
this.conf = new _3x3Configuration();
} else if (size.equals(LAYOUT_4x4)) {
this.conf = new _4x4Configuration();
} else {
return;
switch (size) {
case LAYOUT_3x3:
this.conf = new _3x3Configuration();
break;
case LAYOUT_4x4:
this.conf = new _4x4Configuration();
break;
default:
return;
}
currentPage = 0;
pageLeft.setVisible(false);
@ -412,7 +404,7 @@ public class MageBook extends JComponent {
private ImagePanel jPanelCenter;
private JPanel jPanelRight;
private JLayeredPane jLayeredPane;
private BigCard bigCard;
private final BigCard bigCard;
private HoverButton pageLeft;
private HoverButton pageRight;
@ -423,7 +415,7 @@ public class MageBook extends JComponent {
private static final Logger log = Logger.getLogger(MageBook.class);
private Dimension cardDimension;
private java.util.List<String> setsToDisplay = new ArrayList<>();
private java.util.List<HoverButton> tabs = new ArrayList<>();
private final java.util.List<HoverButton> tabs = new ArrayList<>();
private int selectedTab;
private static final String CENTER_PANEL_IMAGE_PATH = "/book_bg.jpg";

View file

@ -1,6 +1,7 @@
package mage.client.deckeditor.collection.viewer;
import javax.swing.JFrame;
import javax.swing.*;
import mage.cards.repository.CardScanner;
import mage.client.plugins.impl.Plugins;
import org.mage.card.arcane.ManaSymbols;
@ -14,7 +15,7 @@ public class TestMageBook extends JFrame {
ManaSymbols.loadImages();
CardScanner.scan();
JFrame frame = new TestMageBook();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.add(new MageBook(null));
frame.pack();
frame.setVisible(true);

View file

@ -36,7 +36,6 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
@ -76,7 +75,7 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
private static final Logger log = Logger.getLogger(TableModel.class);
protected CardEventSource cardEventSource = new CardEventSource();
protected final CardEventSource cardEventSource = new CardEventSource();
protected BigCard bigCard;
protected UUID gameId;
private final Map<UUID, CardView> cards = new LinkedHashMap<>();
@ -437,7 +436,7 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
recentAscending = ascending;
MageCardComparator sorter = new MageCardComparator(column, ascending);
Collections.sort(view, sorter);
view.sort(sorter);
fireTableDataChanged();

View file

@ -77,11 +77,7 @@ public class AboutDialog extends MageDialog {
setTitle("About XMage");
btnOk.setText("OK");
btnOk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnOkActionPerformed(evt);
}
});
btnOk.addActionListener(this::btnOkActionPerformed);
jLabel1.setText("XMage client");

View file

@ -29,7 +29,6 @@ package mage.client.dialog;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
@ -73,7 +72,7 @@ public class AddLandDialog extends MageDialog {
public void showDialog(Deck deck, DeckEditorMode mode) {
this.deck = deck;
SortedSet<String> landSetNames = new TreeSet<>();
if (!mode.equals(DeckEditorMode.FREE_BUILDING)) {
if (mode!=DeckEditorMode.FREE_BUILDING) {
// decide from which sets basic lands are taken from
for (String setCode : deck.getExpansionSetCodes()) {
ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByCode(setCode);
@ -183,44 +182,32 @@ public class AddLandDialog extends MageDialog {
lblForest.setText("Forest");
spnForest.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1)));
spnForest.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1));
lblIsland.setText("Island");
spnIsland.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1)));
spnIsland.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1));
lblMountain.setText("Mountain");
spnMountain.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1)));
spnMountain.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1));
lblPains.setText("Plains");
spnPlains.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1)));
spnPlains.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1));
lblSwamp.setText("Swamp");
spnSwamp.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1)));
spnSwamp.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1));
btnAdd.setText("Add");
btnAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnAddActionPerformed(evt);
}
});
btnAdd.addActionListener(evt -> btnAddActionPerformed(evt));
btnCancel.setText("Cancel");
btnCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCancelActionPerformed(evt);
}
});
btnCancel.addActionListener(evt -> btnCancelActionPerformed(evt));
btnAutoAdd.setText("Suggest");
btnAutoAdd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnAutoAddActionPerformed(evt);
}
});
btnAutoAdd.addActionListener(evt -> btnAutoAddActionPerformed(evt));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);

View file

@ -65,13 +65,13 @@ public class CardInfoWindowDialog extends MageDialog {
private static final Logger LOGGER = Logger.getLogger(CardInfoWindowDialog.class);
public static enum ShowType {
public enum ShowType {
REVEAL, REVEAL_TOP_LIBRARY, LOOKED_AT, EXILE, GRAVEYARD, OTHER
};
}
private ShowType showType;
private final ShowType showType;
private boolean positioned;
private String name;
private final String name;
public CardInfoWindowDialog(ShowType showType, String name) {
this.name = name;
@ -185,22 +185,19 @@ public class CardInfoWindowDialog extends MageDialog {
}
private void showAndPositionWindow() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
int width = CardInfoWindowDialog.this.getWidth();
int height = CardInfoWindowDialog.this.getHeight();
if (width > 0 && height > 0) {
Point centered = SettingsManager.getInstance().getComponentPosition(width, height);
if (!positioned) {
int xPos = centered.x / 2;
int yPos = centered.y / 2;
CardInfoWindowDialog.this.setLocation(xPos, yPos);
show();
positioned = true;
}
GuiDisplayUtil.keepComponentInsideFrame(centered.x, centered.y, CardInfoWindowDialog.this);
SwingUtilities.invokeLater(() -> {
int width = CardInfoWindowDialog.this.getWidth();
int height = CardInfoWindowDialog.this.getHeight();
if (width > 0 && height > 0) {
Point centered = SettingsManager.getInstance().getComponentPosition(width, height);
if (!positioned) {
int xPos = centered.x / 2;
int yPos = centered.y / 2;
CardInfoWindowDialog.this.setLocation(xPos, yPos);
show();
positioned = true;
}
GuiDisplayUtil.keepComponentInsideFrame(centered.x, centered.y, CardInfoWindowDialog.this);
}
});
}

View file

@ -34,7 +34,6 @@
package mage.client.dialog;
import java.awt.Cursor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@ -78,15 +77,10 @@ public class ConnectDialog extends MageDialog {
private static final Logger logger = Logger.getLogger(ConnectDialog.class);
private Connection connection;
private ConnectTask task;
private RegisterUserDialog registerUserDialog;
private ResetPasswordDialog resetPasswordDialog;
private final RegisterUserDialog registerUserDialog;
private final ResetPasswordDialog resetPasswordDialog;
private final ActionListener connectAction = new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
btnConnectActionPerformed(evt);
}
};
private final ActionListener connectAction = evt -> btnConnectActionPerformed(evt);
/**
* Creates new form ConnectDialog
@ -179,11 +173,7 @@ public class ConnectDialog extends MageDialog {
btnFind.setText("Find...");
btnFind.setToolTipText("Shows the list of public servers");
btnFind.setName("findServerBtn"); // NOI18N
btnFind.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
findPublicServerActionPerformed(evt);
}
});
btnFind.addActionListener(evt -> findPublicServerActionPerformed(evt));
lblPort.setLabelFor(txtPort);
lblPort.setText("Port:");
@ -207,56 +197,28 @@ public class ConnectDialog extends MageDialog {
chkAutoConnect.setText("Automatically connect to this server next time");
chkAutoConnect.setToolTipText("<HTML>If active this connect dialog will not be shown if you choose to connect.<br>\nInstead XMage tries to connect to the last server you were connected to.");
chkAutoConnect.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
chkAutoConnectActionPerformed(evt);
}
});
chkAutoConnect.addActionListener(evt -> chkAutoConnectActionPerformed(evt));
chkForceUpdateDB.setText("Force update of card database");
chkForceUpdateDB.setToolTipText("<HTML>If active the comparison of the server cards database to the client database will be enforced.<br>If not, the comparison will only done if the database version of the client is lower than the version of the server.");
chkForceUpdateDB.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
chkForceUpdateDBActionPerformed(evt);
}
});
chkForceUpdateDB.addActionListener(evt -> chkForceUpdateDBActionPerformed(evt));
jProxySettingsButton.setText("Proxy Settings...");
jProxySettingsButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jProxySettingsButtonActionPerformed(evt);
}
});
jProxySettingsButton.addActionListener(evt -> jProxySettingsButtonActionPerformed(evt));
btnConnect.setText("Connect");
btnConnect.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnConnectActionPerformed(evt);
}
});
btnConnect.addActionListener(evt -> btnConnectActionPerformed(evt));
btnCancel.setText("Cancel");
btnCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCancelActionPerformed(evt);
}
});
btnCancel.addActionListener(evt -> btnCancelActionPerformed(evt));
btnRegister.setText("Register new user");
btnRegister.setToolTipText("<html>XMage now supports user authentication.<br>Register your account before you log in.<html>");
btnRegister.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnRegisterActionPerformed(evt);
}
});
btnRegister.addActionListener(evt -> btnRegisterActionPerformed(evt));
btnForgotPassword.setText("Forgot password");
btnForgotPassword.setToolTipText("<html>You can reset your password if you have registered<br>your account with an email address.</html>");
btnForgotPassword.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnForgotPasswordActionPerformed(evt);
}
});
btnForgotPassword.addActionListener(evt -> btnForgotPasswordActionPerformed(evt));
btnFind1.setText("X");
btnFind1.setToolTipText("Connect to xmage.de");
@ -268,11 +230,7 @@ public class ConnectDialog extends MageDialog {
btnFind1.setMinimumSize(new java.awt.Dimension(42, 23));
btnFind1.setName("connectXmageDeBtn"); // NOI18N
btnFind1.setPreferredSize(new java.awt.Dimension(23, 23));
btnFind1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
connectXmageDe(evt);
}
});
btnFind1.addActionListener(evt -> connectXmageDe(evt));
btnFind2.setText("L");
btnFind2.setToolTipText("Connect to localhost");
@ -282,11 +240,7 @@ public class ConnectDialog extends MageDialog {
btnFind2.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
btnFind2.setName("connectLocalhostBtn"); // NOI18N
btnFind2.setPreferredSize(new java.awt.Dimension(23, 23));
btnFind2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
connectLocalhost(evt);
}
});
btnFind2.addActionListener(evt -> connectLocalhost(evt));
btnFind3.setText("W");
btnFind3.setToolTipText("Connect to woogerworks");
@ -296,11 +250,7 @@ public class ConnectDialog extends MageDialog {
btnFind3.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
btnFind3.setName("connectWoogerworksBtn"); // NOI18N
btnFind3.setPreferredSize(new java.awt.Dimension(23, 23));
btnFind3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
connectWoogerworks(evt);
}
});
btnFind3.addActionListener(evt -> connectWoogerworks(evt));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);

View file

@ -76,11 +76,7 @@ public class ErrorDialog extends MageDialog {
setTitle("Error");
btnOK.setText("OK");
btnOK.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnOKActionPerformed(evt);
}
});
btnOK.addActionListener(this::btnOKActionPerformed);
lblMessage.setColumns(20);
lblMessage.setEditable(false);

View file

@ -28,7 +28,6 @@
package mage.client.dialog;
import mage.client.MageFrame;
import mage.client.SessionHandler;
import org.apache.log4j.Logger;
@ -43,7 +42,7 @@ public class FeedbackDialog extends javax.swing.JDialog {
private static final Logger log = Logger.getLogger(PreferencesDialog.class);
private String[] feedbackTypes = {"", "Bug or \"something doesn't work\"",
private final String[] feedbackTypes = {"", "Bug or \"something doesn't work\"",
"Feature or \"I need that function\"",
"Thank you or \"Devs, you are so cool!\"",
"Question or \"I'm so curious about\""};
@ -186,18 +185,10 @@ public class FeedbackDialog extends javax.swing.JDialog {
jTabbedPane1.addTab("Give feedback", jPanel6);
sendButton.setText("Send");
sendButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendButtonActionPerformed(evt);
}
});
sendButton.addActionListener(evt -> sendButtonActionPerformed(evt));
cancelButton.setText("Cancel");
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
cancelButton.addActionListener(evt -> cancelButtonActionPerformed(evt));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
@ -294,14 +285,12 @@ public class FeedbackDialog extends javax.swing.JDialog {
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
if (!dialog.isVisible()) {
dialog.setLocation(300, 200);
dialog.setVisible(true);
} else {
dialog.requestFocus();
}
java.awt.EventQueue.invokeLater(() -> {
if (!dialog.isVisible()) {
dialog.setLocation(300, 200);
dialog.setVisible(true);
} else {
dialog.requestFocus();
}
});
}

View file

@ -61,7 +61,7 @@ import mage.view.PlayerView;
*/
public class GameEndDialog extends MageDialog {
private final DateFormat df = DateFormat.getDateTimeInstance();;
private final DateFormat df = DateFormat.getDateTimeInstance();
/** Creates new form GameEndDialog
@ -290,11 +290,7 @@ public class GameEndDialog extends MageDialog {
tabPane.addTab("Statistics", tabStatistics);
btnOk.setText("OK");
btnOk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnOkActionPerformed(evt);
}
});
btnOk.addActionListener(evt -> btnOkActionPerformed(evt));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);

View file

@ -85,18 +85,10 @@ public class JoinTableDialog extends MageDialog {
setTitle("Join Table");
btnCancel.setText("Cancel");
btnCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCancelActionPerformed(evt);
}
});
btnCancel.addActionListener(evt -> btnCancelActionPerformed(evt));
btnOK.setText("OK");
btnOK.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnOKActionPerformed(evt);
}
});
btnOK.addActionListener(evt -> btnOKActionPerformed(evt));
lblPassword.setText("Password:");

View file

@ -97,12 +97,7 @@ public class MageDialog extends javax.swing.JInternalFrame {
stopModal();
} else {
try {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
stopModal();
}
});
SwingUtilities.invokeAndWait(() -> stopModal());
} catch (InterruptedException ex) {
LOGGER.fatal("MageDialog error", ex);
} catch (InvocationTargetException ex) {

View file

@ -32,7 +32,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.ListIterator;
import java.util.UUID;
import javax.swing.*;
@ -145,11 +144,7 @@ public class NewTableDialog extends MageDialog {
lblGameType.setText("Game Type:");
cbGameType.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbGameTypeActionPerformed(evt);
}
});
cbGameType.addActionListener(evt -> cbGameTypeActionPerformed(evt));
chkRollbackTurnsAllowed.setText("Allow rollbacks");
chkRollbackTurnsAllowed.setToolTipText("<HTML>Allow to rollback to the start of previous turns<br>\nif all players agree.\n");
@ -163,11 +158,7 @@ public class NewTableDialog extends MageDialog {
lblNumPlayers.setLabelFor(spnNumPlayers);
lblNumPlayers.setText("Players");
spnNumPlayers.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
numPlayersChanged(evt);
}
});
spnNumPlayers.addChangeListener(evt -> numPlayersChanged(evt));
lblRange.setLabelFor(cbRange);
lblRange.setText("Range of Influence");
@ -188,11 +179,7 @@ public class NewTableDialog extends MageDialog {
lblNumWins.setText("Wins");
lblNumWins.setToolTipText("How many games has a player to win to win the match.");
spnNumWins.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spnNumWinsnumPlayersChanged(evt);
}
});
spnNumWins.addChangeListener(evt -> spnNumWinsnumPlayersChanged(evt));
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel1.setText("Player 1 (You)");
@ -203,18 +190,10 @@ public class NewTableDialog extends MageDialog {
pnlOtherPlayers.setLayout(new java.awt.GridLayout(0, 1));
btnOK.setText("OK");
btnOK.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnOKActionPerformed(evt);
}
});
btnOK.addActionListener(evt -> btnOKActionPerformed(evt));
btnCancel.setText("Cancel");
btnCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCancelActionPerformed(evt);
}
});
btnCancel.addActionListener(evt -> btnCancelActionPerformed(evt));
lblQuitRatio.setText("Allowed quit %");
lblEdhPowerLevel.setText("EDH power level");
@ -534,12 +513,7 @@ public class NewTableDialog extends MageDialog {
playerPanel.init(players.size() + 2, playerType);
players.add(playerPanel);
playerPanel.addPlayerTypeEventListener(
new Listener<Event>() {
@Override
public void event(Event event) {
drawPlayers();
}
}
(Listener<Event>) event -> drawPlayers()
);
}
@ -697,12 +671,11 @@ public class NewTableDialog extends MageDialog {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_SKILL_LEVEL, options.getSkillLevel().toString());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_QUIT_RATIO, Integer.toString(options.getQuitRatio()));
StringBuilder playerTypesString = new StringBuilder();
ListIterator iterator = players.listIterator();
while (iterator.hasNext()) {
for (Object player : players) {
if (playerTypesString.length() > 0) {
playerTypesString.append(",");
}
TablePlayerPanel tpp = (TablePlayerPanel) iterator.next();
TablePlayerPanel tpp = (TablePlayerPanel) player;
playerTypesString.append(tpp.getPlayerType());
}
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PLAYER_TYPES, playerTypesString.toString());

View file

@ -65,7 +65,6 @@ import mage.game.draft.DraftOptions;
import mage.game.draft.DraftOptions.TimingOption;
import mage.game.tournament.LimitedOptions;
import mage.game.tournament.TournamentOptions;
import mage.remote.Session;
import mage.view.GameTypeView;
import mage.view.TableView;
import mage.view.TournamentTypeView;
@ -215,11 +214,7 @@ public class NewTournamentDialog extends MageDialog {
lblTournamentType.setText("Tournament Type:");
cbTournamentType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbTournamentType.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbTournamentTypeActionPerformed(evt);
}
});
cbTournamentType.addActionListener(evt -> cbTournamentTypeActionPerformed(evt));
lbDeckType.setText("Deck Type:");
lbDeckType.setFocusable(false);
@ -227,11 +222,7 @@ public class NewTournamentDialog extends MageDialog {
lblGameType.setText("Game Type:");
lblGameType.setFocusable(false);
cbGameType.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbGameTypeActionPerformed(evt);
}
});
cbGameType.addActionListener(evt -> cbGameTypeActionPerformed(evt));
lblFreeMulligans.setText("Free Mulligans:");
@ -240,30 +231,18 @@ public class NewTournamentDialog extends MageDialog {
lblNumWins.setText("Wins:");
spnNumWins.setToolTipText("To win a match a player has to win this number of games.");
spnNumWins.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spnNumWinsnumPlayersChanged(evt);
}
});
spnNumWins.addChangeListener(evt -> spnNumWinsnumPlayersChanged(evt));
lblDraftCube.setText("Draft Cube:");
cbDraftCube.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbDraftCube.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbDraftCubeActionPerformed(evt);
}
});
cbDraftCube.addActionListener(evt -> cbDraftCubeActionPerformed(evt));
lblNumRounds.setText("Number of Swiss Rounds:");
lblNumRounds.setToolTipText("<html>The number of rounds the swiss tournament has in total.<br>\nThe tournaments ends after that number of rounds or<br> \nif there are less than two players left in the tournament.");
spnNumRounds.setToolTipText("<html>The number of rounds the swiss tournament has in total.<br>\nThe tournaments ends after that number of rounds or<br> \nif there are less than two players left in the tournament.");
spnNumRounds.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spnNumRoundsnumPlayersChanged(evt);
}
});
spnNumRounds.addChangeListener(evt -> spnNumRoundsnumPlayersChanged(evt));
lblPacks.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
lblPacks.setText("Packs");
@ -273,28 +252,16 @@ public class NewTournamentDialog extends MageDialog {
lblNbrPlayers.setText("Players:");
spnNumPlayers.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spnNumPlayersStateChanged(evt);
}
});
spnNumPlayers.addChangeListener(evt -> spnNumPlayersStateChanged(evt));
lblNbrSeats.setText("Seats:");
spnNumSeats.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spnNumSeatsStateChanged(evt);
}
});
spnNumSeats.addChangeListener(evt -> spnNumSeatsStateChanged(evt));
jLabel6.setText("Timing:");
cbDraftTiming.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbDraftTiming.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbDraftTimingActionPerformed(evt);
}
});
cbDraftTiming.addActionListener(evt -> cbDraftTimingActionPerformed(evt));
javax.swing.GroupLayout pnlDraftOptionsLayout = new javax.swing.GroupLayout(pnlDraftOptions);
pnlDraftOptions.setLayout(pnlDraftOptionsLayout);
@ -348,18 +315,10 @@ public class NewTournamentDialog extends MageDialog {
);
btnOk.setText("OK");
btnOk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnOkActionPerformed(evt);
}
});
btnOk.addActionListener(evt -> btnOkActionPerformed(evt));
btnCancel.setText("Cancel");
btnCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCancelActionPerformed(evt);
}
});
btnCancel.addActionListener(evt -> btnCancelActionPerformed(evt));
pnlRandomPacks.setBorder(javax.swing.BorderFactory.createEtchedBorder());
pnlRandomPacks.setToolTipText("");
@ -887,13 +846,7 @@ public class NewTournamentDialog extends MageDialog {
btnSelectRandomPacks.setAlignmentX(Component.LEFT_ALIGNMENT);
btnSelectRandomPacks.setText("Select packs to be included in the pool");
btnSelectRandomPacks.setToolTipText(RandomPacksSelectorDialog.randomDraftDescription);
btnSelectRandomPacks.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
showRandomPackSelectorDialog();
}
});
btnSelectRandomPacks.addActionListener(evt -> showRandomPackSelectorDialog());
pnlRandomPacks.add(btnSelectRandomPacks);
}
this.pack();
@ -925,12 +878,7 @@ public class NewTournamentDialog extends MageDialog {
pack.setModel(new DefaultComboBoxModel(ExpansionRepository.instance.getWithBoostersSortedByReleaseDate()));
pnlPacks.add(pack);
packs.add(pack);
pack.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
packActionPerformed(evt);
}
});
pack.addActionListener(evt -> packActionPerformed(evt));
}
this.pack();
this.revalidate();
@ -980,12 +928,9 @@ public class NewTournamentDialog extends MageDialog {
this.pnlOtherPlayers.removeAll();
for (TournamentPlayerPanel panel: players) {
this.pnlOtherPlayers.add(panel);
panel.getPlayerType().addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
if (!automaticChange) {
playerActionPerformed(evt);
}
panel.getPlayerType().addActionListener(evt -> {
if (!automaticChange) {
playerActionPerformed(evt);
}
});
}

View file

@ -134,28 +134,16 @@ public class PickChoiceDialog extends MageDialog {
btnAutoSelect.setText("Auto select");
btnAutoSelect.setToolTipText("If you select an effect with \"Auto select\", this effect will be selected the next time automatically first.");
btnAutoSelect.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnAutoSelectActionPerformed(evt);
}
});
btnAutoSelect.addActionListener(evt -> btnAutoSelectActionPerformed(evt));
btnCancel.setText("Cancel");
btnCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCancelActionPerformed(evt);
}
});
btnCancel.addActionListener(evt -> btnCancelActionPerformed(evt));
btnOk.setText("OK");
btnOk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnOkActionPerformed(evt);
}
});
btnOk.addActionListener(evt -> btnOkActionPerformed(evt));
lstChoices.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
final String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});

View file

@ -90,21 +90,13 @@ public class PickNumberDialog extends MageDialog {
jScrollPane1 = new javax.swing.JScrollPane();
lblMessage = new javax.swing.JTextPane();
spnAmount.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1), null, null, Integer.valueOf(1)));
spnAmount.setModel(new javax.swing.SpinnerNumberModel(1, null, null, 1));
btnCancel.setText("Cancel");
btnCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCancelActionPerformed(evt);
}
});
btnCancel.addActionListener(evt -> btnCancelActionPerformed(evt));
btnOk.setText("OK");
btnOk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnOkActionPerformed(evt);
}
});
btnOk.addActionListener(evt -> btnOkActionPerformed(evt));
jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

View file

@ -30,8 +30,6 @@ package mage.client.dialog;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.UUID;
import javax.swing.JButton;
import javax.swing.JLayeredPane;
@ -69,12 +67,7 @@ public class PickPileDialog extends MageDialog {
panel.add(pile1, BorderLayout.CENTER);
JButton btnChoosePile1 = new JButton("Pile 1");
btnChoosePile1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
btnPile1ActionPerformed(e);
}
});
btnChoosePile1.addActionListener(e -> btnPile1ActionPerformed(e));
panel.add(btnChoosePile1, BorderLayout.NORTH);
JPanel panel_1 = new JPanel();
@ -85,12 +78,7 @@ public class PickPileDialog extends MageDialog {
panel_1.add(pile2, BorderLayout.CENTER);
JButton btnChoosePile2 = new JButton("Pile 2");
btnChoosePile2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
btnPile2ActionPerformed(e);
}
});
btnChoosePile2.addActionListener(e -> btnPile2ActionPerformed(e));
panel_1.add(btnChoosePile2, BorderLayout.NORTH);
}

View file

@ -320,8 +320,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String OPEN_CONNECTION_TAB = "Open-Connection-Tab";
public static final String OPEN_PHASES_TAB = "Open-Phases-Tab";
public static String PHASE_ON = "on";
public static String PHASE_OFF = "off";
public static final String PHASE_ON = "on";
public static final String PHASE_OFF = "off";
private static final Map<Integer, JPanel> PANELS = new HashMap<>();
@ -590,11 +590,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
showCardName.setToolTipText("Write the card's name on the card to make the card name more recognizable.");
showCardName.setActionCommand("");
showCardName.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
showCardName.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
showCardNameActionPerformed(evt);
}
});
showCardName.addActionListener(evt -> showCardNameActionPerformed(evt));
tooltipDelayLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
tooltipDelayLabel.setText("Delay in milliseconds for showing the card tooltip text");
@ -636,71 +632,43 @@ public class PreferencesDialog extends javax.swing.JDialog {
nonLandPermanentsInOnePile.setSelected(true);
nonLandPermanentsInOnePile.setText("Put non-land permanents in same row as creatures");
nonLandPermanentsInOnePile.setToolTipText("<html>If activated, all non land permanents are shown in one row.<br>\nFirst creatures than other permanents. If not activated, creatures are<br>\nshown in a separate row.");
nonLandPermanentsInOnePile.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
nonLandPermanentsInOnePileActionPerformed(evt);
}
});
nonLandPermanentsInOnePile.addActionListener(evt -> nonLandPermanentsInOnePileActionPerformed(evt));
showPlayerNamesPermanently.setSelected(true);
showPlayerNamesPermanently.setText("Show player names on avatar permanently");
showPlayerNamesPermanently.setToolTipText("Instead showing the names only if you hover over the avatar with the mouse, the name is shown all the time.");
showPlayerNamesPermanently.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
showPlayerNamesPermanently.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
showPlayerNamesPermanentlyActionPerformed(evt);
}
});
showPlayerNamesPermanently.addActionListener(evt -> showPlayerNamesPermanentlyActionPerformed(evt));
showAbilityPickerForced.setSelected(true);
showAbilityPickerForced.setText("Show ability picker for abilities or spells without costs");
showAbilityPickerForced.setToolTipText("This prevents you from accidently activating abilities without other costs than tapping or casting spells with 0 mana costs.");
showAbilityPickerForced.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
showAbilityPickerForced.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
showAbilityPickerForcedActionPerformed(evt);
}
});
showAbilityPickerForced.addActionListener(evt -> showAbilityPickerForcedActionPerformed(evt));
cbAllowRequestToShowHandCards.setSelected(true);
cbAllowRequestToShowHandCards.setText("Allow requests from players and spectators to show your hand cards");
cbAllowRequestToShowHandCards.setToolTipText("<html>This is the default setting used for your matches. If activated other players or spectators<br>\nof your match can send a request so you can allow them to see your hand cards.");
cbAllowRequestToShowHandCards.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
cbAllowRequestToShowHandCards.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbAllowRequestToShowHandCardsActionPerformed(evt);
}
});
cbAllowRequestToShowHandCards.addActionListener(evt -> cbAllowRequestToShowHandCardsActionPerformed(evt));
cbShowStormCounter.setSelected(true);
cbShowStormCounter.setText("Show the number of spell casts during the current turn");
cbShowStormCounter.setToolTipText("<html>Adds a little box left to the short keys line with the number<br>\nof spells already cast during the current turn (storm counter).");
cbShowStormCounter.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
cbShowStormCounter.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbShowStormCounterActionPerformed(evt);
}
});
cbShowStormCounter.addActionListener(evt -> cbShowStormCounterActionPerformed(evt));
cbConfirmEmptyManaPool.setSelected(true);
cbConfirmEmptyManaPool.setText("Confirm if you want to pass a phase/step but there is still mana in your mana pool");
cbConfirmEmptyManaPool.setToolTipText("<html>If activated you get a confirm message if you pass priority while stack is empty<br>\n and you still have mana in your mana pool.");
cbConfirmEmptyManaPool.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
cbConfirmEmptyManaPool.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbConfirmEmptyManaPoolActionPerformed(evt);
}
});
cbConfirmEmptyManaPool.addActionListener(evt -> cbConfirmEmptyManaPoolActionPerformed(evt));
cbAskMoveToGraveOrder.setSelected(true);
cbAskMoveToGraveOrder.setText("Ask player for setting order cards go to graveyard");
cbAskMoveToGraveOrder.setToolTipText("<html>If activated and multiple cards go to the graveyard at the same time<br>\nthe player is asked to set the order of the cards.");
cbAskMoveToGraveOrder.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
cbAskMoveToGraveOrder.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbAskMoveToGraveOrderActionPerformed(evt);
}
});
cbAskMoveToGraveOrder.addActionListener(evt -> cbAskMoveToGraveOrderActionPerformed(evt));
org.jdesktop.layout.GroupLayout main_gameLayout = new org.jdesktop.layout.GroupLayout(main_game);
main_game.setLayout(main_gameLayout);
@ -744,20 +712,12 @@ public class PreferencesDialog extends javax.swing.JDialog {
cbGameLogAutoSave.setSelected(true);
cbGameLogAutoSave.setText("Auto save game logs (to \"../Mage.Client/gamelogs/\" directory)");
cbGameLogAutoSave.setToolTipText("The logs of all your games will be saved to the mentioned folder if this option is switched on.");
cbGameLogAutoSave.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbGameLogAutoSaveActionPerformed(evt);
}
});
cbGameLogAutoSave.addActionListener(evt -> cbGameLogAutoSaveActionPerformed(evt));
cbDraftLogAutoSave.setSelected(true);
cbDraftLogAutoSave.setText("Auto save draft logs (to \"../Mage.Client/gamelogs/\" directory)");
cbDraftLogAutoSave.setToolTipText("The logs of all your games will be saved to the mentioned folder if this option is switched on.");
cbDraftLogAutoSave.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbDraftLogAutoSaveActionPerformed(evt);
}
});
cbDraftLogAutoSave.addActionListener(evt -> cbDraftLogAutoSaveActionPerformed(evt));
org.jdesktop.layout.GroupLayout main_gamelogLayout = new org.jdesktop.layout.GroupLayout(main_gamelog);
main_gamelog.setLayout(main_gamelogLayout);
@ -1258,75 +1218,47 @@ public class PreferencesDialog extends javax.swing.JDialog {
cbStopAttack.setText("Stop on declare attackers step if you skip steps (F4/F5/F7) and attackers are available");
cbStopAttack.setToolTipText("If you use F4, F5 or F7 to skip steps, you stop on declare attackers step if attackers are available. If this option is not activated, you also skip the declare attackers step with this actions. F9 does always skip the declare attackers step.");
cbStopAttack.setActionCommand("");
cbStopAttack.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbStopAttackActionPerformed(evt);
}
});
cbStopAttack.addActionListener(evt -> cbStopAttackActionPerformed(evt));
phases_stopSettings.add(cbStopAttack);
cbStopBlock.setText("Stop on your declare blockers step also if no blockers available");
cbStopBlock.setToolTipText("Also if you have no blockers to declare, the game stops at the declare blockers step.");
cbStopBlock.setActionCommand("");
cbStopBlock.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbStopBlockActionPerformed(evt);
}
});
cbStopBlock.addActionListener(evt -> cbStopBlockActionPerformed(evt));
phases_stopSettings.add(cbStopBlock);
cbStopOnAllMain.setText("Skip with F7 to next main phase (if not activated skip always to your next main phase)");
cbStopOnAllMain.setToolTipText("If activated F7 skips to next main phases (regardless of the active players).");
cbStopOnAllMain.setActionCommand("");
cbStopOnAllMain.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbStopOnAllMainActionPerformed(evt);
}
});
cbStopOnAllMain.addActionListener(evt -> cbStopOnAllMainActionPerformed(evt));
phases_stopSettings.add(cbStopOnAllMain);
cbStopOnAllEnd.setText("Skip with F5 to next end step (if not activated only to end steps of opponents)");
cbStopOnAllEnd.setToolTipText("If activated - F5 skips to the next end step (regardless of the current player)");
cbStopOnAllEnd.setActionCommand("");
cbStopOnAllEnd.setPreferredSize(new java.awt.Dimension(300, 25));
cbStopOnAllEnd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbStopOnAllEndActionPerformed(evt);
}
});
cbStopOnAllEnd.addActionListener(evt -> cbStopOnAllEndActionPerformed(evt));
phases_stopSettings.add(cbStopOnAllEnd);
cbPassPriorityCast.setText("Pass priority automatically after you have put a spell on the stack");
cbPassPriorityCast.setToolTipText("If activated the system passes priority automatically for you if you have put a spell on the stack.");
cbPassPriorityCast.setActionCommand("");
cbPassPriorityCast.setPreferredSize(new java.awt.Dimension(300, 25));
cbPassPriorityCast.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbPassPriorityCastActionPerformed(evt);
}
});
cbPassPriorityCast.addActionListener(evt -> cbPassPriorityCastActionPerformed(evt));
phases_stopSettings.add(cbPassPriorityCast);
cbPassPriorityActivation.setText("Pass priority automatically after you have put an activated ability on the stack");
cbPassPriorityActivation.setToolTipText("If activated the system passes priority for you automatically after you have put an activated ability on the stack.");
cbPassPriorityActivation.setActionCommand("");
cbPassPriorityActivation.setPreferredSize(new java.awt.Dimension(300, 25));
cbPassPriorityActivation.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbPassPriorityActivationActionPerformed(evt);
}
});
cbPassPriorityActivation.addActionListener(evt -> cbPassPriorityActivationActionPerformed(evt));
phases_stopSettings.add(cbPassPriorityActivation);
cbAutoOrderTrigger.setText("Set order for your triggers automatically if all have the same text");
cbAutoOrderTrigger.setToolTipText("<HTML>If activated the order to put on the stack your triggers that trigger at the same time<br/>\nis set automatically if all have the same text.");
cbAutoOrderTrigger.setActionCommand("");
cbAutoOrderTrigger.setPreferredSize(new java.awt.Dimension(300, 25));
cbAutoOrderTrigger.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbAutoOrderTriggerActionPerformed(evt);
}
});
cbAutoOrderTrigger.addActionListener(evt -> cbAutoOrderTriggerActionPerformed(evt));
phases_stopSettings.add(cbAutoOrderTrigger);
org.jdesktop.layout.GroupLayout tabPhasesLayout = new org.jdesktop.layout.GroupLayout(tabPhases);
@ -1448,34 +1380,18 @@ public class PreferencesDialog extends javax.swing.JDialog {
panelCardImages.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Card images:"));
cbUseDefaultImageFolder.setText("Use default location to save images");
cbUseDefaultImageFolder.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbUseDefaultImageFolderActionPerformed(evt);
}
});
cbUseDefaultImageFolder.addActionListener(evt -> cbUseDefaultImageFolderActionPerformed(evt));
txtImageFolderPath.setToolTipText("The selected image will be used as background picture. You have to restart MAGE to view a changed background image.");
btnBrowseImageLocation.setText("Browse...");
btnBrowseImageLocation.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnBrowseImageLocationActionPerformed(evt);
}
});
btnBrowseImageLocation.addActionListener(evt -> btnBrowseImageLocationActionPerformed(evt));
cbCheckForNewImages.setText("Check for new images on startup");
cbCheckForNewImages.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbCheckForNewImagesActionPerformed(evt);
}
});
cbCheckForNewImages.addActionListener(evt -> cbCheckForNewImagesActionPerformed(evt));
cbSaveToZipFiles.setText("Store images in zip files");
cbSaveToZipFiles.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbSaveToZipFilesActionPerformed(evt);
}
});
cbSaveToZipFiles.addActionListener(evt -> cbSaveToZipFilesActionPerformed(evt));
cbPreferedImageLanguage.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
@ -1546,51 +1462,23 @@ public class PreferencesDialog extends javax.swing.JDialog {
panelBackgroundImages.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Background images setting:"));
cbUseDefaultBackground.setText("Use default image");
cbUseDefaultBackground.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbUseDefaultBackgroundActionPerformed(evt);
}
});
cbUseDefaultBackground.addActionListener(evt -> cbUseDefaultBackgroundActionPerformed(evt));
txtBackgroundImagePath.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtBackgroundImagePathActionPerformed(evt);
}
});
txtBackgroundImagePath.addActionListener(evt -> txtBackgroundImagePathActionPerformed(evt));
btnBrowseBackgroundImage.setText("Browse...");
btnBrowseBackgroundImage.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnBrowseBackgroundImageActionPerformed(evt);
}
});
btnBrowseBackgroundImage.addActionListener(evt -> btnBrowseBackgroundImageActionPerformed(evt));
txtBattlefieldImagePath.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtBattlefieldImagePathActionPerformed(evt);
}
});
txtBattlefieldImagePath.addActionListener(evt -> txtBattlefieldImagePathActionPerformed(evt));
btnBrowseBattlefieldImage.setText("Browse...");
btnBrowseBattlefieldImage.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnBrowseBattlefieldImageActionPerformed(evt);
}
});
btnBrowseBattlefieldImage.addActionListener(evt -> btnBrowseBattlefieldImageActionPerformed(evt));
cbUseDefaultBattleImage.setText("Use default battlefield image");
cbUseDefaultBattleImage.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbUseDefaultBattleImageActionPerformed(evt);
}
});
cbUseDefaultBattleImage.addActionListener(evt -> cbUseDefaultBattleImageActionPerformed(evt));
cbUseRandomBattleImage.setText("Select random battlefield image");
cbUseRandomBattleImage.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbUseRandomBattleImageActionPerformed(evt);
}
});
cbUseRandomBattleImage.addActionListener(evt -> cbUseRandomBattleImageActionPerformed(evt));
jLabel14.setText("Background:");
@ -1650,25 +1538,13 @@ public class PreferencesDialog extends javax.swing.JDialog {
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Card rendering:"));
cbCardRenderImageFallback.setText("Fall back to plain image based rendering");
cbCardRenderImageFallback.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbCardRenderImageFallbackActionPerformed(evt);
}
});
cbCardRenderImageFallback.addActionListener(evt -> cbCardRenderImageFallbackActionPerformed(evt));
cbCardRenderShowReminderText.setText("Show reminder text in rendered card textboxes");
cbCardRenderShowReminderText.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbCardRenderShowReminderTextActionPerformed(evt);
}
});
cbCardRenderShowReminderText.addActionListener(evt -> cbCardRenderShowReminderTextActionPerformed(evt));
cbCardRenderHideSetSymbol.setText("Hide set symbols on cards (more space on the type line for card types)");
cbCardRenderHideSetSymbol.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbCardRenderHideSetSymbolActionPerformed(evt);
}
});
cbCardRenderHideSetSymbol.addActionListener(evt -> cbCardRenderHideSetSymbolActionPerformed(evt));
org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
@ -1723,38 +1599,22 @@ public class PreferencesDialog extends javax.swing.JDialog {
cbEnableGameSounds.setText("Enable game sounds");
cbEnableGameSounds.setToolTipText("Sounds that will be played for certain actions (e.g. play land, attack, etc.) during the game.");
cbEnableGameSounds.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbEnableGameSoundsActionPerformed(evt);
}
});
cbEnableGameSounds.addActionListener(evt -> cbEnableGameSoundsActionPerformed(evt));
sounds_clips.add(cbEnableGameSounds);
cbEnableDraftSounds.setText("Enable draft sounds");
cbEnableDraftSounds.setToolTipText("Sounds that will be played during drafting for card picking or warining if time runs out.");
cbEnableDraftSounds.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbEnableDraftSoundsActionPerformed(evt);
}
});
cbEnableDraftSounds.addActionListener(evt -> cbEnableDraftSoundsActionPerformed(evt));
sounds_clips.add(cbEnableDraftSounds);
cbEnableSkipButtonsSounds.setText("Enable skip button sounds");
cbEnableSkipButtonsSounds.setToolTipText("Sounds that will be played if a priority skip action (F4/F5/F7/F9) or cancel skip action (F3) is used.");
cbEnableSkipButtonsSounds.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbEnableSkipButtonsSoundsActionPerformed(evt);
}
});
cbEnableSkipButtonsSounds.addActionListener(evt -> cbEnableSkipButtonsSoundsActionPerformed(evt));
sounds_clips.add(cbEnableSkipButtonsSounds);
cbEnableOtherSounds.setText("Enable other sounds");
cbEnableOtherSounds.setToolTipText("Sounds that will be played for actions outside of games (e.g. whisper, player joins your game, player submits a deck ...).");
cbEnableOtherSounds.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbEnableOtherSoundsActionPerformed(evt);
}
});
cbEnableOtherSounds.addActionListener(evt -> cbEnableOtherSoundsActionPerformed(evt));
sounds_clips.add(cbEnableOtherSounds);
sounds_backgroundMusic.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Music"));
@ -1762,27 +1622,15 @@ public class PreferencesDialog extends javax.swing.JDialog {
cbEnableBattlefieldBGM.setText("Play music during match");
cbEnableBattlefieldBGM.setToolTipText("During your matches music will be played from the seleced folder.");
cbEnableBattlefieldBGM.setActionCommand("Play automatically during matches");
cbEnableBattlefieldBGM.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbEnableBattlefieldBGMActionPerformed(evt);
}
});
cbEnableBattlefieldBGM.addActionListener(evt -> cbEnableBattlefieldBGMActionPerformed(evt));
jLabel16.setText("Playing from folder:");
jLabel16.setToolTipText("");
txtBattlefieldIBGMPath.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtBattlefieldIBGMPathActionPerformed(evt);
}
});
txtBattlefieldIBGMPath.addActionListener(evt -> txtBattlefieldIBGMPathActionPerformed(evt));
btnBattlefieldBGMBrowse.setText("Browse...");
btnBattlefieldBGMBrowse.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnBattlefieldBGMBrowseActionPerformed(evt);
}
});
btnBattlefieldBGMBrowse.addActionListener(evt -> btnBattlefieldBGMBrowseActionPerformed(evt));
org.jdesktop.layout.GroupLayout sounds_backgroundMusicLayout = new org.jdesktop.layout.GroupLayout(sounds_backgroundMusic);
sounds_backgroundMusic.setLayout(sounds_backgroundMusicLayout);
@ -2337,11 +2185,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
lblProxyType.setText("Proxy:");
cbProxyType.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbProxyTypeActionPerformed(evt);
}
});
cbProxyType.addActionListener(evt -> cbProxyTypeActionPerformed(evt));
pnlProxySettings.setBorder(javax.swing.BorderFactory.createEtchedBorder());
@ -2359,18 +2203,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
lblProxyPassword.setText("Password:");
txtPasswordField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtPasswordFieldActionPerformed(evt);
}
});
txtPasswordField.addActionListener(evt -> txtPasswordFieldActionPerformed(evt));
rememberPswd.setText("Remember Password");
rememberPswd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rememberPswdActionPerformed(evt);
}
});
rememberPswd.addActionListener(evt -> rememberPswdActionPerformed(evt));
jLabel11.setFont(new java.awt.Font("Tahoma", 2, 10)); // NOI18N
jLabel11.setText("Note: password won't be encrypted!");
@ -2517,11 +2353,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
controlsDescriptionLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP);
bttnResetControls.setText("Reset to default");
bttnResetControls.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bttnResetControlsActionPerformed(evt);
}
});
bttnResetControls.addActionListener(evt -> bttnResetControlsActionPerformed(evt));
org.jdesktop.layout.GroupLayout tabControlsLayout = new org.jdesktop.layout.GroupLayout(tabControls);
tabControls.setLayout(tabControlsLayout);
@ -2613,22 +2445,14 @@ public class PreferencesDialog extends javax.swing.JDialog {
saveButton.setMinimumSize(new java.awt.Dimension(100, 30));
saveButton.setPreferredSize(new java.awt.Dimension(100, 30));
saveButton.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
saveButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
saveButtonActionPerformed(evt);
}
});
saveButton.addActionListener(evt -> saveButtonActionPerformed(evt));
exitButton.setText("Exit");
exitButton.setMaximumSize(new java.awt.Dimension(100, 30));
exitButton.setMinimumSize(new java.awt.Dimension(100, 30));
exitButton.setPreferredSize(new java.awt.Dimension(100, 30));
exitButton.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
exitButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
exitButtonActionPerformed(evt);
}
});
exitButton.addActionListener(evt -> exitButtonActionPerformed(evt));
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
@ -3097,7 +2921,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
}//GEN-LAST:event_cbCardRenderHideSetSymbolActionPerformed
private void bttnResetControlsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bttnResetControlsActionPerformed
getKeybindButtons().stream().forEach((bttn) -> {
getKeybindButtons().forEach((bttn) -> {
String id = bttn.getKey();
int keyCode = getDefaultControlKey(id);
bttn.setKeyCode(keyCode);
@ -3166,43 +2990,40 @@ public class PreferencesDialog extends javax.swing.JDialog {
}
}
final int openedTab = param;
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
if (!dialog.isVisible()) {
Preferences prefs = MageFrame.getPreferences();
java.awt.EventQueue.invokeLater(() -> {
if (!dialog.isVisible()) {
Preferences prefs = MageFrame.getPreferences();
// Main & Phases
loadPhases(prefs);
// Main & Phases
loadPhases(prefs);
// Gui Size
loadGuiSize(prefs);
// Gui Size
loadGuiSize(prefs);
// Images
loadImagesSettings(prefs);
// Images
loadImagesSettings(prefs);
// Sounds
loadSoundSettings(prefs);
// Sounds
loadSoundSettings(prefs);
// Connection
loadProxySettings(prefs);
// Connection
loadProxySettings(prefs);
// Controls
loadControlSettings(prefs);
// Controls
loadControlSettings(prefs);
// Selected avatar
loadSelectedAvatar(prefs);
// Selected avatar
loadSelectedAvatar(prefs);
dialog.reset();
// open specified tab before displaying
openTab(openedTab);
dialog.reset();
// open specified tab before displaying
openTab(openedTab);
dialog.setLocation(300, 200);
dialog.setLocation(300, 200);
dialog.setVisible(true);
} else {
dialog.requestFocus();
}
dialog.setVisible(true);
} else {
dialog.requestFocus();
}
});
}

View file

@ -75,18 +75,10 @@ public class QuestionDialog extends MageDialog {
lblQuestion.setText("question");
btnNo.setText("No");
btnNo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNoActionPerformed(evt);
}
});
btnNo.addActionListener(evt -> btnNoActionPerformed(evt));
btnYes.setText("Yes");
btnYes.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnYesActionPerformed(evt);
}
});
btnYes.addActionListener(evt -> btnYesActionPerformed(evt));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);

View file

@ -135,19 +135,11 @@ public class RandomPacksSelectorDialog extends javax.swing.JDialog {
btnNone.setText("Select none");
btnNone.setActionCommand("none");
btnNone.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNoneActionPerformed(evt);
}
});
btnNone.addActionListener(evt -> btnNoneActionPerformed(evt));
pnlSelect.add(btnNone);
btnAll.setText("Select all");
btnAll.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnAllActionPerformed(evt);
}
});
btnAll.addActionListener(evt -> btnAllActionPerformed(evt));
pnlSelect.add(btnAll);
pnlApply.setLayout(new javax.swing.BoxLayout(pnlApply, javax.swing.BoxLayout.LINE_AXIS));
@ -158,11 +150,7 @@ public class RandomPacksSelectorDialog extends javax.swing.JDialog {
} else if (isRichManDraft) {
btnApply.setToolTipText("At least 1 pack must be selected");
}
btnApply.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnApplyActionPerformed(evt);
}
});
btnApply.addActionListener(evt -> btnApplyActionPerformed(evt));
pnlApply.add(btnApply);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

View file

@ -14,7 +14,7 @@ import org.apache.log4j.Logger;
public class RegisterUserDialog extends MageDialog {
private static final Logger logger = Logger.getLogger(ConnectDialog.class);
private ConnectDialog connectDialog;
private final ConnectDialog connectDialog;
private Connection connection;
private ConnectTask task;
@ -78,25 +78,13 @@ public class RegisterUserDialog extends MageDialog {
lblPassword.setLabelFor(txtPassword);
lblPassword.setText("Password:");
txtUserName.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtUserNameActionPerformed(evt);
}
});
txtUserName.addActionListener(evt -> txtUserNameActionPerformed(evt));
btnRegister.setText("Register");
btnRegister.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnRegisterActionPerformed(evt);
}
});
btnRegister.addActionListener(evt -> btnRegisterActionPerformed(evt));
btnCancel.setText("Cancel");
btnCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCancelActionPerformed(evt);
}
});
btnCancel.addActionListener(evt -> btnCancelActionPerformed(evt));
lblStatus.setToolTipText("");
@ -112,7 +100,7 @@ public class RegisterUserDialog extends MageDialog {
lblEmailReasoning.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N
lblEmailReasoning.setLabelFor(txtEmail);
lblEmailReasoning.setText("(used for password reset)");
lblEmailReasoning.setText("(used for password reset and sending initial password)");
lblEmailReasoning.setToolTipText("");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

View file

@ -14,7 +14,7 @@ import org.apache.log4j.Logger;
public class ResetPasswordDialog extends MageDialog {
private static final Logger logger = Logger.getLogger(ResetPasswordDialog.class);
private ConnectDialog connectDialog;
private final ConnectDialog connectDialog;
private Connection connection;
private GetAuthTokenTask getAuthTokenTask;
private ResetPasswordTask resetPasswordTask;
@ -88,11 +88,7 @@ public class ResetPasswordDialog extends MageDialog {
lblPasswordConfirmation.setText("New password:");
btnSubmitNewPassword.setText("Submit a new password");
btnSubmitNewPassword.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSubmitNewPasswordActionPerformed(evt);
}
});
btnSubmitNewPassword.addActionListener(evt -> btnSubmitNewPasswordActionPerformed(evt));
lblPasswordConfirmationReasoning.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N
lblPasswordConfirmationReasoning.setLabelFor(txtPasswordConfirmation);
@ -157,11 +153,7 @@ public class ResetPasswordDialog extends MageDialog {
lblEmail.setText("Email:");
btnGetAuthToken.setText("Email an auth token");
btnGetAuthToken.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnGetAuthTokenActionPerformed(evt);
}
});
btnGetAuthToken.addActionListener(evt -> btnGetAuthTokenActionPerformed(evt));
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
@ -196,11 +188,7 @@ public class ResetPasswordDialog extends MageDialog {
);
btnCancel.setText("Cancel");
btnCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCancelActionPerformed(evt);
}
});
btnCancel.addActionListener(evt -> btnCancelActionPerformed(evt));
lblServer.setLabelFor(txtServer);
lblServer.setText("Server:");

View file

@ -129,21 +129,18 @@ public class ShowCardsDialog extends MageDialog {
this.repaint();
this.setModal(modal);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (!positioned) {
int width = ShowCardsDialog.this.getWidth();
int height = ShowCardsDialog.this.getHeight();
if (width > 0 && height > 0) {
Point centered = SettingsManager.getInstance().getComponentPosition(width, height);
ShowCardsDialog.this.setLocation(centered.x, centered.y);
positioned = true;
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, ShowCardsDialog.this);
}
SwingUtilities.invokeLater(() -> {
if (!positioned) {
int width = ShowCardsDialog.this.getWidth();
int height = ShowCardsDialog.this.getHeight();
if (width > 0 && height > 0) {
Point centered = SettingsManager.getInstance().getComponentPosition(width, height);
ShowCardsDialog.this.setLocation(centered.x, centered.y);
positioned = true;
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, ShowCardsDialog.this);
}
ShowCardsDialog.this.setVisible(true);
}
ShowCardsDialog.this.setVisible(true);
});
}

View file

@ -206,34 +206,18 @@ public class TableWaitingDialog extends MageDialog {
btnMoveUp.setText("Move Up");
btnMoveUp.setEnabled(false);
btnMoveUp.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnMoveUpActionPerformed(evt);
}
});
btnMoveUp.addActionListener(evt -> btnMoveUpActionPerformed(evt));
btnMoveDown.setText("Move Down");
btnMoveDown.setEnabled(false);
btnMoveDown.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnMoveDownActionPerformed(evt);
}
});
btnMoveDown.addActionListener(evt -> btnMoveDownActionPerformed(evt));
btnCancel.setText("Cancel");
btnCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCancelActionPerformed(evt);
}
});
btnCancel.addActionListener(evt -> btnCancelActionPerformed(evt));
btnStart.setText("Start");
btnStart.setEnabled(false);
btnStart.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnStartActionPerformed(evt);
}
});
btnStart.addActionListener(evt -> btnStartActionPerformed(evt));
jSplitPane1.setDividerLocation(300);
jSplitPane1.setDividerSize(3);

View file

@ -35,7 +35,6 @@ package mage.client.dialog;
import java.awt.Dimension;
import java.awt.Font;
import javax.swing.JComponent;
import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
import javax.swing.plaf.basic.BasicInternalFrameUI;
import mage.client.MageFrame;
import mage.client.util.GUISizeHelper;
@ -76,7 +75,7 @@ public class UserRequestDialog extends MageDialog {
btn3.setMinimumSize(new Dimension(50 + 4 * font.getSize(), 2 * font.getSize() + 10));
btn3.setMaximumSize(new Dimension(50 + 4 * font.getSize(), 2 * font.getSize() + 10));
btn3.setPreferredSize(new Dimension(50 + 4 * font.getSize(), 2 * font.getSize() + 10));
JComponent c = (BasicInternalFrameTitlePane) ((BasicInternalFrameUI) this.getUI()).getNorthPane();
JComponent c = ((BasicInternalFrameUI) this.getUI()).getNorthPane();
c.setMinimumSize(new Dimension(c.getMinimumSize().width, font.getSize() + 10));
c.setMaximumSize(new Dimension(c.getMaximumSize().width, font.getSize() + 10));
c.setPreferredSize(new Dimension(c.getPreferredSize().width, font.getSize() + 10));
@ -138,31 +137,19 @@ public class UserRequestDialog extends MageDialog {
btn3.setMaximumSize(new java.awt.Dimension(150, 50));
btn3.setMinimumSize(new java.awt.Dimension(75, 25));
btn3.setPreferredSize(new java.awt.Dimension(150, 50));
btn3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn3ActionPerformed(evt);
}
});
btn3.addActionListener(evt -> btn3ActionPerformed(evt));
btn2.setText("btn2");
btn2.setMaximumSize(new java.awt.Dimension(150, 50));
btn2.setMinimumSize(new java.awt.Dimension(75, 25));
btn2.setPreferredSize(new java.awt.Dimension(150, 50));
btn2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn2ActionPerformed(evt);
}
});
btn2.addActionListener(evt -> btn2ActionPerformed(evt));
btn1.setText("btn1");
btn1.setMaximumSize(new java.awt.Dimension(150, 50));
btn1.setMinimumSize(new java.awt.Dimension(75, 25));
btn1.setPreferredSize(new java.awt.Dimension(150, 50));
btn1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn1ActionPerformed(evt);
}
});
btn1.addActionListener(evt -> btn1ActionPerformed(evt));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);

View file

@ -105,7 +105,7 @@ public class DraftPanel extends javax.swing.JPanel {
// all cards picked
protected SimpleCardsView pickedCards;
// all cards picked
protected SimpleCardsView pickedCardsShown = new SimpleCardsView();
protected final SimpleCardsView pickedCardsShown = new SimpleCardsView();
// id of card with popup menu
protected UUID cardIdPopupMenu;
@ -145,17 +145,14 @@ public class DraftPanel extends javax.swing.JPanel {
draftLeftPane.setOpaque(false);
countdown = new Timer(1000,
new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (--timeout > 0) {
setTimeout(timeout);
} else {
setTimeout(0);
countdown.stop();
e -> {
if (--timeout > 0) {
setTimeout(timeout);
} else {
setTimeout(0);
countdown.stop();
}
}
}
}
);
}
@ -306,18 +303,15 @@ public class DraftPanel extends javax.swing.JPanel {
loadCardsToPickedCardsArea(draftPickView.getPicks());
this.draftPicks.clearCardEventListeners();
this.draftPicks.addCardEventListener(new Listener<Event>() {
@Override
public void event(Event event) {
if (event.getEventName().equals("show-popup-menu")) {
if (event.getSource() != null) {
// Popup Menu Card
cardIdPopupMenu = ((SimpleCardView) event.getSource()).getId();
popupMenuCardPanel.show(event.getComponent(), event.getxPos(), event.getyPos());
} else {
// Popup Menu area
popupMenuPickedArea.show(event.getComponent(), event.getxPos(), event.getyPos());
}
this.draftPicks.addCardEventListener((Listener<Event>) event -> {
if (event.getEventName().equals("show-popup-menu")) {
if (event.getSource() != null) {
// Popup Menu Card
cardIdPopupMenu = ((SimpleCardView) event.getSource()).getId();
popupMenuCardPanel.show(event.getComponent(), event.getxPos(), event.getyPos());
} else {
// Popup Menu area
popupMenuPickedArea.show(event.getComponent(), event.getxPos(), event.getyPos());
}
}
}
@ -327,25 +321,22 @@ public class DraftPanel extends javax.swing.JPanel {
draftBooster.loadBooster(CardsViewUtil.convertSimple(draftPickView.getBooster()), bigCard);
this.draftBooster.clearCardEventListeners();
this.draftBooster.addCardEventListener(
new Listener<Event>() {
@Override
public void event(Event event) {
if (event.getEventName().equals("pick-a-card")) {
SimpleCardView source = (SimpleCardView) event.getSource();
DraftPickView view = SessionHandler.sendCardPick(draftId, source.getId(), cardsHidden);
if (view != null) {
loadCardsToPickedCardsArea(view.getPicks());
draftBooster.loadBooster(EMPTY_VIEW, bigCard);
Plugins.getInstance().getActionCallback().hideOpenComponents();
setMessage("Waiting for other players");
(Listener<Event>) event -> {
if (event.getEventName().equals("pick-a-card")) {
SimpleCardView source = (SimpleCardView) event.getSource();
DraftPickView view = SessionHandler.sendCardPick(draftId, source.getId(), cardsHidden);
if (view != null) {
loadCardsToPickedCardsArea(view.getPicks());
draftBooster.loadBooster(EMPTY_VIEW, bigCard);
Plugins.getInstance().getActionCallback().hideOpenComponents();
setMessage("Waiting for other players");
}
}
if (event.getEventName().equals("mark-a-card")) {
SimpleCardView source = (SimpleCardView) event.getSource();
SessionHandler.sendCardMark(draftId, source.getId());
}
}
if (event.getEventName().equals("mark-a-card")) {
SimpleCardView source = (SimpleCardView) event.getSource();
SessionHandler.sendCardMark(draftId, source.getId());
}
}
}
);
setMessage("Pick a card");
if (!MageFrame.getInstance().isActive()) {
@ -422,12 +413,7 @@ public class DraftPanel extends javax.swing.JPanel {
popupMenuPickedArea.add(menuItem);
// Confirm (F9)
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
showAgainAllHiddenCards();
}
});
menuItem.addActionListener(e -> showAgainAllHiddenCards());
// popupMenuPickedArea.addSeparator();
}
@ -440,12 +426,7 @@ public class DraftPanel extends javax.swing.JPanel {
popupMenuCardPanel.add(menuItem);
// Hide Card
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
hideThisCard(cardIdPopupMenu);
}
});
menuItem.addActionListener(e -> hideThisCard(cardIdPopupMenu));
// popupMenuCardPanel.addSeparator();
}
@ -608,11 +589,7 @@ public class DraftPanel extends javax.swing.JPanel {
draftLeftPane.setVerifyInputWhenFocusTarget(false);
btnQuitTournament.setText("Quit Tournament");
btnQuitTournament.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnQuitTournamentActionPerformed(evt);
}
});
btnQuitTournament.addActionListener(evt -> btnQuitTournamentActionPerformed(evt));
lblPack1.setText("Pack 1:");

View file

@ -88,7 +88,7 @@ public class AbilityPicker extends JPopupMenu implements PopupMenuListener {
private class AbilityPickerAction extends AbstractAction {
private UUID id;
private final UUID id;
public AbilityPickerAction(UUID id, String choice) {
this.id = id;

View file

@ -299,13 +299,10 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
}
} else if (comp instanceof MagePermanent) {
if (((MagePermanent) comp).getOriginal().getId().equals(permanentId)) {
Thread t = new Thread(new Runnable() {
@Override
public void run() {
Plugins.getInstance().onRemoveCard((MagePermanent) comp, count);
comp.setVisible(false);
BattlefieldPanel.this.jPanel.remove(comp);
}
Thread t = new Thread(() -> {
Plugins.getInstance().onRemoveCard((MagePermanent) comp, count);
comp.setVisible(false);
BattlefieldPanel.this.jPanel.remove(comp);
});
t.start();
}

View file

@ -52,7 +52,6 @@ import static mage.constants.Constants.Option.ORIGINAL_ID;
import static mage.constants.Constants.Option.SECOND_MESSAGE;
import static mage.constants.Constants.Option.SPECIAL_BUTTON;
import mage.constants.PlayerAction;
import mage.remote.Session;
import org.apache.log4j.Logger;
/**
@ -184,17 +183,14 @@ public class FeedbackPanel extends javax.swing.JPanel {
* Close game window by pressing OK button after 8 seconds
*/
private void endWithTimeout() {
Runnable task = new Runnable() {
@Override
public void run() {
LOGGER.info("Ending game...");
Component c = MageFrame.getGame(gameId);
while (c != null && !(c instanceof GamePane)) {
c = c.getParent();
}
if (c != null && ((GamePane) c).isVisible()) { // check if GamePanel still visible
FeedbackPanel.this.btnRight.doClick();
}
Runnable task = () -> {
LOGGER.info("Ending game...");
Component c = MageFrame.getGame(gameId);
while (c != null && !(c instanceof GamePane)) {
c = c.getParent();
}
if (c != null && c.isVisible()) { // check if GamePanel still visible
FeedbackPanel.this.btnRight.doClick();
}
};
WORKER.schedule(task, 8, TimeUnit.SECONDS);
@ -255,36 +251,16 @@ public class FeedbackPanel extends javax.swing.JPanel {
setBackground(new java.awt.Color(0, 0, 0, 80));
btnRight.setText("Cancel");
btnRight.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnRightActionPerformed(evt);
}
});
btnRight.addActionListener(evt -> btnRightActionPerformed(evt));
btnLeft.setText("OK");
btnLeft.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnLeftActionPerformed(evt);
}
});
btnLeft.addActionListener(evt -> btnLeftActionPerformed(evt));
btnSpecial.setText("Special");
btnSpecial.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSpecialActionPerformed(evt);
}
});
btnSpecial.addActionListener(evt -> btnSpecialActionPerformed(evt));
btnUndo.setText("Undo");
btnUndo.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnUndoActionPerformed(evt);
}
});
btnUndo.addActionListener(evt -> btnUndoActionPerformed(evt));
}

View file

@ -50,12 +50,9 @@ public class GamePane extends MagePane {
public GamePane() {
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
initComponents();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
gamePanel.setJLayeredPane(getLayeredPane());
gamePanel.installComponents();
}
SwingUtilities.invokeLater(() -> {
gamePanel.setJLayeredPane(getLayeredPane());
gamePanel.installComponents();
});
}

View file

@ -31,7 +31,6 @@ import java.awt.AWTEvent;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import static java.awt.Component.LEFT_ALIGNMENT;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
@ -53,7 +52,6 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@ -263,20 +261,12 @@ public final class GamePanel extends javax.swing.JPanel {
}
};
resizeTimer = new Timer(1000, new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
resizeTimer.stop();
setGUISize();
feedbackPanel.changeGUISize();
resizeTimer = new Timer(1000, evt -> SwingUtilities.invokeLater(() -> {
resizeTimer.stop();
setGUISize();
feedbackPanel.changeGUISize();
}
});
}
});
}));
pnlHelperHandButtonsStackArea.addComponentListener(componentAdapterPlayField);
initComponents = false;
@ -1124,12 +1114,7 @@ public final class GamePanel extends javax.swing.JPanel {
private void removeClosedCardInfoWindows(Map<String, CardInfoWindowDialog> windowMap) {
// Remove closed window objects from the maps
for (Iterator<Map.Entry<String, CardInfoWindowDialog>> iterator = windowMap.entrySet().iterator(); iterator.hasNext();) {
Map.Entry<String, CardInfoWindowDialog> entry = iterator.next();
if (entry.getValue().isClosed()) {
iterator.remove();
}
}
windowMap.entrySet().removeIf(entry -> entry.getValue().isClosed());
}
public void ask(String question, GameView gameView, int messageId, Map<String, Serializable> options) {
@ -1700,20 +1685,10 @@ public final class GamePanel extends javax.swing.JPanel {
final BasicSplitPaneUI myUi = (BasicSplitPaneUI) jSplitPane0.getUI();
final BasicSplitPaneDivider divider = myUi.getDivider();
final JButton upArrowButton = (JButton) divider.getComponent(0);
upArrowButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
PreferencesDialog.saveValue(PreferencesDialog.KEY_BIG_CARD_TOGGLED, "up");
}
});
upArrowButton.addActionListener(actionEvent -> PreferencesDialog.saveValue(PreferencesDialog.KEY_BIG_CARD_TOGGLED, "up"));
final JButton downArrowButton = (JButton) divider.getComponent(1);
downArrowButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
PreferencesDialog.saveValue(PreferencesDialog.KEY_BIG_CARD_TOGGLED, "down");
}
});
downArrowButton.addActionListener(actionEvent -> PreferencesDialog.saveValue(PreferencesDialog.KEY_BIG_CARD_TOGGLED, "down"));
KeyStroke ksAltEReleased = KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.ALT_MASK, true);
this.getInputMap(c).put(ksAltEReleased, "ENLARGE_RELEASE");
@ -1772,44 +1747,19 @@ public final class GamePanel extends javax.swing.JPanel {
stackObjects.setBackgroundColor(new Color(0, 0, 0, 40));
btnStopReplay.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/control_stop.png")));
btnStopReplay.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnStopReplayActionPerformed(evt);
}
});
btnStopReplay.addActionListener(evt -> btnStopReplayActionPerformed(evt));
btnNextPlay.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/control_stop_right.png")));
btnNextPlay.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNextPlayActionPerformed(evt);
}
});
btnNextPlay.addActionListener(evt -> btnNextPlayActionPerformed(evt));
btnPlay.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/control_right.png")));
btnPlay.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnPlayActionPerformed(evt);
}
});
btnPlay.addActionListener(evt -> btnPlayActionPerformed(evt));
btnSkipForward.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/control_double_stop_right.png")));
btnSkipForward.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSkipForwardActionPerformed(evt);
}
});
btnSkipForward.addActionListener(evt -> btnSkipForwardActionPerformed(evt));
btnPreviousPlay.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/control_stop_left.png")));
btnPreviousPlay.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnPreviousPlayActionPerformed(evt);
}
});
btnPreviousPlay.addActionListener(evt -> btnPreviousPlayActionPerformed(evt));
initPopupMenuTriggerOrder();
@ -2251,21 +2201,18 @@ public final class GamePanel extends javax.swing.JPanel {
// Event listener for the ShowCardsDialog
private Listener<Event> getShowCardsEventListener(final ShowCardsDialog dialog) {
return new Listener<Event>() {
@Override
public void event(Event event) {
if (event.getEventName().equals("show-popup-menu")) {
if (event.getComponent() != null && event.getComponent() instanceof CardPanel) {
JPopupMenu menu = ((CardPanel) event.getComponent()).getPopupMenu();
if (menu != null) {
cardViewPopupMenu = ((CardView) event.getSource());
menu.show(event.getComponent(), event.getxPos(), event.getyPos());
}
return (Listener<Event>) event -> {
if (event.getEventName().equals("show-popup-menu")) {
if (event.getComponent() != null && event.getComponent() instanceof CardPanel) {
JPopupMenu menu = ((CardPanel) event.getComponent()).getPopupMenu();
if (menu != null) {
cardViewPopupMenu = ((CardView) event.getSource());
menu.show(event.getComponent(), event.getxPos(), event.getyPos());
}
}
if (event.getEventName().equals("action-consumed")) {
dialog.removeDialog();
}
}
if (event.getEventName().equals("action-consumed")) {
dialog.removeDialog();
}
};
}
@ -2312,12 +2259,7 @@ public final class GamePanel extends javax.swing.JPanel {
private void initPopupMenuTriggerOrder() {
ActionListener actionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
handleTriggerOrderPopupMenuEvent(e);
}
};
ActionListener actionListener = e -> handleTriggerOrderPopupMenuEvent(e);
popupMenuTriggerOrder = new JPopupMenu();
@ -2366,7 +2308,7 @@ public final class GamePanel extends javax.swing.JPanel {
}
// Use Cmd on OSX since Ctrl+click is already used to simulate right click
private static int holdPriorityMask = System.getProperty("os.name").contains("Mac OS X") ? InputEvent.META_DOWN_MASK : InputEvent.CTRL_DOWN_MASK;
private static final int holdPriorityMask = System.getProperty("os.name").contains("Mac OS X") ? InputEvent.META_DOWN_MASK : InputEvent.CTRL_DOWN_MASK;
public void handleEvent(AWTEvent event) {
if (event instanceof InputEvent) {

View file

@ -48,7 +48,7 @@ import javax.swing.ScrollPaneConstants;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
import javax.swing.UIManager;
import mage.client.MageFrame;
import mage.client.SessionHandler;
import mage.client.components.MageTextArea;
import mage.client.game.FeedbackPanel.FeedbackMode;
@ -59,7 +59,6 @@ import static mage.constants.PlayerAction.REQUEST_AUTO_ANSWER_ID_YES;
import static mage.constants.PlayerAction.REQUEST_AUTO_ANSWER_RESET_ALL;
import static mage.constants.PlayerAction.REQUEST_AUTO_ANSWER_TEXT_NO;
import static mage.constants.PlayerAction.REQUEST_AUTO_ANSWER_TEXT_YES;
import mage.remote.Session;
/**
* Panel with buttons that copy the state of feedback panel.
@ -200,52 +199,30 @@ public class HelperPanel extends JPanel {
};
btnLeft.addMouseListener(checkPopupAdapter);
btnLeft.addActionListener(new ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
if (linkLeft != null) {
clickButton(linkLeft);
}
btnLeft.addActionListener(evt -> {
if (linkLeft != null) {
clickButton(linkLeft);
}
});
btnRight.addMouseListener(checkPopupAdapter);
btnRight.addActionListener(new ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
if (linkRight != null) {
clickButton(linkRight);
}
btnRight.addActionListener(evt -> {
if (linkRight != null) {
clickButton(linkRight);
}
});
btnSpecial.addActionListener(new ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
if (linkSpecial != null) {
clickButton(linkSpecial);
}
btnSpecial.addActionListener(evt -> {
if (linkSpecial != null) {
clickButton(linkSpecial);
}
});
btnUndo.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
if (linkUndo != null) {
{
Thread worker = new Thread() {
@Override
public void run() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
linkUndo.doClick();
}
});
}
};
worker.start();
}
btnUndo.addActionListener(evt -> {
if (linkUndo != null) {
{
Thread worker = new Thread(() -> SwingUtilities.invokeLater(() -> linkUndo.doClick()));
worker.start();
}
}
});
@ -279,19 +256,11 @@ public class HelperPanel extends JPanel {
}
private void clickButton(final JButton button) {
Thread worker = new Thread() {
@Override
public void run() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
setState("", false, "", false, null);
setSpecial("", false);
button.doClick();
}
});
}
};
Thread worker = new Thread(() -> SwingUtilities.invokeLater(() -> {
setState("", false, "", false, null);
setSpecial("", false);
button.doClick();
}));
worker.start();
}
@ -363,12 +332,7 @@ public class HelperPanel extends JPanel {
private void initPopupMenuTriggerOrder() {
ActionListener actionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
handleAutoAnswerPopupMenuEvent(e);
}
};
ActionListener actionListener = e -> handleAutoAnswerPopupMenuEvent(e);
popupMenuAskYes = new JPopupMenu();
popupMenuAskNo = new JPopupMenu();

View file

@ -29,7 +29,6 @@ package mage.client.game;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
@ -158,44 +157,41 @@ public class PlayAreaPanel extends javax.swing.JPanel {
JMenuItem menuItem;
ActionListener skipListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case "F2": {
if (gamePanel.getFeedbackPanel() != null) {
gamePanel.getFeedbackPanel().pressOKYesOrDone();
}
break;
}
case "F3": {
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null);
break;
}
case "F4": {
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null);
break;
}
case "F5": {
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
break;
}
case "F6": {
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN_SKIP_STACK, gameId, null);
break;
}
case "F7": {
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
break;
}
case "F9": {
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null);
break;
}
case "F11": {
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_END_STEP_BEFORE_MY_NEXT_TURN, gameId, null);
break;
ActionListener skipListener = e -> {
switch (e.getActionCommand()) {
case "F2": {
if (gamePanel.getFeedbackPanel() != null) {
gamePanel.getFeedbackPanel().pressOKYesOrDone();
}
break;
}
case "F3": {
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, gameId, null);
break;
}
case "F4": {
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN, gameId, null);
break;
}
case "F5": {
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_TURN_END_STEP, gameId, null);
break;
}
case "F6": {
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_TURN_SKIP_STACK, gameId, null);
break;
}
case "F7": {
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_NEXT_MAIN_PHASE, gameId, null);
break;
}
case "F9": {
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_MY_NEXT_TURN, gameId, null);
break;
}
case "F11": {
SessionHandler.sendPlayerAction(PlayerAction.PASS_PRIORITY_UNTIL_END_STEP_BEFORE_MY_NEXT_TURN, gameId, null);
break;
}
}
};
@ -216,13 +212,10 @@ public class PlayAreaPanel extends javax.swing.JPanel {
holdPriorityMenuItem.setMnemonic(KeyEvent.VK_P);
holdPriorityMenuItem.setToolTipText("<html>Hold priority after casting a spell or activating an ability, instead of automatically passing priority.");
popupMenu.add(holdPriorityMenuItem);
holdPriorityMenuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean holdPriority = ((JCheckBoxMenuItem) e.getSource()).getState();
gamePanel.setMenuStates(manaPoolMenuItem1.getState(), manaPoolMenuItem2.getState(), useFirstManaAbilityItem.getState(), holdPriority);
gamePanel.holdPriority(holdPriority);
}
holdPriorityMenuItem.addActionListener(e -> {
boolean holdPriority = ((JCheckBoxMenuItem) e.getSource()).getState();
gamePanel.setMenuStates(manaPoolMenuItem1.getState(), manaPoolMenuItem2.getState(), useFirstManaAbilityItem.getState(), holdPriority);
gamePanel.holdPriority(holdPriority);
});
JMenu skipMenu = new JMenu("Skip");
@ -287,14 +280,11 @@ public class PlayAreaPanel extends javax.swing.JPanel {
manaPoolMenu.add(manaPoolMenuItem1);
// Auto pay mana from mana pool
manaPoolMenuItem1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean manaPoolAutomatic = ((JCheckBoxMenuItem) e.getSource()).getState();
PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT, manaPoolAutomatic ? "true" : "false");
gamePanel.setMenuStates(manaPoolAutomatic, manaPoolMenuItem2.getState(), useFirstManaAbilityItem.getState(), holdPriorityMenuItem.getState());
SessionHandler.sendPlayerAction(manaPoolAutomatic ? PlayerAction.MANA_AUTO_PAYMENT_ON : PlayerAction.MANA_AUTO_PAYMENT_OFF, gameId, null);
}
manaPoolMenuItem1.addActionListener(e -> {
boolean manaPoolAutomatic = ((JCheckBoxMenuItem) e.getSource()).getState();
PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT, manaPoolAutomatic ? "true" : "false");
gamePanel.setMenuStates(manaPoolAutomatic, manaPoolMenuItem2.getState(), useFirstManaAbilityItem.getState(), holdPriorityMenuItem.getState());
SessionHandler.sendPlayerAction(manaPoolAutomatic ? PlayerAction.MANA_AUTO_PAYMENT_ON : PlayerAction.MANA_AUTO_PAYMENT_OFF, gameId, null);
});
manaPoolMenuItem2 = new JCheckBoxMenuItem("No automatic usage for mana already in the pool", true);
@ -305,14 +295,11 @@ public class PlayAreaPanel extends javax.swing.JPanel {
manaPoolMenu.add(manaPoolMenuItem2);
// Auto pay mana from mana pool
manaPoolMenuItem2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean manaPoolAutomaticRestricted = ((JCheckBoxMenuItem) e.getSource()).getState();
PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, manaPoolAutomaticRestricted ? "true" : "false");
gamePanel.setMenuStates(manaPoolMenuItem1.getState(), manaPoolAutomaticRestricted, useFirstManaAbilityItem.getState(), holdPriorityMenuItem.getState());
SessionHandler.sendPlayerAction(manaPoolAutomaticRestricted ? PlayerAction.MANA_AUTO_PAYMENT_RESTRICTED_ON : PlayerAction.MANA_AUTO_PAYMENT_RESTRICTED_OFF, gameId, null);
}
manaPoolMenuItem2.addActionListener(e -> {
boolean manaPoolAutomaticRestricted = ((JCheckBoxMenuItem) e.getSource()).getState();
PreferencesDialog.saveValue(KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, manaPoolAutomaticRestricted ? "true" : "false");
gamePanel.setMenuStates(manaPoolMenuItem1.getState(), manaPoolAutomaticRestricted, useFirstManaAbilityItem.getState(), holdPriorityMenuItem.getState());
SessionHandler.sendPlayerAction(manaPoolAutomaticRestricted ? PlayerAction.MANA_AUTO_PAYMENT_RESTRICTED_ON : PlayerAction.MANA_AUTO_PAYMENT_RESTRICTED_OFF, gameId, null);
});
useFirstManaAbilityItem = new JCheckBoxMenuItem("Use first mana ability when tapping lands", false);
@ -323,14 +310,11 @@ public class PlayAreaPanel extends javax.swing.JPanel {
manaPoolMenu.add(useFirstManaAbilityItem);
// Use first mana ability of lands
useFirstManaAbilityItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean useFirstManaAbility = ((JCheckBoxMenuItem) e.getSource()).getState();
PreferencesDialog.saveValue(KEY_USE_FIRST_MANA_ABILITY, useFirstManaAbility ? "true" : "false");
gamePanel.setMenuStates(manaPoolMenuItem1.getState(), manaPoolMenuItem2.getState(), useFirstManaAbility, holdPriorityMenuItem.getState());
SessionHandler.sendPlayerAction(useFirstManaAbility ? PlayerAction.USE_FIRST_MANA_ABILITY_ON : PlayerAction.USE_FIRST_MANA_ABILITY_OFF, gameId, null);
}
useFirstManaAbilityItem.addActionListener(e -> {
boolean useFirstManaAbility = ((JCheckBoxMenuItem) e.getSource()).getState();
PreferencesDialog.saveValue(KEY_USE_FIRST_MANA_ABILITY, useFirstManaAbility ? "true" : "false");
gamePanel.setMenuStates(manaPoolMenuItem1.getState(), manaPoolMenuItem2.getState(), useFirstManaAbility, holdPriorityMenuItem.getState());
SessionHandler.sendPlayerAction(useFirstManaAbility ? PlayerAction.USE_FIRST_MANA_ABILITY_ON : PlayerAction.USE_FIRST_MANA_ABILITY_OFF, gameId, null);
});
JMenu automaticConfirmsMenu = new JMenu("Automatic confirms");
@ -342,36 +326,21 @@ public class PlayAreaPanel extends javax.swing.JPanel {
menuItem.setToolTipText("Reset all effects that were added to the list of auto select replacement effects this game.");
automaticConfirmsMenu.add(menuItem);
// Reset the replacement effcts that were auto selected for the game
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
SessionHandler.sendPlayerAction(PlayerAction.RESET_AUTO_SELECT_REPLACEMENT_EFFECTS, gameId, null);
}
});
menuItem.addActionListener(e -> SessionHandler.sendPlayerAction(PlayerAction.RESET_AUTO_SELECT_REPLACEMENT_EFFECTS, gameId, null));
menuItem = new JMenuItem("Triggered abilities - reset auto stack order");
menuItem.setMnemonic(KeyEvent.VK_T);
menuItem.setToolTipText("Deletes all triggered ability order settings you added during the game.");
automaticConfirmsMenu.add(menuItem);
// Reset the replacement effcts that were auto selected for the game
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
SessionHandler.sendPlayerAction(PlayerAction.TRIGGER_AUTO_ORDER_RESET_ALL, gameId, null);
}
});
menuItem.addActionListener(e -> SessionHandler.sendPlayerAction(PlayerAction.TRIGGER_AUTO_ORDER_RESET_ALL, gameId, null));
menuItem = new JMenuItem("Use requests - reset automatic answers");
menuItem.setMnemonic(KeyEvent.VK_T);
menuItem.setToolTipText("Deletes all defined automatic answers for Yes/No usage requests.");
automaticConfirmsMenu.add(menuItem);
// Reset the replacement effcts that were auto selected for the game
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
SessionHandler.sendPlayerAction(PlayerAction.REQUEST_AUTO_ANSWER_RESET_ALL, gameId, null);
}
});
menuItem.addActionListener(e -> SessionHandler.sendPlayerAction(PlayerAction.REQUEST_AUTO_ANSWER_RESET_ALL, gameId, null));
JMenu handCardsMenu = new JMenu("Cards on hand");
handCardsMenu.setMnemonic(KeyEvent.VK_H);
@ -383,12 +352,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
handCardsMenu.add(menuItem);
// Request to see hand cards
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
SessionHandler.sendPlayerAction(PlayerAction.REQUEST_PERMISSION_TO_SEE_HAND_CARDS, gameId, playerId);
}
});
menuItem.addActionListener(e -> SessionHandler.sendPlayerAction(PlayerAction.REQUEST_PERMISSION_TO_SEE_HAND_CARDS, gameId, playerId));
} else {
allowViewHandCardsMenuItem = new JCheckBoxMenuItem("Allow requests to show from other users", allowRequestToShowHandCards);
allowViewHandCardsMenuItem.setMnemonic(KeyEvent.VK_A);
@ -396,13 +360,10 @@ public class PlayAreaPanel extends javax.swing.JPanel {
handCardsMenu.add(allowViewHandCardsMenuItem);
// Requests allowed
allowViewHandCardsMenuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean requestsAllowed = ((JCheckBoxMenuItem) e.getSource()).getState();
PreferencesDialog.setPrefValue(KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, requestsAllowed);
SessionHandler.sendPlayerAction(requestsAllowed ? PlayerAction.PERMISSION_REQUESTS_ALLOWED_ON : PlayerAction.PERMISSION_REQUESTS_ALLOWED_OFF, gameId, null);
}
allowViewHandCardsMenuItem.addActionListener(e -> {
boolean requestsAllowed = ((JCheckBoxMenuItem) e.getSource()).getState();
PreferencesDialog.setPrefValue(KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, requestsAllowed);
SessionHandler.sendPlayerAction(requestsAllowed ? PlayerAction.PERMISSION_REQUESTS_ALLOWED_ON : PlayerAction.PERMISSION_REQUESTS_ALLOWED_OFF, gameId, null);
});
menuItem = new JMenuItem("Revoke all permission(s) to see your hand cards");
@ -411,21 +372,13 @@ public class PlayAreaPanel extends javax.swing.JPanel {
handCardsMenu.add(menuItem);
// revoke permissions to see hand cards
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
SessionHandler.sendPlayerAction(PlayerAction.REVOKE_PERMISSIONS_TO_SEE_HAND_CARDS, gameId, null);
}
});
menuItem.addActionListener(e -> SessionHandler.sendPlayerAction(PlayerAction.REVOKE_PERMISSIONS_TO_SEE_HAND_CARDS, gameId, null));
}
if (options.rollbackTurnsAllowed) {
ActionListener rollBackActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int turnsToRollBack = Integer.parseInt(e.getActionCommand());
SessionHandler.sendPlayerAction(PlayerAction.ROLLBACK_TURNS, gameId, turnsToRollBack);
}
ActionListener rollBackActionListener = e -> {
int turnsToRollBack = Integer.parseInt(e.getActionCommand());
SessionHandler.sendPlayerAction(PlayerAction.ROLLBACK_TURNS, gameId, turnsToRollBack);
};
JMenu rollbackMainItem = new JMenu("Rollback");
@ -463,26 +416,23 @@ public class PlayAreaPanel extends javax.swing.JPanel {
concedeMenu.setMnemonic(KeyEvent.VK_C);
popupMenu.add(concedeMenu);
ActionListener concedeListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case "Game": {
UserRequestMessage message = new UserRequestMessage("Confirm concede game", "Are you sure you want to concede the game?");
message.setButton1("No", null);
message.setButton2("Yes", PlayerAction.CLIENT_CONCEDE_GAME);
message.setGameId(gameId);
MageFrame.getInstance().showUserRequestDialog(message);
break;
}
case "Match": {
UserRequestMessage message = new UserRequestMessage("Confirm concede match", "Are you sure you want to concede the complete match?");
message.setButton1("No", null);
message.setButton2("Yes", PlayerAction.CLIENT_CONCEDE_MATCH);
message.setGameId(gameId);
MageFrame.getInstance().showUserRequestDialog(message);
break;
}
ActionListener concedeListener = e -> {
switch (e.getActionCommand()) {
case "Game": {
UserRequestMessage message = new UserRequestMessage("Confirm concede game", "Are you sure you want to concede the game?");
message.setButton1("No", null);
message.setButton2("Yes", PlayerAction.CLIENT_CONCEDE_GAME);
message.setGameId(gameId);
MageFrame.getInstance().showUserRequestDialog(message);
break;
}
case "Match": {
UserRequestMessage message = new UserRequestMessage("Confirm concede match", "Are you sure you want to concede the complete match?");
message.setButton1("No", null);
message.setButton2("Yes", PlayerAction.CLIENT_CONCEDE_MATCH);
message.setGameId(gameId);
MageFrame.getInstance().showUserRequestDialog(message);
break;
}
}
};
@ -531,27 +481,19 @@ public class PlayAreaPanel extends javax.swing.JPanel {
popupMenu.add(menuItem);
// Stop watching
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
UserRequestMessage message = new UserRequestMessage("Confirm stop watching game", "Are you sure you want to stop watching the game?");
message.setButton1("No", null);
message.setButton2("Yes", PlayerAction.CLIENT_STOP_WATCHING);
message.setGameId(gameId);
MageFrame.getInstance().showUserRequestDialog(message);
}
menuItem.addActionListener(e -> {
UserRequestMessage message = new UserRequestMessage("Confirm stop watching game", "Are you sure you want to stop watching the game?");
message.setButton1("No", null);
message.setButton2("Yes", PlayerAction.CLIENT_STOP_WATCHING);
message.setGameId(gameId);
MageFrame.getInstance().showUserRequestDialog(message);
});
menuItem = new JMenuItem("Request permission to see hand cards");
popupMenu.add(menuItem);
// Request to see hand cards
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
SessionHandler.sendPlayerAction(PlayerAction.REQUEST_PERMISSION_TO_SEE_HAND_CARDS, gameId, playerId);
}
});
menuItem.addActionListener(e -> SessionHandler.sendPlayerAction(PlayerAction.REQUEST_PERMISSION_TO_SEE_HAND_CARDS, gameId, playerId));
battlefieldPanel.getMainPanel().addMouseListener(new MouseAdapter() {
@Override
@ -610,12 +552,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
battlefieldPanel.setTopPanelBattlefield(options.topRow);
btnCheat.setText("Cheat");
btnCheat.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCheatActionPerformed(evt);
}
});
btnCheat.addActionListener(evt -> btnCheatActionPerformed(evt));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
layout.setHorizontalGroup(

View file

@ -38,8 +38,6 @@ import java.awt.Dimension;
import java.awt.Font;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.LinkedHashSet;
@ -58,7 +56,7 @@ import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.SwingConstants;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;
import mage.MageException;
import mage.cards.decks.importer.DckDeckImporter;
import mage.client.MageFrame;
import mage.client.SessionHandler;
@ -68,7 +66,6 @@ import mage.client.components.MageRoundPane;
import mage.client.components.ext.dlg.DialogManager;
import mage.client.dialog.PreferencesDialog;
import mage.client.util.CardsViewUtil;
import mage.client.util.Command;
import mage.client.util.ImageHelper;
import mage.client.util.gui.BufferedImageBuilder;
import mage.client.util.gui.countryBox.CountryUtil;
@ -141,22 +138,16 @@ public class PlayerPanelExt extends javax.swing.JPanel {
if (priorityTime > 0) {
long delay = 1000L;
timer = new PriorityTimer(priorityTime, delay, new mage.interfaces.Action() {
@Override
public void execute() throws MageException {
// do nothing
}
timer = new PriorityTimer(priorityTime, delay, () -> {
// do nothing
});
final PriorityTimer pt = timer;
timer.setTaskOnTick(new mage.interfaces.Action() {
@Override
public void execute() throws MageException {
int priorityTimeValue = pt.getCount();
String text = getPriorityTimeLeftString(priorityTimeValue);
PlayerPanelExt.this.avatar.setTopText(text);
PlayerPanelExt.this.timerLabel.setText(text);
PlayerPanelExt.this.avatar.repaint();
}
timer.setTaskOnTick(() -> {
int priorityTimeValue = pt.getCount();
String text = getPriorityTimeLeftString(priorityTimeValue);
PlayerPanelExt.this.avatar.setTopText(text);
PlayerPanelExt.this.timerLabel.setText(text);
PlayerPanelExt.this.avatar.repaint();
});
timer.init(gameId);
}
@ -414,12 +405,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
avatar.setTextAlwaysVisible(true);
}
avatar.setTextOffsetButtonY(10);
avatar.setObserver(new Command() {
@Override
public void execute() {
SessionHandler.sendPlayerUUID(gameId, playerId);
}
});
avatar.setObserver(() -> SessionHandler.sendPlayerUUID(gameId, playerId));
// timer area /small layout)
timerLabel.setToolTipText("Time left");
@ -462,12 +448,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
library = new HoverButton(null, resizedLibrary, resizedLibrary, resizedLibrary, r);
library.setToolTipText("Library");
library.setOpaque(false);
library.setObserver(new Command() {
@Override
public void execute() {
btnLibraryActionPerformed(null);
}
});
library.setObserver(() -> btnLibraryActionPerformed(null));
// Grave count and open graveyard button
r = new Rectangle(21, 21);
@ -478,12 +459,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
grave = new HoverButton(null, resizedGrave, resizedGrave, resizedGrave, r);
grave.setToolTipText("Graveyard");
grave.setOpaque(false);
grave.setObserver(new Command() {
@Override
public void execute() {
btnGraveActionPerformed(null);
}
});
grave.setObserver(() -> btnGraveActionPerformed(null));
exileLabel = new JLabel();
exileLabel.setToolTipText("Exile");
@ -493,12 +469,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
exileZone = new HoverButton(null, resized, resized, resized, r);
exileZone.setToolTipText("Exile");
exileZone.setOpaque(false);
exileZone.setObserver(new Command() {
@Override
public void execute() {
btnExileZoneActionPerformed(null);
}
});
exileZone.setObserver(() -> btnExileZoneActionPerformed(null));
exileZone.setBounds(25, 0, 21, 21);
// Cheat button
@ -508,12 +479,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
cheat = new JButton();
cheat.setIcon(new ImageIcon(resized));
cheat.setToolTipText("Cheat button");
cheat.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
btnCheatActionPerformed(e);
}
});
cheat.addActionListener(e -> btnCheatActionPerformed(e));
zonesPanel = new JPanel();
zonesPanel.setPreferredSize(new Dimension(100, 60));
@ -527,12 +493,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
commandZone = new HoverButton(null, resized, resized, resized, r);
commandZone.setToolTipText("Command Zone (Commander and Emblems)");
commandZone.setOpaque(false);
commandZone.setObserver(new Command() {
@Override
public void execute() {
btnCommandZoneActionPerformed(null);
}
});
commandZone.setObserver(() -> btnCommandZoneActionPerformed(null));
commandZone.setBounds(5, 0, 21, 21);
zonesPanel.add(commandZone);
@ -569,12 +530,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
btnPlayer.setText("Player");
btnPlayer.setVisible(false);
btnPlayer.setToolTipText("Player");
btnPlayer.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
SessionHandler.sendPlayerUUID(gameId, playerId);
}
});
btnPlayer.addActionListener(e -> SessionHandler.sendPlayerUUID(gameId, playerId));
// Add mana symbols
JLabel manaCountLabelW = new JLabel();
@ -587,12 +543,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
btnWhiteMana.setToolTipText("White mana");
btnWhiteMana.setOpaque(false);
btnWhiteMana.setObserver(new Command() {
@Override
public void execute() {
btnManaActionPerformed(ManaType.WHITE);
}
});
btnWhiteMana.setObserver(() -> btnManaActionPerformed(ManaType.WHITE));
JLabel manaCountLabelU = new JLabel();
manaCountLabelU.setToolTipText("Blue mana");
@ -603,12 +554,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
HoverButton btnBlueMana = new HoverButton(null, imageManaU, imageManaU, imageManaU, r);
btnBlueMana.setToolTipText("Blue mana");
btnBlueMana.setOpaque(false);
btnBlueMana.setObserver(new Command() {
@Override
public void execute() {
btnManaActionPerformed(ManaType.BLUE);
}
});
btnBlueMana.setObserver(() -> btnManaActionPerformed(ManaType.BLUE));
JLabel manaCountLabelB = new JLabel();
manaCountLabelB.setToolTipText("Black mana");
@ -619,12 +565,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
HoverButton btnBlackMana = new HoverButton(null, imageManaB, imageManaB, imageManaB, r);
btnBlackMana.setToolTipText("Black mana");
btnBlackMana.setOpaque(false);
btnBlackMana.setObserver(new Command() {
@Override
public void execute() {
btnManaActionPerformed(ManaType.BLACK);
}
});
btnBlackMana.setObserver(() -> btnManaActionPerformed(ManaType.BLACK));
JLabel manaCountLabelR = new JLabel();
manaCountLabelR.setToolTipText("Red mana");
@ -635,12 +576,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
HoverButton btnRedMana = new HoverButton(null, imageManaR, imageManaR, imageManaR, r);
btnRedMana.setToolTipText("Red mana");
btnRedMana.setOpaque(false);
btnRedMana.setObserver(new Command() {
@Override
public void execute() {
btnManaActionPerformed(ManaType.RED);
}
});
btnRedMana.setObserver(() -> btnManaActionPerformed(ManaType.RED));
JLabel manaCountLabelG = new JLabel();
manaCountLabelG.setToolTipText("Green mana");
@ -651,12 +587,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
HoverButton btnGreenMana = new HoverButton(null, imageManaG, imageManaG, imageManaG, r);
btnGreenMana.setToolTipText("Green mana");
btnGreenMana.setOpaque(false);
btnGreenMana.setObserver(new Command() {
@Override
public void execute() {
btnManaActionPerformed(ManaType.GREEN);
}
});
btnGreenMana.setObserver(() -> btnManaActionPerformed(ManaType.GREEN));
JLabel manaCountLabelX = new JLabel();
manaCountLabelX.setToolTipText("Colorless mana");
@ -667,12 +598,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
HoverButton btnColorlessMana = new HoverButton(null, imageManaX, imageManaX, imageManaX, r);
btnColorlessMana.setToolTipText("Colorless mana");
btnColorlessMana.setOpaque(false);
btnColorlessMana.setObserver(new Command() {
@Override
public void execute() {
btnManaActionPerformed(ManaType.COLORLESS);
}
});
btnColorlessMana.setObserver(() -> btnManaActionPerformed(ManaType.COLORLESS));
GroupLayout gl_panelBackground = new GroupLayout(panelBackground);
gl_panelBackground.setHorizontalGroup(

View file

@ -7,8 +7,6 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
@ -24,6 +22,7 @@ import javax.swing.JPopupMenu;
import javax.swing.Popup;
import javax.swing.PopupFactory;
import javax.swing.SwingUtilities;
import mage.cards.MageCard;
import mage.cards.action.ActionCallback;
import mage.cards.action.TransferData;
@ -80,6 +79,7 @@ public class MageActionCallback implements ActionCallback {
CLOSED, NORMAL, ROTATED
}
private Date enlargeredViewOpened;
private volatile EnlargedWindowState enlargedWindowState = EnlargedWindowState.CLOSED;
//private volatile boolean enlargedImageWindowOpen = false;
@ -158,7 +158,7 @@ public class MageActionCallback implements ActionCallback {
|| !tooltipCard.equals(data.card)
|| SessionHandler.getSession() == null
|| !popupTextWindowOpen
|| !enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
|| enlargedWindowState != EnlargedWindowState.CLOSED) {
return;
}
@ -177,25 +177,22 @@ public class MageActionCallback implements ActionCallback {
public void showPopup(final Component popupContainer, final Component infoPane) throws InterruptedException {
final Component c = MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (!popupTextWindowOpen
|| !enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
return;
}
if (data.locationOnScreen == null) {
data.locationOnScreen = data.component.getLocationOnScreen();
}
SwingUtilities.invokeLater(() -> {
if (!popupTextWindowOpen
|| enlargedWindowState != EnlargedWindowState.CLOSED) {
return;
}
if (data.locationOnScreen == null) {
data.locationOnScreen = data.component.getLocationOnScreen();
}
Point location = new Point((int) data.locationOnScreen.getX() + data.popupOffsetX - 40, (int) data.locationOnScreen.getY() + data.popupOffsetY - 40);
location = GuiDisplayUtil.keepComponentInsideParent(location, parentPoint, infoPane, parentComponent);
location.translate(-parentPoint.x, -parentPoint.y);
popupContainer.setLocation(location);
popupContainer.setVisible(true);
c.repaint();
}
}
Point location = new Point((int) data.locationOnScreen.getX() + data.popupOffsetX - 40, (int) data.locationOnScreen.getY() + data.popupOffsetY - 40);
location = GuiDisplayUtil.keepComponentInsideParent(location, parentPoint, infoPane, parentComponent);
location.translate(-parentPoint.x, -parentPoint.y);
popupContainer.setLocation(location);
popupContainer.setVisible(true);
c.repaint();
}
);
}
});
@ -257,7 +254,7 @@ public class MageActionCallback implements ActionCallback {
if (this.startedDragging && prevCardPanel != null && card != null) {
for (Component component : card.getCardArea().getComponents()) {
if (component instanceof CardPanel) {
if (cardPanels.contains((CardPanel) component)) {
if (cardPanels.contains(component)) {
component.setLocation(component.getLocation().x, component.getLocation().y - GO_DOWN_ON_DRAG_Y_OFFSET);
}
}
@ -331,7 +328,7 @@ public class MageActionCallback implements ActionCallback {
for (Component component : container.getComponents()) {
if (component instanceof CardPanel) {
if (!component.equals(card)) {
if (!cardPanels.contains((CardPanel) component)) {
if (!cardPanels.contains(component)) {
component.setLocation(component.getLocation().x, component.getLocation().y + GO_DOWN_ON_DRAG_Y_OFFSET);
}
cardPanels.add((CardPanel) component);
@ -347,12 +344,7 @@ public class MageActionCallback implements ActionCallback {
private void sortLayout(List<CardPanel> cards, CardPanel source, boolean includeSource) {
source.getLocation().x -= COMPARE_GAP_X; // this creates nice effect
Collections.sort(cards, new Comparator<CardPanel>() {
@Override
public int compare(CardPanel cp1, CardPanel cp2) {
return Integer.valueOf(cp1.getLocation().x).compareTo(cp2.getLocation().x);
}
});
cards.sort((cp1, cp2) -> Integer.valueOf(cp1.getLocation().x).compareTo(cp2.getLocation().x));
int dx = 0;
boolean createdGapForSource = false;
@ -412,7 +404,7 @@ public class MageActionCallback implements ActionCallback {
} else {
popupTextWindowOpen = true;
}
if (!enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
if (enlargedWindowState != EnlargedWindowState.CLOSED) {
cancelTimeout();
displayEnlargedCard(mageCard.getOriginal(), transferData);
}
@ -427,7 +419,6 @@ public class MageActionCallback implements ActionCallback {
/**
* Hides the text popup window
*
*/
public void hideTooltipPopup() {
this.tooltipCard = null;
@ -471,13 +462,13 @@ public class MageActionCallback implements ActionCallback {
@Override
public void mouseWheelMoved(MouseWheelEvent e, TransferData transferData) {
int notches = e.getWheelRotation();
if (!enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
if (enlargedWindowState != EnlargedWindowState.CLOSED) {
// same move direction will be ignored, opposite direction closes the enlarged window
if (new Date().getTime() - enlargeredViewOpened.getTime() > 1000) {
// if the opening is back more than 1 seconds close anyway
hideEnlargedCard();
handleOverNewView(transferData);
} else if (enlargeMode.equals(EnlargeMode.NORMAL)) {
} else if (enlargeMode == EnlargeMode.NORMAL) {
if (notches > 0) {
hideEnlargedCard();
handleOverNewView(transferData);
@ -501,10 +492,10 @@ public class MageActionCallback implements ActionCallback {
* Show the big card image on mouse position while hovering over a card
*
* @param showAlternative defines if the original image (if it's a copied
* card) or the opposite side of a transformable card will be shown
* card) or the opposite side of a transformable card will be shown
*/
public void enlargeCard(EnlargeMode showAlternative) {
if (enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
if (enlargedWindowState == EnlargedWindowState.CLOSED) {
this.enlargeMode = showAlternative;
CardView cardView = null;
if (popupData != null) {
@ -525,7 +516,7 @@ public class MageActionCallback implements ActionCallback {
}
public void hideEnlargedCard() {
if (!enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
if (enlargedWindowState != EnlargedWindowState.CLOSED) {
enlargedWindowState = EnlargedWindowState.CLOSED;
try {
Component cardPreviewContainer = MageFrame.getUI().getComponent(MageComponents.CARD_PREVIEW_CONTAINER);
@ -540,78 +531,75 @@ public class MageActionCallback implements ActionCallback {
}
private void displayEnlargedCard(final CardView cardView, final TransferData transferData) {
ThreadUtils.threadPool3.submit(new Runnable() {
@Override
public void run() {
if (cardView == null) {
ThreadUtils.threadPool3.submit(() -> {
if (cardView == null) {
return;
}
try {
if (enlargedWindowState == EnlargedWindowState.CLOSED) {
return;
}
try {
if (enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
return;
MageComponents mageComponentCardPreviewContainer;
MageComponents mageComponentCardPreviewPane;
if (cardView.isToRotate()) {
if (enlargedWindowState == EnlargedWindowState.NORMAL) {
hideEnlargedCard();
enlargedWindowState = EnlargedWindowState.ROTATED;
}
MageComponents mageComponentCardPreviewContainer;
MageComponents mageComponentCardPreviewPane;
if (cardView.isToRotate()) {
if (enlargedWindowState.equals(EnlargedWindowState.NORMAL)) {
hideEnlargedCard();
enlargedWindowState = EnlargedWindowState.ROTATED;
}
mageComponentCardPreviewContainer = MageComponents.CARD_PREVIEW_CONTAINER_ROTATED;
mageComponentCardPreviewPane = MageComponents.CARD_PREVIEW_PANE_ROTATED;
} else {
if (enlargedWindowState.equals(EnlargedWindowState.ROTATED)) {
hideEnlargedCard();
enlargedWindowState = EnlargedWindowState.NORMAL;
}
mageComponentCardPreviewContainer = MageComponents.CARD_PREVIEW_CONTAINER;
mageComponentCardPreviewPane = MageComponents.CARD_PREVIEW_PANE;
mageComponentCardPreviewContainer = MageComponents.CARD_PREVIEW_CONTAINER_ROTATED;
mageComponentCardPreviewPane = MageComponents.CARD_PREVIEW_PANE_ROTATED;
} else {
if (enlargedWindowState == EnlargedWindowState.ROTATED) {
hideEnlargedCard();
enlargedWindowState = EnlargedWindowState.NORMAL;
}
final Component popupContainer = MageFrame.getUI().getComponent(mageComponentCardPreviewContainer);
Component cardPreviewPane = MageFrame.getUI().getComponent(mageComponentCardPreviewPane);
Component parentComponent = SwingUtilities.getRoot(transferData.component);
if (cardPreviewPane != null && parentComponent != null) {
Point parentPoint = parentComponent.getLocationOnScreen();
transferData.locationOnScreen = transferData.component.getLocationOnScreen();
Point location = new Point((int) transferData.locationOnScreen.getX() + transferData.popupOffsetX - 40, (int) transferData.locationOnScreen.getY() + transferData.popupOffsetY - 40);
location = GuiDisplayUtil.keepComponentInsideParent(location, parentPoint, cardPreviewPane, parentComponent);
location.translate(-parentPoint.x, -parentPoint.y);
popupContainer.setLocation(location);
popupContainer.setVisible(true);
MageCard mageCard = (MageCard) transferData.component;
Image image = null;
switch (enlargeMode) {
case COPY:
if (cardView instanceof PermanentView) {
image = ImageCache.getImageOriginal(((PermanentView) cardView).getOriginal());
}
break;
case ALTERNATE:
if (cardView.getAlternateName() != null) {
if (cardView instanceof PermanentView && !cardView.isFlipCard() && !cardView.canTransform() && ((PermanentView) cardView).isCopy()) {
image = ImageCache.getImageOriginal(((PermanentView) cardView).getOriginal());
} else {
image = ImageCache.getImageOriginalAlternateName(cardView);
}
}
break;
}
if (image == null) {
image = mageCard.getImage();
}
// shows the card in the popup Container
BigCard bigCard = (BigCard) cardPreviewPane;
displayCardInfo(mageCard, image, bigCard);
} else {
LOGGER.warn("No Card preview Pane in Mage Frame defined. Card: " + cardView.getName());
}
} catch (Exception e) {
LOGGER.warn("Problem dring display of enlarged card", e);
mageComponentCardPreviewContainer = MageComponents.CARD_PREVIEW_CONTAINER;
mageComponentCardPreviewPane = MageComponents.CARD_PREVIEW_PANE;
}
final Component popupContainer = MageFrame.getUI().getComponent(mageComponentCardPreviewContainer);
Component cardPreviewPane = MageFrame.getUI().getComponent(mageComponentCardPreviewPane);
Component parentComponent = SwingUtilities.getRoot(transferData.component);
if (cardPreviewPane != null && parentComponent != null) {
Point parentPoint = parentComponent.getLocationOnScreen();
transferData.locationOnScreen = transferData.component.getLocationOnScreen();
Point location = new Point((int) transferData.locationOnScreen.getX() + transferData.popupOffsetX - 40, (int) transferData.locationOnScreen.getY() + transferData.popupOffsetY - 40);
location = GuiDisplayUtil.keepComponentInsideParent(location, parentPoint, cardPreviewPane, parentComponent);
location.translate(-parentPoint.x, -parentPoint.y);
popupContainer.setLocation(location);
popupContainer.setVisible(true);
MageCard mageCard = (MageCard) transferData.component;
Image image = null;
switch (enlargeMode) {
case COPY:
if (cardView instanceof PermanentView) {
image = ImageCache.getImageOriginal(((PermanentView) cardView).getOriginal());
}
break;
case ALTERNATE:
if (cardView.getAlternateName() != null) {
if (cardView instanceof PermanentView && !cardView.isFlipCard() && !cardView.canTransform() && ((PermanentView) cardView).isCopy()) {
image = ImageCache.getImageOriginal(((PermanentView) cardView).getOriginal());
} else {
image = ImageCache.getImageOriginalAlternateName(cardView);
}
}
break;
}
if (image == null) {
image = mageCard.getImage();
}
// shows the card in the popup Container
BigCard bigCard = (BigCard) cardPreviewPane;
displayCardInfo(mageCard, image, bigCard);
} else {
LOGGER.warn("No Card preview Pane in Mage Frame defined. Card: " + cardView.getName());
}
} catch (Exception e) {
LOGGER.warn("Problem dring display of enlarged card", e);
}
});
}
@ -621,7 +609,7 @@ public class MageActionCallback implements ActionCallback {
// XXX: scaled to fit width
bigCard.setCard(mageCard.getOriginal().getId(), enlargeMode, image, mageCard.getOriginal().getRules(), mageCard.getOriginal().isToRotate());
// if it's an ability, show only the ability text as overlay
if (mageCard.getOriginal().isAbility() && enlargeMode.equals(EnlargeMode.NORMAL)) {
if (mageCard.getOriginal().isAbility() && enlargeMode == EnlargeMode.NORMAL) {
bigCard.showTextComponent();
} else {
bigCard.hideTextComponent();
@ -637,12 +625,7 @@ public class MageActionCallback implements ActionCallback {
private synchronized void startHideTimeout() {
cancelTimeout();
hideTimeout = timeoutExecutor.schedule(new Runnable() {
@Override
public void run() {
hideEnlargedCard();
}
}, 700, TimeUnit.MILLISECONDS);
hideTimeout = timeoutExecutor.schedule(this::hideEnlargedCard, 700, TimeUnit.MILLISECONDS);
}
private synchronized void cancelTimeout() {

View file

@ -79,302 +79,299 @@ public class CallbackClientImpl implements CallbackClient {
public synchronized void processCallback(final ClientCallback callback) {
SaveObjectUtil.saveObject(callback.getData(), callback.getMethod());
callback.setData(CompressUtil.decompress(callback.getData()));
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
try {
logger.debug(callback.getMessageId() + " -- " + callback.getMethod());
switch (callback.getMethod()) {
case "startGame": {
TableClientMessage message = (TableClientMessage) callback.getData();
GameManager.getInstance().setCurrentPlayerUUID(message.getPlayerId());
gameStarted(message.getGameId(), message.getPlayerId());
break;
SwingUtilities.invokeLater(() -> {
try {
logger.debug(callback.getMessageId() + " -- " + callback.getMethod());
switch (callback.getMethod()) {
case "startGame": {
TableClientMessage message = (TableClientMessage) callback.getData();
GameManager.getInstance().setCurrentPlayerUUID(message.getPlayerId());
gameStarted(message.getGameId(), message.getPlayerId());
break;
}
case "startTournament": {
TableClientMessage message = (TableClientMessage) callback.getData();
tournamentStarted(message.getGameId(), message.getPlayerId());
break;
}
case "startDraft": {
TableClientMessage message = (TableClientMessage) callback.getData();
draftStarted(message.getGameId(), message.getPlayerId());
break;
}
case "replayGame":
replayGame(callback.getObjectId());
break;
case "showTournament":
showTournament(callback.getObjectId());
break;
case "watchGame":
watchGame(callback.getObjectId());
break;
case "chatMessage": {
ChatMessage message = (ChatMessage) callback.getData();
ChatPanelBasic panel = MageFrame.getChat(callback.getObjectId());
if (panel != null) {
// play the sound related to the message
if (message.getSoundToPlay() != null) {
switch (message.getSoundToPlay()) {
case PlayerLeft:
AudioManager.playPlayerLeft();
break;
case PlayerQuitTournament:
AudioManager.playPlayerQuitTournament();
break;
case PlayerSubmittedDeck:
AudioManager.playPlayerSubmittedDeck();
break;
case PlayerWhispered:
AudioManager.playPlayerWhispered();
break;
}
}
// send start message to chat if not done yet
if (!panel.isStartMessageDone()) {
createChatStartMessage(panel);
}
// send the message to subchat if exists and it's not a game message
if (!message.getMessageType().equals(MessageType.GAME) && panel.getConnectedChat() != null) {
panel.getConnectedChat().receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getMessageType(), ChatMessage.MessageColor.BLACK);
} else {
panel.receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getMessageType(), message.getColor());
}
}
case "startTournament": {
TableClientMessage message = (TableClientMessage) callback.getData();
tournamentStarted(message.getGameId(), message.getPlayerId());
break;
}
case "startDraft": {
TableClientMessage message = (TableClientMessage) callback.getData();
draftStarted(message.getGameId(), message.getPlayerId());
break;
}
case "replayGame":
replayGame(callback.getObjectId());
break;
case "showTournament":
showTournament(callback.getObjectId());
break;
case "watchGame":
watchGame(callback.getObjectId());
break;
case "chatMessage": {
break;
}
case "serverMessage":
if (callback.getData() != null) {
ChatMessage message = (ChatMessage) callback.getData();
ChatPanelBasic panel = MageFrame.getChat(callback.getObjectId());
if (panel != null) {
// play the sound related to the message
if (message.getSoundToPlay() != null) {
switch (message.getSoundToPlay()) {
case PlayerLeft:
AudioManager.playPlayerLeft();
break;
case PlayerQuitTournament:
AudioManager.playPlayerQuitTournament();
break;
case PlayerSubmittedDeck:
AudioManager.playPlayerSubmittedDeck();
break;
case PlayerWhispered:
AudioManager.playPlayerWhispered();
break;
}
}
// send start message to chat if not done yet
if (!panel.isStartMessageDone()) {
createChatStartMessage(panel);
}
// send the message to subchat if exists and it's not a game message
if (!message.getMessageType().equals(MessageType.GAME) && panel.getConnectedChat() != null) {
panel.getConnectedChat().receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getMessageType(), ChatMessage.MessageColor.BLACK);
} else {
panel.receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getMessageType(), message.getColor());
}
if (message.getColor().equals(ChatMessage.MessageColor.RED)) {
JOptionPane.showMessageDialog(null, message.getMessage(), "Server message", JOptionPane.WARNING_MESSAGE);
} else {
JOptionPane.showMessageDialog(null, message.getMessage(), "Server message", JOptionPane.INFORMATION_MESSAGE);
}
}
break;
case "joinedTable": {
TableClientMessage message = (TableClientMessage) callback.getData();
joinedTable(message.getRoomId(), message.getTableId(), message.getFlag());
break;
}
case "replayInit": {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.init((GameView) callback.getData());
}
break;
}
case "replayDone": {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.endMessage((String) callback.getData(), callback.getMessageId());
}
break;
}
case "replayUpdate": {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.updateGame((GameView) callback.getData());
}
break;
}
case "gameInit": {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.init((GameView) callback.getData());
}
break;
}
case "gameOver": {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.endMessage((String) callback.getData(), callback.getMessageId());
}
break;
}
case "gameError":
frame.showErrorDialog("Game Error", (String) callback.getData());
break;
case "gameAsk": {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.ask(message.getMessage(), message.getGameView(), callback.getMessageId(), message.getOptions());
}
break;
}
case "gameTarget": // e.g. Pick triggered ability
{
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.pickTarget(message.getMessage(), message.getCardsView(), message.getGameView(),
message.getTargets(), message.isFlag(), message.getOptions(), callback.getMessageId());
}
break;
}
case "gameSelect": {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.select(message.getMessage(), message.getGameView(), callback.getMessageId(), message.getOptions());
}
break;
}
case "gameChooseAbility": {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.pickAbility((AbilityPickerView) callback.getData());
}
break;
}
case "gameChoosePile": {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.pickPile(message.getMessage(), message.getPile1(), message.getPile2());
}
break;
}
case "gameChooseChoice": {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
}
break;
if (panel != null) {
panel.getChoice(message.getChoice(), callback.getObjectId());
}
case "serverMessage":
if (callback.getData() != null) {
ChatMessage message = (ChatMessage) callback.getData();
if (message.getColor().equals(ChatMessage.MessageColor.RED)) {
JOptionPane.showMessageDialog(null, message.getMessage(), "Server message", JOptionPane.WARNING_MESSAGE);
} else {
JOptionPane.showMessageDialog(null, message.getMessage(), "Server message", JOptionPane.INFORMATION_MESSAGE);
break;
}
case "gamePlayMana": {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.playMana(message.getMessage(), message.getGameView(), message.getOptions(), callback.getMessageId());
}
break;
}
case "gamePlayXMana": {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.playXMana(message.getMessage(), message.getGameView(), callback.getMessageId());
}
break;
}
case "gameSelectAmount": {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.getAmount(message.getMin(), message.getMax(), message.getMessage());
}
break;
}
case "gameUpdate": {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.updateGame((GameView) callback.getData());
}
break;
}
case "endGameInfo":
MageFrame.getInstance().showGameEndDialog((GameEndView) callback.getData());
break;
case "showUserMessage":
List<String> messageData = (List<String>) callback.getData();
if (messageData.size() == 2) {
JOptionPane.showMessageDialog(null, messageData.get(1), messageData.get(0), JOptionPane.WARNING_MESSAGE);
}
break;
case "gameInform":
if (callback.getMessageId() > gameInformMessageId) {
{
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.inform(message.getMessage(), message.getGameView(), callback.getMessageId());
}
}
break;
case "joinedTable": {
TableClientMessage message = (TableClientMessage) callback.getData();
joinedTable(message.getRoomId(), message.getTableId(), message.getFlag());
break;
}
case "replayInit": {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.init((GameView) callback.getData());
}
break;
}
case "replayDone": {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.endMessage((String) callback.getData(), callback.getMessageId());
}
break;
}
case "replayUpdate": {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.updateGame((GameView) callback.getData());
}
break;
}
case "gameInit": {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.init((GameView) callback.getData());
}
break;
}
case "gameOver": {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.endMessage((String) callback.getData(), callback.getMessageId());
}
break;
}
case "gameError":
frame.showErrorDialog("Game Error", (String) callback.getData());
break;
case "gameAsk": {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.ask(message.getMessage(), message.getGameView(), callback.getMessageId(), message.getOptions());
}
break;
}
case "gameTarget": // e.g. Pick triggered ability
{
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.pickTarget(message.getMessage(), message.getCardsView(), message.getGameView(),
message.getTargets(), message.isFlag(), message.getOptions(), callback.getMessageId());
}
break;
}
case "gameSelect": {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.select(message.getMessage(), message.getGameView(), callback.getMessageId(), message.getOptions());
}
break;
}
case "gameChooseAbility": {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.pickAbility((AbilityPickerView) callback.getData());
}
break;
}
case "gameChoosePile": {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.pickPile(message.getMessage(), message.getPile1(), message.getPile2());
}
break;
}
case "gameChooseChoice": {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.getChoice(message.getChoice(), callback.getObjectId());
}
break;
}
case "gamePlayMana": {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.playMana(message.getMessage(), message.getGameView(), message.getOptions(), callback.getMessageId());
}
break;
}
case "gamePlayXMana": {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.playXMana(message.getMessage(), message.getGameView(), callback.getMessageId());
}
break;
}
case "gameSelectAmount": {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.getAmount(message.getMin(), message.getMax(), message.getMessage());
}
break;
}
case "gameUpdate": {
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.updateGame((GameView) callback.getData());
}
break;
}
case "endGameInfo":
MageFrame.getInstance().showGameEndDialog((GameEndView) callback.getData());
break;
case "showUserMessage":
List<String> messageData = (List<String>) callback.getData();
if (messageData.size() == 2) {
JOptionPane.showMessageDialog(null, messageData.get(1), messageData.get(0), JOptionPane.WARNING_MESSAGE);
}
break;
case "gameInform":
if (callback.getMessageId() > gameInformMessageId) {
{
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
panel.inform(message.getMessage(), message.getGameView(), callback.getMessageId());
}
}
// no longer needed because phase skip handling on server side now
} else {
logger.warn(new StringBuilder("message out of sequence - ignoring").append("MessageId = ").append(callback.getMessageId()).append(" method = ").append(callback.getMethod()));
//logger.warn("message out of sequence - ignoring");
}
gameInformMessageId = messageId;
break;
case "gameInformPersonal": {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
JOptionPane.showMessageDialog(panel, message.getMessage(), "Game message",
JOptionPane.INFORMATION_MESSAGE);
}
break;
} else {
logger.warn(new StringBuilder("message out of sequence - ignoring").append("MessageId = ").append(callback.getMessageId()).append(" method = ").append(callback.getMethod()));
//logger.warn("message out of sequence - ignoring");
}
case "sideboard": {
TableClientMessage message = (TableClientMessage) callback.getData();
DeckView deckView = message.getDeck();
Deck deck = DeckUtil.construct(deckView);
if (message.getFlag()) {
construct(deck, message.getTableId(), message.getTime());
} else {
sideboard(deck, message.getTableId(), message.getTime());
}
break;
gameInformMessageId = messageId;
break;
case "gameInformPersonal": {
GameClientMessage message = (GameClientMessage) callback.getData();
GamePanel panel = MageFrame.getGame(callback.getObjectId());
if (panel != null) {
JOptionPane.showMessageDialog(panel, message.getMessage(), "Game message",
JOptionPane.INFORMATION_MESSAGE);
}
case "construct": {
TableClientMessage message = (TableClientMessage) callback.getData();
DeckView deckView = message.getDeck();
Deck deck = DeckUtil.construct(deckView);
break;
}
case "sideboard": {
TableClientMessage message = (TableClientMessage) callback.getData();
DeckView deckView = message.getDeck();
Deck deck = DeckUtil.construct(deckView);
if (message.getFlag()) {
construct(deck, message.getTableId(), message.getTime());
break;
} else {
sideboard(deck, message.getTableId(), message.getTime());
}
case "draftOver":
MageFrame.removeDraft(callback.getObjectId());
break;
case "draftPick": {
DraftClientMessage message = (DraftClientMessage) callback.getData();
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
if (panel != null) {
panel.loadBooster(message.getDraftPickView());
}
break;
break;
}
case "construct": {
TableClientMessage message = (TableClientMessage) callback.getData();
DeckView deckView = message.getDeck();
Deck deck = DeckUtil.construct(deckView);
construct(deck, message.getTableId(), message.getTime());
break;
}
case "draftOver":
MageFrame.removeDraft(callback.getObjectId());
break;
case "draftPick": {
DraftClientMessage message = (DraftClientMessage) callback.getData();
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
if (panel != null) {
panel.loadBooster(message.getDraftPickView());
}
case "draftUpdate": {
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
if (panel != null) {
panel.updateDraft((DraftView) callback.getData());
}
break;
}
case "draftInform": // if (callback.getMessageId() > messageId) {
{
DraftClientMessage message = (DraftClientMessage) callback.getData();
break;
}
case "draftUpdate": {
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
if (panel != null) {
panel.updateDraft((DraftView) callback.getData());
}
break;
}
case "draftInform": // if (callback.getMessageId() > messageId) {
{
DraftClientMessage message = (DraftClientMessage) callback.getData();
}
// } else {
// logger.warn("message out of sequence - ignoring");
// }
break;
case "draftInit": {
DraftClientMessage message = (DraftClientMessage) callback.getData();
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
if (panel != null) {
panel.loadBooster(message.getDraftPickView());
}
break;
break;
case "draftInit": {
DraftClientMessage message = (DraftClientMessage) callback.getData();
DraftPanel panel = MageFrame.getDraft(callback.getObjectId());
if (panel != null) {
panel.loadBooster(message.getDraftPickView());
}
case "tournamentInit":
break;
case "userRequestDialog":
frame.showUserRequestDialog((UserRequestMessage) callback.getData());
break;
break;
}
messageId = callback.getMessageId();
} catch (Exception ex) {
handleException(ex);
case "tournamentInit":
break;
case "userRequestDialog":
frame.showUserRequestDialog((UserRequestMessage) callback.getData());
break;
}
messageId = callback.getMessageId();
} catch (Exception ex) {
handleException(ex);
}
});
}
@ -391,28 +388,28 @@ public class CallbackClientImpl implements CallbackClient {
.append("<br/>Turn mousewheel up (ALT-e) - enlarge image of card the mousepointer hovers over")
.append("<br/>Turn mousewheel down (ALT-s) - enlarge original/alternate image of card the mousepointer hovers over")
.append("<br/><b>")
.append(KeyEvent.getKeyText((Integer) PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_CONFIRM, 113)))
.append(KeyEvent.getKeyText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_CONFIRM, 113)))
.append("</b> - Confirm \"Ok\", \"Yes\" or \"Done\" button")
.append("<br/><b>")
.append(KeyEvent.getKeyText((Integer) PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_NEXT_TURN, 115)))
.append(KeyEvent.getKeyText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_NEXT_TURN, 115)))
.append("</b> - Skip current turn but stop on declare attackers/blockers and something on the stack")
.append("<br/><b>")
.append(KeyEvent.getKeyText((Integer) PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_END_STEP, 116)))
.append(KeyEvent.getKeyText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_END_STEP, 116)))
.append("</b> - Skip to next end step but stop on declare attackers/blockers and something on the stack")
.append("<br/><b>")
.append(KeyEvent.getKeyText((Integer) PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_SKIP_STEP, 117)))
.append(KeyEvent.getKeyText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_SKIP_STEP, 117)))
.append("</b> - Skip current turn but stop on declare attackers/blockers")
.append("<br/><b>")
.append(KeyEvent.getKeyText((Integer) PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_MAIN_STEP, 118)))
.append(KeyEvent.getKeyText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_MAIN_STEP, 118)))
.append("</b> - Skip to next main phase but stop on declare attackers/blockers and something on the stack")
.append("<br/><b>")
.append(KeyEvent.getKeyText((Integer) PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_YOUR_TURN, 120)))
.append(KeyEvent.getKeyText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_YOUR_TURN, 120)))
.append("</b> - Skip everything until your next turn")
.append("<br/><b>")
.append(KeyEvent.getKeyText((Integer) PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_PRIOR_END, 122)))
.append(KeyEvent.getKeyText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_PRIOR_END, 122)))
.append("</b> - Skip everything until the end step just prior to your turn")
.append("<br/><b>")
.append(KeyEvent.getKeyText((Integer) PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_CANCEL_SKIP, 114)))
.append(KeyEvent.getKeyText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CONTROL_CANCEL_SKIP, 114)))
.append("</b> - Undo F4/F5/F7/F9/F11")
.append("<br/><b>").append(System.getProperty("os.name").contains("Mac OS X") ? "Cmd" : "Ctrl").append(" + click</b> - Hold priority while casting a spell or activating an ability").toString(),
null, MessageType.USER_INFO, ChatMessage.MessageColor.BLUE);

View file

@ -153,18 +153,10 @@ public class NewPlayerPanel extends javax.swing.JPanel {
lblPlayerDeck.setText("Deck:");
btnPlayerDeck.setText("...");
btnPlayerDeck.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnPlayerDeckActionPerformed(evt);
}
});
btnPlayerDeck.addActionListener(evt -> btnPlayerDeckActionPerformed(evt));
btnGenerate.setText("Generate");
btnGenerate.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnGenerateActionPerformed(evt);
}
});
btnGenerate.addActionListener(evt -> btnGenerateActionPerformed(evt));
lblLevel.setText("Skill:");

View file

@ -394,7 +394,7 @@ public class PlayersChatPanel extends javax.swing.JPanel {
class ColumnHeaderToolTips extends MouseMotionAdapter {
int curCol;
Map<Integer, String> tips = new HashMap<>();
final Map<Integer, String> tips = new HashMap<>();
public void setToolTip(Integer mCol, String tooltip) {
if (tooltip == null) {

View file

@ -34,17 +34,14 @@
package mage.client.table;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.UUID;
import javax.swing.DefaultComboBoxModel;
import mage.cards.decks.importer.DeckImporterUtil;
import mage.client.MageFrame;
import mage.client.SessionHandler;
import mage.client.util.Config;
import mage.client.util.Event;
import mage.client.util.Listener;
import mage.remote.Session;
/**
*
@ -52,7 +49,7 @@ import mage.remote.Session;
*/
public class TablePlayerPanel extends javax.swing.JPanel {
protected PlayerTypeEventSource playerTypeEventSource = new PlayerTypeEventSource();
protected final PlayerTypeEventSource playerTypeEventSource = new PlayerTypeEventSource();
/** Creates new form TablePlayerPanel */
@ -78,7 +75,7 @@ public class TablePlayerPanel extends javax.swing.JPanel {
}
}
public boolean joinTable(UUID roomId, UUID tableId) throws FileNotFoundException, IOException, ClassNotFoundException {
public boolean joinTable(UUID roomId, UUID tableId) throws IOException, ClassNotFoundException {
if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
return SessionHandler.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), (String)this.cbPlayerType.getSelectedItem(), this.newPlayerPanel.getLevel(), DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()),"");
}
@ -114,11 +111,7 @@ public class TablePlayerPanel extends javax.swing.JPanel {
lbPlayerType.setText("Type:");
cbPlayerType.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbPlayerTypeActionPerformed(evt);
}
});
cbPlayerType.addActionListener(evt -> cbPlayerTypeActionPerformed(evt));
lblPlayerNum.setFont(new java.awt.Font("Tahoma", 1, 11));
lblPlayerNum.setText("Player #");

View file

@ -29,7 +29,7 @@ package mage.client.table;
import java.util.UUID;
import javax.swing.JComponent;
import mage.client.MageFrame;
import mage.client.MagePane;
import mage.client.SessionHandler;
import mage.client.plugins.impl.Plugins;

View file

@ -82,6 +82,7 @@ import mage.client.dialog.PreferencesDialog;
import static mage.client.dialog.PreferencesDialog.KEY_TABLES_COLUMNS_ORDER;
import static mage.client.dialog.PreferencesDialog.KEY_TABLES_COLUMNS_WIDTH;
import mage.client.dialog.TableWaitingDialog;
import static mage.client.table.TablesPanel.PASSWORDED;
import mage.client.util.ButtonColumn;
import mage.client.util.GUISizeHelper;
import mage.client.util.MageTableRowSorter;
@ -109,8 +110,9 @@ public class TablesPanel extends javax.swing.JPanel {
private static final Logger LOGGER = Logger.getLogger(TablesPanel.class);
private static final int[] DEFAULT_COLUMNS_WIDTH = {35, 150, 120, 180, 80, 120, 80, 60, 40, 40, 60};
private TableTableModel tableModel;
private MatchesTableModel matchesModel;
public static final String PASSWORDED = "***";
private final TableTableModel tableModel;
private final MatchesTableModel matchesModel;
private UUID roomId;
private UpdateTablesTask updateTablesTask;
private UpdatePlayersTask updatePlayersTask;
@ -118,15 +120,15 @@ public class TablesPanel extends javax.swing.JPanel {
private JoinTableDialog joinTableDialog;
private NewTableDialog newTableDialog;
private NewTournamentDialog newTournamentDialog;
private GameChooser gameChooser;
private final GameChooser gameChooser;
private List<String> messages;
private int currentMessage;
private MageTableRowSorter activeTablesSorter;
private final MageTableRowSorter activeTablesSorter;
private final ButtonColumn actionButton1;
private final ButtonColumn actionButton2;
JToggleButton[] filterButtons;
final JToggleButton[] filterButtons;
/**
* Creates new form TablesPanel
@ -138,7 +140,7 @@ public class TablesPanel extends javax.swing.JPanel {
gameChooser = new GameChooser();
initComponents();
// tableModel.setSession(session);
// tableModel.setSession(session);
tableTables.createDefaultColumnsFromModel();
@ -180,9 +182,9 @@ public class TablesPanel extends javax.swing.JPanel {
UUID gameId = (UUID) tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN + 2);
String action = (String) tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN);
String deckType = (String) tableModel.getValueAt(modelRow, TableTableModel.COLUMN_DECK_TYPE);
String status = (String) tableModel.getValueAt(modelRow, TableTableModel.COLUMN_STATUS);
boolean isTournament = (Boolean) tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN + 1);
String owner = (String) tableModel.getValueAt(modelRow, TableTableModel.COLUMN_OWNER);
String pwdColumn = (String) tableModel.getValueAt(modelRow, TableTableModel.COLUMN_PASSWORD);
switch (action) {
case "Join":
if (owner.equals(SessionHandler.getUserName()) || owner.startsWith(SessionHandler.getUserName() + ",")) {
@ -209,10 +211,10 @@ public class TablesPanel extends javax.swing.JPanel {
if (isTournament) {
LOGGER.info("Joining tournament " + tableId);
if (deckType.startsWith("Limited")) {
if (!status.endsWith("PW")) {
SessionHandler.joinTournamentTable(roomId, tableId, SessionHandler.getUserName(), "Human", 1, null, "");
} else {
if (PASSWORDED.equals(pwdColumn)) {
joinTableDialog.showDialog(roomId, tableId, true, deckType.startsWith("Limited"));
} else {
SessionHandler.joinTournamentTable(roomId, tableId, SessionHandler.getUserName(), "Human", 1, null, "");
}
} else {
joinTableDialog.showDialog(roomId, tableId, true, deckType.startsWith("Limited"));
@ -266,7 +268,7 @@ public class TablesPanel extends javax.swing.JPanel {
}
// MageFrame.getDesktop().showTournament(tournamentId);
break;
case "Show":;
case "Show":
if (matchesModel.isTournament(modelRow)) {
LOGGER.info("Showing tournament table " + matchesModel.getTableId(modelRow));
SessionHandler.watchTable(roomId, matchesModel.getTableId(modelRow));
@ -505,12 +507,7 @@ public class TablesPanel extends javax.swing.JPanel {
MageFrame.getUI().addButton(MageComponents.NEW_GAME_BUTTON, btnNewTable);
// divider locations have to be set with delay else values set are overwritten with system defaults
Executors.newSingleThreadScheduledExecutor().schedule(new Runnable() {
@Override
public void run() {
restoreDividerLocations();
}
}, 300, TimeUnit.MILLISECONDS);
Executors.newSingleThreadScheduledExecutor().schedule(() -> restoreDividerLocations(), 300, TimeUnit.MILLISECONDS);
}
@ -617,10 +614,10 @@ public class TablesPanel extends javax.swing.JPanel {
}
List<RowFilter<Object, Object>> ratingFilterList = new ArrayList<>();
if (btnRated.isSelected()){
if (btnRated.isSelected()) {
ratingFilterList.add(RowFilter.regexFilter("^Rated", TableTableModel.COLUMN_RATING));
}
if (btnUnrated.isSelected()){
if (btnUnrated.isSelected()) {
ratingFilterList.add(RowFilter.regexFilter("^Unrated", TableTableModel.COLUMN_RATING));
}
@ -670,7 +667,7 @@ public class TablesPanel extends javax.swing.JPanel {
filterList.addAll(ratingFilterList);
}
if (passwordFilterList.size() > 1) {
if (passwordFilterList.size() > 1) {
filterList.add(RowFilter.orFilter(passwordFilterList));
} else if (passwordFilterList.size() == 1) {
filterList.addAll(passwordFilterList);
@ -749,20 +746,12 @@ public class TablesPanel extends javax.swing.JPanel {
btnNewTable.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/match_new.png"))); // NOI18N
btnNewTable.setToolTipText("Creates a new match table.");
btnNewTable.setMargin(new java.awt.Insets(2, 2, 2, 2));
btnNewTable.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNewTableActionPerformed(evt);
}
});
btnNewTable.addActionListener(evt -> btnNewTableActionPerformed(evt));
btnNewTournament.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/tourney_new.png"))); // NOI18N
btnNewTournament.setToolTipText("Creates a new tourney table.");
btnNewTournament.setMargin(new java.awt.Insets(2, 2, 2, 2));
btnNewTournament.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNewTournamentActionPerformed(evt);
}
});
btnNewTournament.addActionListener(evt -> btnNewTournamentActionPerformed(evt));
filterBar1.setFloatable(false);
filterBar1.setForeground(new java.awt.Color(102, 102, 255));
@ -778,11 +767,7 @@ public class TablesPanel extends javax.swing.JPanel {
btnStateWaiting.setRequestFocusEnabled(false);
btnStateWaiting.setVerifyInputWhenFocusTarget(false);
btnStateWaiting.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnStateWaiting.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFilterActionPerformed(evt);
}
});
btnStateWaiting.addActionListener(evt -> btnFilterActionPerformed(evt));
filterBar1.add(btnStateWaiting);
btnStateActive.setSelected(true);
@ -794,11 +779,7 @@ public class TablesPanel extends javax.swing.JPanel {
btnStateActive.setRequestFocusEnabled(false);
btnStateActive.setVerifyInputWhenFocusTarget(false);
btnStateActive.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnStateActive.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFilterActionPerformed(evt);
}
});
btnStateActive.addActionListener(evt -> btnFilterActionPerformed(evt));
filterBar1.add(btnStateActive);
btnStateFinished.setSelected(true);
@ -810,11 +791,7 @@ public class TablesPanel extends javax.swing.JPanel {
btnStateFinished.setRequestFocusEnabled(false);
btnStateFinished.setVerifyInputWhenFocusTarget(false);
btnStateFinished.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnStateFinished.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnStateFinishedActionPerformed(evt);
}
});
btnStateFinished.addActionListener(evt -> btnStateFinishedActionPerformed(evt));
filterBar1.add(btnStateFinished);
filterBar1.add(jSeparator1);
@ -828,11 +805,7 @@ public class TablesPanel extends javax.swing.JPanel {
btnTypeMatch.setRequestFocusEnabled(false);
btnTypeMatch.setVerifyInputWhenFocusTarget(false);
btnTypeMatch.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnTypeMatch.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFilterActionPerformed(evt);
}
});
btnTypeMatch.addActionListener(evt -> btnFilterActionPerformed(evt));
filterBar1.add(btnTypeMatch);
btnTypeTourneyConstructed.setSelected(true);
@ -843,11 +816,7 @@ public class TablesPanel extends javax.swing.JPanel {
btnTypeTourneyConstructed.setFocusable(false);
btnTypeTourneyConstructed.setRequestFocusEnabled(false);
btnTypeTourneyConstructed.setVerifyInputWhenFocusTarget(false);
btnTypeTourneyConstructed.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFilterActionPerformed(evt);
}
});
btnTypeTourneyConstructed.addActionListener(evt -> btnFilterActionPerformed(evt));
filterBar1.add(btnTypeTourneyConstructed);
btnTypeTourneyLimited.setSelected(true);
@ -859,11 +828,7 @@ public class TablesPanel extends javax.swing.JPanel {
btnTypeTourneyLimited.setMaximumSize(new java.awt.Dimension(72, 20));
btnTypeTourneyLimited.setRequestFocusEnabled(false);
btnTypeTourneyLimited.setVerifyInputWhenFocusTarget(false);
btnTypeTourneyLimited.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFilterActionPerformed(evt);
}
});
btnTypeTourneyLimited.addActionListener(evt -> btnFilterActionPerformed(evt));
filterBar1.add(btnTypeTourneyLimited);
filterBar1.add(jSeparator4);
@ -877,11 +842,7 @@ public class TablesPanel extends javax.swing.JPanel {
btnSkillBeginner.setRequestFocusEnabled(false);
btnSkillBeginner.setVerifyInputWhenFocusTarget(false);
btnSkillBeginner.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnSkillBeginner.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFilterActionPerformed(evt);
}
});
btnSkillBeginner.addActionListener(evt -> btnFilterActionPerformed(evt));
filterBar1.add(btnSkillBeginner);
btnSkillCasual.setSelected(true);
@ -894,11 +855,7 @@ public class TablesPanel extends javax.swing.JPanel {
btnSkillCasual.setRequestFocusEnabled(false);
btnSkillCasual.setVerifyInputWhenFocusTarget(false);
btnSkillCasual.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnSkillCasual.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFilterActionPerformed(evt);
}
});
btnSkillCasual.addActionListener(evt -> btnFilterActionPerformed(evt));
filterBar1.add(btnSkillCasual);
btnSkillSerious.setSelected(true);
@ -911,11 +868,7 @@ public class TablesPanel extends javax.swing.JPanel {
btnSkillSerious.setRequestFocusEnabled(false);
btnSkillSerious.setVerifyInputWhenFocusTarget(false);
btnSkillSerious.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnSkillSerious.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFilterActionPerformed(evt);
}
});
btnSkillSerious.addActionListener(evt -> btnFilterActionPerformed(evt));
filterBar1.add(btnSkillSerious);
filterBar1.add(jSeparator4);
@ -929,11 +882,7 @@ public class TablesPanel extends javax.swing.JPanel {
btnRated.setRequestFocusEnabled(false);
btnRated.setVerifyInputWhenFocusTarget(false);
btnRated.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnRated.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFilterActionPerformed(evt);
}
});
btnRated.addActionListener(evt -> btnFilterActionPerformed(evt));
filterBar1.add(btnRated);
btnUnrated.setSelected(true);
@ -945,11 +894,7 @@ public class TablesPanel extends javax.swing.JPanel {
btnUnrated.setRequestFocusEnabled(false);
btnUnrated.setVerifyInputWhenFocusTarget(false);
btnUnrated.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnUnrated.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFilterActionPerformed(evt);
}
});
btnUnrated.addActionListener(evt -> btnFilterActionPerformed(evt));
filterBar1.add(btnUnrated);
// second filter line
@ -966,11 +911,7 @@ public class TablesPanel extends javax.swing.JPanel {
btnFormatBlock.setRequestFocusEnabled(false);
btnFormatBlock.setVerifyInputWhenFocusTarget(false);
btnFormatBlock.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnFormatBlock.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFilterActionPerformed(evt);
}
});
btnFormatBlock.addActionListener(evt -> btnFilterActionPerformed(evt));
filterBar2.add(btnFormatBlock);
btnFormatStandard.setSelected(true);
@ -982,11 +923,7 @@ public class TablesPanel extends javax.swing.JPanel {
btnFormatStandard.setRequestFocusEnabled(false);
btnFormatStandard.setVerifyInputWhenFocusTarget(false);
btnFormatStandard.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnFormatStandard.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFilterActionPerformed(evt);
}
});
btnFormatStandard.addActionListener(evt -> btnFilterActionPerformed(evt));
filterBar2.add(btnFormatStandard);
btnFormatModern.setSelected(true);
@ -996,11 +933,7 @@ public class TablesPanel extends javax.swing.JPanel {
btnFormatModern.setFocusable(false);
btnFormatModern.setRequestFocusEnabled(false);
btnFormatModern.setVerifyInputWhenFocusTarget(false);
btnFormatModern.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFilterActionPerformed(evt);
}
});
btnFormatModern.addActionListener(evt -> btnFilterActionPerformed(evt));
filterBar2.add(btnFormatModern);
btnFormatLegacy.setSelected(true);
@ -1012,11 +945,7 @@ public class TablesPanel extends javax.swing.JPanel {
btnFormatLegacy.setRequestFocusEnabled(false);
btnFormatLegacy.setVerifyInputWhenFocusTarget(false);
btnFormatLegacy.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnFormatLegacy.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFilterActionPerformed(evt);
}
});
btnFormatLegacy.addActionListener(evt -> btnFilterActionPerformed(evt));
filterBar2.add(btnFormatLegacy);
btnFormatVintage.setSelected(true);
@ -1028,11 +957,7 @@ public class TablesPanel extends javax.swing.JPanel {
btnFormatVintage.setRequestFocusEnabled(false);
btnFormatVintage.setVerifyInputWhenFocusTarget(false);
btnFormatVintage.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnFormatVintage.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFilterActionPerformed(evt);
}
});
btnFormatVintage.addActionListener(evt -> btnFilterActionPerformed(evt));
filterBar2.add(btnFormatVintage);
filterBar2.add(jSeparator3);
@ -1045,11 +970,7 @@ public class TablesPanel extends javax.swing.JPanel {
btnFormatCommander.setRequestFocusEnabled(false);
btnFormatCommander.setVerifyInputWhenFocusTarget(false);
btnFormatCommander.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnFormatCommander.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFilterActionPerformed(evt);
}
});
btnFormatCommander.addActionListener(evt -> btnFilterActionPerformed(evt));
filterBar2.add(btnFormatCommander);
btnFormatTinyLeader.setSelected(true);
@ -1059,11 +980,7 @@ public class TablesPanel extends javax.swing.JPanel {
btnFormatTinyLeader.setFocusable(false);
btnFormatTinyLeader.setRequestFocusEnabled(false);
btnFormatTinyLeader.setVerifyInputWhenFocusTarget(false);
btnFormatTinyLeader.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFilterActionPerformed(evt);
}
});
btnFormatTinyLeader.addActionListener(evt -> btnFilterActionPerformed(evt));
filterBar2.add(btnFormatTinyLeader);
filterBar2.add(jSeparator2);
@ -1076,11 +993,7 @@ public class TablesPanel extends javax.swing.JPanel {
btnFormatLimited.setRequestFocusEnabled(false);
btnFormatLimited.setVerifyInputWhenFocusTarget(false);
btnFormatLimited.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnFormatLimited.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFilterActionPerformed(evt);
}
});
btnFormatLimited.addActionListener(evt -> btnFilterActionPerformed(evt));
filterBar2.add(btnFormatLimited);
btnFormatOther.setSelected(true);
@ -1090,11 +1003,7 @@ public class TablesPanel extends javax.swing.JPanel {
btnFormatOther.setFocusable(false);
btnFormatOther.setRequestFocusEnabled(false);
btnFormatOther.setVerifyInputWhenFocusTarget(false);
btnFormatOther.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFilterActionPerformed(evt);
}
});
btnFormatOther.addActionListener(evt -> btnFilterActionPerformed(evt));
filterBar2.add(btnFormatOther);
filterBar2.add(jSeparator5);
@ -1107,11 +1016,7 @@ public class TablesPanel extends javax.swing.JPanel {
btnOpen.setRequestFocusEnabled(false);
btnOpen.setVerifyInputWhenFocusTarget(false);
btnOpen.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnOpen.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFilterActionPerformed(evt);
}
});
btnOpen.addActionListener(evt -> btnFilterActionPerformed(evt));
filterBar2.add(btnOpen);
btnPassword.setSelected(true);
@ -1123,22 +1028,14 @@ public class TablesPanel extends javax.swing.JPanel {
btnPassword.setRequestFocusEnabled(false);
btnPassword.setVerifyInputWhenFocusTarget(false);
btnPassword.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnPassword.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFilterActionPerformed(evt);
}
});
btnPassword.addActionListener(evt -> btnFilterActionPerformed(evt));
filterBar2.add(btnPassword);
btnQuickStart.setText("Quick Start");
btnQuickStart.setFocusable(false);
btnQuickStart.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnQuickStart.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnQuickStart.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnQuickStartActionPerformed(evt);
}
});
btnQuickStart.addActionListener(evt -> btnQuickStartActionPerformed(evt));
javax.swing.GroupLayout jPanelTopLayout = new javax.swing.GroupLayout(jPanelTop);
jPanelTop.setLayout(jPanelTopLayout);
@ -1235,11 +1132,7 @@ public class TablesPanel extends javax.swing.JPanel {
jButtonFooterNext.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
jButtonFooterNext.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jButtonFooterNext.setOpaque(false);
jButtonFooterNext.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonFooterNextActionPerformed(evt);
}
});
jButtonFooterNext.addActionListener(evt -> jButtonFooterNextActionPerformed(evt));
jPanelBottom.add(jButtonFooterNext);
jLabelFooterLabel.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
@ -1380,8 +1273,8 @@ public class TablesPanel extends javax.swing.JPanel {
class TableTableModel extends AbstractTableModel {
ImageIcon tourneyIcon = new javax.swing.ImageIcon(getClass().getResource("/tables/tourney_icon.png"));
ImageIcon matchIcon = new javax.swing.ImageIcon(getClass().getResource("/tables/match_icon.png"));
final ImageIcon tourneyIcon = new javax.swing.ImageIcon(getClass().getResource("/tables/tourney_icon.png"));
final ImageIcon matchIcon = new javax.swing.ImageIcon(getClass().getResource("/tables/match_icon.png"));
public static final int COLUMN_ICON = 0;
public static final int COLUMN_DECK_TYPE = 1; // column the deck type is located (starting with 0) Start string is used to check for Limited
@ -1400,8 +1293,6 @@ class TableTableModel extends AbstractTableModel {
private TableView[] tables = new TableView[0];
private static final DateFormat timeFormatter = new SimpleDateFormat("HH:mm:ss");
;
public void loadData(Collection<TableView> tables) throws MageRemoteException {
this.tables = tables.toArray(new TableView[0]);
@ -1418,7 +1309,6 @@ class TableTableModel extends AbstractTableModel {
return columnNames.length;
}
@Override
public Object getValueAt(int arg0, int arg1) {
switch (arg1) {
@ -1435,7 +1325,7 @@ class TableTableModel extends AbstractTableModel {
case 5:
return tables[arg0].getTableStateText();
case 6:
return tables[arg0].isPassworded() ? "***" : "";
return tables[arg0].isPassworded() ? PASSWORDED : "";
case 7:
return timeFormatter.format(tables[arg0].getCreateTime());
case 8:
@ -1570,7 +1460,7 @@ class UpdatePlayersTask extends SwingWorker<Void, Collection<RoomUsersView>> {
private static final Logger logger = Logger.getLogger(UpdatePlayersTask.class);
UpdatePlayersTask( UUID roomId, PlayersChatPanel chat) {
UpdatePlayersTask(UUID roomId, PlayersChatPanel chat) {
this.roomId = roomId;
this.chat = chat;
@ -1746,7 +1636,6 @@ class UpdateMatchesTask extends SwingWorker<Void, Collection<MatchView>> {
class GameChooser extends JPopupMenu {
public void init() {
}

View file

@ -38,9 +38,7 @@ import java.util.UUID;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import mage.cards.decks.DeckCardLists;
import mage.client.MageFrame;
import mage.client.SessionHandler;
import mage.remote.Session;
/**
*
@ -101,11 +99,7 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
jLabel1.setText("Type:");
cbPlayerType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbPlayerType.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbPlayerTypeActionPerformed(evt);
}
});
cbPlayerType.addActionListener(evt -> cbPlayerTypeActionPerformed(evt));
lblPlayerNum.setFont(new java.awt.Font("Tahoma", 1, 11));
lblPlayerNum.setText("Player Num:");

View file

@ -84,7 +84,7 @@ public class TournamentPanel extends javax.swing.JPanel {
private boolean firstInitDone = false;
private final TournamentPlayersTableModel playersModel;
private TournamentMatchesTableModel matchesModel;
private final TournamentMatchesTableModel matchesModel;
private UpdateTournamentTask updateTask;
private final DateFormat df;
@ -358,11 +358,7 @@ public class TournamentPanel extends javax.swing.JPanel {
txtName.setMaximumSize(new java.awt.Dimension(50, 22));
txtName.setOpaque(false);
txtName.setRequestFocusEnabled(false);
txtName.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtNameActionPerformed(evt);
}
});
txtName.addActionListener(evt -> txtNameActionPerformed(evt));
txtType.setEditable(false);
txtType.setHorizontalAlignment(javax.swing.JTextField.LEFT);
@ -394,19 +390,11 @@ public class TournamentPanel extends javax.swing.JPanel {
btnQuitTournament.setText("Quit Tournament");
btnQuitTournament.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnQuitTournament.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnQuitTournamentActionPerformed(evt);
}
});
btnQuitTournament.addActionListener(evt -> btnQuitTournamentActionPerformed(evt));
btnCloseWindow.setText("Close Window");
btnCloseWindow.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnCloseWindow.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCloseWindowActionPerformed(evt);
}
});
btnCloseWindow.addActionListener(evt -> btnCloseWindowActionPerformed(evt));
lblName.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
lblName.setText("Name:");

View file

@ -9,7 +9,7 @@ import java.util.Map;
public class DelayedViewerThread extends Thread {
private static DelayedViewerThread fInstance = new DelayedViewerThread();
private static final DelayedViewerThread fInstance = new DelayedViewerThread();
public static DelayedViewerThread getInstance() {
return fInstance;

View file

@ -36,11 +36,10 @@ package mage.client.unusedFiles;
import java.awt.Color;
import java.util.UUID;
import mage.client.MageFrame;
import mage.client.SessionHandler;
import mage.client.cards.BigCard;
import mage.client.dialog.ShowCardsDialog;
import mage.remote.Session;
import mage.view.PlayerView;
/**
@ -108,11 +107,7 @@ public class PlayerPanel extends javax.swing.JPanel {
btnPlayerName.setText("Player Name"); // NOI18N
btnPlayerName.setName("btnPlayerName"); // NOI18N
btnPlayerName.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnPlayerNameActionPerformed(evt);
}
});
btnPlayerName.addActionListener(evt -> btnPlayerNameActionPerformed(evt));
lblLife.setLabelFor(txtLife);
lblLife.setText("Life:"); // NOI18N
@ -140,11 +135,7 @@ public class PlayerPanel extends javax.swing.JPanel {
lblGrave.setName("lblGrave"); // NOI18N
btnGrave.setName("btnGrave"); // NOI18N
btnGrave.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnGraveActionPerformed(evt);
}
});
btnGrave.addActionListener(evt -> btnGraveActionPerformed(evt));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);

View file

@ -4,7 +4,6 @@ import java.awt.event.MouseEvent;
import java.util.UUID;
import mage.client.SessionHandler;
import mage.remote.Session;
import mage.view.CardView;

View file

@ -8,7 +8,7 @@ import java.util.UUID;
* @author nantuko
*/
public class GameManager {
private static GameManager fInstance = new GameManager();
private static final GameManager fInstance = new GameManager();
public static GameManager getInstance() {
return fInstance;

View file

@ -49,8 +49,8 @@ import org.mage.card.arcane.UI;
*/
public class ImageHelper {
protected static HashMap<String, BufferedImage> images = new HashMap<>();
protected static HashMap<String, BufferedImage> backgrounds = new HashMap<>();
protected static final HashMap<String, BufferedImage> images = new HashMap<>();
protected static final HashMap<String, BufferedImage> backgrounds = new HashMap<>();
public static BufferedImage loadImage(String ref, int width, int height) {
BufferedImage image = loadImage(ref);

View file

@ -181,7 +181,7 @@ public class NaturalOrderComparator implements Comparator
System.out.println("Scrambled: " + scrambled);
Collections.sort(scrambled, new NaturalOrderComparator());
scrambled.sort(new NaturalOrderComparator());
System.out.println("Sorted: " + scrambled);
}

View file

@ -10,7 +10,7 @@ import org.mage.card.arcane.CardPanel;
* @author nantuko
*/
public class SettingsManager {
private static SettingsManager fInstance = new SettingsManager();
private static final SettingsManager fInstance = new SettingsManager();
public static SettingsManager getInstance() {
return fInstance;
@ -68,5 +68,5 @@ public class SettingsManager {
private int screenWidth;
private int screenHeight;
private Rectangle cardSize = CardPanel.CARD_SIZE_FULL;
private final Rectangle cardSize = CardPanel.CARD_SIZE_FULL;
}

View file

@ -68,27 +68,19 @@ public class TransformedImageCache {
}
}
static Map<Key, Map<BufferedImage, BufferedImage>> IMAGE_CACHE;
static final Map<Key, Map<BufferedImage, BufferedImage>> IMAGE_CACHE;
static {
// TODO: can we use a single map?
IMAGE_CACHE = ImageCaches.register(new MapMaker().softValues().makeComputingMap(new Function<Key, Map<BufferedImage, BufferedImage>>() {
@Override
public Map<BufferedImage, BufferedImage> apply(final Key key) {
return new MapMaker().weakKeys().softValues().makeComputingMap(new Function<BufferedImage, BufferedImage>() {
@Override
public BufferedImage apply(BufferedImage image) {
if (key.width != image.getWidth() || key.height != image.getHeight()) {
image = resizeImage(image, key.width, key.height);
}
if (key.angle != 0.0) {
image = rotateImage(image, key.angle);
}
return image;
}
});
IMAGE_CACHE = ImageCaches.register(new MapMaker().softValues().makeComputingMap((Function<Key, Map<BufferedImage, BufferedImage>>) key -> new MapMaker().weakKeys().softValues().makeComputingMap(image -> {
if (key.width != image.getWidth() || key.height != image.getHeight()) {
image = resizeImage(image, key.width, key.height);
}
}));
if (key.angle != 0.0) {
image = rotateImage(image, key.angle);
}
return image;
})));
}
private static BufferedImage rotateImage(BufferedImage image, double angle) {

View file

@ -9,5 +9,5 @@ public enum AudioGroup {
GameSounds,
DraftSounds,
SkipSounds,
OtherSounds;
OtherSounds
}

View file

@ -39,8 +39,8 @@ public class LinePool {
* from the timer thread to prevent deadlocks in PulseAudio internals.
*/
private Mixer mixer;
private int alwaysActive;
private final Mixer mixer;
private final int alwaysActive;
public LinePool() {
this(new AudioFormat(22050, 16, 1, true, false), 4, 1);

View file

@ -16,7 +16,7 @@ public class MusicPlayer {
private static final Logger log = Logger.getLogger(AudioManager.class);
String filepath;
String filename;
List filelist = new List();
final List filelist = new List();
static MusicPlayer player = null;
//open file and add list
@ -138,11 +138,11 @@ public class MusicPlayer {
breaked = false;
}
}
};
}
class PlayThread extends Thread {
byte tempBuffer[] = new byte[320];
final byte[] tempBuffer = new byte[320];
public void run() {
try {
@ -165,5 +165,5 @@ public class MusicPlayer {
log.error("Thread error: " + e);
}
}
};
}
}

View file

@ -12,7 +12,7 @@ import java.util.List;
*/
public class ArrowBuilder {
private static ArrowBuilder instance;
private static final ArrowBuilder instance;
static {
instance = new ArrowBuilder();
@ -38,7 +38,7 @@ public class ArrowBuilder {
private int currentHeight;
public enum Type {
PAIRED, SOURCE, TARGET, COMBAT, ENCHANT_PLAYERS;
PAIRED, SOURCE, TARGET, COMBAT, ENCHANT_PLAYERS
}
/**
@ -103,16 +103,8 @@ public class ArrowBuilder {
synchronized (map) {
p.add(arrow);
Map<Type, java.util.List<Arrow>> innerMap = map.get(gameId);
if (innerMap == null) {
innerMap = new HashMap<Type, List<Arrow>>();
map.put(gameId, innerMap);
}
java.util.List<Arrow> arrows = innerMap.get(type);
if (arrows == null) {
arrows = new ArrayList<Arrow>();
innerMap.put(type, arrows);
}
Map<Type, java.util.List<Arrow>> innerMap = map.computeIfAbsent(gameId, k -> new HashMap<Type, List<Arrow>>());
java.util.List<Arrow> arrows = innerMap.computeIfAbsent(type, k -> new ArrayList<Arrow>());
arrows.add(arrow);
}

View file

@ -49,25 +49,19 @@ public class BufferedImageBuilder {
private void waitForImage(BufferedImage bufferedImage) {
final ImageLoadStatus imageLoadStatus = new ImageLoadStatus();
bufferedImage.getHeight(new ImageObserver() {
@Override
public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {
if (infoflags == ALLBITS) {
imageLoadStatus.heightDone = true;
return true;
}
return false;
bufferedImage.getHeight((img, infoflags, x, y, width, height) -> {
if (infoflags == ImageObserver.ALLBITS) {
imageLoadStatus.heightDone = true;
return true;
}
return false;
});
bufferedImage.getWidth(new ImageObserver() {
@Override
public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {
if (infoflags == ALLBITS) {
imageLoadStatus.widthDone = true;
return true;
}
return false;
bufferedImage.getWidth((img, infoflags, x, y, width, height) -> {
if (infoflags == ImageObserver.ALLBITS) {
imageLoadStatus.widthDone = true;
return true;
}
return false;
});
while (!imageLoadStatus.widthDone && !imageLoadStatus.heightDone) {
try {

View file

@ -156,8 +156,8 @@ public class GuiDisplayUtil {
if (card.getMageObjectType().canHaveCounters()) {
ArrayList<CounterView> counters = new ArrayList<>();
if (card instanceof PermanentView) {
if (((PermanentView) card).getCounters() != null) {
counters = new ArrayList<>(((PermanentView) card).getCounters());
if (card.getCounters() != null) {
counters = new ArrayList<>(card.getCounters());
}
} else if (card.getCounters() != null) {
counters = new ArrayList<>(card.getCounters());

View file

@ -37,9 +37,9 @@ import mage.client.dialog.MageDialog;
*/
public class MageDialogState {
Dimension dimension;
int xPos;
int yPos;
final Dimension dimension;
final int xPos;
final int yPos;
public MageDialogState(MageDialog mageDialog) {
this.dimension = mageDialog.getSize();

View file

@ -28,8 +28,6 @@
package mage.client.util.gui;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
@ -50,9 +48,9 @@ import mage.client.cards.CardsList;
*/
public class TableSpinnerEditor extends DefaultCellEditor {
JSpinner spinner;
JSpinner.DefaultEditor editor;
JTextField textField;
final JSpinner spinner;
final JSpinner.DefaultEditor editor;
final JTextField textField;
boolean valueSet;
private JTable table;
private int lastRow = -1;
@ -60,7 +58,7 @@ public class TableSpinnerEditor extends DefaultCellEditor {
private int lastOriginalHeigh;
private int currentOriginalHeigh;
private static final int NEEDED_HIGH = 24;
CardsList cardsList;
final CardsList cardsList;
// Initializes the spinner.
public TableSpinnerEditor(CardsList cardsList) {
@ -83,12 +81,9 @@ public class TableSpinnerEditor extends DefaultCellEditor {
table.setRowHeight(lastRow, NEEDED_HIGH);
}
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (valueSet) {
textField.setCaretPosition(1);
}
SwingUtilities.invokeLater(() -> {
if (valueSet) {
textField.setCaretPosition(1);
}
});
}
@ -101,12 +96,7 @@ public class TableSpinnerEditor extends DefaultCellEditor {
}
}
});
textField.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
stopCellEditing();
}
});
textField.addActionListener(ae -> stopCellEditing());
}
private synchronized void resetRow() {
@ -129,12 +119,7 @@ public class TableSpinnerEditor extends DefaultCellEditor {
if (!valueSet) {
spinner.setValue(value);
}
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
textField.requestFocus();
}
});
SwingUtilities.invokeLater(() -> textField.requestFocus());
return spinner;
}

View file

@ -42,7 +42,7 @@ public class CountryCellRenderer extends DefaultTableCellRenderer {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (value == null || ((String) value).isEmpty()) {
value = (String) "world";
value = "world";
}
label.setToolTipText(CountryUtil.getCountryName((String) value));
label.setIcon(CountryUtil.getCountryFlagIcon((String) value));

Some files were not shown because too many files have changed in this diff Show more