mirror of
https://github.com/correl/mage.git
synced 2024-12-24 03:00:14 +00:00
[refactoring][minor] Replaced all tabs with four spaces.
This commit is contained in:
parent
e646e4768d
commit
239a4fb100
2891 changed files with 79411 additions and 79411 deletions
|
@ -1,28 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Config.xsd">
|
||||
<server serverAddress="0.0.0.0" serverName="mage-server" port="17171" maxGameThreads="10" maxSecondsIdle="600"/>
|
||||
<playerTypes>
|
||||
<playerType name="Human" jar="mage-player-human.jar" className="mage.player.human.HumanPlayer"/>
|
||||
<playerType name="Computer - minimax" jar="mage-player-aiminimax.jar" className="mage.player.ai.ComputerPlayer3"/>
|
||||
<playerType name="Computer - mad" jar="mage-player-ai-ma.jar" className="mage.player.ai.ComputerPlayer6"/>
|
||||
<playerType name="Computer - monte carlo" jar="mage-player-aimcts.jar" className="mage.player.ai.ComputerPlayerMCTS"/>
|
||||
</playerTypes>
|
||||
<gameTypes>
|
||||
<gameType name="Two Player Duel" jar="mage-game-twoplayerduel.jar" className="mage.game.TwoPlayerMatch" typeName="mage.game.TwoPlayerDuelType"/>
|
||||
<gameType name="Free For All" jar="mage-game-freeforall.jar" className="mage.game.FreeForAllMatch" typeName="mage.game.FreeForAllType"/>
|
||||
</gameTypes>
|
||||
<tournamentTypes>
|
||||
<tournamentType name="Elimination Booster Draft" jar="mage-tournament-booster-draft.jar" className="mage.tournament.BoosterDraftEliminationTournament" typeName="mage.tournament.BoosterDraftEliminationTournamentType"/>
|
||||
<tournamentType name="Sealed Elimination" jar="mage-tournament-sealed.jar" className="mage.tournament.SealedEliminationTournament" typeName="mage.tournament.SealedEliminationTournamentType"/>
|
||||
</tournamentTypes>
|
||||
<deckTypes>
|
||||
<deckType name="Constructed - Vintage" jar="mage-deck-constructed.jar" className="mage.deck.Vintage"/>
|
||||
<deckType name="Constructed - Extended" jar="mage-deck-constructed.jar" className="mage.deck.Extended"/>
|
||||
<deckType name="Constructed - Standard" jar="mage-deck-constructed.jar" className="mage.deck.Standard"/>
|
||||
<deckType name="Constructed - Shards of Alara Block" jar="mage-deck-constructed.jar" className="mage.deck.ShardsOfAlaraBlock"/>
|
||||
<deckType name="Constructed - Zendikar Block" jar="mage-deck-constructed.jar" className="mage.deck.ZendikarBlock"/>
|
||||
<deckType name="Constructed - Scars of Mirrodin Block" jar="mage-deck-constructed.jar" className="mage.deck.ScarsOfMirrodinBlock"/>
|
||||
<deckType name="Limited" jar="mage-deck-limited.jar" className="mage.deck.Limited"/>
|
||||
</deckTypes>
|
||||
<server serverAddress="0.0.0.0" serverName="mage-server" port="17171" maxGameThreads="10" maxSecondsIdle="600"/>
|
||||
<playerTypes>
|
||||
<playerType name="Human" jar="mage-player-human.jar" className="mage.player.human.HumanPlayer"/>
|
||||
<playerType name="Computer - minimax" jar="mage-player-aiminimax.jar" className="mage.player.ai.ComputerPlayer3"/>
|
||||
<playerType name="Computer - mad" jar="mage-player-ai-ma.jar" className="mage.player.ai.ComputerPlayer6"/>
|
||||
<playerType name="Computer - monte carlo" jar="mage-player-aimcts.jar" className="mage.player.ai.ComputerPlayerMCTS"/>
|
||||
</playerTypes>
|
||||
<gameTypes>
|
||||
<gameType name="Two Player Duel" jar="mage-game-twoplayerduel.jar" className="mage.game.TwoPlayerMatch" typeName="mage.game.TwoPlayerDuelType"/>
|
||||
<gameType name="Free For All" jar="mage-game-freeforall.jar" className="mage.game.FreeForAllMatch" typeName="mage.game.FreeForAllType"/>
|
||||
</gameTypes>
|
||||
<tournamentTypes>
|
||||
<tournamentType name="Elimination Booster Draft" jar="mage-tournament-booster-draft.jar" className="mage.tournament.BoosterDraftEliminationTournament" typeName="mage.tournament.BoosterDraftEliminationTournamentType"/>
|
||||
<tournamentType name="Sealed Elimination" jar="mage-tournament-sealed.jar" className="mage.tournament.SealedEliminationTournament" typeName="mage.tournament.SealedEliminationTournamentType"/>
|
||||
</tournamentTypes>
|
||||
<deckTypes>
|
||||
<deckType name="Constructed - Vintage" jar="mage-deck-constructed.jar" className="mage.deck.Vintage"/>
|
||||
<deckType name="Constructed - Extended" jar="mage-deck-constructed.jar" className="mage.deck.Extended"/>
|
||||
<deckType name="Constructed - Standard" jar="mage-deck-constructed.jar" className="mage.deck.Standard"/>
|
||||
<deckType name="Constructed - Shards of Alara Block" jar="mage-deck-constructed.jar" className="mage.deck.ShardsOfAlaraBlock"/>
|
||||
<deckType name="Constructed - Zendikar Block" jar="mage-deck-constructed.jar" className="mage.deck.ZendikarBlock"/>
|
||||
<deckType name="Constructed - Scars of Mirrodin Block" jar="mage-deck-constructed.jar" className="mage.deck.ScarsOfMirrodinBlock"/>
|
||||
<deckType name="Limited" jar="mage-deck-limited.jar" className="mage.deck.Limited"/>
|
||||
</deckTypes>
|
||||
</config>
|
||||
|
|
|
@ -155,7 +155,7 @@
|
|||
</descriptors>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
<!--
|
||||
<plugin>
|
||||
<groupId>com.akathist.maven.plugins.launch4j</groupId>
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Config.xsd">
|
||||
<server serverAddress="0.0.0.0" serverName="mage-server" port="17171" maxGameThreads="10" maxSecondsIdle="600"/>
|
||||
<playerTypes>
|
||||
<playerType name="Human" jar="mage-player-human.jar" className="mage.player.human.HumanPlayer"/>
|
||||
<playerType name="Computer - minimax" jar="mage-player-aiminimax.jar" className="mage.player.ai.ComputerPlayer3"/>
|
||||
<playerType name="Computer - mad" jar="mage-player-ai-ma.jar" className="mage.player.ai.ComputerPlayer6"/>
|
||||
<playerType name="Computer - monte carlo" jar="mage-player-aimcts.jar" className="mage.player.ai.ComputerPlayerMCTS"/>
|
||||
</playerTypes>
|
||||
<gameTypes>
|
||||
<gameType name="Two Player Duel" jar="mage-game-twoplayerduel.jar" className="mage.game.TwoPlayerMatch" typeName="mage.game.TwoPlayerDuelType"/>
|
||||
<gameType name="Free For All" jar="mage-game-freeforall.jar" className="mage.game.FreeForAllMatch" typeName="mage.game.FreeForAllType"/>
|
||||
</gameTypes>
|
||||
<tournamentTypes>
|
||||
<tournamentType name="Elimination Booster Draft" jar="mage-tournament-booster-draft.jar" className="mage.tournament.BoosterDraftEliminationTournament" typeName="mage.tournament.BoosterDraftEliminationTournamentType"/>
|
||||
<tournamentType name="Sealed Elimination" jar="mage-tournament-sealed.jar" className="mage.tournament.SealedEliminationTournament" typeName="mage.tournament.SealedEliminationTournamentType"/>
|
||||
</tournamentTypes>
|
||||
<deckTypes>
|
||||
<deckType name="Constructed - Vintage" jar="mage-deck-constructed.jar" className="mage.deck.Vintage"/>
|
||||
<deckType name="Constructed - Extended" jar="mage-deck-constructed.jar" className="mage.deck.Extended"/>
|
||||
<deckType name="Constructed - Standard" jar="mage-deck-constructed.jar" className="mage.deck.Standard"/>
|
||||
<deckType name="Constructed - Shards of Alara Block" jar="mage-deck-constructed.jar" className="mage.deck.ShardsOfAlaraBlock"/>
|
||||
<deckType name="Constructed - Zendikar Block" jar="mage-deck-constructed.jar" className="mage.deck.ZendikarBlock"/>
|
||||
<deckType name="Constructed - Scars of Mirrodin Block" jar="mage-deck-constructed.jar" className="mage.deck.ScarsOfMirrodinBlock"/>
|
||||
<deckType name="Limited" jar="mage-deck-limited.jar" className="mage.deck.Limited"/>
|
||||
</deckTypes>
|
||||
<server serverAddress="0.0.0.0" serverName="mage-server" port="17171" maxGameThreads="10" maxSecondsIdle="600"/>
|
||||
<playerTypes>
|
||||
<playerType name="Human" jar="mage-player-human.jar" className="mage.player.human.HumanPlayer"/>
|
||||
<playerType name="Computer - minimax" jar="mage-player-aiminimax.jar" className="mage.player.ai.ComputerPlayer3"/>
|
||||
<playerType name="Computer - mad" jar="mage-player-ai-ma.jar" className="mage.player.ai.ComputerPlayer6"/>
|
||||
<playerType name="Computer - monte carlo" jar="mage-player-aimcts.jar" className="mage.player.ai.ComputerPlayerMCTS"/>
|
||||
</playerTypes>
|
||||
<gameTypes>
|
||||
<gameType name="Two Player Duel" jar="mage-game-twoplayerduel.jar" className="mage.game.TwoPlayerMatch" typeName="mage.game.TwoPlayerDuelType"/>
|
||||
<gameType name="Free For All" jar="mage-game-freeforall.jar" className="mage.game.FreeForAllMatch" typeName="mage.game.FreeForAllType"/>
|
||||
</gameTypes>
|
||||
<tournamentTypes>
|
||||
<tournamentType name="Elimination Booster Draft" jar="mage-tournament-booster-draft.jar" className="mage.tournament.BoosterDraftEliminationTournament" typeName="mage.tournament.BoosterDraftEliminationTournamentType"/>
|
||||
<tournamentType name="Sealed Elimination" jar="mage-tournament-sealed.jar" className="mage.tournament.SealedEliminationTournament" typeName="mage.tournament.SealedEliminationTournamentType"/>
|
||||
</tournamentTypes>
|
||||
<deckTypes>
|
||||
<deckType name="Constructed - Vintage" jar="mage-deck-constructed.jar" className="mage.deck.Vintage"/>
|
||||
<deckType name="Constructed - Extended" jar="mage-deck-constructed.jar" className="mage.deck.Extended"/>
|
||||
<deckType name="Constructed - Standard" jar="mage-deck-constructed.jar" className="mage.deck.Standard"/>
|
||||
<deckType name="Constructed - Shards of Alara Block" jar="mage-deck-constructed.jar" className="mage.deck.ShardsOfAlaraBlock"/>
|
||||
<deckType name="Constructed - Zendikar Block" jar="mage-deck-constructed.jar" className="mage.deck.ZendikarBlock"/>
|
||||
<deckType name="Constructed - Scars of Mirrodin Block" jar="mage-deck-constructed.jar" className="mage.deck.ScarsOfMirrodinBlock"/>
|
||||
<deckType name="Limited" jar="mage-deck-limited.jar" className="mage.deck.Limited"/>
|
||||
</deckTypes>
|
||||
</config>
|
||||
|
|
|
@ -33,7 +33,7 @@ package mage;
|
|||
/*
|
||||
* TrayIconDemo.java
|
||||
*/
|
||||
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
@ -41,7 +41,7 @@ import java.awt.event.ActionListener;
|
|||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.net.URL;
|
||||
|
||||
|
||||
public class TrayIconDemo {
|
||||
public static void main(String[] args) {
|
||||
/* Use an appropriate Look and Feel */
|
||||
|
@ -68,7 +68,7 @@ public class TrayIconDemo {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
//Check the SystemTray support
|
||||
if (!SystemTray.isSupported()) {
|
||||
|
@ -79,7 +79,7 @@ public class TrayIconDemo {
|
|||
final TrayIcon trayIcon =
|
||||
new TrayIcon(createImage("images/bulb.gif", "tray icon"));
|
||||
final SystemTray tray = SystemTray.getSystemTray();
|
||||
|
||||
|
||||
// Create a popup menu components
|
||||
MenuItem aboutItem = new MenuItem("About");
|
||||
CheckboxMenuItem cb1 = new CheckboxMenuItem("Set auto size");
|
||||
|
@ -90,7 +90,7 @@ public class TrayIconDemo {
|
|||
MenuItem infoItem = new MenuItem("Info");
|
||||
MenuItem noneItem = new MenuItem("None");
|
||||
MenuItem exitItem = new MenuItem("Exit");
|
||||
|
||||
|
||||
//Add components to popup menu
|
||||
popup.add(aboutItem);
|
||||
popup.addSeparator();
|
||||
|
@ -103,30 +103,30 @@ public class TrayIconDemo {
|
|||
displayMenu.add(infoItem);
|
||||
displayMenu.add(noneItem);
|
||||
popup.add(exitItem);
|
||||
|
||||
|
||||
trayIcon.setPopupMenu(popup);
|
||||
|
||||
|
||||
try {
|
||||
tray.add(trayIcon);
|
||||
} catch (AWTException e) {
|
||||
System.out.println("TrayIcon could not be added.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
trayIcon.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JOptionPane.showMessageDialog(null,
|
||||
"This dialog box is run from System Tray");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
aboutItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JOptionPane.showMessageDialog(null,
|
||||
"This dialog box is run from the About menu item");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
cb1.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
int cb1Id = e.getStateChange();
|
||||
|
@ -137,7 +137,7 @@ public class TrayIconDemo {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
cb2.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
int cb2Id = e.getStateChange();
|
||||
|
@ -148,7 +148,7 @@ public class TrayIconDemo {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
ActionListener listener = new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
MenuItem item = (MenuItem)e.getSource();
|
||||
|
@ -158,17 +158,17 @@ public class TrayIconDemo {
|
|||
//type = TrayIcon.MessageType.ERROR;
|
||||
trayIcon.displayMessage("Sun TrayIcon Demo",
|
||||
"This is an error message", TrayIcon.MessageType.ERROR);
|
||||
|
||||
|
||||
} else if ("Warning".equals(item.getLabel())) {
|
||||
//type = TrayIcon.MessageType.WARNING;
|
||||
trayIcon.displayMessage("Sun TrayIcon Demo",
|
||||
"This is a warning message", TrayIcon.MessageType.WARNING);
|
||||
|
||||
|
||||
} else if ("Info".equals(item.getLabel())) {
|
||||
//type = TrayIcon.MessageType.INFO;
|
||||
trayIcon.displayMessage("Sun TrayIcon Demo",
|
||||
"This is an info message", TrayIcon.MessageType.INFO);
|
||||
|
||||
|
||||
} else if ("None".equals(item.getLabel())) {
|
||||
//type = TrayIcon.MessageType.NONE;
|
||||
trayIcon.displayMessage("Sun TrayIcon Demo",
|
||||
|
@ -176,12 +176,12 @@ public class TrayIconDemo {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
errorItem.addActionListener(listener);
|
||||
warningItem.addActionListener(listener);
|
||||
infoItem.addActionListener(listener);
|
||||
noneItem.addActionListener(listener);
|
||||
|
||||
|
||||
exitItem.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
tray.remove(trayIcon);
|
||||
|
@ -189,11 +189,11 @@ public class TrayIconDemo {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//Obtain the image URL
|
||||
protected static Image createImage(String path, String description) {
|
||||
URL imageURL = TrayIconDemo.class.getResource(path);
|
||||
|
||||
|
||||
if (imageURL == null) {
|
||||
System.err.println("Resource not found: " + path);
|
||||
return null;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -43,36 +43,36 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public abstract class MagePane extends javax.swing.JInternalFrame {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(MagePane.class);
|
||||
private final static Logger logger = Logger.getLogger(MagePane.class);
|
||||
|
||||
/** Creates new form MagePane */
|
||||
public MagePane() {
|
||||
initComponents();
|
||||
hideTitle();
|
||||
hideTitle();
|
||||
}
|
||||
|
||||
private void hideTitle() {
|
||||
if (ui instanceof BasicInternalFrameUI)
|
||||
((BasicInternalFrameUI) ui).setNorthPane(null);
|
||||
}
|
||||
private void hideTitle() {
|
||||
if (ui instanceof BasicInternalFrameUI)
|
||||
((BasicInternalFrameUI) ui).setNorthPane(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUI() {
|
||||
super.updateUI();
|
||||
hideTitle();
|
||||
}
|
||||
@Override
|
||||
public void updateUI() {
|
||||
super.updateUI();
|
||||
hideTitle();
|
||||
}
|
||||
|
||||
public void hideFrame() {
|
||||
MageFrame.deactivate(this);
|
||||
}
|
||||
|
||||
public void activated() {
|
||||
|
||||
}
|
||||
|
||||
public void deactivated() {
|
||||
|
||||
}
|
||||
public void hideFrame() {
|
||||
MageFrame.deactivate(this);
|
||||
}
|
||||
|
||||
public void activated() {
|
||||
|
||||
}
|
||||
|
||||
public void deactivated() {
|
||||
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
|
|
@ -139,7 +139,7 @@ public class BigCard extends JComponent {
|
|||
graphics.drawImage(bigImage, 0, 0, this);
|
||||
}
|
||||
}*/
|
||||
if (bigImage != null) {
|
||||
if (bigImage != null) {
|
||||
graphics.drawImage(bigImage, 0, 0, this);
|
||||
}
|
||||
super.paintComponent(graphics);
|
||||
|
@ -175,7 +175,7 @@ public class BigCard extends JComponent {
|
|||
}
|
||||
}
|
||||
*/
|
||||
repaint();
|
||||
repaint();
|
||||
}
|
||||
|
||||
private Thread getFoilThread() {
|
||||
|
@ -212,9 +212,9 @@ public class BigCard extends JComponent {
|
|||
if (source == null) {
|
||||
source = BufferedImageBuilder.bufferImage(bigImage);
|
||||
}
|
||||
if (source == null) {
|
||||
return;
|
||||
}
|
||||
if (source == null) {
|
||||
return;
|
||||
}
|
||||
f = filter.filter(source, null);
|
||||
}
|
||||
synchronized (BigCard.class) {
|
||||
|
@ -261,7 +261,7 @@ public class BigCard extends JComponent {
|
|||
setMaximumSize(new Dimension(FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT));
|
||||
setPreferredSize(getMinimumSize());
|
||||
setLayout(null);
|
||||
//setBackground(new Color(255,255,255,200));
|
||||
//setBackground(new Color(255,255,255,200));
|
||||
|
||||
scrollPane.setBorder(null);
|
||||
scrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
|
@ -275,10 +275,10 @@ public class BigCard extends JComponent {
|
|||
add(scrollPane);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
public void setDefaultImage() {
|
||||
bigImage = ImageHelper.getImageFromResources("/empty.png");
|
||||
public void setDefaultImage() {
|
||||
bigImage = ImageHelper.getImageFromResources("/empty.png");
|
||||
bigImage = ImageHelper.getResizedImage((BufferedImage) bigImage, getWidth(), getHeight());
|
||||
}
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JScrollPane scrollPane;
|
||||
|
|
|
@ -69,203 +69,203 @@ import static mage.constants.Constants.*;
|
|||
@SuppressWarnings("serial")
|
||||
public class Card extends MagePermanent implements MouseMotionListener, MouseListener, FocusListener, ComponentListener {
|
||||
|
||||
protected static Session session = MageFrame.getSession();
|
||||
protected static DefaultActionCallback callback = DefaultActionCallback.getInstance();
|
||||
|
||||
protected Point p;
|
||||
protected CardDimensions dimension;
|
||||
protected static Session session = MageFrame.getSession();
|
||||
protected static DefaultActionCallback callback = DefaultActionCallback.getInstance();
|
||||
|
||||
protected final UUID gameId;
|
||||
protected final BigCard bigCard;
|
||||
protected CardView card;
|
||||
protected Popup popup;
|
||||
protected boolean popupShowing;
|
||||
protected Point p;
|
||||
protected CardDimensions dimension;
|
||||
|
||||
protected TextPopup popupText = new TextPopup();
|
||||
protected BufferedImage background;
|
||||
protected BufferedImage image = new BufferedImage(FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT, BufferedImage.TYPE_INT_RGB);
|
||||
protected BufferedImage small;
|
||||
protected String backgroundName;
|
||||
protected final UUID gameId;
|
||||
protected final BigCard bigCard;
|
||||
protected CardView card;
|
||||
protected Popup popup;
|
||||
protected boolean popupShowing;
|
||||
|
||||
protected TextPopup popupText = new TextPopup();
|
||||
protected BufferedImage background;
|
||||
protected BufferedImage image = new BufferedImage(FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT, BufferedImage.TYPE_INT_RGB);
|
||||
protected BufferedImage small;
|
||||
protected String backgroundName;
|
||||
|
||||
/** Creates new form Card */
|
||||
public Card(CardView card, BigCard bigCard, CardDimensions dimension, UUID gameId) {
|
||||
this.dimension = dimension;
|
||||
this.dimension = dimension;
|
||||
initComponents();
|
||||
|
||||
this.gameId = gameId;
|
||||
this.card = card;
|
||||
this.bigCard = bigCard;
|
||||
small = new BufferedImage(Config.dimensions.frameWidth, Config.dimensions.frameHeight, BufferedImage.TYPE_INT_RGB);
|
||||
backgroundName = getBackgroundName();
|
||||
background = ImageHelper.getBackground(card, backgroundName);
|
||||
|
||||
StyledDocument doc = text.getStyledDocument();
|
||||
this.gameId = gameId;
|
||||
this.card = card;
|
||||
this.bigCard = bigCard;
|
||||
small = new BufferedImage(Config.dimensions.frameWidth, Config.dimensions.frameHeight, BufferedImage.TYPE_INT_RGB);
|
||||
backgroundName = getBackgroundName();
|
||||
background = ImageHelper.getBackground(card, backgroundName);
|
||||
|
||||
StyledDocument doc = text.getStyledDocument();
|
||||
Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
|
||||
Style regular = doc.addStyle("regular", def);
|
||||
StyleConstants.setFontFamily(def, "arial");
|
||||
Style s = doc.addStyle("small", regular);
|
||||
StyleConstants.setFontSize(s, 9);
|
||||
|
||||
//addMouseListener(this);
|
||||
//text.addMouseListener(this);
|
||||
//addFocusListener(this);
|
||||
//addMouseMotionListener(this);
|
||||
//text.addMouseMotionListener(this);
|
||||
//addComponentListener(this);
|
||||
//addMouseListener(this);
|
||||
//text.addMouseListener(this);
|
||||
//addFocusListener(this);
|
||||
//addMouseMotionListener(this);
|
||||
//text.addMouseMotionListener(this);
|
||||
//addComponentListener(this);
|
||||
}
|
||||
|
||||
public UUID getCardId() {
|
||||
return card.getId();
|
||||
}
|
||||
public UUID getCardId() {
|
||||
return card.getId();
|
||||
}
|
||||
|
||||
public void update(PermanentView permanent) {
|
||||
this.update((CardView)permanent);
|
||||
}
|
||||
|
||||
public void update(CardView card) {
|
||||
this.card = card;
|
||||
Graphics2D gImage = image.createGraphics();
|
||||
Graphics2D gSmall = small.createGraphics();
|
||||
String cardType = getType(card);
|
||||
String testBackgroundName = getBackgroundName();
|
||||
if (!testBackgroundName.equals(backgroundName)) {
|
||||
backgroundName = testBackgroundName;
|
||||
background = ImageHelper.getBackground(card, backgroundName);
|
||||
}
|
||||
public void update(PermanentView permanent) {
|
||||
this.update((CardView)permanent);
|
||||
}
|
||||
|
||||
popupText.setText(getText(cardType));
|
||||
public void update(CardView card) {
|
||||
this.card = card;
|
||||
Graphics2D gImage = image.createGraphics();
|
||||
Graphics2D gSmall = small.createGraphics();
|
||||
String cardType = getType(card);
|
||||
String testBackgroundName = getBackgroundName();
|
||||
if (!testBackgroundName.equals(backgroundName)) {
|
||||
backgroundName = testBackgroundName;
|
||||
background = ImageHelper.getBackground(card, backgroundName);
|
||||
}
|
||||
|
||||
gImage.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
gImage.setColor(Color.BLACK);
|
||||
gImage.drawImage(background, 0, 0, this);
|
||||
popupText.setText(getText(cardType));
|
||||
|
||||
if (card.getManaCost().size() > 0)
|
||||
ImageHelper.drawCosts(card.getManaCost(), gImage, FRAME_MAX_WIDTH - SYMBOL_MAX_XOFFSET, SYMBOL_MAX_YOFFSET, this);
|
||||
gImage.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
gImage.setColor(Color.BLACK);
|
||||
gImage.drawImage(background, 0, 0, this);
|
||||
|
||||
gSmall.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
gSmall.setColor(Color.BLACK);
|
||||
gSmall.drawImage(ImageHelper.scaleImage(image, Config.dimensions.frameWidth, Config.dimensions.frameHeight), 0, 0, this);
|
||||
if (card.getManaCost().size() > 0)
|
||||
ImageHelper.drawCosts(card.getManaCost(), gImage, FRAME_MAX_WIDTH - SYMBOL_MAX_XOFFSET, SYMBOL_MAX_YOFFSET, this);
|
||||
|
||||
gImage.setFont(new Font("Arial", Font.PLAIN, NAME_FONT_MAX_SIZE));
|
||||
gImage.drawString(card.getName(), CONTENT_MAX_XOFFSET, NAME_MAX_YOFFSET);
|
||||
if (card.getCardTypes().contains(CardType.CREATURE)) {
|
||||
gImage.drawString(card.getPower() + "/" + card.getToughness(), POWBOX_TEXT_MAX_LEFT, POWBOX_TEXT_MAX_TOP);
|
||||
}
|
||||
else if (card.getCardTypes().contains(CardType.PLANESWALKER)) {
|
||||
gImage.drawString(card.getLoyalty(), POWBOX_TEXT_MAX_LEFT, POWBOX_TEXT_MAX_TOP);
|
||||
}
|
||||
gSmall.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
gSmall.setColor(Color.BLACK);
|
||||
gSmall.drawImage(ImageHelper.scaleImage(image, Config.dimensions.frameWidth, Config.dimensions.frameHeight), 0, 0, this);
|
||||
|
||||
if (card.getCardTypes().size() > 0)
|
||||
gImage.drawString(cardType, CONTENT_MAX_XOFFSET, TYPE_MAX_YOFFSET);
|
||||
gImage.setFont(new Font("Arial", Font.PLAIN, NAME_FONT_MAX_SIZE));
|
||||
gImage.drawString(card.getName(), CONTENT_MAX_XOFFSET, NAME_MAX_YOFFSET);
|
||||
if (card.getCardTypes().contains(CardType.CREATURE)) {
|
||||
gImage.drawString(card.getPower() + "/" + card.getToughness(), POWBOX_TEXT_MAX_LEFT, POWBOX_TEXT_MAX_TOP);
|
||||
}
|
||||
else if (card.getCardTypes().contains(CardType.PLANESWALKER)) {
|
||||
gImage.drawString(card.getLoyalty(), POWBOX_TEXT_MAX_LEFT, POWBOX_TEXT_MAX_TOP);
|
||||
}
|
||||
|
||||
gImage.dispose();
|
||||
if (card.getCardTypes().size() > 0)
|
||||
gImage.drawString(cardType, CONTENT_MAX_XOFFSET, TYPE_MAX_YOFFSET);
|
||||
|
||||
gSmall.setFont(new Font("Arial", Font.PLAIN, Config.dimensions.nameFontSize));
|
||||
gSmall.drawString(card.getName(), Config.dimensions.contentXOffset, Config.dimensions.nameYOffset);
|
||||
if (card.getCardTypes().contains(CardType.CREATURE)) {
|
||||
gSmall.drawString(card.getPower() + "/" + card.getToughness(), Config.dimensions.powBoxTextLeft, Config.dimensions.powBoxTextTop);
|
||||
}
|
||||
else if (card.getCardTypes().contains(CardType.PLANESWALKER)) {
|
||||
gSmall.drawString(card.getLoyalty(), Config.dimensions.powBoxTextLeft, Config.dimensions.powBoxTextTop);
|
||||
}
|
||||
gImage.dispose();
|
||||
|
||||
if (card.getCardTypes().size() > 0)
|
||||
gSmall.drawString(cardType, Config.dimensions.contentXOffset, Config.dimensions.typeYOffset);
|
||||
drawText();
|
||||
gSmall.setFont(new Font("Arial", Font.PLAIN, Config.dimensions.nameFontSize));
|
||||
gSmall.drawString(card.getName(), Config.dimensions.contentXOffset, Config.dimensions.nameYOffset);
|
||||
if (card.getCardTypes().contains(CardType.CREATURE)) {
|
||||
gSmall.drawString(card.getPower() + "/" + card.getToughness(), Config.dimensions.powBoxTextLeft, Config.dimensions.powBoxTextTop);
|
||||
}
|
||||
else if (card.getCardTypes().contains(CardType.PLANESWALKER)) {
|
||||
gSmall.drawString(card.getLoyalty(), Config.dimensions.powBoxTextLeft, Config.dimensions.powBoxTextTop);
|
||||
}
|
||||
|
||||
gSmall.dispose();
|
||||
}
|
||||
if (card.getCardTypes().size() > 0)
|
||||
gSmall.drawString(cardType, Config.dimensions.contentXOffset, Config.dimensions.typeYOffset);
|
||||
drawText();
|
||||
|
||||
@Override
|
||||
public void updateImage() {
|
||||
}
|
||||
gSmall.dispose();
|
||||
}
|
||||
|
||||
protected String getText(String cardType) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (card instanceof StackAbilityView || card instanceof AbilityView) {
|
||||
for (String rule: getRules()) {
|
||||
sb.append("\n").append(rule);
|
||||
}
|
||||
}
|
||||
else {
|
||||
sb.append(card.getName());
|
||||
if (card.getManaCost().size() > 0) {
|
||||
sb.append("\n").append(card.getManaCost());
|
||||
}
|
||||
sb.append("\n").append(cardType);
|
||||
if (card.getColor().hasColor()) {
|
||||
sb.append("\n").append(card.getColor().toString());
|
||||
}
|
||||
if (card.getCardTypes().contains(CardType.CREATURE)) {
|
||||
sb.append("\n").append(card.getPower()).append("/").append(card.getToughness());
|
||||
}
|
||||
else if (card.getCardTypes().contains(CardType.PLANESWALKER)) {
|
||||
sb.append("\n").append(card.getLoyalty());
|
||||
}
|
||||
for (String rule: getRules()) {
|
||||
sb.append("\n").append(rule);
|
||||
}
|
||||
if (card.getExpansionSetCode() != null && card.getExpansionSetCode().length() > 0) {
|
||||
sb.append("\n").append(card.getCardNumber()).append(" - ");
|
||||
sb.append(Sets.getInstance().get(card.getExpansionSetCode()).getName()).append(" - ");
|
||||
sb.append(card.getRarity().toString());
|
||||
}
|
||||
}
|
||||
// sb.append("\n").append(card.getId());
|
||||
return sb.toString();
|
||||
}
|
||||
@Override
|
||||
public void updateImage() {
|
||||
}
|
||||
|
||||
protected String getBackgroundName() {
|
||||
if (card instanceof StackAbilityView || card instanceof AbilityView) {
|
||||
return "effect";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (card.getCardTypes().contains(CardType.LAND)) {
|
||||
sb.append("land").append(card.getSuperTypes()).append(card.getSubTypes());
|
||||
}
|
||||
else if (card.getCardTypes() != null && (card.getCardTypes().contains(CardType.CREATURE) || card.getCardTypes().contains(CardType.PLANESWALKER))) {
|
||||
sb.append("creature");
|
||||
}
|
||||
sb.append(card.getColor()).append(card.getRarity()).append(card.getExpansionSetCode());
|
||||
return sb.toString();
|
||||
}
|
||||
protected String getText(String cardType) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (card instanceof StackAbilityView || card instanceof AbilityView) {
|
||||
for (String rule: getRules()) {
|
||||
sb.append("\n").append(rule);
|
||||
}
|
||||
}
|
||||
else {
|
||||
sb.append(card.getName());
|
||||
if (card.getManaCost().size() > 0) {
|
||||
sb.append("\n").append(card.getManaCost());
|
||||
}
|
||||
sb.append("\n").append(cardType);
|
||||
if (card.getColor().hasColor()) {
|
||||
sb.append("\n").append(card.getColor().toString());
|
||||
}
|
||||
if (card.getCardTypes().contains(CardType.CREATURE)) {
|
||||
sb.append("\n").append(card.getPower()).append("/").append(card.getToughness());
|
||||
}
|
||||
else if (card.getCardTypes().contains(CardType.PLANESWALKER)) {
|
||||
sb.append("\n").append(card.getLoyalty());
|
||||
}
|
||||
for (String rule: getRules()) {
|
||||
sb.append("\n").append(rule);
|
||||
}
|
||||
if (card.getExpansionSetCode() != null && card.getExpansionSetCode().length() > 0) {
|
||||
sb.append("\n").append(card.getCardNumber()).append(" - ");
|
||||
sb.append(Sets.getInstance().get(card.getExpansionSetCode()).getName()).append(" - ");
|
||||
sb.append(card.getRarity().toString());
|
||||
}
|
||||
}
|
||||
// sb.append("\n").append(card.getId());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
protected void drawText() {
|
||||
text.setText("");
|
||||
StyledDocument doc = text.getStyledDocument();
|
||||
protected String getBackgroundName() {
|
||||
if (card instanceof StackAbilityView || card instanceof AbilityView) {
|
||||
return "effect";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (card.getCardTypes().contains(CardType.LAND)) {
|
||||
sb.append("land").append(card.getSuperTypes()).append(card.getSubTypes());
|
||||
}
|
||||
else if (card.getCardTypes() != null && (card.getCardTypes().contains(CardType.CREATURE) || card.getCardTypes().contains(CardType.PLANESWALKER))) {
|
||||
sb.append("creature");
|
||||
}
|
||||
sb.append(card.getColor()).append(card.getRarity()).append(card.getExpansionSetCode());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
try {
|
||||
for (String rule: getRules())
|
||||
doc.insertString(doc.getLength(), rule + "\n", doc.getStyle("small"));
|
||||
} catch (BadLocationException e) {}
|
||||
protected void drawText() {
|
||||
text.setText("");
|
||||
StyledDocument doc = text.getStyledDocument();
|
||||
|
||||
text.setCaretPosition(0);
|
||||
}
|
||||
try {
|
||||
for (String rule: getRules())
|
||||
doc.insertString(doc.getLength(), rule + "\n", doc.getStyle("small"));
|
||||
} catch (BadLocationException e) {}
|
||||
|
||||
protected List<String> getRules() {
|
||||
return card.getRules();
|
||||
}
|
||||
text.setCaretPosition(0);
|
||||
}
|
||||
|
||||
protected String getType(CardView card) {
|
||||
StringBuilder sbType = new StringBuilder();
|
||||
protected List<String> getRules() {
|
||||
return card.getRules();
|
||||
}
|
||||
|
||||
for (String superType: card.getSuperTypes()) {
|
||||
sbType.append(superType).append(" ");
|
||||
}
|
||||
protected String getType(CardView card) {
|
||||
StringBuilder sbType = new StringBuilder();
|
||||
|
||||
for (mage.Constants.CardType cardType: card.getCardTypes()) {
|
||||
sbType.append(cardType.toString()).append(" ");
|
||||
}
|
||||
for (String superType: card.getSuperTypes()) {
|
||||
sbType.append(superType).append(" ");
|
||||
}
|
||||
|
||||
if (card.getSubTypes().size() > 0) {
|
||||
sbType.append("- ");
|
||||
for (String subType: card.getSubTypes()) {
|
||||
sbType.append(subType).append(" ");
|
||||
}
|
||||
}
|
||||
for (mage.Constants.CardType cardType: card.getCardTypes()) {
|
||||
sbType.append(cardType.toString()).append(" ");
|
||||
}
|
||||
|
||||
return sbType.toString();
|
||||
}
|
||||
if (card.getSubTypes().size() > 0) {
|
||||
sbType.append("- ");
|
||||
for (String subType: card.getSubTypes()) {
|
||||
sbType.append(subType).append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
return sbType.toString();
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
@ -301,163 +301,163 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
jScrollPane1.setBounds(new Rectangle(dimension.contentXOffset, dimension.textYOffset, dimension.textWidth, dimension.textHeight));
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics graphics) {
|
||||
Graphics2D g2 = (Graphics2D) graphics;
|
||||
g2.drawImage(small, 0, 0, this);
|
||||
@Override
|
||||
public void paintComponent(Graphics graphics) {
|
||||
Graphics2D g2 = (Graphics2D) graphics;
|
||||
g2.drawImage(small, 0, 0, this);
|
||||
|
||||
//Add a border, red if card currently has focus
|
||||
if (isFocusOwner()) {
|
||||
g2.setColor(Color.RED);
|
||||
} else {
|
||||
g2.setColor(Color.BLACK);
|
||||
}
|
||||
g2.drawRect(0, 0, Config.dimensions.frameWidth - 1, Config.dimensions.frameHeight - 1);
|
||||
}
|
||||
//Add a border, red if card currently has focus
|
||||
if (isFocusOwner()) {
|
||||
g2.setColor(Color.RED);
|
||||
} else {
|
||||
g2.setColor(Color.BLACK);
|
||||
}
|
||||
g2.drawRect(0, 0, Config.dimensions.frameWidth - 1, Config.dimensions.frameHeight - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent arg0) {
|
||||
}
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent arg0) {
|
||||
this.bigCard.showTextComponent();
|
||||
this.bigCard.setCard(card.getId(), image, getRules(), false);
|
||||
}
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent arg0) {
|
||||
this.bigCard.showTextComponent();
|
||||
this.bigCard.setCard(card.getId(), image, getRules(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
}
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
requestFocusInWindow();
|
||||
callback.mouseClicked(e, gameId, session, card);
|
||||
}
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
requestFocusInWindow();
|
||||
callback.mouseClicked(e, gameId, session, card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent arg0) {
|
||||
}
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent arg0) {
|
||||
if (!popupShowing) {
|
||||
if (popup != null)
|
||||
popup.hide();
|
||||
PopupFactory factory = PopupFactory.getSharedInstance();
|
||||
popup = factory.getPopup(this, popupText, (int) this.getLocationOnScreen().getX() + Config.dimensions.frameWidth, (int) this.getLocationOnScreen().getY() + 40);
|
||||
popup.show();
|
||||
//hack to get popup to resize to fit text
|
||||
popup.hide();
|
||||
popup = factory.getPopup(this, popupText, (int) this.getLocationOnScreen().getX() + Config.dimensions.frameWidth, (int) this.getLocationOnScreen().getY() + 40);
|
||||
popup.show();
|
||||
popupShowing = true;
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent arg0) {
|
||||
if (!popupShowing) {
|
||||
if (popup != null)
|
||||
popup.hide();
|
||||
PopupFactory factory = PopupFactory.getSharedInstance();
|
||||
popup = factory.getPopup(this, popupText, (int) this.getLocationOnScreen().getX() + Config.dimensions.frameWidth, (int) this.getLocationOnScreen().getY() + 40);
|
||||
popup.show();
|
||||
//hack to get popup to resize to fit text
|
||||
popup.hide();
|
||||
popup = factory.getPopup(this, popupText, (int) this.getLocationOnScreen().getX() + Config.dimensions.frameWidth, (int) this.getLocationOnScreen().getY() + 40);
|
||||
popup.show();
|
||||
popupShowing = true;
|
||||
|
||||
// Draw Arrows for targets
|
||||
List<UUID> targets = card.getTargets();
|
||||
if (targets != null) {
|
||||
for (UUID uuid : targets) {
|
||||
PlayAreaPanel p = MageFrame.getGame(gameId).getPlayers().get(uuid);
|
||||
if (p != null) {
|
||||
Point target = p.getLocationOnScreen();
|
||||
Point me = this.getLocationOnScreen();
|
||||
ArrowBuilder.addArrow((int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() - 40, Color.red, ArrowBuilder.Type.TARGET);
|
||||
} else {
|
||||
for (PlayAreaPanel pa : MageFrame.getGame(gameId).getPlayers().values()) {
|
||||
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
|
||||
if (permanent != null) {
|
||||
Point target = permanent.getLocationOnScreen();
|
||||
Point me = this.getLocationOnScreen();
|
||||
ArrowBuilder.addArrow((int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() + 10, Color.red, ArrowBuilder.Type.TARGET);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Draw Arrows for targets
|
||||
List<UUID> targets = card.getTargets();
|
||||
if (targets != null) {
|
||||
for (UUID uuid : targets) {
|
||||
PlayAreaPanel p = MageFrame.getGame(gameId).getPlayers().get(uuid);
|
||||
if (p != null) {
|
||||
Point target = p.getLocationOnScreen();
|
||||
Point me = this.getLocationOnScreen();
|
||||
ArrowBuilder.addArrow((int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() - 40, Color.red, ArrowBuilder.Type.TARGET);
|
||||
} else {
|
||||
for (PlayAreaPanel pa : MageFrame.getGame(gameId).getPlayers().values()) {
|
||||
MagePermanent permanent = pa.getBattlefieldPanel().getPermanents().get(uuid);
|
||||
if (permanent != null) {
|
||||
Point target = permanent.getLocationOnScreen();
|
||||
Point me = this.getLocationOnScreen();
|
||||
ArrowBuilder.addArrow((int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() + 10, Color.red, ArrowBuilder.Type.TARGET);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent arg0) {
|
||||
if(getMousePosition(true) != null) return;
|
||||
if (popup != null) {
|
||||
popup.hide();
|
||||
popupShowing = false;
|
||||
//ArrowBuilder.removeAllArrows();
|
||||
@Override
|
||||
public void mouseExited(MouseEvent arg0) {
|
||||
if(getMousePosition(true) != null) return;
|
||||
if (popup != null) {
|
||||
popup.hide();
|
||||
popupShowing = false;
|
||||
//ArrowBuilder.removeAllArrows();
|
||||
ArrowBuilder.removeArrowsByType(ArrowBuilder.Type.TARGET);
|
||||
ArrowBuilder.removeArrowsByType(ArrowBuilder.Type.PAIRED);
|
||||
ArrowBuilder.removeArrowsByType(ArrowBuilder.Type.SOURCE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusGained(FocusEvent arg0) {
|
||||
this.repaint();
|
||||
}
|
||||
@Override
|
||||
public void focusGained(FocusEvent arg0) {
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusLost(FocusEvent arg0) {
|
||||
if (popup != null)
|
||||
popup.hide();
|
||||
this.repaint();
|
||||
}
|
||||
@Override
|
||||
public void focusLost(FocusEvent arg0) {
|
||||
if (popup != null)
|
||||
popup.hide();
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
protected JScrollPane getText() {
|
||||
return jScrollPane1;
|
||||
}
|
||||
protected JScrollPane getText() {
|
||||
return jScrollPane1;
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
protected javax.swing.JTextPane text;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) { }
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) { }
|
||||
|
||||
@Override
|
||||
public void componentMoved(ComponentEvent e) { }
|
||||
@Override
|
||||
public void componentMoved(ComponentEvent e) { }
|
||||
|
||||
@Override
|
||||
public void componentShown(ComponentEvent e) { }
|
||||
@Override
|
||||
public void componentShown(ComponentEvent e) { }
|
||||
|
||||
@Override
|
||||
public void componentHidden(ComponentEvent e) {
|
||||
if (popup != null)
|
||||
popup.hide();
|
||||
}
|
||||
@Override
|
||||
public void componentHidden(ComponentEvent e) {
|
||||
if (popup != null)
|
||||
popup.hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MagePermanent> getLinks() {return null;}
|
||||
@Override
|
||||
public List<MagePermanent> getLinks() {return null;}
|
||||
|
||||
@Override
|
||||
public boolean isTapped() {return false;}
|
||||
@Override
|
||||
public boolean isTapped() {return false;}
|
||||
|
||||
@Override
|
||||
public boolean isFlipped() {return false;}
|
||||
@Override
|
||||
public boolean isFlipped() {return false;}
|
||||
|
||||
@Override
|
||||
public void onBeginAnimation() {}
|
||||
@Override
|
||||
public void onBeginAnimation() {}
|
||||
|
||||
@Override
|
||||
public void onEndAnimation() {}
|
||||
@Override
|
||||
public void onEndAnimation() {}
|
||||
|
||||
@Override
|
||||
public void setAlpha(float transparency) {}
|
||||
@Override
|
||||
public void setAlpha(float transparency) {}
|
||||
|
||||
@Override
|
||||
public CardView getOriginal() {
|
||||
return card;
|
||||
}
|
||||
@Override
|
||||
public CardView getOriginal() {
|
||||
return card;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCardBounds(int x, int y, int width, int height) {
|
||||
// do nothing
|
||||
}
|
||||
@Override
|
||||
public void setCardBounds(int x, int y, int width, int height) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getImage() {
|
||||
return image;
|
||||
}
|
||||
@Override
|
||||
public Image getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFoil(boolean foil) {
|
||||
|
@ -478,22 +478,22 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCallback(ActionCallback callback, UUID gameId) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
@Override
|
||||
public void updateCallback(ActionCallback callback, UUID gameId) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermanentView getOriginalPermanent() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public PermanentView getOriginalPermanent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAlpha() {return 0;}
|
||||
@Override
|
||||
public float getAlpha() {return 0;}
|
||||
|
||||
@Override
|
||||
public void toggleTransformed() {
|
||||
}
|
||||
@Override
|
||||
public void toggleTransformed() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTransformed() {
|
||||
|
|
|
@ -50,107 +50,107 @@ import mage.view.SimpleCardsView;
|
|||
|
||||
public class CardArea extends JPanel {
|
||||
|
||||
private boolean reloaded = false;
|
||||
private javax.swing.JLayeredPane cardArea;
|
||||
private javax.swing.JScrollPane scrollPane;
|
||||
private boolean reloaded = false;
|
||||
private javax.swing.JLayeredPane cardArea;
|
||||
private javax.swing.JScrollPane scrollPane;
|
||||
|
||||
/**
|
||||
* Create the panel.
|
||||
*/
|
||||
public CardArea() {
|
||||
setLayout(new BorderLayout(0, 0));
|
||||
|
||||
scrollPane = new JScrollPane();
|
||||
add(scrollPane, BorderLayout.CENTER);
|
||||
|
||||
cardArea = new JLayeredPane();
|
||||
scrollPane.setViewportView(cardArea);
|
||||
/**
|
||||
* Create the panel.
|
||||
*/
|
||||
public CardArea() {
|
||||
setLayout(new BorderLayout(0, 0));
|
||||
|
||||
}
|
||||
scrollPane = new JScrollPane();
|
||||
add(scrollPane, BorderLayout.CENTER);
|
||||
|
||||
public void loadCards(SimpleCardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, MouseListener listener) {
|
||||
cardArea = new JLayeredPane();
|
||||
scrollPane.setViewportView(cardArea);
|
||||
|
||||
}
|
||||
|
||||
public void loadCards(SimpleCardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, MouseListener listener) {
|
||||
loadCards(CardsViewUtil.convertSimple(showCards), bigCard, dimension, gameId, listener);
|
||||
}
|
||||
|
||||
public void loadCards(CardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, MouseListener listener) {
|
||||
this.reloaded = true;
|
||||
cardArea.removeAll();
|
||||
if (showCards != null && showCards.size() < 10)
|
||||
loadCardsFew(showCards, bigCard, gameId, listener);
|
||||
else
|
||||
loadCardsMany(showCards, bigCard, gameId, listener);
|
||||
cardArea.revalidate();
|
||||
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
}
|
||||
public void loadCards(CardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, MouseListener listener) {
|
||||
this.reloaded = true;
|
||||
cardArea.removeAll();
|
||||
if (showCards != null && showCards.size() < 10)
|
||||
loadCardsFew(showCards, bigCard, gameId, listener);
|
||||
else
|
||||
loadCardsMany(showCards, bigCard, gameId, listener);
|
||||
cardArea.revalidate();
|
||||
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
public void loadCardsNarrow(CardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, MouseListener listener) {
|
||||
this.reloaded = true;
|
||||
cardArea.removeAll();
|
||||
loadCardsMany(showCards, bigCard, gameId, listener);
|
||||
cardArea.revalidate();
|
||||
this.reloaded = true;
|
||||
cardArea.removeAll();
|
||||
loadCardsMany(showCards, bigCard, gameId, listener);
|
||||
cardArea.revalidate();
|
||||
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
}
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
private void loadCardsFew(CardsView showCards, BigCard bigCard, UUID gameId, MouseListener listener) {
|
||||
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
Dimension dimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
for (CardView card : showCards.values()) {
|
||||
addCard(card, bigCard, gameId, rectangle, dimension, listener);
|
||||
rectangle.translate(Config.dimensions.frameWidth, 0);
|
||||
}
|
||||
cardArea.setPreferredSize(new Dimension(Config.dimensions.frameWidth * showCards.size(), Config.dimensions.frameHeight));
|
||||
}
|
||||
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
Dimension dimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
for (CardView card : showCards.values()) {
|
||||
addCard(card, bigCard, gameId, rectangle, dimension, listener);
|
||||
rectangle.translate(Config.dimensions.frameWidth, 0);
|
||||
}
|
||||
cardArea.setPreferredSize(new Dimension(Config.dimensions.frameWidth * showCards.size(), Config.dimensions.frameHeight));
|
||||
}
|
||||
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle, Dimension dimension, MouseListener listener) {
|
||||
if (card instanceof AbilityView) {
|
||||
CardView tmp = ((AbilityView) card).getSourceCard();
|
||||
tmp.overrideRules(card.getRules());
|
||||
tmp.setIsAbility(true);
|
||||
tmp.overrideTargets(card.getTargets());
|
||||
tmp.setAbility(card); // cross-reference, required for ability picker
|
||||
card = tmp;
|
||||
}
|
||||
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, dimension, gameId, true);
|
||||
cardImg.setBounds(rectangle);
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle, Dimension dimension, MouseListener listener) {
|
||||
if (card instanceof AbilityView) {
|
||||
CardView tmp = ((AbilityView) card).getSourceCard();
|
||||
tmp.overrideRules(card.getRules());
|
||||
tmp.setIsAbility(true);
|
||||
tmp.overrideTargets(card.getTargets());
|
||||
tmp.setAbility(card); // cross-reference, required for ability picker
|
||||
card = tmp;
|
||||
}
|
||||
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, dimension, gameId, true);
|
||||
cardImg.setBounds(rectangle);
|
||||
if (listener != null)
|
||||
cardImg.addMouseListener(listener);
|
||||
cardArea.add(cardImg);
|
||||
cardArea.moveToFront(cardImg);
|
||||
cardImg.update(card);
|
||||
cardImg.setCardBounds(rectangle.x, rectangle.y, Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
cardArea.add(cardImg);
|
||||
cardArea.moveToFront(cardImg);
|
||||
cardImg.update(card);
|
||||
cardImg.setCardBounds(rectangle.x, rectangle.y, Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
|
||||
private void loadCardsMany(CardsView showCards, BigCard bigCard, UUID gameId, MouseListener listener) {
|
||||
int columns = 1;
|
||||
if (showCards != null && showCards.size() > 0) {
|
||||
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
Dimension dimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
int count = 0;
|
||||
for (CardView card : showCards.values()) {
|
||||
addCard(card, bigCard, gameId, rectangle, dimension, listener);
|
||||
if (count >= 20) {
|
||||
rectangle.translate(Config.dimensions.frameWidth, -400);
|
||||
columns++;
|
||||
count = 0;
|
||||
} else {
|
||||
rectangle.translate(0, 20);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
cardArea.setPreferredSize(new Dimension(Config.dimensions.frameWidth * columns, Config.dimensions.frameHeight + 400));
|
||||
}
|
||||
private void loadCardsMany(CardsView showCards, BigCard bigCard, UUID gameId, MouseListener listener) {
|
||||
int columns = 1;
|
||||
if (showCards != null && showCards.size() > 0) {
|
||||
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
Dimension dimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
int count = 0;
|
||||
for (CardView card : showCards.values()) {
|
||||
addCard(card, bigCard, gameId, rectangle, dimension, listener);
|
||||
if (count >= 20) {
|
||||
rectangle.translate(Config.dimensions.frameWidth, -400);
|
||||
columns++;
|
||||
count = 0;
|
||||
} else {
|
||||
rectangle.translate(0, 20);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
cardArea.setPreferredSize(new Dimension(Config.dimensions.frameWidth * columns, Config.dimensions.frameHeight + 400));
|
||||
}
|
||||
|
||||
public boolean isReloaded() {
|
||||
return this.reloaded;
|
||||
}
|
||||
public boolean isReloaded() {
|
||||
return this.reloaded;
|
||||
}
|
||||
|
||||
public void clearReloaded() {
|
||||
this.reloaded = false;
|
||||
}
|
||||
|
||||
public void clearReloaded() {
|
||||
this.reloaded = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,20 +42,20 @@ import java.util.UUID;
|
|||
*/
|
||||
public class CardEventSource implements EventSource<Event>, Serializable {
|
||||
|
||||
protected final EventDispatcher<Event> dispatcher = new EventDispatcher<Event>() {};
|
||||
protected final EventDispatcher<Event> dispatcher = new EventDispatcher<Event>() {};
|
||||
|
||||
@Override
|
||||
public void addListener(Listener<Event> listener) {
|
||||
dispatcher.addListener(listener);
|
||||
}
|
||||
@Override
|
||||
public void addListener(Listener<Event> listener) {
|
||||
dispatcher.addListener(listener);
|
||||
}
|
||||
|
||||
public void doubleClick(UUID cardId, String message) {
|
||||
dispatcher.fireEvent(new Event(cardId, message));
|
||||
}
|
||||
public void doubleClick(UUID cardId, String message) {
|
||||
dispatcher.fireEvent(new Event(cardId, message));
|
||||
}
|
||||
|
||||
public void shiftDoubleClick(UUID cardId, String message) {
|
||||
dispatcher.fireEvent(new Event(cardId, message));
|
||||
}
|
||||
public void shiftDoubleClick(UUID cardId, String message) {
|
||||
dispatcher.fireEvent(new Event(cardId, message));
|
||||
}
|
||||
|
||||
public void removeFromMainEvent(String message) {
|
||||
dispatcher.fireEvent(new Event(null, message));
|
||||
|
@ -65,9 +65,9 @@ public class CardEventSource implements EventSource<Event>, Serializable {
|
|||
dispatcher.fireEvent(new Event(null, message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearListeners() {
|
||||
dispatcher.clearListeners();
|
||||
}
|
||||
@Override
|
||||
public void clearListeners() {
|
||||
dispatcher.clearListeners();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -64,163 +64,163 @@ import mage.view.CardsView;
|
|||
*/
|
||||
public class CardGrid extends javax.swing.JLayeredPane implements MouseListener, ICardGrid {
|
||||
|
||||
protected CardEventSource cardEventSource = new CardEventSource();
|
||||
protected BigCard bigCard;
|
||||
protected UUID gameId;
|
||||
private Map<UUID, MageCard> cards = new HashMap<UUID, MageCard>();
|
||||
private Dimension cardDimension;
|
||||
protected CardEventSource cardEventSource = new CardEventSource();
|
||||
protected BigCard bigCard;
|
||||
protected UUID gameId;
|
||||
private Map<UUID, MageCard> cards = new HashMap<UUID, MageCard>();
|
||||
private Dimension cardDimension;
|
||||
|
||||
/**
|
||||
* Max amount of cards in card grid for which card images will be drawn.
|
||||
* Done so to solve issue with memory for big piles of cards.
|
||||
*/
|
||||
private static final int MAX_IMAGES = 250;
|
||||
/**
|
||||
* Max amount of cards in card grid for which card images will be drawn.
|
||||
* Done so to solve issue with memory for big piles of cards.
|
||||
*/
|
||||
private static final int MAX_IMAGES = 250;
|
||||
|
||||
public CardGrid() {
|
||||
public CardGrid() {
|
||||
initComponents();
|
||||
setOpaque(false);
|
||||
}
|
||||
|
||||
public void loadCards(CardsView showCards, SortBy sortBy, boolean piles, BigCard bigCard, UUID gameId) {
|
||||
boolean drawImage = showCards.size() < MAX_IMAGES;
|
||||
this.bigCard = bigCard;
|
||||
this.gameId = gameId;
|
||||
for (CardView card: showCards.values()) {
|
||||
if (!cards.containsKey(card.getId())) {
|
||||
addCard(card, bigCard, gameId, drawImage);
|
||||
}
|
||||
}
|
||||
for (Iterator<Entry<UUID, MageCard>> i = cards.entrySet().iterator(); i.hasNext();) {
|
||||
Entry<UUID, MageCard> entry = i.next();
|
||||
if (!showCards.containsKey(entry.getKey())) {
|
||||
removeCardImg(entry.getKey());
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
System.gc();
|
||||
drawCards(sortBy, piles);
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId, boolean drawImage) {
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, cardDimension, gameId, drawImage);
|
||||
cards.put(card.getId(), cardImg);
|
||||
cardImg.addMouseListener(this);
|
||||
add(cardImg);
|
||||
cardImg.update(card);
|
||||
cards.put(card.getId(), cardImg);
|
||||
}
|
||||
|
||||
public void drawCards(SortBy sortBy, boolean piles) {
|
||||
int maxWidth = this.getParent().getWidth();
|
||||
int numColumns = maxWidth / Config.dimensions.frameWidth;
|
||||
int curColumn = 0;
|
||||
int curRow = 0;
|
||||
if (cards.size() > 0) {
|
||||
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
List<MageCard> sortedCards = new ArrayList<MageCard>(cards.values());
|
||||
switch (sortBy) {
|
||||
case NAME:
|
||||
Collections.sort(sortedCards, new CardNameComparator());
|
||||
break;
|
||||
case RARITY:
|
||||
Collections.sort(sortedCards, new CardRarityComparator());
|
||||
break;
|
||||
case COLOR:
|
||||
Collections.sort(sortedCards, new CardColorComparator());
|
||||
break;
|
||||
case CASTING_COST:
|
||||
Collections.sort(sortedCards, new CardCostComparator());
|
||||
break;
|
||||
}
|
||||
MageCard lastCard = null;
|
||||
for (MageCard cardImg: sortedCards) {
|
||||
if (piles) {
|
||||
if (lastCard == null)
|
||||
lastCard = cardImg;
|
||||
switch (sortBy) {
|
||||
case NAME:
|
||||
if (!cardImg.getOriginal().getName().equals(lastCard.getOriginal().getName())) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case RARITY:
|
||||
if (!cardImg.getOriginal().getRarity().equals(lastCard.getOriginal().getRarity())) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case COLOR:
|
||||
if (cardImg.getOriginal().getColor().compareTo(lastCard.getOriginal().getColor()) != 0) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case CASTING_COST:
|
||||
if (cardImg.getOriginal().getConvertedManaCost() != lastCard.getOriginal().getConvertedManaCost()) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20);
|
||||
cardImg.setBounds(rectangle);
|
||||
cardImg.setCardBounds(rectangle.x, rectangle.y, Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
moveToFront(cardImg);
|
||||
curRow++;
|
||||
lastCard = cardImg;
|
||||
}
|
||||
else {
|
||||
rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20);
|
||||
cardImg.setBounds(rectangle);
|
||||
cardImg.setCardBounds(rectangle.x, rectangle.y, Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
moveToFront(cardImg);
|
||||
curColumn++;
|
||||
if (curColumn == numColumns) {
|
||||
curColumn = 0;
|
||||
curRow++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
resizeArea();
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
|
||||
private void removeCardImg(UUID cardId) {
|
||||
for (Component comp: getComponents()) {
|
||||
if (comp instanceof Card) {
|
||||
if (((Card)comp).getCardId().equals(cardId)) {
|
||||
remove(comp);
|
||||
comp = null;
|
||||
}
|
||||
} else if (comp instanceof MageCard) {
|
||||
if (((MageCard)comp).getOriginal().getId().equals(cardId)) {
|
||||
remove(comp);
|
||||
comp = null;
|
||||
}
|
||||
}
|
||||
public void loadCards(CardsView showCards, SortBy sortBy, boolean piles, BigCard bigCard, UUID gameId) {
|
||||
boolean drawImage = showCards.size() < MAX_IMAGES;
|
||||
this.bigCard = bigCard;
|
||||
this.gameId = gameId;
|
||||
for (CardView card: showCards.values()) {
|
||||
if (!cards.containsKey(card.getId())) {
|
||||
addCard(card, bigCard, gameId, drawImage);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Iterator<Entry<UUID, MageCard>> i = cards.entrySet().iterator(); i.hasNext();) {
|
||||
Entry<UUID, MageCard> entry = i.next();
|
||||
if (!showCards.containsKey(entry.getKey())) {
|
||||
removeCardImg(entry.getKey());
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
System.gc();
|
||||
drawCards(sortBy, piles);
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
public void removeCard(UUID cardId) {
|
||||
removeCardImg(cardId);
|
||||
cards.remove(cardId);
|
||||
}
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId, boolean drawImage) {
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, cardDimension, gameId, drawImage);
|
||||
cards.put(card.getId(), cardImg);
|
||||
cardImg.addMouseListener(this);
|
||||
add(cardImg);
|
||||
cardImg.update(card);
|
||||
cards.put(card.getId(), cardImg);
|
||||
}
|
||||
|
||||
public void drawCards(SortBy sortBy, boolean piles) {
|
||||
int maxWidth = this.getParent().getWidth();
|
||||
int numColumns = maxWidth / Config.dimensions.frameWidth;
|
||||
int curColumn = 0;
|
||||
int curRow = 0;
|
||||
if (cards.size() > 0) {
|
||||
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
List<MageCard> sortedCards = new ArrayList<MageCard>(cards.values());
|
||||
switch (sortBy) {
|
||||
case NAME:
|
||||
Collections.sort(sortedCards, new CardNameComparator());
|
||||
break;
|
||||
case RARITY:
|
||||
Collections.sort(sortedCards, new CardRarityComparator());
|
||||
break;
|
||||
case COLOR:
|
||||
Collections.sort(sortedCards, new CardColorComparator());
|
||||
break;
|
||||
case CASTING_COST:
|
||||
Collections.sort(sortedCards, new CardCostComparator());
|
||||
break;
|
||||
}
|
||||
MageCard lastCard = null;
|
||||
for (MageCard cardImg: sortedCards) {
|
||||
if (piles) {
|
||||
if (lastCard == null)
|
||||
lastCard = cardImg;
|
||||
switch (sortBy) {
|
||||
case NAME:
|
||||
if (!cardImg.getOriginal().getName().equals(lastCard.getOriginal().getName())) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case RARITY:
|
||||
if (!cardImg.getOriginal().getRarity().equals(lastCard.getOriginal().getRarity())) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case COLOR:
|
||||
if (cardImg.getOriginal().getColor().compareTo(lastCard.getOriginal().getColor()) != 0) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case CASTING_COST:
|
||||
if (cardImg.getOriginal().getConvertedManaCost() != lastCard.getOriginal().getConvertedManaCost()) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20);
|
||||
cardImg.setBounds(rectangle);
|
||||
cardImg.setCardBounds(rectangle.x, rectangle.y, Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
moveToFront(cardImg);
|
||||
curRow++;
|
||||
lastCard = cardImg;
|
||||
}
|
||||
else {
|
||||
rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20);
|
||||
cardImg.setBounds(rectangle);
|
||||
cardImg.setCardBounds(rectangle.x, rectangle.y, Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
moveToFront(cardImg);
|
||||
curColumn++;
|
||||
if (curColumn == numColumns) {
|
||||
curColumn = 0;
|
||||
curRow++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
resizeArea();
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
|
||||
private void removeCardImg(UUID cardId) {
|
||||
for (Component comp: getComponents()) {
|
||||
if (comp instanceof Card) {
|
||||
if (((Card)comp).getCardId().equals(cardId)) {
|
||||
remove(comp);
|
||||
comp = null;
|
||||
}
|
||||
} else if (comp instanceof MageCard) {
|
||||
if (((MageCard)comp).getOriginal().getId().equals(cardId)) {
|
||||
remove(comp);
|
||||
comp = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeCard(UUID cardId) {
|
||||
removeCardImg(cardId);
|
||||
cards.remove(cardId);
|
||||
}
|
||||
|
||||
|
||||
public void addCardEventListener(Listener<Event> listener) {
|
||||
cardEventSource.addListener(listener);
|
||||
}
|
||||
public void addCardEventListener(Listener<Event> listener) {
|
||||
cardEventSource.addListener(listener);
|
||||
}
|
||||
|
||||
public void clearCardEventListeners() {
|
||||
cardEventSource.clearListeners();
|
||||
}
|
||||
public void clearCardEventListeners() {
|
||||
cardEventSource.clearListeners();
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
@ -247,106 +247,106 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener,
|
|||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (e.getClickCount() == 2 && !e.isConsumed()) {
|
||||
e.consume();
|
||||
Object obj = e.getSource();
|
||||
if (obj instanceof Card) {
|
||||
cardEventSource.doubleClick(((Card)obj).getCardId(), "double-click");
|
||||
} else if (obj instanceof MageCard) {
|
||||
cardEventSource.doubleClick(((MageCard)obj).getOriginal().getId(), "double-click");
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (e.getClickCount() == 2 && !e.isConsumed()) {
|
||||
e.consume();
|
||||
Object obj = e.getSource();
|
||||
if (obj instanceof Card) {
|
||||
cardEventSource.doubleClick(((Card)obj).getCardId(), "double-click");
|
||||
} else if (obj instanceof MageCard) {
|
||||
cardEventSource.doubleClick(((MageCard)obj).getOriginal().getId(), "double-click");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {}
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {}
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {}
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {}
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {}
|
||||
|
||||
private void resizeArea() {
|
||||
private void resizeArea() {
|
||||
Dimension area = new Dimension(0, 0);
|
||||
Dimension size = getPreferredSize();
|
||||
|
||||
for (Component comp: getComponents()) {
|
||||
Rectangle r = comp.getBounds();
|
||||
if (r.x + r.width > area.width) {
|
||||
area.width = r.x + r.width;
|
||||
}
|
||||
if (r.y + r.height > area.height) {
|
||||
area.height = r.y + r.height;
|
||||
}
|
||||
Rectangle r = comp.getBounds();
|
||||
if (r.x + r.width > area.width) {
|
||||
area.width = r.x + r.width;
|
||||
}
|
||||
if (r.y + r.height > area.height) {
|
||||
area.height = r.y + r.height;
|
||||
}
|
||||
}
|
||||
if (size.height != area.height || size.width != area.width) {
|
||||
setPreferredSize(area);
|
||||
setPreferredSize(area);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
@Override
|
||||
public void refresh() {
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
class CardNameComparator implements Comparator<MageCard> {
|
||||
|
||||
@Override
|
||||
public int compare(MageCard o1, MageCard o2) {
|
||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||
}
|
||||
@Override
|
||||
public int compare(MageCard o1, MageCard o2) {
|
||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class CardRarityComparator implements Comparator<MageCard> {
|
||||
|
||||
@Override
|
||||
public int compare(MageCard o1, MageCard o2) {
|
||||
int val = o1.getOriginal().getRarity().compareTo(o2.getOriginal().getRarity());
|
||||
if (val == 0) {
|
||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||
}
|
||||
else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int compare(MageCard o1, MageCard o2) {
|
||||
int val = o1.getOriginal().getRarity().compareTo(o2.getOriginal().getRarity());
|
||||
if (val == 0) {
|
||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||
}
|
||||
else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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()));
|
||||
if (val == 0) {
|
||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||
}
|
||||
else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int compare(MageCard o1, MageCard o2) {
|
||||
int val = Integer.valueOf(o1.getOriginal().getConvertedManaCost()).compareTo(Integer.valueOf(o2.getOriginal().getConvertedManaCost()));
|
||||
if (val == 0) {
|
||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||
}
|
||||
else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class CardColorComparator implements Comparator<MageCard> {
|
||||
|
||||
@Override
|
||||
public int compare(MageCard o1, MageCard o2) {
|
||||
int val = o1.getOriginal().getColor().compareTo(o2.getOriginal().getColor());
|
||||
if (val == 0) {
|
||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||
}
|
||||
else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int compare(MageCard o1, MageCard o2) {
|
||||
int val = o1.getOriginal().getColor().compareTo(o2.getOriginal().getColor());
|
||||
if (val == 0) {
|
||||
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
|
||||
}
|
||||
else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -51,37 +51,37 @@ import java.util.Map.Entry;
|
|||
*/
|
||||
public class Cards extends javax.swing.JPanel {
|
||||
|
||||
private Map<UUID, MageCard> cards = new LinkedHashMap<UUID, MageCard>();
|
||||
private boolean dontDisplayTapped = false;
|
||||
private static final int GAP_X = 5;
|
||||
private Map<UUID, MageCard> cards = new LinkedHashMap<UUID, MageCard>();
|
||||
private boolean dontDisplayTapped = false;
|
||||
private static final int GAP_X = 5;
|
||||
private String zone;
|
||||
|
||||
/**
|
||||
* Defines whether component should be visible whenever there is no objects within.
|
||||
* True by default.
|
||||
*/
|
||||
private boolean isVisibleIfEmpty = true;
|
||||
|
||||
private Dimension cardDimension;
|
||||
/**
|
||||
* Defines whether component should be visible whenever there is no objects within.
|
||||
* True by default.
|
||||
*/
|
||||
private boolean isVisibleIfEmpty = true;
|
||||
|
||||
/** Creates new form Cards */
|
||||
private Dimension cardDimension;
|
||||
|
||||
/** Creates new form Cards */
|
||||
public Cards() {
|
||||
this(false);
|
||||
this(false);
|
||||
}
|
||||
|
||||
public Cards(boolean skipAddingScrollPane) {
|
||||
initComponents(skipAddingScrollPane);
|
||||
public Cards(boolean skipAddingScrollPane) {
|
||||
initComponents(skipAddingScrollPane);
|
||||
setOpaque(false);
|
||||
//cardArea.setOpaque(false);
|
||||
//cardArea.setOpaque(false);
|
||||
setBackgroundColor(new Color(0,0,0,100));
|
||||
if (!skipAddingScrollPane) {
|
||||
jScrollPane1.setOpaque(false);
|
||||
jScrollPane1.getViewport().setOpaque(false);
|
||||
}
|
||||
if (Plugins.getInstance().isCardPluginLoaded()) {
|
||||
cardArea.setLayout(null);
|
||||
jScrollPane1.setOpaque(false);
|
||||
jScrollPane1.getViewport().setOpaque(false);
|
||||
}
|
||||
}
|
||||
if (Plugins.getInstance().isCardPluginLoaded()) {
|
||||
cardArea.setLayout(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets components background color
|
||||
|
@ -91,112 +91,112 @@ public class Cards extends javax.swing.JPanel {
|
|||
cardArea.setOpaque(true);
|
||||
cardArea.setBackground(color);
|
||||
}
|
||||
|
||||
public void setVisibleIfEmpty(boolean isVisibleIfEmpty) {
|
||||
this.isVisibleIfEmpty = isVisibleIfEmpty;
|
||||
}
|
||||
|
||||
public void setBorder(Border border) {
|
||||
super.setBorder(border);
|
||||
if (jScrollPane1 != null) {
|
||||
jScrollPane1.setViewportBorder(border);
|
||||
jScrollPane1.setBorder(border);
|
||||
}
|
||||
}
|
||||
public void setVisibleIfEmpty(boolean isVisibleIfEmpty) {
|
||||
this.isVisibleIfEmpty = isVisibleIfEmpty;
|
||||
}
|
||||
|
||||
public void setBorder(Border border) {
|
||||
super.setBorder(border);
|
||||
if (jScrollPane1 != null) {
|
||||
jScrollPane1.setViewportBorder(border);
|
||||
jScrollPane1.setBorder(border);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean loadCards(SimpleCardsView cardsView, BigCard bigCard, UUID gameId) {
|
||||
return loadCards(CardsViewUtil.convertSimple(cardsView), bigCard, gameId, null);
|
||||
}
|
||||
|
||||
public boolean loadCards(CardsView cardsView, BigCard bigCard, UUID gameId, java.util.List<UUID> order) {
|
||||
boolean changed = false;
|
||||
|
||||
for (Iterator<Entry<UUID, MageCard>> i = cards.entrySet().iterator(); i.hasNext();) {
|
||||
Entry<UUID, MageCard> entry = i.next();
|
||||
if (!cardsView.containsKey(entry.getKey())) {
|
||||
removeCard(entry.getKey());
|
||||
i.remove();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean loadCards(CardsView cardsView, BigCard bigCard, UUID gameId, java.util.List<UUID> order) {
|
||||
boolean changed = false;
|
||||
|
||||
for (Iterator<Entry<UUID, MageCard>> i = cards.entrySet().iterator(); i.hasNext();) {
|
||||
Entry<UUID, MageCard> entry = i.next();
|
||||
if (!cardsView.containsKey(entry.getKey())) {
|
||||
removeCard(entry.getKey());
|
||||
i.remove();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
java.util.List<CardView> orderedList = new ArrayList<CardView>();
|
||||
for (CardView card: cardsView.values()) {
|
||||
orderedList.add(0, card);
|
||||
}
|
||||
|
||||
|
||||
for (CardView card: orderedList) {
|
||||
if (dontDisplayTapped) {
|
||||
if (card instanceof PermanentView) {
|
||||
((PermanentView)card).overrideTapped(false);
|
||||
}
|
||||
}
|
||||
if (card instanceof StackAbilityView) {
|
||||
CardView tmp = ((StackAbilityView)card).getSourceCard();
|
||||
tmp.overrideRules(card.getRules());
|
||||
tmp.setIsAbility(true);
|
||||
tmp.overrideTargets(card.getTargets());
|
||||
tmp.overrideId(card.getId());
|
||||
card = tmp;
|
||||
}
|
||||
if (!cards.containsKey(card.getId())) {
|
||||
addCard(card, bigCard, gameId);
|
||||
changed = true;
|
||||
}
|
||||
cards.get(card.getId()).update(card);
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
layoutCards(getCardDimension(), cards, order);
|
||||
}
|
||||
if (dontDisplayTapped) {
|
||||
if (card instanceof PermanentView) {
|
||||
((PermanentView)card).overrideTapped(false);
|
||||
}
|
||||
}
|
||||
if (card instanceof StackAbilityView) {
|
||||
CardView tmp = ((StackAbilityView)card).getSourceCard();
|
||||
tmp.overrideRules(card.getRules());
|
||||
tmp.setIsAbility(true);
|
||||
tmp.overrideTargets(card.getTargets());
|
||||
tmp.overrideId(card.getId());
|
||||
card = tmp;
|
||||
}
|
||||
if (!cards.containsKey(card.getId())) {
|
||||
addCard(card, bigCard, gameId);
|
||||
changed = true;
|
||||
}
|
||||
cards.get(card.getId()).update(card);
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
layoutCards(getCardDimension(), cards, order);
|
||||
}
|
||||
|
||||
if (!isVisibleIfEmpty) {
|
||||
cardArea.setVisible(cards.size() > 0);
|
||||
cardArea.setVisible(cards.size() > 0);
|
||||
}
|
||||
sizeCards(getCardDimension());
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
|
||||
return changed;
|
||||
}
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
public void sizeCards(Dimension cardDimension) {
|
||||
cardArea.setPreferredSize(new Dimension((int)(cards.size() * (cardDimension.getWidth() + GAP_X)) + 5, (int)(cardDimension.getHeight()) + 20));
|
||||
cardArea.revalidate();
|
||||
cardArea.repaint();
|
||||
cardArea.setPreferredSize(new Dimension((int)(cards.size() * (cardDimension.getWidth() + GAP_X)) + 5, (int)(cardDimension.getHeight()) + 20));
|
||||
cardArea.revalidate();
|
||||
cardArea.repaint();
|
||||
}
|
||||
|
||||
private Dimension getCardDimension() {
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
return cardDimension;
|
||||
}
|
||||
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId) {
|
||||
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, getCardDimension(), gameId, true);
|
||||
if (zone != null) cardImg.setZone(zone);
|
||||
cards.put(card.getId(), cardImg);
|
||||
cardArea.add(cardImg);
|
||||
}
|
||||
|
||||
private void removeCard(UUID cardId) {
|
||||
for (Component comp: cardArea.getComponents()) {
|
||||
if (comp instanceof Card) {
|
||||
if (((Card)comp).getCardId().equals(cardId)) {
|
||||
cardArea.remove(comp);
|
||||
}
|
||||
} else if (comp instanceof MageCard) {
|
||||
if (((MageCard)comp).getOriginal().getId().equals(cardId)) {
|
||||
cardArea.remove(comp);
|
||||
}
|
||||
}
|
||||
private Dimension getCardDimension() {
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
}
|
||||
|
||||
private void layoutCards(Dimension dimension, Map<UUID, MageCard> cards, java.util.List<UUID> order) {
|
||||
if (Plugins.getInstance().isCardPluginLoaded()) {
|
||||
int dx = GAP_X;
|
||||
return cardDimension;
|
||||
}
|
||||
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId) {
|
||||
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, getCardDimension(), gameId, true);
|
||||
if (zone != null) cardImg.setZone(zone);
|
||||
cards.put(card.getId(), cardImg);
|
||||
cardArea.add(cardImg);
|
||||
}
|
||||
|
||||
private void removeCard(UUID cardId) {
|
||||
for (Component comp: cardArea.getComponents()) {
|
||||
if (comp instanceof Card) {
|
||||
if (((Card)comp).getCardId().equals(cardId)) {
|
||||
cardArea.remove(comp);
|
||||
}
|
||||
} else if (comp instanceof MageCard) {
|
||||
if (((MageCard)comp).getOriginal().getId().equals(cardId)) {
|
||||
cardArea.remove(comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void layoutCards(Dimension dimension, Map<UUID, MageCard> cards, java.util.List<UUID> order) {
|
||||
if (Plugins.getInstance().isCardPluginLoaded()) {
|
||||
int dx = GAP_X;
|
||||
if (order != null) {
|
||||
for (UUID cardId : order) {
|
||||
MageCard card = cards.get(cardId);
|
||||
|
@ -215,8 +215,8 @@ public class Cards extends javax.swing.JPanel {
|
|||
dx += dimension.width + GAP_X;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
@ -229,17 +229,17 @@ public class Cards extends javax.swing.JPanel {
|
|||
setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0, 0)));
|
||||
setLayout(new java.awt.BorderLayout());
|
||||
|
||||
cardArea = new javax.swing.JPanel();
|
||||
cardArea.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 0, 0));
|
||||
cardArea = new javax.swing.JPanel();
|
||||
cardArea.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 0, 0));
|
||||
|
||||
if (skipAddingScrollPane) {
|
||||
add(cardArea, java.awt.BorderLayout.CENTER);
|
||||
} else{
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
jScrollPane1.setViewportView(cardArea);
|
||||
jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
|
||||
add(jScrollPane1, java.awt.BorderLayout.CENTER);
|
||||
}
|
||||
if (skipAddingScrollPane) {
|
||||
add(cardArea, java.awt.BorderLayout.CENTER);
|
||||
} else{
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
jScrollPane1.setViewportView(cardArea);
|
||||
jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
|
||||
add(jScrollPane1, java.awt.BorderLayout.CENTER);
|
||||
}
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
|
@ -249,23 +249,23 @@ public class Cards extends javax.swing.JPanel {
|
|||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
public void setDontDisplayTapped(boolean dontDisplayTapped) {
|
||||
this.dontDisplayTapped = dontDisplayTapped;
|
||||
}
|
||||
|
||||
public void setHScrollSpeed(int unitIncrement) {
|
||||
if (jScrollPane1 != null) {
|
||||
jScrollPane1.getHorizontalScrollBar().setUnitIncrement(unitIncrement);
|
||||
}
|
||||
}
|
||||
|
||||
public void setVScrollSpeed(int unitIncrement) {
|
||||
if (jScrollPane1 != null) {
|
||||
jScrollPane1.getVerticalScrollBar().setUnitIncrement(unitIncrement);
|
||||
}
|
||||
this.dontDisplayTapped = dontDisplayTapped;
|
||||
}
|
||||
|
||||
public void setCardDimension(Dimension dimension) {
|
||||
this.cardDimension = dimension;
|
||||
public void setHScrollSpeed(int unitIncrement) {
|
||||
if (jScrollPane1 != null) {
|
||||
jScrollPane1.getHorizontalScrollBar().setUnitIncrement(unitIncrement);
|
||||
}
|
||||
}
|
||||
|
||||
public void setVScrollSpeed(int unitIncrement) {
|
||||
if (jScrollPane1 != null) {
|
||||
jScrollPane1.getVerticalScrollBar().setUnitIncrement(unitIncrement);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCardDimension(Dimension dimension) {
|
||||
this.cardDimension = dimension;
|
||||
layoutCards(cardDimension, cards, null);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,69 +63,69 @@ import java.util.UUID;
|
|||
*/
|
||||
public class CardsList extends javax.swing.JPanel implements MouseListener, ICardGrid {
|
||||
|
||||
protected CardEventSource cardEventSource = new CardEventSource();
|
||||
protected CardEventSource cardEventSource = new CardEventSource();
|
||||
private Dimension cardDimension;
|
||||
private CardsView cards;
|
||||
protected BigCard bigCard;
|
||||
protected UUID gameId;
|
||||
private CardsView cards;
|
||||
protected BigCard bigCard;
|
||||
protected UUID gameId;
|
||||
|
||||
private TableModel mainModel;
|
||||
private JTable mainTable;
|
||||
private ICardGrid currentView;
|
||||
private TableModel mainModel;
|
||||
private JTable mainTable;
|
||||
private ICardGrid currentView;
|
||||
|
||||
/** Creates new form Cards */
|
||||
public CardsList() {
|
||||
initComponents();
|
||||
makeTransparent();
|
||||
initListViewComponents();
|
||||
currentView = mainModel; // by default we use List View
|
||||
initListViewComponents();
|
||||
currentView = mainModel; // by default we use List View
|
||||
}
|
||||
|
||||
public void makeTransparent() {
|
||||
jScrollPane1.setOpaque(false);
|
||||
public void makeTransparent() {
|
||||
jScrollPane1.setOpaque(false);
|
||||
cardArea.setOpaque(false);
|
||||
jScrollPane1.getViewport().setOpaque(false);
|
||||
cbSortBy.setModel(new DefaultComboBoxModel(SortBy.values()));
|
||||
}
|
||||
cbSortBy.setModel(new DefaultComboBoxModel(SortBy.values()));
|
||||
}
|
||||
|
||||
public void initListViewComponents() {
|
||||
mainTable = new JTable();
|
||||
public void initListViewComponents() {
|
||||
mainTable = new JTable();
|
||||
|
||||
mainModel = new TableModel();
|
||||
mainModel.addListeners(mainTable);
|
||||
mainModel = new TableModel();
|
||||
mainModel.addListeners(mainTable);
|
||||
|
||||
mainTable.setModel(mainModel);
|
||||
mainTable.setForeground(Color.white);
|
||||
DefaultTableCellRenderer myRenderer = (DefaultTableCellRenderer) mainTable.getDefaultRenderer(String.class);
|
||||
myRenderer.setBackground(new Color(0, 0, 0, 100));
|
||||
mainTable.getColumnModel().getColumn(0).setMaxWidth(25);
|
||||
mainTable.getColumnModel().getColumn(0).setPreferredWidth(25);
|
||||
mainTable.getColumnModel().getColumn(1).setPreferredWidth(110);
|
||||
mainTable.getColumnModel().getColumn(2).setPreferredWidth(90);
|
||||
mainTable.getColumnModel().getColumn(3).setPreferredWidth(50);
|
||||
mainTable.getColumnModel().getColumn(4).setPreferredWidth(170);
|
||||
mainTable.getColumnModel().getColumn(5).setPreferredWidth(30);
|
||||
mainTable.getColumnModel().getColumn(6).setPreferredWidth(15);
|
||||
mainTable.getColumnModel().getColumn(7).setPreferredWidth(15);
|
||||
mainTable.setForeground(Color.white);
|
||||
DefaultTableCellRenderer myRenderer = (DefaultTableCellRenderer) mainTable.getDefaultRenderer(String.class);
|
||||
myRenderer.setBackground(new Color(0, 0, 0, 100));
|
||||
mainTable.getColumnModel().getColumn(0).setMaxWidth(25);
|
||||
mainTable.getColumnModel().getColumn(0).setPreferredWidth(25);
|
||||
mainTable.getColumnModel().getColumn(1).setPreferredWidth(110);
|
||||
mainTable.getColumnModel().getColumn(2).setPreferredWidth(90);
|
||||
mainTable.getColumnModel().getColumn(3).setPreferredWidth(50);
|
||||
mainTable.getColumnModel().getColumn(4).setPreferredWidth(170);
|
||||
mainTable.getColumnModel().getColumn(5).setPreferredWidth(30);
|
||||
mainTable.getColumnModel().getColumn(6).setPreferredWidth(15);
|
||||
mainTable.getColumnModel().getColumn(7).setPreferredWidth(15);
|
||||
|
||||
jScrollPane1.setViewportView(mainTable);
|
||||
jScrollPane1.setViewportView(mainTable);
|
||||
|
||||
mainTable.setOpaque(false);
|
||||
mainTable.setOpaque(false);
|
||||
|
||||
cbSortBy.setEnabled(false);
|
||||
chkPiles.setEnabled(false);
|
||||
cbSortBy.setEnabled(false);
|
||||
chkPiles.setEnabled(false);
|
||||
|
||||
mainTable.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.getClickCount() == 2 && !e.isConsumed()) {
|
||||
e.consume();
|
||||
mainTable.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.getClickCount() == 2 && !e.isConsumed()) {
|
||||
e.consume();
|
||||
handleDoubleClick();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mainModel.setUpdateCountsCallback(new UpdateCountsCallback(lblCount, lblCreatureCount, lblLandCount));
|
||||
}
|
||||
mainModel.setUpdateCountsCallback(new UpdateCountsCallback(lblCount, lblCreatureCount, lblLandCount));
|
||||
}
|
||||
|
||||
public void handleDoubleClick() {
|
||||
if (mainTable.getSelectedRowCount() > 0) {
|
||||
|
@ -138,162 +138,162 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
|||
}
|
||||
}
|
||||
|
||||
public ICardGrid getMainModel() {
|
||||
return mainModel;
|
||||
}
|
||||
|
||||
public List<Integer> asList(final int[] is) {
|
||||
List<Integer> list = new ArrayList<Integer>();
|
||||
for (int i : is) list.add(i);
|
||||
return list;
|
||||
public ICardGrid getMainModel() {
|
||||
return mainModel;
|
||||
}
|
||||
|
||||
public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId) {
|
||||
this.cards = showCards;
|
||||
this.bigCard = bigCard;
|
||||
this.gameId = gameId;
|
||||
currentView.loadCards(showCards, null, false, bigCard, gameId);
|
||||
//loadCards(showCards, null, false, bigCard, gameId);
|
||||
}
|
||||
public List<Integer> asList(final int[] is) {
|
||||
List<Integer> list = new ArrayList<Integer>();
|
||||
for (int i : is) list.add(i);
|
||||
return list;
|
||||
}
|
||||
|
||||
private void redrawCards() {
|
||||
if (cards == null) cards = new CardsView();
|
||||
currentView.loadCards(cards, null, false, bigCard, gameId);
|
||||
}
|
||||
public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId) {
|
||||
this.cards = showCards;
|
||||
this.bigCard = bigCard;
|
||||
this.gameId = gameId;
|
||||
currentView.loadCards(showCards, null, false, bigCard, gameId);
|
||||
//loadCards(showCards, null, false, bigCard, gameId);
|
||||
}
|
||||
|
||||
public void drawCards(SortBy sortBy, boolean piles) {
|
||||
int maxWidth = this.getParent().getWidth();
|
||||
int numColumns = maxWidth / Config.dimensions.frameWidth;
|
||||
int curColumn = 0;
|
||||
int curRow = 0;
|
||||
int landCount = 0;
|
||||
int creatureCount = 0;
|
||||
//FIXME: why we remove all cards? for performance it's better to merge changes
|
||||
// as it is already done in ListView
|
||||
cardArea.removeAll();
|
||||
if (cards != null && cards.size() > 0) {
|
||||
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
int count = 0;
|
||||
List<CardView> sortedCards = new ArrayList<CardView>(cards.values());
|
||||
switch (sortBy) {
|
||||
case NAME:
|
||||
Collections.sort(sortedCards, new CardViewNameComparator());
|
||||
break;
|
||||
case RARITY:
|
||||
Collections.sort(sortedCards, new CardViewRarityComparator());
|
||||
break;
|
||||
case COLOR:
|
||||
Collections.sort(sortedCards, new CardViewColorComparator());
|
||||
break;
|
||||
case CASTING_COST:
|
||||
Collections.sort(sortedCards, new CardViewCostComparator());
|
||||
break;
|
||||
}
|
||||
CardView lastCard = null;
|
||||
for (CardView card: sortedCards) {
|
||||
if (chkPiles.isSelected()) {
|
||||
if (lastCard == null)
|
||||
lastCard = card;
|
||||
switch (sortBy) {
|
||||
case NAME:
|
||||
if (!card.getName().equals(lastCard.getName())) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case RARITY:
|
||||
if (!card.getRarity().equals(lastCard.getRarity())) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case COLOR:
|
||||
if (card.getColor().compareTo(lastCard.getColor()) != 0) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case CASTING_COST:
|
||||
if (card.getConvertedManaCost() != lastCard.getConvertedManaCost()) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20);
|
||||
addCard(card, bigCard, gameId, rectangle);
|
||||
if (card.getCardTypes().contains(CardType.LAND))
|
||||
landCount++;
|
||||
if (card.getCardTypes().contains(CardType.CREATURE))
|
||||
creatureCount++;
|
||||
curRow++;
|
||||
lastCard = card;
|
||||
}
|
||||
else {
|
||||
rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20);
|
||||
addCard(card, bigCard, gameId, rectangle);
|
||||
if (card.getCardTypes().contains(CardType.LAND))
|
||||
landCount++;
|
||||
if (card.getCardTypes().contains(CardType.CREATURE))
|
||||
creatureCount++;
|
||||
curColumn++;
|
||||
if (curColumn == numColumns) {
|
||||
curColumn = 0;
|
||||
curRow++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int count = cards != null ? cards.size() : 0;
|
||||
this.lblCount.setText("Count: " + Integer.toString(count));
|
||||
this.lblCreatureCount.setText("Creatures: " + Integer.toString(creatureCount));
|
||||
this.lblLandCount.setText("Lands: " + Integer.toString(landCount));
|
||||
cardArea.setPreferredSize(new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight + 200));
|
||||
cardArea.revalidate();
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
this.setVisible(true);
|
||||
}
|
||||
private void redrawCards() {
|
||||
if (cards == null) cards = new CardsView();
|
||||
currentView.loadCards(cards, null, false, bigCard, gameId);
|
||||
}
|
||||
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle) {
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, cardDimension, gameId, true);
|
||||
cardImg.setBounds(rectangle);
|
||||
cardArea.add(cardImg);
|
||||
cardArea.moveToFront(cardImg);
|
||||
cardImg.update(card);
|
||||
cardImg.addMouseListener(this);
|
||||
cardImg.setCardBounds(rectangle.x, rectangle.y, Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
|
||||
public void addCardEventListener(Listener<Event> listener) {
|
||||
cardEventSource.addListener(listener);
|
||||
mainModel.addCardEventListener(listener);
|
||||
}
|
||||
public void drawCards(SortBy sortBy, boolean piles) {
|
||||
int maxWidth = this.getParent().getWidth();
|
||||
int numColumns = maxWidth / Config.dimensions.frameWidth;
|
||||
int curColumn = 0;
|
||||
int curRow = 0;
|
||||
int landCount = 0;
|
||||
int creatureCount = 0;
|
||||
//FIXME: why we remove all cards? for performance it's better to merge changes
|
||||
// as it is already done in ListView
|
||||
cardArea.removeAll();
|
||||
if (cards != null && cards.size() > 0) {
|
||||
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
int count = 0;
|
||||
List<CardView> sortedCards = new ArrayList<CardView>(cards.values());
|
||||
switch (sortBy) {
|
||||
case NAME:
|
||||
Collections.sort(sortedCards, new CardViewNameComparator());
|
||||
break;
|
||||
case RARITY:
|
||||
Collections.sort(sortedCards, new CardViewRarityComparator());
|
||||
break;
|
||||
case COLOR:
|
||||
Collections.sort(sortedCards, new CardViewColorComparator());
|
||||
break;
|
||||
case CASTING_COST:
|
||||
Collections.sort(sortedCards, new CardViewCostComparator());
|
||||
break;
|
||||
}
|
||||
CardView lastCard = null;
|
||||
for (CardView card: sortedCards) {
|
||||
if (chkPiles.isSelected()) {
|
||||
if (lastCard == null)
|
||||
lastCard = card;
|
||||
switch (sortBy) {
|
||||
case NAME:
|
||||
if (!card.getName().equals(lastCard.getName())) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case RARITY:
|
||||
if (!card.getRarity().equals(lastCard.getRarity())) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case COLOR:
|
||||
if (card.getColor().compareTo(lastCard.getColor()) != 0) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
case CASTING_COST:
|
||||
if (card.getConvertedManaCost() != lastCard.getConvertedManaCost()) {
|
||||
curColumn++;
|
||||
curRow = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20);
|
||||
addCard(card, bigCard, gameId, rectangle);
|
||||
if (card.getCardTypes().contains(CardType.LAND))
|
||||
landCount++;
|
||||
if (card.getCardTypes().contains(CardType.CREATURE))
|
||||
creatureCount++;
|
||||
curRow++;
|
||||
lastCard = card;
|
||||
}
|
||||
else {
|
||||
rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20);
|
||||
addCard(card, bigCard, gameId, rectangle);
|
||||
if (card.getCardTypes().contains(CardType.LAND))
|
||||
landCount++;
|
||||
if (card.getCardTypes().contains(CardType.CREATURE))
|
||||
creatureCount++;
|
||||
curColumn++;
|
||||
if (curColumn == numColumns) {
|
||||
curColumn = 0;
|
||||
curRow++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int count = cards != null ? cards.size() : 0;
|
||||
this.lblCount.setText("Count: " + Integer.toString(count));
|
||||
this.lblCreatureCount.setText("Creatures: " + Integer.toString(creatureCount));
|
||||
this.lblLandCount.setText("Lands: " + Integer.toString(landCount));
|
||||
cardArea.setPreferredSize(new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight + 200));
|
||||
cardArea.revalidate();
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
public void drawCards(SortBy sortBy) {
|
||||
drawCards(sortBy, false);
|
||||
}
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle) {
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, cardDimension, gameId, true);
|
||||
cardImg.setBounds(rectangle);
|
||||
cardArea.add(cardImg);
|
||||
cardArea.moveToFront(cardImg);
|
||||
cardImg.update(card);
|
||||
cardImg.addMouseListener(this);
|
||||
cardImg.setCardBounds(rectangle.x, rectangle.y, Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCards(CardsView showCards, SortBy sortBy, boolean piles, BigCard bigCard, UUID gameId) {
|
||||
cards = showCards;
|
||||
this.bigCard = bigCard;
|
||||
this.gameId = gameId;
|
||||
drawCards((SortBy) cbSortBy.getSelectedItem());
|
||||
}
|
||||
public void addCardEventListener(Listener<Event> listener) {
|
||||
cardEventSource.addListener(listener);
|
||||
mainModel.addCardEventListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
redrawCards();
|
||||
}
|
||||
public void drawCards(SortBy sortBy) {
|
||||
drawCards(sortBy, false);
|
||||
}
|
||||
|
||||
public void clearCardEventListeners() {
|
||||
cardEventSource.clearListeners();
|
||||
mainModel.clearCardEventListeners();
|
||||
}
|
||||
@Override
|
||||
public void loadCards(CardsView showCards, SortBy sortBy, boolean piles, BigCard bigCard, UUID gameId) {
|
||||
cards = showCards;
|
||||
this.bigCard = bigCard;
|
||||
this.gameId = gameId;
|
||||
drawCards((SortBy) cbSortBy.getSelectedItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
redrawCards();
|
||||
}
|
||||
|
||||
public void clearCardEventListeners() {
|
||||
cardEventSource.clearListeners();
|
||||
mainModel.clearCardEventListeners();
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
@ -322,10 +322,10 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
|||
|
||||
cbSortBy.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"}));
|
||||
cbSortBy.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
cbSortByActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
cbSortByActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
lblCount.setText("Card Count");
|
||||
|
||||
|
@ -351,17 +351,17 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
|||
jToggleCardView.setOpaque(true);
|
||||
jToggleCardView.setPreferredSize(new java.awt.Dimension(77, 21));
|
||||
jToggleCardView.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jToggleCardViewActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jToggleCardViewActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
chkPiles.setText("Piles");
|
||||
chkPiles.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
chkPilesActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
chkPilesActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
||||
jPanel1.setLayout(jPanel1Layout);
|
||||
|
@ -410,33 +410,33 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
|||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void cbSortByActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbSortByActionPerformed
|
||||
drawCards((SortBy) cbSortBy.getSelectedItem());
|
||||
}//GEN-LAST:event_cbSortByActionPerformed
|
||||
private void cbSortByActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbSortByActionPerformed
|
||||
drawCards((SortBy) cbSortBy.getSelectedItem());
|
||||
}//GEN-LAST:event_cbSortByActionPerformed
|
||||
|
||||
private void chkPilesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkPilesActionPerformed
|
||||
drawCards((SortBy) cbSortBy.getSelectedItem());
|
||||
}//GEN-LAST:event_chkPilesActionPerformed
|
||||
private void chkPilesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkPilesActionPerformed
|
||||
drawCards((SortBy) cbSortBy.getSelectedItem());
|
||||
}//GEN-LAST:event_chkPilesActionPerformed
|
||||
|
||||
private void jToggleListViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleListViewActionPerformed
|
||||
jToggleCardView.setSelected(false);
|
||||
currentView = mainModel;
|
||||
jScrollPane1.setViewportView(mainTable);
|
||||
cbSortBy.setEnabled(false);
|
||||
chkPiles.setEnabled(false);
|
||||
//drawCards((SortBy) cbSortBy.getSelectedItem());
|
||||
redrawCards();
|
||||
}//GEN-LAST:event_jToggleListViewActionPerformed
|
||||
private void jToggleListViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleListViewActionPerformed
|
||||
jToggleCardView.setSelected(false);
|
||||
currentView = mainModel;
|
||||
jScrollPane1.setViewportView(mainTable);
|
||||
cbSortBy.setEnabled(false);
|
||||
chkPiles.setEnabled(false);
|
||||
//drawCards((SortBy) cbSortBy.getSelectedItem());
|
||||
redrawCards();
|
||||
}//GEN-LAST:event_jToggleListViewActionPerformed
|
||||
|
||||
private void jToggleCardViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleCardViewActionPerformed
|
||||
jToggleListView.setSelected(false);
|
||||
currentView = this;
|
||||
jScrollPane1.setViewportView(cardArea);
|
||||
cbSortBy.setEnabled(true);
|
||||
chkPiles.setEnabled(true);
|
||||
//drawCards((SortBy) cbSortBy.getSelectedItem());
|
||||
redrawCards();
|
||||
}//GEN-LAST:event_jToggleCardViewActionPerformed
|
||||
private void jToggleCardViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleCardViewActionPerformed
|
||||
jToggleListView.setSelected(false);
|
||||
currentView = this;
|
||||
jScrollPane1.setViewportView(cardArea);
|
||||
cbSortBy.setEnabled(true);
|
||||
chkPiles.setEnabled(true);
|
||||
//drawCards((SortBy) cbSortBy.getSelectedItem());
|
||||
redrawCards();
|
||||
}//GEN-LAST:event_jToggleCardViewActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JLayeredPane cardArea;
|
||||
|
@ -451,42 +451,42 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
|
|||
private javax.swing.JLabel lblLandCount;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
}
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.getClickCount() == 2 && !e.isConsumed()) {
|
||||
e.consume();
|
||||
Object obj = e.getSource();
|
||||
if (obj instanceof Card) {
|
||||
if (e.isShiftDown())
|
||||
cardEventSource.shiftDoubleClick(((Card)obj).getCardId(), "shift-double-click");
|
||||
else
|
||||
cardEventSource.doubleClick(((Card)obj).getCardId(), "double-click");
|
||||
} else if (obj instanceof MageCard) {
|
||||
if (e.isShiftDown())
|
||||
cardEventSource.shiftDoubleClick(((MageCard)obj).getOriginal().getId(), "shift-double-click");
|
||||
else
|
||||
cardEventSource.doubleClick(((MageCard)obj).getOriginal().getId(), "double-click");
|
||||
}
|
||||
}
|
||||
}
|
||||
e.consume();
|
||||
Object obj = e.getSource();
|
||||
if (obj instanceof Card) {
|
||||
if (e.isShiftDown())
|
||||
cardEventSource.shiftDoubleClick(((Card)obj).getCardId(), "shift-double-click");
|
||||
else
|
||||
cardEventSource.doubleClick(((Card)obj).getCardId(), "double-click");
|
||||
} else if (obj instanceof MageCard) {
|
||||
if (e.isShiftDown())
|
||||
cardEventSource.shiftDoubleClick(((MageCard)obj).getOriginal().getId(), "shift-double-click");
|
||||
else
|
||||
cardEventSource.doubleClick(((MageCard)obj).getOriginal().getId(), "double-click");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
}
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
}
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void setDisplayNoCopies(boolean value) {
|
||||
mainModel.setDisplayNoCopies(value);
|
||||
}
|
||||
public void setDisplayNoCopies(boolean value) {
|
||||
mainModel.setDisplayNoCopies(value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,20 +17,20 @@ import org.apache.log4j.Logger;
|
|||
* @author nantuko
|
||||
*/
|
||||
public class CardsStorage {
|
||||
private static final Logger log = Logger.getLogger(CardsStorage.class);
|
||||
|
||||
private static final List<Card> allCards;
|
||||
private static final Set<Card> nonBasicLandCards;
|
||||
private static final List<String> setCodes;
|
||||
private static Map<String, Integer> ratings;
|
||||
private static Integer min = Integer.MAX_VALUE, max = 0;
|
||||
private static List<Card> notImplementedCards;
|
||||
private static final Logger log = Logger.getLogger(CardsStorage.class);
|
||||
|
||||
/**
|
||||
* Rating that is given for new cards.
|
||||
* Ratings are in [1,10] range, so setting it high will make new cards appear more often.
|
||||
*/
|
||||
private static final int DEFAULT_NOT_RATED_CARD_RATING = 6;
|
||||
private static final List<Card> allCards;
|
||||
private static final Set<Card> nonBasicLandCards;
|
||||
private static final List<String> setCodes;
|
||||
private static Map<String, Integer> ratings;
|
||||
private static Integer min = Integer.MAX_VALUE, max = 0;
|
||||
private static List<Card> notImplementedCards;
|
||||
|
||||
/**
|
||||
* Rating that is given for new cards.
|
||||
* Ratings are in [1,10] range, so setting it high will make new cards appear more often.
|
||||
*/
|
||||
private static final int DEFAULT_NOT_RATED_CARD_RATING = 6;
|
||||
|
||||
static {
|
||||
allCards = new ArrayList<Card>();
|
||||
|
@ -55,134 +55,134 @@ public class CardsStorage {
|
|||
}
|
||||
}
|
||||
|
||||
public static List<Card> getAllCards() {
|
||||
return allCards;
|
||||
}
|
||||
public static List<Card> getAllCards() {
|
||||
return allCards;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cards from card pool starting from start index and ending with end index.
|
||||
* Can filter cards by set (if parameter is not null).
|
||||
*
|
||||
* @param start
|
||||
* @param end
|
||||
* @param set Cards set code. Can be null.
|
||||
* @param onlyImplemented return only implemented cards
|
||||
* @return
|
||||
*/
|
||||
public static List<Card> getAllCards(int start, int end, String set, boolean onlyImplemented) {
|
||||
List<Card> cards = new ArrayList<Card>();
|
||||
List<Card> pool;
|
||||
if (set == null) {
|
||||
pool = allCards;
|
||||
} else {
|
||||
pool = new ArrayList<Card>();
|
||||
for (Card card : allCards) {
|
||||
if (card.getExpansionSetCode().equals(set)) {
|
||||
pool.add(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!onlyImplemented) {
|
||||
for (Card card : getNotImplementedCards()) {
|
||||
if (card.getExpansionSetCode().equals(set)) {
|
||||
pool.add(card);
|
||||
}
|
||||
}
|
||||
Collections.sort(pool, new CardComparator());
|
||||
}
|
||||
for (int i = start; i < Math.min(end + 1, pool.size()); i++) {
|
||||
cards.add(pool.get(i));
|
||||
}
|
||||
return cards;
|
||||
}
|
||||
/**
|
||||
* Get cards from card pool starting from start index and ending with end index.
|
||||
* Can filter cards by set (if parameter is not null).
|
||||
*
|
||||
* @param start
|
||||
* @param end
|
||||
* @param set Cards set code. Can be null.
|
||||
* @param onlyImplemented return only implemented cards
|
||||
* @return
|
||||
*/
|
||||
public static List<Card> getAllCards(int start, int end, String set, boolean onlyImplemented) {
|
||||
List<Card> cards = new ArrayList<Card>();
|
||||
List<Card> pool;
|
||||
if (set == null) {
|
||||
pool = allCards;
|
||||
} else {
|
||||
pool = new ArrayList<Card>();
|
||||
for (Card card : allCards) {
|
||||
if (card.getExpansionSetCode().equals(set)) {
|
||||
pool.add(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!onlyImplemented) {
|
||||
for (Card card : getNotImplementedCards()) {
|
||||
if (card.getExpansionSetCode().equals(set)) {
|
||||
pool.add(card);
|
||||
}
|
||||
}
|
||||
Collections.sort(pool, new CardComparator());
|
||||
}
|
||||
for (int i = start; i < Math.min(end + 1, pool.size()); i++) {
|
||||
cards.add(pool.get(i));
|
||||
}
|
||||
return cards;
|
||||
}
|
||||
|
||||
public static int getCardsCount() {
|
||||
return allCards.size();
|
||||
}
|
||||
public static int getCardsCount() {
|
||||
return allCards.size();
|
||||
}
|
||||
|
||||
public static List<String> getSetCodes() {
|
||||
return setCodes;
|
||||
}
|
||||
|
||||
public static Set<Card> getNonBasicLandCards() {
|
||||
return nonBasicLandCards;
|
||||
}
|
||||
public static Set<Card> getNonBasicLandCards() {
|
||||
return nonBasicLandCards;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return rating of a card: 1-10.
|
||||
*
|
||||
* @param card
|
||||
* @return
|
||||
*/
|
||||
public static int rateCard(Card card) {
|
||||
if (ratings == null) {
|
||||
readRatings();
|
||||
}
|
||||
if (ratings.containsKey(card.getName())) {
|
||||
int r = ratings.get(card.getName());
|
||||
float f = 10.0f * (r - min) / (max - min);
|
||||
// normalize to [1..10]
|
||||
return (int) Math.round(f);
|
||||
}
|
||||
return DEFAULT_NOT_RATED_CARD_RATING;
|
||||
}
|
||||
/**
|
||||
* Return rating of a card: 1-10.
|
||||
*
|
||||
* @param card
|
||||
* @return
|
||||
*/
|
||||
public static int rateCard(Card card) {
|
||||
if (ratings == null) {
|
||||
readRatings();
|
||||
}
|
||||
if (ratings.containsKey(card.getName())) {
|
||||
int r = ratings.get(card.getName());
|
||||
float f = 10.0f * (r - min) / (max - min);
|
||||
// normalize to [1..10]
|
||||
return (int) Math.round(f);
|
||||
}
|
||||
return DEFAULT_NOT_RATED_CARD_RATING;
|
||||
}
|
||||
|
||||
private synchronized static void readRatings() {
|
||||
if (ratings == null) {
|
||||
ratings = new HashMap<String, Integer>();
|
||||
String filename = "/ratings.txt";
|
||||
try {
|
||||
InputStream is = CardsStorage.class.getResourceAsStream(filename);
|
||||
Scanner scanner = new Scanner(is);
|
||||
while (scanner.hasNextLine()) {
|
||||
String line = scanner.nextLine();
|
||||
String[] s = line.split(":");
|
||||
if (s.length == 2) {
|
||||
Integer rating = Integer.parseInt(s[0].trim());
|
||||
String name = s[1].trim();
|
||||
if (rating > max) {
|
||||
max = rating;
|
||||
}
|
||||
if (rating < min) {
|
||||
min = rating;
|
||||
}
|
||||
ratings.put(name, rating);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
ratings.clear(); // no rating available on exception
|
||||
}
|
||||
}
|
||||
}
|
||||
private synchronized static void readRatings() {
|
||||
if (ratings == null) {
|
||||
ratings = new HashMap<String, Integer>();
|
||||
String filename = "/ratings.txt";
|
||||
try {
|
||||
InputStream is = CardsStorage.class.getResourceAsStream(filename);
|
||||
Scanner scanner = new Scanner(is);
|
||||
while (scanner.hasNextLine()) {
|
||||
String line = scanner.nextLine();
|
||||
String[] s = line.split(":");
|
||||
if (s.length == 2) {
|
||||
Integer rating = Integer.parseInt(s[0].trim());
|
||||
String name = s[1].trim();
|
||||
if (rating > max) {
|
||||
max = rating;
|
||||
}
|
||||
if (rating < min) {
|
||||
min = rating;
|
||||
}
|
||||
ratings.put(name, rating);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
ratings.clear(); // no rating available on exception
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of not implemented cards.
|
||||
* Used in collection viewer to show what cards need to be done for the latest set.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static List<Card> getNotImplementedCards() {
|
||||
List<Card> cards = new ArrayList<Card>();
|
||||
if (notImplementedCards == null) {
|
||||
if (allCards.isEmpty()) {
|
||||
return cards;
|
||||
}
|
||||
/**
|
||||
* Get list of not implemented cards.
|
||||
* Used in collection viewer to show what cards need to be done for the latest set.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static List<Card> getNotImplementedCards() {
|
||||
List<Card> cards = new ArrayList<Card>();
|
||||
if (notImplementedCards == null) {
|
||||
if (allCards.isEmpty()) {
|
||||
return cards;
|
||||
}
|
||||
|
||||
Set<String> names = new HashSet<String>();
|
||||
for (Card card : allCards) {
|
||||
names.add(card.getExpansionSetCode() + card.getName());
|
||||
}
|
||||
Set<String> names = new HashSet<String>();
|
||||
for (Card card : allCards) {
|
||||
names.add(card.getExpansionSetCode() + card.getName());
|
||||
}
|
||||
|
||||
readUnimplemented("ZEN", "/zen.txt", names, cards);
|
||||
readUnimplemented("WWK", "/wwk.txt", names, cards);
|
||||
readUnimplemented("ROE", "/roe.txt", names, cards);
|
||||
readUnimplemented("AVR", "/avr.txt", names, cards);
|
||||
readUnimplemented("ZEN", "/zen.txt", names, cards);
|
||||
readUnimplemented("WWK", "/wwk.txt", names, cards);
|
||||
readUnimplemented("ROE", "/roe.txt", names, cards);
|
||||
readUnimplemented("AVR", "/avr.txt", names, cards);
|
||||
|
||||
names.clear();
|
||||
}
|
||||
return cards;
|
||||
}
|
||||
names.clear();
|
||||
}
|
||||
return cards;
|
||||
}
|
||||
|
||||
private static final class UnimplementedCardImpl extends CardImpl {
|
||||
|
||||
|
@ -268,24 +268,24 @@ public class CardsStorage {
|
|||
}
|
||||
}
|
||||
|
||||
public static void main(String[] argv) {
|
||||
for (Card card : getAllCards()) {
|
||||
String name = card.getName();
|
||||
if (name.equals("Baneslayer Angel") || name.equals("Lightning Bolt") || name.equals("Zombie Outlander")
|
||||
|| name.equals("Naturalize") || name.equals("Kraken's Eye") || name.equals("Serra Angel")) {
|
||||
System.out.println(name + " : " + rateCard(card));
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void main(String[] argv) {
|
||||
for (Card card : getAllCards()) {
|
||||
String name = card.getName();
|
||||
if (name.equals("Baneslayer Angel") || name.equals("Lightning Bolt") || name.equals("Zombie Outlander")
|
||||
|| name.equals("Naturalize") || name.equals("Kraken's Eye") || name.equals("Serra Angel")) {
|
||||
System.out.println(name + " : " + rateCard(card));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Card comparator.
|
||||
* First compares collector ids and then card names.
|
||||
* <p/>
|
||||
* Show latest set cards on top.
|
||||
*
|
||||
* @author nantuko
|
||||
*/
|
||||
/**
|
||||
* Card comparator.
|
||||
* First compares collector ids and then card names.
|
||||
* <p/>
|
||||
* Show latest set cards on top.
|
||||
*
|
||||
* @author nantuko
|
||||
*/
|
||||
private static class CardComparator implements Comparator<Card> {
|
||||
|
||||
@Override
|
||||
|
@ -300,14 +300,14 @@ public class CardsStorage {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set comparator. Puts latest set on top.
|
||||
*/
|
||||
private static class SetComparator implements Comparator<ExpansionSet> {
|
||||
/**
|
||||
* Set comparator. Puts latest set on top.
|
||||
*/
|
||||
private static class SetComparator implements Comparator<ExpansionSet> {
|
||||
|
||||
@Override
|
||||
public int compare(ExpansionSet set1, ExpansionSet set2) {
|
||||
return set2.getReleaseDate().compareTo(set1.getReleaseDate());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int compare(ExpansionSet set1, ExpansionSet set2) {
|
||||
return set2.getReleaseDate().compareTo(set1.getReleaseDate());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,50 +57,50 @@ import mage.view.CardsView;
|
|||
*/
|
||||
public class DraftGrid extends javax.swing.JPanel implements MouseListener {
|
||||
|
||||
protected CardEventSource cardEventSource = new CardEventSource();
|
||||
protected BigCard bigCard;
|
||||
protected CardEventSource cardEventSource = new CardEventSource();
|
||||
protected BigCard bigCard;
|
||||
|
||||
/** Creates new form DraftGrid */
|
||||
public DraftGrid() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
public void loadBooster(CardsView booster, BigCard bigCard) {
|
||||
this.bigCard = bigCard;
|
||||
this.removeAll();
|
||||
int numColumns = 5;
|
||||
int curColumn = 0;
|
||||
int curRow = 0;
|
||||
int offsetX = 5;
|
||||
int offsetY = 3;
|
||||
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
Dimension dimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
List<CardView> sortedCards = new ArrayList<CardView>(booster.values());
|
||||
Collections.sort(sortedCards, new CardViewRarityComparator());
|
||||
for (CardView card: sortedCards) {
|
||||
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, dimension, null, true);
|
||||
cardImg.addMouseListener(this);
|
||||
add(cardImg);
|
||||
cardImg.update(card);
|
||||
rectangle.setLocation(curColumn * (Config.dimensions.frameWidth + offsetX) + offsetX, curRow * (Config.dimensions.frameHeight + offsetY) + offsetY);
|
||||
cardImg.setBounds(rectangle);
|
||||
cardImg.setCardBounds(rectangle.x, rectangle.y, Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
curColumn++;
|
||||
if (curColumn == numColumns) {
|
||||
curColumn = 0;
|
||||
curRow++;
|
||||
}
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
public void loadBooster(CardsView booster, BigCard bigCard) {
|
||||
this.bigCard = bigCard;
|
||||
this.removeAll();
|
||||
int numColumns = 5;
|
||||
int curColumn = 0;
|
||||
int curRow = 0;
|
||||
int offsetX = 5;
|
||||
int offsetY = 3;
|
||||
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
Dimension dimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
List<CardView> sortedCards = new ArrayList<CardView>(booster.values());
|
||||
Collections.sort(sortedCards, new CardViewRarityComparator());
|
||||
for (CardView card: sortedCards) {
|
||||
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, dimension, null, true);
|
||||
cardImg.addMouseListener(this);
|
||||
add(cardImg);
|
||||
cardImg.update(card);
|
||||
rectangle.setLocation(curColumn * (Config.dimensions.frameWidth + offsetX) + offsetX, curRow * (Config.dimensions.frameHeight + offsetY) + offsetY);
|
||||
cardImg.setBounds(rectangle);
|
||||
cardImg.setCardBounds(rectangle.x, rectangle.y, Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
curColumn++;
|
||||
if (curColumn == numColumns) {
|
||||
curColumn = 0;
|
||||
curRow++;
|
||||
}
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void addCardEventListener(Listener<Event> listener) {
|
||||
cardEventSource.addListener(listener);
|
||||
}
|
||||
public void addCardEventListener(Listener<Event> listener) {
|
||||
cardEventSource.addListener(listener);
|
||||
}
|
||||
|
||||
public void clearCardEventListeners() {
|
||||
cardEventSource.clearListeners();
|
||||
}
|
||||
public void clearCardEventListeners() {
|
||||
cardEventSource.clearListeners();
|
||||
}
|
||||
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
|
@ -124,29 +124,29 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
|
|||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
}
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
Object obj = e.getSource();
|
||||
if (obj instanceof MageCard) {
|
||||
this.cardEventSource.doubleClick(((MageCard)obj).getOriginal().getId(), "pick-a-card");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
Object obj = e.getSource();
|
||||
if (obj instanceof MageCard) {
|
||||
this.cardEventSource.doubleClick(((MageCard)obj).getOriginal().getId(), "pick-a-card");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
}
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
}
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
|
|
@ -42,9 +42,9 @@ import java.util.UUID;
|
|||
*
|
||||
*/
|
||||
public interface ICardGrid {
|
||||
void clearCardEventListeners();
|
||||
void addCardEventListener(Listener<Event> listener);
|
||||
void drawCards(Constants.SortBy sortBy, boolean piles);
|
||||
void loadCards(CardsView showCards, Constants.SortBy sortBy, boolean piles, BigCard bigCard, UUID gameId);
|
||||
void refresh();
|
||||
void clearCardEventListeners();
|
||||
void addCardEventListener(Listener<Event> listener);
|
||||
void drawCards(Constants.SortBy sortBy, boolean piles);
|
||||
void loadCards(CardsView showCards, Constants.SortBy sortBy, boolean piles, BigCard bigCard, UUID gameId);
|
||||
void refresh();
|
||||
}
|
||||
|
|
|
@ -66,199 +66,199 @@ import mage.view.PermanentView;
|
|||
*/
|
||||
public class Permanent extends Card {
|
||||
|
||||
protected PermanentView permanent;
|
||||
protected PermanentView permanent;
|
||||
|
||||
protected List<MagePermanent> links = new ArrayList<MagePermanent>();
|
||||
protected boolean linked;
|
||||
protected BufferedImage tappedImage;
|
||||
protected BufferedImage flippedImage;
|
||||
protected List<MagePermanent> links = new ArrayList<MagePermanent>();
|
||||
protected boolean linked;
|
||||
protected BufferedImage tappedImage;
|
||||
protected BufferedImage flippedImage;
|
||||
|
||||
/** Creates new form Permanent */
|
||||
public Permanent(PermanentView permanent, BigCard bigCard, CardDimensions dimensions, UUID gameId) {
|
||||
super(permanent, bigCard, dimensions, gameId);
|
||||
this.setSize(this.getPreferredSize());
|
||||
this.permanent = permanent;
|
||||
tappedImage = new BufferedImage(Config.dimensions.frameHeight, Config.dimensions.frameWidth, BufferedImage.TYPE_INT_RGB);
|
||||
}
|
||||
public Permanent(PermanentView permanent, BigCard bigCard, CardDimensions dimensions, UUID gameId) {
|
||||
super(permanent, bigCard, dimensions, gameId);
|
||||
this.setSize(this.getPreferredSize());
|
||||
this.permanent = permanent;
|
||||
tappedImage = new BufferedImage(Config.dimensions.frameHeight, Config.dimensions.frameWidth, BufferedImage.TYPE_INT_RGB);
|
||||
}
|
||||
|
||||
public UUID getPermanentId() {
|
||||
return permanent.getId();
|
||||
}
|
||||
public UUID getPermanentId() {
|
||||
return permanent.getId();
|
||||
}
|
||||
|
||||
public List<MagePermanent> getLinks() {
|
||||
return links;
|
||||
}
|
||||
public List<MagePermanent> getLinks() {
|
||||
return links;
|
||||
}
|
||||
|
||||
public boolean isLinked() {
|
||||
return linked;
|
||||
}
|
||||
public boolean isLinked() {
|
||||
return linked;
|
||||
}
|
||||
|
||||
public void setLinked(boolean linked) {
|
||||
this.linked = linked;
|
||||
}
|
||||
public void setLinked(boolean linked) {
|
||||
this.linked = linked;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getText(String cardType) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(super.getText(cardType));
|
||||
sb.append("\n----- Originally -------\n");
|
||||
sb.append(permanent.getOriginal().getName());
|
||||
if (permanent.getOriginal().getManaCost().size() > 0) {
|
||||
sb.append("\n").append(permanent.getOriginal().getManaCost());
|
||||
}
|
||||
sb.append("\n").append(getType(permanent.getOriginal()));
|
||||
if (permanent.getOriginal().getColor().hasColor()) {
|
||||
sb.append("\n").append(permanent.getOriginal().getColor().toString());
|
||||
}
|
||||
if (permanent.getOriginal().getCardTypes().contains(CardType.CREATURE)) {
|
||||
sb.append("\n").append(permanent.getOriginal().getPower()).append("/").append(permanent.getOriginal().getToughness());
|
||||
}
|
||||
else if (permanent.getOriginal().getCardTypes().contains(CardType.PLANESWALKER)) {
|
||||
sb.append("\n").append(permanent.getOriginal().getLoyalty());
|
||||
}
|
||||
for (String rule: getRules()) {
|
||||
sb.append("\n").append(rule);
|
||||
}
|
||||
if (permanent.getOriginal().getExpansionSetCode().length() > 0) {
|
||||
sb.append("\n").append(permanent.getCardNumber()).append(" - ");
|
||||
sb.append("\n").append(Sets.getInstance().get(permanent.getOriginal().getExpansionSetCode()).getName()).append(" - ");
|
||||
sb.append(permanent.getOriginal().getRarity().toString());
|
||||
}
|
||||
// sb.append("\n").append(card.getId());
|
||||
return sb.toString();
|
||||
@Override
|
||||
protected String getText(String cardType) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(super.getText(cardType));
|
||||
sb.append("\n----- Originally -------\n");
|
||||
sb.append(permanent.getOriginal().getName());
|
||||
if (permanent.getOriginal().getManaCost().size() > 0) {
|
||||
sb.append("\n").append(permanent.getOriginal().getManaCost());
|
||||
}
|
||||
sb.append("\n").append(getType(permanent.getOriginal()));
|
||||
if (permanent.getOriginal().getColor().hasColor()) {
|
||||
sb.append("\n").append(permanent.getOriginal().getColor().toString());
|
||||
}
|
||||
if (permanent.getOriginal().getCardTypes().contains(CardType.CREATURE)) {
|
||||
sb.append("\n").append(permanent.getOriginal().getPower()).append("/").append(permanent.getOriginal().getToughness());
|
||||
}
|
||||
else if (permanent.getOriginal().getCardTypes().contains(CardType.PLANESWALKER)) {
|
||||
sb.append("\n").append(permanent.getOriginal().getLoyalty());
|
||||
}
|
||||
for (String rule: getRules()) {
|
||||
sb.append("\n").append(rule);
|
||||
}
|
||||
if (permanent.getOriginal().getExpansionSetCode().length() > 0) {
|
||||
sb.append("\n").append(permanent.getCardNumber()).append(" - ");
|
||||
sb.append("\n").append(Sets.getInstance().get(permanent.getOriginal().getExpansionSetCode()).getName()).append(" - ");
|
||||
sb.append(permanent.getOriginal().getRarity().toString());
|
||||
}
|
||||
// sb.append("\n").append(card.getId());
|
||||
return sb.toString();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getRules() {
|
||||
if (permanent.getCounters() != null) {
|
||||
List<String> rules = new ArrayList<String>(permanent.getRules());
|
||||
for (CounterView counter: permanent.getCounters())
|
||||
rules.add(counter.getCount() + " x " + counter.getName());
|
||||
return rules;
|
||||
}
|
||||
else {
|
||||
return permanent.getRules();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected List<String> getRules() {
|
||||
if (permanent.getCounters() != null) {
|
||||
List<String> rules = new ArrayList<String>(permanent.getRules());
|
||||
for (CounterView counter: permanent.getCounters())
|
||||
rules.add(counter.getCount() + " x " + counter.getName());
|
||||
return rules;
|
||||
}
|
||||
else {
|
||||
return permanent.getRules();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
p = e.getPoint();
|
||||
e.consume();
|
||||
}
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
p = e.getPoint();
|
||||
e.consume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
if (!linked) {
|
||||
int dx = e.getX() - p.x;
|
||||
int dy = e.getY() - p.y;
|
||||
Rectangle r = this.getBounds();
|
||||
r.x += dx;
|
||||
r.y += dy;
|
||||
if (r.x < 0) r.x = 0;
|
||||
if (r.y < 0) r.y = 0;
|
||||
this.setBounds(r);
|
||||
this.repaint();
|
||||
for (MagePermanent perm: links) {
|
||||
r.x += 20;
|
||||
r.y += 20;
|
||||
perm.setBounds(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
if (!linked) {
|
||||
int dx = e.getX() - p.x;
|
||||
int dy = e.getY() - p.y;
|
||||
Rectangle r = this.getBounds();
|
||||
r.x += dx;
|
||||
r.y += dy;
|
||||
if (r.x < 0) r.x = 0;
|
||||
if (r.y < 0) r.y = 0;
|
||||
this.setBounds(r);
|
||||
this.repaint();
|
||||
for (MagePermanent perm: links) {
|
||||
r.x += 20;
|
||||
r.y += 20;
|
||||
perm.setBounds(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent arg0) {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent arg0) {
|
||||
|
||||
super.mouseClicked(arg0);
|
||||
}
|
||||
super.mouseClicked(arg0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics graphics) {
|
||||
Graphics2D g2 = (Graphics2D) graphics;
|
||||
this.setSize(this.getPreferredSize());
|
||||
if (permanent.isTapped()) {
|
||||
this.getText().setVisible(false);
|
||||
g2.drawImage(tappedImage, 0, 0, this);
|
||||
}
|
||||
else {
|
||||
this.getText().setVisible(true);
|
||||
g2.drawImage(small, 0, 0, this);
|
||||
}
|
||||
@Override
|
||||
public void paintComponent(Graphics graphics) {
|
||||
Graphics2D g2 = (Graphics2D) graphics;
|
||||
this.setSize(this.getPreferredSize());
|
||||
if (permanent.isTapped()) {
|
||||
this.getText().setVisible(false);
|
||||
g2.drawImage(tappedImage, 0, 0, this);
|
||||
}
|
||||
else {
|
||||
this.getText().setVisible(true);
|
||||
g2.drawImage(small, 0, 0, this);
|
||||
}
|
||||
|
||||
//Add a border, red if card currently has focus
|
||||
if (isFocusOwner()) {
|
||||
g2.setColor(Color.RED);
|
||||
} else {
|
||||
g2.setColor(Color.BLACK);
|
||||
}
|
||||
if (permanent.isTapped()) {
|
||||
g2.drawRect(0, 0, Config.dimensions.frameHeight - 1, Config.dimensions.frameWidth - 1);
|
||||
}
|
||||
else {
|
||||
g2.drawRect(0, 0, Config.dimensions.frameWidth - 1, Config.dimensions.frameHeight - 1);
|
||||
}
|
||||
//Add a border, red if card currently has focus
|
||||
if (isFocusOwner()) {
|
||||
g2.setColor(Color.RED);
|
||||
} else {
|
||||
g2.setColor(Color.BLACK);
|
||||
}
|
||||
if (permanent.isTapped()) {
|
||||
g2.drawRect(0, 0, Config.dimensions.frameHeight - 1, Config.dimensions.frameWidth - 1);
|
||||
}
|
||||
else {
|
||||
g2.drawRect(0, 0, Config.dimensions.frameWidth - 1, Config.dimensions.frameHeight - 1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void generateTappedImage() {
|
||||
Graphics2D g = (Graphics2D) tappedImage.getGraphics();
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
protected void generateTappedImage() {
|
||||
Graphics2D g = (Graphics2D) tappedImage.getGraphics();
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
g.drawImage(this.createImage(ImageHelper.rotate(small, dimension)), 0, 0, this);
|
||||
g.drawImage(this.createImage(ImageHelper.rotate(small, dimension)), 0, 0, this);
|
||||
|
||||
g.dispose();
|
||||
}
|
||||
g.dispose();
|
||||
}
|
||||
|
||||
public void update(PermanentView permanent) {
|
||||
this.permanent = permanent;
|
||||
super.update(permanent);
|
||||
if (permanent.getDamage() > 0) {
|
||||
Graphics2D g = image.createGraphics();
|
||||
g.setColor(Color.RED);
|
||||
g.drawString(Integer.toString(permanent.getDamage()), DAMAGE_MAX_LEFT, POWBOX_TEXT_MAX_TOP);
|
||||
g.dispose();
|
||||
}
|
||||
generateTappedImage();
|
||||
}
|
||||
public void update(PermanentView permanent) {
|
||||
this.permanent = permanent;
|
||||
super.update(permanent);
|
||||
if (permanent.getDamage() > 0) {
|
||||
Graphics2D g = image.createGraphics();
|
||||
g.setColor(Color.RED);
|
||||
g.drawString(Integer.toString(permanent.getDamage()), DAMAGE_MAX_LEFT, POWBOX_TEXT_MAX_TOP);
|
||||
g.dispose();
|
||||
}
|
||||
generateTappedImage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
if (permanent != null && permanent.isTapped()) {
|
||||
return new Dimension(Config.dimensions.frameHeight, Config.dimensions.frameWidth);
|
||||
}
|
||||
else {
|
||||
return new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
if (permanent != null && permanent.isTapped()) {
|
||||
return new Dimension(Config.dimensions.frameHeight, Config.dimensions.frameWidth);
|
||||
}
|
||||
else {
|
||||
return new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
return this.getPreferredSize();
|
||||
}
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
return this.getPreferredSize();
|
||||
}
|
||||
|
||||
public boolean overlaps(Rectangle r1) {
|
||||
return this.getBounds().intersects(r1);
|
||||
}
|
||||
public boolean overlaps(Rectangle r1) {
|
||||
return this.getBounds().intersects(r1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent arg0) {
|
||||
if (!popupShowing) {
|
||||
if (popup != null)
|
||||
popup.hide();
|
||||
PopupFactory factory = PopupFactory.getSharedInstance();
|
||||
int x = (int) this.getLocationOnScreen().getX() + (permanent.isTapped()?Config.dimensions.frameHeight:Config.dimensions.frameWidth);
|
||||
int y = (int) this.getLocationOnScreen().getY() + 40;
|
||||
popup = factory.getPopup(this, popupText, x, y);
|
||||
popup.show();
|
||||
//hack to get popup to resize to fit text
|
||||
popup.hide();
|
||||
popup = factory.getPopup(this, popupText, x, y);
|
||||
popup.show();
|
||||
popupShowing = true;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent arg0) {
|
||||
if (!popupShowing) {
|
||||
if (popup != null)
|
||||
popup.hide();
|
||||
PopupFactory factory = PopupFactory.getSharedInstance();
|
||||
int x = (int) this.getLocationOnScreen().getX() + (permanent.isTapped()?Config.dimensions.frameHeight:Config.dimensions.frameWidth);
|
||||
int y = (int) this.getLocationOnScreen().getY() + 40;
|
||||
popup = factory.getPopup(this, popupText, x, y);
|
||||
popup.show();
|
||||
//hack to get popup to resize to fit text
|
||||
popup.hide();
|
||||
popup = factory.getPopup(this, popupText, x, y);
|
||||
popup.show();
|
||||
popupShowing = true;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
|
|
@ -53,175 +53,175 @@ import javax.swing.table.AbstractTableModel;
|
|||
*/
|
||||
public class ChatPanel extends javax.swing.JPanel {
|
||||
|
||||
private UUID chatId;
|
||||
private Session session;
|
||||
private UUID chatId;
|
||||
private Session session;
|
||||
|
||||
private List<String> players = new ArrayList<String>();
|
||||
private TableModel tableModel;
|
||||
private List<String> players = new ArrayList<String>();
|
||||
private TableModel tableModel;
|
||||
|
||||
/**
|
||||
* Chat message color for opponents.
|
||||
*/
|
||||
private static final Color OPPONENT_COLOR = new Color(0, 230, 64);
|
||||
/**
|
||||
* Chat message color for opponents.
|
||||
*/
|
||||
private static final Color OPPONENT_COLOR = new Color(0, 230, 64);
|
||||
|
||||
/**
|
||||
* Chat message color for client player.
|
||||
*/
|
||||
private static final Color MY_COLOR = new Color(0, 230, 64);
|
||||
/**
|
||||
* Chat message color for client player.
|
||||
*/
|
||||
private static final Color MY_COLOR = new Color(0, 230, 64);
|
||||
|
||||
/**
|
||||
* Chat message color for timestamps.
|
||||
*/
|
||||
private static final Color TIMESTAMP_COLOR = new Color(255, 255, 0, 120);
|
||||
/**
|
||||
* Chat message color for timestamps.
|
||||
*/
|
||||
private static final Color TIMESTAMP_COLOR = new Color(255, 255, 0, 120);
|
||||
|
||||
/**
|
||||
* Chat message color for messages.
|
||||
*/
|
||||
private static final Color MESSAGE_COLOR = Color.white;
|
||||
/**
|
||||
* Chat message color for messages.
|
||||
*/
|
||||
private static final Color MESSAGE_COLOR = Color.white;
|
||||
|
||||
/**
|
||||
* This will be a chat that will be connected to {this} and will handle redirected messages;
|
||||
* Mostly used to redirect user messages to another window.
|
||||
*/
|
||||
private ChatPanel connectedChat;
|
||||
/**
|
||||
* This will be a chat that will be connected to {this} and will handle redirected messages;
|
||||
* Mostly used to redirect user messages to another window.
|
||||
*/
|
||||
private ChatPanel connectedChat;
|
||||
|
||||
/**
|
||||
* Parent chat this chat connected to.
|
||||
* Used to send messages using parent chat as it is the only one connected to server.
|
||||
*/
|
||||
private ChatPanel parentChatRef;
|
||||
/**
|
||||
* Parent chat this chat connected to.
|
||||
* Used to send messages using parent chat as it is the only one connected to server.
|
||||
*/
|
||||
private ChatPanel parentChatRef;
|
||||
|
||||
/**
|
||||
* Selected extended view mode.
|
||||
*/
|
||||
private VIEW_MODE extendedViewMode = VIEW_MODE.NONE;
|
||||
/**
|
||||
* Selected extended view mode.
|
||||
*/
|
||||
private VIEW_MODE extendedViewMode = VIEW_MODE.NONE;
|
||||
|
||||
public enum VIEW_MODE {
|
||||
NONE, GAME, CHAT
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps message colors to {@link Color}.
|
||||
*/
|
||||
private static final Map<MessageColor, Color> colorMap = new EnumMap<MessageColor, Color>(MessageColor.class);
|
||||
|
||||
static {
|
||||
colorMap.put(MessageColor.BLACK, Color.black);
|
||||
colorMap.put(MessageColor.GREEN, Color.green);
|
||||
colorMap.put(MessageColor.ORANGE, Color.orange);
|
||||
colorMap.put(MessageColor.BLUE, Color.blue);
|
||||
colorMap.put(MessageColor.RED, Color.red);
|
||||
}
|
||||
|
||||
/** Creates new form ChatPanel */
|
||||
public ChatPanel() {
|
||||
this(false);
|
||||
public enum VIEW_MODE {
|
||||
NONE, GAME, CHAT
|
||||
}
|
||||
|
||||
/**
|
||||
* @param addPlayersTab if true, adds chat/players tabs
|
||||
*/
|
||||
/**
|
||||
* Maps message colors to {@link Color}.
|
||||
*/
|
||||
private static final Map<MessageColor, Color> colorMap = new EnumMap<MessageColor, Color>(MessageColor.class);
|
||||
|
||||
static {
|
||||
colorMap.put(MessageColor.BLACK, Color.black);
|
||||
colorMap.put(MessageColor.GREEN, Color.green);
|
||||
colorMap.put(MessageColor.ORANGE, Color.orange);
|
||||
colorMap.put(MessageColor.BLUE, Color.blue);
|
||||
colorMap.put(MessageColor.RED, Color.red);
|
||||
}
|
||||
|
||||
/** Creates new form ChatPanel */
|
||||
public ChatPanel() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param addPlayersTab if true, adds chat/players tabs
|
||||
*/
|
||||
/** Creates new form ChatPanel */
|
||||
public ChatPanel(boolean addPlayersTab) {
|
||||
tableModel = new TableModel();
|
||||
tableModel = new TableModel();
|
||||
initComponents();
|
||||
if (!addPlayersTab) simplifyComponents();
|
||||
if (!addPlayersTab) simplifyComponents();
|
||||
}
|
||||
|
||||
public void connect(UUID chatId) {
|
||||
session = MageFrame.getSession();
|
||||
this.chatId = chatId;
|
||||
if (session.joinChat(chatId)) {
|
||||
MageFrame.addChat(chatId, this);
|
||||
}
|
||||
}
|
||||
public void connect(UUID chatId) {
|
||||
session = MageFrame.getSession();
|
||||
this.chatId = chatId;
|
||||
if (session.joinChat(chatId)) {
|
||||
MageFrame.addChat(chatId, this);
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
if (session != null)
|
||||
session.leaveChat(chatId);
|
||||
}
|
||||
public void disconnect() {
|
||||
if (session != null)
|
||||
session.leaveChat(chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display message in the chat.
|
||||
* Use different colors for timestamp, username and message.
|
||||
*
|
||||
* @param username message sender
|
||||
* @param message message itself
|
||||
* @param time timestamp
|
||||
* @param color Preferred color. Not used.
|
||||
*/
|
||||
public void receiveMessage(String username, String message, String time, MessageColor color) {
|
||||
if (extendedViewMode.equals(VIEW_MODE.GAME)) {
|
||||
this.txtConversation.append(TIMESTAMP_COLOR, time + " ");
|
||||
this.txtConversation.append(MESSAGE_COLOR, (username.isEmpty() ? "" : username + ":") + message + "\n");
|
||||
} else {
|
||||
this.txtConversation.append(TIMESTAMP_COLOR, time + " ");
|
||||
Color userColor;
|
||||
if (parentChatRef != null) {
|
||||
userColor = parentChatRef.session.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
|
||||
} else {
|
||||
userColor = session.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
|
||||
}
|
||||
this.txtConversation.append(userColor, username + ": ");
|
||||
this.txtConversation.append(MESSAGE_COLOR, message + "\n");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Display message in the chat.
|
||||
* Use different colors for timestamp, username and message.
|
||||
*
|
||||
* @param username message sender
|
||||
* @param message message itself
|
||||
* @param time timestamp
|
||||
* @param color Preferred color. Not used.
|
||||
*/
|
||||
public void receiveMessage(String username, String message, String time, MessageColor color) {
|
||||
if (extendedViewMode.equals(VIEW_MODE.GAME)) {
|
||||
this.txtConversation.append(TIMESTAMP_COLOR, time + " ");
|
||||
this.txtConversation.append(MESSAGE_COLOR, (username.isEmpty() ? "" : username + ":") + message + "\n");
|
||||
} else {
|
||||
this.txtConversation.append(TIMESTAMP_COLOR, time + " ");
|
||||
Color userColor;
|
||||
if (parentChatRef != null) {
|
||||
userColor = parentChatRef.session.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
|
||||
} else {
|
||||
userColor = session.getUserName().equals(username) ? MY_COLOR : OPPONENT_COLOR;
|
||||
}
|
||||
this.txtConversation.append(userColor, username + ": ");
|
||||
this.txtConversation.append(MESSAGE_COLOR, message + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
public ChatPanel getConnectedChat() {
|
||||
return connectedChat;
|
||||
}
|
||||
public ChatPanel getConnectedChat() {
|
||||
return connectedChat;
|
||||
}
|
||||
|
||||
public void setConnectedChat(ChatPanel connectedChat) {
|
||||
this.connectedChat = connectedChat;
|
||||
}
|
||||
public void setConnectedChat(ChatPanel connectedChat) {
|
||||
this.connectedChat = connectedChat;
|
||||
}
|
||||
|
||||
public void setParentChat(ChatPanel parentChatRef) {
|
||||
this.parentChatRef = parentChatRef;
|
||||
}
|
||||
public void setParentChat(ChatPanel parentChatRef) {
|
||||
this.parentChatRef = parentChatRef;
|
||||
}
|
||||
|
||||
public void disableInput() {
|
||||
this.txtMessage.setVisible(false);
|
||||
}
|
||||
public void disableInput() {
|
||||
this.txtMessage.setVisible(false);
|
||||
}
|
||||
|
||||
public JTextField getTxtMessageInputComponent() {
|
||||
return this.txtMessage;
|
||||
}
|
||||
public JTextField getTxtMessageInputComponent() {
|
||||
return this.txtMessage;
|
||||
}
|
||||
|
||||
public void useExtendedView(VIEW_MODE extendedViewMode) {
|
||||
this.extendedViewMode = extendedViewMode;
|
||||
this.txtConversation.setExtBackgroundColor(new Color(0,0,0,100));
|
||||
this.txtConversation.setBackground(new Color(0,0,0,0));
|
||||
this.txtConversation.setForeground(new Color(255,255,255));
|
||||
this.jScrollPane1.setOpaque(false);
|
||||
this.jScrollPane1.getViewport().setOpaque(false);
|
||||
}
|
||||
public void useExtendedView(VIEW_MODE extendedViewMode) {
|
||||
this.extendedViewMode = extendedViewMode;
|
||||
this.txtConversation.setExtBackgroundColor(new Color(0,0,0,100));
|
||||
this.txtConversation.setBackground(new Color(0,0,0,0));
|
||||
this.txtConversation.setForeground(new Color(255,255,255));
|
||||
this.jScrollPane1.setOpaque(false);
|
||||
this.jScrollPane1.getViewport().setOpaque(false);
|
||||
}
|
||||
|
||||
class TableModel extends AbstractTableModel {
|
||||
private String[] columnNames = new String[]{"Players"};
|
||||
private List<String> players = new ArrayList<String>(0);
|
||||
private List<String> players = new ArrayList<String>(0);
|
||||
|
||||
public void loadData(List<String> players) {
|
||||
this.players = players;
|
||||
this.fireTableDataChanged();
|
||||
}
|
||||
public void loadData(List<String> players) {
|
||||
this.players = players;
|
||||
this.fireTableDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return players.size();
|
||||
}
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return players.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return columnNames.length;
|
||||
}
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return columnNames.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int arg0, int arg1) {
|
||||
return players.get(arg0);
|
||||
}
|
||||
@Override
|
||||
public Object getValueAt(int arg0, int arg1) {
|
||||
return players.get(arg0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnName(int columnIndex) {
|
||||
@Override
|
||||
public String getColumnName(int columnIndex) {
|
||||
String colName = "";
|
||||
|
||||
if (columnIndex <= getColumnCount())
|
||||
|
@ -230,22 +230,22 @@ class TableModel extends AbstractTableModel {
|
|||
return colName;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Class getColumnClass(int columnIndex){
|
||||
return String.class;
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.txtConversation.selectAll();
|
||||
this.txtConversation.replaceSelection("");
|
||||
}
|
||||
public void clear() {
|
||||
this.txtConversation.selectAll();
|
||||
this.txtConversation.replaceSelection("");
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
@ -273,14 +273,14 @@ class TableModel extends AbstractTableModel {
|
|||
jSplitPane1.setResizeWeight(0.25);
|
||||
|
||||
// txtConversation.setColumns(20);
|
||||
txtConversation.setOpaque(false);
|
||||
txtConversation.setOpaque(false);
|
||||
// txtConversation.setEditable(false);
|
||||
txtConversation.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
// txtConversation.setLineWrap(true);
|
||||
// txtConversation.setRows(5);
|
||||
// txtConversation.setWrapStyleWord(true);
|
||||
jScrollPane1.setViewportView(txtConversation);
|
||||
jScrollPane1.setBorder(new EmptyBorder(0,0,0,0));
|
||||
jScrollPane1.setBorder(new EmptyBorder(0,0,0,0));
|
||||
|
||||
jSplitPane1.setLeftComponent(jScrollPane2);
|
||||
|
||||
|
@ -290,7 +290,7 @@ class TableModel extends AbstractTableModel {
|
|||
jScrollPane2.setViewportView(jTable1);
|
||||
|
||||
jSplitPane1.setBottomComponent(jScrollPane1);
|
||||
jSplitPane1.setDividerLocation(150 + jSplitPane1.getInsets().bottom);
|
||||
jSplitPane1.setDividerLocation(150 + jSplitPane1.getInsets().bottom);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
|
@ -308,8 +308,8 @@ class TableModel extends AbstractTableModel {
|
|||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void simplifyComponents() {
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
private void simplifyComponents() {
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
|
@ -324,50 +324,50 @@ class TableModel extends AbstractTableModel {
|
|||
.addComponent(txtMessage, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
);
|
||||
|
||||
jTable1 = null;
|
||||
jScrollPane2 = null;
|
||||
}
|
||||
jTable1 = null;
|
||||
jScrollPane2 = null;
|
||||
}
|
||||
|
||||
private void txtMessageKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtMessageKeyTyped
|
||||
if (evt.getKeyChar() == KeyEvent.VK_ENTER) {
|
||||
if (parentChatRef != null) {
|
||||
parentChatRef.session.sendChatMessage(parentChatRef.chatId, this.txtMessage.getText());
|
||||
} else {
|
||||
session.sendChatMessage(chatId, this.txtMessage.getText());
|
||||
}
|
||||
this.txtMessage.setText("");
|
||||
this.txtMessage.repaint();
|
||||
}
|
||||
private void txtMessageKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtMessageKeyTyped
|
||||
if (evt.getKeyChar() == KeyEvent.VK_ENTER) {
|
||||
if (parentChatRef != null) {
|
||||
parentChatRef.session.sendChatMessage(parentChatRef.chatId, this.txtMessage.getText());
|
||||
} else {
|
||||
session.sendChatMessage(chatId, this.txtMessage.getText());
|
||||
}
|
||||
this.txtMessage.setText("");
|
||||
this.txtMessage.repaint();
|
||||
}
|
||||
}//GEN-LAST:event_txtMessageKeyTyped
|
||||
|
||||
public void setPlayers(Collection<String> players) {
|
||||
if (players != null) {
|
||||
boolean update = false;
|
||||
int size = players.size();
|
||||
List<String> list = new ArrayList<String>(players);
|
||||
Collections.sort(list);
|
||||
if (size != this.players.size()) {
|
||||
update = true;
|
||||
} else {
|
||||
update = true;
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (!list.get(i).equals(this.players.get(i))) {
|
||||
update = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (update && list != null) {
|
||||
synchronized (tableModel) {
|
||||
this.players = list;
|
||||
tableModel.loadData(this.players);
|
||||
}
|
||||
}
|
||||
public void setPlayers(Collection<String> players) {
|
||||
if (players != null) {
|
||||
boolean update = false;
|
||||
int size = players.size();
|
||||
List<String> list = new ArrayList<String>(players);
|
||||
Collections.sort(list);
|
||||
if (size != this.players.size()) {
|
||||
update = true;
|
||||
} else {
|
||||
update = true;
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (!list.get(i).equals(this.players.get(i))) {
|
||||
update = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (update && list != null) {
|
||||
synchronized (tableModel) {
|
||||
this.players = list;
|
||||
tableModel.loadData(this.players);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
this.players.clear();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.players.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
|
|
|
@ -37,7 +37,7 @@ public class CombatManager {
|
|||
public void hideCombat() {
|
||||
ArrowBuilder.removeArrowsByType(ArrowBuilder.Type.COMBAT);
|
||||
}
|
||||
|
||||
|
||||
private void displayArrows(List<CombatGroupView> combatView, UUID gameId) {
|
||||
parentPoint = null;
|
||||
for (CombatGroupView group : combatView) {
|
||||
|
@ -103,7 +103,7 @@ public class CombatManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Point getParentPoint(MagePermanent permanent) {
|
||||
if (parentPoint == null) {
|
||||
Component parentComponent = SwingUtilities.getRoot(permanent);
|
||||
|
|
|
@ -14,57 +14,57 @@ import java.awt.*;
|
|||
*/
|
||||
public class ColorPane extends JTextPane {
|
||||
|
||||
/**
|
||||
* This method solves the known issue with Nimbus LAF background transparency and background color.
|
||||
* @param color
|
||||
*/
|
||||
public void setExtBackgroundColor(Color color) {
|
||||
setBackground(new Color(0,0,0,0));
|
||||
JPanel jPanel = new JPanel();
|
||||
jPanel.setBackground(color);
|
||||
setLayout(new BorderLayout());
|
||||
add(jPanel);
|
||||
}
|
||||
/**
|
||||
* This method solves the known issue with Nimbus LAF background transparency and background color.
|
||||
* @param color
|
||||
*/
|
||||
public void setExtBackgroundColor(Color color) {
|
||||
setBackground(new Color(0,0,0,0));
|
||||
JPanel jPanel = new JPanel();
|
||||
jPanel.setBackground(color);
|
||||
setLayout(new BorderLayout());
|
||||
add(jPanel);
|
||||
}
|
||||
|
||||
public void append(Color color, String s) {
|
||||
if (color == null) {
|
||||
return;
|
||||
}
|
||||
if (color == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
setEditable(true);
|
||||
|
||||
StyleContext sc = StyleContext.getDefaultStyleContext();
|
||||
AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, color);
|
||||
setEditable(true);
|
||||
|
||||
int len = getDocument().getLength();
|
||||
StyleContext sc = StyleContext.getDefaultStyleContext();
|
||||
AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, color);
|
||||
|
||||
setCaretPosition(len);
|
||||
setCharacterAttributes(aset, false);
|
||||
replaceSelection(s);
|
||||
int len = getDocument().getLength();
|
||||
|
||||
setEditable(false);
|
||||
setCaretPosition(len);
|
||||
setCharacterAttributes(aset, false);
|
||||
replaceSelection(s);
|
||||
|
||||
setEditable(false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A little trick to paint black background under the text.
|
||||
*
|
||||
* @param g
|
||||
*/
|
||||
public void paintChildren(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
}
|
||||
/**
|
||||
* A little trick to paint black background under the text.
|
||||
*
|
||||
* @param g
|
||||
*/
|
||||
public void paintChildren(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
}
|
||||
|
||||
/**
|
||||
* A little trick to paint black background under the text.
|
||||
*
|
||||
* @param g
|
||||
*/
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintChildren(g);
|
||||
}
|
||||
/**
|
||||
* A little trick to paint black background under the text.
|
||||
*
|
||||
* @param g
|
||||
*/
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintChildren(g);
|
||||
}
|
||||
|
||||
}
|
|
@ -15,214 +15,214 @@ import java.awt.font.FontRenderContext;
|
|||
*/
|
||||
public class HoverButton extends JPanel implements MouseListener {
|
||||
|
||||
private Image image;
|
||||
private Image hoverImage;
|
||||
private Image disabledImage;
|
||||
private Image selectedImage;
|
||||
protected Image overlayImage;
|
||||
private Rectangle imageSize;
|
||||
private Rectangle buttonSize;
|
||||
private String text;
|
||||
private int textOffsetY = 0;
|
||||
private int textOffsetX = -1;
|
||||
private Dimension overlayImageSize;
|
||||
private Image image;
|
||||
private Image hoverImage;
|
||||
private Image disabledImage;
|
||||
private Image selectedImage;
|
||||
protected Image overlayImage;
|
||||
private Rectangle imageSize;
|
||||
private Rectangle buttonSize;
|
||||
private String text;
|
||||
private int textOffsetY = 0;
|
||||
private int textOffsetX = -1;
|
||||
private Dimension overlayImageSize;
|
||||
|
||||
private boolean isHovered = false;
|
||||
private boolean isSelected = false;
|
||||
private boolean drawSet = false;
|
||||
private String set = null;
|
||||
private boolean isHovered = false;
|
||||
private boolean isSelected = false;
|
||||
private boolean drawSet = false;
|
||||
private String set = null;
|
||||
|
||||
private Command observer = null;
|
||||
private Command onHover = null;
|
||||
private Color textColor = Color.white;
|
||||
private Command observer = null;
|
||||
private Command onHover = null;
|
||||
private Color textColor = Color.white;
|
||||
|
||||
final static Font textFont = new Font("Arial", Font.PLAIN, 12);
|
||||
final static Font textFontMini = new Font("Arial", Font.PLAIN, 11);
|
||||
final static Font textSetFontBoldMini = new Font("Arial", Font.BOLD, 12);
|
||||
final static Font textSetFontBold = new Font("Arial", Font.BOLD, 14);
|
||||
private boolean useMiniFont = false;
|
||||
final static Font textFont = new Font("Arial", Font.PLAIN, 12);
|
||||
final static Font textFontMini = new Font("Arial", Font.PLAIN, 11);
|
||||
final static Font textSetFontBoldMini = new Font("Arial", Font.BOLD, 12);
|
||||
final static Font textSetFontBold = new Font("Arial", Font.BOLD, 14);
|
||||
private boolean useMiniFont = false;
|
||||
|
||||
public HoverButton(String text, Image image, Image hover, Image disabled, Rectangle size) {
|
||||
this(text, image, hover, null, disabled, size);
|
||||
}
|
||||
public HoverButton(String text, Image image, Image hover, Image disabled, Rectangle size) {
|
||||
this(text, image, hover, null, disabled, size);
|
||||
}
|
||||
|
||||
public HoverButton(String text, Image image, Image hover, Image selected, Image disabled, Rectangle size) {
|
||||
this.image = image;
|
||||
this.hoverImage = hover;
|
||||
this.selectedImage = selected;
|
||||
this.disabledImage = disabled;
|
||||
this.imageSize = size;
|
||||
this.text = text;
|
||||
setOpaque(false);
|
||||
addMouseListener(this);
|
||||
}
|
||||
public HoverButton(String text, Image image, Image hover, Image selected, Image disabled, Rectangle size) {
|
||||
this.image = image;
|
||||
this.hoverImage = hover;
|
||||
this.selectedImage = selected;
|
||||
this.disabledImage = disabled;
|
||||
this.imageSize = size;
|
||||
this.text = text;
|
||||
setOpaque(false);
|
||||
addMouseListener(this);
|
||||
}
|
||||
|
||||
public HoverButton(HoverButton button) {
|
||||
this(button.text, button.image, button.hoverImage, button.selectedImage, button.disabledImage, button.imageSize);
|
||||
}
|
||||
public HoverButton(HoverButton button) {
|
||||
this(button.text, button.image, button.hoverImage, button.selectedImage, button.disabledImage, button.imageSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
if (isEnabled()) {
|
||||
if (isHovered) {
|
||||
g.drawImage(hoverImage, 0, 0, imageSize.width, imageSize.height, this);
|
||||
if (text != null) {
|
||||
if (textColor != null) g2d.setColor(textColor);
|
||||
if (useMiniFont) g2d.setFont(textFontMini);
|
||||
else g2d.setFont(textFont);
|
||||
textOffsetX = calculateOffset(g2d);
|
||||
g2d.drawString(text, textOffsetX, textOffsetY);
|
||||
}
|
||||
} else {
|
||||
g.drawImage(image, 0, 0, imageSize.width, imageSize.height, this);
|
||||
}
|
||||
if (isSelected) {
|
||||
if (selectedImage != null) {
|
||||
g.drawImage(selectedImage, 0, 0, imageSize.width, imageSize.height, this);
|
||||
} else {
|
||||
System.err.println("No selectedImage for button.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
g.drawImage(disabledImage, 0, 0, imageSize.width, imageSize.height, this);
|
||||
}
|
||||
if (overlayImage != null) {
|
||||
g.drawImage(overlayImage, (imageSize.width - overlayImageSize.width) / 2, 10, this);
|
||||
} else if (set != null) {
|
||||
// draw only if it is not current tab
|
||||
if (!drawSet) {
|
||||
g2d.setFont(textSetFontBoldMini);
|
||||
g2d.drawString(set, 5, 25);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
if (isEnabled()) {
|
||||
if (isHovered) {
|
||||
g.drawImage(hoverImage, 0, 0, imageSize.width, imageSize.height, this);
|
||||
if (text != null) {
|
||||
if (textColor != null) g2d.setColor(textColor);
|
||||
if (useMiniFont) g2d.setFont(textFontMini);
|
||||
else g2d.setFont(textFont);
|
||||
textOffsetX = calculateOffset(g2d);
|
||||
g2d.drawString(text, textOffsetX, textOffsetY);
|
||||
}
|
||||
} else {
|
||||
g.drawImage(image, 0, 0, imageSize.width, imageSize.height, this);
|
||||
}
|
||||
if (isSelected) {
|
||||
if (selectedImage != null) {
|
||||
g.drawImage(selectedImage, 0, 0, imageSize.width, imageSize.height, this);
|
||||
} else {
|
||||
System.err.println("No selectedImage for button.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
g.drawImage(disabledImage, 0, 0, imageSize.width, imageSize.height, this);
|
||||
}
|
||||
if (overlayImage != null) {
|
||||
g.drawImage(overlayImage, (imageSize.width - overlayImageSize.width) / 2, 10, this);
|
||||
} else if (set != null) {
|
||||
// draw only if it is not current tab
|
||||
if (!drawSet) {
|
||||
g2d.setFont(textSetFontBoldMini);
|
||||
g2d.drawString(set, 5, 25);
|
||||
}
|
||||
}
|
||||
|
||||
if (drawSet && set != null) {
|
||||
g2d.setFont(textSetFontBold);
|
||||
int w = (int) (getWidth() / 2.0);
|
||||
int h = (int) (getHeight() / 2.0);
|
||||
int dy = overlayImage == null ? 15 : 25;
|
||||
g2d.translate(w + 5, h + dy);
|
||||
g2d.rotate(-Math.PI / 2.0);
|
||||
g2d.drawString(set, 0, 0);
|
||||
}
|
||||
}
|
||||
if (drawSet && set != null) {
|
||||
g2d.setFont(textSetFontBold);
|
||||
int w = (int) (getWidth() / 2.0);
|
||||
int h = (int) (getHeight() / 2.0);
|
||||
int dy = overlayImage == null ? 15 : 25;
|
||||
g2d.translate(w + 5, h + dy);
|
||||
g2d.rotate(-Math.PI / 2.0);
|
||||
g2d.drawString(set, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private int calculateOffset(Graphics2D g2d) {
|
||||
if (textOffsetX == -1) { // calculate once
|
||||
FontRenderContext frc = g2d.getFontRenderContext();
|
||||
int textWidth = (int) textFont.getStringBounds(text, frc).getWidth();
|
||||
if (textWidth > buttonSize.width) {
|
||||
g2d.setFont(textFontMini);
|
||||
useMiniFont = true;
|
||||
frc = g2d.getFontRenderContext();
|
||||
textWidth = (int) textFontMini.getStringBounds(text, frc).getWidth();
|
||||
}
|
||||
textOffsetX = (int) ((imageSize.width - textWidth) / 2);
|
||||
}
|
||||
return textOffsetX;
|
||||
}
|
||||
private int calculateOffset(Graphics2D g2d) {
|
||||
if (textOffsetX == -1) { // calculate once
|
||||
FontRenderContext frc = g2d.getFontRenderContext();
|
||||
int textWidth = (int) textFont.getStringBounds(text, frc).getWidth();
|
||||
if (textWidth > buttonSize.width) {
|
||||
g2d.setFont(textFontMini);
|
||||
useMiniFont = true;
|
||||
frc = g2d.getFontRenderContext();
|
||||
textWidth = (int) textFontMini.getStringBounds(text, frc).getWidth();
|
||||
}
|
||||
textOffsetX = (int) ((imageSize.width - textWidth) / 2);
|
||||
}
|
||||
return textOffsetX;
|
||||
}
|
||||
|
||||
public void setTextColor(Color textColor) {
|
||||
this.textColor = textColor;
|
||||
}
|
||||
public void setTextColor(Color textColor) {
|
||||
this.textColor = textColor;
|
||||
}
|
||||
|
||||
public void setOverlayImage(Image image) {
|
||||
this.overlayImage = image;
|
||||
this.overlayImageSize = new Dimension(image.getWidth(null), image.getHeight(null));
|
||||
}
|
||||
public void setOverlayImage(Image image) {
|
||||
this.overlayImage = image;
|
||||
this.overlayImageSize = new Dimension(image.getWidth(null), image.getHeight(null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
}
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
isHovered = true;
|
||||
this.repaint();
|
||||
if (onHover != null) {
|
||||
onHover.execute();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
isHovered = true;
|
||||
this.repaint();
|
||||
if (onHover != null) {
|
||||
onHover.execute();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
isHovered = false;
|
||||
this.repaint();
|
||||
}
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
isHovered = false;
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.getButton() == MouseEvent.BUTTON1) {
|
||||
if (isEnabled() && observer != null) {
|
||||
observer.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.getButton() == MouseEvent.BUTTON1) {
|
||||
if (isEnabled() && observer != null) {
|
||||
observer.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
}
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void setObserver(Command observer) {
|
||||
this.observer = observer;
|
||||
}
|
||||
public void setObserver(Command observer) {
|
||||
this.observer = observer;
|
||||
}
|
||||
|
||||
public void setOnHover(Command onHover) {
|
||||
this.onHover = onHover;
|
||||
}
|
||||
public void setOnHover(Command onHover) {
|
||||
this.onHover = onHover;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBounds(Rectangle r) {
|
||||
super.setBounds(r);
|
||||
this.textOffsetY = r.height - 2;
|
||||
this.buttonSize = r;
|
||||
}
|
||||
@Override
|
||||
public void setBounds(Rectangle r) {
|
||||
super.setBounds(r);
|
||||
this.textOffsetY = r.height - 2;
|
||||
this.buttonSize = r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBounds(int x, int y, int width, int height) {
|
||||
super.setBounds(x, y, width, height);
|
||||
this.textOffsetY = height - 2;
|
||||
this.buttonSize = new Rectangle(x, y, width, height);
|
||||
}
|
||||
@Override
|
||||
public void setBounds(int x, int y, int width, int height) {
|
||||
super.setBounds(x, y, width, height);
|
||||
this.textOffsetY = height - 2;
|
||||
this.buttonSize = new Rectangle(x, y, width, height);
|
||||
}
|
||||
|
||||
public boolean isSelected() {
|
||||
return isSelected;
|
||||
}
|
||||
public boolean isSelected() {
|
||||
return isSelected;
|
||||
}
|
||||
|
||||
public void setSelected(boolean isSelected) {
|
||||
this.isSelected = isSelected;
|
||||
}
|
||||
public void setSelected(boolean isSelected) {
|
||||
this.isSelected = isSelected;
|
||||
}
|
||||
|
||||
public void changeSelected() {
|
||||
this.isSelected = !this.isSelected;
|
||||
}
|
||||
public void changeSelected() {
|
||||
this.isSelected = !this.isSelected;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public void setSet(String set) {
|
||||
this.set = set;
|
||||
}
|
||||
public void setSet(String set) {
|
||||
this.set = set;
|
||||
}
|
||||
|
||||
public void drawSet() {
|
||||
this.drawSet = true;
|
||||
}
|
||||
public void drawSet() {
|
||||
this.drawSet = true;
|
||||
}
|
||||
|
||||
public void update(String text, Image image, Image hover, Image selected, Image disabled, Rectangle size) {
|
||||
this.image = image;
|
||||
this.hoverImage = hover;
|
||||
this.selectedImage = selected;
|
||||
this.disabledImage = disabled;
|
||||
this.imageSize = size;
|
||||
this.text = text;
|
||||
repaint();
|
||||
}
|
||||
public void update(String text, Image image, Image hover, Image selected, Image disabled, Rectangle size) {
|
||||
this.image = image;
|
||||
this.hoverImage = hover;
|
||||
this.selectedImage = selected;
|
||||
this.disabledImage = disabled;
|
||||
this.imageSize = size;
|
||||
this.text = text;
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void execute() {
|
||||
if (isEnabled() && observer != null) {
|
||||
observer.execute();
|
||||
}
|
||||
observer.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
package mage.client.components;
|
||||
|
||||
public enum MageComponents {
|
||||
TABLES_MENU_BUTTON("btnGames"),
|
||||
NEW_GAME_BUTTON("btnNewTable"),
|
||||
NEW_TABLE_OK_BUTTON("btnOK"),
|
||||
TABLE_WAITING_START_BUTTON("btnStart"),
|
||||
DESKTOP_PANE("desktopPane"),
|
||||
TABLES_MENU_BUTTON("btnGames"),
|
||||
NEW_GAME_BUTTON("btnNewTable"),
|
||||
NEW_TABLE_OK_BUTTON("btnOK"),
|
||||
TABLE_WAITING_START_BUTTON("btnStart"),
|
||||
DESKTOP_PANE("desktopPane"),
|
||||
CARD_INFO_PANE("cardInfoPane"),
|
||||
POPUP_CONTAINER("popupContainer");
|
||||
|
||||
private String name;
|
||||
MageComponents(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
private String name;
|
||||
MageComponents(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,13 +64,13 @@ public class MageRoundPane extends JPanel {
|
|||
g2.dispose();
|
||||
}
|
||||
|
||||
public void setXOffset(int x_offset) {
|
||||
X_OFFSET = x_offset;
|
||||
}
|
||||
public void setXOffset(int x_offset) {
|
||||
X_OFFSET = x_offset;
|
||||
}
|
||||
|
||||
public void setYOffset(int y_offset) {
|
||||
Y_OFFSET = y_offset;
|
||||
}
|
||||
public void setYOffset(int y_offset) {
|
||||
Y_OFFSET = y_offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBounds(int x, int y, int width, int height) {
|
||||
|
|
|
@ -14,17 +14,17 @@ import javax.swing.plaf.synth.SynthStyleFactory;
|
|||
* @author nantuko
|
||||
*/
|
||||
public class MageSynthStyleFactory extends SynthStyleFactory {
|
||||
private SynthStyleFactory wrappedFactory;
|
||||
private SynthStyleFactory wrappedFactory;
|
||||
|
||||
public MageSynthStyleFactory(SynthStyleFactory factory) {
|
||||
this.wrappedFactory = factory;
|
||||
}
|
||||
public MageSynthStyleFactory(SynthStyleFactory factory) {
|
||||
this.wrappedFactory = factory;
|
||||
}
|
||||
|
||||
public SynthStyle getStyle(JComponent c, Region id) {
|
||||
SynthStyle s = wrappedFactory.getStyle(c, id);
|
||||
if (id == Region.INTERNAL_FRAME) {
|
||||
s = new TranslucentSynthSytle(s);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
public SynthStyle getStyle(JComponent c, Region id) {
|
||||
SynthStyle s = wrappedFactory.getStyle(c, id);
|
||||
if (id == Region.INTERNAL_FRAME) {
|
||||
s = new TranslucentSynthSytle(s);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
|
@ -8,95 +8,95 @@ import javax.swing.JButton;
|
|||
|
||||
public class MageUI {
|
||||
|
||||
private Map<MageComponents, Component> ui = new HashMap<MageComponents, Component>();
|
||||
private Map<MageComponents, Object> sync = new HashMap<MageComponents, Object>();
|
||||
private Map<MageComponents, Component> ui = new HashMap<MageComponents, Component>();
|
||||
private Map<MageComponents, Object> sync = new HashMap<MageComponents, Object>();
|
||||
|
||||
public JButton getButton(MageComponents name) throws InterruptedException {
|
||||
//System.out.println("request for " + name);
|
||||
Object buttonSync;
|
||||
synchronized (ui) {
|
||||
if (ui.containsKey(name)) {
|
||||
//System.out.println("clicking " + name);
|
||||
return (JButton) ui.get(name);
|
||||
} else {
|
||||
buttonSync = new Object();
|
||||
sync.put(name, buttonSync);
|
||||
}
|
||||
}
|
||||
public JButton getButton(MageComponents name) throws InterruptedException {
|
||||
//System.out.println("request for " + name);
|
||||
Object buttonSync;
|
||||
synchronized (ui) {
|
||||
if (ui.containsKey(name)) {
|
||||
//System.out.println("clicking " + name);
|
||||
return (JButton) ui.get(name);
|
||||
} else {
|
||||
buttonSync = new Object();
|
||||
sync.put(name, buttonSync);
|
||||
}
|
||||
}
|
||||
|
||||
synchronized (buttonSync) {
|
||||
//System.out.println("waiting " + name + " to be created");
|
||||
buttonSync.wait();
|
||||
//System.out.println(name + "was created");
|
||||
if (!ui.containsKey(name)) {
|
||||
throw new IllegalStateException("Component wasn't initialized. This should not happen.");
|
||||
}
|
||||
return (JButton) ui.get(name);
|
||||
}
|
||||
synchronized (buttonSync) {
|
||||
//System.out.println("waiting " + name + " to be created");
|
||||
buttonSync.wait();
|
||||
//System.out.println(name + "was created");
|
||||
if (!ui.containsKey(name)) {
|
||||
throw new IllegalStateException("Component wasn't initialized. This should not happen.");
|
||||
}
|
||||
return (JButton) ui.get(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Component getComponent(MageComponents name) throws InterruptedException {
|
||||
Object componentSync;
|
||||
synchronized (ui) {
|
||||
if (ui.containsKey(name)) {
|
||||
return ui.get(name);
|
||||
} else {
|
||||
componentSync = new Object();
|
||||
sync.put(name, componentSync);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
synchronized (componentSync) {
|
||||
componentSync.wait();
|
||||
if (!ui.containsKey(name)) {
|
||||
throw new IllegalStateException("Component wasn't initialized. This should not happen.");
|
||||
}
|
||||
return ui.get(name);
|
||||
}
|
||||
public Component getComponent(MageComponents name) throws InterruptedException {
|
||||
Object componentSync;
|
||||
synchronized (ui) {
|
||||
if (ui.containsKey(name)) {
|
||||
return ui.get(name);
|
||||
} else {
|
||||
componentSync = new Object();
|
||||
sync.put(name, componentSync);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
synchronized (componentSync) {
|
||||
componentSync.wait();
|
||||
if (!ui.containsKey(name)) {
|
||||
throw new IllegalStateException("Component wasn't initialized. This should not happen.");
|
||||
}
|
||||
return ui.get(name);
|
||||
}
|
||||
|
||||
public void addButton(MageComponents name, JButton button) {
|
||||
synchronized (ui) {
|
||||
//System.out.println("added " + name);
|
||||
ui.put(name, button);
|
||||
if (sync.containsKey(name)) {
|
||||
synchronized (sync.get(name)) {
|
||||
//System.out.println("notifyAll - " + name);
|
||||
sync.get(name).notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addComponent(MageComponents name, Component component) {
|
||||
synchronized (ui) {
|
||||
ui.put(name, component);
|
||||
if (sync.containsKey(name)) {
|
||||
synchronized (sync.get(name)) {
|
||||
sync.get(name).notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void doClick(MageComponents name) throws InterruptedException {
|
||||
doClick(name, 0);
|
||||
}
|
||||
|
||||
public void doClick(MageComponents name, int waitBeforeClick) throws InterruptedException {
|
||||
final JButton j = getButton(name);
|
||||
Thread.sleep(waitBeforeClick);
|
||||
while (!j.isEnabled()) {
|
||||
Thread.sleep(10);
|
||||
}
|
||||
Thread t = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
j.doClick();
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
}
|
||||
|
||||
public void addButton(MageComponents name, JButton button) {
|
||||
synchronized (ui) {
|
||||
//System.out.println("added " + name);
|
||||
ui.put(name, button);
|
||||
if (sync.containsKey(name)) {
|
||||
synchronized (sync.get(name)) {
|
||||
//System.out.println("notifyAll - " + name);
|
||||
sync.get(name).notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addComponent(MageComponents name, Component component) {
|
||||
synchronized (ui) {
|
||||
ui.put(name, component);
|
||||
if (sync.containsKey(name)) {
|
||||
synchronized (sync.get(name)) {
|
||||
sync.get(name).notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void doClick(MageComponents name) throws InterruptedException {
|
||||
doClick(name, 0);
|
||||
}
|
||||
|
||||
public void doClick(MageComponents name, int waitBeforeClick) throws InterruptedException {
|
||||
final JButton j = getButton(name);
|
||||
Thread.sleep(waitBeforeClick);
|
||||
while (!j.isEnabled()) {
|
||||
Thread.sleep(10);
|
||||
}
|
||||
Thread t = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
j.doClick();
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,81 +14,81 @@ import javax.swing.plaf.synth.SynthPainter;
|
|||
import javax.swing.plaf.synth.SynthStyle;
|
||||
|
||||
class TranslucentSynthSytle extends SynthStyle {
|
||||
private final SynthStyle style;
|
||||
private final SynthStyle style;
|
||||
|
||||
public TranslucentSynthSytle(SynthStyle s) {
|
||||
style = s;
|
||||
}
|
||||
public TranslucentSynthSytle(SynthStyle s) {
|
||||
style = s;
|
||||
}
|
||||
|
||||
public Object get(SynthContext context, Object key) {
|
||||
return style.get(context, key);
|
||||
}
|
||||
public Object get(SynthContext context, Object key) {
|
||||
return style.get(context, key);
|
||||
}
|
||||
|
||||
public boolean getBoolean(SynthContext context, Object key,
|
||||
boolean defaultValue) {
|
||||
return style.getBoolean(context, key, defaultValue);
|
||||
}
|
||||
public boolean getBoolean(SynthContext context, Object key,
|
||||
boolean defaultValue) {
|
||||
return style.getBoolean(context, key, defaultValue);
|
||||
}
|
||||
|
||||
public Color getColor(SynthContext context, ColorType type) {
|
||||
return style.getColor(context, type);
|
||||
}
|
||||
public Color getColor(SynthContext context, ColorType type) {
|
||||
return style.getColor(context, type);
|
||||
}
|
||||
|
||||
public Font getFont(SynthContext context) {
|
||||
return style.getFont(context);
|
||||
}
|
||||
public Font getFont(SynthContext context) {
|
||||
return style.getFont(context);
|
||||
}
|
||||
|
||||
public SynthGraphicsUtils getGraphicsUtils(SynthContext context) {
|
||||
return style.getGraphicsUtils(context);
|
||||
}
|
||||
public SynthGraphicsUtils getGraphicsUtils(SynthContext context) {
|
||||
return style.getGraphicsUtils(context);
|
||||
}
|
||||
|
||||
public Icon getIcon(SynthContext context, Object key) {
|
||||
return style.getIcon(context, key);
|
||||
}
|
||||
public Icon getIcon(SynthContext context, Object key) {
|
||||
return style.getIcon(context, key);
|
||||
}
|
||||
|
||||
public Insets getInsets(SynthContext context, Insets insets) {
|
||||
return style.getInsets(context, insets);
|
||||
}
|
||||
public Insets getInsets(SynthContext context, Insets insets) {
|
||||
return style.getInsets(context, insets);
|
||||
}
|
||||
|
||||
public int getInt(SynthContext context, Object key, int defaultValue) {
|
||||
return style.getInt(context, key, defaultValue);
|
||||
}
|
||||
public int getInt(SynthContext context, Object key, int defaultValue) {
|
||||
return style.getInt(context, key, defaultValue);
|
||||
}
|
||||
|
||||
public SynthPainter getPainter(final SynthContext context) {
|
||||
return new SynthPainter() {
|
||||
public void paintInternalFrameBackground(SynthContext context,
|
||||
Graphics g, int x, int y, int w, int h) {
|
||||
g.setColor(new Color(50, 50, 50, 100));
|
||||
g.fillRoundRect(x, y, w, h, 5, 5);
|
||||
}
|
||||
};
|
||||
}
|
||||
public SynthPainter getPainter(final SynthContext context) {
|
||||
return new SynthPainter() {
|
||||
public void paintInternalFrameBackground(SynthContext context,
|
||||
Graphics g, int x, int y, int w, int h) {
|
||||
g.setColor(new Color(50, 50, 50, 100));
|
||||
g.fillRoundRect(x, y, w, h, 5, 5);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public String getString(SynthContext context, Object key,
|
||||
String defaultValue) {
|
||||
return style.getString(context, key, defaultValue);
|
||||
}
|
||||
public String getString(SynthContext context, Object key,
|
||||
String defaultValue) {
|
||||
return style.getString(context, key, defaultValue);
|
||||
}
|
||||
|
||||
public void installDefaults(SynthContext context) {
|
||||
style.installDefaults(context);
|
||||
}
|
||||
public void installDefaults(SynthContext context) {
|
||||
style.installDefaults(context);
|
||||
}
|
||||
|
||||
public void uninstallDefaults(SynthContext context) {
|
||||
style.uninstallDefaults(context);
|
||||
}
|
||||
public void uninstallDefaults(SynthContext context) {
|
||||
style.uninstallDefaults(context);
|
||||
}
|
||||
|
||||
public boolean isOpaque(SynthContext context) {
|
||||
if (context.getRegion() == Region.INTERNAL_FRAME) {
|
||||
return false;
|
||||
} else {
|
||||
return style.isOpaque(context);
|
||||
}
|
||||
}
|
||||
public boolean isOpaque(SynthContext context) {
|
||||
if (context.getRegion() == Region.INTERNAL_FRAME) {
|
||||
return false;
|
||||
} else {
|
||||
return style.isOpaque(context);
|
||||
}
|
||||
}
|
||||
|
||||
public Color getColorForState(SynthContext context, ColorType type) {
|
||||
return null;
|
||||
}
|
||||
public Color getColorForState(SynthContext context, ColorType type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Font getFontForState(SynthContext context) {
|
||||
return null;
|
||||
}
|
||||
public Font getFontForState(SynthContext context) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -29,17 +29,17 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
|||
private static final int DIALOG_WIDTH = 440;
|
||||
private static final int DIALOG_HEIGHT = 260;
|
||||
|
||||
private transient static final Logger log = Logger.getLogger(AbilityPicker.class);
|
||||
private transient static final Logger log = Logger.getLogger(AbilityPicker.class);
|
||||
|
||||
private JList rows;
|
||||
private List<Object> choices;
|
||||
private String message = DEFAULT_MESSAGE;
|
||||
|
||||
private Session session;
|
||||
private UUID gameId;
|
||||
private UUID gameId;
|
||||
|
||||
private BackgroundPainter mwPanelPainter;
|
||||
private JScrollPane jScrollPane2;
|
||||
private JScrollPane jScrollPane2;
|
||||
private JTextField title;
|
||||
|
||||
private Image rightImage;
|
||||
|
@ -51,213 +51,213 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
|||
private static Color SELECTED_COLOR = new Color(64,147,208);
|
||||
private static Color BORDER_COLOR = new Color(0,0,0,50);
|
||||
|
||||
private boolean selected = false;
|
||||
private boolean selected = false;
|
||||
|
||||
public AbilityPicker() {
|
||||
setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
|
||||
initComponents();
|
||||
initComponents();
|
||||
|
||||
jScrollPane2.setOpaque(false);
|
||||
jScrollPane2.setOpaque(false);
|
||||
jScrollPane2.getViewport().setOpaque(false);
|
||||
UIManager.put( "ScrollBar.width", 17);
|
||||
jScrollPane2.getHorizontalScrollBar().setUI(new MageScrollbarUI());
|
||||
UIManager.put( "ScrollBar.width", 17);
|
||||
jScrollPane2.getHorizontalScrollBar().setUI(new MageScrollbarUI());
|
||||
jScrollPane2.getVerticalScrollBar().setUI(new MageScrollbarUI());
|
||||
}
|
||||
|
||||
public AbilityPicker(List<Object> choices, String message) {
|
||||
this.choices = choices;
|
||||
setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
|
||||
if (message!= null) {
|
||||
this.message = message + " (single-click)";
|
||||
}
|
||||
initComponents();
|
||||
jScrollPane2.setOpaque(false);
|
||||
jScrollPane2.getViewport().setOpaque(false);
|
||||
UIManager.put( "ScrollBar.width", 17);
|
||||
jScrollPane2.getHorizontalScrollBar().setUI(new MageScrollbarUI());
|
||||
jScrollPane2.getVerticalScrollBar().setUI(new MageScrollbarUI());
|
||||
}
|
||||
this.choices = choices;
|
||||
setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
|
||||
if (message!= null) {
|
||||
this.message = message + " (single-click)";
|
||||
}
|
||||
initComponents();
|
||||
jScrollPane2.setOpaque(false);
|
||||
jScrollPane2.getViewport().setOpaque(false);
|
||||
UIManager.put( "ScrollBar.width", 17);
|
||||
jScrollPane2.getHorizontalScrollBar().setUI(new MageScrollbarUI());
|
||||
jScrollPane2.getVerticalScrollBar().setUI(new MageScrollbarUI());
|
||||
}
|
||||
|
||||
public void init(Session session, UUID gameId) {
|
||||
this.session = session;
|
||||
this.gameId = gameId;
|
||||
}
|
||||
this.session = session;
|
||||
this.gameId = gameId;
|
||||
}
|
||||
|
||||
public void show(AbilityPickerView choices, Point p) {
|
||||
this.choices = new ArrayList<Object>();
|
||||
this.selected = true; // to stop previous modal
|
||||
this.selected = true; // to stop previous modal
|
||||
|
||||
for (Map.Entry<UUID, String> choice: choices.getChoices().entrySet()) {
|
||||
this.choices.add(new AbilityPickerAction(choice.getKey(), choice.getValue()));
|
||||
}
|
||||
for (Map.Entry<UUID, String> choice: choices.getChoices().entrySet()) {
|
||||
this.choices.add(new AbilityPickerAction(choice.getKey(), choice.getValue()));
|
||||
}
|
||||
this.choices.add(new AbilityPickerAction(null, "Cancel"));
|
||||
|
||||
show(this.choices);
|
||||
}
|
||||
show(this.choices);
|
||||
}
|
||||
|
||||
private void show(List<Object> choices) {
|
||||
this.choices = choices;
|
||||
this.selected = true; // to stop previous modal
|
||||
private void show(List<Object> choices) {
|
||||
this.choices = choices;
|
||||
this.selected = true; // to stop previous modal
|
||||
|
||||
rows.setListData(this.choices.toArray());
|
||||
this.rows.setSelectedIndex(0);
|
||||
this.selected = false; // back to false - waiting for selection
|
||||
setVisible(true);
|
||||
rows.setListData(this.choices.toArray());
|
||||
this.rows.setSelectedIndex(0);
|
||||
this.selected = false; // back to false - waiting for selection
|
||||
setVisible(true);
|
||||
|
||||
Point centered = SettingsManager.getInstance().getComponentPosition(DIALOG_WIDTH, DIALOG_HEIGHT);
|
||||
this.setLocation(centered.x, centered.y);
|
||||
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, this);
|
||||
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, this);
|
||||
|
||||
//startModal();
|
||||
}
|
||||
//startModal();
|
||||
}
|
||||
|
||||
public void initComponents() {
|
||||
JLabel jLabel1;
|
||||
JLabel jLabel3;
|
||||
JLabel jLabel3;
|
||||
|
||||
Color textColor = Color.white;
|
||||
Color textColor = Color.white;
|
||||
|
||||
mwPanelPainter = new BackgroundPainter();
|
||||
jLabel1 = new JLabel();
|
||||
jLabel3 = new JLabel();
|
||||
mwPanelPainter = new BackgroundPainter();
|
||||
jLabel1 = new JLabel();
|
||||
jLabel3 = new JLabel();
|
||||
|
||||
title = new JTextField();
|
||||
jScrollPane2 = new JScrollPane();
|
||||
title = new JTextField();
|
||||
jScrollPane2 = new JScrollPane();
|
||||
|
||||
setBackground(textColor);
|
||||
setBackgroundPainter(mwPanelPainter);
|
||||
jLabel1.setFont(new Font("Times New Roman", 1, 18));
|
||||
jLabel1.setForeground(textColor);
|
||||
jLabel1.setText(message);
|
||||
setBackground(textColor);
|
||||
setBackgroundPainter(mwPanelPainter);
|
||||
jLabel1.setFont(new Font("Times New Roman", 1, 18));
|
||||
jLabel1.setForeground(textColor);
|
||||
jLabel1.setText(message);
|
||||
|
||||
jLabel3.setForeground(textColor);
|
||||
jLabel3.setHorizontalAlignment(SwingConstants.TRAILING);
|
||||
jLabel3.setText("Selected:");
|
||||
jLabel3.setForeground(textColor);
|
||||
jLabel3.setHorizontalAlignment(SwingConstants.TRAILING);
|
||||
jLabel3.setText("Selected:");
|
||||
|
||||
title.setFont(new Font("Tahoma", 1, 11));
|
||||
title.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
|
||||
title.setFont(new Font("Tahoma", 1, 11));
|
||||
title.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
|
||||
|
||||
jScrollPane2.setBorder(null);
|
||||
jScrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
jScrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||
jScrollPane2.setBorder(null);
|
||||
jScrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
jScrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||
|
||||
rightImage = ImageHelper.loadImage(IMAGE_RIGHT_PATH);
|
||||
rightImageHovered = ImageHelper.loadImage(IMAGE_RIGHT_HOVERED_PATH);
|
||||
rightImage = ImageHelper.loadImage(IMAGE_RIGHT_PATH);
|
||||
rightImageHovered = ImageHelper.loadImage(IMAGE_RIGHT_HOVERED_PATH);
|
||||
|
||||
setOpaque(false);
|
||||
setOpaque(false);
|
||||
|
||||
rows = new JList();
|
||||
|
||||
rows.setBackground(textColor);
|
||||
rows.setCellRenderer(new ImageRenderer());
|
||||
rows.ensureIndexIsVisible(rows.getModel().getSize());
|
||||
rows.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
rows.setLayoutOrientation(JList.VERTICAL);
|
||||
rows.setMaximumSize(new Dimension(32767, 32767));
|
||||
rows.setMinimumSize(new Dimension(67, 16));
|
||||
rows.setOpaque(false);
|
||||
rows.addMouseListener(new MouseAdapter() {
|
||||
rows.setBackground(textColor);
|
||||
rows.setCellRenderer(new ImageRenderer());
|
||||
rows.ensureIndexIsVisible(rows.getModel().getSize());
|
||||
rows.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
rows.setLayoutOrientation(JList.VERTICAL);
|
||||
rows.setMaximumSize(new Dimension(32767, 32767));
|
||||
rows.setMinimumSize(new Dimension(67, 16));
|
||||
rows.setOpaque(false);
|
||||
rows.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent evt) {
|
||||
if (evt.getButton() == MouseEvent.BUTTON1) {
|
||||
objectMouseClicked(evt);
|
||||
}
|
||||
}
|
||||
});
|
||||
rows.setSelectedIndex(0);
|
||||
rows.setFont(new Font("Times New Roman", 1, 17));
|
||||
rows.setBorder(BorderFactory.createEmptyBorder());
|
||||
rows.addMouseWheelListener(this);
|
||||
rows.setSelectedIndex(0);
|
||||
rows.setFont(new Font("Times New Roman", 1, 17));
|
||||
rows.setBorder(BorderFactory.createEmptyBorder());
|
||||
rows.addMouseWheelListener(this);
|
||||
|
||||
jScrollPane2.setViewportView(rows);
|
||||
jScrollPane2.setViewportBorder(BorderFactory.createEmptyBorder());
|
||||
jScrollPane2.setViewportView(rows);
|
||||
jScrollPane2.setViewportBorder(BorderFactory.createEmptyBorder());
|
||||
|
||||
GroupLayout layout = new GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
GroupLayout layout = new GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
|
||||
layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.LEADING).add(
|
||||
GroupLayout.TRAILING,
|
||||
layout.createSequentialGroup().addContainerGap().add(
|
||||
layout.createParallelGroup(GroupLayout.TRAILING).add(GroupLayout.LEADING, jScrollPane2, GroupLayout.DEFAULT_SIZE, 422, Short.MAX_VALUE).add(GroupLayout.LEADING,
|
||||
layout.createSequentialGroup().add(jLabel1).addPreferredGap(LayoutStyle.RELATED, 175, Short.MAX_VALUE).add(1, 1, 1)).add(
|
||||
GroupLayout.LEADING,
|
||||
layout.createSequentialGroup().add(layout.createParallelGroup(GroupLayout.LEADING)
|
||||
)
|
||||
.addPreferredGap(LayoutStyle.RELATED)
|
||||
.add(
|
||||
layout.createParallelGroup(GroupLayout.TRAILING)
|
||||
.add(
|
||||
GroupLayout.TRAILING,
|
||||
layout.createSequentialGroup().addContainerGap().add(
|
||||
layout.createParallelGroup(GroupLayout.TRAILING).add(GroupLayout.LEADING, jScrollPane2, GroupLayout.DEFAULT_SIZE, 422, Short.MAX_VALUE).add(GroupLayout.LEADING,
|
||||
layout.createSequentialGroup().add(jLabel1).addPreferredGap(LayoutStyle.RELATED, 175, Short.MAX_VALUE).add(1, 1, 1)).add(
|
||||
GroupLayout.LEADING,
|
||||
layout.createSequentialGroup().add(layout.createParallelGroup(GroupLayout.LEADING)
|
||||
)
|
||||
.addPreferredGap(LayoutStyle.RELATED)
|
||||
.add(
|
||||
layout.createParallelGroup(GroupLayout.TRAILING)
|
||||
.add(
|
||||
GroupLayout.LEADING, layout.createParallelGroup(GroupLayout.LEADING))))).add(10, 10, 10)));
|
||||
|
||||
layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.LEADING).add(
|
||||
layout.createSequentialGroup().add(
|
||||
layout.createParallelGroup(GroupLayout.LEADING).add(
|
||||
layout.createSequentialGroup().add(jLabel1, GroupLayout.PREFERRED_SIZE, 36, GroupLayout.PREFERRED_SIZE)
|
||||
.add(5, 5, 5)
|
||||
.add(
|
||||
layout.createParallelGroup(GroupLayout.BASELINE)
|
||||
)
|
||||
).add(layout.createSequentialGroup().add(8, 8, 8)))
|
||||
.addPreferredGap(LayoutStyle.RELATED).add(layout.createParallelGroup(GroupLayout.BASELINE)).addPreferredGap(LayoutStyle.RELATED).add(
|
||||
layout.createParallelGroup(GroupLayout.BASELINE)).addPreferredGap(LayoutStyle.RELATED).add(layout.createParallelGroup(GroupLayout.LEADING)).addPreferredGap(
|
||||
LayoutStyle.RELATED).add(jScrollPane2, GroupLayout.PREFERRED_SIZE, 180, GroupLayout.PREFERRED_SIZE).addContainerGap(23, Short.MAX_VALUE)));
|
||||
layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.LEADING).add(
|
||||
layout.createSequentialGroup().add(
|
||||
layout.createParallelGroup(GroupLayout.LEADING).add(
|
||||
layout.createSequentialGroup().add(jLabel1, GroupLayout.PREFERRED_SIZE, 36, GroupLayout.PREFERRED_SIZE)
|
||||
.add(5, 5, 5)
|
||||
.add(
|
||||
layout.createParallelGroup(GroupLayout.BASELINE)
|
||||
)
|
||||
).add(layout.createSequentialGroup().add(8, 8, 8)))
|
||||
.addPreferredGap(LayoutStyle.RELATED).add(layout.createParallelGroup(GroupLayout.BASELINE)).addPreferredGap(LayoutStyle.RELATED).add(
|
||||
layout.createParallelGroup(GroupLayout.BASELINE)).addPreferredGap(LayoutStyle.RELATED).add(layout.createParallelGroup(GroupLayout.LEADING)).addPreferredGap(
|
||||
LayoutStyle.RELATED).add(jScrollPane2, GroupLayout.PREFERRED_SIZE, 180, GroupLayout.PREFERRED_SIZE).addContainerGap(23, Short.MAX_VALUE)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||
int notches = e.getWheelRotation();
|
||||
int index = rows.getSelectedIndex();
|
||||
int index = rows.getSelectedIndex();
|
||||
|
||||
if (notches < 0) {
|
||||
if (index > 0) {
|
||||
rows.setSelectedIndex(index-1);
|
||||
rows.repaint();
|
||||
}
|
||||
} else {
|
||||
if (index < choices.size() - 1) {
|
||||
rows.setSelectedIndex(index+1);
|
||||
rows.repaint();
|
||||
}
|
||||
}
|
||||
if (notches < 0) {
|
||||
if (index > 0) {
|
||||
rows.setSelectedIndex(index-1);
|
||||
rows.repaint();
|
||||
}
|
||||
} else {
|
||||
if (index < choices.size() - 1) {
|
||||
rows.setSelectedIndex(index+1);
|
||||
rows.repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void objectMouseClicked(MouseEvent event) {
|
||||
int index = rows.getSelectedIndex();
|
||||
AbilityPickerAction action = (AbilityPickerAction)choices.get(index);
|
||||
int index = rows.getSelectedIndex();
|
||||
AbilityPickerAction action = (AbilityPickerAction)choices.get(index);
|
||||
action.actionPerformed(null);
|
||||
}
|
||||
}
|
||||
|
||||
class ImageRenderer extends DefaultListCellRenderer {
|
||||
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
|
||||
JLabel label = ((JLabel) c);
|
||||
label.setOpaque(false);
|
||||
label.setForeground(Color.white);
|
||||
JLabel label = ((JLabel) c);
|
||||
label.setOpaque(false);
|
||||
label.setForeground(Color.white);
|
||||
|
||||
if (choices.size() <= index) return label;
|
||||
if (choices.size() <= index) return label;
|
||||
|
||||
Object object = choices.get(index);
|
||||
String name = object.toString();
|
||||
label.setText(name);
|
||||
Object object = choices.get(index);
|
||||
String name = object.toString();
|
||||
label.setText(name);
|
||||
|
||||
if (isSelected) {
|
||||
label.setIcon(new ImageIcon(rightImageHovered));
|
||||
label.setForeground(SELECTED_COLOR);
|
||||
//label.setBorder(BorderFactory.createLineBorder(BORDER_COLOR));
|
||||
label.setBorder(BorderFactory.createEmptyBorder());
|
||||
} else {
|
||||
label.setIcon(new ImageIcon(rightImage));
|
||||
}
|
||||
if (isSelected) {
|
||||
label.setIcon(new ImageIcon(rightImageHovered));
|
||||
label.setForeground(SELECTED_COLOR);
|
||||
//label.setBorder(BorderFactory.createLineBorder(BORDER_COLOR));
|
||||
label.setBorder(BorderFactory.createEmptyBorder());
|
||||
} else {
|
||||
label.setIcon(new ImageIcon(rightImage));
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 7689696087189956997L;
|
||||
}
|
||||
private static final long serialVersionUID = 7689696087189956997L;
|
||||
}
|
||||
|
||||
private synchronized void startModal() {
|
||||
try {
|
||||
private synchronized void startModal() {
|
||||
try {
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
EventQueue theQueue = getToolkit().getSystemEventQueue();
|
||||
while (!selected) {
|
||||
|
@ -268,17 +268,17 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
|||
/*if (event instanceof MouseEvent) {
|
||||
MouseEvent e = (MouseEvent) event;
|
||||
if (e.getID() == MouseEvent.MOUSE_PRESSED || e.getID() == MouseEvent.MOUSE_CLICKED) {
|
||||
MouseEvent m = SwingUtilities.convertMouseEvent((Component) e.getSource(), e, this);
|
||||
if (!this.contains(m.getPoint())) {
|
||||
selected = true;
|
||||
cancel();
|
||||
setVisible(false);
|
||||
dispatch = false;
|
||||
}
|
||||
}
|
||||
MouseEvent m = SwingUtilities.convertMouseEvent((Component) e.getSource(), e, this);
|
||||
if (!this.contains(m.getPoint())) {
|
||||
selected = true;
|
||||
cancel();
|
||||
setVisible(false);
|
||||
dispatch = false;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if (event instanceof MouseEvent) {
|
||||
if (event instanceof MouseEvent) {
|
||||
MouseEvent e = (MouseEvent) event;
|
||||
MouseEvent m = SwingUtilities.convertMouseEvent((Component) e.getSource(), e, this);
|
||||
if (!this.contains(m.getPoint()) && e.getID() != MouseEvent.MOUSE_DRAGGED) {
|
||||
|
@ -307,72 +307,72 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
|
|||
}
|
||||
|
||||
public static void main(String[] argv) {
|
||||
try {
|
||||
try {
|
||||
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
|
||||
JFrame jframe = new JFrame("Test");
|
||||
JFrame jframe = new JFrame("Test");
|
||||
|
||||
List<Object> objectList = new ArrayList<Object>();
|
||||
objectList.add("T: add {R} to your mana pool. 111111111111111111111111111");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("Cancel");
|
||||
AbilityPicker panel = new AbilityPicker(objectList, "Choose ability");
|
||||
jframe.add(panel);
|
||||
panel.show(objectList);
|
||||
jframe.setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
|
||||
jframe.setVisible(true);
|
||||
}
|
||||
List<Object> objectList = new ArrayList<Object>();
|
||||
objectList.add("T: add {R} to your mana pool. 111111111111111111111111111");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("T: add {B} to your mana pool");
|
||||
objectList.add("Cancel");
|
||||
AbilityPicker panel = new AbilityPicker(objectList, "Choose ability");
|
||||
jframe.add(panel);
|
||||
panel.show(objectList);
|
||||
jframe.setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
|
||||
jframe.setVisible(true);
|
||||
}
|
||||
|
||||
public class AbilityPickerAction extends AbstractAction {
|
||||
|
||||
private UUID id;
|
||||
private UUID id;
|
||||
|
||||
public AbilityPickerAction(UUID id, String choice) {
|
||||
this.id = id;
|
||||
putValue(Action.NAME, choice);
|
||||
}
|
||||
public AbilityPickerAction(UUID id, String choice) {
|
||||
this.id = id;
|
||||
putValue(Action.NAME, choice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// cancel
|
||||
if (id == null) {
|
||||
cancel();
|
||||
} else {
|
||||
session.sendPlayerUUID(gameId, id);
|
||||
session.sendPlayerUUID(gameId, id);
|
||||
}
|
||||
setVisible(false);
|
||||
AbilityPicker.this.selected = true;
|
||||
}
|
||||
setVisible(false);
|
||||
AbilityPicker.this.selected = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return (String)getValue(Action.NAME);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void cancel() {
|
||||
try {
|
||||
session.sendPlayerBoolean(gameId, false);
|
||||
} catch (Exception e) {
|
||||
log.error("Couldn't cancel choose dialog: " + e, e);
|
||||
}
|
||||
}
|
||||
private void cancel() {
|
||||
try {
|
||||
session.sendPlayerBoolean(gameId, false);
|
||||
} catch (Exception e) {
|
||||
log.error("Couldn't cancel choose dialog: " + e, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,60 +16,60 @@ 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 ImageIcon buttonLeft;
|
||||
private static ImageIcon buttonRight;
|
||||
private static ImageIcon buttonUp;
|
||||
private static ImageIcon buttonDown;
|
||||
|
||||
private int width;
|
||||
private int width;
|
||||
|
||||
static {
|
||||
buttonLeft = new ImageIcon(MageScrollButton.class.getResource("/buttons/left.png"));
|
||||
buttonRight = new ImageIcon(MageScrollButton.class.getResource("/buttons/right.png"));
|
||||
buttonUp = new ImageIcon(MageScrollButton.class.getResource("/buttons/up.png"));
|
||||
buttonDown = new ImageIcon(MageScrollButton.class.getResource("/buttons/down.png"));
|
||||
}
|
||||
static {
|
||||
buttonLeft = new ImageIcon(MageScrollButton.class.getResource("/buttons/left.png"));
|
||||
buttonRight = new ImageIcon(MageScrollButton.class.getResource("/buttons/right.png"));
|
||||
buttonUp = new ImageIcon(MageScrollButton.class.getResource("/buttons/up.png"));
|
||||
buttonDown = new ImageIcon(MageScrollButton.class.getResource("/buttons/down.png"));
|
||||
}
|
||||
|
||||
public MageScrollButton(int direction, int width, boolean freeStanding) {
|
||||
super(direction, width, freeStanding);
|
||||
setOpaque(false);
|
||||
this.width = width;
|
||||
buttonUp.setImage(buttonUp.getImage().getScaledInstance(width, width, Image.SCALE_SMOOTH));
|
||||
buttonDown.setImage(buttonDown.getImage().getScaledInstance(width, width, Image.SCALE_SMOOTH));
|
||||
buttonLeft.setImage(buttonLeft.getImage().getScaledInstance(width, width, Image.SCALE_SMOOTH));
|
||||
buttonRight.setImage(buttonRight.getImage().getScaledInstance(width, width, Image.SCALE_SMOOTH));
|
||||
}
|
||||
public MageScrollButton(int direction, int width, boolean freeStanding) {
|
||||
super(direction, width, freeStanding);
|
||||
setOpaque(false);
|
||||
this.width = width;
|
||||
buttonUp.setImage(buttonUp.getImage().getScaledInstance(width, width, Image.SCALE_SMOOTH));
|
||||
buttonDown.setImage(buttonDown.getImage().getScaledInstance(width, width, Image.SCALE_SMOOTH));
|
||||
buttonLeft.setImage(buttonLeft.getImage().getScaledInstance(width, width, Image.SCALE_SMOOTH));
|
||||
buttonRight.setImage(buttonRight.getImage().getScaledInstance(width, width, Image.SCALE_SMOOTH));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMaximumSize() {
|
||||
return this.getPreferredSize();
|
||||
}
|
||||
@Override
|
||||
public Dimension getMaximumSize() {
|
||||
return this.getPreferredSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
return this.getPreferredSize();
|
||||
}
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
return this.getPreferredSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension(width, width);
|
||||
}
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension(width, width);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
switch (getDirection()) {
|
||||
case BasicArrowButton.WEST:
|
||||
buttonLeft.paintIcon(null, g, 0, 0);
|
||||
break;
|
||||
case BasicArrowButton.EAST:
|
||||
buttonRight.paintIcon(null, g, 0, 0);
|
||||
break;
|
||||
case BasicArrowButton.NORTH:
|
||||
buttonUp.paintIcon(null, g, 0, 0);
|
||||
break;
|
||||
case BasicArrowButton.SOUTH:
|
||||
buttonDown.paintIcon(null, g, 0, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
switch (getDirection()) {
|
||||
case BasicArrowButton.WEST:
|
||||
buttonLeft.paintIcon(null, g, 0, 0);
|
||||
break;
|
||||
case BasicArrowButton.EAST:
|
||||
buttonRight.paintIcon(null, g, 0, 0);
|
||||
break;
|
||||
case BasicArrowButton.NORTH:
|
||||
buttonUp.paintIcon(null, g, 0, 0);
|
||||
break;
|
||||
case BasicArrowButton.SOUTH:
|
||||
buttonDown.paintIcon(null, g, 0, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,139 +27,139 @@ import javax.swing.plaf.metal.MetalScrollBarUI;
|
|||
*/
|
||||
public class MageScrollbarUI extends MetalScrollBarUI {
|
||||
|
||||
private static int ANTI_WIDTH = -3;
|
||||
private static int ANTI_WIDTH = -3;
|
||||
|
||||
@Override
|
||||
public void installUI(JComponent c) {
|
||||
super.installUI(c);
|
||||
c.setOpaque(false);
|
||||
}
|
||||
@Override
|
||||
public void installUI(JComponent c) {
|
||||
super.installUI(c);
|
||||
c.setOpaque(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JButton createDecreaseButton(int orientation) {
|
||||
decreaseButton = new MageScrollButton(orientation, scrollBarWidth + ANTI_WIDTH, isFreeStanding);
|
||||
return decreaseButton;
|
||||
}
|
||||
@Override
|
||||
protected JButton createDecreaseButton(int orientation) {
|
||||
decreaseButton = new MageScrollButton(orientation, scrollBarWidth + ANTI_WIDTH, isFreeStanding);
|
||||
return decreaseButton;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JButton createIncreaseButton(int orientation) {
|
||||
increaseButton = new MageScrollButton(orientation, scrollBarWidth + ANTI_WIDTH, isFreeStanding);
|
||||
return increaseButton;
|
||||
}
|
||||
@Override
|
||||
protected JButton createIncreaseButton(int orientation) {
|
||||
increaseButton = new MageScrollButton(orientation, scrollBarWidth + ANTI_WIDTH, isFreeStanding);
|
||||
return increaseButton;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
@Override
|
||||
protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
|
||||
int width = trackBounds.width - 4 + ANTI_WIDTH;
|
||||
int height = trackBounds.height;
|
||||
if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
|
||||
int width = trackBounds.width - 4 + ANTI_WIDTH;
|
||||
int height = trackBounds.height;
|
||||
|
||||
g2.translate(trackBounds.x + 2, trackBounds.y);
|
||||
g2.translate(trackBounds.x + 2, trackBounds.y);
|
||||
|
||||
Rectangle2D casing = new Rectangle2D.Double(0, 0, width, height);
|
||||
g2.setColor(Color.BLACK);
|
||||
Rectangle2D casing = new Rectangle2D.Double(0, 0, width, height);
|
||||
g2.setColor(Color.BLACK);
|
||||
|
||||
float alpha = 0.5f;
|
||||
Composite composite = g2.getComposite();
|
||||
if (composite instanceof AlphaComposite) {
|
||||
alpha *= ((AlphaComposite) composite).getAlpha();
|
||||
}
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
|
||||
g2.fill(casing);
|
||||
g2.setComposite(composite);
|
||||
float alpha = 0.5f;
|
||||
Composite composite = g2.getComposite();
|
||||
if (composite instanceof AlphaComposite) {
|
||||
alpha *= ((AlphaComposite) composite).getAlpha();
|
||||
}
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
|
||||
g2.fill(casing);
|
||||
g2.setComposite(composite);
|
||||
|
||||
g2.drawLine(-1, 0, -1, height);
|
||||
g2.drawLine(-2, 0, -2, height);
|
||||
g2.drawLine(-1, 0, -1, height);
|
||||
g2.drawLine(-2, 0, -2, height);
|
||||
|
||||
g2.drawLine(width, 0, width, height);
|
||||
g2.drawLine(width + 1, 0, width + 1, height);
|
||||
g2.drawLine(width, 0, width, height);
|
||||
g2.drawLine(width + 1, 0, width + 1, height);
|
||||
|
||||
RoundRectangle2D roundCasing = new RoundRectangle2D.Double(0, 2, width, height - 4, width, width);
|
||||
Area area = new Area(casing);
|
||||
area.subtract(new Area(roundCasing));
|
||||
g2.fill(area);
|
||||
RoundRectangle2D roundCasing = new RoundRectangle2D.Double(0, 2, width, height - 4, width, width);
|
||||
Area area = new Area(casing);
|
||||
area.subtract(new Area(roundCasing));
|
||||
g2.fill(area);
|
||||
|
||||
g2.translate(-trackBounds.x - 2, -trackBounds.y);
|
||||
} else {
|
||||
int width = trackBounds.width;
|
||||
int height = trackBounds.height - 4 + ANTI_WIDTH;
|
||||
g2.translate(-trackBounds.x - 2, -trackBounds.y);
|
||||
} else {
|
||||
int width = trackBounds.width;
|
||||
int height = trackBounds.height - 4 + ANTI_WIDTH;
|
||||
|
||||
g2.translate(trackBounds.x, trackBounds.y + 2);
|
||||
g2.translate(trackBounds.x, trackBounds.y + 2);
|
||||
|
||||
Rectangle2D casing = new Rectangle2D.Double(0, 0, width, height);
|
||||
g2.setColor(Color.BLACK);
|
||||
Rectangle2D casing = new Rectangle2D.Double(0, 0, width, height);
|
||||
g2.setColor(Color.BLACK);
|
||||
|
||||
float alpha = 0.5f;
|
||||
Composite composite = g2.getComposite();
|
||||
if (composite instanceof AlphaComposite) {
|
||||
alpha *= ((AlphaComposite) composite).getAlpha();
|
||||
}
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
|
||||
g2.fill(casing);
|
||||
g2.setComposite(composite);
|
||||
float alpha = 0.5f;
|
||||
Composite composite = g2.getComposite();
|
||||
if (composite instanceof AlphaComposite) {
|
||||
alpha *= ((AlphaComposite) composite).getAlpha();
|
||||
}
|
||||
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
|
||||
g2.fill(casing);
|
||||
g2.setComposite(composite);
|
||||
|
||||
g2.drawLine(0, -1, width, -1);
|
||||
g2.drawLine(0, -2, width, -2);
|
||||
g2.drawLine(0, -1, width, -1);
|
||||
g2.drawLine(0, -2, width, -2);
|
||||
|
||||
g2.drawLine(0, height, width, height);
|
||||
g2.drawLine(0, height + 1, width, height + 1);
|
||||
g2.drawLine(0, height, width, height);
|
||||
g2.drawLine(0, height + 1, width, height + 1);
|
||||
|
||||
RoundRectangle2D roundCasing = new RoundRectangle2D.Double(2, 0, width - 4, height, height, height);
|
||||
Area area = new Area(casing);
|
||||
area.subtract(new Area(roundCasing));
|
||||
g2.fill(area);
|
||||
RoundRectangle2D roundCasing = new RoundRectangle2D.Double(2, 0, width - 4, height, height, height);
|
||||
Area area = new Area(casing);
|
||||
area.subtract(new Area(roundCasing));
|
||||
g2.fill(area);
|
||||
|
||||
g2.translate(-trackBounds.x, -trackBounds.y - 2);
|
||||
}
|
||||
g2.translate(-trackBounds.x, -trackBounds.y - 2);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
@Override
|
||||
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
|
||||
g2.translate(thumbBounds.x + 1, thumbBounds.y + 2);
|
||||
if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
|
||||
g2.translate(thumbBounds.x + 1, thumbBounds.y + 2);
|
||||
|
||||
int width = thumbBounds.width - 3 + ANTI_WIDTH;
|
||||
int height = thumbBounds.height - 4;
|
||||
int width = thumbBounds.width - 3 + ANTI_WIDTH;
|
||||
int height = thumbBounds.height - 4;
|
||||
|
||||
RoundRectangle2D casing = new RoundRectangle2D.Double(0, 0, width, height, width, width);
|
||||
g2.setColor(Color.BLACK);
|
||||
Paint paint = g2.getPaint();
|
||||
g2.setPaint(new GradientPaint(0, 0, new Color(0x818a9b), 0, height, new Color(0x3a4252)));
|
||||
g2.fill(casing);
|
||||
g2.setPaint(paint);
|
||||
RoundRectangle2D casing = new RoundRectangle2D.Double(0, 0, width, height, width, width);
|
||||
g2.setColor(Color.BLACK);
|
||||
Paint paint = g2.getPaint();
|
||||
g2.setPaint(new GradientPaint(0, 0, new Color(0x818a9b), 0, height, new Color(0x3a4252)));
|
||||
g2.fill(casing);
|
||||
g2.setPaint(paint);
|
||||
|
||||
Stroke stroke = g2.getStroke();
|
||||
g2.setStroke(new BasicStroke(2.0f));
|
||||
g2.draw(casing);
|
||||
g2.setStroke(stroke);
|
||||
Stroke stroke = g2.getStroke();
|
||||
g2.setStroke(new BasicStroke(2.0f));
|
||||
g2.draw(casing);
|
||||
g2.setStroke(stroke);
|
||||
|
||||
g2.translate(-thumbBounds.x - 1, -thumbBounds.y - 2);
|
||||
} else {
|
||||
g2.translate(thumbBounds.x + 2, thumbBounds.y + 1);
|
||||
g2.translate(-thumbBounds.x - 1, -thumbBounds.y - 2);
|
||||
} else {
|
||||
g2.translate(thumbBounds.x + 2, thumbBounds.y + 1);
|
||||
|
||||
int width = thumbBounds.width - 4;
|
||||
int height = thumbBounds.height - 3 + ANTI_WIDTH;
|
||||
int width = thumbBounds.width - 4;
|
||||
int height = thumbBounds.height - 3 + ANTI_WIDTH;
|
||||
|
||||
RoundRectangle2D casing = new RoundRectangle2D.Double(0, 0, width, height, height, height);
|
||||
g2.setColor(Color.BLACK);
|
||||
RoundRectangle2D casing = new RoundRectangle2D.Double(0, 0, width, height, height, height);
|
||||
g2.setColor(Color.BLACK);
|
||||
|
||||
Paint paint = g2.getPaint();
|
||||
g2.setPaint(new GradientPaint(0, 0, new Color(0x818a9b), 0, height, new Color(0x3a4252)));
|
||||
g2.fill(casing);
|
||||
g2.setPaint(paint);
|
||||
Paint paint = g2.getPaint();
|
||||
g2.setPaint(new GradientPaint(0, 0, new Color(0x818a9b), 0, height, new Color(0x3a4252)));
|
||||
g2.fill(casing);
|
||||
g2.setPaint(paint);
|
||||
|
||||
Stroke stroke = g2.getStroke();
|
||||
g2.setStroke(new BasicStroke(2.0f));
|
||||
g2.draw(casing);
|
||||
g2.setStroke(stroke);
|
||||
Stroke stroke = g2.getStroke();
|
||||
g2.setStroke(new BasicStroke(2.0f));
|
||||
g2.draw(casing);
|
||||
g2.setStroke(stroke);
|
||||
|
||||
g2.translate(-thumbBounds.x - 2, -thumbBounds.y - 1);
|
||||
}
|
||||
}
|
||||
g2.translate(-thumbBounds.x - 2, -thumbBounds.y - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,14 +28,14 @@ public class DialogContainer extends JPanel {
|
|||
|
||||
private boolean drawContainer = true;
|
||||
private DialogManager.MTGDialogs dialogType;
|
||||
|
||||
|
||||
public DialogContainer(DialogManager.MTGDialogs dialogType, DlgParams params) {
|
||||
setOpaque(false);
|
||||
this.dialogType = dialogType;
|
||||
|
||||
setLayout(null);
|
||||
drawContainer = true;
|
||||
|
||||
|
||||
if (dialogType == DialogManager.MTGDialogs.MessageDialog) {
|
||||
//backgroundColor = new Color(0, 255, 255, 60);
|
||||
if (params.type.equals(MessageDlg.Types.Warning)) {
|
||||
|
@ -74,10 +74,10 @@ public class DialogContainer extends JPanel {
|
|||
//backgroundColor = new Color(200, 200, 172, 120);
|
||||
//backgroundColor = new Color(180, 150, 200, 120);
|
||||
//backgroundColor = new Color(0, 255, 0, 60);
|
||||
|
||||
//latest:
|
||||
backgroundColor = new Color(139, 46, 173, 20);
|
||||
//backgroundColor = new Color(139, 46, 173, 0);
|
||||
|
||||
//latest:
|
||||
backgroundColor = new Color(139, 46, 173, 20);
|
||||
//backgroundColor = new Color(139, 46, 173, 0);
|
||||
|
||||
alpha = 0;
|
||||
ChoiceDialog dlg = new ChoiceDialog(params);
|
||||
|
@ -150,12 +150,12 @@ public class DialogContainer extends JPanel {
|
|||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
|
||||
if (!drawContainer) {
|
||||
return;
|
||||
}
|
||||
|
||||
int x = X_OFFSET;
|
||||
|
||||
if (!drawContainer) {
|
||||
return;
|
||||
}
|
||||
|
||||
int x = X_OFFSET;
|
||||
int y = Y_OFFSET;
|
||||
int w = getWidth() - 2 * X_OFFSET;
|
||||
int h = getHeight() - 2 * Y_OFFSET;
|
||||
|
@ -205,9 +205,9 @@ public class DialogContainer extends JPanel {
|
|||
public void showDialog(boolean bShow) {
|
||||
setVisible(bShow);
|
||||
}
|
||||
|
||||
|
||||
public DialogManager.MTGDialogs getType() {
|
||||
return this.dialogType;
|
||||
return this.dialogType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -72,11 +72,11 @@ public class DialogManager extends JComponent implements MouseListener,
|
|||
/*if (h < 200) {
|
||||
h = 200;
|
||||
}*/
|
||||
|
||||
|
||||
if (w > 800) {
|
||||
w = 800;
|
||||
w = 800;
|
||||
}
|
||||
|
||||
|
||||
int height = getHeight();
|
||||
int width = getWidth();
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class DialogManager extends JComponent implements MouseListener,
|
|||
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
public void setDlgBounds(Rectangle r) {
|
||||
if (currentDialog == MTGDialogs.DialogContainer) {
|
||||
dialogContainer.setBounds(r.x, r.y, r.width, r.height);
|
||||
|
@ -109,7 +109,7 @@ public class DialogManager extends JComponent implements MouseListener,
|
|||
}
|
||||
|
||||
public void fadeOut() {
|
||||
|
||||
|
||||
if (dialogContainer != null) {
|
||||
dialogContainer.showDialog(false);
|
||||
removeAll();
|
||||
|
@ -123,8 +123,8 @@ public class DialogManager extends JComponent implements MouseListener,
|
|||
}
|
||||
|
||||
public void fadeOut(DialogContainer dc) {
|
||||
//log.debug("start:fadeOut:"+dc.toString());
|
||||
|
||||
//log.debug("start:fadeOut:"+dc.toString());
|
||||
|
||||
dc.showDialog(false);
|
||||
remove(dc);
|
||||
|
||||
|
@ -135,7 +135,7 @@ public class DialogManager extends JComponent implements MouseListener,
|
|||
bFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!bFound) {
|
||||
setVisible(false);
|
||||
}
|
||||
|
@ -176,18 +176,18 @@ public class DialogManager extends JComponent implements MouseListener,
|
|||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.getButton() == MouseEvent.BUTTON1) {
|
||||
j = (JComponent) getComponentAt(e.getX(), e.getY());
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.getButton() == MouseEvent.BUTTON1) {
|
||||
j = (JComponent) getComponentAt(e.getX(), e.getY());
|
||||
|
||||
if (j != null && j instanceof DialogContainer) {
|
||||
rec = j.getBounds();
|
||||
bDragged = true;
|
||||
mx = e.getX();
|
||||
my = e.getY();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (j != null && j instanceof DialogContainer) {
|
||||
rec = j.getBounds();
|
||||
bDragged = true;
|
||||
mx = e.getX();
|
||||
my = e.getY();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
bDragged = false;
|
||||
|
@ -214,14 +214,14 @@ public class DialogManager extends JComponent implements MouseListener,
|
|||
j = null;
|
||||
}
|
||||
|
||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||
int notches = e.getWheelRotation();
|
||||
System.out.println("outx:"+notches);
|
||||
if (currentDialog != null && currentDialog.equals(MTGDialogs.ChooseCommonDialog)) {
|
||||
System.out.println("out:"+1);
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||
int notches = e.getWheelRotation();
|
||||
System.out.println("outx:"+notches);
|
||||
if (currentDialog != null && currentDialog.equals(MTGDialogs.ChooseCommonDialog)) {
|
||||
System.out.println("out:"+1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Default UID.
|
||||
*/
|
||||
|
|
|
@ -22,7 +22,7 @@ public class DlgParams {
|
|||
public BigCard bigCard;
|
||||
public FeedbackPanel feedbackPanel;
|
||||
public UUID gameId;
|
||||
|
||||
|
||||
private int playerID;
|
||||
|
||||
private CardsView cards;
|
||||
|
@ -30,16 +30,16 @@ public class DlgParams {
|
|||
//private ArrayList<DeckInfo> deckList;
|
||||
private ArrayList<Object> objectList;
|
||||
|
||||
private String title;
|
||||
private String title;
|
||||
private int opponentID;
|
||||
boolean isOptional = false;
|
||||
boolean isChooseAbility = false;
|
||||
boolean isCancelStopsPlaying = true;
|
||||
|
||||
boolean isAI = false;
|
||||
|
||||
public HashSet<String> manaChoices = new HashSet<String>();
|
||||
|
||||
|
||||
public HashSet<String> manaChoices = new HashSet<String>();
|
||||
|
||||
public int getPlayerID() {
|
||||
return playerID;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class DlgParams {
|
|||
public void setOpponentID(int opponentID) {
|
||||
this.opponentID = opponentID;
|
||||
}
|
||||
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public class DlgParams {
|
|||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
|
||||
public HashSet<String> getManaChoices() {
|
||||
return manaChoices;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public class DlgParams {
|
|||
public void setManaChoices(HashSet<String> manaChoices) {
|
||||
this.manaChoices = manaChoices;
|
||||
}
|
||||
|
||||
|
||||
public boolean isOptional() {
|
||||
return isOptional;
|
||||
}
|
||||
|
@ -90,53 +90,53 @@ public class DlgParams {
|
|||
this.isOptional = isOptional;
|
||||
}
|
||||
|
||||
public boolean isChooseAbility() {
|
||||
return isChooseAbility;
|
||||
}
|
||||
public boolean isChooseAbility() {
|
||||
return isChooseAbility;
|
||||
}
|
||||
|
||||
public void setChooseAbility(boolean isChooseAbility) {
|
||||
this.isChooseAbility = isChooseAbility;
|
||||
}
|
||||
|
||||
public void setChooseAbility(boolean isChooseAbility) {
|
||||
this.isChooseAbility = isChooseAbility;
|
||||
}
|
||||
|
||||
public ArrayList<String> getStringList() {
|
||||
return stringList;
|
||||
}
|
||||
return stringList;
|
||||
}
|
||||
|
||||
public void setStringList(ArrayList<String> stringList) {
|
||||
this.stringList = stringList;
|
||||
}
|
||||
public void setStringList(ArrayList<String> stringList) {
|
||||
this.stringList = stringList;
|
||||
}
|
||||
|
||||
/*public ArrayList<DeckInfo> getDeckList() {
|
||||
return deckList;
|
||||
}
|
||||
/*public ArrayList<DeckInfo> getDeckList() {
|
||||
return deckList;
|
||||
}
|
||||
|
||||
public void setDeckList(ArrayList<DeckInfo> deckList) {
|
||||
this.deckList = deckList;
|
||||
}*/
|
||||
|
||||
public ArrayList<Object> getObjectList() {
|
||||
return objectList;
|
||||
}
|
||||
public void setDeckList(ArrayList<DeckInfo> deckList) {
|
||||
this.deckList = deckList;
|
||||
}*/
|
||||
|
||||
public void setObjectList(ArrayList<Object> objectList) {
|
||||
this.objectList = objectList;
|
||||
}
|
||||
public ArrayList<Object> getObjectList() {
|
||||
return objectList;
|
||||
}
|
||||
|
||||
public void setObjectList(ArrayList<Object> objectList) {
|
||||
this.objectList = objectList;
|
||||
}
|
||||
|
||||
public boolean isAI() {
|
||||
return isAI;
|
||||
}
|
||||
return isAI;
|
||||
}
|
||||
|
||||
public void setAI(boolean isAI) {
|
||||
this.isAI = isAI;
|
||||
}
|
||||
|
||||
public void setAI(boolean isAI) {
|
||||
this.isAI = isAI;
|
||||
}
|
||||
|
||||
public boolean isCancelStopsPlaying() {
|
||||
return isCancelStopsPlaying;
|
||||
}
|
||||
return isCancelStopsPlaying;
|
||||
}
|
||||
|
||||
public void setCancelStopsPlaying(boolean isCancelStopsPlaying) {
|
||||
this.isCancelStopsPlaying = isCancelStopsPlaying;
|
||||
}
|
||||
public void setCancelStopsPlaying(boolean isCancelStopsPlaying) {
|
||||
this.isCancelStopsPlaying = isCancelStopsPlaying;
|
||||
}
|
||||
|
||||
public CardsView getCards() {
|
||||
return cards;
|
||||
|
|
|
@ -10,9 +10,9 @@ import java.awt.*;
|
|||
* @author mw, noxx
|
||||
*/
|
||||
abstract public class IDialogPanel extends JXPanel {
|
||||
|
||||
|
||||
private DlgParams params;
|
||||
|
||||
|
||||
public DlgParams getDlgParams() {
|
||||
return params;
|
||||
}
|
||||
|
@ -25,24 +25,24 @@ abstract public class IDialogPanel extends JXPanel {
|
|||
super();
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
|
||||
protected void updateSize(int newWidth, int newHeight) {
|
||||
|
||||
Rectangle r0 = getBounds();
|
||||
|
||||
|
||||
r0.width = newWidth;
|
||||
r0.height = newHeight;
|
||||
|
||||
|
||||
setBounds(r0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Make inner component transparent.
|
||||
*/
|
||||
protected void makeTransparent() {
|
||||
|
||||
setOpaque(false);
|
||||
|
||||
|
||||
for (int i = 0; i < getComponentCount(); i++) {
|
||||
Component c = getComponent(i);
|
||||
if (c instanceof AbstractButton && !(c instanceof JButton)) {
|
||||
|
@ -52,11 +52,11 @@ abstract public class IDialogPanel extends JXPanel {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void makeTransparent(JLayeredPane jLayeredPane) {
|
||||
|
||||
setOpaque(false);
|
||||
|
||||
|
||||
for (int i = 0; i < getComponentCount(); i++) {
|
||||
Component c = jLayeredPane.getComponent(i);
|
||||
if (c instanceof AbstractButton && !(c instanceof JButton)) {
|
||||
|
@ -66,7 +66,7 @@ abstract public class IDialogPanel extends JXPanel {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Default UID.
|
||||
*/
|
||||
|
|
|
@ -34,24 +34,24 @@ public class StackDialog extends IDialogPanel {
|
|||
|
||||
private JLayeredPane jLayeredPane;
|
||||
private FeedbackPanel feedbackPanel;
|
||||
|
||||
|
||||
private class CustomLabel extends JLabel {
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
Graphics2D g2D = (Graphics2D)g;
|
||||
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
Graphics2D g2D = (Graphics2D)g;
|
||||
g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
g2D.setColor(Color.black);
|
||||
g2D.drawString(getText(), 1, 11);
|
||||
g2D.setColor(Color.white);
|
||||
g2D.drawString(getText(), 0, 10);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
g2D.setColor(Color.black);
|
||||
g2D.drawString(getText(), 1, 11);
|
||||
g2D.setColor(Color.white);
|
||||
g2D.drawString(getText(), 0, 10);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This is the default constructor
|
||||
*/
|
||||
|
@ -69,15 +69,15 @@ public class StackDialog extends IDialogPanel {
|
|||
*/
|
||||
private void initialize() {
|
||||
|
||||
int w = getDlgParams().rect.width;
|
||||
int w = getDlgParams().rect.width;
|
||||
int h = getDlgParams().rect.height;
|
||||
|
||||
jLayeredPane = new JLayeredPane();
|
||||
jLayeredPane = new JLayeredPane();
|
||||
add(jLayeredPane);
|
||||
jLayeredPane.setSize(w, h);
|
||||
jLayeredPane.setVisible(true);
|
||||
jLayeredPane.setOpaque(false);
|
||||
|
||||
|
||||
jTitle = new CustomLabel();
|
||||
jTitle.setBounds(new Rectangle(5, 3, w, 16));
|
||||
jTitle.setFont(new Font("Dialog", Font.BOLD, 14));
|
||||
|
@ -90,7 +90,7 @@ public class StackDialog extends IDialogPanel {
|
|||
|
||||
this.setLayout(null);
|
||||
jLayeredPane.setLayout(null);
|
||||
|
||||
|
||||
jLayeredPane.add(jTitle, null);
|
||||
//jLayeredPane.add(jTitle2, null);
|
||||
jLayeredPane.add(getJButtonAccept(), null);
|
||||
|
@ -98,19 +98,19 @@ public class StackDialog extends IDialogPanel {
|
|||
|
||||
makeTransparent(jLayeredPane);
|
||||
}
|
||||
|
||||
|
||||
private void displayStack(CardsView cards, UUID gameId, BigCard bigCard) {
|
||||
|
||||
if (cards == null || cards.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display spells and theis targets above them
|
||||
*/
|
||||
int dx = (SettingsManager.getInstance().getCardSize().width + 15) * (cards.size() - 1);
|
||||
int dy = 30;
|
||||
|
||||
|
||||
for (CardView card : cards.values()) {
|
||||
|
||||
if (card instanceof StackAbilityView) {
|
||||
|
@ -127,7 +127,7 @@ public class StackDialog extends IDialogPanel {
|
|||
cardImg.setLocation(dx, dy);
|
||||
|
||||
jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 1);
|
||||
|
||||
|
||||
dx -= (SettingsManager.getInstance().getCardSize().width + 15);
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ public class StackDialog extends IDialogPanel {
|
|||
}
|
||||
return cardDimension;
|
||||
}
|
||||
|
||||
|
||||
private HoverButton getJButtonAccept() {
|
||||
if (jButtonAccept == null) {
|
||||
jButtonAccept = new HoverButton("", ImageManagerImpl.getInstance().getDlgAcceptButtonImage(),
|
||||
|
@ -149,11 +149,11 @@ public class StackDialog extends IDialogPanel {
|
|||
int h = getDlgParams().rect.height - 90;
|
||||
jButtonAccept.setBounds(new Rectangle(w / 2 - 80, h - 50, 60, 60));
|
||||
//jButtonAccept.setBorder(BorderFactory.createLineBorder(Color.red));
|
||||
|
||||
|
||||
jButtonAccept.setObserver(new Command() {
|
||||
@Override
|
||||
public void execute() {
|
||||
DialogManager.getManager().fadeOut((DialogContainer)getParent());
|
||||
DialogManager.getManager().fadeOut((DialogContainer)getParent());
|
||||
//GameManager.getInputControl().getInput().selectButtonOK();
|
||||
StackDialog.this.feedbackPanel.doClick();
|
||||
}
|
||||
|
@ -172,11 +172,11 @@ public class StackDialog extends IDialogPanel {
|
|||
int w = getDlgParams().rect.width - 90;
|
||||
int h = getDlgParams().rect.height - 90;
|
||||
jButtonResponse.setBounds(new Rectangle(w / 2 + 5, h - 48, 60, 60));
|
||||
|
||||
|
||||
jButtonResponse.setObserver(new Command() {
|
||||
@Override
|
||||
public void execute() {
|
||||
DialogManager.getManager().fadeOut((DialogContainer)getParent());
|
||||
DialogManager.getManager().fadeOut((DialogContainer)getParent());
|
||||
}
|
||||
private static final long serialVersionUID = 1L;
|
||||
});
|
||||
|
|
|
@ -37,78 +37,78 @@ import javax.swing.border.Border;
|
|||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public final class Constants {
|
||||
private Constants() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
private Constants() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
public static final int FRAME_MAX_HEIGHT = 367;
|
||||
public static final int FRAME_MAX_WIDTH = 256;
|
||||
public static final int ART_MAX_HEIGHT = 168;
|
||||
public static final int ART_MAX_WIDTH = 227;
|
||||
public static final int SYMBOL_MAX_HEIGHT = 14;
|
||||
public static final int SYMBOL_MAX_WIDTH = 14;
|
||||
public static final int SYMBOL_MAX_XOFFSET = 27;
|
||||
public static final int SYMBOL_MAX_YOFFSET = 15;
|
||||
public static final int SYMBOL_MAX_SPACE = 14;
|
||||
public static final int CONTENT_MAX_XOFFSET = 15;
|
||||
public static final int ART_MAX_YOFFSET = 37;
|
||||
public static final int NAME_MAX_YOFFSET = 28;
|
||||
public static final int TYPE_MAX_YOFFSET = 223;
|
||||
public static final int ICON_MAX_HEIGHT = 16;
|
||||
public static final int ICON_MAX_WIDTH = 16;
|
||||
public static final int ICON_MAX_XOFFSET = 238;
|
||||
public static final int ICON_MAX_YOFFSET = 210;
|
||||
public static final int TEXT_MAX_YOFFSET = 232;
|
||||
public static final int TEXT_MAX_WIDTH = 227;
|
||||
public static final int TEXT_MAX_HEIGHT = 105;
|
||||
public static final int NAME_FONT_MAX_SIZE = 13;
|
||||
public static final int TEXT_FONT_MAX_SIZE = 11;
|
||||
public static final int POWBOX_MAX_TOP = 336;
|
||||
public static final int POWBOX_MAX_LEFT = 202;
|
||||
public static final int POWBOX_TEXT_MAX_TOP = 352;
|
||||
public static final int POWBOX_TEXT_MAX_LEFT = 212;
|
||||
public static final int DAMAGE_MAX_LEFT = 180;
|
||||
public static final int FRAME_MAX_HEIGHT = 367;
|
||||
public static final int FRAME_MAX_WIDTH = 256;
|
||||
public static final int ART_MAX_HEIGHT = 168;
|
||||
public static final int ART_MAX_WIDTH = 227;
|
||||
public static final int SYMBOL_MAX_HEIGHT = 14;
|
||||
public static final int SYMBOL_MAX_WIDTH = 14;
|
||||
public static final int SYMBOL_MAX_XOFFSET = 27;
|
||||
public static final int SYMBOL_MAX_YOFFSET = 15;
|
||||
public static final int SYMBOL_MAX_SPACE = 14;
|
||||
public static final int CONTENT_MAX_XOFFSET = 15;
|
||||
public static final int ART_MAX_YOFFSET = 37;
|
||||
public static final int NAME_MAX_YOFFSET = 28;
|
||||
public static final int TYPE_MAX_YOFFSET = 223;
|
||||
public static final int ICON_MAX_HEIGHT = 16;
|
||||
public static final int ICON_MAX_WIDTH = 16;
|
||||
public static final int ICON_MAX_XOFFSET = 238;
|
||||
public static final int ICON_MAX_YOFFSET = 210;
|
||||
public static final int TEXT_MAX_YOFFSET = 232;
|
||||
public static final int TEXT_MAX_WIDTH = 227;
|
||||
public static final int TEXT_MAX_HEIGHT = 105;
|
||||
public static final int NAME_FONT_MAX_SIZE = 13;
|
||||
public static final int TEXT_FONT_MAX_SIZE = 11;
|
||||
public static final int POWBOX_MAX_TOP = 336;
|
||||
public static final int POWBOX_MAX_LEFT = 202;
|
||||
public static final int POWBOX_TEXT_MAX_TOP = 352;
|
||||
public static final int POWBOX_TEXT_MAX_LEFT = 212;
|
||||
public static final int DAMAGE_MAX_LEFT = 180;
|
||||
|
||||
public static final Border EMPTY_BORDER = BorderFactory.createEmptyBorder(2,2,2,2);
|
||||
public static final Border EMPTY_BORDER = BorderFactory.createEmptyBorder(2,2,2,2);
|
||||
|
||||
public static final double SCALE_FACTOR = 0.5;
|
||||
|
||||
public static final String PLUGINS_DIRECTORY = "plugins/";
|
||||
public static final double SCALE_FACTOR = 0.5;
|
||||
|
||||
public static final String PLUGINS_DIRECTORY = "plugins/";
|
||||
|
||||
public static final String RESOURCE_PATH_MANA_LARGE = IO.imageBaseDir + "symbols" + File.separator + "large";
|
||||
public static final String RESOURCE_PATH_MANA_MEDIUM = IO.imageBaseDir + "symbols" + File.separator + "medium";
|
||||
public static final String RESOURCE_PATH_MANA_MEDIUM = IO.imageBaseDir + "symbols" + File.separator + "medium";
|
||||
public static final String RESOURCE_PATH_SET = IO.imageBaseDir + "sets" + File.separator;
|
||||
public static final String RESOURCE_PATH_SET_SMALL = RESOURCE_PATH_SET + File.separator + "small" + File.separator;
|
||||
public static final String RESOURCE_PATH_SET_SMALL = RESOURCE_PATH_SET + File.separator + "small" + File.separator;
|
||||
public static final String BASE_SOUND_PATH = "plugins" + File.separator + "sounds" + File.separator;
|
||||
|
||||
public interface IO {
|
||||
public static final String imageBaseDir = "plugins" + File.separator + "images" + File.separator;
|
||||
public static final String IMAGE_PROPERTIES_FILE = "image.url.properties";
|
||||
}
|
||||
public static final String imageBaseDir = "plugins" + File.separator + "images" + File.separator;
|
||||
public static final String IMAGE_PROPERTIES_FILE = "image.url.properties";
|
||||
}
|
||||
|
||||
public enum DeckEditorMode {
|
||||
Constructed,
|
||||
Limited,
|
||||
Sideboard
|
||||
}
|
||||
public enum DeckEditorMode {
|
||||
Constructed,
|
||||
Limited,
|
||||
Sideboard
|
||||
}
|
||||
|
||||
public enum SortBy {
|
||||
CASTING_COST ("Casting Cost"),
|
||||
RARITY ("Rarity"),
|
||||
COLOR ("Color"),
|
||||
NAME ("Name"),
|
||||
UNSORTED ("Unsorted");
|
||||
public enum SortBy {
|
||||
CASTING_COST ("Casting Cost"),
|
||||
RARITY ("Rarity"),
|
||||
COLOR ("Color"),
|
||||
NAME ("Name"),
|
||||
UNSORTED ("Unsorted");
|
||||
|
||||
private String text;
|
||||
private String text;
|
||||
|
||||
SortBy(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
SortBy(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,12 +46,12 @@ public class DeckGenerator {
|
|||
|
||||
private static String colors = "GWUBR";
|
||||
|
||||
/**
|
||||
* Opens color chooser dialog. Generates deck.
|
||||
* Saves generated deck and use it as selected deck to play.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/**
|
||||
* Opens color chooser dialog. Generates deck.
|
||||
* Saves generated deck and use it as selected deck to play.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String generateDeck() {
|
||||
JPanel p0 = new JPanel();
|
||||
p0.setLayout(new BoxLayout(p0, BoxLayout.Y_AXIS));
|
||||
|
@ -61,7 +61,7 @@ public class DeckGenerator {
|
|||
p0.add(text);
|
||||
|
||||
p0.add(Box.createVerticalStrut(5));
|
||||
String chosen = MageFrame.getPreferences().get("genDeckColor", "u");
|
||||
String chosen = MageFrame.getPreferences().get("genDeckColor", "u");
|
||||
final ColorsChooser colorsChooser = new ColorsChooser(chosen);
|
||||
p0.add(colorsChooser);
|
||||
|
||||
|
@ -89,7 +89,7 @@ public class DeckGenerator {
|
|||
colorsChooser.setEnabled(false);
|
||||
selectedColors = (String) colorsChooser.getSelectedItem();
|
||||
dlg.setVisible(false);
|
||||
MageFrame.getPreferences().put("genDeckColor", selectedColors);
|
||||
MageFrame.getPreferences().put("genDeckColor", selectedColors);
|
||||
}
|
||||
});
|
||||
final JButton btnCancel = new JButton("Cancel");
|
||||
|
@ -123,9 +123,9 @@ public class DeckGenerator {
|
|||
return selectedColors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates card pool
|
||||
*/
|
||||
/**
|
||||
* Generates card pool
|
||||
*/
|
||||
protected static void buildDeck() {
|
||||
List<ColoredManaSymbol> allowedColors = new ArrayList<ColoredManaSymbol>();
|
||||
selectedColors = selectedColors.toUpperCase();
|
||||
|
@ -157,14 +157,14 @@ public class DeckGenerator {
|
|||
|
||||
final List<String> setsToUseFinal = setsToUse;
|
||||
|
||||
deck = DeckBuilder.buildDeck(spellCardPool, allowedColors, landCardPool, new RateCallback() {
|
||||
@Override
|
||||
public int rateCard(Card card) {
|
||||
return CardsStorage.rateCard(card);
|
||||
}
|
||||
@Override
|
||||
public Card getBestBasicLand(ColoredManaSymbol color) {
|
||||
int tries = 100;
|
||||
deck = DeckBuilder.buildDeck(spellCardPool, allowedColors, landCardPool, new RateCallback() {
|
||||
@Override
|
||||
public int rateCard(Card card) {
|
||||
return CardsStorage.rateCard(card);
|
||||
}
|
||||
@Override
|
||||
public Card getBestBasicLand(ColoredManaSymbol color) {
|
||||
int tries = 100;
|
||||
Card land;
|
||||
do {
|
||||
land = DeckGenerator.getBestBasicLand(color);
|
||||
|
@ -172,8 +172,8 @@ public class DeckGenerator {
|
|||
if (tries < 0) break;
|
||||
} while (!setsToUseFinal.contains(land.getExpansionSetCode()));
|
||||
return land;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static String getRandomColors(String _selectedColors) {
|
||||
|
@ -325,13 +325,13 @@ public class DeckGenerator {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get random basic land that can produce specified color mana.
|
||||
* Random here means random set and collector id for the same mana producing land.
|
||||
*
|
||||
* @param color
|
||||
* @return
|
||||
*/
|
||||
/**
|
||||
* Get random basic land that can produce specified color mana.
|
||||
* Random here means random set and collector id for the same mana producing land.
|
||||
*
|
||||
* @param color
|
||||
* @return
|
||||
*/
|
||||
private static Card getBestBasicLand(ColoredManaSymbol color) {
|
||||
if (color.equals(ColoredManaSymbol.G)) {
|
||||
return Sets.findCard("Forest", GENERATE_RANDOM_BASIC_LAND);
|
||||
|
|
|
@ -62,10 +62,10 @@ import java.util.List;
|
|||
*/
|
||||
public class CardSelector extends javax.swing.JPanel implements ComponentListener {
|
||||
|
||||
private final List<Card> cards = new ArrayList<Card>();
|
||||
private final FilterCard filter = new FilterCard();
|
||||
private BigCard bigCard;
|
||||
private boolean limited = false;
|
||||
private final List<Card> cards = new ArrayList<Card>();
|
||||
private final FilterCard filter = new FilterCard();
|
||||
private BigCard bigCard;
|
||||
private boolean limited = false;
|
||||
|
||||
private final ActionListener searchAction = new ActionListener() {
|
||||
@Override
|
||||
|
@ -73,184 +73,184 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
jButtonSearchActionPerformed(evt);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** Creates new form CardSelector */
|
||||
public CardSelector() {
|
||||
initComponents();
|
||||
cardGrid = new CardGrid();
|
||||
makeTransparent();
|
||||
initListViewComponents();
|
||||
currentView = mainModel; // by default we use List View
|
||||
makeTransparent();
|
||||
initListViewComponents();
|
||||
currentView = mainModel; // by default we use List View
|
||||
}
|
||||
|
||||
public void makeTransparent() {
|
||||
this.addComponentListener(this);
|
||||
setOpaque(false);
|
||||
cardGrid.setOpaque(false);
|
||||
jScrollPane1.setOpaque(false);
|
||||
jScrollPane1.getViewport().setOpaque(false);
|
||||
cbSortBy.setModel(new DefaultComboBoxModel(SortBy.values()));
|
||||
public void makeTransparent() {
|
||||
this.addComponentListener(this);
|
||||
setOpaque(false);
|
||||
cardGrid.setOpaque(false);
|
||||
jScrollPane1.setOpaque(false);
|
||||
jScrollPane1.getViewport().setOpaque(false);
|
||||
cbSortBy.setModel(new DefaultComboBoxModel(SortBy.values()));
|
||||
jTextFieldSearch.addActionListener(searchAction);
|
||||
}
|
||||
}
|
||||
|
||||
public void initListViewComponents() {
|
||||
mainTable = new JTable();
|
||||
public void initListViewComponents() {
|
||||
mainTable = new JTable();
|
||||
|
||||
mainModel = new TableModel();
|
||||
mainModel.addListeners(mainTable);
|
||||
mainModel = new TableModel();
|
||||
mainModel.addListeners(mainTable);
|
||||
|
||||
mainTable.setModel(mainModel);
|
||||
mainTable.setForeground(Color.white);
|
||||
DefaultTableCellRenderer myRenderer = (DefaultTableCellRenderer) mainTable.getDefaultRenderer(String.class);
|
||||
myRenderer.setBackground(new Color(0, 0, 0, 100));
|
||||
mainTable.getColumnModel().getColumn(0).setMaxWidth(0);
|
||||
mainTable.getColumnModel().getColumn(0).setPreferredWidth(10);
|
||||
mainTable.getColumnModel().getColumn(1).setPreferredWidth(110);
|
||||
mainTable.getColumnModel().getColumn(2).setPreferredWidth(90);
|
||||
mainTable.getColumnModel().getColumn(3).setPreferredWidth(50);
|
||||
mainTable.getColumnModel().getColumn(4).setPreferredWidth(170);
|
||||
mainTable.getColumnModel().getColumn(5).setPreferredWidth(30);
|
||||
mainTable.getColumnModel().getColumn(6).setPreferredWidth(15);
|
||||
mainTable.getColumnModel().getColumn(7).setPreferredWidth(15);
|
||||
mainTable.setForeground(Color.white);
|
||||
DefaultTableCellRenderer myRenderer = (DefaultTableCellRenderer) mainTable.getDefaultRenderer(String.class);
|
||||
myRenderer.setBackground(new Color(0, 0, 0, 100));
|
||||
mainTable.getColumnModel().getColumn(0).setMaxWidth(0);
|
||||
mainTable.getColumnModel().getColumn(0).setPreferredWidth(10);
|
||||
mainTable.getColumnModel().getColumn(1).setPreferredWidth(110);
|
||||
mainTable.getColumnModel().getColumn(2).setPreferredWidth(90);
|
||||
mainTable.getColumnModel().getColumn(3).setPreferredWidth(50);
|
||||
mainTable.getColumnModel().getColumn(4).setPreferredWidth(170);
|
||||
mainTable.getColumnModel().getColumn(5).setPreferredWidth(30);
|
||||
mainTable.getColumnModel().getColumn(6).setPreferredWidth(15);
|
||||
mainTable.getColumnModel().getColumn(7).setPreferredWidth(15);
|
||||
|
||||
jScrollPane1.setViewportView(mainTable);
|
||||
jScrollPane1.setViewportView(mainTable);
|
||||
|
||||
mainTable.setOpaque(false);
|
||||
mainTable.setOpaque(false);
|
||||
|
||||
cbSortBy.setEnabled(false);
|
||||
chkPiles.setEnabled(false);
|
||||
cbSortBy.setEnabled(false);
|
||||
chkPiles.setEnabled(false);
|
||||
|
||||
mainTable.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.getClickCount() == 2 && !e.isConsumed()) {
|
||||
e.consume();
|
||||
jButtonAddToMainActionPerformed(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
mainTable.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.getClickCount() == 2 && !e.isConsumed()) {
|
||||
e.consume();
|
||||
jButtonAddToMainActionPerformed(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void loadSideboard(List<Card> sideboard, BigCard bigCard) {
|
||||
this.bigCard = bigCard;
|
||||
this.btnBooster.setVisible(false);
|
||||
this.btnClear.setVisible(false);
|
||||
this.cbExpansionSet.setVisible(false);
|
||||
this.limited = true;
|
||||
this.cards.clear();
|
||||
for (Card card: sideboard) {
|
||||
this.cards.add(card);
|
||||
}
|
||||
initFilter();
|
||||
filterCards();
|
||||
}
|
||||
public void loadSideboard(List<Card> sideboard, BigCard bigCard) {
|
||||
this.bigCard = bigCard;
|
||||
this.btnBooster.setVisible(false);
|
||||
this.btnClear.setVisible(false);
|
||||
this.cbExpansionSet.setVisible(false);
|
||||
this.limited = true;
|
||||
this.cards.clear();
|
||||
for (Card card: sideboard) {
|
||||
this.cards.add(card);
|
||||
}
|
||||
initFilter();
|
||||
filterCards();
|
||||
}
|
||||
|
||||
public void loadCards(BigCard bigCard) {
|
||||
this.bigCard = bigCard;
|
||||
this.btnBooster.setVisible(true);
|
||||
this.btnClear.setVisible(true);
|
||||
this.cbExpansionSet.setVisible(true);
|
||||
Object[] l = Sets.getInstance().values().toArray();
|
||||
Arrays.sort(l, new Comparator<Object>() {
|
||||
@Override
|
||||
public int compare(Object o1, Object o2) {
|
||||
return ((ExpansionSet)o2).getReleaseDate().compareTo(((ExpansionSet)o1).getReleaseDate());
|
||||
}
|
||||
});
|
||||
cbExpansionSet.setModel(new DefaultComboBoxModel(l));
|
||||
cbExpansionSet.insertItemAt("-- All sets", 0);
|
||||
public void loadCards(BigCard bigCard) {
|
||||
this.bigCard = bigCard;
|
||||
this.btnBooster.setVisible(true);
|
||||
this.btnClear.setVisible(true);
|
||||
this.cbExpansionSet.setVisible(true);
|
||||
Object[] l = Sets.getInstance().values().toArray();
|
||||
Arrays.sort(l, new Comparator<Object>() {
|
||||
@Override
|
||||
public int compare(Object o1, Object o2) {
|
||||
return ((ExpansionSet)o2).getReleaseDate().compareTo(((ExpansionSet)o1).getReleaseDate());
|
||||
}
|
||||
});
|
||||
cbExpansionSet.setModel(new DefaultComboBoxModel(l));
|
||||
cbExpansionSet.insertItemAt("-- All sets", 0);
|
||||
cbExpansionSet.insertItemAt("-- Standard", 1);
|
||||
cbExpansionSet.setSelectedIndex(0);
|
||||
initFilter();
|
||||
if (this.cbExpansionSet.getSelectedItem() instanceof ExpansionSet) {
|
||||
filter.getExpansionSetCode().add(((ExpansionSet) this.cbExpansionSet.getSelectedItem()).getCode());
|
||||
} else if (this.cbExpansionSet.getSelectedItem().equals("-- Standard")) {
|
||||
cbExpansionSet.setSelectedIndex(0);
|
||||
initFilter();
|
||||
if (this.cbExpansionSet.getSelectedItem() instanceof ExpansionSet) {
|
||||
filter.getExpansionSetCode().add(((ExpansionSet) this.cbExpansionSet.getSelectedItem()).getCode());
|
||||
} else if (this.cbExpansionSet.getSelectedItem().equals("-- Standard")) {
|
||||
filter.getExpansionSetCode().addAll(ConstructedFormats.getSetsByFormat("Standard"));
|
||||
}
|
||||
filterCards();
|
||||
}
|
||||
filterCards();
|
||||
}
|
||||
|
||||
private void initFilter() {
|
||||
filter.setUseColor(true);
|
||||
filter.getColor().setBlack(true);
|
||||
filter.getColor().setBlue(true);
|
||||
filter.getColor().setGreen(true);
|
||||
filter.getColor().setWhite(true);
|
||||
filter.getColor().setRed(true);
|
||||
filter.setColorless(true);
|
||||
filter.setUseColorless(true);
|
||||
filter.setNotColor(false);
|
||||
filter.setScopeColor(ComparisonScope.Any);
|
||||
filter.getCardType().add(CardType.LAND);
|
||||
filter.getCardType().add(CardType.ARTIFACT);
|
||||
filter.getCardType().add(CardType.CREATURE);
|
||||
filter.getCardType().add(CardType.ENCHANTMENT);
|
||||
filter.getCardType().add(CardType.INSTANT);
|
||||
filter.getCardType().add(CardType.PLANESWALKER);
|
||||
filter.getCardType().add(CardType.SORCERY);
|
||||
filter.setScopeCardType(ComparisonScope.Any);
|
||||
}
|
||||
private void initFilter() {
|
||||
filter.setUseColor(true);
|
||||
filter.getColor().setBlack(true);
|
||||
filter.getColor().setBlue(true);
|
||||
filter.getColor().setGreen(true);
|
||||
filter.getColor().setWhite(true);
|
||||
filter.getColor().setRed(true);
|
||||
filter.setColorless(true);
|
||||
filter.setUseColorless(true);
|
||||
filter.setNotColor(false);
|
||||
filter.setScopeColor(ComparisonScope.Any);
|
||||
filter.getCardType().add(CardType.LAND);
|
||||
filter.getCardType().add(CardType.ARTIFACT);
|
||||
filter.getCardType().add(CardType.CREATURE);
|
||||
filter.getCardType().add(CardType.ENCHANTMENT);
|
||||
filter.getCardType().add(CardType.INSTANT);
|
||||
filter.getCardType().add(CardType.PLANESWALKER);
|
||||
filter.getCardType().add(CardType.SORCERY);
|
||||
filter.setScopeCardType(ComparisonScope.Any);
|
||||
}
|
||||
|
||||
private void filterCards() {
|
||||
try {
|
||||
List<Card> filteredCards = new ArrayList<Card>();
|
||||
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||
if (limited) {
|
||||
for (Card card: cards) {
|
||||
if (filter.match(card, null))
|
||||
filteredCards.add(card);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (Card card: CardsStorage.getAllCards()) {
|
||||
if (filter.match(card, null))
|
||||
filteredCards.add(card);
|
||||
}
|
||||
}
|
||||
this.currentView.loadCards(new CardsView(filteredCards), (SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected(), bigCard, null);
|
||||
this.cardCount.setText(String.valueOf(filteredCards.size()));
|
||||
private void filterCards() {
|
||||
try {
|
||||
List<Card> filteredCards = new ArrayList<Card>();
|
||||
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||
if (limited) {
|
||||
for (Card card: cards) {
|
||||
if (filter.match(card, null))
|
||||
filteredCards.add(card);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (Card card: CardsStorage.getAllCards()) {
|
||||
if (filter.match(card, null))
|
||||
filteredCards.add(card);
|
||||
}
|
||||
}
|
||||
this.currentView.loadCards(new CardsView(filteredCards), (SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected(), bigCard, null);
|
||||
this.cardCount.setText(String.valueOf(filteredCards.size()));
|
||||
}
|
||||
finally {
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
}
|
||||
finally {
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
}
|
||||
|
||||
public ICardGrid getCardsList() {
|
||||
return this.currentView;
|
||||
}
|
||||
public ICardGrid getCardsList() {
|
||||
return this.currentView;
|
||||
}
|
||||
|
||||
public List<ICardGrid> getCardGridComponents() {
|
||||
List<ICardGrid> components = new ArrayList<ICardGrid>();
|
||||
components.add(mainModel);
|
||||
components.add(cardGrid);
|
||||
return components;
|
||||
}
|
||||
public List<ICardGrid> getCardGridComponents() {
|
||||
List<ICardGrid> components = new ArrayList<ICardGrid>();
|
||||
components.add(mainModel);
|
||||
components.add(cardGrid);
|
||||
return components;
|
||||
}
|
||||
|
||||
public void removeCard(UUID cardId) {
|
||||
this.mainModel.removeCard(cardId);
|
||||
this.cardGrid.removeCard(cardId);
|
||||
for (Card card: cards) {
|
||||
if (card.getId().equals(cardId)) {
|
||||
cards.remove(card);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void removeCard(UUID cardId) {
|
||||
this.mainModel.removeCard(cardId);
|
||||
this.cardGrid.removeCard(cardId);
|
||||
for (Card card: cards) {
|
||||
if (card.getId().equals(cardId)) {
|
||||
cards.remove(card);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Card getCard(UUID cardId) {
|
||||
if (!cards.isEmpty()) {
|
||||
for (Card card: cards) {
|
||||
if (card.getId().equals(cardId))
|
||||
return card;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (Card card: CardsStorage.getAllCards()) {
|
||||
if (card.getId().equals(cardId))
|
||||
return card;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public Card getCard(UUID cardId) {
|
||||
if (!cards.isEmpty()) {
|
||||
for (Card card: cards) {
|
||||
if (card.getId().equals(cardId))
|
||||
return card;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (Card card: CardsStorage.getAllCards()) {
|
||||
if (card.getId().equals(cardId))
|
||||
return card;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
@ -654,186 +654,186 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void rdoGreenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoGreenActionPerformed
|
||||
filter.getColor().setGreen(this.rdoGreen.isSelected());
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoGreenActionPerformed
|
||||
private void rdoGreenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoGreenActionPerformed
|
||||
filter.getColor().setGreen(this.rdoGreen.isSelected());
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoGreenActionPerformed
|
||||
|
||||
private void rdoBlackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoBlackActionPerformed
|
||||
filter.getColor().setBlack(this.rdoBlack.isSelected());
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoBlackActionPerformed
|
||||
private void rdoBlackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoBlackActionPerformed
|
||||
filter.getColor().setBlack(this.rdoBlack.isSelected());
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoBlackActionPerformed
|
||||
|
||||
private void rdoWhiteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoWhiteActionPerformed
|
||||
filter.getColor().setWhite(this.rdoWhite.isSelected());
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoWhiteActionPerformed
|
||||
private void rdoWhiteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoWhiteActionPerformed
|
||||
filter.getColor().setWhite(this.rdoWhite.isSelected());
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoWhiteActionPerformed
|
||||
|
||||
private void rdoRedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoRedActionPerformed
|
||||
filter.getColor().setRed(this.rdoRed.isSelected());
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoRedActionPerformed
|
||||
private void rdoRedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoRedActionPerformed
|
||||
filter.getColor().setRed(this.rdoRed.isSelected());
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoRedActionPerformed
|
||||
|
||||
private void rdoBlueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoBlueActionPerformed
|
||||
filter.getColor().setBlue(this.rdoBlue.isSelected());
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoBlueActionPerformed
|
||||
private void rdoBlueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoBlueActionPerformed
|
||||
filter.getColor().setBlue(this.rdoBlue.isSelected());
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoBlueActionPerformed
|
||||
|
||||
private void rdoColorlessActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoColorlessActionPerformed
|
||||
filter.setColorless(this.rdoColorless.isSelected());
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoColorlessActionPerformed
|
||||
private void rdoColorlessActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoColorlessActionPerformed
|
||||
filter.setColorless(this.rdoColorless.isSelected());
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoColorlessActionPerformed
|
||||
|
||||
private void rdoLandActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoLandActionPerformed
|
||||
if (this.rdoLand.isSelected())
|
||||
filter.getCardType().add(CardType.LAND);
|
||||
else
|
||||
filter.getCardType().remove(CardType.LAND);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoLandActionPerformed
|
||||
private void rdoLandActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoLandActionPerformed
|
||||
if (this.rdoLand.isSelected())
|
||||
filter.getCardType().add(CardType.LAND);
|
||||
else
|
||||
filter.getCardType().remove(CardType.LAND);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoLandActionPerformed
|
||||
|
||||
private void rdoCreaturesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoCreaturesActionPerformed
|
||||
if (this.rdoCreatures.isSelected())
|
||||
filter.getCardType().add(CardType.CREATURE);
|
||||
else
|
||||
filter.getCardType().remove(CardType.CREATURE);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoCreaturesActionPerformed
|
||||
private void rdoCreaturesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoCreaturesActionPerformed
|
||||
if (this.rdoCreatures.isSelected())
|
||||
filter.getCardType().add(CardType.CREATURE);
|
||||
else
|
||||
filter.getCardType().remove(CardType.CREATURE);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoCreaturesActionPerformed
|
||||
|
||||
private void rdoArtifactsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoArtifactsActionPerformed
|
||||
if (this.rdoArtifacts.isSelected())
|
||||
filter.getCardType().add(CardType.ARTIFACT);
|
||||
else
|
||||
filter.getCardType().remove(CardType.ARTIFACT);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoArtifactsActionPerformed
|
||||
private void rdoArtifactsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoArtifactsActionPerformed
|
||||
if (this.rdoArtifacts.isSelected())
|
||||
filter.getCardType().add(CardType.ARTIFACT);
|
||||
else
|
||||
filter.getCardType().remove(CardType.ARTIFACT);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoArtifactsActionPerformed
|
||||
|
||||
private void rdoEnchantmentsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoEnchantmentsActionPerformed
|
||||
if (this.rdoEnchantments.isSelected())
|
||||
filter.getCardType().add(CardType.ENCHANTMENT);
|
||||
else
|
||||
filter.getCardType().remove(CardType.ENCHANTMENT);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoEnchantmentsActionPerformed
|
||||
private void rdoEnchantmentsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoEnchantmentsActionPerformed
|
||||
if (this.rdoEnchantments.isSelected())
|
||||
filter.getCardType().add(CardType.ENCHANTMENT);
|
||||
else
|
||||
filter.getCardType().remove(CardType.ENCHANTMENT);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoEnchantmentsActionPerformed
|
||||
|
||||
private void rdoInstantsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoInstantsActionPerformed
|
||||
if (this.rdoInstants.isSelected())
|
||||
filter.getCardType().add(CardType.INSTANT);
|
||||
else
|
||||
filter.getCardType().remove(CardType.INSTANT);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoInstantsActionPerformed
|
||||
private void rdoInstantsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoInstantsActionPerformed
|
||||
if (this.rdoInstants.isSelected())
|
||||
filter.getCardType().add(CardType.INSTANT);
|
||||
else
|
||||
filter.getCardType().remove(CardType.INSTANT);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoInstantsActionPerformed
|
||||
|
||||
private void rdoSorceriesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoSorceriesActionPerformed
|
||||
if (this.rdoSorceries.isSelected())
|
||||
filter.getCardType().add(CardType.SORCERY);
|
||||
else
|
||||
filter.getCardType().remove(CardType.SORCERY);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoSorceriesActionPerformed
|
||||
private void rdoSorceriesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoSorceriesActionPerformed
|
||||
if (this.rdoSorceries.isSelected())
|
||||
filter.getCardType().add(CardType.SORCERY);
|
||||
else
|
||||
filter.getCardType().remove(CardType.SORCERY);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoSorceriesActionPerformed
|
||||
|
||||
private void rdoPlaneswalkersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoPlaneswalkersActionPerformed
|
||||
if (this.rdoPlaneswalkers.isSelected())
|
||||
filter.getCardType().add(CardType.PLANESWALKER);
|
||||
else
|
||||
filter.getCardType().remove(CardType.PLANESWALKER);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoPlaneswalkersActionPerformed
|
||||
private void rdoPlaneswalkersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoPlaneswalkersActionPerformed
|
||||
if (this.rdoPlaneswalkers.isSelected())
|
||||
filter.getCardType().add(CardType.PLANESWALKER);
|
||||
else
|
||||
filter.getCardType().remove(CardType.PLANESWALKER);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoPlaneswalkersActionPerformed
|
||||
|
||||
private void cbExpansionSetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbExpansionSetActionPerformed
|
||||
filter.getExpansionSetCode().clear();
|
||||
if (cbExpansionSet.getSelectedItem() instanceof ExpansionSet) {
|
||||
filter.getExpansionSetCode().add(((ExpansionSet)this.cbExpansionSet.getSelectedItem()).getCode());
|
||||
filterCards();
|
||||
} else {
|
||||
private void cbExpansionSetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbExpansionSetActionPerformed
|
||||
filter.getExpansionSetCode().clear();
|
||||
if (cbExpansionSet.getSelectedItem() instanceof ExpansionSet) {
|
||||
filter.getExpansionSetCode().add(((ExpansionSet)this.cbExpansionSet.getSelectedItem()).getCode());
|
||||
filterCards();
|
||||
} else {
|
||||
if (this.cbExpansionSet.getSelectedItem().equals("-- Standard")) {
|
||||
filter.getExpansionSetCode().addAll(ConstructedFormats.getSetsByFormat("Standard"));
|
||||
filterCards();
|
||||
} else {
|
||||
// auto switch for ListView for "All sets" (too many cards to load)
|
||||
jToggleListView.doClick();
|
||||
jToggleListView.setSelected(true);
|
||||
// auto switch for ListView for "All sets" (too many cards to load)
|
||||
jToggleListView.doClick();
|
||||
jToggleListView.setSelected(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}//GEN-LAST:event_cbExpansionSetActionPerformed
|
||||
}//GEN-LAST:event_cbExpansionSetActionPerformed
|
||||
|
||||
private void btnClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClearActionPerformed
|
||||
cards.clear();
|
||||
filterCards();
|
||||
}//GEN-LAST:event_btnClearActionPerformed
|
||||
private void btnClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClearActionPerformed
|
||||
cards.clear();
|
||||
filterCards();
|
||||
}//GEN-LAST:event_btnClearActionPerformed
|
||||
|
||||
private void btnBoosterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBoosterActionPerformed
|
||||
if (cbExpansionSet.getSelectedItem() instanceof ExpansionSet) {
|
||||
List<Card> booster = ((ExpansionSet)this.cbExpansionSet.getSelectedItem()).createBooster();
|
||||
for (Card card: booster) {
|
||||
cards.add(card);
|
||||
}
|
||||
filterCards();
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "It's not possible to generate booster for not Expansion Set \nChoose Expansion Set first.");
|
||||
}
|
||||
}//GEN-LAST:event_btnBoosterActionPerformed
|
||||
private void btnBoosterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBoosterActionPerformed
|
||||
if (cbExpansionSet.getSelectedItem() instanceof ExpansionSet) {
|
||||
List<Card> booster = ((ExpansionSet)this.cbExpansionSet.getSelectedItem()).createBooster();
|
||||
for (Card card: booster) {
|
||||
cards.add(card);
|
||||
}
|
||||
filterCards();
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "It's not possible to generate booster for not Expansion Set \nChoose Expansion Set first.");
|
||||
}
|
||||
}//GEN-LAST:event_btnBoosterActionPerformed
|
||||
|
||||
private void cbSortByActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbSortByActionPerformed
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy)
|
||||
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
}//GEN-LAST:event_cbSortByActionPerformed
|
||||
private void cbSortByActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbSortByActionPerformed
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy)
|
||||
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
}//GEN-LAST:event_cbSortByActionPerformed
|
||||
|
||||
private void chkPilesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkPilesActionPerformed
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy)
|
||||
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
}//GEN-LAST:event_chkPilesActionPerformed
|
||||
private void chkPilesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkPilesActionPerformed
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy)
|
||||
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
}//GEN-LAST:event_chkPilesActionPerformed
|
||||
|
||||
private void jToggleListViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleListViewActionPerformed
|
||||
jToggleCardView.setSelected(false);
|
||||
currentView = mainModel;
|
||||
jScrollPane1.setViewportView(mainTable);
|
||||
cbSortBy.setEnabled(false);
|
||||
chkPiles.setEnabled(false);
|
||||
jButtonAddToMain.setEnabled(true);
|
||||
jButtonAddToSideboard.setEnabled(true);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_jToggleListViewActionPerformed
|
||||
private void jToggleListViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleListViewActionPerformed
|
||||
jToggleCardView.setSelected(false);
|
||||
currentView = mainModel;
|
||||
jScrollPane1.setViewportView(mainTable);
|
||||
cbSortBy.setEnabled(false);
|
||||
chkPiles.setEnabled(false);
|
||||
jButtonAddToMain.setEnabled(true);
|
||||
jButtonAddToSideboard.setEnabled(true);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_jToggleListViewActionPerformed
|
||||
|
||||
private void jToggleCardViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleCardViewActionPerformed
|
||||
jToggleListView.setSelected(false);
|
||||
currentView = cardGrid;
|
||||
jScrollPane1.setViewportView(cardGrid);
|
||||
cbSortBy.setEnabled(true);
|
||||
chkPiles.setEnabled(true);
|
||||
jButtonAddToMain.setEnabled(false);
|
||||
jButtonAddToSideboard.setEnabled(false);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_jToggleCardViewActionPerformed
|
||||
private void jToggleCardViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleCardViewActionPerformed
|
||||
jToggleListView.setSelected(false);
|
||||
currentView = cardGrid;
|
||||
jScrollPane1.setViewportView(cardGrid);
|
||||
cbSortBy.setEnabled(true);
|
||||
chkPiles.setEnabled(true);
|
||||
jButtonAddToMain.setEnabled(false);
|
||||
jButtonAddToSideboard.setEnabled(false);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_jToggleCardViewActionPerformed
|
||||
|
||||
private void jButtonAddToMainActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAddToMainActionPerformed
|
||||
if (mainTable.getSelectedRowCount() > 0) {
|
||||
int[] n = mainTable.getSelectedRows();
|
||||
List<Integer> indexes = asList(n);
|
||||
Collections.reverse(indexes);
|
||||
for (Integer index : indexes) {
|
||||
mainModel.doubleClick(index);
|
||||
}
|
||||
//if (!mode.equals(Constants.DeckEditorMode.Constructed))
|
||||
if (limited)
|
||||
mainModel.fireTableDataChanged();
|
||||
}
|
||||
}//GEN-LAST:event_jButtonAddToMainActionPerformed
|
||||
private void jButtonAddToMainActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAddToMainActionPerformed
|
||||
if (mainTable.getSelectedRowCount() > 0) {
|
||||
int[] n = mainTable.getSelectedRows();
|
||||
List<Integer> indexes = asList(n);
|
||||
Collections.reverse(indexes);
|
||||
for (Integer index : indexes) {
|
||||
mainModel.doubleClick(index);
|
||||
}
|
||||
//if (!mode.equals(Constants.DeckEditorMode.Constructed))
|
||||
if (limited)
|
||||
mainModel.fireTableDataChanged();
|
||||
}
|
||||
}//GEN-LAST:event_jButtonAddToMainActionPerformed
|
||||
|
||||
private void jButtonAddToSideboardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAddToSideboardActionPerformed
|
||||
if (mainTable.getSelectedRowCount() > 0) {
|
||||
int[] n = mainTable.getSelectedRows();
|
||||
List<Integer> indexes = asList(n);
|
||||
Collections.reverse(indexes);
|
||||
for (Integer index : indexes) {
|
||||
mainModel.shiftDoubleClick(index);
|
||||
}
|
||||
//if (!mode.equals(Constants.DeckEditorMode.Constructed))
|
||||
if (limited)
|
||||
mainModel.fireTableDataChanged();
|
||||
}
|
||||
}//GEN-LAST:event_jButtonAddToSideboardActionPerformed
|
||||
private void jButtonAddToSideboardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAddToSideboardActionPerformed
|
||||
if (mainTable.getSelectedRowCount() > 0) {
|
||||
int[] n = mainTable.getSelectedRows();
|
||||
List<Integer> indexes = asList(n);
|
||||
Collections.reverse(indexes);
|
||||
for (Integer index : indexes) {
|
||||
mainModel.shiftDoubleClick(index);
|
||||
}
|
||||
//if (!mode.equals(Constants.DeckEditorMode.Constructed))
|
||||
if (limited)
|
||||
mainModel.fireTableDataChanged();
|
||||
}
|
||||
}//GEN-LAST:event_jButtonAddToSideboardActionPerformed
|
||||
|
||||
private void jButtonRemoveFromMainActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRemoveFromMainActionPerformed
|
||||
mainModel.removeFromMainEvent(0);
|
||||
|
@ -844,36 +844,36 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
}//GEN-LAST:event_jButtonRemoveFromSideboardActionPerformed
|
||||
|
||||
|
||||
private void jButtonSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSearchActionPerformed
|
||||
String name = jTextFieldSearch.getText().trim();
|
||||
filter.setText(name);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_jButtonSearchActionPerformed
|
||||
private void jButtonSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSearchActionPerformed
|
||||
String name = jTextFieldSearch.getText().trim();
|
||||
filter.setText(name);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_jButtonSearchActionPerformed
|
||||
|
||||
private void jButtonCleanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCleanActionPerformed
|
||||
jTextFieldSearch.setText("");
|
||||
filter.setText("");
|
||||
filterCards();
|
||||
}//GEN-LAST:event_jButtonCleanActionPerformed
|
||||
private void jButtonCleanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCleanActionPerformed
|
||||
jTextFieldSearch.setText("");
|
||||
filter.setText("");
|
||||
filterCards();
|
||||
}//GEN-LAST:event_jButtonCleanActionPerformed
|
||||
|
||||
public List<Integer> asList(final int[] is) {
|
||||
List<Integer> list = new ArrayList<Integer>();
|
||||
for (int i : is) list.add(i);
|
||||
return list;
|
||||
for (int i : is) list.add(i);
|
||||
return list;
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
currentView.refresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
public void refresh() {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
currentView.refresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private TableModel mainModel;
|
||||
private JTable mainTable;
|
||||
private ICardGrid currentView;
|
||||
private TableModel mainModel;
|
||||
private JTable mainTable;
|
||||
private ICardGrid currentView;
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton btnBooster;
|
||||
|
@ -914,28 +914,28 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
|
||||
private mage.client.cards.CardGrid cardGrid;
|
||||
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy)
|
||||
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
}
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy)
|
||||
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentMoved(ComponentEvent e) {
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy)
|
||||
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
}
|
||||
@Override
|
||||
public void componentMoved(ComponentEvent e) {
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy)
|
||||
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentShown(ComponentEvent e) {
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy)
|
||||
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
}
|
||||
@Override
|
||||
public void componentShown(ComponentEvent e) {
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy)
|
||||
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentHidden(ComponentEvent e) {
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy)
|
||||
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
}
|
||||
@Override
|
||||
public void componentHidden(ComponentEvent e) {
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy)
|
||||
this.currentView.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -54,35 +54,35 @@ public class DeckArea extends javax.swing.JPanel {
|
|||
jSplitPane1.setOpaque(false);
|
||||
deckList.setOpaque(false);
|
||||
sideboardList.setOpaque(false);
|
||||
deckList.setDisplayNoCopies(true);
|
||||
sideboardList.setDisplayNoCopies(true);
|
||||
deckList.setDisplayNoCopies(true);
|
||||
sideboardList.setDisplayNoCopies(true);
|
||||
}
|
||||
|
||||
public void showSideboard(boolean show) {
|
||||
this.sideboardList.setVisible(show);
|
||||
}
|
||||
public void showSideboard(boolean show) {
|
||||
this.sideboardList.setVisible(show);
|
||||
}
|
||||
|
||||
public void loadDeck(Deck deck, BigCard bigCard) {
|
||||
deckList.loadCards(new CardsView(deck.getCards()), bigCard, null);
|
||||
if (sideboardList.isVisible())
|
||||
sideboardList.loadCards(new CardsView(deck.getSideboard()), bigCard, null);
|
||||
}
|
||||
public void loadDeck(Deck deck, BigCard bigCard) {
|
||||
deckList.loadCards(new CardsView(deck.getCards()), bigCard, null);
|
||||
if (sideboardList.isVisible())
|
||||
sideboardList.loadCards(new CardsView(deck.getSideboard()), bigCard, null);
|
||||
}
|
||||
|
||||
public void addDeckEventListener(Listener<Event> listener) {
|
||||
deckList.addCardEventListener(listener);
|
||||
}
|
||||
public void addDeckEventListener(Listener<Event> listener) {
|
||||
deckList.addCardEventListener(listener);
|
||||
}
|
||||
|
||||
public void clearDeckEventListeners() {
|
||||
deckList.clearCardEventListeners();
|
||||
}
|
||||
public void clearDeckEventListeners() {
|
||||
deckList.clearCardEventListeners();
|
||||
}
|
||||
|
||||
public void addSideboardEventListener(Listener<Event> listener) {
|
||||
sideboardList.addCardEventListener(listener);
|
||||
}
|
||||
public void addSideboardEventListener(Listener<Event> listener) {
|
||||
sideboardList.addCardEventListener(listener);
|
||||
}
|
||||
|
||||
public void clearSideboardEventListeners() {
|
||||
sideboardList.clearCardEventListeners();
|
||||
}
|
||||
public void clearSideboardEventListeners() {
|
||||
sideboardList.clearCardEventListeners();
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
|
|
@ -54,26 +54,26 @@ public class DeckEditorPane extends MagePane {
|
|||
|
||||
/** Creates new form TablesPane */
|
||||
public DeckEditorPane() {
|
||||
|
||||
|
||||
boolean initialized = false;
|
||||
if (Plugins.getInstance().isThemePluginLoaded()) {
|
||||
Map<String, JComponent> ui = new HashMap<String, JComponent>();
|
||||
JComponent container = Plugins.getInstance().updateTablePanel(ui);
|
||||
if (container != null) {
|
||||
deckEditorPanel1 = new mage.client.deckeditor.DeckEditorPanel();
|
||||
initComponents(container);
|
||||
container.add(deckEditorPanel1);
|
||||
container.setOpaque(false);
|
||||
deckEditorPanel1.setOpaque(false);
|
||||
initialized = true;
|
||||
}
|
||||
Map<String, JComponent> ui = new HashMap<String, JComponent>();
|
||||
JComponent container = Plugins.getInstance().updateTablePanel(ui);
|
||||
if (container != null) {
|
||||
deckEditorPanel1 = new mage.client.deckeditor.DeckEditorPanel();
|
||||
initComponents(container);
|
||||
container.add(deckEditorPanel1);
|
||||
container.setOpaque(false);
|
||||
deckEditorPanel1.setOpaque(false);
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
if (!initialized) {
|
||||
initComponents();
|
||||
initComponents();
|
||||
}
|
||||
}
|
||||
|
||||
public void show(DeckEditorMode mode, Deck deck, String name, UUID tableId, int time) {
|
||||
public void show(DeckEditorMode mode, Deck deck, String name, UUID tableId, int time) {
|
||||
if (mode == DeckEditorMode.Sideboard || mode == DeckEditorMode.Limited)
|
||||
this.setTitle("Deck Editor - " + tableId.toString());
|
||||
else {
|
||||
|
@ -82,9 +82,9 @@ public class DeckEditorPane extends MagePane {
|
|||
else
|
||||
this.setTitle("Deck Editor");
|
||||
}
|
||||
this.deckEditorPanel1.showDeckEditor(mode, deck, tableId, time);
|
||||
this.repaint();
|
||||
}
|
||||
this.deckEditorPanel1.showDeckEditor(mode, deck, tableId, time);
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
|
|
|
@ -64,232 +64,232 @@ import java.util.concurrent.ExecutionException;
|
|||
*/
|
||||
public class DeckEditorPanel extends javax.swing.JPanel {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(DeckEditorPanel.class);
|
||||
private final static Logger logger = Logger.getLogger(DeckEditorPanel.class);
|
||||
|
||||
private JFileChooser fcSelectDeck;
|
||||
private JFileChooser fcImportDeck;
|
||||
private Deck deck = new Deck();
|
||||
private JFileChooser fcImportDeck;
|
||||
private Deck deck = new Deck();
|
||||
private boolean isShowCardInfo = false;
|
||||
private UUID tableId;
|
||||
private DeckEditorMode mode;
|
||||
private int timeout;
|
||||
private Timer countdown;
|
||||
private UpdateDeckTask updateDeckTask;
|
||||
private UUID tableId;
|
||||
private DeckEditorMode mode;
|
||||
private int timeout;
|
||||
private Timer countdown;
|
||||
private UpdateDeckTask updateDeckTask;
|
||||
|
||||
|
||||
/** Creates new form DeckEditorPanel */
|
||||
public DeckEditorPanel() {
|
||||
initComponents();
|
||||
fcSelectDeck = new JFileChooser();
|
||||
fcSelectDeck.setAcceptAllFileFilterUsed(false);
|
||||
fcSelectDeck.addChoosableFileFilter(new DeckFilter());
|
||||
fcImportDeck = new JFileChooser();
|
||||
fcImportDeck.setAcceptAllFileFilterUsed(false);
|
||||
fcImportDeck.addChoosableFileFilter(new ImportFilter());
|
||||
|
||||
deckArea.setOpaque(false);
|
||||
jPanel1.setOpaque(false);
|
||||
jSplitPane1.setOpaque(false);
|
||||
countdown = new Timer(1000,
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (--timeout > 0) {
|
||||
setTimeout(Integer.toString(timeout));
|
||||
}
|
||||
else {
|
||||
fcSelectDeck = new JFileChooser();
|
||||
fcSelectDeck.setAcceptAllFileFilterUsed(false);
|
||||
fcSelectDeck.addChoosableFileFilter(new DeckFilter());
|
||||
fcImportDeck = new JFileChooser();
|
||||
fcImportDeck.setAcceptAllFileFilterUsed(false);
|
||||
fcImportDeck.addChoosableFileFilter(new ImportFilter());
|
||||
|
||||
deckArea.setOpaque(false);
|
||||
jPanel1.setOpaque(false);
|
||||
jSplitPane1.setOpaque(false);
|
||||
countdown = new Timer(1000,
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (--timeout > 0) {
|
||||
setTimeout(Integer.toString(timeout));
|
||||
}
|
||||
else {
|
||||
if (updateDeckTask != null)
|
||||
updateDeckTask.cancel(true);
|
||||
setTimeout("0");
|
||||
countdown.stop();
|
||||
setTimeout("0");
|
||||
countdown.stop();
|
||||
hideDeckEditor();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID tableId, int time) {
|
||||
if (deck != null)
|
||||
this.deck = deck;
|
||||
this.tableId = tableId;
|
||||
this.mode = mode;
|
||||
this.btnAddLand.setVisible(false);
|
||||
switch (mode) {
|
||||
case Limited:
|
||||
this.btnAddLand.setVisible(true);
|
||||
this.txtTimeRemaining.setVisible(true);
|
||||
case Sideboard:
|
||||
this.btnSubmit.setVisible(true);
|
||||
this.cardSelector.loadSideboard(new ArrayList<Card>(deck.getSideboard()), this.bigCard);
|
||||
this.btnExit.setVisible(false);
|
||||
this.btnImport.setVisible(false);
|
||||
if (!MageFrame.getSession().isTestMode())
|
||||
this.btnLoad.setVisible(false);
|
||||
this.deckArea.showSideboard(false);
|
||||
countdown.stop();
|
||||
this.timeout = time;
|
||||
setTimeout(Integer.toString(timeout));
|
||||
if (timeout != 0) {
|
||||
countdown.start();
|
||||
public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID tableId, int time) {
|
||||
if (deck != null)
|
||||
this.deck = deck;
|
||||
this.tableId = tableId;
|
||||
this.mode = mode;
|
||||
this.btnAddLand.setVisible(false);
|
||||
switch (mode) {
|
||||
case Limited:
|
||||
this.btnAddLand.setVisible(true);
|
||||
this.txtTimeRemaining.setVisible(true);
|
||||
case Sideboard:
|
||||
this.btnSubmit.setVisible(true);
|
||||
this.cardSelector.loadSideboard(new ArrayList<Card>(deck.getSideboard()), this.bigCard);
|
||||
this.btnExit.setVisible(false);
|
||||
this.btnImport.setVisible(false);
|
||||
if (!MageFrame.getSession().isTestMode())
|
||||
this.btnLoad.setVisible(false);
|
||||
this.deckArea.showSideboard(false);
|
||||
countdown.stop();
|
||||
this.timeout = time;
|
||||
setTimeout(Integer.toString(timeout));
|
||||
if (timeout != 0) {
|
||||
countdown.start();
|
||||
if (updateDeckTask == null || updateDeckTask.isDone()) {
|
||||
updateDeckTask = new UpdateDeckTask(MageFrame.getSession(), tableId, deck);
|
||||
updateDeckTask.execute();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Constructed:
|
||||
this.btnSubmit.setVisible(false);
|
||||
this.cardSelector.loadCards(this.bigCard);
|
||||
//this.cardTableSelector.loadCards(this.bigCard);
|
||||
this.btnExit.setVisible(true);
|
||||
this.btnImport.setVisible(true);
|
||||
if (!MageFrame.getSession().isTestMode())
|
||||
this.btnLoad.setVisible(true);
|
||||
this.deckArea.showSideboard(true);
|
||||
this.txtTimeRemaining.setVisible(false);
|
||||
break;
|
||||
}
|
||||
init();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Constructed:
|
||||
this.btnSubmit.setVisible(false);
|
||||
this.cardSelector.loadCards(this.bigCard);
|
||||
//this.cardTableSelector.loadCards(this.bigCard);
|
||||
this.btnExit.setVisible(true);
|
||||
this.btnImport.setVisible(true);
|
||||
if (!MageFrame.getSession().isTestMode())
|
||||
this.btnLoad.setVisible(true);
|
||||
this.deckArea.showSideboard(true);
|
||||
this.txtTimeRemaining.setVisible(false);
|
||||
break;
|
||||
}
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
this.cardSelector.setVisible(true);
|
||||
this.jPanel1.setVisible(true);
|
||||
for (ICardGrid component : this.cardSelector.getCardGridComponents()) {
|
||||
component.clearCardEventListeners();
|
||||
component.addCardEventListener(
|
||||
new Listener<Event> () {
|
||||
@Override
|
||||
public void event(Event event) {
|
||||
if (event.getEventName().equals("double-click")) {
|
||||
Card card = cardSelector.getCard((UUID) event.getSource());
|
||||
if (card != null) {
|
||||
deck.getCards().add(Sets.createCard(card.getClass()));
|
||||
if (mode == DeckEditorMode.Sideboard || mode == DeckEditorMode.Limited) {
|
||||
deck.getSideboard().remove(card);
|
||||
cardSelector.removeCard(card.getId());
|
||||
cardSelector.refresh();
|
||||
private void init() {
|
||||
this.cardSelector.setVisible(true);
|
||||
this.jPanel1.setVisible(true);
|
||||
for (ICardGrid component : this.cardSelector.getCardGridComponents()) {
|
||||
component.clearCardEventListeners();
|
||||
component.addCardEventListener(
|
||||
new Listener<Event> () {
|
||||
@Override
|
||||
public void event(Event event) {
|
||||
if (event.getEventName().equals("double-click")) {
|
||||
Card card = cardSelector.getCard((UUID) event.getSource());
|
||||
if (card != null) {
|
||||
deck.getCards().add(Sets.createCard(card.getClass()));
|
||||
if (mode == DeckEditorMode.Sideboard || mode == DeckEditorMode.Limited) {
|
||||
deck.getSideboard().remove(card);
|
||||
cardSelector.removeCard(card.getId());
|
||||
cardSelector.refresh();
|
||||
|
||||
}
|
||||
if (cardInfoPane instanceof CardInfoPane) {
|
||||
((CardInfoPane)cardInfoPane).setCard(new CardView(card));
|
||||
}
|
||||
hidePopup();
|
||||
}
|
||||
}
|
||||
if (cardInfoPane instanceof CardInfoPane) {
|
||||
((CardInfoPane)cardInfoPane).setCard(new CardView(card));
|
||||
}
|
||||
hidePopup();
|
||||
}
|
||||
|
||||
} else if (event.getEventName().equals("shift-double-click") && mode == DeckEditorMode.Constructed) {
|
||||
Card card = cardSelector.getCard((UUID) event.getSource());
|
||||
deck.getSideboard().add(Sets.createCard(card.getClass()));
|
||||
if (cardInfoPane instanceof CardInfoPane) {
|
||||
((CardInfoPane)cardInfoPane).setCard(new CardView(card));
|
||||
}
|
||||
hidePopup();
|
||||
} else if (event.getEventName().equals("shift-double-click") && mode == DeckEditorMode.Constructed) {
|
||||
Card card = cardSelector.getCard((UUID) event.getSource());
|
||||
deck.getSideboard().add(Sets.createCard(card.getClass()));
|
||||
if (cardInfoPane instanceof CardInfoPane) {
|
||||
((CardInfoPane)cardInfoPane).setCard(new CardView(card));
|
||||
}
|
||||
hidePopup();
|
||||
} else if (event.getEventName().equals("remove-main")) {
|
||||
DeckEditorPanel.this.deckArea.getDeckList().handleDoubleClick();
|
||||
} else if (event.getEventName().equals("remove-sideboard")) {
|
||||
DeckEditorPanel.this.deckArea.getSideboardList().handleDoubleClick();
|
||||
}
|
||||
refreshDeck();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
this.deckArea.clearDeckEventListeners();
|
||||
this.deckArea.addDeckEventListener(
|
||||
new Listener<Event> () {
|
||||
@Override
|
||||
public void event(Event event) {
|
||||
if (event.getEventName().equals("double-click")) {
|
||||
for (Card card: deck.getCards()) {
|
||||
if (card.getId().equals(event.getSource())) {
|
||||
deck.getCards().remove(card);
|
||||
if (mode == DeckEditorMode.Limited || mode == DeckEditorMode.Sideboard) {
|
||||
deck.getSideboard().add(card);
|
||||
cardSelector.loadSideboard(new ArrayList<Card>(deck.getSideboard()), getBigCard());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
hidePopup();
|
||||
refreshDeck();
|
||||
}
|
||||
else if (event.getEventName().equals("shift-double-click") && mode == DeckEditorMode.Constructed) {
|
||||
for (Card card: deck.getCards()) {
|
||||
if (card.getId().equals(event.getSource())) {
|
||||
deck.getCards().remove(card);
|
||||
deck.getSideboard().add(card);
|
||||
break;
|
||||
}
|
||||
}
|
||||
hidePopup();
|
||||
refreshDeck();
|
||||
refreshDeck();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
this.deckArea.addSideboardEventListener(
|
||||
new Listener<Event> () {
|
||||
@Override
|
||||
public void event(Event event) {
|
||||
if (event.getEventName().equals("double-click")) {
|
||||
for (Card card: deck.getSideboard()) {
|
||||
if (card.getId().equals(event.getSource())) {
|
||||
deck.getSideboard().remove(card);
|
||||
deck.getCards().add(card);
|
||||
break;
|
||||
}
|
||||
}
|
||||
hidePopup();
|
||||
refreshDeck();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
refreshDeck();
|
||||
this.setVisible(true);
|
||||
this.repaint();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
this.deckArea.clearDeckEventListeners();
|
||||
this.deckArea.addDeckEventListener(
|
||||
new Listener<Event> () {
|
||||
@Override
|
||||
public void event(Event event) {
|
||||
if (event.getEventName().equals("double-click")) {
|
||||
for (Card card: deck.getCards()) {
|
||||
if (card.getId().equals(event.getSource())) {
|
||||
deck.getCards().remove(card);
|
||||
if (mode == DeckEditorMode.Limited || mode == DeckEditorMode.Sideboard) {
|
||||
deck.getSideboard().add(card);
|
||||
cardSelector.loadSideboard(new ArrayList<Card>(deck.getSideboard()), getBigCard());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
hidePopup();
|
||||
refreshDeck();
|
||||
}
|
||||
else if (event.getEventName().equals("shift-double-click") && mode == DeckEditorMode.Constructed) {
|
||||
for (Card card: deck.getCards()) {
|
||||
if (card.getId().equals(event.getSource())) {
|
||||
deck.getCards().remove(card);
|
||||
deck.getSideboard().add(card);
|
||||
break;
|
||||
}
|
||||
}
|
||||
hidePopup();
|
||||
refreshDeck();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
this.deckArea.addSideboardEventListener(
|
||||
new Listener<Event> () {
|
||||
@Override
|
||||
public void event(Event event) {
|
||||
if (event.getEventName().equals("double-click")) {
|
||||
for (Card card: deck.getSideboard()) {
|
||||
if (card.getId().equals(event.getSource())) {
|
||||
deck.getSideboard().remove(card);
|
||||
deck.getCards().add(card);
|
||||
break;
|
||||
}
|
||||
}
|
||||
hidePopup();
|
||||
refreshDeck();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
refreshDeck();
|
||||
this.setVisible(true);
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
private void hidePopup() {
|
||||
Plugins.getInstance().getActionCallback().mouseExited(null, null);
|
||||
}
|
||||
|
||||
public void hideDeckEditor() {
|
||||
private void hidePopup() {
|
||||
Plugins.getInstance().getActionCallback().mouseExited(null, null);
|
||||
}
|
||||
|
||||
public void hideDeckEditor() {
|
||||
if (updateDeckTask != null)
|
||||
updateDeckTask.cancel(true);
|
||||
Component c = this.getParent();
|
||||
while (c != null && !(c instanceof DeckEditorPane)) {
|
||||
c = c.getParent();
|
||||
}
|
||||
if (c != null)
|
||||
((DeckEditorPane)c).hideFrame();
|
||||
}
|
||||
Component c = this.getParent();
|
||||
while (c != null && !(c instanceof DeckEditorPane)) {
|
||||
c = c.getParent();
|
||||
}
|
||||
if (c != null)
|
||||
((DeckEditorPane)c).hideFrame();
|
||||
}
|
||||
|
||||
private BigCard getBigCard() {
|
||||
return this.bigCard;
|
||||
}
|
||||
private BigCard getBigCard() {
|
||||
return this.bigCard;
|
||||
}
|
||||
|
||||
private void refreshDeck() {
|
||||
try {
|
||||
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||
this.txtDeckName.setText(deck.getName());
|
||||
deckArea.loadDeck(deck, bigCard);
|
||||
}
|
||||
finally {
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
}
|
||||
private void refreshDeck() {
|
||||
try {
|
||||
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||
this.txtDeckName.setText(deck.getName());
|
||||
deckArea.loadDeck(deck, bigCard);
|
||||
}
|
||||
finally {
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
}
|
||||
|
||||
private void setTimeout(String text) {
|
||||
this.txtTimeRemaining.setText(text);
|
||||
}
|
||||
private void setTimeout(String text) {
|
||||
this.txtTimeRemaining.setText(text);
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
private void initComponents() {
|
||||
|
||||
jSplitPane1 = new javax.swing.JSplitPane();
|
||||
cardSelector = new mage.client.deckeditor.CardSelector();
|
||||
deckArea = new mage.client.deckeditor.DeckArea();
|
||||
deckArea = new mage.client.deckeditor.DeckArea();
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
bigCard = new mage.client.cards.BigCard();
|
||||
txtDeckName = new javax.swing.JTextField();
|
||||
|
@ -300,20 +300,20 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
btnExit = new javax.swing.JButton();
|
||||
btnImport = new javax.swing.JButton();
|
||||
btnSubmit = new javax.swing.JButton();
|
||||
btnAddLand = new javax.swing.JButton();
|
||||
txtTimeRemaining = new javax.swing.JTextField();
|
||||
btnAddLand = new javax.swing.JButton();
|
||||
txtTimeRemaining = new javax.swing.JTextField();
|
||||
|
||||
jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
|
||||
jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
|
||||
jSplitPane1.setResizeWeight(0.5);
|
||||
jSplitPane1.setTopComponent(cardSelector);
|
||||
jSplitPane1.setBottomComponent(deckArea);
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
jSplitPane1.setDividerLocation(0.6);
|
||||
}
|
||||
});
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
jSplitPane1.setDividerLocation(0.6);
|
||||
}
|
||||
});
|
||||
|
||||
bigCard.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
|
||||
|
||||
|
@ -384,9 +384,9 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
btnAddLand.setName("btnAddLand"); // NOI18N
|
||||
btnAddLand.addActionListener(new java.awt.event.ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnAddLandActionPerformed(evt);
|
||||
}
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnAddLandActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
txtTimeRemaining.setEditable(false);
|
||||
|
@ -394,69 +394,69 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
txtTimeRemaining.setHorizontalAlignment(javax.swing.JTextField.CENTER);
|
||||
txtTimeRemaining.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
|
||||
|
||||
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
||||
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
||||
jPanel1.setLayout(jPanel1Layout);
|
||||
jPanel1Layout.setHorizontalGroup(
|
||||
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(btnAddLand)
|
||||
.addContainerGap()
|
||||
.addComponent(btnSubmit))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(txtTimeRemaining))
|
||||
)
|
||||
.addContainerGap())
|
||||
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(btnAddLand)
|
||||
.addContainerGap()
|
||||
.addComponent(btnSubmit))
|
||||
.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))
|
||||
.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))
|
||||
.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(btnAddLand)
|
||||
.addComponent(btnSubmit))
|
||||
.addComponent(btnImport)
|
||||
.addComponent(btnAddLand)
|
||||
.addComponent(btnSubmit))
|
||||
.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)
|
||||
.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)
|
||||
.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))
|
||||
);
|
||||
|
||||
|
@ -476,124 +476,124 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
);
|
||||
}
|
||||
|
||||
private void btnLoadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoadActionPerformed
|
||||
String lastFolder = MageFrame.getPreferences().get("lastDeckFolder", "");
|
||||
if (!lastFolder.isEmpty())
|
||||
fcSelectDeck.setCurrentDirectory(new File(lastFolder));
|
||||
int ret = fcSelectDeck.showOpenDialog(this);
|
||||
if (ret == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fcSelectDeck.getSelectedFile();
|
||||
try {
|
||||
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||
deck = Deck.load(DeckImporterUtil.importDeck(file.getPath()), true);
|
||||
} catch (GameException ex) {
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Error loading deck", JOptionPane.ERROR_MESSAGE);
|
||||
} catch (Exception ex) {
|
||||
logger.fatal(ex);
|
||||
}
|
||||
finally {
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
refreshDeck();
|
||||
try {
|
||||
MageFrame.getPreferences().put("lastDeckFolder", file.getCanonicalPath());
|
||||
} catch (IOException ex) { }
|
||||
}
|
||||
fcSelectDeck.setSelectedFile(null);
|
||||
}//GEN-LAST:event_btnLoadActionPerformed
|
||||
private void btnLoadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoadActionPerformed
|
||||
String lastFolder = MageFrame.getPreferences().get("lastDeckFolder", "");
|
||||
if (!lastFolder.isEmpty())
|
||||
fcSelectDeck.setCurrentDirectory(new File(lastFolder));
|
||||
int ret = fcSelectDeck.showOpenDialog(this);
|
||||
if (ret == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fcSelectDeck.getSelectedFile();
|
||||
try {
|
||||
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||
deck = Deck.load(DeckImporterUtil.importDeck(file.getPath()), true);
|
||||
} catch (GameException ex) {
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Error loading deck", JOptionPane.ERROR_MESSAGE);
|
||||
} catch (Exception ex) {
|
||||
logger.fatal(ex);
|
||||
}
|
||||
finally {
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
refreshDeck();
|
||||
try {
|
||||
MageFrame.getPreferences().put("lastDeckFolder", file.getCanonicalPath());
|
||||
} catch (IOException ex) { }
|
||||
}
|
||||
fcSelectDeck.setSelectedFile(null);
|
||||
}//GEN-LAST:event_btnLoadActionPerformed
|
||||
|
||||
private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
|
||||
String lastFolder = MageFrame.getPreferences().get("lastDeckFolder", "");
|
||||
if (!lastFolder.isEmpty())
|
||||
fcSelectDeck.setCurrentDirectory(new File(lastFolder));
|
||||
deck.setName(this.txtDeckName.getText());
|
||||
int ret = fcSelectDeck.showSaveDialog(this);
|
||||
if (ret == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fcSelectDeck.getSelectedFile();
|
||||
try {
|
||||
String fileName = file.getPath();
|
||||
if (!fileName.endsWith(".dck"))
|
||||
fileName += ".dck";
|
||||
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||
Sets.saveDeck(fileName, deck.getDeckCardLists());
|
||||
} catch (Exception ex) {
|
||||
logger.fatal(ex);
|
||||
}
|
||||
finally {
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
try {
|
||||
MageFrame.getPreferences().put("lastDeckFolder", file.getCanonicalPath());
|
||||
} catch (IOException ex) { }
|
||||
}
|
||||
}//GEN-LAST:event_btnSaveActionPerformed
|
||||
private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
|
||||
String lastFolder = MageFrame.getPreferences().get("lastDeckFolder", "");
|
||||
if (!lastFolder.isEmpty())
|
||||
fcSelectDeck.setCurrentDirectory(new File(lastFolder));
|
||||
deck.setName(this.txtDeckName.getText());
|
||||
int ret = fcSelectDeck.showSaveDialog(this);
|
||||
if (ret == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fcSelectDeck.getSelectedFile();
|
||||
try {
|
||||
String fileName = file.getPath();
|
||||
if (!fileName.endsWith(".dck"))
|
||||
fileName += ".dck";
|
||||
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||
Sets.saveDeck(fileName, deck.getDeckCardLists());
|
||||
} catch (Exception ex) {
|
||||
logger.fatal(ex);
|
||||
}
|
||||
finally {
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
try {
|
||||
MageFrame.getPreferences().put("lastDeckFolder", file.getCanonicalPath());
|
||||
} catch (IOException ex) { }
|
||||
}
|
||||
}//GEN-LAST:event_btnSaveActionPerformed
|
||||
|
||||
private void btnNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewActionPerformed
|
||||
if (mode == DeckEditorMode.Sideboard || mode == DeckEditorMode.Limited) {
|
||||
for (Card card: deck.getCards()) {
|
||||
deck.getSideboard().add(card);
|
||||
}
|
||||
deck.getCards().clear();
|
||||
cardSelector.loadSideboard(new ArrayList<Card>(deck.getSideboard()), this.bigCard);
|
||||
}
|
||||
else {
|
||||
deck = new Deck();
|
||||
}
|
||||
refreshDeck();
|
||||
}//GEN-LAST:event_btnNewActionPerformed
|
||||
private void btnNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewActionPerformed
|
||||
if (mode == DeckEditorMode.Sideboard || mode == DeckEditorMode.Limited) {
|
||||
for (Card card: deck.getCards()) {
|
||||
deck.getSideboard().add(card);
|
||||
}
|
||||
deck.getCards().clear();
|
||||
cardSelector.loadSideboard(new ArrayList<Card>(deck.getSideboard()), this.bigCard);
|
||||
}
|
||||
else {
|
||||
deck = new Deck();
|
||||
}
|
||||
refreshDeck();
|
||||
}//GEN-LAST:event_btnNewActionPerformed
|
||||
|
||||
private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExitActionPerformed
|
||||
hideDeckEditor();
|
||||
}//GEN-LAST:event_btnExitActionPerformed
|
||||
private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExitActionPerformed
|
||||
hideDeckEditor();
|
||||
}//GEN-LAST:event_btnExitActionPerformed
|
||||
|
||||
private void btnImportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImportActionPerformed
|
||||
String lastFolder = MageFrame.getPreferences().get("lastImportFolder", "");
|
||||
if (!lastFolder.isEmpty())
|
||||
fcImportDeck.setCurrentDirectory(new File(lastFolder));
|
||||
int ret = fcImportDeck.showOpenDialog(this);
|
||||
if (ret == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fcImportDeck.getSelectedFile();
|
||||
try {
|
||||
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||
DeckImporter importer = DeckImporterUtil.getDeckImporter(file.getPath());
|
||||
if (importer != null) {
|
||||
deck = Deck.load(importer.importDeck(file.getPath()));
|
||||
String errors = importer.getErrors();
|
||||
if(!errors.isEmpty()){
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), errors, "Error importing deck", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Unknown deck format", "Error importing deck", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.fatal(ex);
|
||||
}
|
||||
finally {
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
refreshDeck();
|
||||
try {
|
||||
if (file != null)
|
||||
MageFrame.getPreferences().put("lastImportFolder", file.getCanonicalPath());
|
||||
} catch (IOException ex) { }
|
||||
}
|
||||
fcImportDeck.setSelectedFile(null);
|
||||
}//GEN-LAST:event_btnImportActionPerformed
|
||||
private void btnImportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImportActionPerformed
|
||||
String lastFolder = MageFrame.getPreferences().get("lastImportFolder", "");
|
||||
if (!lastFolder.isEmpty())
|
||||
fcImportDeck.setCurrentDirectory(new File(lastFolder));
|
||||
int ret = fcImportDeck.showOpenDialog(this);
|
||||
if (ret == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fcImportDeck.getSelectedFile();
|
||||
try {
|
||||
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||
DeckImporter importer = DeckImporterUtil.getDeckImporter(file.getPath());
|
||||
if (importer != null) {
|
||||
deck = Deck.load(importer.importDeck(file.getPath()));
|
||||
String errors = importer.getErrors();
|
||||
if(!errors.isEmpty()){
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), errors, "Error importing deck", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Unknown deck format", "Error importing deck", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.fatal(ex);
|
||||
}
|
||||
finally {
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
refreshDeck();
|
||||
try {
|
||||
if (file != null)
|
||||
MageFrame.getPreferences().put("lastImportFolder", file.getCanonicalPath());
|
||||
} catch (IOException ex) { }
|
||||
}
|
||||
fcImportDeck.setSelectedFile(null);
|
||||
}//GEN-LAST:event_btnImportActionPerformed
|
||||
|
||||
private void btnSubmitActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
private void btnSubmitActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
if (updateDeckTask != null)
|
||||
updateDeckTask.cancel(true);
|
||||
|
||||
if (MageFrame.getSession().submitDeck(tableId, deck.getDeckCardLists()))
|
||||
hideDeckEditor();
|
||||
}
|
||||
if (MageFrame.getSession().submitDeck(tableId, deck.getDeckCardLists()))
|
||||
hideDeckEditor();
|
||||
}
|
||||
|
||||
private void btnAddLandActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
AddLandDialog addLand = new AddLandDialog();
|
||||
addLand.showDialog(deck);
|
||||
refreshDeck();
|
||||
}
|
||||
private void btnAddLandActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
AddLandDialog addLand = new AddLandDialog();
|
||||
addLand.showDialog(deck);
|
||||
refreshDeck();
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private mage.client.cards.BigCard bigCard;
|
||||
|
@ -611,17 +611,17 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
private JComponent cardInfoPane;
|
||||
private javax.swing.JButton btnSubmit;
|
||||
private javax.swing.JButton btnAddLand;
|
||||
private javax.swing.JTextField txtTimeRemaining;
|
||||
private javax.swing.JButton btnSubmit;
|
||||
private javax.swing.JButton btnAddLand;
|
||||
private javax.swing.JTextField txtTimeRemaining;
|
||||
}
|
||||
|
||||
class DeckFilter extends FileFilter {
|
||||
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
if (f.isDirectory())
|
||||
return true;
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
if (f.isDirectory())
|
||||
return true;
|
||||
|
||||
String ext = null;
|
||||
String s = f.getName();
|
||||
|
@ -630,21 +630,21 @@ class DeckFilter extends FileFilter {
|
|||
if (i > 0 && i < s.length() - 1) {
|
||||
ext = s.substring(i+1).toLowerCase();
|
||||
}
|
||||
return (ext==null)?false:ext.equals("dck");
|
||||
}
|
||||
return (ext==null)?false:ext.equals("dck");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Deck Files";
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Deck Files";
|
||||
}
|
||||
}
|
||||
|
||||
class ImportFilter extends FileFilter {
|
||||
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
if (f.isDirectory())
|
||||
return true;
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
if (f.isDirectory())
|
||||
return true;
|
||||
|
||||
String ext = null;
|
||||
String s = f.getName();
|
||||
|
@ -653,53 +653,53 @@ class ImportFilter extends FileFilter {
|
|||
if (i > 0 && i < s.length() - 1) {
|
||||
ext = s.substring(i+1).toLowerCase();
|
||||
}
|
||||
if (ext != null) {
|
||||
if (ext.toLowerCase().equals("dec") || ext.toLowerCase().equals("mwdeck") || ext.toLowerCase().equals("txt"))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (ext != null) {
|
||||
if (ext.toLowerCase().equals("dec") || ext.toLowerCase().equals("mwdeck") || ext.toLowerCase().equals("txt"))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "*.dec | *.mwDeck | *.txt";
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "*.dec | *.mwDeck | *.txt";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class UpdateDeckTask extends SwingWorker<Void, Void> {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(UpdateDeckTask.class);
|
||||
private final static Logger logger = Logger.getLogger(UpdateDeckTask.class);
|
||||
|
||||
private Session session;
|
||||
private UUID tableId;
|
||||
private Deck deck;
|
||||
private UUID tableId;
|
||||
private Deck deck;
|
||||
|
||||
UpdateDeckTask(Session session, UUID tableId, Deck deck) {
|
||||
this.session = session;
|
||||
this.tableId = tableId;
|
||||
this.deck = deck;
|
||||
}
|
||||
UpdateDeckTask(Session session, UUID tableId, Deck deck) {
|
||||
this.session = session;
|
||||
this.tableId = tableId;
|
||||
this.deck = deck;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
while (!isCancelled()) {
|
||||
session.updateDeck(tableId, deck.getDeckCardLists());
|
||||
Thread.sleep(5000);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
while (!isCancelled()) {
|
||||
session.updateDeck(tableId, deck.getDeckCardLists());
|
||||
Thread.sleep(5000);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
try {
|
||||
get();
|
||||
} catch (InterruptedException ex) {
|
||||
logger.fatal("Update Matches Task error", ex);
|
||||
} catch (ExecutionException ex) {
|
||||
logger.fatal("Update Matches Task error", ex);
|
||||
} catch (CancellationException ex) {}
|
||||
}
|
||||
@Override
|
||||
protected void done() {
|
||||
try {
|
||||
get();
|
||||
} catch (InterruptedException ex) {
|
||||
logger.fatal("Update Matches Task error", ex);
|
||||
} catch (ExecutionException ex) {
|
||||
logger.fatal("Update Matches Task error", ex);
|
||||
} catch (CancellationException ex) {}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -44,21 +44,21 @@ public class CollectionViewerPane extends MagePane {
|
|||
|
||||
public CollectionViewerPane() {
|
||||
boolean initialized = false;
|
||||
this.setTitle("Collection Viewier");
|
||||
this.setTitle("Collection Viewier");
|
||||
if (Plugins.getInstance().isThemePluginLoaded()) {
|
||||
Map<String, JComponent> ui = new HashMap<String, JComponent>();
|
||||
JComponent container = Plugins.getInstance().updateTablePanel(ui);
|
||||
if (container != null) {
|
||||
collectionViewerPanel = new CollectionViewerPanel();
|
||||
initComponents(container);
|
||||
container.add(collectionViewerPanel);
|
||||
container.setOpaque(false);
|
||||
collectionViewerPanel.setOpaque(false);
|
||||
initialized = true;
|
||||
}
|
||||
Map<String, JComponent> ui = new HashMap<String, JComponent>();
|
||||
JComponent container = Plugins.getInstance().updateTablePanel(ui);
|
||||
if (container != null) {
|
||||
collectionViewerPanel = new CollectionViewerPanel();
|
||||
initComponents(container);
|
||||
container.add(collectionViewerPanel);
|
||||
container.setOpaque(false);
|
||||
collectionViewerPanel.setOpaque(false);
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
if (!initialized) {
|
||||
initComponents(null);
|
||||
initComponents(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ public final class CollectionViewerPanel extends JPanel {
|
|||
}
|
||||
});
|
||||
|
||||
jPanel1.add(Box.createVerticalGlue());
|
||||
jPanel1.add(Box.createVerticalGlue());
|
||||
|
||||
bigCard.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
|
||||
bigCard.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
|
@ -182,14 +182,14 @@ public final class CollectionViewerPanel extends JPanel {
|
|||
|
||||
}
|
||||
|
||||
private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
Component c = this.getParent();
|
||||
while (c != null && !(c instanceof CollectionViewerPane)) {
|
||||
c = c.getParent();
|
||||
}
|
||||
if (c != null)
|
||||
c.setVisible(false);
|
||||
}
|
||||
private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
Component c = this.getParent();
|
||||
while (c != null && !(c instanceof CollectionViewerPane)) {
|
||||
c = c.getParent();
|
||||
}
|
||||
if (c != null)
|
||||
c.setVisible(false);
|
||||
}
|
||||
|
||||
private final class MageBookContainer extends JPanel {
|
||||
public MageBookContainer() {
|
||||
|
@ -218,7 +218,7 @@ public final class CollectionViewerPanel extends JPanel {
|
|||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JPanel jPanel2;
|
||||
private mage.client.cards.BigCard bigCard;
|
||||
private javax.swing.JButton btnExit;
|
||||
private javax.swing.JButton btnExit;
|
||||
private JComboBox formats;
|
||||
private MageBook mageBook;
|
||||
private JRadioButton small3x3;
|
||||
|
|
|
@ -62,9 +62,9 @@ import java.util.UUID;
|
|||
* @author nantuko
|
||||
*/
|
||||
public class MageBook extends JComponent {
|
||||
|
||||
|
||||
public static final String LAYOUT_3x3 = "small";
|
||||
|
||||
|
||||
public static final String LAYOUT_4x4 = "big";
|
||||
|
||||
public MageBook(BigCard bigCard) {
|
||||
|
|
|
@ -38,41 +38,41 @@ import mage.view.CardView;
|
|||
* @author nantuko
|
||||
*/
|
||||
public class CardHelper {
|
||||
private CardHelper() {
|
||||
}
|
||||
|
||||
public static String getColor(CardView c) {
|
||||
if (c.getColor().getColorCount() == 0) return "Colorless";
|
||||
else if (c.getColor().getColorCount() > 1) return "Gold";
|
||||
else if (c.getColor().isBlack()) return "Black";
|
||||
else if (c.getColor().isBlue()) return "Blue";
|
||||
else if (c.getColor().isWhite()) return "White";
|
||||
else if (c.getColor().isGreen()) return "Green";
|
||||
else if (c.getColor().isRed()) return "Red";
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String getType(CardView c) {
|
||||
StringBuilder type = new StringBuilder();
|
||||
for (String superType : c.getSuperTypes()) {
|
||||
type.append(superType);
|
||||
type.append(" ");
|
||||
}
|
||||
for (CardType cardType : c.getCardTypes()) {
|
||||
type.append(cardType.toString());
|
||||
type.append(" ");
|
||||
}
|
||||
if (c.getSubTypes().size() > 0) {
|
||||
type.append("- ");
|
||||
for (String subType : c.getSubTypes()) {
|
||||
type.append(subType);
|
||||
type.append(" ");
|
||||
}
|
||||
}
|
||||
return type.toString();
|
||||
}
|
||||
|
||||
public static boolean isCreature(CardView c) {
|
||||
return c.getCardTypes().contains(CardType.CREATURE);
|
||||
}
|
||||
private CardHelper() {
|
||||
}
|
||||
|
||||
public static String getColor(CardView c) {
|
||||
if (c.getColor().getColorCount() == 0) return "Colorless";
|
||||
else if (c.getColor().getColorCount() > 1) return "Gold";
|
||||
else if (c.getColor().isBlack()) return "Black";
|
||||
else if (c.getColor().isBlue()) return "Blue";
|
||||
else if (c.getColor().isWhite()) return "White";
|
||||
else if (c.getColor().isGreen()) return "Green";
|
||||
else if (c.getColor().isRed()) return "Red";
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String getType(CardView c) {
|
||||
StringBuilder type = new StringBuilder();
|
||||
for (String superType : c.getSuperTypes()) {
|
||||
type.append(superType);
|
||||
type.append(" ");
|
||||
}
|
||||
for (CardType cardType : c.getCardTypes()) {
|
||||
type.append(cardType.toString());
|
||||
type.append(" ");
|
||||
}
|
||||
if (c.getSubTypes().size() > 0) {
|
||||
type.append("- ");
|
||||
for (String subType : c.getSubTypes()) {
|
||||
type.append(subType);
|
||||
type.append(" ");
|
||||
}
|
||||
}
|
||||
return type.toString();
|
||||
}
|
||||
|
||||
public static boolean isCreature(CardView c) {
|
||||
return c.getCardTypes().contains(CardType.CREATURE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,142 +58,142 @@ import java.util.List;
|
|||
*/
|
||||
public class CardTableSelector extends javax.swing.JPanel implements ComponentListener {
|
||||
|
||||
private final List<Card> cards = new ArrayList<Card>();
|
||||
private final FilterCard filter = new FilterCard();
|
||||
private BigCard bigCard;
|
||||
protected CardEventSource cardEventSource = new CardEventSource();
|
||||
private DeckEditorMode mode = DeckEditorMode.Constructed;
|
||||
|
||||
private final List<Card> cards = new ArrayList<Card>();
|
||||
private final FilterCard filter = new FilterCard();
|
||||
private BigCard bigCard;
|
||||
protected CardEventSource cardEventSource = new CardEventSource();
|
||||
private DeckEditorMode mode = DeckEditorMode.Constructed;
|
||||
|
||||
public CardTableSelector() {
|
||||
initComponents();
|
||||
this.addComponentListener(this);
|
||||
setOpaque(false);
|
||||
mainTable.setOpaque(false);
|
||||
jScrollPane1.setOpaque(false);
|
||||
jScrollPane1.getViewport().setOpaque(false);
|
||||
cbSortBy.setModel(new DefaultComboBoxModel(SortBy.values()));
|
||||
cbSortBy.setVisible(false);
|
||||
chkPiles.setVisible(false);
|
||||
|
||||
mainTable.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.getClickCount() == 2 && !e.isConsumed()) {
|
||||
e.consume();
|
||||
jButtonAddToMainActionPerformed(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.addComponentListener(this);
|
||||
setOpaque(false);
|
||||
mainTable.setOpaque(false);
|
||||
jScrollPane1.setOpaque(false);
|
||||
jScrollPane1.getViewport().setOpaque(false);
|
||||
cbSortBy.setModel(new DefaultComboBoxModel(SortBy.values()));
|
||||
cbSortBy.setVisible(false);
|
||||
chkPiles.setVisible(false);
|
||||
|
||||
mainTable.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.getClickCount() == 2 && !e.isConsumed()) {
|
||||
e.consume();
|
||||
jButtonAddToMainActionPerformed(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void loadCards(List<Card> sideboard, BigCard bigCard, boolean construct) {
|
||||
this.bigCard = bigCard;
|
||||
this.btnBooster.setVisible(false);
|
||||
this.btnClear.setVisible(false);
|
||||
this.cbExpansionSet.setVisible(false);
|
||||
this.cards.clear();
|
||||
for (Card card: sideboard) {
|
||||
this.cards.add(card);
|
||||
}
|
||||
initFilter();
|
||||
filterCards();
|
||||
}
|
||||
public void loadCards(List<Card> sideboard, BigCard bigCard, boolean construct) {
|
||||
this.bigCard = bigCard;
|
||||
this.btnBooster.setVisible(false);
|
||||
this.btnClear.setVisible(false);
|
||||
this.cbExpansionSet.setVisible(false);
|
||||
this.cards.clear();
|
||||
for (Card card: sideboard) {
|
||||
this.cards.add(card);
|
||||
}
|
||||
initFilter();
|
||||
filterCards();
|
||||
}
|
||||
|
||||
public void loadCards(BigCard bigCard) {
|
||||
this.bigCard = bigCard;
|
||||
this.btnBooster.setVisible(true);
|
||||
this.btnClear.setVisible(true);
|
||||
this.cbExpansionSet.setVisible(true);
|
||||
Object[] l = Sets.getInstance().values().toArray();
|
||||
Arrays.sort(l, new Comparator<Object>() {
|
||||
@Override
|
||||
public int compare(Object o1, Object o2) {
|
||||
return ((ExpansionSet)o1).getName().compareTo(((ExpansionSet)o2).getName());
|
||||
}
|
||||
});
|
||||
cbExpansionSet.setModel(new DefaultComboBoxModel(l));
|
||||
cbExpansionSet.insertItemAt("-- All sets -- ", 0);
|
||||
cbExpansionSet.setSelectedIndex(0);
|
||||
initFilter();
|
||||
if (this.cbExpansionSet.getSelectedItem() instanceof ExpansionSet) {
|
||||
filter.getExpansionSetCode().add(((ExpansionSet)this.cbExpansionSet.getSelectedItem()).getCode());
|
||||
}
|
||||
filterCards();
|
||||
}
|
||||
public void loadCards(BigCard bigCard) {
|
||||
this.bigCard = bigCard;
|
||||
this.btnBooster.setVisible(true);
|
||||
this.btnClear.setVisible(true);
|
||||
this.cbExpansionSet.setVisible(true);
|
||||
Object[] l = Sets.getInstance().values().toArray();
|
||||
Arrays.sort(l, new Comparator<Object>() {
|
||||
@Override
|
||||
public int compare(Object o1, Object o2) {
|
||||
return ((ExpansionSet)o1).getName().compareTo(((ExpansionSet)o2).getName());
|
||||
}
|
||||
});
|
||||
cbExpansionSet.setModel(new DefaultComboBoxModel(l));
|
||||
cbExpansionSet.insertItemAt("-- All sets -- ", 0);
|
||||
cbExpansionSet.setSelectedIndex(0);
|
||||
initFilter();
|
||||
if (this.cbExpansionSet.getSelectedItem() instanceof ExpansionSet) {
|
||||
filter.getExpansionSetCode().add(((ExpansionSet)this.cbExpansionSet.getSelectedItem()).getCode());
|
||||
}
|
||||
filterCards();
|
||||
}
|
||||
|
||||
private void initFilter() {
|
||||
filter.setUseColor(true);
|
||||
filter.getColor().setBlack(true);
|
||||
filter.getColor().setBlue(true);
|
||||
filter.getColor().setGreen(true);
|
||||
filter.getColor().setWhite(true);
|
||||
filter.getColor().setRed(true);
|
||||
filter.setColorless(true);
|
||||
filter.setUseColorless(true);
|
||||
filter.setNotColor(false);
|
||||
filter.setScopeColor(ComparisonScope.Any);
|
||||
filter.getCardType().add(CardType.LAND);
|
||||
filter.getCardType().add(CardType.ARTIFACT);
|
||||
filter.getCardType().add(CardType.CREATURE);
|
||||
filter.getCardType().add(CardType.ENCHANTMENT);
|
||||
filter.getCardType().add(CardType.INSTANT);
|
||||
filter.getCardType().add(CardType.PLANESWALKER);
|
||||
filter.getCardType().add(CardType.SORCERY);
|
||||
filter.setScopeCardType(ComparisonScope.Any);
|
||||
}
|
||||
private void initFilter() {
|
||||
filter.setUseColor(true);
|
||||
filter.getColor().setBlack(true);
|
||||
filter.getColor().setBlue(true);
|
||||
filter.getColor().setGreen(true);
|
||||
filter.getColor().setWhite(true);
|
||||
filter.getColor().setRed(true);
|
||||
filter.setColorless(true);
|
||||
filter.setUseColorless(true);
|
||||
filter.setNotColor(false);
|
||||
filter.setScopeColor(ComparisonScope.Any);
|
||||
filter.getCardType().add(CardType.LAND);
|
||||
filter.getCardType().add(CardType.ARTIFACT);
|
||||
filter.getCardType().add(CardType.CREATURE);
|
||||
filter.getCardType().add(CardType.ENCHANTMENT);
|
||||
filter.getCardType().add(CardType.INSTANT);
|
||||
filter.getCardType().add(CardType.PLANESWALKER);
|
||||
filter.getCardType().add(CardType.SORCERY);
|
||||
filter.setScopeCardType(ComparisonScope.Any);
|
||||
}
|
||||
|
||||
private void filterCards() {
|
||||
try {
|
||||
List<Card> filteredCards = new ArrayList<Card>();
|
||||
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||
if (!cards.isEmpty()) {
|
||||
for (Card card: cards) {
|
||||
if (filter.match(card, null))
|
||||
filteredCards.add(card);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (Card card: CardsStorage.getAllCards()) {
|
||||
if (filter.match(card, null))
|
||||
filteredCards.add(card);
|
||||
}
|
||||
}
|
||||
this.mainModel.loadCards(new CardsView(filteredCards), (SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected(), bigCard, null);
|
||||
}
|
||||
finally {
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
}
|
||||
private void filterCards() {
|
||||
try {
|
||||
List<Card> filteredCards = new ArrayList<Card>();
|
||||
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||
if (!cards.isEmpty()) {
|
||||
for (Card card: cards) {
|
||||
if (filter.match(card, null))
|
||||
filteredCards.add(card);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (Card card: CardsStorage.getAllCards()) {
|
||||
if (filter.match(card, null))
|
||||
filteredCards.add(card);
|
||||
}
|
||||
}
|
||||
this.mainModel.loadCards(new CardsView(filteredCards), (SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected(), bigCard, null);
|
||||
}
|
||||
finally {
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
}
|
||||
|
||||
public ICardGrid getCardsList() {
|
||||
return this.mainModel;
|
||||
}
|
||||
public ICardGrid getCardsList() {
|
||||
return this.mainModel;
|
||||
}
|
||||
|
||||
public void removeCard(UUID cardId) {
|
||||
this.mainModel.removeCard(cardId);
|
||||
for (Card card: cards) {
|
||||
if (card.getId().equals(cardId)) {
|
||||
cards.remove(card);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void removeCard(UUID cardId) {
|
||||
this.mainModel.removeCard(cardId);
|
||||
for (Card card: cards) {
|
||||
if (card.getId().equals(cardId)) {
|
||||
cards.remove(card);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Card getCard(UUID cardId) {
|
||||
if (!cards.isEmpty()) {
|
||||
for (Card card: cards) {
|
||||
if (card.getId().equals(cardId))
|
||||
return card;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (Card card: CardsStorage.getAllCards()) {
|
||||
if (card.getId().equals(cardId))
|
||||
return card;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public Card getCard(UUID cardId) {
|
||||
if (!cards.isEmpty()) {
|
||||
for (Card card: cards) {
|
||||
if (card.getId().equals(cardId))
|
||||
return card;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (Card card: CardsStorage.getAllCards()) {
|
||||
if (card.getId().equals(cardId))
|
||||
return card;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
|
||||
|
@ -219,13 +219,13 @@ public class CardTableSelector extends javax.swing.JPanel implements ComponentLi
|
|||
rdoPlaneswalkers = new javax.swing.JRadioButton();
|
||||
chkPiles = new javax.swing.JCheckBox();
|
||||
cbSortBy = new javax.swing.JComboBox();
|
||||
jTextFieldSearch = new javax.swing.JTextField();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
jButtonSearch = new javax.swing.JButton();
|
||||
jButtonClean = new javax.swing.JButton();
|
||||
jSeparator1 = new javax.swing.JSeparator();
|
||||
jButtonAddToMain = new javax.swing.JButton();
|
||||
jButtonAddToSideboard = new javax.swing.JButton();
|
||||
jTextFieldSearch = new javax.swing.JTextField();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
jButtonSearch = new javax.swing.JButton();
|
||||
jButtonClean = new javax.swing.JButton();
|
||||
jSeparator1 = new javax.swing.JSeparator();
|
||||
jButtonAddToMain = new javax.swing.JButton();
|
||||
jButtonAddToSideboard = new javax.swing.JButton();
|
||||
|
||||
tbColor.setFloatable(false);
|
||||
tbColor.setRollover(true);
|
||||
|
@ -331,24 +331,24 @@ public class CardTableSelector extends javax.swing.JPanel implements ComponentLi
|
|||
}
|
||||
});
|
||||
tbColor.add(btnClear);
|
||||
|
||||
|
||||
mainModel = new TableModel();
|
||||
mainModel.addListeners(mainTable);
|
||||
|
||||
mainModel.addListeners(mainTable);
|
||||
|
||||
mainTable.setModel(mainModel);
|
||||
mainTable.setForeground(Color.white);
|
||||
DefaultTableCellRenderer myRenderer = (DefaultTableCellRenderer) mainTable.getDefaultRenderer(String.class);
|
||||
myRenderer.setBackground(new Color(0, 0, 0, 100));
|
||||
mainTable.getColumnModel().getColumn(0).setMaxWidth(0);
|
||||
mainTable.getColumnModel().getColumn(0).setPreferredWidth(10);
|
||||
mainTable.getColumnModel().getColumn(1).setPreferredWidth(110);
|
||||
mainTable.getColumnModel().getColumn(2).setPreferredWidth(90);
|
||||
mainTable.getColumnModel().getColumn(3).setPreferredWidth(50);
|
||||
mainTable.getColumnModel().getColumn(4).setPreferredWidth(170);
|
||||
mainTable.getColumnModel().getColumn(5).setPreferredWidth(30);
|
||||
mainTable.getColumnModel().getColumn(6).setPreferredWidth(15);
|
||||
mainTable.getColumnModel().getColumn(7).setPreferredWidth(15);
|
||||
|
||||
mainTable.setForeground(Color.white);
|
||||
DefaultTableCellRenderer myRenderer = (DefaultTableCellRenderer) mainTable.getDefaultRenderer(String.class);
|
||||
myRenderer.setBackground(new Color(0, 0, 0, 100));
|
||||
mainTable.getColumnModel().getColumn(0).setMaxWidth(0);
|
||||
mainTable.getColumnModel().getColumn(0).setPreferredWidth(10);
|
||||
mainTable.getColumnModel().getColumn(1).setPreferredWidth(110);
|
||||
mainTable.getColumnModel().getColumn(2).setPreferredWidth(90);
|
||||
mainTable.getColumnModel().getColumn(3).setPreferredWidth(50);
|
||||
mainTable.getColumnModel().getColumn(4).setPreferredWidth(170);
|
||||
mainTable.getColumnModel().getColumn(5).setPreferredWidth(30);
|
||||
mainTable.getColumnModel().getColumn(6).setPreferredWidth(15);
|
||||
mainTable.getColumnModel().getColumn(7).setPreferredWidth(15);
|
||||
|
||||
jScrollPane1.setViewportView(mainTable);
|
||||
|
||||
tbTypes.setFloatable(false);
|
||||
|
@ -457,266 +457,266 @@ public class CardTableSelector extends javax.swing.JPanel implements ComponentLi
|
|||
});
|
||||
tbTypes.add(cbSortBy);
|
||||
|
||||
jLabel1.setText("Search (by name,in rules):");
|
||||
jLabel1.setText("Search (by name,in rules):");
|
||||
|
||||
jButtonSearch.setLabel("Search");
|
||||
jButtonSearch.setMaximumSize(new java.awt.Dimension(85, 23));
|
||||
jButtonSearch.setMinimumSize(new java.awt.Dimension(85, 23));
|
||||
jButtonSearch.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButtonSearchActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jButtonSearch.setLabel("Search");
|
||||
jButtonSearch.setMaximumSize(new java.awt.Dimension(85, 23));
|
||||
jButtonSearch.setMinimumSize(new java.awt.Dimension(85, 23));
|
||||
jButtonSearch.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButtonSearchActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jButtonClean.setText("Clear");
|
||||
jButtonClean.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButtonCleanActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jButtonClean.setText("Clear");
|
||||
jButtonClean.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButtonCleanActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
|
||||
jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
|
||||
|
||||
jButtonAddToMain.setLabel("Add to Main");
|
||||
jButtonAddToMain.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButtonAddToMainActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jButtonAddToMain.setLabel("Add to Main");
|
||||
jButtonAddToMain.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButtonAddToMainActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jButtonAddToSideboard.setLabel("Add to Sideboard");
|
||||
jButtonAddToSideboard.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButtonAddToSideboardActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jButtonAddToSideboard.setLabel("Add to Sideboard");
|
||||
jButtonAddToSideboard.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButtonAddToSideboardActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(tbColor, javax.swing.GroupLayout.DEFAULT_SIZE, 938, Short.MAX_VALUE)
|
||||
.addComponent(tbTypes, javax.swing.GroupLayout.DEFAULT_SIZE, 938, Short.MAX_VALUE)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 938, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jButtonAddToMain, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(jButtonAddToSideboard)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jLabel1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jTextFieldSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jButtonSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jButtonClean)
|
||||
.addContainerGap(322, Short.MAX_VALUE))
|
||||
);
|
||||
.addComponent(tbColor, javax.swing.GroupLayout.DEFAULT_SIZE, 938, Short.MAX_VALUE)
|
||||
.addComponent(tbTypes, javax.swing.GroupLayout.DEFAULT_SIZE, 938, Short.MAX_VALUE)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 938, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jButtonAddToMain, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(jButtonAddToSideboard)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jLabel1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jTextFieldSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jButtonSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jButtonClean)
|
||||
.addContainerGap(322, Short.MAX_VALUE))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(tbColor, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 0, 0)
|
||||
.addComponent(tbTypes, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jButtonAddToMain)
|
||||
.addComponent(jButtonAddToSideboard))
|
||||
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel1)
|
||||
.addComponent(jButtonSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jButtonClean)
|
||||
.addComponent(jTextFieldSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap())
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jButtonAddToMain)
|
||||
.addComponent(jButtonAddToSideboard))
|
||||
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel1)
|
||||
.addComponent(jButtonSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jButtonClean)
|
||||
.addComponent(jTextFieldSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
}
|
||||
|
||||
private void rdoGreenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoGreenActionPerformed
|
||||
filter.getColor().setGreen(this.rdoGreen.isSelected());
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoGreenActionPerformed
|
||||
private void rdoGreenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoGreenActionPerformed
|
||||
filter.getColor().setGreen(this.rdoGreen.isSelected());
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoGreenActionPerformed
|
||||
|
||||
private void rdoBlackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoBlackActionPerformed
|
||||
filter.getColor().setBlack(this.rdoBlack.isSelected());
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoBlackActionPerformed
|
||||
private void rdoBlackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoBlackActionPerformed
|
||||
filter.getColor().setBlack(this.rdoBlack.isSelected());
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoBlackActionPerformed
|
||||
|
||||
private void rdoWhiteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoWhiteActionPerformed
|
||||
filter.getColor().setWhite(this.rdoWhite.isSelected());
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoWhiteActionPerformed
|
||||
private void rdoWhiteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoWhiteActionPerformed
|
||||
filter.getColor().setWhite(this.rdoWhite.isSelected());
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoWhiteActionPerformed
|
||||
|
||||
private void rdoRedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoRedActionPerformed
|
||||
filter.getColor().setRed(this.rdoRed.isSelected());
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoRedActionPerformed
|
||||
private void rdoRedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoRedActionPerformed
|
||||
filter.getColor().setRed(this.rdoRed.isSelected());
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoRedActionPerformed
|
||||
|
||||
private void rdoBlueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoBlueActionPerformed
|
||||
filter.getColor().setBlue(this.rdoBlue.isSelected());
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoBlueActionPerformed
|
||||
private void rdoBlueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoBlueActionPerformed
|
||||
filter.getColor().setBlue(this.rdoBlue.isSelected());
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoBlueActionPerformed
|
||||
|
||||
private void rdoColorlessActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoColorlessActionPerformed
|
||||
filter.setColorless(this.rdoColorless.isSelected());
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoColorlessActionPerformed
|
||||
private void rdoColorlessActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoColorlessActionPerformed
|
||||
filter.setColorless(this.rdoColorless.isSelected());
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoColorlessActionPerformed
|
||||
|
||||
private void rdoLandActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoLandActionPerformed
|
||||
if (this.rdoLand.isSelected())
|
||||
filter.getCardType().add(CardType.LAND);
|
||||
else
|
||||
filter.getCardType().remove(CardType.LAND);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoLandActionPerformed
|
||||
private void rdoLandActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoLandActionPerformed
|
||||
if (this.rdoLand.isSelected())
|
||||
filter.getCardType().add(CardType.LAND);
|
||||
else
|
||||
filter.getCardType().remove(CardType.LAND);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoLandActionPerformed
|
||||
|
||||
private void rdoCreaturesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoCreaturesActionPerformed
|
||||
if (this.rdoCreatures.isSelected())
|
||||
filter.getCardType().add(CardType.CREATURE);
|
||||
else
|
||||
filter.getCardType().remove(CardType.CREATURE);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoCreaturesActionPerformed
|
||||
private void rdoCreaturesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoCreaturesActionPerformed
|
||||
if (this.rdoCreatures.isSelected())
|
||||
filter.getCardType().add(CardType.CREATURE);
|
||||
else
|
||||
filter.getCardType().remove(CardType.CREATURE);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoCreaturesActionPerformed
|
||||
|
||||
private void rdoArtifactsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoArtifactsActionPerformed
|
||||
if (this.rdoArtifacts.isSelected())
|
||||
filter.getCardType().add(CardType.ARTIFACT);
|
||||
else
|
||||
filter.getCardType().remove(CardType.ARTIFACT);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoArtifactsActionPerformed
|
||||
private void rdoArtifactsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoArtifactsActionPerformed
|
||||
if (this.rdoArtifacts.isSelected())
|
||||
filter.getCardType().add(CardType.ARTIFACT);
|
||||
else
|
||||
filter.getCardType().remove(CardType.ARTIFACT);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoArtifactsActionPerformed
|
||||
|
||||
private void rdoEnchantmentsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoEnchantmentsActionPerformed
|
||||
if (this.rdoEnchantments.isSelected())
|
||||
filter.getCardType().add(CardType.ENCHANTMENT);
|
||||
else
|
||||
filter.getCardType().remove(CardType.ENCHANTMENT);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoEnchantmentsActionPerformed
|
||||
private void rdoEnchantmentsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoEnchantmentsActionPerformed
|
||||
if (this.rdoEnchantments.isSelected())
|
||||
filter.getCardType().add(CardType.ENCHANTMENT);
|
||||
else
|
||||
filter.getCardType().remove(CardType.ENCHANTMENT);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoEnchantmentsActionPerformed
|
||||
|
||||
private void rdoInstantsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoInstantsActionPerformed
|
||||
if (this.rdoInstants.isSelected())
|
||||
filter.getCardType().add(CardType.INSTANT);
|
||||
else
|
||||
filter.getCardType().remove(CardType.INSTANT);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoInstantsActionPerformed
|
||||
private void rdoInstantsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoInstantsActionPerformed
|
||||
if (this.rdoInstants.isSelected())
|
||||
filter.getCardType().add(CardType.INSTANT);
|
||||
else
|
||||
filter.getCardType().remove(CardType.INSTANT);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoInstantsActionPerformed
|
||||
|
||||
private void rdoSorceriesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoSorceriesActionPerformed
|
||||
if (this.rdoSorceries.isSelected())
|
||||
filter.getCardType().add(CardType.SORCERY);
|
||||
else
|
||||
filter.getCardType().remove(CardType.SORCERY);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoSorceriesActionPerformed
|
||||
private void rdoSorceriesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoSorceriesActionPerformed
|
||||
if (this.rdoSorceries.isSelected())
|
||||
filter.getCardType().add(CardType.SORCERY);
|
||||
else
|
||||
filter.getCardType().remove(CardType.SORCERY);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoSorceriesActionPerformed
|
||||
|
||||
private void rdoPlaneswalkersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoPlaneswalkersActionPerformed
|
||||
if (this.rdoPlaneswalkers.isSelected())
|
||||
filter.getCardType().add(CardType.PLANESWALKER);
|
||||
else
|
||||
filter.getCardType().remove(CardType.PLANESWALKER);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoPlaneswalkersActionPerformed
|
||||
private void rdoPlaneswalkersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoPlaneswalkersActionPerformed
|
||||
if (this.rdoPlaneswalkers.isSelected())
|
||||
filter.getCardType().add(CardType.PLANESWALKER);
|
||||
else
|
||||
filter.getCardType().remove(CardType.PLANESWALKER);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_rdoPlaneswalkersActionPerformed
|
||||
|
||||
private void cbExpansionSetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbExpansionSetActionPerformed
|
||||
filter.getExpansionSetCode().clear();
|
||||
if (cbExpansionSet.getSelectedItem() instanceof ExpansionSet) {
|
||||
filter.getExpansionSetCode().add(((ExpansionSet)this.cbExpansionSet.getSelectedItem()).getCode());
|
||||
}
|
||||
filterCards();
|
||||
}//GEN-LAST:event_cbExpansionSetActionPerformed
|
||||
private void cbExpansionSetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbExpansionSetActionPerformed
|
||||
filter.getExpansionSetCode().clear();
|
||||
if (cbExpansionSet.getSelectedItem() instanceof ExpansionSet) {
|
||||
filter.getExpansionSetCode().add(((ExpansionSet)this.cbExpansionSet.getSelectedItem()).getCode());
|
||||
}
|
||||
filterCards();
|
||||
}//GEN-LAST:event_cbExpansionSetActionPerformed
|
||||
|
||||
private void btnClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClearActionPerformed
|
||||
cards.clear();
|
||||
filterCards();
|
||||
}//GEN-LAST:event_btnClearActionPerformed
|
||||
private void btnClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClearActionPerformed
|
||||
cards.clear();
|
||||
filterCards();
|
||||
}//GEN-LAST:event_btnClearActionPerformed
|
||||
|
||||
private void btnBoosterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBoosterActionPerformed
|
||||
if (this.cbExpansionSet.getSelectedItem() instanceof ExpansionSet) {
|
||||
List<Card> booster = ((ExpansionSet)this.cbExpansionSet.getSelectedItem()).createBooster();
|
||||
for (Card card: booster) {
|
||||
cards.add(card);
|
||||
}
|
||||
filterCards();
|
||||
}
|
||||
}//GEN-LAST:event_btnBoosterActionPerformed
|
||||
private void btnBoosterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBoosterActionPerformed
|
||||
if (this.cbExpansionSet.getSelectedItem() instanceof ExpansionSet) {
|
||||
List<Card> booster = ((ExpansionSet)this.cbExpansionSet.getSelectedItem()).createBooster();
|
||||
for (Card card: booster) {
|
||||
cards.add(card);
|
||||
}
|
||||
filterCards();
|
||||
}
|
||||
}//GEN-LAST:event_btnBoosterActionPerformed
|
||||
|
||||
private void cbSortByActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbSortByActionPerformed
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy)
|
||||
this.mainModel.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
}//GEN-LAST:event_cbSortByActionPerformed
|
||||
private void cbSortByActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbSortByActionPerformed
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy)
|
||||
this.mainModel.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
}//GEN-LAST:event_cbSortByActionPerformed
|
||||
|
||||
private void chkPilesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkPilesActionPerformed
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy)
|
||||
this.mainModel.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
}//GEN-LAST:event_chkPilesActionPerformed
|
||||
private void chkPilesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkPilesActionPerformed
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy)
|
||||
this.mainModel.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
}//GEN-LAST:event_chkPilesActionPerformed
|
||||
|
||||
private void jButtonAddToMainActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
|
||||
if (mainTable.getSelectedRowCount() > 0) {
|
||||
int[] n = mainTable.getSelectedRows();
|
||||
List<Integer> indexes = asList(n);
|
||||
Collections.reverse(indexes);
|
||||
for (Integer index : indexes) {
|
||||
mainModel.doubleClick(index);
|
||||
}
|
||||
if (!mode.equals(DeckEditorMode.Constructed))
|
||||
mainModel.fireTableDataChanged();
|
||||
}
|
||||
}//GEN-LAST:event_jButton3ActionPerformed
|
||||
private void jButtonAddToMainActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
|
||||
if (mainTable.getSelectedRowCount() > 0) {
|
||||
int[] n = mainTable.getSelectedRows();
|
||||
List<Integer> indexes = asList(n);
|
||||
Collections.reverse(indexes);
|
||||
for (Integer index : indexes) {
|
||||
mainModel.doubleClick(index);
|
||||
}
|
||||
if (!mode.equals(DeckEditorMode.Constructed))
|
||||
mainModel.fireTableDataChanged();
|
||||
}
|
||||
}//GEN-LAST:event_jButton3ActionPerformed
|
||||
|
||||
private void jButtonAddToSideboardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
|
||||
if (mainTable.getSelectedRowCount() > 0) {
|
||||
int[] n = mainTable.getSelectedRows();
|
||||
List<Integer> indexes = asList(n);
|
||||
Collections.reverse(indexes);
|
||||
for (Integer index : indexes) {
|
||||
mainModel.shiftDoubleClick(index);
|
||||
}
|
||||
if (!mode.equals(DeckEditorMode.Constructed))
|
||||
mainModel.fireTableDataChanged();
|
||||
}
|
||||
}//GEN-LAST:event_jButton4ActionPerformed
|
||||
private void jButtonAddToSideboardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
|
||||
if (mainTable.getSelectedRowCount() > 0) {
|
||||
int[] n = mainTable.getSelectedRows();
|
||||
List<Integer> indexes = asList(n);
|
||||
Collections.reverse(indexes);
|
||||
for (Integer index : indexes) {
|
||||
mainModel.shiftDoubleClick(index);
|
||||
}
|
||||
if (!mode.equals(DeckEditorMode.Constructed))
|
||||
mainModel.fireTableDataChanged();
|
||||
}
|
||||
}//GEN-LAST:event_jButton4ActionPerformed
|
||||
|
||||
public List<Integer> asList(final int[] is) {
|
||||
public List<Integer> asList(final int[] is) {
|
||||
List<Integer> list = new ArrayList<Integer>();
|
||||
for (int i : is) list.add(i);
|
||||
return list;
|
||||
for (int i : is) list.add(i);
|
||||
return list;
|
||||
}
|
||||
|
||||
private void jButtonSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
||||
String name = jTextFieldSearch.getText().trim();
|
||||
filter.setText(name);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_jButton1ActionPerformed
|
||||
private void jButtonSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
|
||||
String name = jTextFieldSearch.getText().trim();
|
||||
filter.setText(name);
|
||||
filterCards();
|
||||
}//GEN-LAST:event_jButton1ActionPerformed
|
||||
|
||||
private void jButtonCleanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
|
||||
jTextFieldSearch.setText("");
|
||||
filter.setText("");
|
||||
filterCards();
|
||||
}//GEN-LAST:event_jButton2ActionPerformed
|
||||
private void jButtonCleanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
|
||||
jTextFieldSearch.setText("");
|
||||
filter.setText("");
|
||||
filterCards();
|
||||
}//GEN-LAST:event_jButton2ActionPerformed
|
||||
|
||||
private TableModel mainModel;
|
||||
|
||||
private javax.swing.JButton btnBooster;
|
||||
private javax.swing.JButton btnClear;
|
||||
private JTable mainTable = new JTable();
|
||||
private javax.swing.JComboBox cbExpansionSet;
|
||||
private javax.swing.JComboBox cbExpansionSet;
|
||||
private javax.swing.JComboBox cbSortBy;
|
||||
private javax.swing.JCheckBox chkPiles;
|
||||
private javax.swing.JButton jButtonSearch;
|
||||
private javax.swing.JButton jButtonClean;
|
||||
private javax.swing.JButton jButtonAddToMain;
|
||||
private javax.swing.JButton jButtonAddToSideboard;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JSeparator jSeparator1;
|
||||
private javax.swing.JTextField jTextFieldSearch;
|
||||
private javax.swing.JButton jButtonSearch;
|
||||
private javax.swing.JButton jButtonClean;
|
||||
private javax.swing.JButton jButtonAddToMain;
|
||||
private javax.swing.JButton jButtonAddToSideboard;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JSeparator jSeparator1;
|
||||
private javax.swing.JTextField jTextFieldSearch;
|
||||
private javax.swing.JRadioButton rdoArtifacts;
|
||||
private javax.swing.JRadioButton rdoBlack;
|
||||
private javax.swing.JRadioButton rdoBlue;
|
||||
|
@ -733,31 +733,31 @@ public class CardTableSelector extends javax.swing.JPanel implements ComponentLi
|
|||
private javax.swing.JToolBar tbColor;
|
||||
private javax.swing.JToolBar tbTypes;
|
||||
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy)
|
||||
this.mainModel.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
}
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy)
|
||||
this.mainModel.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentMoved(ComponentEvent e) {
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy)
|
||||
this.mainModel.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
}
|
||||
@Override
|
||||
public void componentMoved(ComponentEvent e) {
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy)
|
||||
this.mainModel.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentShown(ComponentEvent e) {
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy)
|
||||
this.mainModel.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
}
|
||||
@Override
|
||||
public void componentShown(ComponentEvent e) {
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy)
|
||||
this.mainModel.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentHidden(ComponentEvent e) {
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy)
|
||||
this.mainModel.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
}
|
||||
@Override
|
||||
public void componentHidden(ComponentEvent e) {
|
||||
if (cbSortBy.getSelectedItem() instanceof SortBy)
|
||||
this.mainModel.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
|
||||
}
|
||||
|
||||
public void setMode(DeckEditorMode mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
public void setMode(DeckEditorMode mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,64 +38,64 @@ import mage.view.CardView;
|
|||
* @author nantuko
|
||||
*/
|
||||
public class MageCardComparator implements Comparator<CardView> {
|
||||
private final int column;
|
||||
private boolean ascending;
|
||||
private final int column;
|
||||
private boolean ascending;
|
||||
|
||||
public MageCardComparator(int column, boolean ascending) {
|
||||
this.column = column;
|
||||
this.ascending = ascending;
|
||||
}
|
||||
public MageCardComparator(int column, boolean ascending) {
|
||||
this.column = column;
|
||||
this.ascending = ascending;
|
||||
}
|
||||
|
||||
public int compare(CardView a, CardView b) {
|
||||
Comparable aCom = null;
|
||||
Comparable bCom = null;
|
||||
public int compare(CardView a, CardView b) {
|
||||
Comparable aCom = null;
|
||||
Comparable bCom = null;
|
||||
|
||||
if (column == 0)// #skip
|
||||
{
|
||||
aCom = Integer.valueOf(1);
|
||||
bCom = Integer.valueOf(1);
|
||||
} else if (column == 1)// Name
|
||||
{
|
||||
aCom = a.getName();
|
||||
bCom = b.getName();
|
||||
if (aCom.equals(bCom) && a.getExpansionSetCode().equals(b.getExpansionSetCode())) {
|
||||
aCom = a.getCardNumber();
|
||||
bCom = b.getCardNumber();
|
||||
}
|
||||
} else if (column == 2)// Cost
|
||||
{
|
||||
aCom = a.getConvertedManaCost();
|
||||
bCom = b.getConvertedManaCost();
|
||||
} else if (column == 3)// Color
|
||||
{
|
||||
aCom = CardHelper.getColor(a);
|
||||
bCom = CardHelper.getColor(b);
|
||||
} else if (column == 4)// Type
|
||||
{
|
||||
aCom = CardHelper.getType(a);
|
||||
bCom = CardHelper.getType(b);
|
||||
} else if (column == 5)// Stats, attack and defense
|
||||
{
|
||||
aCom = new Float(-1);
|
||||
bCom = new Float(-1);
|
||||
if (column == 0)// #skip
|
||||
{
|
||||
aCom = Integer.valueOf(1);
|
||||
bCom = Integer.valueOf(1);
|
||||
} else if (column == 1)// Name
|
||||
{
|
||||
aCom = a.getName();
|
||||
bCom = b.getName();
|
||||
if (aCom.equals(bCom) && a.getExpansionSetCode().equals(b.getExpansionSetCode())) {
|
||||
aCom = a.getCardNumber();
|
||||
bCom = b.getCardNumber();
|
||||
}
|
||||
} else if (column == 2)// Cost
|
||||
{
|
||||
aCom = a.getConvertedManaCost();
|
||||
bCom = b.getConvertedManaCost();
|
||||
} else if (column == 3)// Color
|
||||
{
|
||||
aCom = CardHelper.getColor(a);
|
||||
bCom = CardHelper.getColor(b);
|
||||
} else if (column == 4)// Type
|
||||
{
|
||||
aCom = CardHelper.getType(a);
|
||||
bCom = CardHelper.getType(b);
|
||||
} else if (column == 5)// Stats, attack and defense
|
||||
{
|
||||
aCom = new Float(-1);
|
||||
bCom = new Float(-1);
|
||||
|
||||
if (CardHelper.isCreature(a))
|
||||
aCom = new Float(a.getPower() + "." + a.getToughness());
|
||||
if (CardHelper.isCreature(b))
|
||||
bCom = new Float(b.getPower() + "." + b.getToughness());
|
||||
} else if (column == 6)// Rarity
|
||||
{
|
||||
aCom = a.getRarity().toString();
|
||||
bCom = b.getRarity().toString();
|
||||
} else if (column == 7)// Set name
|
||||
{
|
||||
aCom = a.getExpansionSetCode();
|
||||
bCom = b.getExpansionSetCode();
|
||||
}
|
||||
if (CardHelper.isCreature(a))
|
||||
aCom = new Float(a.getPower() + "." + a.getToughness());
|
||||
if (CardHelper.isCreature(b))
|
||||
bCom = new Float(b.getPower() + "." + b.getToughness());
|
||||
} else if (column == 6)// Rarity
|
||||
{
|
||||
aCom = a.getRarity().toString();
|
||||
bCom = b.getRarity().toString();
|
||||
} else if (column == 7)// Set name
|
||||
{
|
||||
aCom = a.getExpansionSetCode();
|
||||
bCom = b.getExpansionSetCode();
|
||||
}
|
||||
|
||||
if (ascending)
|
||||
return aCom.compareTo(bCom);
|
||||
else
|
||||
return bCom.compareTo(aCom);
|
||||
}// compare()
|
||||
if (ascending)
|
||||
return aCom.compareTo(bCom);
|
||||
else
|
||||
return bCom.compareTo(aCom);
|
||||
}// compare()
|
||||
}
|
||||
|
|
|
@ -62,220 +62,220 @@ import java.util.Map.Entry;
|
|||
*/
|
||||
public class TableModel extends AbstractTableModel implements ICardGrid {
|
||||
|
||||
private static final long serialVersionUID = -528008802935423088L;
|
||||
private static final long serialVersionUID = -528008802935423088L;
|
||||
|
||||
private static final Logger log = Logger.getLogger(TableModel.class);
|
||||
private static final Logger log = Logger.getLogger(TableModel.class);
|
||||
|
||||
protected CardEventSource cardEventSource = new CardEventSource();
|
||||
protected BigCard bigCard;
|
||||
protected UUID gameId;
|
||||
private Map<UUID, CardView> cards = new LinkedHashMap<UUID, CardView>();
|
||||
private Map<String, Integer> cardsNoCopies = new LinkedHashMap<String, Integer>();
|
||||
private List<CardView> view = new ArrayList<CardView>();
|
||||
private Dimension cardDimension;
|
||||
protected CardEventSource cardEventSource = new CardEventSource();
|
||||
protected BigCard bigCard;
|
||||
protected UUID gameId;
|
||||
private Map<UUID, CardView> cards = new LinkedHashMap<UUID, CardView>();
|
||||
private Map<String, Integer> cardsNoCopies = new LinkedHashMap<String, Integer>();
|
||||
private List<CardView> view = new ArrayList<CardView>();
|
||||
private Dimension cardDimension;
|
||||
|
||||
private boolean displayNoCopies = false;
|
||||
private UpdateCountsCallback updateCountsCallback;
|
||||
private boolean displayNoCopies = false;
|
||||
private UpdateCountsCallback updateCountsCallback;
|
||||
|
||||
private String column[] = { "", "Name", "Cost", "Color", "Type", "Stats", "Rarity", "Set" };
|
||||
private String column[] = { "", "Name", "Cost", "Color", "Type", "Stats", "Rarity", "Set" };
|
||||
|
||||
private int recentSortedColumn;
|
||||
private boolean recentAscending;
|
||||
private int recentSortedColumn;
|
||||
private boolean recentAscending;
|
||||
|
||||
@Override
|
||||
public void loadCards(CardsView showCards, SortBy sortBy, boolean piles, BigCard bigCard, UUID gameId) {
|
||||
this.bigCard = bigCard;
|
||||
this.gameId = gameId;
|
||||
int landCount = 0;
|
||||
int creatureCount = 0;
|
||||
for (CardView card : showCards.values()) {
|
||||
if (!cards.containsKey(card.getId())) {
|
||||
addCard(card, bigCard, gameId);
|
||||
}
|
||||
if (updateCountsCallback != null) {
|
||||
if (card.getCardTypes().contains(Constants.CardType.LAND))
|
||||
landCount++;
|
||||
if (card.getCardTypes().contains(Constants.CardType.CREATURE))
|
||||
creatureCount++;
|
||||
}
|
||||
}
|
||||
// not easy logic for merge :)
|
||||
for (Iterator<Entry<UUID, CardView>> i = cards.entrySet().iterator(); i.hasNext();) {
|
||||
Entry<UUID, CardView> entry = i.next();
|
||||
if (!showCards.containsKey(entry.getKey())) {
|
||||
i.remove();
|
||||
if (displayNoCopies) {
|
||||
String key = entry.getValue().getName() + entry.getValue().getExpansionSetCode() + entry.getValue().getCardNumber();
|
||||
if (cardsNoCopies.containsKey(key)) {
|
||||
Integer count = cardsNoCopies.get(key);
|
||||
count--;
|
||||
if (count > 0) {
|
||||
cardsNoCopies.put(key, count);
|
||||
} else {
|
||||
cardsNoCopies.remove(key);
|
||||
}
|
||||
for (int j = 0; j < view.size(); j++) {
|
||||
CardView cv = view.get(j);
|
||||
if (cv.getId().equals(entry.getKey())) {
|
||||
if (count > 0) {
|
||||
// replace by another card with the same name+setCode
|
||||
String key1 = cv.getName()+cv.getExpansionSetCode();
|
||||
for (CardView cardView : cards.values()) {
|
||||
String key2 = cardView.getName()+cardView.getExpansionSetCode();
|
||||
if ((key1).equals(key2)) {
|
||||
view.set(j, cardView);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
view.remove(j);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (CardView cv : view) {
|
||||
if (cv.getId().equals(entry.getKey())) {
|
||||
view.remove(cv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void loadCards(CardsView showCards, SortBy sortBy, boolean piles, BigCard bigCard, UUID gameId) {
|
||||
this.bigCard = bigCard;
|
||||
this.gameId = gameId;
|
||||
int landCount = 0;
|
||||
int creatureCount = 0;
|
||||
for (CardView card : showCards.values()) {
|
||||
if (!cards.containsKey(card.getId())) {
|
||||
addCard(card, bigCard, gameId);
|
||||
}
|
||||
if (updateCountsCallback != null) {
|
||||
if (card.getCardTypes().contains(Constants.CardType.LAND))
|
||||
landCount++;
|
||||
if (card.getCardTypes().contains(Constants.CardType.CREATURE))
|
||||
creatureCount++;
|
||||
}
|
||||
}
|
||||
// not easy logic for merge :)
|
||||
for (Iterator<Entry<UUID, CardView>> i = cards.entrySet().iterator(); i.hasNext();) {
|
||||
Entry<UUID, CardView> entry = i.next();
|
||||
if (!showCards.containsKey(entry.getKey())) {
|
||||
i.remove();
|
||||
if (displayNoCopies) {
|
||||
String key = entry.getValue().getName() + entry.getValue().getExpansionSetCode() + entry.getValue().getCardNumber();
|
||||
if (cardsNoCopies.containsKey(key)) {
|
||||
Integer count = cardsNoCopies.get(key);
|
||||
count--;
|
||||
if (count > 0) {
|
||||
cardsNoCopies.put(key, count);
|
||||
} else {
|
||||
cardsNoCopies.remove(key);
|
||||
}
|
||||
for (int j = 0; j < view.size(); j++) {
|
||||
CardView cv = view.get(j);
|
||||
if (cv.getId().equals(entry.getKey())) {
|
||||
if (count > 0) {
|
||||
// replace by another card with the same name+setCode
|
||||
String key1 = cv.getName()+cv.getExpansionSetCode();
|
||||
for (CardView cardView : cards.values()) {
|
||||
String key2 = cardView.getName()+cardView.getExpansionSetCode();
|
||||
if ((key1).equals(key2)) {
|
||||
view.set(j, cardView);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
view.remove(j);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (CardView cv : view) {
|
||||
if (cv.getId().equals(entry.getKey())) {
|
||||
view.remove(cv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (updateCountsCallback != null) {
|
||||
updateCountsCallback.update(cards.size(), creatureCount, landCount);
|
||||
}
|
||||
if (updateCountsCallback != null) {
|
||||
updateCountsCallback.update(cards.size(), creatureCount, landCount);
|
||||
}
|
||||
|
||||
sort(1, true);
|
||||
drawCards(sortBy, piles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
view.clear();
|
||||
cards.clear();
|
||||
}
|
||||
sort(1, true);
|
||||
drawCards(sortBy, piles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return view.size();
|
||||
}
|
||||
public void refresh() {
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
view.clear();
|
||||
cards.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return column.length;
|
||||
}
|
||||
public int getRowCount() {
|
||||
return view.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnName(int n) {
|
||||
return column[n];
|
||||
}
|
||||
public int getColumnCount() {
|
||||
return column.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int row, int column) {
|
||||
return getColumn(view.get(row), column);
|
||||
}
|
||||
|
||||
private Object getColumn(Object obj, int column) {
|
||||
CardView c = (CardView) obj;
|
||||
switch (column) {
|
||||
case 0:
|
||||
if (displayNoCopies) {
|
||||
String key = c.getName() + c.getExpansionSetCode() + c.getCardNumber();
|
||||
Integer count = cardsNoCopies.get(key);
|
||||
return count != null ? count : "";
|
||||
}
|
||||
return "";
|
||||
case 1:
|
||||
return c.getName();
|
||||
case 2:
|
||||
StringBuilder s = new StringBuilder();
|
||||
for (String cost : c.getManaCost()) {
|
||||
s.append(cost);
|
||||
}
|
||||
String cost = s.toString();
|
||||
if (cost.isEmpty()) {
|
||||
return "0";
|
||||
}
|
||||
return cost;
|
||||
case 3:
|
||||
return CardHelper.getColor(c);
|
||||
case 4:
|
||||
return CardHelper.getType(c);
|
||||
case 5:
|
||||
return CardHelper.isCreature(c) ? c.getPower() + "/"
|
||||
+ c.getToughness() : "-";
|
||||
case 6:
|
||||
return c.getRarity().toString();
|
||||
case 7:
|
||||
return c.getExpansionSetCode();
|
||||
default:
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId) {
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth,
|
||||
Config.dimensions.frameHeight);
|
||||
}
|
||||
cards.put(card.getId(), card);
|
||||
|
||||
if (displayNoCopies) {
|
||||
String key = card.getName()+card.getExpansionSetCode()+card.getCardNumber();
|
||||
Integer count = 1;
|
||||
if (cardsNoCopies.containsKey(key)) {
|
||||
count = cardsNoCopies.get(key) + 1;
|
||||
} else {
|
||||
view.add(card);
|
||||
}
|
||||
cardsNoCopies.put(key, count);
|
||||
} else {
|
||||
view.add(card);
|
||||
}
|
||||
}
|
||||
public String getColumnName(int n) {
|
||||
return column[n];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawCards(SortBy sortBy, boolean piles) {
|
||||
fireTableDataChanged();
|
||||
}
|
||||
public Object getValueAt(int row, int column) {
|
||||
return getColumn(view.get(row), column);
|
||||
}
|
||||
|
||||
public void removeCard(UUID cardId) {
|
||||
cards.remove(cardId);
|
||||
for (CardView cv : view) {
|
||||
if (cv.getId().equals(cardId)) {
|
||||
view.remove(cv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
private Object getColumn(Object obj, int column) {
|
||||
CardView c = (CardView) obj;
|
||||
switch (column) {
|
||||
case 0:
|
||||
if (displayNoCopies) {
|
||||
String key = c.getName() + c.getExpansionSetCode() + c.getCardNumber();
|
||||
Integer count = cardsNoCopies.get(key);
|
||||
return count != null ? count : "";
|
||||
}
|
||||
return "";
|
||||
case 1:
|
||||
return c.getName();
|
||||
case 2:
|
||||
StringBuilder s = new StringBuilder();
|
||||
for (String cost : c.getManaCost()) {
|
||||
s.append(cost);
|
||||
}
|
||||
String cost = s.toString();
|
||||
if (cost.isEmpty()) {
|
||||
return "0";
|
||||
}
|
||||
return cost;
|
||||
case 3:
|
||||
return CardHelper.getColor(c);
|
||||
case 4:
|
||||
return CardHelper.getType(c);
|
||||
case 5:
|
||||
return CardHelper.isCreature(c) ? c.getPower() + "/"
|
||||
+ c.getToughness() : "-";
|
||||
case 6:
|
||||
return c.getRarity().toString();
|
||||
case 7:
|
||||
return c.getExpansionSetCode();
|
||||
default:
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId) {
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth,
|
||||
Config.dimensions.frameHeight);
|
||||
}
|
||||
cards.put(card.getId(), card);
|
||||
|
||||
if (displayNoCopies) {
|
||||
String key = card.getName()+card.getExpansionSetCode()+card.getCardNumber();
|
||||
Integer count = 1;
|
||||
if (cardsNoCopies.containsKey(key)) {
|
||||
count = cardsNoCopies.get(key) + 1;
|
||||
} else {
|
||||
view.add(card);
|
||||
}
|
||||
cardsNoCopies.put(key, count);
|
||||
} else {
|
||||
view.add(card);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCardEventListener(Listener<Event> listener) {
|
||||
cardEventSource.addListener(listener);
|
||||
}
|
||||
public void drawCards(SortBy sortBy, boolean piles) {
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
public void removeCard(UUID cardId) {
|
||||
cards.remove(cardId);
|
||||
for (CardView cv : view) {
|
||||
if (cv.getId().equals(cardId)) {
|
||||
view.remove(cv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearCardEventListeners() {
|
||||
cardEventSource.clearListeners();
|
||||
}
|
||||
public void addCardEventListener(Listener<Event> listener) {
|
||||
cardEventSource.addListener(listener);
|
||||
}
|
||||
|
||||
public void doubleClick(int index) {
|
||||
CardView card = view.get(index);
|
||||
cardEventSource.doubleClick(card.getId(), "double-click");
|
||||
}
|
||||
@Override
|
||||
public void clearCardEventListeners() {
|
||||
cardEventSource.clearListeners();
|
||||
}
|
||||
|
||||
public void shiftDoubleClick(int index) {
|
||||
CardView card = view.get(index);
|
||||
cardEventSource.shiftDoubleClick(card.getId(), "shift-double-click");
|
||||
}
|
||||
public void doubleClick(int index) {
|
||||
CardView card = view.get(index);
|
||||
cardEventSource.doubleClick(card.getId(), "double-click");
|
||||
}
|
||||
|
||||
public void shiftDoubleClick(int index) {
|
||||
CardView card = view.get(index);
|
||||
cardEventSource.shiftDoubleClick(card.getId(), "shift-double-click");
|
||||
}
|
||||
|
||||
public void removeFromMainEvent(int index) {
|
||||
cardEventSource.removeFromMainEvent("remove-main");
|
||||
|
@ -285,103 +285,103 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
|
|||
cardEventSource.removeFromSideboardEvent("remove-sideboard");
|
||||
}
|
||||
|
||||
public void addListeners(final JTable table) {
|
||||
// updates card detail, listens to any key strokes
|
||||
public void addListeners(final JTable table) {
|
||||
// updates card detail, listens to any key strokes
|
||||
|
||||
table.addKeyListener(new KeyListener() {
|
||||
table.addKeyListener(new KeyListener() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent ev) {}
|
||||
public void keyPressed(KeyEvent ev) {}
|
||||
@Override
|
||||
public void keyTyped(KeyEvent ev) {}
|
||||
public void keyTyped(KeyEvent ev) {}
|
||||
@Override
|
||||
public void keyReleased(KeyEvent ev) {
|
||||
int row = table.getSelectedRow();
|
||||
if (row != -1) {
|
||||
showImage(row);
|
||||
}
|
||||
}
|
||||
});
|
||||
public void keyReleased(KeyEvent ev) {
|
||||
int row = table.getSelectedRow();
|
||||
if (row != -1) {
|
||||
showImage(row);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// updates card detail, listens to any mouse clicks
|
||||
table.addMouseListener(new MouseAdapter() {
|
||||
// updates card detail, listens to any mouse clicks
|
||||
table.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
int row = table.getSelectedRow();
|
||||
if (row != -1) {
|
||||
showImage(row);
|
||||
}
|
||||
}
|
||||
});
|
||||
public void mousePressed(MouseEvent e) {
|
||||
int row = table.getSelectedRow();
|
||||
if (row != -1) {
|
||||
showImage(row);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// sorts
|
||||
MouseListener mouse = new MouseAdapter() {
|
||||
// sorts
|
||||
MouseListener mouse = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
TableColumnModel columnModel = table.getColumnModel();
|
||||
int viewColumn = columnModel.getColumnIndexAtX(e.getX());
|
||||
int column = table.convertColumnIndexToModel(viewColumn);
|
||||
public void mousePressed(MouseEvent e) {
|
||||
TableColumnModel columnModel = table.getColumnModel();
|
||||
int viewColumn = columnModel.getColumnIndexAtX(e.getX());
|
||||
int column = table.convertColumnIndexToModel(viewColumn);
|
||||
|
||||
if (column != -1) {
|
||||
// sort ascending
|
||||
boolean asc = true;
|
||||
if (recentSortedColumn == column) {
|
||||
asc = !recentAscending;
|
||||
}
|
||||
sort(column, asc);
|
||||
fireTableDataChanged();
|
||||
}
|
||||
}
|
||||
};
|
||||
table.getTableHeader().addMouseListener(mouse);
|
||||
}
|
||||
if (column != -1) {
|
||||
// sort ascending
|
||||
boolean asc = true;
|
||||
if (recentSortedColumn == column) {
|
||||
asc = !recentAscending;
|
||||
}
|
||||
sort(column, asc);
|
||||
fireTableDataChanged();
|
||||
}
|
||||
}
|
||||
};
|
||||
table.getTableHeader().addMouseListener(mouse);
|
||||
}
|
||||
|
||||
private void showImage(int row) {
|
||||
CardView card = view.get(row);
|
||||
if (!card.getId().equals(bigCard.getCardId())) {
|
||||
if (!MageFrame.isLite()) {
|
||||
Image image = Plugins.getInstance().getOriginalImage(card);
|
||||
if (image != null && image instanceof BufferedImage) {
|
||||
// XXX: scaled to fit width
|
||||
image = ImageHelper.getResizedImage((BufferedImage) image, bigCard.getWidth());
|
||||
bigCard.setCard(card.getId(), image, new ArrayList<String>(), false);
|
||||
} else {
|
||||
drawCardText(card);
|
||||
}
|
||||
} else {
|
||||
drawCardText(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void showImage(int row) {
|
||||
CardView card = view.get(row);
|
||||
if (!card.getId().equals(bigCard.getCardId())) {
|
||||
if (!MageFrame.isLite()) {
|
||||
Image image = Plugins.getInstance().getOriginalImage(card);
|
||||
if (image != null && image instanceof BufferedImage) {
|
||||
// XXX: scaled to fit width
|
||||
image = ImageHelper.getResizedImage((BufferedImage) image, bigCard.getWidth());
|
||||
bigCard.setCard(card.getId(), image, new ArrayList<String>(), false);
|
||||
} else {
|
||||
drawCardText(card);
|
||||
}
|
||||
} else {
|
||||
drawCardText(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void drawCardText(CardView card) {
|
||||
JXPanel panel = GuiDisplayUtil.getDescription(card, bigCard.getWidth(), bigCard.getHeight());
|
||||
panel.setVisible(true);
|
||||
bigCard.hideTextComponent();
|
||||
bigCard.addJXPanel(card.getId(), panel);
|
||||
}
|
||||
|
||||
public List<CardView> getCardsView() {
|
||||
return view;
|
||||
}
|
||||
private void drawCardText(CardView card) {
|
||||
JXPanel panel = GuiDisplayUtil.getDescription(card, bigCard.getWidth(), bigCard.getHeight());
|
||||
panel.setVisible(true);
|
||||
bigCard.hideTextComponent();
|
||||
bigCard.addJXPanel(card.getId(), panel);
|
||||
}
|
||||
|
||||
public boolean sort(int column, boolean ascending) {
|
||||
// used by addCard() to resort the cards
|
||||
recentSortedColumn = column;
|
||||
recentAscending = ascending;
|
||||
public List<CardView> getCardsView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
MageCardComparator sorter = new MageCardComparator(column, ascending);
|
||||
Collections.sort(view, sorter);
|
||||
public boolean sort(int column, boolean ascending) {
|
||||
// used by addCard() to resort the cards
|
||||
recentSortedColumn = column;
|
||||
recentAscending = ascending;
|
||||
|
||||
fireTableDataChanged();
|
||||
MageCardComparator sorter = new MageCardComparator(column, ascending);
|
||||
Collections.sort(view, sorter);
|
||||
|
||||
return true;
|
||||
}
|
||||
fireTableDataChanged();
|
||||
|
||||
public void setDisplayNoCopies(boolean value) {
|
||||
this.displayNoCopies = value;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setUpdateCountsCallback(UpdateCountsCallback callback) {
|
||||
this.updateCountsCallback = callback;
|
||||
}
|
||||
public void setDisplayNoCopies(boolean value) {
|
||||
this.displayNoCopies = value;
|
||||
}
|
||||
|
||||
public void setUpdateCountsCallback(UpdateCountsCallback callback) {
|
||||
this.updateCountsCallback = callback;
|
||||
}
|
||||
}
|
|
@ -8,19 +8,19 @@ import javax.swing.*;
|
|||
*/
|
||||
public class UpdateCountsCallback {
|
||||
|
||||
private javax.swing.JLabel lblCount;
|
||||
private javax.swing.JLabel lblCount;
|
||||
private javax.swing.JLabel lblCreatureCount;
|
||||
private javax.swing.JLabel lblLandCount;
|
||||
|
||||
public UpdateCountsCallback(JLabel count, JLabel creatures, JLabel lands) {
|
||||
this.lblCount = count;
|
||||
this.lblCreatureCount = creatures;
|
||||
this.lblLandCount = lands;
|
||||
}
|
||||
public UpdateCountsCallback(JLabel count, JLabel creatures, JLabel lands) {
|
||||
this.lblCount = count;
|
||||
this.lblCreatureCount = creatures;
|
||||
this.lblLandCount = lands;
|
||||
}
|
||||
|
||||
public void update(int count, int creatures, int lands) {
|
||||
this.lblCount.setText("Count: " + Integer.toString(count));
|
||||
this.lblCreatureCount.setText("Creatures: " + Integer.toString(creatures));
|
||||
this.lblLandCount.setText("Lands: " + Integer.toString(lands));
|
||||
}
|
||||
public void update(int count, int creatures, int lands) {
|
||||
this.lblCount.setText("Count: " + Integer.toString(count));
|
||||
this.lblCreatureCount.setText("Creatures: " + Integer.toString(creatures));
|
||||
this.lblLandCount.setText("Lands: " + Integer.toString(lands));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,14 +45,14 @@ public class AboutDialog extends MageDialog {
|
|||
/** Creates new form AboutDialog */
|
||||
public AboutDialog() {
|
||||
initComponents();
|
||||
this.modal = false;
|
||||
this.modal = false;
|
||||
}
|
||||
|
||||
public void showDialog(MageVersion version) {
|
||||
this.lblVersion.setText(version.toString());
|
||||
this.setLocation(100, 100);
|
||||
this.setVisible(true);
|
||||
}
|
||||
public void showDialog(MageVersion version) {
|
||||
this.lblVersion.setText(version.toString());
|
||||
this.setLocation(100, 100);
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
@ -127,9 +127,9 @@ public class AboutDialog extends MageDialog {
|
|||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnOkActionPerformed
|
||||
private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnOkActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton btnOk;
|
||||
|
|
|
@ -45,19 +45,19 @@ import mage.sets.Sets;
|
|||
*/
|
||||
public class AddLandDialog extends MageDialog {
|
||||
|
||||
private Deck deck;
|
||||
private Deck deck;
|
||||
|
||||
/** Creates new form AddLandDialog */
|
||||
public AddLandDialog() {
|
||||
initComponents();
|
||||
this.setModal(true);
|
||||
this.setModal(true);
|
||||
}
|
||||
|
||||
public void showDialog(Deck deck) {
|
||||
this.deck = deck;
|
||||
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
||||
this.setVisible(true);
|
||||
}
|
||||
public void showDialog(Deck deck) {
|
||||
this.deck = deck;
|
||||
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
@ -188,33 +188,33 @@ public class AddLandDialog extends MageDialog {
|
|||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnCancelActionPerformed
|
||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnCancelActionPerformed
|
||||
|
||||
private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddActionPerformed
|
||||
int nForest = ((Number)spnForest.getValue()).intValue();
|
||||
for (int i = 0; i < nForest; i++) {
|
||||
deck.getCards().add(Sets.findCard("Forest", true));
|
||||
}
|
||||
int nIsland = ((Number)spnIsland.getValue()).intValue();
|
||||
for (int i = 0; i < nIsland; i++) {
|
||||
deck.getCards().add(Sets.findCard("Island", true));
|
||||
}
|
||||
int nMountain = ((Number)spnMountain.getValue()).intValue();
|
||||
for (int i = 0; i < nMountain; i++) {
|
||||
deck.getCards().add(Sets.findCard("Mountain", true));
|
||||
}
|
||||
int nPlains = ((Number)spnPlains.getValue()).intValue();
|
||||
for (int i = 0; i < nPlains; i++) {
|
||||
deck.getCards().add(Sets.findCard("Plains", true));
|
||||
}
|
||||
int nSwamp = ((Number)spnSwamp.getValue()).intValue();
|
||||
for (int i = 0; i < nSwamp; i++) {
|
||||
deck.getCards().add(Sets.findCard("Swamp", true));
|
||||
}
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnAddActionPerformed
|
||||
private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddActionPerformed
|
||||
int nForest = ((Number)spnForest.getValue()).intValue();
|
||||
for (int i = 0; i < nForest; i++) {
|
||||
deck.getCards().add(Sets.findCard("Forest", true));
|
||||
}
|
||||
int nIsland = ((Number)spnIsland.getValue()).intValue();
|
||||
for (int i = 0; i < nIsland; i++) {
|
||||
deck.getCards().add(Sets.findCard("Island", true));
|
||||
}
|
||||
int nMountain = ((Number)spnMountain.getValue()).intValue();
|
||||
for (int i = 0; i < nMountain; i++) {
|
||||
deck.getCards().add(Sets.findCard("Mountain", true));
|
||||
}
|
||||
int nPlains = ((Number)spnPlains.getValue()).intValue();
|
||||
for (int i = 0; i < nPlains; i++) {
|
||||
deck.getCards().add(Sets.findCard("Plains", true));
|
||||
}
|
||||
int nSwamp = ((Number)spnSwamp.getValue()).intValue();
|
||||
for (int i = 0; i < nSwamp; i++) {
|
||||
deck.getCards().add(Sets.findCard("Swamp", true));
|
||||
}
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnAddActionPerformed
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
|
|
@ -52,69 +52,69 @@ import java.util.logging.Logger;
|
|||
*/
|
||||
public class CombatDialog extends MageDialog {
|
||||
|
||||
private UUID gameId;
|
||||
private BigCard bigCard;
|
||||
private int lastX = 500;
|
||||
private int lastY = 300;
|
||||
private UUID gameId;
|
||||
private BigCard bigCard;
|
||||
private int lastX = 500;
|
||||
private int lastY = 300;
|
||||
|
||||
/** Creates new form CombatDialog */
|
||||
public CombatDialog() {
|
||||
|
||||
|
||||
JPanel contentPane = new JPanel() {
|
||||
private static final long serialVersionUID = -8283955788355547309L;
|
||||
public void paintComponent(Graphics g) {
|
||||
g.setColor(new Color(50, 50, 50, 100));
|
||||
g.fillRect(0, 0, getWidth(), getHeight());
|
||||
}
|
||||
};
|
||||
private static final long serialVersionUID = -8283955788355547309L;
|
||||
public void paintComponent(Graphics g) {
|
||||
g.setColor(new Color(50, 50, 50, 100));
|
||||
g.fillRect(0, 0, getWidth(), getHeight());
|
||||
}
|
||||
};
|
||||
setContentPane(contentPane);
|
||||
|
||||
|
||||
initComponents();
|
||||
this.setModal(false);
|
||||
|
||||
this.setModal(false);
|
||||
|
||||
combatArea.setOpaque(false);
|
||||
jScrollPane1.setOpaque(false);
|
||||
jScrollPane1.getViewport().setOpaque(false);
|
||||
getRootPane().setOpaque(false);
|
||||
|
||||
//setDefaultCloseOperation(JInternalFrame.HIDE_ON_CLOSE);
|
||||
//setDefaultCloseOperation(JInternalFrame.HIDE_ON_CLOSE);
|
||||
}
|
||||
|
||||
public void init(UUID gameId, BigCard bigCard) {
|
||||
this.gameId = gameId;
|
||||
this.bigCard = bigCard;
|
||||
}
|
||||
public void init(UUID gameId, BigCard bigCard) {
|
||||
this.gameId = gameId;
|
||||
this.bigCard = bigCard;
|
||||
}
|
||||
|
||||
public void showDialog(List<CombatGroupView> combat) {
|
||||
combatArea.removeAll();
|
||||
for (CombatGroupView group: combat) {
|
||||
CombatGroup combatGroup = new CombatGroup();
|
||||
combatGroup.init(gameId, bigCard);
|
||||
combatGroup.update(group);
|
||||
combatGroup.setVisible(true);
|
||||
combatArea.add(combatGroup);
|
||||
combatGroup.revalidate();
|
||||
}
|
||||
try {
|
||||
this.setSelected(true);
|
||||
} catch (PropertyVetoException ex) {
|
||||
Logger.getLogger(CombatDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
pack();
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
if (!this.isVisible()) {
|
||||
this.setVisible(true);
|
||||
this.setLocation(lastX, lastY);
|
||||
}
|
||||
}
|
||||
public void showDialog(List<CombatGroupView> combat) {
|
||||
combatArea.removeAll();
|
||||
for (CombatGroupView group: combat) {
|
||||
CombatGroup combatGroup = new CombatGroup();
|
||||
combatGroup.init(gameId, bigCard);
|
||||
combatGroup.update(group);
|
||||
combatGroup.setVisible(true);
|
||||
combatArea.add(combatGroup);
|
||||
combatGroup.revalidate();
|
||||
}
|
||||
try {
|
||||
this.setSelected(true);
|
||||
} catch (PropertyVetoException ex) {
|
||||
Logger.getLogger(CombatDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
pack();
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
if (!this.isVisible()) {
|
||||
this.setVisible(true);
|
||||
this.setLocation(lastX, lastY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideDialog() {
|
||||
this.lastX = this.getX();
|
||||
this.lastY = this.getY();
|
||||
super.hideDialog();
|
||||
}
|
||||
@Override
|
||||
public void hideDialog() {
|
||||
this.lastX = this.getX();
|
||||
this.lastY = this.getY();
|
||||
super.hideDialog();
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
|
|
@ -46,16 +46,16 @@ public class ErrorDialog extends MageDialog {
|
|||
initComponents();
|
||||
}
|
||||
|
||||
public void showDialog(String title, String message) {
|
||||
this.setTitle(title);
|
||||
this.lblMessage.setText(message);
|
||||
public void showDialog(String title, String message) {
|
||||
this.setTitle(title);
|
||||
this.lblMessage.setText(message);
|
||||
this.lblMessage.setCaretPosition(0);
|
||||
this.pack();
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
this.setModal(true);
|
||||
this.setVisible(true);
|
||||
}
|
||||
this.pack();
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
this.setModal(true);
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
@ -129,9 +129,9 @@ public class ErrorDialog extends MageDialog {
|
|||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnOKActionPerformed
|
||||
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnOKActionPerformed
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
|
|
@ -51,28 +51,28 @@ public class ExileZoneDialog extends MageDialog {
|
|||
/** Creates new form ExileZoneDialog */
|
||||
public ExileZoneDialog() {
|
||||
initComponents();
|
||||
this.setModal(false);
|
||||
this.setModal(false);
|
||||
}
|
||||
|
||||
public void loadCards(ExileView exile, BigCard bigCard, UUID gameId) {
|
||||
this.title = exile.getName();
|
||||
boolean changed = false;
|
||||
changed = cards.loadCards(exile, bigCard, gameId);
|
||||
if (exile.size() > 0) {
|
||||
show();
|
||||
if (changed) {
|
||||
try {
|
||||
this.setIcon(false);
|
||||
} catch (PropertyVetoException ex) {
|
||||
Logger.getLogger(ExileZoneDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.hideDialog();
|
||||
}
|
||||
}
|
||||
|
||||
public void loadCards(ExileView exile, BigCard bigCard, UUID gameId) {
|
||||
this.title = exile.getName();
|
||||
boolean changed = false;
|
||||
changed = cards.loadCards(exile, bigCard, gameId);
|
||||
if (exile.size() > 0) {
|
||||
show();
|
||||
if (changed) {
|
||||
try {
|
||||
this.setIcon(false);
|
||||
} catch (PropertyVetoException ex) {
|
||||
Logger.getLogger(ExileZoneDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.hideDialog();
|
||||
}
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
|
|
|
@ -40,7 +40,7 @@ import javax.swing.*;
|
|||
*/
|
||||
public class FeedbackDialog extends javax.swing.JDialog {
|
||||
|
||||
private static final transient Logger log = Logger.getLogger(PreferencesDialog.class);
|
||||
private static final transient Logger log = Logger.getLogger(PreferencesDialog.class);
|
||||
|
||||
private String[] feedbackTypes = {"", "Bug or \"something doesn't work\"",
|
||||
"Feature or \"I need that function\"",
|
||||
|
@ -51,7 +51,7 @@ public class FeedbackDialog extends javax.swing.JDialog {
|
|||
public FeedbackDialog(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
initComponents();
|
||||
cbFeedbackType.setModel(new DefaultComboBoxModel(feedbackTypes));
|
||||
cbFeedbackType.setModel(new DefaultComboBoxModel(feedbackTypes));
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
|
@ -282,26 +282,26 @@ public class FeedbackDialog extends javax.swing.JDialog {
|
|||
}
|
||||
|
||||
private void reset() {
|
||||
cbFeedbackType.setSelectedIndex(0);
|
||||
cbFeedbackType.setSelectedIndex(0);
|
||||
txtIdeaTitle.setText("");
|
||||
txtFeedbackMessage.setText("");
|
||||
txtEmail.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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();
|
||||
}
|
||||
}
|
||||
});
|
||||
public void run() {
|
||||
if (!dialog.isVisible()) {
|
||||
dialog.setLocation(300, 200);
|
||||
dialog.setVisible(true);
|
||||
} else {
|
||||
dialog.requestFocus();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
|
|
@ -40,26 +40,26 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class JoinTableDialog extends MageDialog {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(JoinTableDialog.class);
|
||||
private final static Logger logger = Logger.getLogger(JoinTableDialog.class);
|
||||
|
||||
private UUID tableId;
|
||||
private UUID roomId;
|
||||
private boolean joined = false;
|
||||
private UUID tableId;
|
||||
private UUID roomId;
|
||||
private boolean joined = false;
|
||||
|
||||
/** Creates new form JoinTableDialog */
|
||||
public JoinTableDialog() {
|
||||
initComponents();
|
||||
newPlayerPanel.showLevel(false);
|
||||
newPlayerPanel.showLevel(false);
|
||||
}
|
||||
|
||||
public void showDialog(UUID roomId, UUID tableId) {
|
||||
this.roomId = roomId;
|
||||
this.tableId = tableId;
|
||||
this.newPlayerPanel.setPlayerName(MageFrame.getSession().getUserName());
|
||||
this.setModal(true);
|
||||
this.setLocation(100, 100);
|
||||
this.setVisible(true);
|
||||
}
|
||||
public void showDialog(UUID roomId, UUID tableId) {
|
||||
this.roomId = roomId;
|
||||
this.tableId = tableId;
|
||||
this.newPlayerPanel.setPlayerName(MageFrame.getSession().getUserName());
|
||||
this.setModal(true);
|
||||
this.setLocation(100, 100);
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
|
@ -120,32 +120,32 @@ public class JoinTableDialog extends MageDialog {
|
|||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||
this.joined = false;
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnCancelActionPerformed
|
||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||
this.joined = false;
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnCancelActionPerformed
|
||||
|
||||
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
|
||||
Session session = MageFrame.getSession();
|
||||
try {
|
||||
joined = session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), "Human", 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()));
|
||||
} catch (Exception ex) {
|
||||
handleError(ex);
|
||||
}
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnOKActionPerformed
|
||||
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
|
||||
Session session = MageFrame.getSession();
|
||||
try {
|
||||
joined = session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), "Human", 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()));
|
||||
} catch (Exception ex) {
|
||||
handleError(ex);
|
||||
}
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnOKActionPerformed
|
||||
|
||||
/**
|
||||
* @return the joined
|
||||
*/
|
||||
public boolean isJoined() {
|
||||
return joined;
|
||||
}
|
||||
/**
|
||||
* @return the joined
|
||||
*/
|
||||
public boolean isJoined() {
|
||||
return joined;
|
||||
}
|
||||
|
||||
private void handleError(Exception ex) {
|
||||
logger.fatal("Error loading deck", ex);
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error loading deck.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
private void handleError(Exception ex) {
|
||||
logger.fatal("Error loading deck", ex);
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error loading deck.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
|
|
@ -50,21 +50,21 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class MageDialog extends javax.swing.JInternalFrame {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(MageDialog.class);
|
||||
private final static Logger logger = Logger.getLogger(MageDialog.class);
|
||||
|
||||
protected boolean modal = false;
|
||||
protected boolean modal = false;
|
||||
|
||||
/** Creates new form MageDialog */
|
||||
public MageDialog() {
|
||||
initComponents();
|
||||
initComponents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
super.show();
|
||||
this.toFront();
|
||||
if (modal)
|
||||
this.setClosable(false);
|
||||
this.toFront();
|
||||
if (modal)
|
||||
this.setClosable(false);
|
||||
if (this.modal) {
|
||||
startModal();
|
||||
}
|
||||
|
@ -73,36 +73,36 @@ public class MageDialog extends javax.swing.JInternalFrame {
|
|||
@Override
|
||||
public void setVisible(boolean value) {
|
||||
super.setVisible(value);
|
||||
if (value)
|
||||
this.toFront();
|
||||
if (value)
|
||||
this.toFront();
|
||||
if (modal) {
|
||||
this.setClosable(false);
|
||||
this.setClosable(false);
|
||||
if (value) {
|
||||
startModal();
|
||||
} else {
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
stopModal();
|
||||
} else {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
stopModal();
|
||||
}
|
||||
});
|
||||
} catch (InterruptedException ex) {
|
||||
logger.fatal("MageDialog error", ex);
|
||||
} catch (InvocationTargetException ex) {
|
||||
logger.fatal("MageDialog error", ex);
|
||||
}
|
||||
}
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
stopModal();
|
||||
} else {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
stopModal();
|
||||
}
|
||||
});
|
||||
} catch (InterruptedException ex) {
|
||||
logger.fatal("MageDialog error", ex);
|
||||
} catch (InvocationTargetException ex) {
|
||||
logger.fatal("MageDialog error", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void startModal() {
|
||||
|
||||
try {
|
||||
try {
|
||||
if (SwingUtilities.isEventDispatchThread()) {
|
||||
EventQueue theQueue = getToolkit().getSystemEventQueue();
|
||||
while (isVisible()) {
|
||||
|
@ -126,7 +126,7 @@ public class MageDialog extends javax.swing.JInternalFrame {
|
|||
} else if (source instanceof MenuComponent) {
|
||||
((MenuComponent) source).dispatchEvent(event);
|
||||
} else {
|
||||
logger.warn("Unable to dispatch: " + event);
|
||||
logger.warn("Unable to dispatch: " + event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ public class MageDialog extends javax.swing.JInternalFrame {
|
|||
notifyAll();
|
||||
}
|
||||
|
||||
public void setModal(boolean modal) {
|
||||
public void setModal(boolean modal) {
|
||||
this.modal = modal;
|
||||
}
|
||||
|
||||
|
@ -152,10 +152,10 @@ public class MageDialog extends javax.swing.JInternalFrame {
|
|||
return this.modal;
|
||||
}
|
||||
|
||||
public void hideDialog() {
|
||||
this.setVisible(false);
|
||||
}
|
||||
|
||||
public void hideDialog() {
|
||||
this.setVisible(false);
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
|
|
|
@ -54,22 +54,22 @@ import java.util.UUID;
|
|||
*/
|
||||
public class NewTableDialog extends MageDialog {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(NewTableDialog.class);
|
||||
private final static Logger logger = Logger.getLogger(NewTableDialog.class);
|
||||
|
||||
private TableView table;
|
||||
private UUID playerId;
|
||||
private UUID roomId;
|
||||
private Session session;
|
||||
private List<TablePlayerPanel> players = new ArrayList<TablePlayerPanel>();
|
||||
|
||||
private static final String LIMITED = "Limited";
|
||||
|
||||
private TableView table;
|
||||
private UUID playerId;
|
||||
private UUID roomId;
|
||||
private Session session;
|
||||
private List<TablePlayerPanel> players = new ArrayList<TablePlayerPanel>();
|
||||
|
||||
private static final String LIMITED = "Limited";
|
||||
|
||||
/** Creates new form NewTableDialog */
|
||||
public NewTableDialog() {
|
||||
initComponents();
|
||||
txtName.setText("Game");
|
||||
player1Panel.showLevel(false);
|
||||
this.spnNumWins.setModel(new SpinnerNumberModel(1, 1, 5, 1));
|
||||
txtName.setText("Game");
|
||||
player1Panel.showLevel(false);
|
||||
this.spnNumWins.setModel(new SpinnerNumberModel(1, 1, 5, 1));
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
|
@ -290,150 +290,150 @@ public class NewTableDialog extends MageDialog {
|
|||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||
this.table = null;
|
||||
this.playerId = null;
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnCancelActionPerformed
|
||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||
this.table = null;
|
||||
this.playerId = null;
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnCancelActionPerformed
|
||||
|
||||
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
|
||||
GameTypeView gameType = (GameTypeView) cbGameType.getSelectedItem();
|
||||
MatchOptions options = new MatchOptions(this.txtName.getText(), gameType.getName());
|
||||
options.getPlayerTypes().add("Human");
|
||||
for (TablePlayerPanel player: players) {
|
||||
options.getPlayerTypes().add(player.getPlayerType());
|
||||
}
|
||||
options.setDeckType((String) this.cbDeckType.getSelectedItem());
|
||||
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
|
||||
GameTypeView gameType = (GameTypeView) cbGameType.getSelectedItem();
|
||||
MatchOptions options = new MatchOptions(this.txtName.getText(), gameType.getName());
|
||||
options.getPlayerTypes().add("Human");
|
||||
for (TablePlayerPanel player: players) {
|
||||
options.getPlayerTypes().add(player.getPlayerType());
|
||||
}
|
||||
options.setDeckType((String) this.cbDeckType.getSelectedItem());
|
||||
options.setLimited(false);
|
||||
options.setAttackOption((MultiplayerAttackOption) this.cbAttackOption.getSelectedItem());
|
||||
options.setRange((RangeOfInfluence) this.cbRange.getSelectedItem());
|
||||
options.setWinsNeeded((Integer)this.spnNumWins.getValue());
|
||||
table = session.createTable(roomId, options);
|
||||
if (table == null) {
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error creating table.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (session.joinTable(roomId, table.getTableId(), this.player1Panel.getPlayerName(), "Human", 1, DeckImporterUtil.importDeck(this.player1Panel.getDeckFile()))) {
|
||||
for (TablePlayerPanel player: players) {
|
||||
if (!player.getPlayerType().equals("Human")) {
|
||||
if (!player.joinTable(roomId, table.getTableId())) {
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining table.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
session.removeTable(roomId, table.getTableId());
|
||||
table = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.hideDialog();
|
||||
return;
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
handleError(ex);
|
||||
} catch (IOException ex) {
|
||||
handleError(ex);
|
||||
} catch (ClassNotFoundException ex) {
|
||||
handleError(ex);
|
||||
}
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining table.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
session.removeTable(roomId, table.getTableId());
|
||||
table = null;
|
||||
}//GEN-LAST:event_btnOKActionPerformed
|
||||
options.setAttackOption((MultiplayerAttackOption) this.cbAttackOption.getSelectedItem());
|
||||
options.setRange((RangeOfInfluence) this.cbRange.getSelectedItem());
|
||||
options.setWinsNeeded((Integer)this.spnNumWins.getValue());
|
||||
table = session.createTable(roomId, options);
|
||||
if (table == null) {
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error creating table.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (session.joinTable(roomId, table.getTableId(), this.player1Panel.getPlayerName(), "Human", 1, DeckImporterUtil.importDeck(this.player1Panel.getDeckFile()))) {
|
||||
for (TablePlayerPanel player: players) {
|
||||
if (!player.getPlayerType().equals("Human")) {
|
||||
if (!player.joinTable(roomId, table.getTableId())) {
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining table.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
session.removeTable(roomId, table.getTableId());
|
||||
table = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.hideDialog();
|
||||
return;
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
handleError(ex);
|
||||
} catch (IOException ex) {
|
||||
handleError(ex);
|
||||
} catch (ClassNotFoundException ex) {
|
||||
handleError(ex);
|
||||
}
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining table.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
session.removeTable(roomId, table.getTableId());
|
||||
table = null;
|
||||
}//GEN-LAST:event_btnOKActionPerformed
|
||||
|
||||
private void cbGameTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbGameTypeActionPerformed
|
||||
setGameOptions();
|
||||
}//GEN-LAST:event_cbGameTypeActionPerformed
|
||||
private void cbGameTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbGameTypeActionPerformed
|
||||
setGameOptions();
|
||||
}//GEN-LAST:event_cbGameTypeActionPerformed
|
||||
|
||||
private void numPlayersChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_numPlayersChanged
|
||||
int numPlayers = (Integer)this.spnNumPlayers.getValue() - 1;
|
||||
createPlayers(numPlayers);
|
||||
}//GEN-LAST:event_numPlayersChanged
|
||||
private void numPlayersChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_numPlayersChanged
|
||||
int numPlayers = (Integer)this.spnNumPlayers.getValue() - 1;
|
||||
createPlayers(numPlayers);
|
||||
}//GEN-LAST:event_numPlayersChanged
|
||||
|
||||
private void spnNumWinsnumPlayersChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spnNumWinsnumPlayersChanged
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_spnNumWinsnumPlayersChanged
|
||||
private void spnNumWinsnumPlayersChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spnNumWinsnumPlayersChanged
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_spnNumWinsnumPlayersChanged
|
||||
|
||||
private void setGameOptions() {
|
||||
GameTypeView gameType = (GameTypeView) cbGameType.getSelectedItem();
|
||||
this.spnNumPlayers.setModel(new SpinnerNumberModel(gameType.getMinPlayers(), gameType.getMinPlayers(), gameType.getMaxPlayers(), 1));
|
||||
this.spnNumPlayers.setEnabled(gameType.getMinPlayers() != gameType.getMaxPlayers());
|
||||
this.cbAttackOption.setEnabled(gameType.isUseAttackOption());
|
||||
this.cbRange.setEnabled(gameType.isUseRange());
|
||||
createPlayers(gameType.getMinPlayers() - 1);
|
||||
}
|
||||
private void setGameOptions() {
|
||||
GameTypeView gameType = (GameTypeView) cbGameType.getSelectedItem();
|
||||
this.spnNumPlayers.setModel(new SpinnerNumberModel(gameType.getMinPlayers(), gameType.getMinPlayers(), gameType.getMaxPlayers(), 1));
|
||||
this.spnNumPlayers.setEnabled(gameType.getMinPlayers() != gameType.getMaxPlayers());
|
||||
this.cbAttackOption.setEnabled(gameType.isUseAttackOption());
|
||||
this.cbRange.setEnabled(gameType.isUseRange());
|
||||
createPlayers(gameType.getMinPlayers() - 1);
|
||||
}
|
||||
|
||||
private void createPlayers(int numPlayers) {
|
||||
if (numPlayers > players.size()) {
|
||||
while (players.size() != numPlayers) {
|
||||
TablePlayerPanel playerPanel = new TablePlayerPanel();
|
||||
playerPanel.init(players.size() + 2);
|
||||
players.add(playerPanel);
|
||||
playerPanel.addPlayerTypeEventListener(
|
||||
new Listener<Event> () {
|
||||
@Override
|
||||
public void event(Event event) {
|
||||
drawPlayers();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (numPlayers < players.size()) {
|
||||
while (players.size() != numPlayers) {
|
||||
players.remove(players.size() - 1);
|
||||
}
|
||||
}
|
||||
drawPlayers();
|
||||
}
|
||||
private void createPlayers(int numPlayers) {
|
||||
if (numPlayers > players.size()) {
|
||||
while (players.size() != numPlayers) {
|
||||
TablePlayerPanel playerPanel = new TablePlayerPanel();
|
||||
playerPanel.init(players.size() + 2);
|
||||
players.add(playerPanel);
|
||||
playerPanel.addPlayerTypeEventListener(
|
||||
new Listener<Event> () {
|
||||
@Override
|
||||
public void event(Event event) {
|
||||
drawPlayers();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (numPlayers < players.size()) {
|
||||
while (players.size() != numPlayers) {
|
||||
players.remove(players.size() - 1);
|
||||
}
|
||||
}
|
||||
drawPlayers();
|
||||
}
|
||||
|
||||
private void drawPlayers() {
|
||||
this.pnlOtherPlayers.removeAll();
|
||||
for (TablePlayerPanel panel: players) {
|
||||
this.pnlOtherPlayers.add(panel);
|
||||
}
|
||||
this.pack();
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
}
|
||||
private void drawPlayers() {
|
||||
this.pnlOtherPlayers.removeAll();
|
||||
for (TablePlayerPanel panel: players) {
|
||||
this.pnlOtherPlayers.add(panel);
|
||||
}
|
||||
this.pack();
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
private void handleError(Exception ex) {
|
||||
logger.fatal("Error loading deck", ex);
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error loading deck.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
private void handleError(Exception ex) {
|
||||
logger.fatal("Error loading deck", ex);
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error loading deck.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
public void showDialog(UUID roomId) {
|
||||
session = MageFrame.getSession();
|
||||
MageFrame.getUI().addButton(MageComponents.NEW_TABLE_OK_BUTTON, btnOK);
|
||||
this.player1Panel.setPlayerName(session.getUserName());
|
||||
cbGameType.setModel(new DefaultComboBoxModel(session.getGameTypes().toArray()));
|
||||
cbDeckType.setModel(new DefaultComboBoxModel(session.getDeckTypes()));
|
||||
selectLimitedByDefault();
|
||||
cbRange.setModel(new DefaultComboBoxModel(RangeOfInfluence.values()));
|
||||
cbAttackOption.setModel(new DefaultComboBoxModel(MultiplayerAttackOption.values()));
|
||||
this.roomId = roomId;
|
||||
this.setModal(true);
|
||||
setGameOptions();
|
||||
this.setLocation(150, 100);
|
||||
this.setVisible(true);
|
||||
}
|
||||
public void showDialog(UUID roomId) {
|
||||
session = MageFrame.getSession();
|
||||
MageFrame.getUI().addButton(MageComponents.NEW_TABLE_OK_BUTTON, btnOK);
|
||||
this.player1Panel.setPlayerName(session.getUserName());
|
||||
cbGameType.setModel(new DefaultComboBoxModel(session.getGameTypes().toArray()));
|
||||
cbDeckType.setModel(new DefaultComboBoxModel(session.getDeckTypes()));
|
||||
selectLimitedByDefault();
|
||||
cbRange.setModel(new DefaultComboBoxModel(RangeOfInfluence.values()));
|
||||
cbAttackOption.setModel(new DefaultComboBoxModel(MultiplayerAttackOption.values()));
|
||||
this.roomId = roomId;
|
||||
this.setModal(true);
|
||||
setGameOptions();
|
||||
this.setLocation(150, 100);
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
public TableView getTable() {
|
||||
return table;
|
||||
}
|
||||
public TableView getTable() {
|
||||
return table;
|
||||
}
|
||||
|
||||
public UUID getPlayerId() {
|
||||
return playerId;
|
||||
}
|
||||
|
||||
private void selectLimitedByDefault() {
|
||||
for (int i = 0; i < cbDeckType.getItemCount(); i++) {
|
||||
String name = (String)cbDeckType.getItemAt(i);
|
||||
if (name.equals(LIMITED)) {
|
||||
cbDeckType.setSelectedIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public UUID getPlayerId() {
|
||||
return playerId;
|
||||
}
|
||||
|
||||
private void selectLimitedByDefault() {
|
||||
for (int i = 0; i < cbDeckType.getItemCount(); i++) {
|
||||
String name = (String)cbDeckType.getItemAt(i);
|
||||
if (name.equals(LIMITED)) {
|
||||
cbDeckType.setSelectedIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton btnCancel;
|
||||
|
|
|
@ -62,32 +62,32 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class NewTournamentDialog extends MageDialog {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(NewTournamentDialog.class);
|
||||
private final static Logger logger = Logger.getLogger(NewTournamentDialog.class);
|
||||
|
||||
private TableView table;
|
||||
private UUID playerId;
|
||||
private UUID roomId;
|
||||
private Session session;
|
||||
private List<TournamentPlayerPanel> players = new ArrayList<TournamentPlayerPanel>();
|
||||
private List<JComboBox> packs = new ArrayList<JComboBox>();
|
||||
private TableView table;
|
||||
private UUID playerId;
|
||||
private UUID roomId;
|
||||
private Session session;
|
||||
private List<TournamentPlayerPanel> players = new ArrayList<TournamentPlayerPanel>();
|
||||
private List<JComboBox> packs = new ArrayList<JComboBox>();
|
||||
|
||||
/** Creates new form NewTournamentDialog */
|
||||
/** Creates new form NewTournamentDialog */
|
||||
public NewTournamentDialog() {
|
||||
initComponents();
|
||||
txtName.setText("Tournament");
|
||||
txtName.setText("Tournament");
|
||||
}
|
||||
|
||||
public void showDialog(UUID roomId) {
|
||||
this.roomId = roomId;
|
||||
session = MageFrame.getSession();
|
||||
this.txtPlayer1Name.setText(session.getUserName());
|
||||
cbTournamentType.setModel(new DefaultComboBoxModel(session.getTournamentTypes().toArray()));
|
||||
cbDraftTiming.setModel(new DefaultComboBoxModel(DraftOptions.TimingOption.values()));
|
||||
this.setModal(true);
|
||||
setTournamentOptions();
|
||||
this.setLocation(150, 100);
|
||||
this.setVisible(true);
|
||||
}
|
||||
public void showDialog(UUID roomId) {
|
||||
this.roomId = roomId;
|
||||
session = MageFrame.getSession();
|
||||
this.txtPlayer1Name.setText(session.getUserName());
|
||||
cbTournamentType.setModel(new DefaultComboBoxModel(session.getTournamentTypes().toArray()));
|
||||
cbDraftTiming.setModel(new DefaultComboBoxModel(DraftOptions.TimingOption.values()));
|
||||
this.setModal(true);
|
||||
setTournamentOptions();
|
||||
this.setLocation(150, 100);
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
@ -277,173 +277,173 @@ public class NewTournamentDialog extends MageDialog {
|
|||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void cbTournamentTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbTournamentTypeActionPerformed
|
||||
setTournamentOptions();
|
||||
}//GEN-LAST:event_cbTournamentTypeActionPerformed
|
||||
private void cbTournamentTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbTournamentTypeActionPerformed
|
||||
setTournamentOptions();
|
||||
}//GEN-LAST:event_cbTournamentTypeActionPerformed
|
||||
|
||||
private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
|
||||
TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem();
|
||||
TournamentOptions tOptions = new TournamentOptions(this.txtName.getText());
|
||||
tOptions.setTournamentType(tournamentType.getName());
|
||||
tOptions.getPlayerTypes().add("Human");
|
||||
for (TournamentPlayerPanel player: players) {
|
||||
tOptions.getPlayerTypes().add((String) player.getPlayerType().getSelectedItem());
|
||||
}
|
||||
if (tournamentType.isDraft()) {
|
||||
DraftOptions options = new DraftOptions();
|
||||
options.setDraftType("");
|
||||
options.setTiming((TimingOption) this.cbDraftTiming.getSelectedItem());
|
||||
tOptions.setLimitedOptions(options);
|
||||
}
|
||||
if (tournamentType.isLimited()) {
|
||||
if (tOptions.getLimitedOptions() == null)
|
||||
tOptions.setLimitedOptions(new LimitedOptions());
|
||||
for (JComboBox pack: packs) {
|
||||
tOptions.getLimitedOptions().getSetCodes().add(((ExpansionSet) pack.getSelectedItem()).getCode());
|
||||
}
|
||||
}
|
||||
tOptions.getMatchOptions().setDeckType("Limited");
|
||||
tOptions.getMatchOptions().setWinsNeeded(2);
|
||||
tOptions.getMatchOptions().setAttackOption(MultiplayerAttackOption.LEFT);
|
||||
tOptions.getMatchOptions().setRange(RangeOfInfluence.ALL);
|
||||
private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
|
||||
TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem();
|
||||
TournamentOptions tOptions = new TournamentOptions(this.txtName.getText());
|
||||
tOptions.setTournamentType(tournamentType.getName());
|
||||
tOptions.getPlayerTypes().add("Human");
|
||||
for (TournamentPlayerPanel player: players) {
|
||||
tOptions.getPlayerTypes().add((String) player.getPlayerType().getSelectedItem());
|
||||
}
|
||||
if (tournamentType.isDraft()) {
|
||||
DraftOptions options = new DraftOptions();
|
||||
options.setDraftType("");
|
||||
options.setTiming((TimingOption) this.cbDraftTiming.getSelectedItem());
|
||||
tOptions.setLimitedOptions(options);
|
||||
}
|
||||
if (tournamentType.isLimited()) {
|
||||
if (tOptions.getLimitedOptions() == null)
|
||||
tOptions.setLimitedOptions(new LimitedOptions());
|
||||
for (JComboBox pack: packs) {
|
||||
tOptions.getLimitedOptions().getSetCodes().add(((ExpansionSet) pack.getSelectedItem()).getCode());
|
||||
}
|
||||
}
|
||||
tOptions.getMatchOptions().setDeckType("Limited");
|
||||
tOptions.getMatchOptions().setWinsNeeded(2);
|
||||
tOptions.getMatchOptions().setAttackOption(MultiplayerAttackOption.LEFT);
|
||||
tOptions.getMatchOptions().setRange(RangeOfInfluence.ALL);
|
||||
tOptions.getMatchOptions().setLimited(true);
|
||||
table = session.createTournamentTable(roomId, tOptions);
|
||||
if (table == null) {
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error creating table.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
if (session.joinTournamentTable(roomId, table.getTableId(), this.txtPlayer1Name.getText(), "Human", 1)) {
|
||||
for (TournamentPlayerPanel player: players) {
|
||||
if (!player.getPlayerType().equals("Human")) {
|
||||
if (!player.joinTournamentTable(roomId, table.getTableId())) {
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining tournament.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
session.removeTable(roomId, table.getTableId());
|
||||
table = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.hideDialog();
|
||||
return;
|
||||
}
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining tournament.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
session.removeTable(roomId, table.getTableId());
|
||||
table = null;
|
||||
}//GEN-LAST:event_btnOkActionPerformed
|
||||
table = session.createTournamentTable(roomId, tOptions);
|
||||
if (table == null) {
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error creating table.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
if (session.joinTournamentTable(roomId, table.getTableId(), this.txtPlayer1Name.getText(), "Human", 1)) {
|
||||
for (TournamentPlayerPanel player: players) {
|
||||
if (!player.getPlayerType().equals("Human")) {
|
||||
if (!player.joinTournamentTable(roomId, table.getTableId())) {
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining tournament.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
session.removeTable(roomId, table.getTableId());
|
||||
table = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.hideDialog();
|
||||
return;
|
||||
}
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining tournament.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
session.removeTable(roomId, table.getTableId());
|
||||
table = null;
|
||||
}//GEN-LAST:event_btnOkActionPerformed
|
||||
|
||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||
this.table = null;
|
||||
this.playerId = null;
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnCancelActionPerformed
|
||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||
this.table = null;
|
||||
this.playerId = null;
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnCancelActionPerformed
|
||||
|
||||
private void spnNumPlayersStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spnNumPlayersStateChanged
|
||||
int numPlayers = (Integer)this.spnNumPlayers.getValue() - 1;
|
||||
createPlayers(numPlayers);
|
||||
}//GEN-LAST:event_spnNumPlayersStateChanged
|
||||
private void spnNumPlayersStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spnNumPlayersStateChanged
|
||||
int numPlayers = (Integer)this.spnNumPlayers.getValue() - 1;
|
||||
createPlayers(numPlayers);
|
||||
}//GEN-LAST:event_spnNumPlayersStateChanged
|
||||
|
||||
private void setTournamentOptions() {
|
||||
TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem();
|
||||
this.spnNumPlayers.setModel(new SpinnerNumberModel(tournamentType.getMinPlayers(), tournamentType.getMinPlayers(), tournamentType.getMaxPlayers(), 1));
|
||||
this.spnNumPlayers.setEnabled(tournamentType.getMinPlayers() != tournamentType.getMaxPlayers());
|
||||
createPlayers(tournamentType.getMinPlayers() - 1);
|
||||
if (tournamentType.isLimited()) {
|
||||
this.pnlPacks.setVisible(true);
|
||||
createPacks(tournamentType.getNumBoosters());
|
||||
}
|
||||
else {
|
||||
this.pnlPacks.setVisible(false);
|
||||
}
|
||||
this.pnlDraftOptions.setVisible(tournamentType.isDraft());
|
||||
}
|
||||
private void setTournamentOptions() {
|
||||
TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem();
|
||||
this.spnNumPlayers.setModel(new SpinnerNumberModel(tournamentType.getMinPlayers(), tournamentType.getMinPlayers(), tournamentType.getMaxPlayers(), 1));
|
||||
this.spnNumPlayers.setEnabled(tournamentType.getMinPlayers() != tournamentType.getMaxPlayers());
|
||||
createPlayers(tournamentType.getMinPlayers() - 1);
|
||||
if (tournamentType.isLimited()) {
|
||||
this.pnlPacks.setVisible(true);
|
||||
createPacks(tournamentType.getNumBoosters());
|
||||
}
|
||||
else {
|
||||
this.pnlPacks.setVisible(false);
|
||||
}
|
||||
this.pnlDraftOptions.setVisible(tournamentType.isDraft());
|
||||
}
|
||||
|
||||
private void createPacks(int numPacks) {
|
||||
while (packs.size() > numPacks) {
|
||||
pnlPacks.remove(packs.get(packs.size() - 1));
|
||||
packs.remove(packs.size() - 1);
|
||||
}
|
||||
while (packs.size() < numPacks) {
|
||||
JComboBox pack = new JComboBox();
|
||||
pack.setModel(new DefaultComboBoxModel(Sets.getInstance().values().toArray()));
|
||||
pnlPacks.add(pack);
|
||||
packs.add(pack);
|
||||
pack.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
packActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.pack();
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
}
|
||||
private void createPacks(int numPacks) {
|
||||
while (packs.size() > numPacks) {
|
||||
pnlPacks.remove(packs.get(packs.size() - 1));
|
||||
packs.remove(packs.size() - 1);
|
||||
}
|
||||
while (packs.size() < numPacks) {
|
||||
JComboBox pack = new JComboBox();
|
||||
pack.setModel(new DefaultComboBoxModel(Sets.getInstance().values().toArray()));
|
||||
pnlPacks.add(pack);
|
||||
packs.add(pack);
|
||||
pack.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
packActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.pack();
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
private void packActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
boolean start = false;
|
||||
int selectedIndex = 0;
|
||||
for (JComboBox pack: packs) {
|
||||
if (!start) {
|
||||
if (evt.getSource().equals(pack)) {
|
||||
start = true;
|
||||
selectedIndex = pack.getSelectedIndex();
|
||||
}
|
||||
}
|
||||
else {
|
||||
pack.setSelectedIndex(selectedIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void packActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
boolean start = false;
|
||||
int selectedIndex = 0;
|
||||
for (JComboBox pack: packs) {
|
||||
if (!start) {
|
||||
if (evt.getSource().equals(pack)) {
|
||||
start = true;
|
||||
selectedIndex = pack.getSelectedIndex();
|
||||
}
|
||||
}
|
||||
else {
|
||||
pack.setSelectedIndex(selectedIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createPlayers(int numPlayers) {
|
||||
if (numPlayers > players.size()) {
|
||||
while (players.size() != numPlayers) {
|
||||
TournamentPlayerPanel playerPanel = new TournamentPlayerPanel();
|
||||
playerPanel.init(players.size() + 2);
|
||||
players.add(playerPanel);
|
||||
}
|
||||
}
|
||||
else if (numPlayers < players.size()) {
|
||||
while (players.size() != numPlayers) {
|
||||
players.remove(players.size() - 1);
|
||||
}
|
||||
}
|
||||
drawPlayers();
|
||||
}
|
||||
private void createPlayers(int numPlayers) {
|
||||
if (numPlayers > players.size()) {
|
||||
while (players.size() != numPlayers) {
|
||||
TournamentPlayerPanel playerPanel = new TournamentPlayerPanel();
|
||||
playerPanel.init(players.size() + 2);
|
||||
players.add(playerPanel);
|
||||
}
|
||||
}
|
||||
else if (numPlayers < players.size()) {
|
||||
while (players.size() != numPlayers) {
|
||||
players.remove(players.size() - 1);
|
||||
}
|
||||
}
|
||||
drawPlayers();
|
||||
}
|
||||
|
||||
private void drawPlayers() {
|
||||
this.pnlOtherPlayers.removeAll();
|
||||
for (TournamentPlayerPanel panel: players) {
|
||||
this.pnlOtherPlayers.add(panel);
|
||||
panel.getPlayerType().addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
playerActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.pack();
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
}
|
||||
private void drawPlayers() {
|
||||
this.pnlOtherPlayers.removeAll();
|
||||
for (TournamentPlayerPanel panel: players) {
|
||||
this.pnlOtherPlayers.add(panel);
|
||||
panel.getPlayerType().addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
playerActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.pack();
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
private void playerActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
boolean start = false;
|
||||
int selectedIndex = 0;
|
||||
for (TournamentPlayerPanel player: players) {
|
||||
if (!start) {
|
||||
if (evt.getSource().equals(player.getPlayerType())) {
|
||||
start = true;
|
||||
selectedIndex = player.getPlayerType().getSelectedIndex();
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.getPlayerType().setSelectedIndex(selectedIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void playerActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
boolean start = false;
|
||||
int selectedIndex = 0;
|
||||
for (TournamentPlayerPanel player: players) {
|
||||
if (!start) {
|
||||
if (evt.getSource().equals(player.getPlayerType())) {
|
||||
start = true;
|
||||
selectedIndex = player.getPlayerType().getSelectedIndex();
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.getPlayerType().setSelectedIndex(selectedIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TableView getTable() {
|
||||
return table;
|
||||
}
|
||||
public TableView getTable() {
|
||||
return table;
|
||||
}
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
|
|
@ -46,19 +46,19 @@ public class PickChoiceDialog extends MageDialog {
|
|||
/** Creates new form PickNumberDialog */
|
||||
public PickChoiceDialog() {
|
||||
initComponents();
|
||||
this.setModal(true);
|
||||
this.setModal(true);
|
||||
}
|
||||
|
||||
public void showDialog(String message, String[] choices) {
|
||||
this.lblMessage.setText(message);
|
||||
this.lstChoices.setListData(choices);
|
||||
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
||||
this.setVisible(true);
|
||||
}
|
||||
public void showDialog(String message, String[] choices) {
|
||||
this.lblMessage.setText(message);
|
||||
this.lstChoices.setListData(choices);
|
||||
MageFrame.getDesktop().add(this, JLayeredPane.PALETTE_LAYER);
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
public String getChoice() {
|
||||
return (String)this.lstChoices.getSelectedValue();
|
||||
}
|
||||
public String getChoice() {
|
||||
return (String)this.lstChoices.getSelectedValue();
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
@ -131,13 +131,13 @@ public class PickChoiceDialog extends MageDialog {
|
|||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnOkActionPerformed
|
||||
private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnOkActionPerformed
|
||||
|
||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnCancelActionPerformed
|
||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnCancelActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton btnCancel;
|
||||
|
|
|
@ -42,30 +42,30 @@ import javax.swing.SpinnerNumberModel;
|
|||
*/
|
||||
public class PickNumberDialog extends MageDialog {
|
||||
|
||||
private boolean cancel;
|
||||
private boolean cancel;
|
||||
|
||||
/** Creates new form PickNumberDialog */
|
||||
public PickNumberDialog() {
|
||||
initComponents();
|
||||
this.setModal(true);
|
||||
this.setModal(true);
|
||||
}
|
||||
|
||||
public void showDialog(int min, int max, String message) {
|
||||
this.spnAmount.setModel(new SpinnerNumberModel(min, min, max, 1));
|
||||
this.lblMessage.setText(message);
|
||||
this.btnOk.setVisible(true);
|
||||
this.btnCancel.setVisible(false);
|
||||
this.pack();
|
||||
this.setVisible(true);
|
||||
}
|
||||
public void showDialog(int min, int max, String message) {
|
||||
this.spnAmount.setModel(new SpinnerNumberModel(min, min, max, 1));
|
||||
this.lblMessage.setText(message);
|
||||
this.btnOk.setVisible(true);
|
||||
this.btnCancel.setVisible(false);
|
||||
this.pack();
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return ((Number)spnAmount.getValue()).intValue();
|
||||
}
|
||||
public int getAmount() {
|
||||
return ((Number)spnAmount.getValue()).intValue();
|
||||
}
|
||||
|
||||
public boolean isCancel() {
|
||||
return cancel;
|
||||
}
|
||||
public boolean isCancel() {
|
||||
return cancel;
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
@ -102,7 +102,7 @@ public class PickNumberDialog extends MageDialog {
|
|||
|
||||
lblMessage.setBorder(null);
|
||||
lblMessage.setEditable(false);
|
||||
lblMessage.setCursor(null );
|
||||
lblMessage.setCursor(null );
|
||||
lblMessage.setFocusable(false);
|
||||
lblMessage.setOpaque(false);
|
||||
jScrollPane1.setViewportView(lblMessage);
|
||||
|
@ -143,15 +143,15 @@ public class PickNumberDialog extends MageDialog {
|
|||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
|
||||
this.cancel = false;
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnOkActionPerformed
|
||||
private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
|
||||
this.cancel = false;
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnOkActionPerformed
|
||||
|
||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||
this.cancel = true;
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnCancelActionPerformed
|
||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||
this.cancel = true;
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnCancelActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton btnCancel;
|
||||
|
|
|
@ -49,89 +49,89 @@ import mage.view.CardsView;
|
|||
*/
|
||||
public class PickPileDialog extends MageDialog {
|
||||
|
||||
private CardArea pile1;
|
||||
private CardArea pile2;
|
||||
|
||||
private boolean pickedPile1 = false;
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
private CardArea pile1;
|
||||
private CardArea pile2;
|
||||
|
||||
private boolean pickedPile1 = false;
|
||||
|
||||
/**
|
||||
* Create the frame.
|
||||
*/
|
||||
public PickPileDialog() {
|
||||
getContentPane().setLayout(new BorderLayout(0, 0));
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
getContentPane().add(panel, BorderLayout.WEST);
|
||||
panel.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
pile1 = new CardArea();
|
||||
panel.add(pile1, BorderLayout.CENTER);
|
||||
|
||||
JButton btnChoosePile1 = new JButton("Pile 1");
|
||||
btnChoosePile1.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
btnPile1ActionPerformed(e);
|
||||
}
|
||||
});
|
||||
panel.add(btnChoosePile1, BorderLayout.NORTH);
|
||||
|
||||
JPanel panel_1 = new JPanel();
|
||||
getContentPane().add(panel_1, BorderLayout.EAST);
|
||||
panel_1.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
pile2 = new CardArea();
|
||||
panel_1.add(pile2, BorderLayout.CENTER);
|
||||
|
||||
JButton btnChoosePile2 = new JButton("Pile 2");
|
||||
btnChoosePile2.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
btnPile2ActionPerformed(e);
|
||||
}
|
||||
});
|
||||
panel_1.add(btnChoosePile2, BorderLayout.NORTH);
|
||||
getContentPane().setLayout(new BorderLayout(0, 0));
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
getContentPane().add(panel, BorderLayout.WEST);
|
||||
panel.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
pile1 = new CardArea();
|
||||
panel.add(pile1, BorderLayout.CENTER);
|
||||
|
||||
JButton btnChoosePile1 = new JButton("Pile 1");
|
||||
btnChoosePile1.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
btnPile1ActionPerformed(e);
|
||||
}
|
||||
});
|
||||
panel.add(btnChoosePile1, BorderLayout.NORTH);
|
||||
|
||||
JPanel panel_1 = new JPanel();
|
||||
getContentPane().add(panel_1, BorderLayout.EAST);
|
||||
panel_1.setLayout(new BorderLayout(0, 0));
|
||||
|
||||
pile2 = new CardArea();
|
||||
panel_1.add(pile2, BorderLayout.CENTER);
|
||||
|
||||
JButton btnChoosePile2 = new JButton("Pile 2");
|
||||
btnChoosePile2.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
btnPile2ActionPerformed(e);
|
||||
}
|
||||
});
|
||||
panel_1.add(btnChoosePile2, BorderLayout.NORTH);
|
||||
}
|
||||
|
||||
|
||||
public void loadCards(String name, CardsView pile1, CardsView pile2, BigCard bigCard, CardDimensions dimension, UUID gameId) {
|
||||
this.title = name;
|
||||
this.pile1.loadCardsNarrow(pile1, bigCard, dimension, gameId, null);
|
||||
this.pile2.loadCardsNarrow(pile2, bigCard, dimension, gameId, null);
|
||||
|
||||
if (getParent() != MageFrame.getDesktop() /*|| this.isClosed*/) {
|
||||
MageFrame.getDesktop().add(this, JLayeredPane.POPUP_LAYER);
|
||||
}
|
||||
pack();
|
||||
this.title = name;
|
||||
this.pile1.loadCardsNarrow(pile1, bigCard, dimension, gameId, null);
|
||||
this.pile2.loadCardsNarrow(pile2, bigCard, dimension, gameId, null);
|
||||
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
this.setModal(true);
|
||||
this.setVisible(true);
|
||||
if (getParent() != MageFrame.getDesktop() /*|| this.isClosed*/) {
|
||||
MageFrame.getDesktop().add(this, JLayeredPane.POPUP_LAYER);
|
||||
}
|
||||
pack();
|
||||
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
this.setModal(true);
|
||||
this.setVisible(true);
|
||||
|
||||
// SwingUtilities.invokeLater(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// int width = PickPileDialog.this.getWidth();
|
||||
// int height = PickPileDialog.this.getWidth();
|
||||
// if (width > 0 && height > 0) {
|
||||
// Point centered = SettingsManager.getInstance().getComponentPosition(width, height);
|
||||
// PickPileDialog.this.setLocation(centered.x, centered.y);
|
||||
// GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, PickPileDialog.this);
|
||||
// }
|
||||
// PickPileDialog.this.setVisible(true);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
// SwingUtilities.invokeLater(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// int width = PickPileDialog.this.getWidth();
|
||||
// int height = PickPileDialog.this.getWidth();
|
||||
// if (width > 0 && height > 0) {
|
||||
// Point centered = SettingsManager.getInstance().getComponentPosition(width, height);
|
||||
// PickPileDialog.this.setLocation(centered.x, centered.y);
|
||||
// GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, PickPileDialog.this);
|
||||
// }
|
||||
// PickPileDialog.this.setVisible(true);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
private void btnPile1ActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
pickedPile1 = true;
|
||||
this.hideDialog();
|
||||
pickedPile1 = true;
|
||||
this.hideDialog();
|
||||
}
|
||||
|
||||
|
||||
private void btnPile2ActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
pickedPile1 = false;
|
||||
this.hideDialog();
|
||||
pickedPile1 = false;
|
||||
this.hideDialog();
|
||||
}
|
||||
|
||||
|
||||
public boolean isPickedPile1() {
|
||||
return this.pickedPile1;
|
||||
return this.pickedPile1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,49 +65,49 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
|
||||
public static final String KEY_HAND_USE_BIG_CARDS = "handUseBigCards";
|
||||
public static final String KEY_SHOW_TOOLTIPS_ANY_ZONE = "showTooltipsInAnyZone";
|
||||
public static final String KEY_PERMANENTS_IN_ONE_PILE = "nonLandPermanentsInOnePile";
|
||||
public static final String KEY_PERMANENTS_IN_ONE_PILE = "nonLandPermanentsInOnePile";
|
||||
public static final String KEY_CARD_IMAGES_USE_DEFAULT = "cardImagesUseDefault";
|
||||
public static final String KEY_CARD_IMAGES_PATH = "cardImagesPath";
|
||||
public static final String KEY_CARD_IMAGES_CHECK = "cardImagesCheck";
|
||||
|
||||
public static final String KEY_PROXY_ADDRESS = "proxyAddress";
|
||||
public static final String KEY_PROXY_PORT = "proxyPort";
|
||||
public static final String KEY_PROXY_USERNAME = "proxyUsername";
|
||||
public static final String KEY_PROXY_REMEMBER = "proxyRemember";
|
||||
public static final String KEY_PROXY_TYPE = "proxyType";
|
||||
public static final String KEY_PROXY_PSWD = "proxyPassword";
|
||||
public static final String KEY_PROXY_ADDRESS = "proxyAddress";
|
||||
public static final String KEY_PROXY_PORT = "proxyPort";
|
||||
public static final String KEY_PROXY_USERNAME = "proxyUsername";
|
||||
public static final String KEY_PROXY_REMEMBER = "proxyRemember";
|
||||
public static final String KEY_PROXY_TYPE = "proxyType";
|
||||
public static final String KEY_PROXY_PSWD = "proxyPassword";
|
||||
|
||||
public static final String KEY_AVATAR = "selectedId";
|
||||
public static final String KEY_AVATAR = "selectedId";
|
||||
|
||||
private static Map<String, String> cache = new HashMap<String, String>();
|
||||
private static final Boolean UPDATE_CACHE_POLICY = Boolean.TRUE;
|
||||
|
||||
public static final String OPEN_CONNECTION_TAB = "Open-Connection-Tab";
|
||||
public static final String OPEN_CONNECTION_TAB = "Open-Connection-Tab";
|
||||
|
||||
private static final transient Logger log = Logger.getLogger(PreferencesDialog.class);
|
||||
private static final transient Logger log = Logger.getLogger(PreferencesDialog.class);
|
||||
|
||||
public static final int DEFAULT_AVATAR_ID = 51;
|
||||
private static int selectedId = DEFAULT_AVATAR_ID;
|
||||
private static Set<Integer> availableAvatars = new HashSet<Integer>();
|
||||
private static Map<Integer, JPanel> panels = new HashMap<Integer, JPanel>();
|
||||
public static final int DEFAULT_AVATAR_ID = 51;
|
||||
private static int selectedId = DEFAULT_AVATAR_ID;
|
||||
private static Set<Integer> availableAvatars = new HashSet<Integer>();
|
||||
private static Map<Integer, JPanel> panels = new HashMap<Integer, JPanel>();
|
||||
|
||||
private static final Border GREEN_BORDER = BorderFactory.createLineBorder(Color.GREEN, 3);
|
||||
private static final Border BLACK_BORDER = BorderFactory.createLineBorder(Color.BLACK, 3);
|
||||
private static final Border GREEN_BORDER = BorderFactory.createLineBorder(Color.GREEN, 3);
|
||||
private static final Border BLACK_BORDER = BorderFactory.createLineBorder(Color.BLACK, 3);
|
||||
|
||||
static {
|
||||
availableAvatars.add(51);
|
||||
availableAvatars.add(13);
|
||||
availableAvatars.add(9);
|
||||
availableAvatars.add(53);
|
||||
availableAvatars.add(10);
|
||||
availableAvatars.add(39);
|
||||
availableAvatars.add(19);
|
||||
availableAvatars.add(30);
|
||||
availableAvatars.add(25);
|
||||
static {
|
||||
availableAvatars.add(51);
|
||||
availableAvatars.add(13);
|
||||
availableAvatars.add(9);
|
||||
availableAvatars.add(53);
|
||||
availableAvatars.add(10);
|
||||
availableAvatars.add(39);
|
||||
availableAvatars.add(19);
|
||||
availableAvatars.add(30);
|
||||
availableAvatars.add(25);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private final JFileChooser fc = new JFileChooser();
|
||||
private final JFileChooser fc = new JFileChooser();
|
||||
|
||||
{
|
||||
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||
|
@ -118,8 +118,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
super(parent, modal);
|
||||
initComponents();
|
||||
imageFolderPath.setEditable(false);
|
||||
cbProxyType.setModel(new DefaultComboBoxModel(Connection.ProxyType.values()));
|
||||
addAvatars();
|
||||
cbProxyType.setModel(new DefaultComboBoxModel(Connection.ProxyType.values()));
|
||||
addAvatars();
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
|
@ -939,26 +939,26 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
save(prefs, dialog.checkBoxEndTurnOthers, END_OF_TURN_OTHERS);
|
||||
save(prefs, dialog.displayBigCardsInHand, KEY_HAND_USE_BIG_CARDS, "true", "false", UPDATE_CACHE_POLICY);
|
||||
save(prefs, dialog.showToolTipsInAnyZone, KEY_SHOW_TOOLTIPS_ANY_ZONE, "true", "false", UPDATE_CACHE_POLICY);
|
||||
save(prefs, dialog.nonLandPermanentsInOnePile, KEY_PERMANENTS_IN_ONE_PILE, "true", "false", UPDATE_CACHE_POLICY);
|
||||
save(prefs, dialog.nonLandPermanentsInOnePile, KEY_PERMANENTS_IN_ONE_PILE, "true", "false", UPDATE_CACHE_POLICY);
|
||||
|
||||
// connection
|
||||
// connection
|
||||
save(prefs, dialog.cbProxyType, KEY_PROXY_TYPE);
|
||||
save(prefs, dialog.txtProxyServer, KEY_PROXY_ADDRESS);
|
||||
save(prefs, dialog.txtProxyPort, KEY_PROXY_PORT);
|
||||
save(prefs, dialog.txtProxyUserName, KEY_PROXY_USERNAME);
|
||||
save(prefs, dialog.rememberPswd, KEY_PROXY_REMEMBER, "true", "false", UPDATE_CACHE_POLICY);
|
||||
if (dialog.rememberPswd.isSelected()) {
|
||||
char[] input = txtPasswordField.getPassword();
|
||||
prefs.put(KEY_PROXY_PSWD, new String(input));
|
||||
}
|
||||
save(prefs, dialog.txtProxyServer, KEY_PROXY_ADDRESS);
|
||||
save(prefs, dialog.txtProxyPort, KEY_PROXY_PORT);
|
||||
save(prefs, dialog.txtProxyUserName, KEY_PROXY_USERNAME);
|
||||
save(prefs, dialog.rememberPswd, KEY_PROXY_REMEMBER, "true", "false", UPDATE_CACHE_POLICY);
|
||||
if (dialog.rememberPswd.isSelected()) {
|
||||
char[] input = txtPasswordField.getPassword();
|
||||
prefs.put(KEY_PROXY_PSWD, new String(input));
|
||||
}
|
||||
|
||||
if (availableAvatars.contains(selectedId)) {
|
||||
prefs.put(KEY_AVATAR, String.valueOf(selectedId));
|
||||
updateCache(KEY_AVATAR, String.valueOf(selectedId));
|
||||
}
|
||||
if (availableAvatars.contains(selectedId)) {
|
||||
prefs.put(KEY_AVATAR, String.valueOf(selectedId));
|
||||
updateCache(KEY_AVATAR, String.valueOf(selectedId));
|
||||
}
|
||||
|
||||
// images
|
||||
saveImagesPath(prefs);
|
||||
// images
|
||||
saveImagesPath(prefs);
|
||||
|
||||
try {
|
||||
prefs.flush();
|
||||
|
@ -1012,13 +1012,13 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
|
||||
private void cbProxyTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbProxyTypeActionPerformed
|
||||
this.showProxySettings();
|
||||
}//GEN-LAST:event_cbProxyTypeActionPerformed
|
||||
}//GEN-LAST:event_cbProxyTypeActionPerformed
|
||||
|
||||
private void txtPasswordFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtPasswordFieldActionPerformed
|
||||
}//GEN-LAST:event_txtPasswordFieldActionPerformed
|
||||
}//GEN-LAST:event_txtPasswordFieldActionPerformed
|
||||
|
||||
private void txtProxyPortkeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtProxyPortkeyTyped
|
||||
}//GEN-LAST:event_txtProxyPortkeyTyped
|
||||
}//GEN-LAST:event_txtProxyPortkeyTyped
|
||||
|
||||
private void nonLandPermanentsInOnePileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nonLandPermanentsInOnePileActionPerformed
|
||||
}//GEN-LAST:event_nonLandPermanentsInOnePileActionPerformed
|
||||
|
@ -1026,126 +1026,126 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
private void rememberPswdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rememberPswdActionPerformed
|
||||
}//GEN-LAST:event_rememberPswdActionPerformed
|
||||
|
||||
private void showProxySettings() {
|
||||
if (cbProxyType.getSelectedItem() == Connection.ProxyType.SOCKS) {
|
||||
this.pnlProxy.setVisible(true);
|
||||
this.pnlProxySettings.setVisible(true);
|
||||
}
|
||||
else if (cbProxyType.getSelectedItem() == Connection.ProxyType.HTTP) {
|
||||
this.pnlProxy.setVisible(true);
|
||||
this.pnlProxySettings.setVisible(true);
|
||||
}
|
||||
else if (cbProxyType.getSelectedItem() == Connection.ProxyType.NONE) {
|
||||
this.pnlProxy.setVisible(false);
|
||||
this.pnlProxySettings.setVisible(false);
|
||||
}
|
||||
this.pack();
|
||||
this.repaint();
|
||||
}
|
||||
private void showProxySettings() {
|
||||
if (cbProxyType.getSelectedItem() == Connection.ProxyType.SOCKS) {
|
||||
this.pnlProxy.setVisible(true);
|
||||
this.pnlProxySettings.setVisible(true);
|
||||
}
|
||||
else if (cbProxyType.getSelectedItem() == Connection.ProxyType.HTTP) {
|
||||
this.pnlProxy.setVisible(true);
|
||||
this.pnlProxySettings.setVisible(true);
|
||||
}
|
||||
else if (cbProxyType.getSelectedItem() == Connection.ProxyType.NONE) {
|
||||
this.pnlProxy.setVisible(false);
|
||||
this.pnlProxySettings.setVisible(false);
|
||||
}
|
||||
this.pack();
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
int param = 0;
|
||||
if (args.length > 0) {
|
||||
String param1 = args[0];
|
||||
if (param1.equals(OPEN_CONNECTION_TAB)) {
|
||||
param = 3;
|
||||
}
|
||||
}
|
||||
final int openedTab = param;
|
||||
int param = 0;
|
||||
if (args.length > 0) {
|
||||
String param1 = args[0];
|
||||
if (param1.equals(OPEN_CONNECTION_TAB)) {
|
||||
param = 3;
|
||||
}
|
||||
}
|
||||
final int openedTab = param;
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
if (!dialog.isVisible()) {
|
||||
Preferences prefs = MageFrame.getPreferences();
|
||||
public void run() {
|
||||
if (!dialog.isVisible()) {
|
||||
Preferences prefs = MageFrame.getPreferences();
|
||||
|
||||
// Phases
|
||||
loadPhases(prefs);
|
||||
// Phases
|
||||
loadPhases(prefs);
|
||||
|
||||
// Connection
|
||||
loadProxySettings(prefs);
|
||||
// Connection
|
||||
loadProxySettings(prefs);
|
||||
|
||||
// Selected avatar
|
||||
loadSelectedAvatar(prefs);
|
||||
// Selected avatar
|
||||
loadSelectedAvatar(prefs);
|
||||
|
||||
// Images
|
||||
loadImagesPath(prefs);
|
||||
// Images
|
||||
loadImagesPath(prefs);
|
||||
|
||||
// open specified tab before displaying
|
||||
openTab(openedTab);
|
||||
// open specified tab before displaying
|
||||
openTab(openedTab);
|
||||
|
||||
dialog.setLocation(300, 200);
|
||||
dialog.reset();
|
||||
dialog.setLocation(300, 200);
|
||||
dialog.reset();
|
||||
|
||||
dialog.setVisible(true);
|
||||
} else {
|
||||
dialog.requestFocus();
|
||||
}
|
||||
}
|
||||
});
|
||||
dialog.setVisible(true);
|
||||
} else {
|
||||
dialog.requestFocus();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void loadPhases(Preferences prefs) {
|
||||
load(prefs, dialog.checkBoxUpkeepYou, UPKEEP_YOU);
|
||||
load(prefs, dialog.checkBoxDrawYou, DRAW_YOU);
|
||||
load(prefs, dialog.checkBoxMainYou, MAIN_YOU);
|
||||
load(prefs, dialog.checkBoxBeforeCYou, BEFORE_COMBAT_YOU);
|
||||
load(prefs, dialog.checkBoxEndOfCYou, END_OF_COMBAT_YOU);
|
||||
load(prefs, dialog.checkBoxMain2You, MAIN_2_YOU);
|
||||
load(prefs, dialog.checkBoxEndTurnYou, END_OF_TURN_YOU);
|
||||
private static void loadPhases(Preferences prefs) {
|
||||
load(prefs, dialog.checkBoxUpkeepYou, UPKEEP_YOU);
|
||||
load(prefs, dialog.checkBoxDrawYou, DRAW_YOU);
|
||||
load(prefs, dialog.checkBoxMainYou, MAIN_YOU);
|
||||
load(prefs, dialog.checkBoxBeforeCYou, BEFORE_COMBAT_YOU);
|
||||
load(prefs, dialog.checkBoxEndOfCYou, END_OF_COMBAT_YOU);
|
||||
load(prefs, dialog.checkBoxMain2You, MAIN_2_YOU);
|
||||
load(prefs, dialog.checkBoxEndTurnYou, END_OF_TURN_YOU);
|
||||
|
||||
load(prefs, dialog.checkBoxUpkeepOthers, UPKEEP_OTHERS);
|
||||
load(prefs, dialog.checkBoxDrawOthers, DRAW_OTHERS);
|
||||
load(prefs, dialog.checkBoxMainOthers, MAIN_OTHERS);
|
||||
load(prefs, dialog.checkBoxBeforeCOthers, BEFORE_COMBAT_OTHERS);
|
||||
load(prefs, dialog.checkBoxEndOfCOthers, END_OF_COMBAT_OTHERS);
|
||||
load(prefs, dialog.checkBoxMain2Others, MAIN_2_OTHERS);
|
||||
load(prefs, dialog.checkBoxEndTurnOthers, END_OF_TURN_OTHERS);
|
||||
load(prefs, dialog.displayBigCardsInHand, KEY_HAND_USE_BIG_CARDS, "true");
|
||||
load(prefs, dialog.showToolTipsInAnyZone, KEY_SHOW_TOOLTIPS_ANY_ZONE, "true");
|
||||
load(prefs, dialog.nonLandPermanentsInOnePile, KEY_PERMANENTS_IN_ONE_PILE, "true");
|
||||
}
|
||||
load(prefs, dialog.checkBoxUpkeepOthers, UPKEEP_OTHERS);
|
||||
load(prefs, dialog.checkBoxDrawOthers, DRAW_OTHERS);
|
||||
load(prefs, dialog.checkBoxMainOthers, MAIN_OTHERS);
|
||||
load(prefs, dialog.checkBoxBeforeCOthers, BEFORE_COMBAT_OTHERS);
|
||||
load(prefs, dialog.checkBoxEndOfCOthers, END_OF_COMBAT_OTHERS);
|
||||
load(prefs, dialog.checkBoxMain2Others, MAIN_2_OTHERS);
|
||||
load(prefs, dialog.checkBoxEndTurnOthers, END_OF_TURN_OTHERS);
|
||||
load(prefs, dialog.displayBigCardsInHand, KEY_HAND_USE_BIG_CARDS, "true");
|
||||
load(prefs, dialog.showToolTipsInAnyZone, KEY_SHOW_TOOLTIPS_ANY_ZONE, "true");
|
||||
load(prefs, dialog.nonLandPermanentsInOnePile, KEY_PERMANENTS_IN_ONE_PILE, "true");
|
||||
}
|
||||
|
||||
private static void loadProxySettings(Preferences prefs) {
|
||||
dialog.cbProxyType.setSelectedItem(Connection.ProxyType.valueOf(MageFrame.getPreferences().get(KEY_PROXY_TYPE, "NONE").toUpperCase()));
|
||||
private static void loadProxySettings(Preferences prefs) {
|
||||
dialog.cbProxyType.setSelectedItem(Connection.ProxyType.valueOf(MageFrame.getPreferences().get(KEY_PROXY_TYPE, "NONE").toUpperCase()));
|
||||
|
||||
load(prefs, dialog.txtProxyServer, KEY_PROXY_ADDRESS, Config.serverName);
|
||||
load(prefs, dialog.txtProxyPort, KEY_PROXY_PORT, Integer.toString(Config.port));
|
||||
load(prefs, dialog.txtProxyUserName, KEY_PROXY_USERNAME, "");
|
||||
load(prefs, dialog.rememberPswd, KEY_PROXY_REMEMBER, "true", "false");
|
||||
if (dialog.rememberPswd.isSelected()) {
|
||||
load(prefs, dialog.txtPasswordField, KEY_PROXY_PSWD, "");
|
||||
}
|
||||
}
|
||||
load(prefs, dialog.txtProxyServer, KEY_PROXY_ADDRESS, Config.serverName);
|
||||
load(prefs, dialog.txtProxyPort, KEY_PROXY_PORT, Integer.toString(Config.port));
|
||||
load(prefs, dialog.txtProxyUserName, KEY_PROXY_USERNAME, "");
|
||||
load(prefs, dialog.rememberPswd, KEY_PROXY_REMEMBER, "true", "false");
|
||||
if (dialog.rememberPswd.isSelected()) {
|
||||
load(prefs, dialog.txtPasswordField, KEY_PROXY_PSWD, "");
|
||||
}
|
||||
}
|
||||
|
||||
private static void loadSelectedAvatar(Preferences prefs) {
|
||||
getSelectedAvatar();
|
||||
dialog.setSelectedId(selectedId);
|
||||
}
|
||||
private static void loadSelectedAvatar(Preferences prefs) {
|
||||
getSelectedAvatar();
|
||||
dialog.setSelectedId(selectedId);
|
||||
}
|
||||
|
||||
public static int getSelectedAvatar() {
|
||||
try {
|
||||
selectedId = Integer.valueOf(MageFrame.getPreferences().get(KEY_AVATAR, String.valueOf(DEFAULT_AVATAR_ID)));
|
||||
} catch (NumberFormatException n) {
|
||||
selectedId = DEFAULT_AVATAR_ID;
|
||||
} finally {
|
||||
if (!availableAvatars.contains(selectedId)) {
|
||||
selectedId = DEFAULT_AVATAR_ID;
|
||||
}
|
||||
}
|
||||
return selectedId;
|
||||
}
|
||||
public static int getSelectedAvatar() {
|
||||
try {
|
||||
selectedId = Integer.valueOf(MageFrame.getPreferences().get(KEY_AVATAR, String.valueOf(DEFAULT_AVATAR_ID)));
|
||||
} catch (NumberFormatException n) {
|
||||
selectedId = DEFAULT_AVATAR_ID;
|
||||
} finally {
|
||||
if (!availableAvatars.contains(selectedId)) {
|
||||
selectedId = DEFAULT_AVATAR_ID;
|
||||
}
|
||||
}
|
||||
return selectedId;
|
||||
}
|
||||
|
||||
private static void openTab(int index) {
|
||||
try {
|
||||
if (index > 0) {
|
||||
dialog.jTabbedPane1.setSelectedIndex(3);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
private static void openTab(int index) {
|
||||
try {
|
||||
if (index > 0) {
|
||||
dialog.jTabbedPane1.setSelectedIndex(3);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void loadImagesPath(Preferences prefs) {
|
||||
String prop = prefs.get(KEY_CARD_IMAGES_USE_DEFAULT, "true");
|
||||
|
@ -1183,17 +1183,17 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
checkBox.setSelected(prop.equals(yesValue));
|
||||
}
|
||||
|
||||
private static void load(Preferences prefs, JCheckBox checkBox, String propName, String yesValue, String defaultValue) {
|
||||
private static void load(Preferences prefs, JCheckBox checkBox, String propName, String yesValue, String defaultValue) {
|
||||
String prop = prefs.get(propName, defaultValue);
|
||||
checkBox.setSelected(prop.equals(yesValue));
|
||||
}
|
||||
|
||||
private static void load(Preferences prefs, JTextField field, String propName, String defaultValue) {
|
||||
private static void load(Preferences prefs, JTextField field, String propName, String defaultValue) {
|
||||
String prop = prefs.get(propName, defaultValue);
|
||||
field.setText(prop);
|
||||
}
|
||||
|
||||
private static void load(Preferences prefs, JComboBox field, String propName, String defaultValue) {
|
||||
private static void load(Preferences prefs, JComboBox field, String propName, String defaultValue) {
|
||||
String prop = prefs.get(propName, defaultValue);
|
||||
field.setSelectedItem(prop);
|
||||
}
|
||||
|
@ -1213,19 +1213,19 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
}
|
||||
}
|
||||
|
||||
private static void save(Preferences prefs, JTextField textField, String propName) {
|
||||
private static void save(Preferences prefs, JTextField textField, String propName) {
|
||||
prefs.put(propName, textField.getText().trim());
|
||||
updateCache(propName, textField.getText().trim());
|
||||
}
|
||||
|
||||
private static void save(Preferences prefs, JComboBox comboBox, String propName) {
|
||||
prefs.put(propName, comboBox.getSelectedItem().toString().trim());
|
||||
updateCache(propName, comboBox.getSelectedItem().toString().trim());
|
||||
updateCache(propName, textField.getText().trim());
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
jTabbedPane1.setSelectedIndex(0);
|
||||
}
|
||||
private static void save(Preferences prefs, JComboBox comboBox, String propName) {
|
||||
prefs.put(propName, comboBox.getSelectedItem().toString().trim());
|
||||
updateCache(propName, comboBox.getSelectedItem().toString().trim());
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
jTabbedPane1.setSelectedIndex(0);
|
||||
}
|
||||
|
||||
public static String getCachedValue(String key, String def) {
|
||||
if (cache.containsKey(key)) {
|
||||
|
@ -1243,69 +1243,69 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
cache.put(key, value);
|
||||
}
|
||||
|
||||
private void addAvatars() {
|
||||
try {
|
||||
addAvatar(jPanel10, 51, true, false);
|
||||
addAvatar(jPanel13, 13, false, false);
|
||||
addAvatar(jPanel11, 9, false, false);
|
||||
addAvatar(jPanel12, 53, false, false);
|
||||
addAvatar(jPanel14, 10, false, false);
|
||||
addAvatar(jPanel15, 39, false, false);
|
||||
addAvatar(jPanel19, 19, false, false);
|
||||
addAvatar(jPanel20, 30, false, false);
|
||||
addAvatar(jPanel21, 25, false, false);
|
||||
private void addAvatars() {
|
||||
try {
|
||||
addAvatar(jPanel10, 51, true, false);
|
||||
addAvatar(jPanel13, 13, false, false);
|
||||
addAvatar(jPanel11, 9, false, false);
|
||||
addAvatar(jPanel12, 53, false, false);
|
||||
addAvatar(jPanel14, 10, false, false);
|
||||
addAvatar(jPanel15, 39, false, false);
|
||||
addAvatar(jPanel19, 19, false, false);
|
||||
addAvatar(jPanel20, 30, false, false);
|
||||
addAvatar(jPanel21, 25, false, false);
|
||||
|
||||
addAvatar(jPanel16, 22, false, true);
|
||||
addAvatar(jPanel17, 77, false, true);
|
||||
addAvatar(jPanel18, 62, false, true);
|
||||
} catch (Exception e) {
|
||||
log.error(e, e);
|
||||
}
|
||||
}
|
||||
addAvatar(jPanel16, 22, false, true);
|
||||
addAvatar(jPanel17, 77, false, true);
|
||||
addAvatar(jPanel18, 62, false, true);
|
||||
} catch (Exception e) {
|
||||
log.error(e, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSelectedId(int id) {
|
||||
if (availableAvatars.contains(id)) {
|
||||
for (JPanel panel : panels.values()) {
|
||||
panel.setBorder(BLACK_BORDER);
|
||||
}
|
||||
this.selectedId = id;
|
||||
panels.get(this.selectedId).setBorder(GREEN_BORDER);
|
||||
}
|
||||
}
|
||||
public void setSelectedId(int id) {
|
||||
if (availableAvatars.contains(id)) {
|
||||
for (JPanel panel : panels.values()) {
|
||||
panel.setBorder(BLACK_BORDER);
|
||||
}
|
||||
this.selectedId = id;
|
||||
panels.get(this.selectedId).setBorder(GREEN_BORDER);
|
||||
}
|
||||
}
|
||||
|
||||
private void addAvatar(JPanel jPanel, final int id, boolean selected, boolean locked) {
|
||||
String path = "/avatars/" + String.valueOf(id) + ".jpg";
|
||||
panels.put(id, jPanel);
|
||||
Image image = ImageHelper.getImageFromResources(path);
|
||||
Rectangle r = new Rectangle(90, 90);
|
||||
BufferedImage bufferedImage;
|
||||
if (!locked) {
|
||||
bufferedImage = BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB);
|
||||
} else {
|
||||
bufferedImage = BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB, new Color(150, 150, 150, 170));
|
||||
}
|
||||
BufferedImage resized = ImageHelper.getResizedImage(bufferedImage, r);
|
||||
final JLabel jLabel = new JLabel();
|
||||
jLabel.setIcon(new ImageIcon(resized));
|
||||
if (selected) {
|
||||
jPanel.setBorder(GREEN_BORDER);
|
||||
} else {
|
||||
jPanel.setBorder(BLACK_BORDER);
|
||||
}
|
||||
jPanel.setLayout(new BorderLayout());
|
||||
jPanel.add(jLabel);
|
||||
if (!locked) {
|
||||
jLabel.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (selectedId != id) {
|
||||
setSelectedId(id);
|
||||
MageFrame.getSession().updateAvatar(id);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
private void addAvatar(JPanel jPanel, final int id, boolean selected, boolean locked) {
|
||||
String path = "/avatars/" + String.valueOf(id) + ".jpg";
|
||||
panels.put(id, jPanel);
|
||||
Image image = ImageHelper.getImageFromResources(path);
|
||||
Rectangle r = new Rectangle(90, 90);
|
||||
BufferedImage bufferedImage;
|
||||
if (!locked) {
|
||||
bufferedImage = BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB);
|
||||
} else {
|
||||
bufferedImage = BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB, new Color(150, 150, 150, 170));
|
||||
}
|
||||
BufferedImage resized = ImageHelper.getResizedImage(bufferedImage, r);
|
||||
final JLabel jLabel = new JLabel();
|
||||
jLabel.setIcon(new ImageIcon(resized));
|
||||
if (selected) {
|
||||
jPanel.setBorder(GREEN_BORDER);
|
||||
} else {
|
||||
jPanel.setBorder(BLACK_BORDER);
|
||||
}
|
||||
jPanel.setLayout(new BorderLayout());
|
||||
jPanel.add(jLabel);
|
||||
if (!locked) {
|
||||
jLabel.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (selectedId != id) {
|
||||
setSelectedId(id);
|
||||
MageFrame.getSession().updateAvatar(id);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton browseButton;
|
||||
|
|
|
@ -41,22 +41,22 @@ package mage.client.dialog;
|
|||
*/
|
||||
public class QuestionDialog extends MageDialog {
|
||||
|
||||
private boolean answer;
|
||||
private boolean answer;
|
||||
|
||||
/** Creates new form QuestionDialog */
|
||||
public QuestionDialog() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
public void showDialog(String question) {
|
||||
this.lblQuestion.setText(question);
|
||||
this.setModal(true);
|
||||
this.setVisible(true);
|
||||
}
|
||||
public void showDialog(String question) {
|
||||
this.lblQuestion.setText(question);
|
||||
this.setModal(true);
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
public boolean getAnswer() {
|
||||
return answer;
|
||||
}
|
||||
public boolean getAnswer() {
|
||||
return answer;
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
@ -117,15 +117,15 @@ public class QuestionDialog extends MageDialog {
|
|||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void btnYesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnYesActionPerformed
|
||||
this.answer = true;
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnYesActionPerformed
|
||||
private void btnYesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnYesActionPerformed
|
||||
this.answer = true;
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnYesActionPerformed
|
||||
|
||||
private void btnNoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNoActionPerformed
|
||||
this.answer = false;
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnNoActionPerformed
|
||||
private void btnNoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNoActionPerformed
|
||||
this.answer = false;
|
||||
this.hideDialog();
|
||||
}//GEN-LAST:event_btnNoActionPerformed
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
|
|
@ -57,91 +57,91 @@ import mage.view.SimpleCardsView;
|
|||
*/
|
||||
public class ShowCardsDialog extends MageDialog implements MouseListener {
|
||||
|
||||
private boolean reloaded = false;
|
||||
private boolean reloaded = false;
|
||||
|
||||
/**
|
||||
* Creates new form ShowCardsDialog
|
||||
*/
|
||||
public ShowCardsDialog() {
|
||||
initComponents();
|
||||
this.setModal(false);
|
||||
}
|
||||
/**
|
||||
* Creates new form ShowCardsDialog
|
||||
*/
|
||||
public ShowCardsDialog() {
|
||||
initComponents();
|
||||
this.setModal(false);
|
||||
}
|
||||
|
||||
public void loadCards(String name, SimpleCardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, boolean modal) {
|
||||
public void loadCards(String name, SimpleCardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, boolean modal) {
|
||||
loadCards(name, CardsViewUtil.convertSimple(showCards), bigCard, dimension, gameId, modal);
|
||||
}
|
||||
|
||||
|
||||
public void loadCards(String name, CardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, boolean modal) {
|
||||
this.reloaded = true;
|
||||
this.title = name;
|
||||
cardArea.loadCards(showCards, bigCard, dimension, gameId, this);
|
||||
if (getParent() != MageFrame.getDesktop() /*|| this.isClosed*/) {
|
||||
MageFrame.getDesktop().add(this, JLayeredPane.POPUP_LAYER);
|
||||
}
|
||||
pack();
|
||||
this.reloaded = true;
|
||||
this.title = name;
|
||||
cardArea.loadCards(showCards, bigCard, dimension, gameId, this);
|
||||
if (getParent() != MageFrame.getDesktop() /*|| this.isClosed*/) {
|
||||
MageFrame.getDesktop().add(this, JLayeredPane.POPUP_LAYER);
|
||||
}
|
||||
pack();
|
||||
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
this.setModal(modal);
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
this.setModal(modal);
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int width = ShowCardsDialog.this.getWidth();
|
||||
int height = ShowCardsDialog.this.getWidth();
|
||||
if (width > 0 && height > 0) {
|
||||
Point centered = SettingsManager.getInstance().getComponentPosition(width, height);
|
||||
ShowCardsDialog.this.setLocation(centered.x, centered.y);
|
||||
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, ShowCardsDialog.this);
|
||||
}
|
||||
ShowCardsDialog.this.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int width = ShowCardsDialog.this.getWidth();
|
||||
int height = ShowCardsDialog.this.getWidth();
|
||||
if (width > 0 && height > 0) {
|
||||
Point centered = SettingsManager.getInstance().getComponentPosition(width, height);
|
||||
ShowCardsDialog.this.setLocation(centered.x, centered.y);
|
||||
GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, ShowCardsDialog.this);
|
||||
}
|
||||
ShowCardsDialog.this.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isReloaded() {
|
||||
return this.reloaded;
|
||||
}
|
||||
public boolean isReloaded() {
|
||||
return this.reloaded;
|
||||
}
|
||||
|
||||
public void clearReloaded() {
|
||||
this.reloaded = false;
|
||||
}
|
||||
public void clearReloaded() {
|
||||
this.reloaded = false;
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
private void initComponents() {
|
||||
|
||||
cardArea = new CardArea();
|
||||
cardArea = new CardArea();
|
||||
|
||||
setClosable(true);
|
||||
setResizable(true);
|
||||
getContentPane().setLayout(new java.awt.BorderLayout());
|
||||
getContentPane().add(cardArea, java.awt.BorderLayout.CENTER);
|
||||
setClosable(true);
|
||||
setResizable(true);
|
||||
getContentPane().setLayout(new java.awt.BorderLayout());
|
||||
getContentPane().add(cardArea, java.awt.BorderLayout.CENTER);
|
||||
this.addMouseListener(this);
|
||||
|
||||
pack();
|
||||
}
|
||||
|
||||
private CardArea cardArea;
|
||||
pack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
this.hideDialog();
|
||||
}
|
||||
private CardArea cardArea;
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
this.hideDialog();
|
||||
}
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
this.hideDialog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
}
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
this.hideDialog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
}
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -54,92 +54,92 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class TableWaitingDialog extends MageDialog {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(TableWaitingDialog.class);
|
||||
private final static Logger logger = Logger.getLogger(TableWaitingDialog.class);
|
||||
|
||||
private UUID tableId;
|
||||
private UUID roomId;
|
||||
private boolean isTournament;
|
||||
private Session session;
|
||||
private TableWaitModel tableWaitModel;
|
||||
private UpdateSeatsTask updateTask;
|
||||
private UUID tableId;
|
||||
private UUID roomId;
|
||||
private boolean isTournament;
|
||||
private Session session;
|
||||
private TableWaitModel tableWaitModel;
|
||||
private UpdateSeatsTask updateTask;
|
||||
|
||||
/** Creates new form TableWaitingDialog */
|
||||
public TableWaitingDialog() {
|
||||
|
||||
session = MageFrame.getSession();
|
||||
tableWaitModel = new TableWaitModel();
|
||||
session = MageFrame.getSession();
|
||||
tableWaitModel = new TableWaitModel();
|
||||
|
||||
initComponents();
|
||||
initComponents();
|
||||
|
||||
chatPanel.useExtendedView(ChatPanel.VIEW_MODE.NONE);
|
||||
tableSeats.createDefaultColumnsFromModel();
|
||||
MageFrame.getUI().addButton(MageComponents.TABLE_WAITING_START_BUTTON, btnStart);
|
||||
tableSeats.createDefaultColumnsFromModel();
|
||||
MageFrame.getUI().addButton(MageComponents.TABLE_WAITING_START_BUTTON, btnStart);
|
||||
}
|
||||
|
||||
public void update(TableView table) {
|
||||
try {
|
||||
if (table != null) {
|
||||
switch (table.getTableState()) {
|
||||
case STARTING:
|
||||
this.btnStart.setEnabled(true);
|
||||
this.btnMoveDown.setEnabled(true);
|
||||
this.btnMoveUp.setEnabled(true);
|
||||
break;
|
||||
case WAITING:
|
||||
this.btnStart.setEnabled(false);
|
||||
this.btnMoveDown.setEnabled(false);
|
||||
this.btnMoveUp.setEnabled(false);
|
||||
break;
|
||||
default:
|
||||
closeDialog();
|
||||
return;
|
||||
}
|
||||
int row = this.tableSeats.getSelectedRow();
|
||||
tableWaitModel.loadData(table);
|
||||
this.tableSeats.repaint();
|
||||
this.tableSeats.getSelectionModel().setSelectionInterval(row, row);
|
||||
}
|
||||
else {
|
||||
closeDialog();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
closeDialog();
|
||||
}
|
||||
}
|
||||
public void update(TableView table) {
|
||||
try {
|
||||
if (table != null) {
|
||||
switch (table.getTableState()) {
|
||||
case STARTING:
|
||||
this.btnStart.setEnabled(true);
|
||||
this.btnMoveDown.setEnabled(true);
|
||||
this.btnMoveUp.setEnabled(true);
|
||||
break;
|
||||
case WAITING:
|
||||
this.btnStart.setEnabled(false);
|
||||
this.btnMoveDown.setEnabled(false);
|
||||
this.btnMoveUp.setEnabled(false);
|
||||
break;
|
||||
default:
|
||||
closeDialog();
|
||||
return;
|
||||
}
|
||||
int row = this.tableSeats.getSelectedRow();
|
||||
tableWaitModel.loadData(table);
|
||||
this.tableSeats.repaint();
|
||||
this.tableSeats.getSelectionModel().setSelectionInterval(row, row);
|
||||
}
|
||||
else {
|
||||
closeDialog();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
closeDialog();
|
||||
}
|
||||
}
|
||||
|
||||
public void showDialog(UUID roomId, UUID tableId, boolean isTournament) {
|
||||
this.roomId = roomId;
|
||||
this.tableId = tableId;
|
||||
this.isTournament = isTournament;
|
||||
session = MageFrame.getSession();
|
||||
updateTask = new UpdateSeatsTask(session, roomId, tableId, this);
|
||||
if (session.isTableOwner(roomId, tableId)) {
|
||||
this.btnStart.setVisible(true);
|
||||
this.btnMoveDown.setVisible(true);
|
||||
this.btnMoveUp.setVisible(true);
|
||||
} else {
|
||||
this.btnStart.setVisible(false);
|
||||
this.btnMoveDown.setVisible(false);
|
||||
this.btnMoveUp.setVisible(false);
|
||||
}
|
||||
UUID chatId = session.getTableChatId(tableId);
|
||||
if (chatId != null) {
|
||||
this.chatPanel.connect(chatId);
|
||||
updateTask.execute();
|
||||
this.setModal(false);
|
||||
this.setLocation(100, 100);
|
||||
this.setVisible(true);
|
||||
}
|
||||
else {
|
||||
closeDialog();
|
||||
}
|
||||
}
|
||||
public void showDialog(UUID roomId, UUID tableId, boolean isTournament) {
|
||||
this.roomId = roomId;
|
||||
this.tableId = tableId;
|
||||
this.isTournament = isTournament;
|
||||
session = MageFrame.getSession();
|
||||
updateTask = new UpdateSeatsTask(session, roomId, tableId, this);
|
||||
if (session.isTableOwner(roomId, tableId)) {
|
||||
this.btnStart.setVisible(true);
|
||||
this.btnMoveDown.setVisible(true);
|
||||
this.btnMoveUp.setVisible(true);
|
||||
} else {
|
||||
this.btnStart.setVisible(false);
|
||||
this.btnMoveDown.setVisible(false);
|
||||
this.btnMoveUp.setVisible(false);
|
||||
}
|
||||
UUID chatId = session.getTableChatId(tableId);
|
||||
if (chatId != null) {
|
||||
this.chatPanel.connect(chatId);
|
||||
updateTask.execute();
|
||||
this.setModal(false);
|
||||
this.setLocation(100, 100);
|
||||
this.setVisible(true);
|
||||
}
|
||||
else {
|
||||
closeDialog();
|
||||
}
|
||||
}
|
||||
|
||||
public void closeDialog() {
|
||||
if (updateTask != null) updateTask.cancel(true);
|
||||
this.chatPanel.disconnect();
|
||||
this.hideDialog();
|
||||
}
|
||||
public void closeDialog() {
|
||||
if (updateTask != null) updateTask.cancel(true);
|
||||
this.chatPanel.disconnect();
|
||||
this.hideDialog();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -239,44 +239,44 @@ public class TableWaitingDialog extends MageDialog {
|
|||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void btnStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStartActionPerformed
|
||||
closeDialog();
|
||||
if (!isTournament)
|
||||
session.startGame(roomId, tableId);
|
||||
else
|
||||
session.startTournament(roomId, tableId);
|
||||
}//GEN-LAST:event_btnStartActionPerformed
|
||||
private void btnStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStartActionPerformed
|
||||
closeDialog();
|
||||
if (!isTournament)
|
||||
session.startGame(roomId, tableId);
|
||||
else
|
||||
session.startTournament(roomId, tableId);
|
||||
}//GEN-LAST:event_btnStartActionPerformed
|
||||
|
||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||
try {
|
||||
if (session.isTableOwner(roomId, tableId)) {
|
||||
session.removeTable(roomId, tableId);
|
||||
} else {
|
||||
session.leaveTable(roomId, tableId);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//swallow exception
|
||||
logger.error(e);
|
||||
}
|
||||
closeDialog();
|
||||
}//GEN-LAST:event_btnCancelActionPerformed
|
||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||
try {
|
||||
if (session.isTableOwner(roomId, tableId)) {
|
||||
session.removeTable(roomId, tableId);
|
||||
} else {
|
||||
session.leaveTable(roomId, tableId);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//swallow exception
|
||||
logger.error(e);
|
||||
}
|
||||
closeDialog();
|
||||
}//GEN-LAST:event_btnCancelActionPerformed
|
||||
|
||||
private void btnMoveDownActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMoveDownActionPerformed
|
||||
int row = this.tableSeats.getSelectedRow();
|
||||
if (row < this.tableSeats.getRowCount() - 1) {
|
||||
session.swapSeats(roomId, tableId, row, row + 1);
|
||||
this.tableSeats.getSelectionModel().setSelectionInterval(row + 1, row + 1);
|
||||
}
|
||||
private void btnMoveDownActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMoveDownActionPerformed
|
||||
int row = this.tableSeats.getSelectedRow();
|
||||
if (row < this.tableSeats.getRowCount() - 1) {
|
||||
session.swapSeats(roomId, tableId, row, row + 1);
|
||||
this.tableSeats.getSelectionModel().setSelectionInterval(row + 1, row + 1);
|
||||
}
|
||||
|
||||
}//GEN-LAST:event_btnMoveDownActionPerformed
|
||||
}//GEN-LAST:event_btnMoveDownActionPerformed
|
||||
|
||||
private void btnMoveUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMoveUpActionPerformed
|
||||
int row = this.tableSeats.getSelectedRow();
|
||||
if (row > 0) {
|
||||
session.swapSeats(roomId, tableId, row, row - 1);
|
||||
this.tableSeats.getSelectionModel().setSelectionInterval(row - 1, row - 1);
|
||||
}
|
||||
}//GEN-LAST:event_btnMoveUpActionPerformed
|
||||
private void btnMoveUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMoveUpActionPerformed
|
||||
int row = this.tableSeats.getSelectedRow();
|
||||
if (row > 0) {
|
||||
session.swapSeats(roomId, tableId, row, row - 1);
|
||||
this.tableSeats.getSelectionModel().setSelectionInterval(row - 1, row - 1);
|
||||
}
|
||||
}//GEN-LAST:event_btnMoveUpActionPerformed
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
@ -294,45 +294,45 @@ public class TableWaitingDialog extends MageDialog {
|
|||
|
||||
class TableWaitModel extends AbstractTableModel {
|
||||
private String[] columnNames = new String[]{"Seat Num", "Player Name", "Player Type"};
|
||||
private SeatView[] seats = new SeatView[0];
|
||||
private SeatView[] seats = new SeatView[0];
|
||||
|
||||
public void loadData(TableView table) {
|
||||
seats = table.getSeats().toArray(new SeatView[0]);
|
||||
this.fireTableDataChanged();
|
||||
}
|
||||
public void loadData(TableView table) {
|
||||
seats = table.getSeats().toArray(new SeatView[0]);
|
||||
this.fireTableDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return seats.length;
|
||||
}
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return seats.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return columnNames.length;
|
||||
}
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return columnNames.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int arg0, int arg1) {
|
||||
if (seats[arg0].getPlayerId() == null) {
|
||||
if (arg1 == 0) {
|
||||
return Integer.toString(arg0 + 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (arg1) {
|
||||
case 0:
|
||||
return Integer.toString(arg0 + 1);
|
||||
case 1:
|
||||
return seats[arg0].getPlayerName();
|
||||
case 2:
|
||||
return seats[arg0].getPlayerType();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@Override
|
||||
public Object getValueAt(int arg0, int arg1) {
|
||||
if (seats[arg0].getPlayerId() == null) {
|
||||
if (arg1 == 0) {
|
||||
return Integer.toString(arg0 + 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (arg1) {
|
||||
case 0:
|
||||
return Integer.toString(arg0 + 1);
|
||||
case 1:
|
||||
return seats[arg0].getPlayerName();
|
||||
case 2:
|
||||
return seats[arg0].getPlayerType();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnName(int columnIndex) {
|
||||
@Override
|
||||
public String getColumnName(int columnIndex) {
|
||||
String colName = "";
|
||||
|
||||
if (columnIndex <= getColumnCount())
|
||||
|
@ -341,57 +341,57 @@ class TableWaitModel extends AbstractTableModel {
|
|||
return colName;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Class getColumnClass(int columnIndex){
|
||||
return String.class;
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class UpdateSeatsTask extends SwingWorker<Void, TableView> {
|
||||
|
||||
private Session session;
|
||||
private UUID roomId;
|
||||
private UUID tableId;
|
||||
private TableWaitingDialog dialog;
|
||||
private Session session;
|
||||
private UUID roomId;
|
||||
private UUID tableId;
|
||||
private TableWaitingDialog dialog;
|
||||
|
||||
private final static Logger logger = Logger.getLogger(TableWaitingDialog.class);
|
||||
private final static Logger logger = Logger.getLogger(TableWaitingDialog.class);
|
||||
|
||||
UpdateSeatsTask(Session session, UUID roomId, UUID tableId, TableWaitingDialog dialog) {
|
||||
this.session = session;
|
||||
this.roomId = roomId;
|
||||
this.tableId = tableId;
|
||||
this.dialog = dialog;
|
||||
}
|
||||
UpdateSeatsTask(Session session, UUID roomId, UUID tableId, TableWaitingDialog dialog) {
|
||||
this.session = session;
|
||||
this.roomId = roomId;
|
||||
this.tableId = tableId;
|
||||
this.dialog = dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
while (!isCancelled()) {
|
||||
this.publish(session.getTable(roomId, tableId));
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
while (!isCancelled()) {
|
||||
this.publish(session.getTable(roomId, tableId));
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void process(List<TableView> view) {
|
||||
dialog.update(view.get(0));
|
||||
}
|
||||
@Override
|
||||
protected void process(List<TableView> view) {
|
||||
dialog.update(view.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
try {
|
||||
get();
|
||||
} catch (InterruptedException ex) {
|
||||
logger.fatal("Update Seats Task error", ex);
|
||||
} catch (ExecutionException ex) {
|
||||
logger.fatal("Update Seats Task error", ex);
|
||||
} catch (CancellationException ex) {}
|
||||
}
|
||||
@Override
|
||||
protected void done() {
|
||||
try {
|
||||
get();
|
||||
} catch (InterruptedException ex) {
|
||||
logger.fatal("Update Seats Task error", ex);
|
||||
} catch (ExecutionException ex) {
|
||||
logger.fatal("Update Seats Task error", ex);
|
||||
} catch (CancellationException ex) {}
|
||||
}
|
||||
|
||||
}
|
|
@ -48,15 +48,15 @@ public class DraftPane extends MagePane {
|
|||
initComponents();
|
||||
}
|
||||
|
||||
public void showDraft(UUID draftId) {
|
||||
this.setTitle("Draft - " + draftId);
|
||||
this.draftPanel1.showDraft(draftId);
|
||||
}
|
||||
public void showDraft(UUID draftId) {
|
||||
this.setTitle("Draft - " + draftId);
|
||||
this.draftPanel1.showDraft(draftId);
|
||||
}
|
||||
|
||||
public void hideDraft() {
|
||||
public void hideDraft() {
|
||||
draftPanel1.hideDraft();
|
||||
}
|
||||
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
|
|
|
@ -56,98 +56,98 @@ import java.util.UUID;
|
|||
*/
|
||||
public class DraftPanel extends javax.swing.JPanel {
|
||||
|
||||
private UUID draftId;
|
||||
private Session session;
|
||||
private Timer countdown;
|
||||
private int timeout;
|
||||
private boolean picked;
|
||||
private UUID draftId;
|
||||
private Session session;
|
||||
private Timer countdown;
|
||||
private int timeout;
|
||||
private boolean picked;
|
||||
|
||||
private static CardsView emptyView = new CardsView();
|
||||
|
||||
private static CardsView emptyView = new CardsView();
|
||||
|
||||
/** Creates new form DraftPanel */
|
||||
public DraftPanel() {
|
||||
initComponents();
|
||||
countdown = new Timer(1000,
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (--timeout > 0) {
|
||||
setTimeout(Integer.toString(timeout));
|
||||
}
|
||||
else {
|
||||
setTimeout("0");
|
||||
countdown.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
countdown = new Timer(1000,
|
||||
new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (--timeout > 0) {
|
||||
setTimeout(Integer.toString(timeout));
|
||||
}
|
||||
else {
|
||||
setTimeout("0");
|
||||
countdown.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public synchronized void showDraft(UUID draftId) {
|
||||
this.draftId = draftId;
|
||||
session = MageFrame.getSession();
|
||||
MageFrame.addDraft(draftId, this);
|
||||
if (!session.joinDraft(draftId))
|
||||
hideDraft();
|
||||
}
|
||||
|
||||
public void updateDraft(DraftView draftView) {
|
||||
this.txtPack1.setText(draftView.getSets().get(0));
|
||||
this.txtPack2.setText(draftView.getSets().get(1));
|
||||
this.txtPack3.setText(draftView.getSets().get(2));
|
||||
this.chkPack1.setSelected(draftView.getBoosterNum() > 0);
|
||||
this.chkPack2.setSelected(draftView.getBoosterNum() > 1);
|
||||
this.chkPack3.setSelected(draftView.getBoosterNum() > 2);
|
||||
this.txtCardNo.setText(Integer.toString(draftView.getCardNum()));
|
||||
}
|
||||
public synchronized void showDraft(UUID draftId) {
|
||||
this.draftId = draftId;
|
||||
session = MageFrame.getSession();
|
||||
MageFrame.addDraft(draftId, this);
|
||||
if (!session.joinDraft(draftId))
|
||||
hideDraft();
|
||||
}
|
||||
|
||||
public void loadBooster(DraftPickView draftPickView) {
|
||||
draftBooster.loadBooster(CardsViewUtil.convertSimple(draftPickView.getBooster()), bigCard);
|
||||
draftPicks.loadCards(CardsViewUtil.convertSimple(draftPickView.getPicks()), bigCard, null);
|
||||
this.draftBooster.clearCardEventListeners();
|
||||
this.draftBooster.addCardEventListener(
|
||||
new Listener<Event> () {
|
||||
@Override
|
||||
public void event(Event event) {
|
||||
if (event.getEventName().equals("pick-a-card")) {
|
||||
DraftPickView view = session.sendCardPick(draftId, (UUID)event.getSource());
|
||||
if (view != null) {
|
||||
//draftBooster.loadBooster(view.getBooster(), bigCard);
|
||||
draftBooster.loadBooster(emptyView, bigCard);
|
||||
draftPicks.loadCards(CardsViewUtil.convertSimple(view.getPicks()), bigCard, null);
|
||||
Plugins.getInstance().getActionCallback().hidePopup();
|
||||
setMessage("Waiting for other players");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
setMessage("Pick a card");
|
||||
countdown.stop();
|
||||
this.timeout = draftPickView.getTimeout();
|
||||
setTimeout(Integer.toString(timeout));
|
||||
if (timeout != 0) {
|
||||
countdown.start();
|
||||
}
|
||||
}
|
||||
public void updateDraft(DraftView draftView) {
|
||||
this.txtPack1.setText(draftView.getSets().get(0));
|
||||
this.txtPack2.setText(draftView.getSets().get(1));
|
||||
this.txtPack3.setText(draftView.getSets().get(2));
|
||||
this.chkPack1.setSelected(draftView.getBoosterNum() > 0);
|
||||
this.chkPack2.setSelected(draftView.getBoosterNum() > 1);
|
||||
this.chkPack3.setSelected(draftView.getBoosterNum() > 2);
|
||||
this.txtCardNo.setText(Integer.toString(draftView.getCardNum()));
|
||||
}
|
||||
|
||||
private void setTimeout(String text) {
|
||||
this.txtTimeRemaining.setText(text);
|
||||
}
|
||||
public void loadBooster(DraftPickView draftPickView) {
|
||||
draftBooster.loadBooster(CardsViewUtil.convertSimple(draftPickView.getBooster()), bigCard);
|
||||
draftPicks.loadCards(CardsViewUtil.convertSimple(draftPickView.getPicks()), bigCard, null);
|
||||
this.draftBooster.clearCardEventListeners();
|
||||
this.draftBooster.addCardEventListener(
|
||||
new Listener<Event> () {
|
||||
@Override
|
||||
public void event(Event event) {
|
||||
if (event.getEventName().equals("pick-a-card")) {
|
||||
DraftPickView view = session.sendCardPick(draftId, (UUID)event.getSource());
|
||||
if (view != null) {
|
||||
//draftBooster.loadBooster(view.getBooster(), bigCard);
|
||||
draftBooster.loadBooster(emptyView, bigCard);
|
||||
draftPicks.loadCards(CardsViewUtil.convertSimple(view.getPicks()), bigCard, null);
|
||||
Plugins.getInstance().getActionCallback().hidePopup();
|
||||
setMessage("Waiting for other players");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
setMessage("Pick a card");
|
||||
countdown.stop();
|
||||
this.timeout = draftPickView.getTimeout();
|
||||
setTimeout(Integer.toString(timeout));
|
||||
if (timeout != 0) {
|
||||
countdown.start();
|
||||
}
|
||||
}
|
||||
|
||||
public void hideDraft() {
|
||||
Component c = this.getParent();
|
||||
while (c != null && !(c instanceof DraftPane)) {
|
||||
c = c.getParent();
|
||||
}
|
||||
if (c != null) {
|
||||
((DraftPane)c).hideFrame();
|
||||
}
|
||||
}
|
||||
private void setTimeout(String text) {
|
||||
this.txtTimeRemaining.setText(text);
|
||||
}
|
||||
|
||||
protected void setMessage(String message) {
|
||||
this.lblMessage.setText(message);
|
||||
}
|
||||
public void hideDraft() {
|
||||
Component c = this.getParent();
|
||||
while (c != null && !(c instanceof DraftPane)) {
|
||||
c = c.getParent();
|
||||
}
|
||||
if (c != null) {
|
||||
((DraftPane)c).hideFrame();
|
||||
}
|
||||
}
|
||||
|
||||
protected void setMessage(String message) {
|
||||
this.lblMessage.setText(message);
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
|
|
@ -47,54 +47,54 @@ import java.util.UUID;
|
|||
*/
|
||||
public class AbilityPicker extends JPopupMenu implements PopupMenuListener {
|
||||
|
||||
private Session session;
|
||||
private UUID gameId;
|
||||
private Session session;
|
||||
private UUID gameId;
|
||||
|
||||
public AbilityPicker() {
|
||||
this.addPopupMenuListener(this);
|
||||
}
|
||||
public AbilityPicker() {
|
||||
this.addPopupMenuListener(this);
|
||||
}
|
||||
|
||||
public void init(Session session, UUID gameId) {
|
||||
this.session = session;
|
||||
this.gameId = gameId;
|
||||
}
|
||||
public void init(Session session, UUID gameId) {
|
||||
this.session = session;
|
||||
this.gameId = gameId;
|
||||
}
|
||||
|
||||
public void show(AbilityPickerView choices, Point p) {
|
||||
if (p == null) return;
|
||||
this.removeAll();
|
||||
for (Entry<UUID, String> choice: choices.getChoices().entrySet()) {
|
||||
this.add(new AbilityPickerAction(choice.getKey(), choice.getValue()));
|
||||
}
|
||||
this.show(MageFrame.getDesktop(), p.x, p.y);
|
||||
GuiDisplayUtil.keepComponentInsideScreen(p.x, p.y, this);
|
||||
}
|
||||
public void show(AbilityPickerView choices, Point p) {
|
||||
if (p == null) return;
|
||||
this.removeAll();
|
||||
for (Entry<UUID, String> choice: choices.getChoices().entrySet()) {
|
||||
this.add(new AbilityPickerAction(choice.getKey(), choice.getValue()));
|
||||
}
|
||||
this.show(MageFrame.getDesktop(), p.x, p.y);
|
||||
GuiDisplayUtil.keepComponentInsideScreen(p.x, p.y, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void popupMenuWillBecomeVisible(PopupMenuEvent e) { }
|
||||
@Override
|
||||
public void popupMenuWillBecomeVisible(PopupMenuEvent e) { }
|
||||
|
||||
@Override
|
||||
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { }
|
||||
@Override
|
||||
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { }
|
||||
|
||||
@Override
|
||||
public void popupMenuCanceled(PopupMenuEvent e) {
|
||||
session.sendPlayerBoolean(gameId, false);
|
||||
}
|
||||
@Override
|
||||
public void popupMenuCanceled(PopupMenuEvent e) {
|
||||
session.sendPlayerBoolean(gameId, false);
|
||||
}
|
||||
|
||||
private class AbilityPickerAction extends AbstractAction {
|
||||
private class AbilityPickerAction extends AbstractAction {
|
||||
|
||||
private UUID id;
|
||||
private UUID id;
|
||||
|
||||
public AbilityPickerAction(UUID id, String choice) {
|
||||
this.id = id;
|
||||
putValue(Action.NAME, choice);
|
||||
}
|
||||
public AbilityPickerAction(UUID id, String choice) {
|
||||
this.id = id;
|
||||
putValue(Action.NAME, choice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
session.sendPlayerUUID(gameId, id);
|
||||
setVisible(false);
|
||||
}
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
session.sendPlayerUUID(gameId, id);
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -57,26 +57,26 @@ import java.util.Map.Entry;
|
|||
*/
|
||||
public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
||||
|
||||
private Map<UUID, MagePermanent> permanents = new HashMap<UUID, MagePermanent>();
|
||||
private UUID gameId;
|
||||
private BigCard bigCard;
|
||||
private Map<String, JComponent> ui = new HashMap<String, JComponent>();
|
||||
private Map<UUID, MagePermanent> permanents = new HashMap<UUID, MagePermanent>();
|
||||
private UUID gameId;
|
||||
private BigCard bigCard;
|
||||
private Map<String, JComponent> ui = new HashMap<String, JComponent>();
|
||||
|
||||
protected Map<UUID, PermanentView> battlefield;
|
||||
private Dimension cardDimension;
|
||||
protected Map<UUID, PermanentView> battlefield;
|
||||
private Dimension cardDimension;
|
||||
|
||||
private JComponent jPanel;
|
||||
private JScrollPane jScrollPane;
|
||||
private int width;
|
||||
|
||||
|
||||
private static int i = 0;
|
||||
|
||||
|
||||
/** Creates new form BattlefieldPanel */
|
||||
public BattlefieldPanel() {
|
||||
ui.put("battlefieldPanel", this);
|
||||
ui.put("battlefieldPanel", this);
|
||||
initComponents();
|
||||
ui.put("jPanel", jPanel);
|
||||
|
||||
|
||||
addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
|
@ -89,193 +89,193 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
});
|
||||
}
|
||||
|
||||
public void init(UUID gameId, BigCard bigCard) {
|
||||
this.gameId = gameId;
|
||||
this.bigCard = bigCard;
|
||||
}
|
||||
public void init(UUID gameId, BigCard bigCard) {
|
||||
this.gameId = gameId;
|
||||
this.bigCard = bigCard;
|
||||
}
|
||||
|
||||
public void update(Map<UUID, PermanentView> battlefield) {
|
||||
public void update(Map<UUID, PermanentView> battlefield) {
|
||||
boolean changed = false;
|
||||
|
||||
List<PermanentView> permanentsToAdd = new ArrayList<PermanentView>();
|
||||
for (PermanentView permanent: battlefield.values()) {
|
||||
if (!permanents.containsKey(permanent.getId())) {
|
||||
permanentsToAdd.add(permanent);
|
||||
changed = true;
|
||||
} else {
|
||||
MagePermanent p = permanents.get(permanent.getId());
|
||||
if (!changed) {
|
||||
int s1 = permanent.getAttachments() == null ? 0 : permanent.getAttachments().size();
|
||||
int s2 = p.getLinks().size();
|
||||
if (s1 != s2) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
permanents.get(permanent.getId()).update(permanent);
|
||||
}
|
||||
}
|
||||
for (PermanentView permanent: battlefield.values()) {
|
||||
if (!permanents.containsKey(permanent.getId())) {
|
||||
permanentsToAdd.add(permanent);
|
||||
changed = true;
|
||||
} else {
|
||||
MagePermanent p = permanents.get(permanent.getId());
|
||||
if (!changed) {
|
||||
int s1 = permanent.getAttachments() == null ? 0 : permanent.getAttachments().size();
|
||||
int s2 = p.getLinks().size();
|
||||
if (s1 != s2) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
permanents.get(permanent.getId()).update(permanent);
|
||||
}
|
||||
}
|
||||
int count = permanentsToAdd.size();
|
||||
for (PermanentView permanent : permanentsToAdd) {
|
||||
addPermanent(permanent, count);
|
||||
}
|
||||
|
||||
for (Iterator<Entry<UUID, MagePermanent>> i = permanents.entrySet().iterator(); i.hasNext();) {
|
||||
Entry<UUID, MagePermanent> entry = i.next();
|
||||
if (!battlefield.containsKey(entry.getKey())) {
|
||||
removePermanent(entry.getKey(), 1);
|
||||
i.remove();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
this.battlefield = battlefield;
|
||||
sortLayout();
|
||||
}
|
||||
}
|
||||
for (Iterator<Entry<UUID, MagePermanent>> i = permanents.entrySet().iterator(); i.hasNext();) {
|
||||
Entry<UUID, MagePermanent> entry = i.next();
|
||||
if (!battlefield.containsKey(entry.getKey())) {
|
||||
removePermanent(entry.getKey(), 1);
|
||||
i.remove();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: review sorting stuff
|
||||
public void sortLayout() {
|
||||
int height = Plugins.getInstance().sortPermanents(ui, permanents.values());
|
||||
if (changed) {
|
||||
this.battlefield = battlefield;
|
||||
sortLayout();
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: review sorting stuff
|
||||
public void sortLayout() {
|
||||
int height = Plugins.getInstance().sortPermanents(ui, permanents.values());
|
||||
BattlefieldPanel.this.jPanel.setPreferredSize(new Dimension(width - 30, height));
|
||||
this.jScrollPane.repaint();
|
||||
this.jScrollPane.revalidate();
|
||||
|
||||
if (battlefield == null) {return;}
|
||||
|
||||
for (PermanentView permanent: battlefield.values()) {
|
||||
if (permanent.getAttachments() != null) {
|
||||
groupAttachments(permanent);
|
||||
}
|
||||
}
|
||||
|
||||
invalidate();
|
||||
repaint();
|
||||
}
|
||||
if (battlefield == null) {return;}
|
||||
|
||||
private void addPermanent(PermanentView permanent, final int count) {
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
final MagePermanent perm = Plugins.getInstance().getMagePermanent(permanent, bigCard, cardDimension, gameId, true);
|
||||
if (!Plugins.getInstance().isCardPluginLoaded()) {
|
||||
perm.setBounds(findEmptySpace(new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight)));
|
||||
} else {
|
||||
//perm.setAlpha(0);
|
||||
}
|
||||
permanents.put(permanent.getId(), perm);
|
||||
|
||||
BattlefieldPanel.this.jPanel.add(perm, 10);
|
||||
for (PermanentView permanent: battlefield.values()) {
|
||||
if (permanent.getAttachments() != null) {
|
||||
groupAttachments(permanent);
|
||||
}
|
||||
}
|
||||
|
||||
invalidate();
|
||||
repaint();
|
||||
}
|
||||
|
||||
private void addPermanent(PermanentView permanent, final int count) {
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
final MagePermanent perm = Plugins.getInstance().getMagePermanent(permanent, bigCard, cardDimension, gameId, true);
|
||||
if (!Plugins.getInstance().isCardPluginLoaded()) {
|
||||
perm.setBounds(findEmptySpace(new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight)));
|
||||
} else {
|
||||
//perm.setAlpha(0);
|
||||
}
|
||||
permanents.put(permanent.getId(), perm);
|
||||
|
||||
BattlefieldPanel.this.jPanel.add(perm, 10);
|
||||
//this.jPanel.add(perm);
|
||||
if (!Plugins.getInstance().isCardPluginLoaded()) {
|
||||
moveToFront(perm);
|
||||
perm.update(permanent);
|
||||
} else {
|
||||
if (!Plugins.getInstance().isCardPluginLoaded()) {
|
||||
moveToFront(perm);
|
||||
perm.update(permanent);
|
||||
} else {
|
||||
moveToFront(jPanel);
|
||||
Plugins.getInstance().onAddCard(perm, 1);
|
||||
/*Thread t = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Plugins.getInstance().onAddCard(perm, count);
|
||||
}
|
||||
});
|
||||
synchronized (this) {
|
||||
threads.add(t);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
private void groupAttachments(PermanentView permanent) {
|
||||
MagePermanent perm = permanents.get(permanent.getId());
|
||||
if (perm == null) return;
|
||||
int position = getPosition(perm);
|
||||
perm.getLinks().clear();
|
||||
Rectangle r = perm.getBounds();
|
||||
if (!Plugins.getInstance().isCardPluginLoaded()) {
|
||||
for (UUID attachmentId: permanent.getAttachments()) {
|
||||
MagePermanent link = permanents.get(attachmentId);
|
||||
if (link != null) {
|
||||
perm.getLinks().add(link);
|
||||
r.translate(20, 20);
|
||||
link.setBounds(r);
|
||||
setPosition(link, ++position);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/*Thread t = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Plugins.getInstance().onAddCard(perm, count);
|
||||
}
|
||||
});
|
||||
synchronized (this) {
|
||||
threads.add(t);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
private void groupAttachments(PermanentView permanent) {
|
||||
MagePermanent perm = permanents.get(permanent.getId());
|
||||
if (perm == null) return;
|
||||
int position = getPosition(perm);
|
||||
perm.getLinks().clear();
|
||||
Rectangle r = perm.getBounds();
|
||||
if (!Plugins.getInstance().isCardPluginLoaded()) {
|
||||
for (UUID attachmentId: permanent.getAttachments()) {
|
||||
MagePermanent link = permanents.get(attachmentId);
|
||||
if (link != null) {
|
||||
perm.getLinks().add(link);
|
||||
r.translate(20, 20);
|
||||
link.setBounds(r);
|
||||
setPosition(link, ++position);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int index = permanent.getAttachments().size();
|
||||
for (UUID attachmentId: permanent.getAttachments()) {
|
||||
MagePermanent link = permanents.get(attachmentId);
|
||||
if (link != null) {
|
||||
link.setBounds(r);
|
||||
perm.getLinks().add(link);
|
||||
r.translate(8, 10);
|
||||
perm.setBounds(r);
|
||||
moveToFront(link);
|
||||
moveToFront(perm);
|
||||
for (UUID attachmentId: permanent.getAttachments()) {
|
||||
MagePermanent link = permanents.get(attachmentId);
|
||||
if (link != null) {
|
||||
link.setBounds(r);
|
||||
perm.getLinks().add(link);
|
||||
r.translate(8, 10);
|
||||
perm.setBounds(r);
|
||||
moveToFront(link);
|
||||
moveToFront(perm);
|
||||
jPanel.setComponentZOrder(link, index);
|
||||
index--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
jPanel.setComponentZOrder(perm, index);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void removePermanent(UUID permanentId, final int count) {
|
||||
}
|
||||
|
||||
private void removePermanent(UUID permanentId, final int count) {
|
||||
for (Component c: this.jPanel.getComponents()) {
|
||||
final Component comp = c;
|
||||
if (comp instanceof Permanent) {
|
||||
if (((Permanent)comp).getPermanentId().equals(permanentId)) {
|
||||
comp.setVisible(false);
|
||||
final Component comp = c;
|
||||
if (comp instanceof Permanent) {
|
||||
if (((Permanent)comp).getPermanentId().equals(permanentId)) {
|
||||
comp.setVisible(false);
|
||||
this.jPanel.remove(comp);
|
||||
}
|
||||
} 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);
|
||||
} 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);
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
}
|
||||
BattlefieldPanel.this.jPanel.remove(comp);
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Rectangle findEmptySpace(Dimension size) {
|
||||
int battlefieldWidth = this.getWidth();
|
||||
Rectangle r = new Rectangle(size);
|
||||
boolean intersects;
|
||||
while (true) {
|
||||
intersects = false;
|
||||
for (MagePermanent perm: permanents.values()) {
|
||||
Rectangle pr = perm.getBounds();
|
||||
if (r.intersects(pr)) {
|
||||
intersects = true;
|
||||
if (pr.x + pr.width + r.width > battlefieldWidth)
|
||||
r.setLocation(0, pr.y + pr.height + 1);
|
||||
else
|
||||
r.translate(pr.x + pr.width - r.x, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!intersects)
|
||||
break;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
private Rectangle findEmptySpace(Dimension size) {
|
||||
int battlefieldWidth = this.getWidth();
|
||||
Rectangle r = new Rectangle(size);
|
||||
boolean intersects;
|
||||
while (true) {
|
||||
intersects = false;
|
||||
for (MagePermanent perm: permanents.values()) {
|
||||
Rectangle pr = perm.getBounds();
|
||||
if (r.intersects(pr)) {
|
||||
intersects = true;
|
||||
if (pr.x + pr.width + r.width > battlefieldWidth)
|
||||
r.setLocation(0, pr.y + pr.height + 1);
|
||||
else
|
||||
r.translate(pr.x + pr.width - r.x, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!intersects)
|
||||
break;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOptimizedDrawingEnabled () {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Map<UUID, MagePermanent> getPermanents() {
|
||||
return permanents;
|
||||
}
|
||||
@Override
|
||||
public boolean isOptimizedDrawingEnabled () {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Map<UUID, MagePermanent> getPermanents() {
|
||||
return permanents;
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
setOpaque(false);
|
||||
|
|
|
@ -46,8 +46,8 @@ import java.util.UUID;
|
|||
*/
|
||||
public class CombatGroup extends javax.swing.JPanel {
|
||||
|
||||
private UUID gameId;
|
||||
private BigCard bigCard;
|
||||
private UUID gameId;
|
||||
private BigCard bigCard;
|
||||
|
||||
/** Creates new form CombatGroup */
|
||||
public CombatGroup() {
|
||||
|
@ -55,20 +55,20 @@ public class CombatGroup extends javax.swing.JPanel {
|
|||
attackers.setDontDisplayTapped(true);
|
||||
}
|
||||
|
||||
public void init(UUID gameId, BigCard bigCard) {
|
||||
this.gameId = gameId;
|
||||
this.bigCard = bigCard;
|
||||
}
|
||||
public void init(UUID gameId, BigCard bigCard) {
|
||||
this.gameId = gameId;
|
||||
this.bigCard = bigCard;
|
||||
}
|
||||
|
||||
public void update(CombatGroupView combatGroup) {
|
||||
this.lblDefender.setText(combatGroup.getDefenderName());
|
||||
this.attackers.loadCards(combatGroup.getAttackers(), bigCard, gameId, null);
|
||||
// attackers.setPreferredSize(new Dimension(Config.dimensions.frameWidth + 6, Config.dimensions.frameHeight + 6));
|
||||
this.blockers.loadCards(combatGroup.getBlockers(), bigCard, gameId, null);
|
||||
// blockers.setPreferredSize(new Dimension(Config.dimensions.frameWidth + 6, Config.dimensions.frameHeight + 6));
|
||||
this.attackers.setVisible(true);
|
||||
this.blockers.setVisible(true);
|
||||
}
|
||||
public void update(CombatGroupView combatGroup) {
|
||||
this.lblDefender.setText(combatGroup.getDefenderName());
|
||||
this.attackers.loadCards(combatGroup.getAttackers(), bigCard, gameId, null);
|
||||
// attackers.setPreferredSize(new Dimension(Config.dimensions.frameWidth + 6, Config.dimensions.frameHeight + 6));
|
||||
this.blockers.loadCards(combatGroup.getBlockers(), bigCard, gameId, null);
|
||||
// blockers.setPreferredSize(new Dimension(Config.dimensions.frameWidth + 6, Config.dimensions.frameHeight + 6));
|
||||
this.attackers.setVisible(true);
|
||||
this.blockers.setVisible(true);
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
|
|
@ -56,140 +56,140 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class FeedbackPanel extends javax.swing.JPanel {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(FeedbackPanel.class);
|
||||
private final static Logger logger = Logger.getLogger(FeedbackPanel.class);
|
||||
|
||||
public enum FeedbackMode {
|
||||
INFORM, QUESTION, CONFIRM, CANCEL, SELECT, END
|
||||
}
|
||||
public enum FeedbackMode {
|
||||
INFORM, QUESTION, CONFIRM, CANCEL, SELECT, END
|
||||
}
|
||||
|
||||
private boolean selected = false;
|
||||
private UUID gameId;
|
||||
private Session session;
|
||||
private FeedbackMode mode;
|
||||
private MageDialog connectedDialog;
|
||||
private ChatPanel connectedChatPanel;
|
||||
private boolean selected = false;
|
||||
private UUID gameId;
|
||||
private Session session;
|
||||
private FeedbackMode mode;
|
||||
private MageDialog connectedDialog;
|
||||
private ChatPanel connectedChatPanel;
|
||||
|
||||
/** Creates new form FeedbackPanel */
|
||||
public FeedbackPanel() {
|
||||
//initComponents();
|
||||
customInitComponents();
|
||||
}
|
||||
/** Creates new form FeedbackPanel */
|
||||
public FeedbackPanel() {
|
||||
//initComponents();
|
||||
customInitComponents();
|
||||
}
|
||||
|
||||
public void init(UUID gameId) {
|
||||
this.gameId = gameId;
|
||||
session = MageFrame.getSession();
|
||||
}
|
||||
public void init(UUID gameId) {
|
||||
this.gameId = gameId;
|
||||
session = MageFrame.getSession();
|
||||
}
|
||||
|
||||
public void getFeedback(FeedbackMode mode, String message, boolean special, Map<String, Serializable> options) {
|
||||
logger.info("text: " + message);
|
||||
this.lblMessage.setText(message);
|
||||
this.selected = false;
|
||||
this.mode = mode;
|
||||
switch (this.mode) {
|
||||
case INFORM:
|
||||
this.btnLeft.setVisible(false);
|
||||
this.btnRight.setVisible(false);
|
||||
this.helper.setState("", false, "", false);
|
||||
break;
|
||||
case QUESTION:
|
||||
this.btnLeft.setVisible(true);
|
||||
this.btnLeft.setText("Yes");
|
||||
this.btnRight.setVisible(true);
|
||||
this.btnRight.setText("No");
|
||||
this.helper.setState("Yes", true, "Yes", true);
|
||||
break;
|
||||
case CONFIRM:
|
||||
this.btnLeft.setVisible(true);
|
||||
this.btnLeft.setText("OK");
|
||||
this.btnRight.setVisible(true);
|
||||
this.btnRight.setText("Cancel");
|
||||
this.helper.setState("Ok", true, "Cancel", true);
|
||||
break;
|
||||
case CANCEL:
|
||||
this.btnLeft.setVisible(false);
|
||||
this.btnRight.setVisible(true);
|
||||
this.btnRight.setText("Cancel");
|
||||
this.helper.setState("", false, "Cancel", true);
|
||||
break;
|
||||
case SELECT:
|
||||
this.btnLeft.setVisible(false);
|
||||
this.btnRight.setVisible(true);
|
||||
this.btnRight.setText("Done");
|
||||
this.helper.setState("", false, "Done", true);
|
||||
break;
|
||||
public void getFeedback(FeedbackMode mode, String message, boolean special, Map<String, Serializable> options) {
|
||||
logger.info("text: " + message);
|
||||
this.lblMessage.setText(message);
|
||||
this.selected = false;
|
||||
this.mode = mode;
|
||||
switch (this.mode) {
|
||||
case INFORM:
|
||||
this.btnLeft.setVisible(false);
|
||||
this.btnRight.setVisible(false);
|
||||
this.helper.setState("", false, "", false);
|
||||
break;
|
||||
case QUESTION:
|
||||
this.btnLeft.setVisible(true);
|
||||
this.btnLeft.setText("Yes");
|
||||
this.btnRight.setVisible(true);
|
||||
this.btnRight.setText("No");
|
||||
this.helper.setState("Yes", true, "Yes", true);
|
||||
break;
|
||||
case CONFIRM:
|
||||
this.btnLeft.setVisible(true);
|
||||
this.btnLeft.setText("OK");
|
||||
this.btnRight.setVisible(true);
|
||||
this.btnRight.setText("Cancel");
|
||||
this.helper.setState("Ok", true, "Cancel", true);
|
||||
break;
|
||||
case CANCEL:
|
||||
this.btnLeft.setVisible(false);
|
||||
this.btnRight.setVisible(true);
|
||||
this.btnRight.setText("Cancel");
|
||||
this.helper.setState("", false, "Cancel", true);
|
||||
break;
|
||||
case SELECT:
|
||||
this.btnLeft.setVisible(false);
|
||||
this.btnRight.setVisible(true);
|
||||
this.btnRight.setText("Done");
|
||||
this.helper.setState("", false, "Done", true);
|
||||
break;
|
||||
case END:
|
||||
this.btnLeft.setVisible(false);
|
||||
this.btnRight.setVisible(true);
|
||||
this.btnRight.setText("OK");
|
||||
this.helper.setState("", false, "Done", true);
|
||||
break;
|
||||
}
|
||||
this.btnSpecial.setVisible(special);
|
||||
this.btnSpecial.setText("Special");
|
||||
this.helper.setSpecial("Special", special);
|
||||
if (message.contains("P}")) {
|
||||
this.btnSpecial.setVisible(true);
|
||||
this.btnSpecial.setText("Pay 2 life");
|
||||
this.helper.setSpecial("Pay 2 life", true);
|
||||
}
|
||||
this.btnLeft.setVisible(false);
|
||||
this.btnRight.setVisible(true);
|
||||
this.btnRight.setText("OK");
|
||||
this.helper.setState("", false, "Done", true);
|
||||
break;
|
||||
}
|
||||
this.btnSpecial.setVisible(special);
|
||||
this.btnSpecial.setText("Special");
|
||||
this.helper.setSpecial("Special", special);
|
||||
if (message.contains("P}")) {
|
||||
this.btnSpecial.setVisible(true);
|
||||
this.btnSpecial.setText("Pay 2 life");
|
||||
this.helper.setSpecial("Pay 2 life", true);
|
||||
}
|
||||
|
||||
requestFocusIfPossible();
|
||||
handleOptions(options);
|
||||
requestFocusIfPossible();
|
||||
handleOptions(options);
|
||||
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
this.helper.setLinks(btnLeft, btnRight, btnSpecial);
|
||||
// if (modal) {
|
||||
// this.helper.setVisible(false);
|
||||
// startModal();
|
||||
// } else {
|
||||
this.helper.setVisible(true);
|
||||
// }
|
||||
}
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
this.helper.setLinks(btnLeft, btnRight, btnSpecial);
|
||||
// if (modal) {
|
||||
// this.helper.setVisible(false);
|
||||
// startModal();
|
||||
// } else {
|
||||
this.helper.setVisible(true);
|
||||
// }
|
||||
}
|
||||
|
||||
private void handleOptions(Map<String, Serializable> options) {
|
||||
if (options != null) {
|
||||
if (options.containsKey("UI.right.btn.text")) {
|
||||
this.btnRight.setText((String)options.get("UI.right.btn.text"));
|
||||
this.helper.setRight((String)options.get("UI.right.btn.text"), true);
|
||||
}
|
||||
if (options.containsKey("dialog")) {
|
||||
connectedDialog = (MageDialog) options.get("dialog");
|
||||
}
|
||||
}
|
||||
}
|
||||
private void handleOptions(Map<String, Serializable> options) {
|
||||
if (options != null) {
|
||||
if (options.containsKey("UI.right.btn.text")) {
|
||||
this.btnRight.setText((String)options.get("UI.right.btn.text"));
|
||||
this.helper.setRight((String)options.get("UI.right.btn.text"), true);
|
||||
}
|
||||
if (options.containsKey("dialog")) {
|
||||
connectedDialog = (MageDialog) options.get("dialog");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Issue 256: Chat+Feedback panel: request focus prevents players from chatting
|
||||
private void requestFocusIfPossible() {
|
||||
boolean requestFocusAllowed = true;
|
||||
if (connectedChatPanel != null && connectedChatPanel.getTxtMessageInputComponent() != null) {
|
||||
if (connectedChatPanel.getTxtMessageInputComponent().hasFocus()) {
|
||||
requestFocusAllowed = false;
|
||||
}
|
||||
}
|
||||
if (requestFocusAllowed) {
|
||||
this.btnRight.requestFocus();
|
||||
}
|
||||
}
|
||||
// Issue 256: Chat+Feedback panel: request focus prevents players from chatting
|
||||
private void requestFocusIfPossible() {
|
||||
boolean requestFocusAllowed = true;
|
||||
if (connectedChatPanel != null && connectedChatPanel.getTxtMessageInputComponent() != null) {
|
||||
if (connectedChatPanel.getTxtMessageInputComponent().hasFocus()) {
|
||||
requestFocusAllowed = false;
|
||||
}
|
||||
}
|
||||
if (requestFocusAllowed) {
|
||||
this.btnRight.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
public void doClick() {
|
||||
this.btnRight.doClick();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
// stopModal();
|
||||
this.btnLeft.setVisible(false);
|
||||
this.btnRight.setVisible(false);
|
||||
this.btnSpecial.setVisible(false);
|
||||
this.lblMessage.setText("");
|
||||
logger.debug("feedback - clear");
|
||||
}
|
||||
public void clear() {
|
||||
// stopModal();
|
||||
this.btnLeft.setVisible(false);
|
||||
this.btnRight.setVisible(false);
|
||||
this.btnSpecial.setVisible(false);
|
||||
this.lblMessage.setText("");
|
||||
logger.debug("feedback - clear");
|
||||
}
|
||||
|
||||
// public void clear0() {
|
||||
// stopModal();
|
||||
// }
|
||||
// public void clear0() {
|
||||
// stopModal();
|
||||
// }
|
||||
|
||||
// private synchronized void startModal() {
|
||||
// private synchronized void startModal() {
|
||||
//
|
||||
// try {
|
||||
// if (SwingUtilities.isEventDispatchThread()) {
|
||||
|
@ -215,7 +215,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
// } else if (source instanceof MenuComponent) {
|
||||
// ((MenuComponent) source).dispatchEvent(event);
|
||||
// } else {
|
||||
// logger.warn("Unable to dispatch: " + event);
|
||||
// logger.warn("Unable to dispatch: " + event);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
@ -232,7 +232,7 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
// private synchronized void stopModal() {
|
||||
// notifyAll();
|
||||
// }
|
||||
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
|
@ -365,42 +365,42 @@ public class FeedbackPanel extends javax.swing.JPanel {
|
|||
add(jlabel2, BorderLayout.PAGE_END);
|
||||
}
|
||||
|
||||
private void btnRightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRightActionPerformed
|
||||
this.selected = true;
|
||||
// clear0();
|
||||
if (connectedDialog != null) {
|
||||
connectedDialog.hideDialog();
|
||||
}
|
||||
if (mode == FeedbackMode.SELECT && (evt.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK) {
|
||||
session.sendPlayerInteger(gameId, 0);
|
||||
private void btnRightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRightActionPerformed
|
||||
this.selected = true;
|
||||
// clear0();
|
||||
if (connectedDialog != null) {
|
||||
connectedDialog.hideDialog();
|
||||
}
|
||||
if (mode == FeedbackMode.SELECT && (evt.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK) {
|
||||
session.sendPlayerInteger(gameId, 0);
|
||||
} else if (mode == FeedbackMode.END) {
|
||||
MageFrame.getGame(gameId).hideGame();
|
||||
} else {
|
||||
session.sendPlayerBoolean(gameId, false);
|
||||
}
|
||||
}//GEN-LAST:event_btnRightActionPerformed
|
||||
} else {
|
||||
session.sendPlayerBoolean(gameId, false);
|
||||
}
|
||||
}//GEN-LAST:event_btnRightActionPerformed
|
||||
|
||||
private void btnLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLeftActionPerformed
|
||||
this.selected = true;
|
||||
// clear0();
|
||||
session.sendPlayerBoolean(gameId, true);
|
||||
}//GEN-LAST:event_btnLeftActionPerformed
|
||||
private void btnLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLeftActionPerformed
|
||||
this.selected = true;
|
||||
// clear0();
|
||||
session.sendPlayerBoolean(gameId, true);
|
||||
}//GEN-LAST:event_btnLeftActionPerformed
|
||||
|
||||
private void btnSpecialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSpecialActionPerformed
|
||||
session.sendPlayerString(gameId, "special");
|
||||
}//GEN-LAST:event_btnSpecialActionPerformed
|
||||
private void btnSpecialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSpecialActionPerformed
|
||||
session.sendPlayerString(gameId, "special");
|
||||
}//GEN-LAST:event_btnSpecialActionPerformed
|
||||
|
||||
public void setHelperPanel(HelperPanel helper) {
|
||||
this.helper = helper;
|
||||
}
|
||||
|
||||
public FeedbackMode getMode() {
|
||||
return this.mode;
|
||||
}
|
||||
public FeedbackMode getMode() {
|
||||
return this.mode;
|
||||
}
|
||||
|
||||
public void setConnectedChatPanel(ChatPanel chatPanel) {
|
||||
this.connectedChatPanel = chatPanel;
|
||||
}
|
||||
public void setConnectedChatPanel(ChatPanel chatPanel) {
|
||||
this.connectedChatPanel = chatPanel;
|
||||
}
|
||||
|
||||
private javax.swing.JButton btnLeft;
|
||||
private javax.swing.JButton btnRight;
|
||||
|
|
|
@ -48,34 +48,34 @@ public class GamePane extends MagePane {
|
|||
/** Creates new form GamePane */
|
||||
public GamePane() {
|
||||
initComponents();
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
gamePanel.setJLayeredPane(getLayeredPane());
|
||||
gamePanel.installComponents();
|
||||
}
|
||||
});
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
gamePanel.setJLayeredPane(getLayeredPane());
|
||||
gamePanel.installComponents();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void showGame(UUID gameId, UUID playerId) {
|
||||
this.setTitle("Game " + gameId);
|
||||
gamePanel.showGame(gameId, playerId);
|
||||
}
|
||||
public void showGame(UUID gameId, UUID playerId) {
|
||||
this.setTitle("Game " + gameId);
|
||||
gamePanel.showGame(gameId, playerId);
|
||||
}
|
||||
|
||||
public void hideGame() {
|
||||
gamePanel.hideGame();
|
||||
}
|
||||
|
||||
public void watchGame(UUID gameId) {
|
||||
this.setTitle("Watching " + gameId);
|
||||
gamePanel.watchGame(gameId);
|
||||
}
|
||||
public void hideGame() {
|
||||
gamePanel.hideGame();
|
||||
}
|
||||
|
||||
public void replayGame(UUID gameId) {
|
||||
this.setTitle("Replaying " + gameId);
|
||||
gamePanel.replayGame(gameId);
|
||||
}
|
||||
public void watchGame(UUID gameId) {
|
||||
this.setTitle("Watching " + gameId);
|
||||
gamePanel.watchGame(gameId);
|
||||
}
|
||||
|
||||
public void replayGame(UUID gameId) {
|
||||
this.setTitle("Replaying " + gameId);
|
||||
gamePanel.replayGame(gameId);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void initComponents() {
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -22,10 +22,10 @@ public class HandPanel extends JPanel {
|
|||
|
||||
private static final int CARD_WIDTH = 75;
|
||||
private static final double ASPECT_RATIO = 3.5 / 2.5;
|
||||
|
||||
private boolean smallMode = false;
|
||||
|
||||
private boolean smallMode = false;
|
||||
private Dimension handCardDimensionBig;
|
||||
private Dimension handCardDimension;
|
||||
private Dimension handCardDimension;
|
||||
|
||||
public HandPanel() {
|
||||
double factor = 1;
|
||||
|
@ -35,7 +35,7 @@ public class HandPanel extends JPanel {
|
|||
|
||||
public void initComponents() {
|
||||
hand = new mage.client.cards.Cards(true);
|
||||
hand.setCardDimension(getHandCardDimension());
|
||||
hand.setCardDimension(getHandCardDimension());
|
||||
jPanel = new JPanel();
|
||||
jScrollPane1 = new JScrollPane(jPanel);
|
||||
jScrollPane1.getViewport().setBackground(new Color(0,0,0,0));
|
||||
|
@ -44,14 +44,14 @@ public class HandPanel extends JPanel {
|
|||
jPanel.setBackground(new Color(0,0,0,0));
|
||||
jPanel.add(hand);
|
||||
|
||||
setOpaque(false);
|
||||
jPanel.setOpaque(false);
|
||||
jScrollPane1.setOpaque(false);
|
||||
setOpaque(false);
|
||||
jPanel.setOpaque(false);
|
||||
jScrollPane1.setOpaque(false);
|
||||
|
||||
jPanel.setBorder(emptyBorder);
|
||||
jScrollPane1.setBorder(emptyBorder);
|
||||
jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
|
||||
jScrollPane1.getHorizontalScrollBar().setUnitIncrement(8);
|
||||
jPanel.setBorder(emptyBorder);
|
||||
jScrollPane1.setBorder(emptyBorder);
|
||||
jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
|
||||
jScrollPane1.getHorizontalScrollBar().setUnitIncrement(8);
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
add(jScrollPane1, BorderLayout.CENTER);
|
||||
|
@ -59,14 +59,14 @@ public class HandPanel extends JPanel {
|
|||
hand.setHScrollSpeed(8);
|
||||
hand.setBackgroundColor(new Color(0, 0, 0, 100));
|
||||
hand.setVisibleIfEmpty(false);
|
||||
hand.setBorder(emptyBorder);
|
||||
hand.setBorder(emptyBorder);
|
||||
hand.setZone(Constants.Zone.HAND.toString());
|
||||
}
|
||||
|
||||
public void loadCards(SimpleCardsView cards, BigCard bigCard, UUID gameId) {
|
||||
hand.loadCards(cards, bigCard, gameId);
|
||||
hand.loadCards(cards, bigCard, gameId);
|
||||
hand.sizeCards(getHandCardDimension());
|
||||
}
|
||||
}
|
||||
|
||||
private Dimension getHandCardDimension() {
|
||||
String useBigCards = MageFrame.getPreferences().get(PreferencesDialog.KEY_HAND_USE_BIG_CARDS, "false");
|
||||
|
@ -82,13 +82,13 @@ public class HandPanel extends JPanel {
|
|||
int bigWidth = (int)(Config.handScalingFactor * CARD_WIDTH);
|
||||
handCardDimension = new Dimension(width, (int)(width * ASPECT_RATIO));
|
||||
handCardDimensionBig = new Dimension(bigWidth, (int)(bigWidth * ASPECT_RATIO));
|
||||
hand.setCardDimension(getHandCardDimension());
|
||||
hand.setCardDimension(getHandCardDimension());
|
||||
hand.sizeCards(getHandCardDimension());
|
||||
}
|
||||
|
||||
|
||||
private JPanel jPanel;
|
||||
private JScrollPane jScrollPane1;
|
||||
private Border emptyBorder = new EmptyBorder(0,0,0,0);
|
||||
private Border emptyBorder = new EmptyBorder(0,0,0,0);
|
||||
private mage.client.cards.Cards hand;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public class HelperPanel extends JPanel {
|
|||
setState("",false,"",false);
|
||||
setSpecial("", false);
|
||||
linkLeft.doClick();
|
||||
}}
|
||||
}}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -47,14 +47,14 @@ public class ManaPool extends javax.swing.JPanel {
|
|||
initComponents();
|
||||
}
|
||||
|
||||
public void update(ManaPoolView pool) {
|
||||
this.btnBlack.setText(Integer.toString(pool.getBlack()));
|
||||
this.btnRed.setText(Integer.toString(pool.getRed()));
|
||||
this.btnWhite.setText(Integer.toString(pool.getWhite()));
|
||||
this.btnGreen.setText(Integer.toString(pool.getGreen()));
|
||||
this.btnBlue.setText(Integer.toString(pool.getBlue()));
|
||||
this.btnColorless.setText(Integer.toString(pool.getColorless()));
|
||||
}
|
||||
public void update(ManaPoolView pool) {
|
||||
this.btnBlack.setText(Integer.toString(pool.getBlack()));
|
||||
this.btnRed.setText(Integer.toString(pool.getRed()));
|
||||
this.btnWhite.setText(Integer.toString(pool.getWhite()));
|
||||
this.btnGreen.setText(Integer.toString(pool.getGreen()));
|
||||
this.btnBlue.setText(Integer.toString(pool.getBlue()));
|
||||
this.btnColorless.setText(Integer.toString(pool.getColorless()));
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
|
|
@ -44,48 +44,48 @@ import java.util.UUID;
|
|||
*/
|
||||
public class PlayAreaPanel extends javax.swing.JPanel {
|
||||
|
||||
private UUID playerId;
|
||||
private UUID gameId;
|
||||
private UUID playerId;
|
||||
private UUID gameId;
|
||||
|
||||
/** Creates new form PlayAreaPanel */
|
||||
public PlayAreaPanel() {
|
||||
initComponents();
|
||||
setOpaque(false);
|
||||
setOpaque(false);
|
||||
//jScrollPane1.setOpaque(false);
|
||||
//jScrollPane1.getViewport().setOpaque(false);
|
||||
battlefieldPanel.setOpaque(false);
|
||||
}
|
||||
}
|
||||
|
||||
public PlayAreaPanel(PlayerView player, BigCard bigCard, UUID gameId, boolean me) {
|
||||
this();
|
||||
init(player, bigCard, gameId);
|
||||
update(player);
|
||||
}
|
||||
public PlayAreaPanel(PlayerView player, BigCard bigCard, UUID gameId, boolean me) {
|
||||
this();
|
||||
init(player, bigCard, gameId);
|
||||
update(player);
|
||||
}
|
||||
|
||||
public final void init(PlayerView player, BigCard bigCard, UUID gameId) {
|
||||
this.playerPanel.init(gameId, player.getPlayerId(), bigCard);
|
||||
this.battlefieldPanel.init(gameId, bigCard);
|
||||
if (MageFrame.getSession().isTestMode()) {
|
||||
this.playerId = player.getPlayerId();
|
||||
this.gameId = gameId;
|
||||
this.btnCheat.setVisible(true);
|
||||
}
|
||||
else {
|
||||
this.btnCheat.setVisible(false);
|
||||
}
|
||||
}
|
||||
public final void init(PlayerView player, BigCard bigCard, UUID gameId) {
|
||||
this.playerPanel.init(gameId, player.getPlayerId(), bigCard);
|
||||
this.battlefieldPanel.init(gameId, bigCard);
|
||||
if (MageFrame.getSession().isTestMode()) {
|
||||
this.playerId = player.getPlayerId();
|
||||
this.gameId = gameId;
|
||||
this.btnCheat.setVisible(true);
|
||||
}
|
||||
else {
|
||||
this.btnCheat.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
public final void update(PlayerView player) {
|
||||
this.playerPanel.update(player);
|
||||
this.battlefieldPanel.update(player.getBattlefield());
|
||||
}
|
||||
public final void update(PlayerView player) {
|
||||
this.playerPanel.update(player);
|
||||
this.battlefieldPanel.update(player.getBattlefield());
|
||||
}
|
||||
|
||||
public mage.client.game.BattlefieldPanel getBattlefieldPanel() {
|
||||
return battlefieldPanel;
|
||||
}
|
||||
public mage.client.game.BattlefieldPanel getBattlefieldPanel() {
|
||||
return battlefieldPanel;
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
setBorder(BorderFactory.createLineBorder(new Color(0,0,0,0)));
|
||||
setBorder(BorderFactory.createLineBorder(new Color(0,0,0,0)));
|
||||
playerPanel = new PlayerPanelExt();
|
||||
btnCheat = new javax.swing.JButton();
|
||||
//jScrollPane1 = new javax.swing.JScrollPane();
|
||||
|
@ -101,46 +101,46 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
});
|
||||
|
||||
//jScrollPane1.setViewportView(battlefieldPanel);
|
||||
//Border empty = new EmptyBorder(0,0,0,0);
|
||||
//jScrollPane1.setBorder(empty);
|
||||
//jScrollPane1.setViewportBorder(empty);
|
||||
//Border empty = new EmptyBorder(0,0,0,0);
|
||||
//jScrollPane1.setBorder(empty);
|
||||
//jScrollPane1.setViewportBorder(empty);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createSequentialGroup()
|
||||
.addComponent(playerPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(battlefieldPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
layout.createSequentialGroup()
|
||||
.addComponent(playerPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(battlefieldPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(Alignment.LEADING)
|
||||
.addComponent(playerPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(battlefieldPanel, GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
|
||||
layout.createParallelGroup(Alignment.LEADING)
|
||||
.addComponent(playerPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(battlefieldPanel, GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
|
||||
);
|
||||
this.setLayout(layout);
|
||||
}
|
||||
|
||||
public void sizePlayer(boolean smallMode) {
|
||||
this.playerPanel.sizePlayerPanel(smallMode);
|
||||
if (smallMode) {
|
||||
this.playerPanel.setPreferredSize(new Dimension(92, 160));
|
||||
//this.jScrollPane1.setPreferredSize(new Dimension(160, 160));
|
||||
this.playerPanel.sizePlayerPanel(smallMode);
|
||||
if (smallMode) {
|
||||
this.playerPanel.setPreferredSize(new Dimension(92, 160));
|
||||
//this.jScrollPane1.setPreferredSize(new Dimension(160, 160));
|
||||
this.battlefieldPanel.setPreferredSize(new Dimension(160, 160));
|
||||
}
|
||||
else {
|
||||
this.playerPanel.setPreferredSize(new Dimension(92, 212));
|
||||
//this.jScrollPane1.setPreferredSize(new Dimension(160, 212));
|
||||
}
|
||||
else {
|
||||
this.playerPanel.setPreferredSize(new Dimension(92, 212));
|
||||
//this.jScrollPane1.setPreferredSize(new Dimension(160, 212));
|
||||
this.battlefieldPanel.setPreferredSize(new Dimension(160, 212));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
MageFrame.getSession().cheat(gameId, playerId, DeckImporterUtil.importDeck("cheat.dck"));
|
||||
}
|
||||
|
||||
|
||||
private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
MageFrame.getSession().cheat(gameId, playerId, DeckImporterUtil.importDeck("cheat.dck"));
|
||||
}
|
||||
|
||||
|
||||
private mage.client.game.BattlefieldPanel battlefieldPanel;
|
||||
private javax.swing.JButton btnCheat;
|
||||
private javax.swing.JButton btnCheat;
|
||||
//private javax.swing.JScrollPane jScrollPane1;
|
||||
private PlayerPanelExt playerPanel;
|
||||
|
||||
|
|
|
@ -49,43 +49,43 @@ import mage.view.PlayerView;
|
|||
*/
|
||||
public class PlayerPanel extends javax.swing.JPanel {
|
||||
|
||||
private UUID playerId;
|
||||
private UUID gameId;
|
||||
private Session session;
|
||||
private PlayerView player;
|
||||
private UUID playerId;
|
||||
private UUID gameId;
|
||||
private Session session;
|
||||
private PlayerView player;
|
||||
|
||||
private ShowCardsDialog graveyard;
|
||||
private BigCard bigCard;
|
||||
private ShowCardsDialog graveyard;
|
||||
private BigCard bigCard;
|
||||
|
||||
/** Creates new form PlayerPanel */
|
||||
public PlayerPanel() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
public void init(UUID gameId, UUID playerId, BigCard bigCard) {
|
||||
this.gameId = gameId;
|
||||
this.playerId = playerId;
|
||||
this.bigCard = bigCard;
|
||||
session = MageFrame.getSession();
|
||||
}
|
||||
public void init(UUID gameId, UUID playerId, BigCard bigCard) {
|
||||
this.gameId = gameId;
|
||||
this.playerId = playerId;
|
||||
this.bigCard = bigCard;
|
||||
session = MageFrame.getSession();
|
||||
}
|
||||
|
||||
public void update(PlayerView player) {
|
||||
this.player = player;
|
||||
this.txtLife.setText(Integer.toString(player.getLife()));
|
||||
this.txtHand.setText(Integer.toString(player.getHandCount()));
|
||||
this.txtLibrary.setText(Integer.toString(player.getLibraryCount()));
|
||||
this.btnGrave.setText(Integer.toString(player.getGraveyard().size()));
|
||||
this.btnPlayerName.setText(player.getName());
|
||||
if (player.isActive()) {
|
||||
this.btnPlayerName.setBackground(Color.DARK_GRAY);
|
||||
}
|
||||
else if (player.hasLeft()) {
|
||||
this.btnPlayerName.setBackground(Color.RED);
|
||||
}
|
||||
else {
|
||||
this.btnPlayerName.setBackground(Color.LIGHT_GRAY);
|
||||
}
|
||||
}
|
||||
public void update(PlayerView player) {
|
||||
this.player = player;
|
||||
this.txtLife.setText(Integer.toString(player.getLife()));
|
||||
this.txtHand.setText(Integer.toString(player.getHandCount()));
|
||||
this.txtLibrary.setText(Integer.toString(player.getLibraryCount()));
|
||||
this.btnGrave.setText(Integer.toString(player.getGraveyard().size()));
|
||||
this.btnPlayerName.setText(player.getName());
|
||||
if (player.isActive()) {
|
||||
this.btnPlayerName.setBackground(Color.DARK_GRAY);
|
||||
}
|
||||
else if (player.hasLeft()) {
|
||||
this.btnPlayerName.setBackground(Color.RED);
|
||||
}
|
||||
else {
|
||||
this.btnPlayerName.setBackground(Color.LIGHT_GRAY);
|
||||
}
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
@ -192,16 +192,16 @@ public class PlayerPanel extends javax.swing.JPanel {
|
|||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void btnPlayerNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPlayerNameActionPerformed
|
||||
session.sendPlayerUUID(gameId, playerId);
|
||||
}//GEN-LAST:event_btnPlayerNameActionPerformed
|
||||
private void btnPlayerNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPlayerNameActionPerformed
|
||||
session.sendPlayerUUID(gameId, playerId);
|
||||
}//GEN-LAST:event_btnPlayerNameActionPerformed
|
||||
|
||||
private void btnGraveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGraveActionPerformed
|
||||
if (graveyard == null) {
|
||||
graveyard = new ShowCardsDialog();
|
||||
}
|
||||
graveyard.loadCards(player.getName() + " graveyard", player.getGraveyard(), bigCard, Config.dimensions, gameId, false);
|
||||
}//GEN-LAST:event_btnGraveActionPerformed
|
||||
private void btnGraveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGraveActionPerformed
|
||||
if (graveyard == null) {
|
||||
graveyard = new ShowCardsDialog();
|
||||
}
|
||||
graveyard.loadCards(player.getName() + " graveyard", player.getGraveyard(), bigCard, Config.dimensions, gameId, false);
|
||||
}//GEN-LAST:event_btnGraveActionPerformed
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
|
|
@ -76,45 +76,45 @@ import java.util.UUID;
|
|||
*/
|
||||
public class PlayerPanelExt extends javax.swing.JPanel {
|
||||
|
||||
private UUID playerId;
|
||||
private UUID gameId;
|
||||
private Session session;
|
||||
private PlayerView player;
|
||||
private UUID playerId;
|
||||
private UUID gameId;
|
||||
private Session session;
|
||||
private PlayerView player;
|
||||
|
||||
private ShowCardsDialog graveyard;
|
||||
private BigCard bigCard;
|
||||
private ShowCardsDialog graveyard;
|
||||
private BigCard bigCard;
|
||||
|
||||
private static final int AVATAR_COUNT = 77;
|
||||
private static final int AVATAR_COUNT = 77;
|
||||
|
||||
private static final Border greenBorder = new LineBorder(Color.red, 3);
|
||||
private static final Border redBorder = new LineBorder(Color.red, 2);
|
||||
private static final Border emptyBorder = BorderFactory.createEmptyBorder(0,0,0,0);
|
||||
private static final Border greenBorder = new LineBorder(Color.red, 3);
|
||||
private static final Border redBorder = new LineBorder(Color.red, 2);
|
||||
private static final Border emptyBorder = BorderFactory.createEmptyBorder(0,0,0,0);
|
||||
|
||||
private static final Dimension topCardDimension = new Dimension(40, 56);
|
||||
private static final Dimension topCardDimension = new Dimension(40, 56);
|
||||
|
||||
private int avatarId = -1;
|
||||
private int avatarId = -1;
|
||||
|
||||
/** Creates new form PlayerPanel */
|
||||
public PlayerPanelExt() {
|
||||
setPreferredSize(new Dimension(94, 212));
|
||||
setPreferredSize(new Dimension(94, 212));
|
||||
initComponents();
|
||||
}
|
||||
|
||||
public void init(UUID gameId, UUID playerId, BigCard bigCard) {
|
||||
this.gameId = gameId;
|
||||
this.playerId = playerId;
|
||||
this.bigCard = bigCard;
|
||||
session = MageFrame.getSession();
|
||||
cheat.setVisible(session.isTestMode());
|
||||
}
|
||||
public void init(UUID gameId, UUID playerId, BigCard bigCard) {
|
||||
this.gameId = gameId;
|
||||
this.playerId = playerId;
|
||||
this.bigCard = bigCard;
|
||||
session = MageFrame.getSession();
|
||||
cheat.setVisible(session.isTestMode());
|
||||
}
|
||||
|
||||
public void update(PlayerView player) {
|
||||
this.player = player;
|
||||
lifeLabel.setText(Integer.toString(player.getLife()));
|
||||
poisonLabel.setText(Integer.toString(player.getPoison()));
|
||||
handLabel.setText(Integer.toString(player.getHandCount()));
|
||||
libraryLabel.setText(Integer.toString(player.getLibraryCount()));
|
||||
graveLabel.setText(Integer.toString(player.getGraveyard().size()));
|
||||
public void update(PlayerView player) {
|
||||
this.player = player;
|
||||
lifeLabel.setText(Integer.toString(player.getLife()));
|
||||
poisonLabel.setText(Integer.toString(player.getPoison()));
|
||||
handLabel.setText(Integer.toString(player.getHandCount()));
|
||||
libraryLabel.setText(Integer.toString(player.getLibraryCount()));
|
||||
graveLabel.setText(Integer.toString(player.getGraveyard().size()));
|
||||
|
||||
if (!MageFrame.isLite()) {
|
||||
int id = player.getUserData().getAvatarId();
|
||||
|
@ -133,49 +133,49 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
this.avatar.update("player", resized, resized, resized, resized, r);
|
||||
}
|
||||
}
|
||||
this.avatar.setText(player.getName());
|
||||
this.btnPlayer.setText(player.getName());
|
||||
if (player.isActive()) {
|
||||
this.avatar.setBorder(greenBorder);
|
||||
this.btnPlayer.setBorder(greenBorder);
|
||||
} else if (player.hasLeft()) {
|
||||
this.avatar.setBorder(redBorder);
|
||||
this.btnPlayer.setBorder(redBorder);
|
||||
} else {
|
||||
this.avatar.setBorder(emptyBorder);
|
||||
this.btnPlayer.setBorder(emptyBorder);
|
||||
}
|
||||
this.avatar.setText(player.getName());
|
||||
this.btnPlayer.setText(player.getName());
|
||||
if (player.isActive()) {
|
||||
this.avatar.setBorder(greenBorder);
|
||||
this.btnPlayer.setBorder(greenBorder);
|
||||
} else if (player.hasLeft()) {
|
||||
this.avatar.setBorder(redBorder);
|
||||
this.btnPlayer.setBorder(redBorder);
|
||||
} else {
|
||||
this.avatar.setBorder(emptyBorder);
|
||||
this.btnPlayer.setBorder(emptyBorder);
|
||||
}
|
||||
|
||||
synchronized (this) {
|
||||
if (player.getTopCard() != null) {
|
||||
if (topCard == null || !topCard.getId().equals(player.getTopCard().getId())) {
|
||||
if (topCard == null) {
|
||||
topCardPanel.setVisible(true);
|
||||
}
|
||||
topCard = player.getTopCard();
|
||||
topCardPanel.update(topCard);
|
||||
topCardPanel.updateImage();
|
||||
ActionCallback callback = Plugins.getInstance().getActionCallback();
|
||||
((MageActionCallback)callback).refreshSession();
|
||||
topCardPanel.updateCallback(callback, gameId);
|
||||
}
|
||||
} else if (topCard != null) {
|
||||
topCard = null;
|
||||
topCardPanel.setVisible(false);
|
||||
}
|
||||
}
|
||||
synchronized (this) {
|
||||
if (player.getTopCard() != null) {
|
||||
if (topCard == null || !topCard.getId().equals(player.getTopCard().getId())) {
|
||||
if (topCard == null) {
|
||||
topCardPanel.setVisible(true);
|
||||
}
|
||||
topCard = player.getTopCard();
|
||||
topCardPanel.update(topCard);
|
||||
topCardPanel.updateImage();
|
||||
ActionCallback callback = Plugins.getInstance().getActionCallback();
|
||||
((MageActionCallback)callback).refreshSession();
|
||||
topCardPanel.updateCallback(callback, gameId);
|
||||
}
|
||||
} else if (topCard != null) {
|
||||
topCard = null;
|
||||
topCardPanel.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
update(player.getManaPool());
|
||||
}
|
||||
update(player.getManaPool());
|
||||
}
|
||||
|
||||
protected void update(ManaPoolView pool) {
|
||||
manaLabels.get("B").setText(Integer.toString(pool.getBlack()));
|
||||
manaLabels.get("R").setText(Integer.toString(pool.getRed()));
|
||||
manaLabels.get("W").setText(Integer.toString(pool.getWhite()));
|
||||
manaLabels.get("G").setText(Integer.toString(pool.getGreen()));
|
||||
manaLabels.get("U").setText(Integer.toString(pool.getBlue()));
|
||||
manaLabels.get("X").setText(Integer.toString(pool.getColorless()));
|
||||
}
|
||||
protected void update(ManaPoolView pool) {
|
||||
manaLabels.get("B").setText(Integer.toString(pool.getBlack()));
|
||||
manaLabels.get("R").setText(Integer.toString(pool.getRed()));
|
||||
manaLabels.get("W").setText(Integer.toString(pool.getWhite()));
|
||||
manaLabels.get("G").setText(Integer.toString(pool.getGreen()));
|
||||
manaLabels.get("U").setText(Integer.toString(pool.getBlue()));
|
||||
manaLabels.get("X").setText(Integer.toString(pool.getColorless()));
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
@ -184,313 +184,313 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private void initComponents() {
|
||||
|
||||
panelBackground = new MageRoundPane();
|
||||
panelBackground.setPreferredSize(new Dimension(92, 212));
|
||||
Rectangle r = new Rectangle(80, 80);
|
||||
lifeLabel = new JLabel();
|
||||
handLabel = new JLabel();
|
||||
poisonLabel = new JLabel();
|
||||
libraryLabel = new JLabel();
|
||||
setOpaque(false);
|
||||
|
||||
panelBackground.setXOffset(3);
|
||||
panelBackground.setYOffset(3);
|
||||
panelBackground = new MageRoundPane();
|
||||
panelBackground.setPreferredSize(new Dimension(92, 212));
|
||||
Rectangle r = new Rectangle(80, 80);
|
||||
lifeLabel = new JLabel();
|
||||
handLabel = new JLabel();
|
||||
poisonLabel = new JLabel();
|
||||
libraryLabel = new JLabel();
|
||||
setOpaque(false);
|
||||
|
||||
panelBackground.setXOffset(3);
|
||||
panelBackground.setYOffset(3);
|
||||
panelBackground.setVisible(true);
|
||||
|
||||
// Avatar
|
||||
Image image = ImageHelper.getImageFromResources("/avatars/unknown.jpg");
|
||||
// Avatar
|
||||
Image image = ImageHelper.getImageFromResources("/avatars/unknown.jpg");
|
||||
|
||||
topCardPanel = Plugins.getInstance().getMageCard(new CardView(Sets.findCard("Forest")), bigCard, topCardDimension, gameId, true);
|
||||
topCardPanel.setVisible(false);
|
||||
panelBackground.add(topCardPanel);
|
||||
topCardPanel.setVisible(false);
|
||||
panelBackground.add(topCardPanel);
|
||||
|
||||
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
|
||||
avatar = new HoverButton("player", resized, resized, resized, r);
|
||||
avatar.setObserver(new Command() {
|
||||
@Override
|
||||
public void execute() {
|
||||
session.sendPlayerUUID(gameId, playerId);
|
||||
}
|
||||
});
|
||||
r = new Rectangle(18, 18);
|
||||
lifeLabel.setToolTipText("Life");
|
||||
Image imageLife = ImageHelper.getImageFromResources("/info/life.png");
|
||||
BufferedImage resizedLife = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageLife, BufferedImage.TYPE_INT_ARGB), r);
|
||||
life = new ImagePanel(resizedLife, ImagePanel.ACTUAL);
|
||||
life.setToolTipText("Life");
|
||||
life.setOpaque(false);
|
||||
r = new Rectangle(18, 18);
|
||||
handLabel.setToolTipText("Hand");
|
||||
Image imageHand = ImageHelper.getImageFromResources("/info/hand.png");
|
||||
BufferedImage resizedHand = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageHand, BufferedImage.TYPE_INT_ARGB), r);
|
||||
hand = new ImagePanel(resizedHand, ImagePanel.ACTUAL);
|
||||
hand.setToolTipText("Hand");
|
||||
hand.setOpaque(false);
|
||||
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
|
||||
avatar = new HoverButton("player", resized, resized, resized, r);
|
||||
avatar.setObserver(new Command() {
|
||||
@Override
|
||||
public void execute() {
|
||||
session.sendPlayerUUID(gameId, playerId);
|
||||
}
|
||||
});
|
||||
r = new Rectangle(18, 18);
|
||||
lifeLabel.setToolTipText("Life");
|
||||
Image imageLife = ImageHelper.getImageFromResources("/info/life.png");
|
||||
BufferedImage resizedLife = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageLife, BufferedImage.TYPE_INT_ARGB), r);
|
||||
life = new ImagePanel(resizedLife, ImagePanel.ACTUAL);
|
||||
life.setToolTipText("Life");
|
||||
life.setOpaque(false);
|
||||
r = new Rectangle(18, 18);
|
||||
handLabel.setToolTipText("Hand");
|
||||
Image imageHand = ImageHelper.getImageFromResources("/info/hand.png");
|
||||
BufferedImage resizedHand = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageHand, BufferedImage.TYPE_INT_ARGB), r);
|
||||
hand = new ImagePanel(resizedHand, ImagePanel.ACTUAL);
|
||||
hand.setToolTipText("Hand");
|
||||
hand.setOpaque(false);
|
||||
|
||||
// Poison count
|
||||
poisonLabel.setText("0");
|
||||
r = new Rectangle(14, 14);
|
||||
poisonLabel.setToolTipText("Poison");
|
||||
Image imagePoison = ImageHelper.getImageFromResources("/info/poison.png");
|
||||
BufferedImage resizedPoison = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imagePoison, BufferedImage.TYPE_INT_ARGB), r);
|
||||
poison = new ImagePanel(resizedPoison, ImagePanel.ACTUAL);
|
||||
poison.setToolTipText("Poison");
|
||||
poison.setOpaque(false);
|
||||
r = new Rectangle(19, 19);
|
||||
libraryLabel.setToolTipText("Library");
|
||||
Image imageLibrary = ImageHelper.getImageFromResources("/info/library.png");
|
||||
BufferedImage resizedLibrary = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageLibrary, BufferedImage.TYPE_INT_ARGB), r);
|
||||
library = new ImagePanel(resizedLibrary, ImagePanel.ACTUAL);
|
||||
library.setToolTipText("Library");
|
||||
library.setOpaque(false);
|
||||
// Poison count
|
||||
poisonLabel.setText("0");
|
||||
r = new Rectangle(14, 14);
|
||||
poisonLabel.setToolTipText("Poison");
|
||||
Image imagePoison = ImageHelper.getImageFromResources("/info/poison.png");
|
||||
BufferedImage resizedPoison = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imagePoison, BufferedImage.TYPE_INT_ARGB), r);
|
||||
poison = new ImagePanel(resizedPoison, ImagePanel.ACTUAL);
|
||||
poison.setToolTipText("Poison");
|
||||
poison.setOpaque(false);
|
||||
r = new Rectangle(19, 19);
|
||||
libraryLabel.setToolTipText("Library");
|
||||
Image imageLibrary = ImageHelper.getImageFromResources("/info/library.png");
|
||||
BufferedImage resizedLibrary = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageLibrary, BufferedImage.TYPE_INT_ARGB), r);
|
||||
library = new ImagePanel(resizedLibrary, ImagePanel.ACTUAL);
|
||||
library.setToolTipText("Library");
|
||||
library.setOpaque(false);
|
||||
|
||||
// Grave count and open graveyard button
|
||||
graveLabel = new JLabel();
|
||||
r = new Rectangle(21, 21);
|
||||
graveLabel.setToolTipText("Graveyard");
|
||||
Image imageGrave = ImageHelper.getImageFromResources("/info/grave.png");
|
||||
BufferedImage resizedGrave = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageGrave, BufferedImage.TYPE_INT_ARGB), r);
|
||||
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 count and open graveyard button
|
||||
graveLabel = new JLabel();
|
||||
r = new Rectangle(21, 21);
|
||||
graveLabel.setToolTipText("Graveyard");
|
||||
Image imageGrave = ImageHelper.getImageFromResources("/info/grave.png");
|
||||
BufferedImage resizedGrave = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageGrave, BufferedImage.TYPE_INT_ARGB), r);
|
||||
grave = new HoverButton(null, resizedGrave, resizedGrave, resizedGrave, r);
|
||||
grave.setToolTipText("Graveyard");
|
||||
grave.setOpaque(false);
|
||||
grave.setObserver(new Command() {
|
||||
@Override
|
||||
public void execute() {
|
||||
btnGraveActionPerformed(null);
|
||||
}
|
||||
});
|
||||
|
||||
// Cheat button
|
||||
r = new Rectangle(25, 21);
|
||||
image = ImageHelper.getImageFromResources("/info/cheat.png");
|
||||
resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
|
||||
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 button
|
||||
r = new Rectangle(25, 21);
|
||||
image = ImageHelper.getImageFromResources("/info/cheat.png");
|
||||
resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
|
||||
cheat = new JButton();
|
||||
cheat.setIcon(new ImageIcon(resized));
|
||||
cheat.setToolTipText("Cheat button");
|
||||
cheat.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
btnCheatActionPerformed(e);
|
||||
}
|
||||
});
|
||||
|
||||
btnPlayer = new JButton();
|
||||
btnPlayer.setText("Player");
|
||||
btnPlayer.setVisible(false);
|
||||
btnPlayer.setToolTipText("Player");
|
||||
btnPlayer.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
session.sendPlayerUUID(gameId, playerId);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Add mana symbols
|
||||
BufferedImage imageManaW = ManaSymbols.getManaSymbolImageSmall("W");
|
||||
ImagePanel manaW = new ImagePanel(imageManaW, ImagePanel.ACTUAL);
|
||||
manaW.setOpaque(false);
|
||||
JLabel manaCountLabelW = new JLabel();
|
||||
manaCountLabelW.setText("0");
|
||||
manaLabels.put("W", manaCountLabelW);
|
||||
btnPlayer = new JButton();
|
||||
btnPlayer.setText("Player");
|
||||
btnPlayer.setVisible(false);
|
||||
btnPlayer.setToolTipText("Player");
|
||||
btnPlayer.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
session.sendPlayerUUID(gameId, playerId);
|
||||
}
|
||||
});
|
||||
|
||||
BufferedImage imageManaU = ManaSymbols.getManaSymbolImageSmall("U");
|
||||
ImagePanel manaU = new ImagePanel(imageManaU, ImagePanel.ACTUAL);
|
||||
manaU.setOpaque(false);
|
||||
JLabel manaCountLabelU = new JLabel();
|
||||
manaCountLabelU.setText("0");
|
||||
manaLabels.put("U", manaCountLabelU);
|
||||
|
||||
BufferedImage imageManaB = ManaSymbols.getManaSymbolImageSmall("B");
|
||||
ImagePanel manaB = new ImagePanel(imageManaB, ImagePanel.ACTUAL);
|
||||
manaB.setOpaque(false);
|
||||
JLabel manaCountLabelB = new JLabel();
|
||||
manaCountLabelB.setText("0");
|
||||
manaLabels.put("B", manaCountLabelB);
|
||||
// Add mana symbols
|
||||
BufferedImage imageManaW = ManaSymbols.getManaSymbolImageSmall("W");
|
||||
ImagePanel manaW = new ImagePanel(imageManaW, ImagePanel.ACTUAL);
|
||||
manaW.setOpaque(false);
|
||||
JLabel manaCountLabelW = new JLabel();
|
||||
manaCountLabelW.setText("0");
|
||||
manaLabels.put("W", manaCountLabelW);
|
||||
|
||||
BufferedImage imageManaR = ManaSymbols.getManaSymbolImageSmall("R");
|
||||
ImagePanel manaR = new ImagePanel(imageManaR, ImagePanel.ACTUAL);
|
||||
manaR.setOpaque(false);
|
||||
JLabel manaCountLabelR = new JLabel();
|
||||
manaCountLabelR.setText("0");
|
||||
manaLabels.put("R", manaCountLabelR);
|
||||
BufferedImage imageManaU = ManaSymbols.getManaSymbolImageSmall("U");
|
||||
ImagePanel manaU = new ImagePanel(imageManaU, ImagePanel.ACTUAL);
|
||||
manaU.setOpaque(false);
|
||||
JLabel manaCountLabelU = new JLabel();
|
||||
manaCountLabelU.setText("0");
|
||||
manaLabels.put("U", manaCountLabelU);
|
||||
|
||||
BufferedImage imageManaG = ManaSymbols.getManaSymbolImageSmall("G");
|
||||
ImagePanel manaG = new ImagePanel(imageManaG, ImagePanel.ACTUAL);
|
||||
manaG.setOpaque(false);
|
||||
JLabel manaCountLabelG = new JLabel();
|
||||
manaCountLabelG.setText("0");
|
||||
manaLabels.put("G", manaCountLabelG);
|
||||
BufferedImage imageManaB = ManaSymbols.getManaSymbolImageSmall("B");
|
||||
ImagePanel manaB = new ImagePanel(imageManaB, ImagePanel.ACTUAL);
|
||||
manaB.setOpaque(false);
|
||||
JLabel manaCountLabelB = new JLabel();
|
||||
manaCountLabelB.setText("0");
|
||||
manaLabels.put("B", manaCountLabelB);
|
||||
|
||||
BufferedImage imageManaX = ManaSymbols.getManaSymbolImageSmall("X");
|
||||
ImagePanel manaX = new ImagePanel(imageManaX, ImagePanel.ACTUAL);
|
||||
manaX.setOpaque(false);
|
||||
JLabel manaCountLabelX = new JLabel();
|
||||
manaCountLabelX.setText("0");
|
||||
manaLabels.put("X", manaCountLabelX);
|
||||
GroupLayout gl_panelBackground = new GroupLayout(panelBackground);
|
||||
gl_panelBackground.setHorizontalGroup(
|
||||
gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(9)
|
||||
.addComponent(life, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(3)
|
||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(18)
|
||||
.addComponent(hand, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(lifeLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(4)
|
||||
.addComponent(handLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(9)
|
||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(3)
|
||||
.addComponent(poison, GroupLayout.PREFERRED_SIZE, 14, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(2)
|
||||
.addComponent(manaW, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(2)
|
||||
.addComponent(manaU, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(2)
|
||||
.addComponent(manaB, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(grave, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(18)
|
||||
.addComponent(library, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(poisonLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(20)
|
||||
.addComponent(manaR, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(1)
|
||||
.addComponent(manaCountLabelW, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)))
|
||||
.addGap(3)
|
||||
.addComponent(manaCountLabelR, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(1)
|
||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addComponent(manaCountLabelB, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(19)
|
||||
.addComponent(manaX, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)))
|
||||
.addGap(5)
|
||||
.addComponent(manaCountLabelX, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(20)
|
||||
.addComponent(manaG, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(40)
|
||||
.addComponent(manaCountLabelG, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(40)
|
||||
.addComponent(libraryLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(18)
|
||||
.addComponent(cheat, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(5)
|
||||
.addComponent(graveLabel, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(1)
|
||||
.addComponent(manaCountLabelU, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(6)
|
||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addComponent(btnPlayer, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(avatar, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
|
||||
.addGap(14))
|
||||
);
|
||||
gl_panelBackground.setVerticalGroup(
|
||||
gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(6)
|
||||
.addComponent(avatar, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(btnPlayer)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(1)
|
||||
.addComponent(life, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(1)
|
||||
.addComponent(hand, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(lifeLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(handLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(1)
|
||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(4)
|
||||
.addComponent(poison, GroupLayout.PREFERRED_SIZE, 14, GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(4)
|
||||
.addComponent(manaW, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(2)
|
||||
.addComponent(manaU, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(2)
|
||||
.addComponent(manaB, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(5)
|
||||
.addComponent(grave, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(1)
|
||||
.addComponent(library, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(poisonLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(2)
|
||||
.addComponent(manaR, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(14)
|
||||
.addComponent(manaCountLabelW, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(14)
|
||||
.addComponent(manaCountLabelR, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)))
|
||||
.addGap(4)
|
||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addComponent(manaCountLabelB, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(8)
|
||||
.addComponent(manaX, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(manaCountLabelX, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(39)
|
||||
.addComponent(manaG, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(31)
|
||||
.addComponent(manaCountLabelG, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(libraryLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(76)
|
||||
.addComponent(cheat, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(76)
|
||||
.addComponent(graveLabel, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(31)
|
||||
.addComponent(manaCountLabelU, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))))
|
||||
);
|
||||
panelBackground.setLayout(gl_panelBackground);
|
||||
GroupLayout groupLayout = new GroupLayout(this);
|
||||
groupLayout.setHorizontalGroup(
|
||||
groupLayout.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(groupLayout.createSequentialGroup()
|
||||
.addComponent(panelBackground, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||
);
|
||||
groupLayout.setVerticalGroup(
|
||||
groupLayout.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(groupLayout.createSequentialGroup()
|
||||
.addComponent(panelBackground, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||
);
|
||||
setLayout(groupLayout);
|
||||
BufferedImage imageManaR = ManaSymbols.getManaSymbolImageSmall("R");
|
||||
ImagePanel manaR = new ImagePanel(imageManaR, ImagePanel.ACTUAL);
|
||||
manaR.setOpaque(false);
|
||||
JLabel manaCountLabelR = new JLabel();
|
||||
manaCountLabelR.setText("0");
|
||||
manaLabels.put("R", manaCountLabelR);
|
||||
|
||||
BufferedImage imageManaG = ManaSymbols.getManaSymbolImageSmall("G");
|
||||
ImagePanel manaG = new ImagePanel(imageManaG, ImagePanel.ACTUAL);
|
||||
manaG.setOpaque(false);
|
||||
JLabel manaCountLabelG = new JLabel();
|
||||
manaCountLabelG.setText("0");
|
||||
manaLabels.put("G", manaCountLabelG);
|
||||
|
||||
BufferedImage imageManaX = ManaSymbols.getManaSymbolImageSmall("X");
|
||||
ImagePanel manaX = new ImagePanel(imageManaX, ImagePanel.ACTUAL);
|
||||
manaX.setOpaque(false);
|
||||
JLabel manaCountLabelX = new JLabel();
|
||||
manaCountLabelX.setText("0");
|
||||
manaLabels.put("X", manaCountLabelX);
|
||||
GroupLayout gl_panelBackground = new GroupLayout(panelBackground);
|
||||
gl_panelBackground.setHorizontalGroup(
|
||||
gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(9)
|
||||
.addComponent(life, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(3)
|
||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(18)
|
||||
.addComponent(hand, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(lifeLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(4)
|
||||
.addComponent(handLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(9)
|
||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(3)
|
||||
.addComponent(poison, GroupLayout.PREFERRED_SIZE, 14, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(2)
|
||||
.addComponent(manaW, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(2)
|
||||
.addComponent(manaU, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(2)
|
||||
.addComponent(manaB, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(grave, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(18)
|
||||
.addComponent(library, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(poisonLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(20)
|
||||
.addComponent(manaR, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(1)
|
||||
.addComponent(manaCountLabelW, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)))
|
||||
.addGap(3)
|
||||
.addComponent(manaCountLabelR, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(1)
|
||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addComponent(manaCountLabelB, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(19)
|
||||
.addComponent(manaX, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)))
|
||||
.addGap(5)
|
||||
.addComponent(manaCountLabelX, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(20)
|
||||
.addComponent(manaG, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(40)
|
||||
.addComponent(manaCountLabelG, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(40)
|
||||
.addComponent(libraryLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(18)
|
||||
.addComponent(cheat, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(5)
|
||||
.addComponent(graveLabel, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(1)
|
||||
.addComponent(manaCountLabelU, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(6)
|
||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addComponent(btnPlayer, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(avatar, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
|
||||
.addGap(14))
|
||||
);
|
||||
gl_panelBackground.setVerticalGroup(
|
||||
gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(6)
|
||||
.addComponent(avatar, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(btnPlayer)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(1)
|
||||
.addComponent(life, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(1)
|
||||
.addComponent(hand, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(lifeLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(handLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(1)
|
||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(4)
|
||||
.addComponent(poison, GroupLayout.PREFERRED_SIZE, 14, GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(4)
|
||||
.addComponent(manaW, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(2)
|
||||
.addComponent(manaU, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(2)
|
||||
.addComponent(manaB, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(5)
|
||||
.addComponent(grave, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(1)
|
||||
.addComponent(library, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(poisonLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(2)
|
||||
.addComponent(manaR, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(14)
|
||||
.addComponent(manaCountLabelW, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(14)
|
||||
.addComponent(manaCountLabelR, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)))
|
||||
.addGap(4)
|
||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addComponent(manaCountLabelB, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(8)
|
||||
.addComponent(manaX, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(manaCountLabelX, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(39)
|
||||
.addComponent(manaG, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(31)
|
||||
.addComponent(manaCountLabelG, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(libraryLabel, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(76)
|
||||
.addComponent(cheat, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(76)
|
||||
.addComponent(graveLabel, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(31)
|
||||
.addComponent(manaCountLabelU, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))))
|
||||
);
|
||||
panelBackground.setLayout(gl_panelBackground);
|
||||
GroupLayout groupLayout = new GroupLayout(this);
|
||||
groupLayout.setHorizontalGroup(
|
||||
groupLayout.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(groupLayout.createSequentialGroup()
|
||||
.addComponent(panelBackground, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||
);
|
||||
groupLayout.setVerticalGroup(
|
||||
groupLayout.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(groupLayout.createSequentialGroup()
|
||||
.addComponent(panelBackground, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||
);
|
||||
setLayout(groupLayout);
|
||||
|
||||
}
|
||||
|
||||
|
@ -502,42 +502,42 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
panelBackground.setBounds(0, 0, 92, 160);
|
||||
}
|
||||
else {
|
||||
avatar.setVisible(true);
|
||||
btnPlayer.setVisible(false);
|
||||
panelBackground.setPreferredSize(new Dimension(92, 212));
|
||||
panelBackground.setBounds(0, 0, 92, 212);
|
||||
avatar.setVisible(true);
|
||||
btnPlayer.setVisible(false);
|
||||
panelBackground.setPreferredSize(new Dimension(92, 212));
|
||||
panelBackground.setBounds(0, 0, 92, 212);
|
||||
}
|
||||
}
|
||||
|
||||
private void btnGraveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGraveActionPerformed
|
||||
if (graveyard == null) {
|
||||
graveyard = new ShowCardsDialog();
|
||||
}
|
||||
graveyard.loadCards(player.getName() + " graveyard", player.getGraveyard(), bigCard, Config.dimensions, gameId, false);
|
||||
}
|
||||
private void btnGraveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGraveActionPerformed
|
||||
if (graveyard == null) {
|
||||
graveyard = new ShowCardsDialog();
|
||||
}
|
||||
graveyard.loadCards(player.getName() + " graveyard", player.getGraveyard(), bigCard, Config.dimensions, gameId, false);
|
||||
}
|
||||
|
||||
private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCheatActionPerformed
|
||||
DckDeckImporter deckImporter = new DckDeckImporter();
|
||||
session.cheat(gameId, playerId, deckImporter.importDeck("cheat.dck"));
|
||||
}
|
||||
private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCheatActionPerformed
|
||||
DckDeckImporter deckImporter = new DckDeckImporter();
|
||||
session.cheat(gameId, playerId, deckImporter.importDeck("cheat.dck"));
|
||||
}
|
||||
|
||||
private HoverButton avatar;
|
||||
private JButton btnPlayer;
|
||||
private ImagePanel life;
|
||||
private ImagePanel poison;
|
||||
private ImagePanel hand;
|
||||
private HoverButton grave;
|
||||
private ImagePanel library;
|
||||
private CardView topCard;
|
||||
private MageCard topCardPanel;
|
||||
private JButton cheat;
|
||||
private MageRoundPane panelBackground;
|
||||
private HoverButton avatar;
|
||||
private JButton btnPlayer;
|
||||
private ImagePanel life;
|
||||
private ImagePanel poison;
|
||||
private ImagePanel hand;
|
||||
private HoverButton grave;
|
||||
private ImagePanel library;
|
||||
private CardView topCard;
|
||||
private MageCard topCardPanel;
|
||||
private JButton cheat;
|
||||
private MageRoundPane panelBackground;
|
||||
|
||||
private JLabel lifeLabel;
|
||||
private JLabel handLabel;
|
||||
private JLabel libraryLabel;
|
||||
private JLabel poisonLabel;
|
||||
private JLabel graveLabel;
|
||||
private JLabel lifeLabel;
|
||||
private JLabel handLabel;
|
||||
private JLabel libraryLabel;
|
||||
private JLabel poisonLabel;
|
||||
private JLabel graveLabel;
|
||||
|
||||
private Map<String, JLabel> manaLabels = new HashMap<String, JLabel>();
|
||||
private Map<String, JLabel> manaLabels = new HashMap<String, JLabel>();
|
||||
}
|
||||
|
|
|
@ -17,25 +17,25 @@ import java.util.Set;
|
|||
import java.util.UUID;
|
||||
|
||||
public interface MagePlugins {
|
||||
void loadPlugins();
|
||||
void shutdown();
|
||||
void updateGamePanel(Map<String, JComponent> ui);
|
||||
JComponent updateTablePanel(Map<String, JComponent> ui);
|
||||
MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage);
|
||||
MageCard getMageCard(CardView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage);
|
||||
boolean isThemePluginLoaded();
|
||||
boolean isCardPluginLoaded();
|
||||
boolean isCounterPluginLoaded();
|
||||
int sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> permanents);
|
||||
boolean newImage(Set<Card> allCards);
|
||||
void downloadImage(Set<Card> allCards);
|
||||
void downloadSymbols();
|
||||
int getGamesPlayed();
|
||||
void addGamesPlayed();
|
||||
Image getManaSymbolImage(String symbol);
|
||||
void onAddCard(MagePermanent card, int count);
|
||||
void onRemoveCard(MagePermanent card, int count);
|
||||
void loadPlugins();
|
||||
void shutdown();
|
||||
void updateGamePanel(Map<String, JComponent> ui);
|
||||
JComponent updateTablePanel(Map<String, JComponent> ui);
|
||||
MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage);
|
||||
MageCard getMageCard(CardView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage);
|
||||
boolean isThemePluginLoaded();
|
||||
boolean isCardPluginLoaded();
|
||||
boolean isCounterPluginLoaded();
|
||||
int sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> permanents);
|
||||
boolean newImage(Set<Card> allCards);
|
||||
void downloadImage(Set<Card> allCards);
|
||||
void downloadSymbols();
|
||||
int getGamesPlayed();
|
||||
void addGamesPlayed();
|
||||
Image getManaSymbolImage(String symbol);
|
||||
void onAddCard(MagePermanent card, int count);
|
||||
void onRemoveCard(MagePermanent card, int count);
|
||||
JComponent getCardInfoPane();
|
||||
BufferedImage getOriginalImage(CardView card);
|
||||
ActionCallback getActionCallback();
|
||||
BufferedImage getOriginalImage(CardView card);
|
||||
ActionCallback getActionCallback();
|
||||
}
|
||||
|
|
|
@ -184,9 +184,9 @@ public class MageActionCallback implements ActionCallback {
|
|||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!state) {
|
||||
return;
|
||||
}
|
||||
if (!state) {
|
||||
return;
|
||||
}
|
||||
popupContainer.setVisible(true);
|
||||
c.repaint();
|
||||
}
|
||||
|
|
|
@ -32,183 +32,183 @@ import java.util.*;
|
|||
|
||||
public class Plugins implements MagePlugins {
|
||||
|
||||
private final static MagePlugins fINSTANCE = new Plugins();
|
||||
private final static Logger logger = Logger.getLogger(Plugins.class);
|
||||
private static PluginManager pm;
|
||||
|
||||
private ThemePlugin themePlugin = null;
|
||||
private CardPlugin cardPlugin = null;
|
||||
private CounterPlugin counterPlugin = null;
|
||||
private static final MageActionCallback mageActionCallback = new MageActionCallback();
|
||||
private Map<String, String> sortingOptions = new HashMap<String, String>();
|
||||
|
||||
public static MagePlugins getInstance() {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadPlugins() {
|
||||
logger.info("Loading plugins...");
|
||||
pm = PluginManagerFactory.createPluginManager();
|
||||
pm.addPluginsFrom(new File(Constants.PLUGINS_DIRECTORY).toURI());
|
||||
this.cardPlugin = new CardPluginImpl();
|
||||
this.counterPlugin = pm.getPlugin(CounterPlugin.class);
|
||||
this.themePlugin = pm.getPlugin(ThemePlugin.class);
|
||||
logger.info("Done.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
if (pm != null) pm.shutdown();
|
||||
}
|
||||
private final static MagePlugins fINSTANCE = new Plugins();
|
||||
private final static Logger logger = Logger.getLogger(Plugins.class);
|
||||
private static PluginManager pm;
|
||||
|
||||
@Override
|
||||
public void updateGamePanel(Map<String, JComponent> ui) {
|
||||
if (MageFrame.isLite() || MageFrame.isGray() || themePlugin == null) return;
|
||||
themePlugin.applyInGame(ui);
|
||||
}
|
||||
private ThemePlugin themePlugin = null;
|
||||
private CardPlugin cardPlugin = null;
|
||||
private CounterPlugin counterPlugin = null;
|
||||
private static final MageActionCallback mageActionCallback = new MageActionCallback();
|
||||
private Map<String, String> sortingOptions = new HashMap<String, String>();
|
||||
|
||||
@Override
|
||||
public JComponent updateTablePanel(Map<String, JComponent> ui) {
|
||||
if (MageFrame.isLite() || MageFrame.isGray() || themePlugin == null) return null;
|
||||
return themePlugin.updateTable(ui);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage) {
|
||||
if (cardPlugin != null) {
|
||||
mageActionCallback.refreshSession();
|
||||
mageActionCallback.setCardPreviewComponent(bigCard);
|
||||
return cardPlugin.getMagePermanent(card, dimension, gameId, mageActionCallback, false, !MageFrame.isLite() && loadImage);
|
||||
} else {
|
||||
return new Permanent(card, bigCard, Config.dimensions, gameId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MageCard getMageCard(CardView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage) {
|
||||
if (cardPlugin != null) {
|
||||
mageActionCallback.refreshSession();
|
||||
mageActionCallback.setCardPreviewComponent(bigCard);
|
||||
return cardPlugin.getMageCard(card, dimension, gameId, mageActionCallback, false, !MageFrame.isLite() && loadImage);
|
||||
} else {
|
||||
return new Card(card, bigCard, Config.dimensions, gameId);
|
||||
}
|
||||
}
|
||||
public static MagePlugins getInstance() {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadPlugins() {
|
||||
logger.info("Loading plugins...");
|
||||
pm = PluginManagerFactory.createPluginManager();
|
||||
pm.addPluginsFrom(new File(Constants.PLUGINS_DIRECTORY).toURI());
|
||||
this.cardPlugin = new CardPluginImpl();
|
||||
this.counterPlugin = pm.getPlugin(CounterPlugin.class);
|
||||
this.themePlugin = pm.getPlugin(ThemePlugin.class);
|
||||
logger.info("Done.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
if (pm != null) pm.shutdown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateGamePanel(Map<String, JComponent> ui) {
|
||||
if (MageFrame.isLite() || MageFrame.isGray() || themePlugin == null) return;
|
||||
themePlugin.applyInGame(ui);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent updateTablePanel(Map<String, JComponent> ui) {
|
||||
if (MageFrame.isLite() || MageFrame.isGray() || themePlugin == null) return null;
|
||||
return themePlugin.updateTable(ui);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage) {
|
||||
if (cardPlugin != null) {
|
||||
mageActionCallback.refreshSession();
|
||||
mageActionCallback.setCardPreviewComponent(bigCard);
|
||||
return cardPlugin.getMagePermanent(card, dimension, gameId, mageActionCallback, false, !MageFrame.isLite() && loadImage);
|
||||
} else {
|
||||
return new Permanent(card, bigCard, Config.dimensions, gameId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MageCard getMageCard(CardView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage) {
|
||||
if (cardPlugin != null) {
|
||||
mageActionCallback.refreshSession();
|
||||
mageActionCallback.setCardPreviewComponent(bigCard);
|
||||
return cardPlugin.getMageCard(card, dimension, gameId, mageActionCallback, false, !MageFrame.isLite() && loadImage);
|
||||
} else {
|
||||
return new Card(card, bigCard, Config.dimensions, gameId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isCardPluginLoaded() {
|
||||
return this.cardPlugin != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> permanents) {
|
||||
sortingOptions.put("nonLandPermanentsInOnePile", PreferencesDialog.getCachedValue("nonLandPermanentsInOnePile", "false"));
|
||||
if (this.cardPlugin != null) return this.cardPlugin.sortPermanents(ui, permanents, sortingOptions);
|
||||
@Override
|
||||
public boolean isCardPluginLoaded() {
|
||||
return this.cardPlugin != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> permanents) {
|
||||
sortingOptions.put("nonLandPermanentsInOnePile", PreferencesDialog.getCachedValue("nonLandPermanentsInOnePile", "false"));
|
||||
if (this.cardPlugin != null) return this.cardPlugin.sortPermanents(ui, permanents, sortingOptions);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean newImage(Set<mage.cards.Card> allCards) {
|
||||
@Override
|
||||
public boolean newImage(Set<mage.cards.Card> allCards) {
|
||||
String useDefault = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_USE_DEFAULT, "true");
|
||||
String path = useDefault.equals("true") ? null : PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PATH, null);
|
||||
return this.cardPlugin.newImages(allCards, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadImage(Set<mage.cards.Card> allCards) {
|
||||
return this.cardPlugin.newImages(allCards, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadImage(Set<mage.cards.Card> allCards) {
|
||||
String useDefault = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_USE_DEFAULT, "true");
|
||||
String path = useDefault.equals("true") ? null : PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PATH, null);
|
||||
if (this.cardPlugin != null) this.cardPlugin.downloadImages(allCards, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadSymbols() {
|
||||
if (this.cardPlugin != null) this.cardPlugin.downloadImages(allCards, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadSymbols() {
|
||||
String useDefault = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_USE_DEFAULT, "true");
|
||||
String path = useDefault.equals("true") ? null : PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PATH, null);
|
||||
if (this.cardPlugin != null) this.cardPlugin.downloadSymbols(path);
|
||||
}
|
||||
if (this.cardPlugin != null) this.cardPlugin.downloadSymbols(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGamesPlayed() {
|
||||
if (this.counterPlugin != null) {
|
||||
synchronized(Plugins.class) {
|
||||
try {
|
||||
return this.counterPlugin.getGamePlayed();
|
||||
} catch (PluginException e) {
|
||||
logger.fatal(e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@Override
|
||||
public int getGamesPlayed() {
|
||||
if (this.counterPlugin != null) {
|
||||
synchronized(Plugins.class) {
|
||||
try {
|
||||
return this.counterPlugin.getGamePlayed();
|
||||
} catch (PluginException e) {
|
||||
logger.fatal(e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGamesPlayed() {
|
||||
if (this.counterPlugin != null) {
|
||||
synchronized(Plugins.class) {
|
||||
try {
|
||||
this.counterPlugin.addGamePlayed();
|
||||
} catch (PluginException e) {
|
||||
logger.fatal(e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void addGamesPlayed() {
|
||||
if (this.counterPlugin != null) {
|
||||
synchronized(Plugins.class) {
|
||||
try {
|
||||
this.counterPlugin.addGamePlayed();
|
||||
} catch (PluginException e) {
|
||||
logger.fatal(e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCounterPluginLoaded() {
|
||||
return this.counterPlugin != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isThemePluginLoaded() {
|
||||
return this.themePlugin != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getManaSymbolImage(String symbol) {
|
||||
if (this.cardPlugin != null) {
|
||||
return this.cardPlugin.getManaSymbolImage(symbol);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public boolean isCounterPluginLoaded() {
|
||||
return this.counterPlugin != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddCard(MagePermanent card, int count) {
|
||||
if (this.cardPlugin != null) {
|
||||
this.cardPlugin.onAddCard(card, count);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean isThemePluginLoaded() {
|
||||
return this.themePlugin != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoveCard(MagePermanent card, int count) {
|
||||
if (this.cardPlugin != null) {
|
||||
this.cardPlugin.onRemoveCard(card, count);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Image getManaSymbolImage(String symbol) {
|
||||
if (this.cardPlugin != null) {
|
||||
return this.cardPlugin.getManaSymbolImage(symbol);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddCard(MagePermanent card, int count) {
|
||||
if (this.cardPlugin != null) {
|
||||
this.cardPlugin.onAddCard(card, count);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoveCard(MagePermanent card, int count) {
|
||||
if (this.cardPlugin != null) {
|
||||
this.cardPlugin.onRemoveCard(card, count);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getCardInfoPane() {
|
||||
if (this.cardPlugin != null) {
|
||||
return this.cardPlugin.getCardInfoPane();
|
||||
}
|
||||
return this.cardPlugin.getCardInfoPane();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedImage getOriginalImage(CardView card) {
|
||||
if (this.cardPlugin != null) {
|
||||
return this.cardPlugin.getOriginalImage(card);
|
||||
}
|
||||
@Override
|
||||
public BufferedImage getOriginalImage(CardView card) {
|
||||
if (this.cardPlugin != null) {
|
||||
return this.cardPlugin.getOriginalImage(card);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public ActionCallback getActionCallback() {
|
||||
return mageActionCallback;
|
||||
}
|
||||
public ActionCallback getActionCallback() {
|
||||
return mageActionCallback;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,308 +53,308 @@ import java.util.UUID;
|
|||
*/
|
||||
public class CallbackClientImpl implements CallbackClient {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(CallbackClientImpl.class);
|
||||
private final static Logger logger = Logger.getLogger(CallbackClientImpl.class);
|
||||
|
||||
private UUID clientId;
|
||||
private MageFrame frame;
|
||||
private int messageId = 0;
|
||||
private UUID clientId;
|
||||
private MageFrame frame;
|
||||
private int messageId = 0;
|
||||
|
||||
public CallbackClientImpl(MageFrame frame) {
|
||||
public CallbackClientImpl(MageFrame frame) {
|
||||
|
||||
this.clientId = UUID.randomUUID();
|
||||
this.frame = frame;
|
||||
this.clientId = UUID.randomUUID();
|
||||
this.frame = frame;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void processCallback(final ClientCallback callback) {
|
||||
logger.info(callback.getMessageId() + " - " + callback.getMethod());
|
||||
SaveObjectUtil.saveObject(callback.getData(), callback.getMethod());
|
||||
callback.setData(CompressUtil.decompress(callback.getData()));
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
logger.info(callback.getMessageId() + " -- " + callback.getMethod());
|
||||
if (callback.getMethod().equals("startGame")) {
|
||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
GameManager.getInstance().setCurrentPlayerUUID(message.getPlayerId());
|
||||
gameStarted(message.getGameId(), message.getPlayerId());
|
||||
}
|
||||
else if(callback.getMethod().equals("startTournament")) {
|
||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
tournamentStarted(message.getGameId(), message.getPlayerId());
|
||||
}
|
||||
else if(callback.getMethod().equals("startDraft")) {
|
||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
draftStarted(message.getGameId(), message.getPlayerId());
|
||||
}
|
||||
else if (callback.getMethod().equals("replayGame")) {
|
||||
replayGame(callback.getObjectId());
|
||||
}
|
||||
else if (callback.getMethod().equals("watchGame")) {
|
||||
watchGame((UUID) callback.getObjectId());
|
||||
}
|
||||
else if (callback.getMethod().equals("chatMessage")) {
|
||||
ChatMessage message = (ChatMessage) callback.getData();
|
||||
ChatPanel panel = frame.getChat(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
if (message.isUserMessage() && panel.getConnectedChat() != null) {
|
||||
panel.getConnectedChat().receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), ChatMessage.MessageColor.BLACK);
|
||||
} else {
|
||||
panel.receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getColor());
|
||||
}
|
||||
}
|
||||
} else if (callback.getMethod().equals("serverMessage")) {
|
||||
@Override
|
||||
public synchronized void processCallback(final ClientCallback callback) {
|
||||
logger.info(callback.getMessageId() + " - " + callback.getMethod());
|
||||
SaveObjectUtil.saveObject(callback.getData(), callback.getMethod());
|
||||
callback.setData(CompressUtil.decompress(callback.getData()));
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
logger.info(callback.getMessageId() + " -- " + callback.getMethod());
|
||||
if (callback.getMethod().equals("startGame")) {
|
||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
GameManager.getInstance().setCurrentPlayerUUID(message.getPlayerId());
|
||||
gameStarted(message.getGameId(), message.getPlayerId());
|
||||
}
|
||||
else if(callback.getMethod().equals("startTournament")) {
|
||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
tournamentStarted(message.getGameId(), message.getPlayerId());
|
||||
}
|
||||
else if(callback.getMethod().equals("startDraft")) {
|
||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
draftStarted(message.getGameId(), message.getPlayerId());
|
||||
}
|
||||
else if (callback.getMethod().equals("replayGame")) {
|
||||
replayGame(callback.getObjectId());
|
||||
}
|
||||
else if (callback.getMethod().equals("watchGame")) {
|
||||
watchGame((UUID) callback.getObjectId());
|
||||
}
|
||||
else if (callback.getMethod().equals("chatMessage")) {
|
||||
ChatMessage message = (ChatMessage) callback.getData();
|
||||
ChatPanel panel = frame.getChat(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
if (message.isUserMessage() && panel.getConnectedChat() != null) {
|
||||
panel.getConnectedChat().receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), ChatMessage.MessageColor.BLACK);
|
||||
} else {
|
||||
panel.receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getColor());
|
||||
}
|
||||
}
|
||||
} else if (callback.getMethod().equals("serverMessage")) {
|
||||
if (callback.getData() != null) {
|
||||
ChatMessage message = (ChatMessage) callback.getData();
|
||||
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);
|
||||
}
|
||||
}
|
||||
} else if (callback.getMethod().equals("joinedTable")) {
|
||||
} else if (callback.getMethod().equals("joinedTable")) {
|
||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
joinedTable(message.getRoomId(), message.getTableId(), message.getFlag());
|
||||
}
|
||||
else if (callback.getMethod().equals("replayInit")) {
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.init((GameView) callback.getData());
|
||||
}
|
||||
else if (callback.getMethod().equals("replayDone")) {
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
panel.endMessage((String) callback.getData());
|
||||
}
|
||||
}
|
||||
else if (callback.getMethod().equals("replayUpdate")) {
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.updateGame((GameView) callback.getData());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameInit")) {
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
panel.init((GameView) callback.getData());
|
||||
}
|
||||
else if (callback.getMethod().equals("replayInit")) {
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.init((GameView) callback.getData());
|
||||
}
|
||||
else if (callback.getMethod().equals("replayDone")) {
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
panel.endMessage((String) callback.getData());
|
||||
}
|
||||
}
|
||||
else if (callback.getMethod().equals("replayUpdate")) {
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.updateGame((GameView) callback.getData());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameInit")) {
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
panel.init((GameView) callback.getData());
|
||||
|
||||
}
|
||||
}
|
||||
else if (callback.getMethod().equals("gameOver")) {
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
panel.endMessage((String) callback.getData());
|
||||
}
|
||||
}
|
||||
else if (callback.getMethod().equals("gameError")) {
|
||||
}
|
||||
}
|
||||
else if (callback.getMethod().equals("gameOver")) {
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
panel.endMessage((String) callback.getData());
|
||||
}
|
||||
}
|
||||
else if (callback.getMethod().equals("gameError")) {
|
||||
frame.showErrorDialog("Game Error", (String) callback.getData());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameAsk")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.ask(message.getMessage(), message.getGameView());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameTarget")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.pickTarget(message.getMessage(), message.getCardsView(), message.getGameView(), message.getTargets(), message.isFlag(), message.getOptions());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameSelect")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.select(message.getMessage(), message.getGameView());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameChooseAbility")) {
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.pickAbility((AbilityPickerView) callback.getData());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameChoosePile")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.pickPile(message.getMessage(), message.getPile1(), message.getPile2());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameChoose")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.getChoice(message.getMessage(), message.getStrings());
|
||||
}
|
||||
else if (callback.getMethod().equals("gamePlayMana")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.playMana(message.getMessage(), message.getGameView());
|
||||
}
|
||||
else if (callback.getMethod().equals("gamePlayXMana")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.playXMana(message.getMessage(), message.getGameView());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameSelectAmount")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.getAmount(message.getMin(), message.getMax(), message.getMessage());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameUpdate")) {
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.updateGame((GameView) callback.getData());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameInform")) {
|
||||
|
||||
if (callback.getMessageId() > messageId) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.inform(message.getMessage(), message.getGameView());
|
||||
}
|
||||
else {
|
||||
logger.warn("message out of sequence - ignoring");
|
||||
}
|
||||
}
|
||||
else if (callback.getMethod().equals("sideboard")) {
|
||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
DeckView deckView = message.getDeck();
|
||||
Deck deck = DeckUtil.construct(deckView);
|
||||
}
|
||||
else if (callback.getMethod().equals("gameAsk")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.ask(message.getMessage(), message.getGameView());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameTarget")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.pickTarget(message.getMessage(), message.getCardsView(), message.getGameView(), message.getTargets(), message.isFlag(), message.getOptions());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameSelect")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.select(message.getMessage(), message.getGameView());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameChooseAbility")) {
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.pickAbility((AbilityPickerView) callback.getData());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameChoosePile")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.pickPile(message.getMessage(), message.getPile1(), message.getPile2());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameChoose")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.getChoice(message.getMessage(), message.getStrings());
|
||||
}
|
||||
else if (callback.getMethod().equals("gamePlayMana")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.playMana(message.getMessage(), message.getGameView());
|
||||
}
|
||||
else if (callback.getMethod().equals("gamePlayXMana")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.playXMana(message.getMessage(), message.getGameView());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameSelectAmount")) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.getAmount(message.getMin(), message.getMax(), message.getMessage());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameUpdate")) {
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.updateGame((GameView) callback.getData());
|
||||
}
|
||||
else if (callback.getMethod().equals("gameInform")) {
|
||||
|
||||
if (callback.getMessageId() > messageId) {
|
||||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.inform(message.getMessage(), message.getGameView());
|
||||
}
|
||||
else {
|
||||
logger.warn("message out of sequence - ignoring");
|
||||
}
|
||||
}
|
||||
else if (callback.getMethod().equals("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());
|
||||
}
|
||||
else if (callback.getMethod().equals("construct")) {
|
||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
DeckView deckView = message.getDeck();
|
||||
Deck deck = DeckUtil.construct(deckView);
|
||||
construct(deck, message.getTableId(), message.getTime());
|
||||
}
|
||||
else if (callback.getMethod().equals("draftOver")) {
|
||||
DraftPanel panel = frame.getDraft(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.hideDraft();
|
||||
}
|
||||
else if (callback.getMethod().equals("draftPick")) {
|
||||
DraftClientMessage message = (DraftClientMessage) callback.getData();
|
||||
DraftPanel panel = frame.getDraft(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.loadBooster(message.getDraftPickView());
|
||||
}
|
||||
else if (callback.getMethod().equals("draftUpdate")) {
|
||||
DraftPanel panel = frame.getDraft(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.updateDraft((DraftView) callback.getData());
|
||||
}
|
||||
else if (callback.getMethod().equals("draftInform")) {
|
||||
if (callback.getMessageId() > messageId) {
|
||||
DraftClientMessage message = (DraftClientMessage) callback.getData();
|
||||
}
|
||||
else {
|
||||
logger.warn("message out of sequence - ignoring");
|
||||
}
|
||||
}
|
||||
else if (callback.getMethod().equals("draftInit")) {
|
||||
DraftClientMessage message = (DraftClientMessage) callback.getData();
|
||||
DraftPanel panel = frame.getDraft(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.loadBooster(message.getDraftPickView());
|
||||
}
|
||||
else if (callback.getMethod().equals("tournamentInit")) {
|
||||
}
|
||||
else if (callback.getMethod().equals("construct")) {
|
||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||
DeckView deckView = message.getDeck();
|
||||
Deck deck = DeckUtil.construct(deckView);
|
||||
construct(deck, message.getTableId(), message.getTime());
|
||||
}
|
||||
else if (callback.getMethod().equals("draftOver")) {
|
||||
DraftPanel panel = frame.getDraft(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.hideDraft();
|
||||
}
|
||||
else if (callback.getMethod().equals("draftPick")) {
|
||||
DraftClientMessage message = (DraftClientMessage) callback.getData();
|
||||
DraftPanel panel = frame.getDraft(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.loadBooster(message.getDraftPickView());
|
||||
}
|
||||
else if (callback.getMethod().equals("draftUpdate")) {
|
||||
DraftPanel panel = frame.getDraft(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.updateDraft((DraftView) callback.getData());
|
||||
}
|
||||
else if (callback.getMethod().equals("draftInform")) {
|
||||
if (callback.getMessageId() > messageId) {
|
||||
DraftClientMessage message = (DraftClientMessage) callback.getData();
|
||||
}
|
||||
else {
|
||||
logger.warn("message out of sequence - ignoring");
|
||||
}
|
||||
}
|
||||
else if (callback.getMethod().equals("draftInit")) {
|
||||
DraftClientMessage message = (DraftClientMessage) callback.getData();
|
||||
DraftPanel panel = frame.getDraft(callback.getObjectId());
|
||||
if (panel != null)
|
||||
panel.loadBooster(message.getDraftPickView());
|
||||
}
|
||||
else if (callback.getMethod().equals("tournamentInit")) {
|
||||
|
||||
}
|
||||
messageId = callback.getMessageId();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
messageId = callback.getMessageId();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public UUID getId() {
|
||||
return clientId;
|
||||
}
|
||||
public UUID getId() {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
private void joinedTable(UUID roomId, UUID tableId, boolean isTournament) {
|
||||
try {
|
||||
frame.showTableWaitingDialog(roomId, tableId, isTournament);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected void gameStarted(final UUID gameId, final UUID playerId) {
|
||||
try {
|
||||
frame.showGame(gameId, playerId);
|
||||
logger.info("Game " + gameId + " started for player " + playerId);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
|
||||
if (Plugins.getInstance().isCounterPluginLoaded()) {
|
||||
Plugins.getInstance().addGamesPlayed();
|
||||
}
|
||||
}
|
||||
protected void gameStarted(final UUID gameId, final UUID playerId) {
|
||||
try {
|
||||
frame.showGame(gameId, playerId);
|
||||
logger.info("Game " + gameId + " started for player " + playerId);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
|
||||
protected void draftStarted(UUID draftId, UUID playerId) {
|
||||
try {
|
||||
frame.showDraft(draftId);
|
||||
logger.info("Draft " + draftId + " started for player " + playerId);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
if (Plugins.getInstance().isCounterPluginLoaded()) {
|
||||
Plugins.getInstance().addGamesPlayed();
|
||||
}
|
||||
}
|
||||
|
||||
protected void tournamentStarted(UUID tournamentId, UUID playerId) {
|
||||
try {
|
||||
frame.showTournament(tournamentId);
|
||||
logger.info("Tournament " + tournamentId + " started for player " + playerId);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
protected void draftStarted(UUID draftId, UUID playerId) {
|
||||
try {
|
||||
frame.showDraft(draftId);
|
||||
logger.info("Draft " + draftId + " started for player " + playerId);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected void watchGame(UUID gameId) {
|
||||
try {
|
||||
frame.watchGame(gameId);
|
||||
logger.info("Watching game " + gameId);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
protected void tournamentStarted(UUID tournamentId, UUID playerId) {
|
||||
try {
|
||||
frame.showTournament(tournamentId);
|
||||
logger.info("Tournament " + tournamentId + " started for player " + playerId);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected void replayGame(UUID gameId) {
|
||||
try {
|
||||
frame.replayGame(gameId);
|
||||
logger.info("Replaying game");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
protected void watchGame(UUID gameId) {
|
||||
try {
|
||||
frame.watchGame(gameId);
|
||||
logger.info("Watching game " + gameId);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected void sideboard(Deck deck, UUID tableId, int time) {
|
||||
frame.showDeckEditor(DeckEditorMode.Sideboard, deck, tableId, time);
|
||||
}
|
||||
protected void replayGame(UUID gameId) {
|
||||
try {
|
||||
frame.replayGame(gameId);
|
||||
logger.info("Replaying game");
|
||||
}
|
||||
catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected void construct(Deck deck, UUID tableId, int time) {
|
||||
frame.showDeckEditor(DeckEditorMode.Limited, deck, tableId, time);
|
||||
}
|
||||
protected void sideboard(Deck deck, UUID tableId, int time) {
|
||||
frame.showDeckEditor(DeckEditorMode.Sideboard, deck, tableId, time);
|
||||
}
|
||||
|
||||
private void handleException(Exception ex) {
|
||||
logger.fatal("Client error\n", ex);
|
||||
frame.showError("Error: " + ex.getMessage());
|
||||
}
|
||||
protected void construct(Deck deck, UUID tableId, int time) {
|
||||
frame.showDeckEditor(DeckEditorMode.Limited, deck, tableId, time);
|
||||
}
|
||||
|
||||
private void handleException(Exception ex) {
|
||||
logger.fatal("Client error\n", ex);
|
||||
frame.showError("Error: " + ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,68 +48,68 @@ import mage.client.util.Config;
|
|||
*/
|
||||
public class NewPlayerPanel extends javax.swing.JPanel {
|
||||
|
||||
private JFileChooser fcSelectDeck;
|
||||
private JFileChooser fcSelectDeck;
|
||||
|
||||
/** Creates new form NewPlayerPanel */
|
||||
public NewPlayerPanel() {
|
||||
initComponents();
|
||||
fcSelectDeck = new JFileChooser();
|
||||
fcSelectDeck.setAcceptAllFileFilterUsed(false);
|
||||
fcSelectDeck.addChoosableFileFilter(new DeckFilter());
|
||||
String deckPath = MageFrame.getPreferences().get("defaultDeckPath", "");
|
||||
if (deckPath.isEmpty()) {
|
||||
if (Config.defaultDeckPath != null) deckPath = Config.defaultDeckPath;
|
||||
}
|
||||
this.txtPlayerDeck.setText(deckPath);
|
||||
if (Config.defaultComputerName != null) this.txtPlayerName.setText(Config.defaultComputerName);
|
||||
if (cbLevel.getModel().getSize() > 0) cbLevel.setSelectedIndex(cbLevel.getModel().getSize()-1);
|
||||
fcSelectDeck = new JFileChooser();
|
||||
fcSelectDeck.setAcceptAllFileFilterUsed(false);
|
||||
fcSelectDeck.addChoosableFileFilter(new DeckFilter());
|
||||
String deckPath = MageFrame.getPreferences().get("defaultDeckPath", "");
|
||||
if (deckPath.isEmpty()) {
|
||||
if (Config.defaultDeckPath != null) deckPath = Config.defaultDeckPath;
|
||||
}
|
||||
this.txtPlayerDeck.setText(deckPath);
|
||||
if (Config.defaultComputerName != null) this.txtPlayerName.setText(Config.defaultComputerName);
|
||||
if (cbLevel.getModel().getSize() > 0) cbLevel.setSelectedIndex(cbLevel.getModel().getSize()-1);
|
||||
}
|
||||
|
||||
public void setPlayerName(String playerName) {
|
||||
this.txtPlayerName.setText(playerName);
|
||||
this.txtPlayerName.setEditable(false);
|
||||
this.txtPlayerName.setEnabled(false);
|
||||
public void setPlayerName(String playerName) {
|
||||
this.txtPlayerName.setText(playerName);
|
||||
this.txtPlayerName.setEditable(false);
|
||||
this.txtPlayerName.setEnabled(false);
|
||||
}
|
||||
|
||||
protected void playerLoadDeck() {
|
||||
String lastFolder = MageFrame.getPreferences().get("lastDeckFolder", "");
|
||||
if (!lastFolder.isEmpty())
|
||||
fcSelectDeck.setCurrentDirectory(new File(lastFolder));
|
||||
int ret = fcSelectDeck.showDialog(this, "Select Deck");
|
||||
if (ret == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fcSelectDeck.getSelectedFile();
|
||||
this.txtPlayerDeck.setText(file.getPath());
|
||||
try {
|
||||
MageFrame.getPreferences().put("lastDeckFolder", file.getCanonicalPath());
|
||||
} catch (IOException ex) { }
|
||||
}
|
||||
fcSelectDeck.setSelectedFile(null);
|
||||
}
|
||||
protected void playerLoadDeck() {
|
||||
String lastFolder = MageFrame.getPreferences().get("lastDeckFolder", "");
|
||||
if (!lastFolder.isEmpty())
|
||||
fcSelectDeck.setCurrentDirectory(new File(lastFolder));
|
||||
int ret = fcSelectDeck.showDialog(this, "Select Deck");
|
||||
if (ret == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fcSelectDeck.getSelectedFile();
|
||||
this.txtPlayerDeck.setText(file.getPath());
|
||||
try {
|
||||
MageFrame.getPreferences().put("lastDeckFolder", file.getCanonicalPath());
|
||||
} catch (IOException ex) { }
|
||||
}
|
||||
fcSelectDeck.setSelectedFile(null);
|
||||
}
|
||||
|
||||
protected void generateDeck() {
|
||||
String path = DeckGenerator.generateDeck();
|
||||
if (path != null) {
|
||||
this.txtPlayerDeck.setText(path);
|
||||
MageFrame.getPreferences().put("defaultDeckPath", path);
|
||||
}
|
||||
}
|
||||
protected void generateDeck() {
|
||||
String path = DeckGenerator.generateDeck();
|
||||
if (path != null) {
|
||||
this.txtPlayerDeck.setText(path);
|
||||
MageFrame.getPreferences().put("defaultDeckPath", path);
|
||||
}
|
||||
}
|
||||
|
||||
public String getPlayerName() {
|
||||
return this.txtPlayerName.getText();
|
||||
}
|
||||
public String getPlayerName() {
|
||||
return this.txtPlayerName.getText();
|
||||
}
|
||||
|
||||
public String getDeckFile() {
|
||||
return this.txtPlayerDeck.getText();
|
||||
}
|
||||
public String getDeckFile() {
|
||||
return this.txtPlayerDeck.getText();
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return Integer.valueOf((String)this.cbLevel.getSelectedItem());
|
||||
}
|
||||
public int getLevel() {
|
||||
return Integer.valueOf((String)this.cbLevel.getSelectedItem());
|
||||
}
|
||||
|
||||
public void showLevel(boolean show) {
|
||||
this.cbLevel.setVisible(show);
|
||||
this.lblLevel.setVisible(show);
|
||||
}
|
||||
public void showLevel(boolean show) {
|
||||
this.cbLevel.setVisible(show);
|
||||
this.lblLevel.setVisible(show);
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
@ -193,13 +193,13 @@ public class NewPlayerPanel extends javax.swing.JPanel {
|
|||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void btnPlayerDeckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPlayerDeckActionPerformed
|
||||
playerLoadDeck();
|
||||
private void btnPlayerDeckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPlayerDeckActionPerformed
|
||||
playerLoadDeck();
|
||||
}//GEN-LAST:event_btnPlayerDeckActionPerformed
|
||||
|
||||
private void btnGenerateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGenerateActionPerformed
|
||||
generateDeck();
|
||||
}//GEN-LAST:event_btnGenerateActionPerformed
|
||||
private void btnGenerateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGenerateActionPerformed
|
||||
generateDeck();
|
||||
}//GEN-LAST:event_btnGenerateActionPerformed
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
@ -217,10 +217,10 @@ public class NewPlayerPanel extends javax.swing.JPanel {
|
|||
|
||||
class DeckFilter extends FileFilter {
|
||||
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
if (f.isDirectory())
|
||||
return true;
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
if (f.isDirectory())
|
||||
return true;
|
||||
|
||||
String ext = null;
|
||||
String s = f.getName();
|
||||
|
@ -229,12 +229,12 @@ class DeckFilter extends FileFilter {
|
|||
if (i > 0 && i < s.length() - 1) {
|
||||
ext = s.substring(i+1).toLowerCase();
|
||||
}
|
||||
return (ext==null)?false:ext.equals("dck");
|
||||
}
|
||||
return (ext==null)?false:ext.equals("dck");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Deck Files";
|
||||
}
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Deck Files";
|
||||
}
|
||||
|
||||
}
|
|
@ -40,21 +40,21 @@ import mage.client.util.Listener;
|
|||
*/
|
||||
public class PlayerTypeEventSource implements EventSource<Event>, Serializable {
|
||||
|
||||
protected final EventDispatcher<Event> dispatcher = new EventDispatcher<Event>() {};
|
||||
protected final EventDispatcher<Event> dispatcher = new EventDispatcher<Event>() {};
|
||||
|
||||
@Override
|
||||
public void addListener(Listener<Event> listener) {
|
||||
dispatcher.addListener(listener);
|
||||
}
|
||||
@Override
|
||||
public void addListener(Listener<Event> listener) {
|
||||
dispatcher.addListener(listener);
|
||||
}
|
||||
|
||||
public void playerTypeChanged() {
|
||||
dispatcher.fireEvent(new Event(null, "playerTypeChanged"));
|
||||
}
|
||||
public void playerTypeChanged() {
|
||||
dispatcher.fireEvent(new Event(null, "playerTypeChanged"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearListeners() {
|
||||
dispatcher.clearListeners();
|
||||
}
|
||||
@Override
|
||||
public void clearListeners() {
|
||||
dispatcher.clearListeners();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -51,48 +51,48 @@ import mage.remote.Session;
|
|||
*/
|
||||
public class TablePlayerPanel extends javax.swing.JPanel {
|
||||
|
||||
protected PlayerTypeEventSource playerTypeEventSource = new PlayerTypeEventSource();
|
||||
protected PlayerTypeEventSource playerTypeEventSource = new PlayerTypeEventSource();
|
||||
|
||||
private Session session;
|
||||
private Session session;
|
||||
|
||||
/** Creates new form TablePlayerPanel */
|
||||
public TablePlayerPanel() {
|
||||
initComponents();
|
||||
this.newPlayerPanel.setVisible(false);
|
||||
this.newPlayerPanel.setVisible(false);
|
||||
}
|
||||
|
||||
public void init(int playerNum) {
|
||||
session = MageFrame.getSession();
|
||||
cbPlayerType.setModel(new DefaultComboBoxModel(session.getPlayerTypes()));
|
||||
this.lblPlayerNum.setText("Player " + playerNum);
|
||||
if (Config.defaultOtherPlayerIndex != null) {
|
||||
if (Integer.valueOf(Config.defaultOtherPlayerIndex) >= cbPlayerType.getItemCount())
|
||||
cbPlayerType.setSelectedIndex(cbPlayerType.getItemCount() - 1);
|
||||
else {
|
||||
Integer index = Integer.parseInt(Config.defaultOtherPlayerIndex);
|
||||
cbPlayerType.setSelectedIndex(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void init(int playerNum) {
|
||||
session = MageFrame.getSession();
|
||||
cbPlayerType.setModel(new DefaultComboBoxModel(session.getPlayerTypes()));
|
||||
this.lblPlayerNum.setText("Player " + playerNum);
|
||||
if (Config.defaultOtherPlayerIndex != null) {
|
||||
if (Integer.valueOf(Config.defaultOtherPlayerIndex) >= cbPlayerType.getItemCount())
|
||||
cbPlayerType.setSelectedIndex(cbPlayerType.getItemCount() - 1);
|
||||
else {
|
||||
Integer index = Integer.parseInt(Config.defaultOtherPlayerIndex);
|
||||
cbPlayerType.setSelectedIndex(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean joinTable(UUID roomId, UUID tableId) throws FileNotFoundException, IOException, ClassNotFoundException {
|
||||
if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
|
||||
return session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), (String)this.cbPlayerType.getSelectedItem(), this.newPlayerPanel.getLevel(), DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean joinTable(UUID roomId, UUID tableId) throws FileNotFoundException, IOException, ClassNotFoundException {
|
||||
if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
|
||||
return session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), (String)this.cbPlayerType.getSelectedItem(), this.newPlayerPanel.getLevel(), DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getPlayerType() {
|
||||
return (String) this.cbPlayerType.getSelectedItem();
|
||||
}
|
||||
public String getPlayerType() {
|
||||
return (String) this.cbPlayerType.getSelectedItem();
|
||||
}
|
||||
|
||||
public void addPlayerTypeEventListener(Listener<Event> listener) {
|
||||
playerTypeEventSource.addListener(listener);
|
||||
}
|
||||
public void addPlayerTypeEventListener(Listener<Event> listener) {
|
||||
playerTypeEventSource.addListener(listener);
|
||||
}
|
||||
|
||||
public void clearPlayerTypeEventListeners() {
|
||||
playerTypeEventSource.clearListeners();
|
||||
}
|
||||
public void clearPlayerTypeEventListeners() {
|
||||
playerTypeEventSource.clearListeners();
|
||||
}
|
||||
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
|
@ -150,17 +150,17 @@ public class TablePlayerPanel extends javax.swing.JPanel {
|
|||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void cbPlayerTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbPlayerTypeActionPerformed
|
||||
if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
|
||||
this.newPlayerPanel.setVisible(true);
|
||||
}
|
||||
else {
|
||||
this.newPlayerPanel.setVisible(false);
|
||||
}
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
this.playerTypeEventSource.playerTypeChanged();
|
||||
}//GEN-LAST:event_cbPlayerTypeActionPerformed
|
||||
private void cbPlayerTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbPlayerTypeActionPerformed
|
||||
if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
|
||||
this.newPlayerPanel.setVisible(true);
|
||||
}
|
||||
else {
|
||||
this.newPlayerPanel.setVisible(false);
|
||||
}
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
this.playerTypeEventSource.playerTypeChanged();
|
||||
}//GEN-LAST:event_cbPlayerTypeActionPerformed
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
|
|
@ -51,36 +51,36 @@ public class TablesPane extends MagePane {
|
|||
|
||||
/** Creates new form TablesPane */
|
||||
public TablesPane() {
|
||||
boolean initialized = false;
|
||||
if (Plugins.getInstance().isThemePluginLoaded()) {
|
||||
tablesPanel = new mage.client.table.TablesPanel();
|
||||
Map<String, JComponent> ui = tablesPanel.getUIComponents();
|
||||
JComponent container = Plugins.getInstance().updateTablePanel(ui);
|
||||
if (container != null) {
|
||||
initComponents(container);
|
||||
container.add(tablesPanel);
|
||||
container.setOpaque(false);
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
if (!initialized) {
|
||||
initComponents();
|
||||
}
|
||||
boolean initialized = false;
|
||||
if (Plugins.getInstance().isThemePluginLoaded()) {
|
||||
tablesPanel = new mage.client.table.TablesPanel();
|
||||
Map<String, JComponent> ui = tablesPanel.getUIComponents();
|
||||
JComponent container = Plugins.getInstance().updateTablePanel(ui);
|
||||
if (container != null) {
|
||||
initComponents(container);
|
||||
container.add(tablesPanel);
|
||||
container.setOpaque(false);
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
if (!initialized) {
|
||||
initComponents();
|
||||
}
|
||||
}
|
||||
|
||||
public void showTables() {
|
||||
UUID roomId = MageFrame.getSession().getMainRoomId();
|
||||
if (roomId != null) {
|
||||
this.setTitle("Tables");
|
||||
tablesPanel.showTables(roomId);
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
}
|
||||
public void showTables() {
|
||||
UUID roomId = MageFrame.getSession().getMainRoomId();
|
||||
if (roomId != null) {
|
||||
this.setTitle("Tables");
|
||||
tablesPanel.showTables(roomId);
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
public void hideTables() {
|
||||
tablesPanel.hideTables();
|
||||
}
|
||||
}
|
||||
|
||||
public void hideTables() {
|
||||
tablesPanel.hideTables();
|
||||
}
|
||||
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
|
@ -107,7 +107,7 @@ public class TablesPane extends MagePane {
|
|||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
||||
private void initComponents(JComponent container) {
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
|
@ -127,13 +127,13 @@ public class TablesPane extends MagePane {
|
|||
private mage.client.table.TablesPanel tablesPanel;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
@Override
|
||||
public void activated() {
|
||||
tablesPanel.startTasks();
|
||||
}
|
||||
@Override
|
||||
public void activated() {
|
||||
tablesPanel.startTasks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deactivated() {
|
||||
tablesPanel.stopTasks();
|
||||
}
|
||||
@Override
|
||||
public void deactivated() {
|
||||
tablesPanel.stopTasks();
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -46,30 +46,30 @@ import mage.remote.Session;
|
|||
*/
|
||||
public class TournamentPlayerPanel extends javax.swing.JPanel {
|
||||
|
||||
private Session session;
|
||||
private Session session;
|
||||
|
||||
/** Creates new form TournamentPlayerPanel */
|
||||
/** Creates new form TournamentPlayerPanel */
|
||||
public TournamentPlayerPanel() {
|
||||
initComponents();
|
||||
this.pnlPlayerName.setVisible(false);
|
||||
this.pnlPlayerName.setVisible(false);
|
||||
}
|
||||
|
||||
public void init(int playerNum) {
|
||||
session = MageFrame.getSession();
|
||||
cbPlayerType.setModel(new DefaultComboBoxModel(session.getPlayerTypes()));
|
||||
this.lblPlayerNum.setText("Player " + playerNum);
|
||||
}
|
||||
public void init(int playerNum) {
|
||||
session = MageFrame.getSession();
|
||||
cbPlayerType.setModel(new DefaultComboBoxModel(session.getPlayerTypes()));
|
||||
this.lblPlayerNum.setText("Player " + playerNum);
|
||||
}
|
||||
|
||||
public JComboBox getPlayerType() {
|
||||
return this.cbPlayerType;
|
||||
}
|
||||
public JComboBox getPlayerType() {
|
||||
return this.cbPlayerType;
|
||||
}
|
||||
|
||||
public boolean joinTournamentTable(UUID roomId, UUID tableId) {
|
||||
if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
|
||||
return session.joinTournamentTable(roomId, tableId, this.txtPlayerName.getText(), (String)this.cbPlayerType.getSelectedItem(), Integer.valueOf((String)this.cbLevel.getSelectedItem()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean joinTournamentTable(UUID roomId, UUID tableId) {
|
||||
if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
|
||||
return session.joinTournamentTable(roomId, tableId, this.txtPlayerName.getText(), (String)this.cbPlayerType.getSelectedItem(), Integer.valueOf((String)this.cbLevel.getSelectedItem()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
|
@ -155,19 +155,19 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
|
|||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void cbPlayerTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbPlayerTypeActionPerformed
|
||||
if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
|
||||
this.pnlPlayerName.setVisible(true);
|
||||
if (this.txtPlayerName.getText().length() == 0) {
|
||||
this.txtPlayerName.setText("Computer " + this.lblPlayerNum.getText());
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.pnlPlayerName.setVisible(false);
|
||||
}
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
}//GEN-LAST:event_cbPlayerTypeActionPerformed
|
||||
private void cbPlayerTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbPlayerTypeActionPerformed
|
||||
if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
|
||||
this.pnlPlayerName.setVisible(true);
|
||||
if (this.txtPlayerName.getText().length() == 0) {
|
||||
this.txtPlayerName.setText("Computer " + this.lblPlayerNum.getText());
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.pnlPlayerName.setVisible(false);
|
||||
}
|
||||
this.revalidate();
|
||||
this.repaint();
|
||||
}//GEN-LAST:event_cbPlayerTypeActionPerformed
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
|
|
@ -7,49 +7,49 @@ import java.util.Map;
|
|||
|
||||
|
||||
public class DelayedViewerThread extends Thread {
|
||||
private static DelayedViewerThread fInstance = new DelayedViewerThread();
|
||||
private static DelayedViewerThread fInstance = new DelayedViewerThread();
|
||||
|
||||
public static DelayedViewerThread getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
public static DelayedViewerThread getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
private final Map<Component, Long> delayedViewers;
|
||||
private final Map<Component, Long> delayedViewers;
|
||||
|
||||
protected DelayedViewerThread() {
|
||||
delayedViewers = new HashMap<Component, Long>();
|
||||
start();
|
||||
}
|
||||
protected DelayedViewerThread() {
|
||||
delayedViewers = new HashMap<Component, Long>();
|
||||
start();
|
||||
}
|
||||
|
||||
public synchronized void show(Component component, long delay) {
|
||||
delayedViewers.put(component, System.currentTimeMillis() + delay);
|
||||
notify();
|
||||
}
|
||||
public synchronized void show(Component component, long delay) {
|
||||
delayedViewers.put(component, System.currentTimeMillis() + delay);
|
||||
notify();
|
||||
}
|
||||
|
||||
public synchronized void hide(Component component) {
|
||||
delayedViewers.remove(component);
|
||||
component.setVisible(false);
|
||||
}
|
||||
public synchronized void hide(Component component) {
|
||||
delayedViewers.remove(component);
|
||||
component.setVisible(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void run() {
|
||||
while (true) {
|
||||
try {
|
||||
if (delayedViewers.isEmpty()) {
|
||||
wait();
|
||||
}
|
||||
final long time = System.currentTimeMillis();
|
||||
for (Iterator<Component> it = delayedViewers.keySet().iterator(); it.hasNext();) {
|
||||
Component component = it.next();
|
||||
final long delayedTime = delayedViewers.get(component);
|
||||
if (delayedTime <= time) {
|
||||
component.setVisible(true);
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
wait(100);
|
||||
} catch (final InterruptedException ex) {
|
||||
System.out.println("Interrupted : " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public synchronized void run() {
|
||||
while (true) {
|
||||
try {
|
||||
if (delayedViewers.isEmpty()) {
|
||||
wait();
|
||||
}
|
||||
final long time = System.currentTimeMillis();
|
||||
for (Iterator<Component> it = delayedViewers.keySet().iterator(); it.hasNext();) {
|
||||
Component component = it.next();
|
||||
final long delayedTime = delayedViewers.get(component);
|
||||
if (delayedTime <= time) {
|
||||
component.setVisible(true);
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
wait(100);
|
||||
} catch (final InterruptedException ex) {
|
||||
System.out.println("Interrupted : " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,16 +48,16 @@ public class TournamentPane extends MagePane {
|
|||
initComponents();
|
||||
}
|
||||
|
||||
public void showTournament(UUID tournamentId) {
|
||||
this.setTitle("Tournament " + tournamentId);
|
||||
this.tournamentPanel.showTournament(tournamentId);
|
||||
this.repaint();
|
||||
}
|
||||
public void showTournament(UUID tournamentId) {
|
||||
this.setTitle("Tournament " + tournamentId);
|
||||
this.tournamentPanel.showTournament(tournamentId);
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
public void hideTournament() {
|
||||
tournamentPanel.hideTournament();
|
||||
}
|
||||
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
|
@ -88,14 +88,14 @@ public class TournamentPane extends MagePane {
|
|||
private mage.client.tournament.TournamentPanel tournamentPanel;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
@Override
|
||||
public void activated() {
|
||||
tournamentPanel.startTasks();
|
||||
}
|
||||
@Override
|
||||
public void activated() {
|
||||
tournamentPanel.startTasks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deactivated() {
|
||||
tournamentPanel.stopTasks();
|
||||
}
|
||||
@Override
|
||||
public void deactivated() {
|
||||
tournamentPanel.stopTasks();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -59,94 +59,94 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class TournamentPanel extends javax.swing.JPanel {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(TournamentPanel.class);
|
||||
private final static Logger logger = Logger.getLogger(TournamentPanel.class);
|
||||
|
||||
private UUID tournamentId;
|
||||
private Session session;
|
||||
private TournamentPlayersTableModel playersModel;
|
||||
private TournamentMatchesTableModel matchesModel;
|
||||
private UpdateTournamentTask updateTask;
|
||||
private UUID tournamentId;
|
||||
private Session session;
|
||||
private TournamentPlayersTableModel playersModel;
|
||||
private TournamentMatchesTableModel matchesModel;
|
||||
private UpdateTournamentTask updateTask;
|
||||
|
||||
/** Creates new form TournamentPanel */
|
||||
/** Creates new form TournamentPanel */
|
||||
public TournamentPanel() {
|
||||
playersModel = new TournamentPlayersTableModel();
|
||||
matchesModel = new TournamentMatchesTableModel();
|
||||
|
||||
initComponents();
|
||||
playersModel = new TournamentPlayersTableModel();
|
||||
matchesModel = new TournamentMatchesTableModel();
|
||||
|
||||
tablePlayers.createDefaultColumnsFromModel();
|
||||
tableMatches.createDefaultColumnsFromModel();
|
||||
initComponents();
|
||||
|
||||
chatPanel1.useExtendedView(ChatPanel.VIEW_MODE.NONE);
|
||||
tablePlayers.createDefaultColumnsFromModel();
|
||||
tableMatches.createDefaultColumnsFromModel();
|
||||
|
||||
Action action = new AbstractAction()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
int modelRow = Integer.valueOf( e.getActionCommand() );
|
||||
UUID gameId = UUID.fromString((String)tableMatches.getValueAt(modelRow, 3));
|
||||
String state = (String)tableMatches.getValueAt(modelRow, 4);
|
||||
chatPanel1.useExtendedView(ChatPanel.VIEW_MODE.NONE);
|
||||
|
||||
if (state.equals("Finished")) {
|
||||
logger.info("Replaying game " + gameId);
|
||||
session.replayGame(gameId);
|
||||
}
|
||||
}
|
||||
};
|
||||
Action action = new AbstractAction()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
int modelRow = Integer.valueOf( e.getActionCommand() );
|
||||
UUID gameId = UUID.fromString((String)tableMatches.getValueAt(modelRow, 3));
|
||||
String state = (String)tableMatches.getValueAt(modelRow, 4);
|
||||
|
||||
ButtonColumn buttonColumn = new ButtonColumn(tableMatches, action, 6);
|
||||
if (state.equals("Finished")) {
|
||||
logger.info("Replaying game " + gameId);
|
||||
session.replayGame(gameId);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ButtonColumn buttonColumn = new ButtonColumn(tableMatches, action, 6);
|
||||
|
||||
}
|
||||
|
||||
public synchronized void showTournament(UUID tournamentId) {
|
||||
this.tournamentId = tournamentId;
|
||||
session = MageFrame.getSession();
|
||||
MageFrame.addTournament(tournamentId, this);
|
||||
UUID chatRoomId = session.getTournamentChatId(tournamentId);
|
||||
if (session.joinTournament(tournamentId) && chatRoomId != null) {
|
||||
this.chatPanel1.connect(chatRoomId);
|
||||
startTasks();
|
||||
this.setVisible(true);
|
||||
this.repaint();
|
||||
}
|
||||
else {
|
||||
hideTournament();
|
||||
}
|
||||
}
|
||||
public synchronized void showTournament(UUID tournamentId) {
|
||||
this.tournamentId = tournamentId;
|
||||
session = MageFrame.getSession();
|
||||
MageFrame.addTournament(tournamentId, this);
|
||||
UUID chatRoomId = session.getTournamentChatId(tournamentId);
|
||||
if (session.joinTournament(tournamentId) && chatRoomId != null) {
|
||||
this.chatPanel1.connect(chatRoomId);
|
||||
startTasks();
|
||||
this.setVisible(true);
|
||||
this.repaint();
|
||||
}
|
||||
else {
|
||||
hideTournament();
|
||||
}
|
||||
}
|
||||
|
||||
public void hideTournament() {
|
||||
stopTasks();
|
||||
this.chatPanel1.disconnect();
|
||||
Component c = this.getParent();
|
||||
while (c != null && !(c instanceof TournamentPane)) {
|
||||
c = c.getParent();
|
||||
}
|
||||
if (c != null) {
|
||||
((TournamentPane)c).hideFrame();
|
||||
}
|
||||
}
|
||||
public void hideTournament() {
|
||||
stopTasks();
|
||||
this.chatPanel1.disconnect();
|
||||
Component c = this.getParent();
|
||||
while (c != null && !(c instanceof TournamentPane)) {
|
||||
c = c.getParent();
|
||||
}
|
||||
if (c != null) {
|
||||
((TournamentPane)c).hideFrame();
|
||||
}
|
||||
}
|
||||
|
||||
public void update(TournamentView tournament) {
|
||||
playersModel.loadData(tournament);
|
||||
matchesModel.loadData(tournament);
|
||||
this.tablePlayers.repaint();
|
||||
this.tableMatches.repaint();
|
||||
}
|
||||
|
||||
public void startTasks() {
|
||||
if (session != null) {
|
||||
if (updateTask == null || updateTask.isDone()) {
|
||||
updateTask = new UpdateTournamentTask(session, tournamentId, this);
|
||||
updateTask.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void stopTasks() {
|
||||
if (updateTask != null)
|
||||
updateTask.cancel(true);
|
||||
}
|
||||
public void update(TournamentView tournament) {
|
||||
playersModel.loadData(tournament);
|
||||
matchesModel.loadData(tournament);
|
||||
this.tablePlayers.repaint();
|
||||
this.tableMatches.repaint();
|
||||
}
|
||||
|
||||
public void startTasks() {
|
||||
if (session != null) {
|
||||
if (updateTask == null || updateTask.isDone()) {
|
||||
updateTask = new UpdateTournamentTask(session, tournamentId, this);
|
||||
updateTask.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void stopTasks() {
|
||||
if (updateTask != null)
|
||||
updateTask.cancel(true);
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
@ -203,38 +203,38 @@ public class TournamentPanel extends javax.swing.JPanel {
|
|||
|
||||
class TournamentPlayersTableModel extends AbstractTableModel {
|
||||
private String[] columnNames = new String[]{"Player Name", "Points", "Results"};
|
||||
private TournamentPlayerView[] players = new TournamentPlayerView[0];
|
||||
private TournamentPlayerView[] players = new TournamentPlayerView[0];
|
||||
|
||||
public void loadData(TournamentView tournament) {
|
||||
players = tournament.getPlayers().toArray(new TournamentPlayerView[0]);
|
||||
this.fireTableDataChanged();
|
||||
}
|
||||
public void loadData(TournamentView tournament) {
|
||||
players = tournament.getPlayers().toArray(new TournamentPlayerView[0]);
|
||||
this.fireTableDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return players.length;
|
||||
}
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return players.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return columnNames.length;
|
||||
}
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return columnNames.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int arg0, int arg1) {
|
||||
switch (arg1) {
|
||||
case 0:
|
||||
return players[arg0].getName();
|
||||
case 1:
|
||||
return Integer.toString(players[arg0].getPoints());
|
||||
case 2:
|
||||
return players[arg0].getResults();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@Override
|
||||
public Object getValueAt(int arg0, int arg1) {
|
||||
switch (arg1) {
|
||||
case 0:
|
||||
return players[arg0].getName();
|
||||
case 1:
|
||||
return Integer.toString(players[arg0].getPoints());
|
||||
case 2:
|
||||
return players[arg0].getResults();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnName(int columnIndex) {
|
||||
@Override
|
||||
public String getColumnName(int columnIndex) {
|
||||
String colName = "";
|
||||
|
||||
if (columnIndex <= getColumnCount())
|
||||
|
@ -243,69 +243,69 @@ class TournamentPlayersTableModel extends AbstractTableModel {
|
|||
return colName;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Class getColumnClass(int columnIndex){
|
||||
return String.class;
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class TournamentMatchesTableModel extends AbstractTableModel {
|
||||
private String[] columnNames = new String[]{"Round Number", "Players", "Match Id", "Game Id", "State", "Result", "Action"};
|
||||
private TournamentGameView[] games = new TournamentGameView[0];
|
||||
private TournamentGameView[] games = new TournamentGameView[0];
|
||||
|
||||
public void loadData(TournamentView tournament) {
|
||||
List<TournamentGameView> views = new ArrayList<TournamentGameView>();
|
||||
for (RoundView round: tournament.getRounds()) {
|
||||
for (TournamentGameView game: round.getGames()) {
|
||||
views.add(game);
|
||||
}
|
||||
}
|
||||
games = views.toArray(new TournamentGameView[0]);
|
||||
this.fireTableDataChanged();
|
||||
}
|
||||
public void loadData(TournamentView tournament) {
|
||||
List<TournamentGameView> views = new ArrayList<TournamentGameView>();
|
||||
for (RoundView round: tournament.getRounds()) {
|
||||
for (TournamentGameView game: round.getGames()) {
|
||||
views.add(game);
|
||||
}
|
||||
}
|
||||
games = views.toArray(new TournamentGameView[0]);
|
||||
this.fireTableDataChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return games.length;
|
||||
}
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return games.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return columnNames.length;
|
||||
}
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return columnNames.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int arg0, int arg1) {
|
||||
switch (arg1) {
|
||||
case 0:
|
||||
return Integer.toString(games[arg0].getRoundNum());
|
||||
case 1:
|
||||
return games[arg0].getPlayers();
|
||||
case 2:
|
||||
return games[arg0].getMatchId().toString();
|
||||
case 3:
|
||||
return games[arg0].getGameId().toString();
|
||||
case 4:
|
||||
return games[arg0].getState();
|
||||
case 5:
|
||||
return games[arg0].getResult();
|
||||
case 6:
|
||||
if (games[arg0].getState().equals("Finished")) {
|
||||
return "Replay";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@Override
|
||||
public Object getValueAt(int arg0, int arg1) {
|
||||
switch (arg1) {
|
||||
case 0:
|
||||
return Integer.toString(games[arg0].getRoundNum());
|
||||
case 1:
|
||||
return games[arg0].getPlayers();
|
||||
case 2:
|
||||
return games[arg0].getMatchId().toString();
|
||||
case 3:
|
||||
return games[arg0].getGameId().toString();
|
||||
case 4:
|
||||
return games[arg0].getState();
|
||||
case 5:
|
||||
return games[arg0].getResult();
|
||||
case 6:
|
||||
if (games[arg0].getState().equals("Finished")) {
|
||||
return "Replay";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnName(int columnIndex) {
|
||||
@Override
|
||||
public String getColumnName(int columnIndex) {
|
||||
String colName = "";
|
||||
|
||||
if (columnIndex <= getColumnCount())
|
||||
|
@ -314,57 +314,57 @@ class TournamentMatchesTableModel extends AbstractTableModel {
|
|||
return colName;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Class getColumnClass(int columnIndex){
|
||||
return String.class;
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
if (columnIndex != 6)
|
||||
return false;
|
||||
return true;
|
||||
if (columnIndex != 6)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class UpdateTournamentTask extends SwingWorker<Void, TournamentView> {
|
||||
|
||||
private Session session;
|
||||
private UUID tournamentId;
|
||||
private TournamentPanel panel;
|
||||
private Session session;
|
||||
private UUID tournamentId;
|
||||
private TournamentPanel panel;
|
||||
|
||||
private final static Logger logger = Logger.getLogger(UpdateTournamentTask.class);
|
||||
private final static Logger logger = Logger.getLogger(UpdateTournamentTask.class);
|
||||
|
||||
UpdateTournamentTask(Session session, UUID tournamentId, TournamentPanel panel) {
|
||||
this.session = session;
|
||||
this.tournamentId = tournamentId;
|
||||
this.panel = panel;
|
||||
}
|
||||
UpdateTournamentTask(Session session, UUID tournamentId, TournamentPanel panel) {
|
||||
this.session = session;
|
||||
this.tournamentId = tournamentId;
|
||||
this.panel = panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
while (!isCancelled()) {
|
||||
this.publish(session.getTournament(tournamentId));
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
while (!isCancelled()) {
|
||||
this.publish(session.getTournament(tournamentId));
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void process(List<TournamentView> view) {
|
||||
panel.update(view.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
try {
|
||||
get();
|
||||
} catch (InterruptedException ex) {
|
||||
logger.fatal("Update Tournament Task error", ex);
|
||||
} catch (ExecutionException ex) {
|
||||
logger.fatal("Update Tournament Task error", ex);
|
||||
} catch (CancellationException ex) {}
|
||||
}
|
||||
@Override
|
||||
protected void process(List<TournamentView> view) {
|
||||
panel.update(view.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
try {
|
||||
get();
|
||||
} catch (InterruptedException ex) {
|
||||
logger.fatal("Update Tournament Task error", ex);
|
||||
} catch (ExecutionException ex) {
|
||||
logger.fatal("Update Tournament Task error", ex);
|
||||
} catch (CancellationException ex) {}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class AudioManager {
|
|||
audioManager = new AudioManager();
|
||||
audioManager.nextPageClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnPrevPage.wav"); //sounds better than OnNextPage
|
||||
audioManager.prevPageClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnPrevPage.wav");
|
||||
audioManager.anotherTabClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnNextPage.wav");
|
||||
audioManager.anotherTabClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnNextPage.wav");
|
||||
audioManager.nextPhaseClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnNextPhase.wav");
|
||||
audioManager.endTurnClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnEndTurn.wav");
|
||||
audioManager.tapPermanentClip = audioManager.loadClip(Constants.BASE_SOUND_PATH + "OnTapPermanent.wav");
|
||||
|
@ -52,7 +52,7 @@ public class AudioManager {
|
|||
checkAndPlayClip(getManager().prevPageClip);
|
||||
}
|
||||
|
||||
public static void playAnotherTab() {
|
||||
public static void playAnotherTab() {
|
||||
checkAndPlayClip(getManager().anotherTabClip);
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ public class AudioManager {
|
|||
|
||||
private Clip nextPageClip = null;
|
||||
private Clip prevPageClip = null;
|
||||
private Clip anotherTabClip = null;
|
||||
private Clip anotherTabClip = null;
|
||||
private Clip nextPhaseClip = null;
|
||||
private Clip endTurnClip = null;
|
||||
private Clip tapPermanentClip = null;
|
||||
|
|
|
@ -48,85 +48,85 @@ import javax.swing.table.TableColumnModel;
|
|||
*/
|
||||
public class ButtonColumn extends AbstractCellEditor implements TableCellRenderer, TableCellEditor, ActionListener, MouseListener {
|
||||
|
||||
private JTable table;
|
||||
private Action action;
|
||||
private JButton renderButton;
|
||||
private JButton editButton;
|
||||
private String text;
|
||||
private boolean isButtonColumnEditor;
|
||||
private JTable table;
|
||||
private Action action;
|
||||
private JButton renderButton;
|
||||
private JButton editButton;
|
||||
private String text;
|
||||
private boolean isButtonColumnEditor;
|
||||
|
||||
public ButtonColumn(JTable table, Action action, int column) {
|
||||
super();
|
||||
this.table = table;
|
||||
this.action = action;
|
||||
renderButton = new JButton();
|
||||
public ButtonColumn(JTable table, Action action, int column) {
|
||||
super();
|
||||
this.table = table;
|
||||
this.action = action;
|
||||
renderButton = new JButton();
|
||||
|
||||
editButton = new JButton();
|
||||
editButton.setFocusPainted(false);
|
||||
editButton.addActionListener(this);
|
||||
editButton = new JButton();
|
||||
editButton.setFocusPainted(false);
|
||||
editButton.addActionListener(this);
|
||||
|
||||
TableColumnModel columnModel = table.getColumnModel();
|
||||
columnModel.getColumn(column).setCellRenderer(this);
|
||||
columnModel.getColumn(column).setCellEditor(this);
|
||||
table.addMouseListener(this);
|
||||
}
|
||||
TableColumnModel columnModel = table.getColumnModel();
|
||||
columnModel.getColumn(column).setCellRenderer(this);
|
||||
columnModel.getColumn(column).setCellEditor(this);
|
||||
table.addMouseListener(this);
|
||||
}
|
||||
|
||||
public Object getCellEditorValue() {
|
||||
return text;
|
||||
}
|
||||
public Object getCellEditorValue() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
if (hasFocus)
|
||||
{
|
||||
renderButton.setForeground(table.getForeground());
|
||||
renderButton.setBackground(UIManager.getColor("Button.background"));
|
||||
}
|
||||
else if (isSelected)
|
||||
{
|
||||
renderButton.setForeground(table.getSelectionForeground());
|
||||
renderButton.setBackground(table.getSelectionBackground());
|
||||
}
|
||||
else
|
||||
{
|
||||
renderButton.setForeground(table.getForeground());
|
||||
renderButton.setBackground(UIManager.getColor("Button.background"));
|
||||
}
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
if (hasFocus)
|
||||
{
|
||||
renderButton.setForeground(table.getForeground());
|
||||
renderButton.setBackground(UIManager.getColor("Button.background"));
|
||||
}
|
||||
else if (isSelected)
|
||||
{
|
||||
renderButton.setForeground(table.getSelectionForeground());
|
||||
renderButton.setBackground(table.getSelectionBackground());
|
||||
}
|
||||
else
|
||||
{
|
||||
renderButton.setForeground(table.getForeground());
|
||||
renderButton.setBackground(UIManager.getColor("Button.background"));
|
||||
}
|
||||
|
||||
renderButton.setText( (value == null) ? "" : value.toString() );
|
||||
return renderButton;
|
||||
}
|
||||
renderButton.setText( (value == null) ? "" : value.toString() );
|
||||
return renderButton;
|
||||
}
|
||||
|
||||
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
|
||||
text = (value == null) ? "" : value.toString();
|
||||
editButton.setText( text );
|
||||
return editButton;
|
||||
}
|
||||
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
|
||||
text = (value == null) ? "" : value.toString();
|
||||
editButton.setText( text );
|
||||
return editButton;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
int row = table.convertRowIndexToModel( table.getEditingRow() );
|
||||
fireEditingStopped();
|
||||
ActionEvent event = new ActionEvent(table, ActionEvent.ACTION_PERFORMED, "" + row);
|
||||
action.actionPerformed(event);
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
int row = table.convertRowIndexToModel( table.getEditingRow() );
|
||||
fireEditingStopped();
|
||||
ActionEvent event = new ActionEvent(table, ActionEvent.ACTION_PERFORMED, "" + row);
|
||||
action.actionPerformed(event);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent arg0) {
|
||||
if (table.isEditing() && table.getCellEditor() == this)
|
||||
isButtonColumnEditor = true;
|
||||
}
|
||||
public void mousePressed(MouseEvent arg0) {
|
||||
if (table.isEditing() && table.getCellEditor() == this)
|
||||
isButtonColumnEditor = true;
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent arg0) {
|
||||
if (isButtonColumnEditor && table.isEditing())
|
||||
table.getCellEditor().stopCellEditing();
|
||||
public void mouseReleased(MouseEvent arg0) {
|
||||
if (isButtonColumnEditor && table.isEditing())
|
||||
table.getCellEditor().stopCellEditing();
|
||||
|
||||
isButtonColumnEditor = false;
|
||||
}
|
||||
isButtonColumnEditor = false;
|
||||
}
|
||||
|
||||
public void mouseClicked(MouseEvent arg0) {}
|
||||
public void mouseClicked(MouseEvent arg0) {}
|
||||
|
||||
public void mouseEntered(MouseEvent arg0) {}
|
||||
public void mouseEntered(MouseEvent arg0) {}
|
||||
|
||||
public void mouseExited(MouseEvent arg0) {}
|
||||
public void mouseExited(MouseEvent arg0) {}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -37,15 +37,15 @@ import mage.view.CardView;
|
|||
*/
|
||||
public class CardViewColorComparator implements Comparator<CardView> {
|
||||
|
||||
@Override
|
||||
public int compare(CardView o1, CardView o2) {
|
||||
int val = o1.getColor().compareTo(o2.getColor());
|
||||
if (val == 0) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int compare(CardView o1, CardView o2) {
|
||||
int val = o1.getColor().compareTo(o2.getColor());
|
||||
if (val == 0) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -37,15 +37,15 @@ import mage.view.CardView;
|
|||
*/
|
||||
public class CardViewCostComparator implements Comparator<CardView> {
|
||||
|
||||
@Override
|
||||
public int compare(CardView o1, CardView o2) {
|
||||
int val = Integer.valueOf(o1.getConvertedManaCost()).compareTo(Integer.valueOf(o2.getConvertedManaCost()));
|
||||
if (val == 0) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int compare(CardView o1, CardView o2) {
|
||||
int val = Integer.valueOf(o1.getConvertedManaCost()).compareTo(Integer.valueOf(o2.getConvertedManaCost()));
|
||||
if (val == 0) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,9 +37,9 @@ import mage.view.CardView;
|
|||
*/
|
||||
public class CardViewNameComparator implements Comparator<CardView> {
|
||||
|
||||
@Override
|
||||
public int compare(CardView o1, CardView o2) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
@Override
|
||||
public int compare(CardView o1, CardView o2) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
|
||||
}
|
|
@ -37,15 +37,15 @@ import mage.view.CardView;
|
|||
*/
|
||||
public class CardViewRarityComparator implements Comparator<CardView> {
|
||||
|
||||
@Override
|
||||
public int compare(CardView o1, CardView o2) {
|
||||
int val = o1.getRarity().compareTo(o2.getRarity());
|
||||
if (val == 0) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int compare(CardView o1, CardView o2) {
|
||||
int val = o1.getRarity().compareTo(o2.getRarity());
|
||||
if (val == 0) {
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -39,19 +39,19 @@ import mage.view.SimpleCardsView;
|
|||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class CardsViewUtil {
|
||||
|
||||
|
||||
public static CardsView convertSimple(SimpleCardsView view) {
|
||||
CardsView cards = new CardsView();
|
||||
|
||||
|
||||
for (SimpleCardView simple: view.values()) {
|
||||
mage.cards.Card card = Sets.findCard(simple.getExpansionSetCode(), simple.getCardNumber());
|
||||
if (card != null) {
|
||||
|
||||
|
||||
cards.put(simple.getId(), new CardView(card, simple.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return cards;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -42,38 +42,38 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class Config {
|
||||
|
||||
private final static Logger logger = Logger.getLogger(Config.class);
|
||||
private final static Logger logger = Logger.getLogger(Config.class);
|
||||
|
||||
public static final String remoteServer;
|
||||
public static final String serverName;
|
||||
public static final int port;
|
||||
public static final double cardScalingFactor;
|
||||
public static final String remoteServer;
|
||||
public static final String serverName;
|
||||
public static final int port;
|
||||
public static final double cardScalingFactor;
|
||||
public static final double handScalingFactor;
|
||||
public static final CardDimensions dimensions;
|
||||
|
||||
public static final String defaultGameType;
|
||||
public static final String defaultDeckPath;
|
||||
public static final String defaultOtherPlayerIndex;
|
||||
public static final String defaultComputerName;
|
||||
public static final CardDimensions dimensions;
|
||||
|
||||
static {
|
||||
Properties p = new Properties();
|
||||
try {
|
||||
p.load(new FileInputStream(new File("config/config.properties")));
|
||||
} catch (IOException ex) {
|
||||
logger.fatal("Config error ", ex);
|
||||
}
|
||||
serverName = p.getProperty("server-name");
|
||||
port = Integer.parseInt(p.getProperty("port"));
|
||||
remoteServer = p.getProperty("remote-server");
|
||||
cardScalingFactor = Double.valueOf(p.getProperty("card-scaling-factor"));
|
||||
public static final String defaultGameType;
|
||||
public static final String defaultDeckPath;
|
||||
public static final String defaultOtherPlayerIndex;
|
||||
public static final String defaultComputerName;
|
||||
|
||||
static {
|
||||
Properties p = new Properties();
|
||||
try {
|
||||
p.load(new FileInputStream(new File("config/config.properties")));
|
||||
} catch (IOException ex) {
|
||||
logger.fatal("Config error ", ex);
|
||||
}
|
||||
serverName = p.getProperty("server-name");
|
||||
port = Integer.parseInt(p.getProperty("port"));
|
||||
remoteServer = p.getProperty("remote-server");
|
||||
cardScalingFactor = Double.valueOf(p.getProperty("card-scaling-factor"));
|
||||
handScalingFactor = Double.valueOf(p.getProperty("hand-scaling-factor"));
|
||||
defaultGameType = p.getProperty("default-game-type", "Human");
|
||||
defaultDeckPath = p.getProperty("default-deck-path");
|
||||
defaultOtherPlayerIndex = p.getProperty("default-other-player-index");
|
||||
defaultComputerName = p.getProperty("default-computer-name");
|
||||
|
||||
dimensions = new CardDimensions(cardScalingFactor);
|
||||
}
|
||||
defaultGameType = p.getProperty("default-game-type", "Human");
|
||||
defaultDeckPath = p.getProperty("default-deck-path");
|
||||
defaultOtherPlayerIndex = p.getProperty("default-other-player-index");
|
||||
defaultComputerName = p.getProperty("default-computer-name");
|
||||
|
||||
dimensions = new CardDimensions(cardScalingFactor);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue