UI changes + created lite mode (client without images) for remote desktop work

This commit is contained in:
BetaSteward 2011-06-16 14:56:35 -04:00
parent e40caef07b
commit 89770db58e
12 changed files with 150 additions and 85 deletions

View file

@ -47,6 +47,7 @@
</Property> </Property>
</Properties> </Properties>
<AuxValues> <AuxValues>
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new MageJDesktop()"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="10"/> <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="10"/>
</AuxValues> </AuxValues>
@ -80,7 +81,7 @@
</Component> </Component>
<Component class="javax.swing.JButton" name="btnGames"> <Component class="javax.swing.JButton" name="btnGames">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Tables"/> <Property name="text" type="java.lang.String" value="Games"/>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
<EmptyBorder/> <EmptyBorder/>
@ -114,6 +115,32 @@
</Component> </Component>
<Component class="javax.swing.JToolBar$Separator" name="jSeparator2"> <Component class="javax.swing.JToolBar$Separator" name="jSeparator2">
</Component> </Component>
<Component class="javax.swing.JButton" name="btnCollectionViewer">
<Properties>
<Property name="text" type="java.lang.String" value="Collection Viewer"/>
<Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCollectionViewerActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JToolBar$Separator" name="jSeparator5">
</Component>
<Component class="javax.swing.JButton" name="btnPreferences">
<Properties>
<Property name="text" type="java.lang.String" value="Preferences"/>
<Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnPreferencesActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JToolBar$Separator" name="jSeparator6">
</Component>
<Component class="javax.swing.JButton" name="btnAbout"> <Component class="javax.swing.JButton" name="btnAbout">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="About"/> <Property name="text" type="java.lang.String" value="About"/>

View file

@ -100,6 +100,7 @@ import org.apache.log4j.Logger;
public class MageFrame extends javax.swing.JFrame implements MageClient { public class MageFrame extends javax.swing.JFrame implements MageClient {
private final static Logger logger = Logger.getLogger(MageFrame.class); private final static Logger logger = Logger.getLogger(MageFrame.class);
private final static String liteModeArg = "-lite";
private static Session session; private static Session session;
private ConnectDialog connectDialog; private ConnectDialog connectDialog;
@ -110,6 +111,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
private final static MageVersion version = new MageVersion(0, 7, 4, "beta-2"); private final static MageVersion version = new MageVersion(0, 7, 4, "beta-2");
private UUID clientId; private UUID clientId;
private static MagePane activeFrame; private static MagePane activeFrame;
private static boolean liteMode = false;
private static Map<UUID, ChatPanel> chats = new HashMap<UUID, ChatPanel>(); private static Map<UUID, ChatPanel> chats = new HashMap<UUID, ChatPanel>();
private static Map<UUID, GamePanel> games = new HashMap<UUID, GamePanel>(); private static Map<UUID, GamePanel> games = new HashMap<UUID, GamePanel>();
@ -132,6 +134,10 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
return prefs; return prefs;
} }
public static boolean isLite() {
return liteMode;
}
@Override @Override
public MageVersion getVersion() { public MageVersion getVersion() {
return version; return version;
@ -205,6 +211,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
public void componentResized(ComponentEvent e) { public void componentResized(ComponentEvent e) {
int width = ((JComponent) e.getSource()).getWidth(); int width = ((JComponent) e.getSource()).getWidth();
int height = ((JComponent) e.getSource()).getHeight(); int height = ((JComponent) e.getSource()).getHeight();
if (!liteMode)
backgroundPane.setSize(width, height); backgroundPane.setSize(width, height);
JPanel arrowsPanel = ArrowBuilder.getArrowsPanelRef(); JPanel arrowsPanel = ArrowBuilder.getArrowsPanelRef();
if (arrowsPanel != null) arrowsPanel.setSize(width, height); if (arrowsPanel != null) arrowsPanel.setSize(width, height);
@ -297,6 +304,8 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
} }
private void setBackground() { private void setBackground() {
if (liteMode)
return;
String filename = "/background.jpg"; String filename = "/background.jpg";
try { try {
if (Plugins.getInstance().isThemePluginLoaded()) { if (Plugins.getInstance().isThemePluginLoaded()) {
@ -315,6 +324,8 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
} }
private void addMageLabel() { private void addMageLabel() {
if (liteMode)
return;
String filename = "/label-mage.png"; String filename = "/label-mage.png";
try { try {
InputStream is = this.getClass().getResourceAsStream(filename); InputStream is = this.getClass().getResourceAsStream(filename);
@ -557,24 +568,24 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
desktopPane = new MageJDesktop(); desktopPane = new MageJDesktop();
mageToolbar = new javax.swing.JToolBar(); mageToolbar = new javax.swing.JToolBar();
btnConnect = new javax.swing.JButton(); btnConnect = new javax.swing.JButton();
jSeparator5 = new javax.swing.JToolBar.Separator();
btnGames = new javax.swing.JButton();
jSeparator4 = new javax.swing.JToolBar.Separator(); jSeparator4 = new javax.swing.JToolBar.Separator();
btnDeckEditor = new javax.swing.JButton(); btnGames = new javax.swing.JButton();
jSeparator3 = new javax.swing.JToolBar.Separator(); jSeparator3 = new javax.swing.JToolBar.Separator();
btnPreferences = new javax.swing.JButton(); btnDeckEditor = new javax.swing.JButton();
jSeparator2 = new javax.swing.JToolBar.Separator(); jSeparator2 = new javax.swing.JToolBar.Separator();
btnCollectionViewer = new javax.swing.JButton();
jSeparator5 = new javax.swing.JToolBar.Separator();
btnPreferences = new javax.swing.JButton();
jSeparator6 = new javax.swing.JToolBar.Separator();
btnAbout = new javax.swing.JButton(); btnAbout = new javax.swing.JButton();
jSeparator1 = new javax.swing.JToolBar.Separator(); jSeparator1 = new javax.swing.JToolBar.Separator();
btnExit = new javax.swing.JButton(); btnExit = new javax.swing.JButton();
lblStatus = new javax.swing.JLabel(); lblStatus = new javax.swing.JLabel();
jSeparator6 = new javax.swing.JToolBar.Separator();
btnCollectionViewer = new JButton();
jSeparator7 = new javax.swing.JToolBar.Separator();
btnChallenges = new JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
//setMinimumSize(new java.awt.Dimension(1024, 768)); setMinimumSize(new java.awt.Dimension(1024, 768));
desktopPane.setBackground(new java.awt.Color(204, 204, 204));
mageToolbar.setFloatable(false); mageToolbar.setFloatable(false);
mageToolbar.setRollover(true); mageToolbar.setRollover(true);
@ -592,7 +603,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
mageToolbar.add(btnConnect); mageToolbar.add(btnConnect);
mageToolbar.add(jSeparator4); mageToolbar.add(jSeparator4);
btnGames.setText("Tables"); btnGames.setText("Games");
btnGames.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); btnGames.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
btnGames.setFocusable(false); btnGames.setFocusable(false);
btnGames.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); btnGames.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
@ -619,7 +630,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
mageToolbar.add(jSeparator2); mageToolbar.add(jSeparator2);
btnCollectionViewer.setText("Collection Viewer"); btnCollectionViewer.setText("Collection Viewer");
btnCollectionViewer.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
btnCollectionViewer.setFocusable(false); btnCollectionViewer.setFocusable(false);
btnCollectionViewer.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); btnCollectionViewer.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnCollectionViewer.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); btnCollectionViewer.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
@ -629,23 +639,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
} }
}); });
mageToolbar.add(btnCollectionViewer); mageToolbar.add(btnCollectionViewer);
mageToolbar.add(jSeparator6); mageToolbar.add(jSeparator5);
/*btnChallenges.setText("Challenges");
btnChallenges.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
btnChallenges.setFocusable(false);
btnChallenges.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnChallenges.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnChallenges.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnChallengesActionPerformed(evt);
}
});
mageToolbar.add(btnChallenges);
mageToolbar.add(jSeparator7);*/
btnPreferences.setText("Preferences"); btnPreferences.setText("Preferences");
btnPreferences.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
btnPreferences.setFocusable(false); btnPreferences.setFocusable(false);
btnPreferences.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); btnPreferences.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnPreferences.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); btnPreferences.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
@ -655,7 +651,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
} }
}); });
mageToolbar.add(btnPreferences); mageToolbar.add(btnPreferences);
mageToolbar.add(jSeparator5); mageToolbar.add(jSeparator6);
btnAbout.setText("About"); btnAbout.setText("About");
btnAbout.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); btnAbout.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
@ -708,10 +704,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
showDeckEditor(DeckEditorMode.Constructed, null, null, 0); showDeckEditor(DeckEditorMode.Constructed, null, null, 0);
}//GEN-LAST:event_btnDeckEditorActionPerformed }//GEN-LAST:event_btnDeckEditorActionPerformed
private void btnCollectionViewerActionPerformed(java.awt.event.ActionEvent evt) {
showCollectionViewer();
}
private void btnChallengesActionPerformed(java.awt.event.ActionEvent evt) { private void btnChallengesActionPerformed(java.awt.event.ActionEvent evt) {
TableView table; TableView table;
try { try {
@ -737,10 +729,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
} }
} }
private void btnPreferencesActionPerformed(java.awt.event.ActionEvent evt) {
PhasesDialog.main(new String[]{});
}
private void btnGamesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGamesActionPerformed private void btnGamesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGamesActionPerformed
this.tablesPane.setVisible(true); this.tablesPane.setVisible(true);
this.tablesPane.showTables(); this.tablesPane.showTables();
@ -768,6 +756,14 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
aboutDialog.showDialog(version); aboutDialog.showDialog(version);
}//GEN-LAST:event_btnAboutActionPerformed }//GEN-LAST:event_btnAboutActionPerformed
private void btnCollectionViewerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCollectionViewerActionPerformed
showCollectionViewer();
}//GEN-LAST:event_btnCollectionViewerActionPerformed
private void btnPreferencesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPreferencesActionPerformed
PhasesDialog.main(new String[]{});
}//GEN-LAST:event_btnPreferencesActionPerformed
public void exitApp() { public void exitApp() {
session.disconnect(false); session.disconnect(false);
Plugins.getInstance().shutdown(); Plugins.getInstance().shutdown();
@ -832,7 +828,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
/** /**
* @param args the command line arguments * @param args the command line arguments
*/ */
public static void main(String args[]) { public static void main(final String args[]) {
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
public void uncaughtException(Thread t, Throwable e) { public void uncaughtException(Thread t, Throwable e) {
@ -841,6 +837,12 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}); });
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
public void run() { public void run() {
for (String arg: args) {
if (arg.startsWith(liteModeArg)) {
liteMode = true;
}
}
if (!liteMode) {
final SplashScreen splash = SplashScreen.getSplashScreen(); final SplashScreen splash = SplashScreen.getSplashScreen();
if (splash != null) { if (splash != null) {
Graphics2D g = splash.createGraphics(); Graphics2D g = splash.createGraphics();
@ -849,6 +851,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
} }
splash.update(); splash.update();
} }
}
new MageFrame().setVisible(true); new MageFrame().setVisible(true);
} }
}); });
@ -856,21 +859,19 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnAbout; private javax.swing.JButton btnAbout;
private javax.swing.JButton btnCollectionViewer;
private javax.swing.JButton btnConnect; private javax.swing.JButton btnConnect;
private javax.swing.JButton btnDeckEditor; private javax.swing.JButton btnDeckEditor;
private javax.swing.JButton btnCollectionViewer;
private javax.swing.JButton btnChallenges;
private javax.swing.JButton btnPreferences;
private javax.swing.JButton btnExit; private javax.swing.JButton btnExit;
private javax.swing.JButton btnGames; private javax.swing.JButton btnGames;
private static MageJDesktop desktopPane; private javax.swing.JButton btnPreferences;
private static javax.swing.JDesktopPane desktopPane;
private javax.swing.JToolBar.Separator jSeparator1; private javax.swing.JToolBar.Separator jSeparator1;
private javax.swing.JToolBar.Separator jSeparator2; private javax.swing.JToolBar.Separator jSeparator2;
private javax.swing.JToolBar.Separator jSeparator3; private javax.swing.JToolBar.Separator jSeparator3;
private javax.swing.JToolBar.Separator jSeparator4; private javax.swing.JToolBar.Separator jSeparator4;
private javax.swing.JToolBar.Separator jSeparator5; private javax.swing.JToolBar.Separator jSeparator5;
private javax.swing.JToolBar.Separator jSeparator6; private javax.swing.JToolBar.Separator jSeparator6;
private javax.swing.JToolBar.Separator jSeparator7;
private javax.swing.JLabel lblStatus; private javax.swing.JLabel lblStatus;
private javax.swing.JToolBar mageToolbar; private javax.swing.JToolBar mageToolbar;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables

View file

@ -50,6 +50,9 @@ import java.awt.image.BufferedImage;
import java.util.*; import java.util.*;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import mage.client.MageFrame;
import mage.client.util.gui.GuiDisplayUtil;
import org.jdesktop.swingx.JXPanel;
/** /**
* Table Model for card list. * Table Model for card list.
@ -244,15 +247,28 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
private void showImage(int row) { private void showImage(int row) {
CardView card = view.get(row); CardView card = view.get(row);
if (!card.getId().equals(bigCard.getCardId())) { if (!card.getId().equals(bigCard.getCardId())) {
if (!MageFrame.isLite()) {
Image image = Plugins.getInstance().getOriginalImage(card); Image image = Plugins.getInstance().getOriginalImage(card);
if (image != null && image instanceof BufferedImage) { if (image != null && image instanceof BufferedImage) {
// XXX: scaled to fit width // XXX: scaled to fit width
image = ImageHelper.getResizedImage((BufferedImage) image, bigCard.getWidth()); image = ImageHelper.getResizedImage((BufferedImage) image, bigCard.getWidth());
bigCard.setCard(card.getId(), image, new ArrayList<String>(), false); 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() { public List<CardView> getCardsView() {
return view; return view;
} }

View file

@ -13,6 +13,7 @@ import javax.swing.JComponent;
import mage.cards.MageCard; import mage.cards.MageCard;
import mage.cards.MagePermanent; import mage.cards.MagePermanent;
import mage.cards.action.impl.EmptyCallback; import mage.cards.action.impl.EmptyCallback;
import mage.client.MageFrame;
import mage.client.cards.BigCard; import mage.client.cards.BigCard;
import mage.client.cards.Card; import mage.client.cards.Card;
import mage.client.cards.Permanent; import mage.client.cards.Permanent;
@ -67,13 +68,13 @@ public class Plugins implements MagePlugins {
@Override @Override
public void updateGamePanel(Map<String, JComponent> ui) { public void updateGamePanel(Map<String, JComponent> ui) {
if (themePlugin == null) return; if (MageFrame.isLite() || themePlugin == null) return;
themePlugin.applyInGame(ui); themePlugin.applyInGame(ui);
} }
@Override @Override
public JComponent updateTablePanel(Map<String, JComponent> ui) { public JComponent updateTablePanel(Map<String, JComponent> ui) {
if (themePlugin == null) return null; if (MageFrame.isLite() || themePlugin == null) return null;
return themePlugin.updateTable(ui); return themePlugin.updateTable(ui);
} }
@ -82,7 +83,7 @@ public class Plugins implements MagePlugins {
if (cardPlugin != null) { if (cardPlugin != null) {
mageActionCallback.refreshSession(); mageActionCallback.refreshSession();
mageActionCallback.setCardPreviewComponent(bigCard); mageActionCallback.setCardPreviewComponent(bigCard);
return cardPlugin.getMagePermanent(card, dimension, gameId, mageActionCallback, canBeFoil); return cardPlugin.getMagePermanent(card, dimension, gameId, mageActionCallback, canBeFoil, !MageFrame.isLite());
} else { } else {
return new Permanent(card, bigCard, Config.dimensions, gameId); return new Permanent(card, bigCard, Config.dimensions, gameId);
} }
@ -93,7 +94,7 @@ public class Plugins implements MagePlugins {
if (cardPlugin != null) { if (cardPlugin != null) {
mageActionCallback.refreshSession(); mageActionCallback.refreshSession();
mageActionCallback.setCardPreviewComponent(bigCard); mageActionCallback.setCardPreviewComponent(bigCard);
return cardPlugin.getMageCard(card, dimension, gameId, mageActionCallback, canBeFoil); return cardPlugin.getMageCard(card, dimension, gameId, mageActionCallback, canBeFoil, !MageFrame.isLite());
} else { } else {
return new Card(card, bigCard, Config.dimensions, gameId); return new Card(card, bigCard, Config.dimensions, gameId);
} }

View file

@ -56,6 +56,8 @@ import javax.swing.table.AbstractTableModel;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.beans.PropertyVetoException; import java.beans.PropertyVetoException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.List; import java.util.List;
import java.util.concurrent.CancellationException; import java.util.concurrent.CancellationException;
@ -97,10 +99,10 @@ public class TablesPanel extends javax.swing.JPanel {
public void actionPerformed(ActionEvent e) public void actionPerformed(ActionEvent e)
{ {
int modelRow = Integer.valueOf( e.getActionCommand() ); int modelRow = Integer.valueOf( e.getActionCommand() );
UUID tableId = (UUID)tableModel.getValueAt(modelRow, 8); UUID tableId = (UUID)tableModel.getValueAt(modelRow, 9);
UUID gameId = (UUID)tableModel.getValueAt(modelRow, 7); UUID gameId = (UUID)tableModel.getValueAt(modelRow, 8);
String state = (String)tableModel.getValueAt(modelRow, 5); String state = (String)tableModel.getValueAt(modelRow, 5);
boolean isTournament = (Boolean)tableModel.getValueAt(modelRow, 6); boolean isTournament = (Boolean)tableModel.getValueAt(modelRow, 7);
String owner = (String)tableModel.getValueAt(modelRow, 1); String owner = (String)tableModel.getValueAt(modelRow, 1);
if (state.equals("Join")) { if (state.equals("Join")) {
@ -148,7 +150,7 @@ public class TablesPanel extends javax.swing.JPanel {
} }
}; };
ButtonColumn buttonColumn = new ButtonColumn(tableTables, join, 5); ButtonColumn buttonColumn = new ButtonColumn(tableTables, join, 6);
jSplitPane1.setOpaque(false); jSplitPane1.setOpaque(false);
jScrollPane1.setOpaque(false); jScrollPane1.setOpaque(false);
@ -394,9 +396,9 @@ public class TablesPanel extends javax.swing.JPanel {
} }
class TableTableModel extends AbstractTableModel { class TableTableModel extends AbstractTableModel {
private String[] columnNames = new String[]{"Table Name", "Owner", "Game Type", "Deck Type", "Status", "Action"}; private String[] columnNames = new String[]{"Match Name", "Owner", "Game Type", "Deck Type", "Status", "Created", "Action"};
private TableView[] tables = new TableView[0]; private TableView[] tables = new TableView[0];
private static final DateFormat timeFormatter = SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT);
public void loadData(Collection<TableView> tables) throws MageRemoteException { public void loadData(Collection<TableView> tables) throws MageRemoteException {
this.tables = tables.toArray(new TableView[0]); this.tables = tables.toArray(new TableView[0]);
@ -427,6 +429,8 @@ class TableTableModel extends AbstractTableModel {
case 4: case 4:
return tables[arg0].getTableState().toString(); return tables[arg0].getTableState().toString();
case 5: case 5:
return timeFormatter.format(tables[arg0].getCreateTime());
case 6:
switch (tables[arg0].getTableState()) { switch (tables[arg0].getTableState()) {
case WAITING: case WAITING:
return "Join"; return "Join";
@ -437,13 +441,13 @@ class TableTableModel extends AbstractTableModel {
default: default:
return ""; return "";
} }
case 6:
return tables[arg0].isTournament();
case 7: case 7:
return tables[arg0].isTournament();
case 8:
if (!tables[arg0].getGames().isEmpty()) if (!tables[arg0].getGames().isEmpty())
return tables[arg0].getGames().get(0); return tables[arg0].getGames().get(0);
return null; return null;
case 8: case 9:
return tables[arg0].getTableId(); return tables[arg0].getTableId();
} }
return ""; return "";
@ -466,7 +470,7 @@ class TableTableModel extends AbstractTableModel {
@Override @Override
public boolean isCellEditable(int rowIndex, int columnIndex) { public boolean isCellEditable(int rowIndex, int columnIndex) {
if (columnIndex != 5) if (columnIndex != 6)
return false; return false;
return true; return true;
} }

View file

@ -26,8 +26,8 @@ import net.xeoh.plugins.base.Plugin;
* @author nantuko * @author nantuko
*/ */
public interface CardPlugin extends Plugin { public interface CardPlugin extends Plugin {
MagePermanent getMagePermanent(PermanentView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil); MagePermanent getMagePermanent(PermanentView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage);
MagePermanent getMageCard(CardView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil); MagePermanent getMageCard(CardView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage);
void sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> cards); void sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> cards);
void downloadImages(Set<Card> allCards); void downloadImages(Set<Card> allCards);
void downloadSymbols(); void downloadSymbols();

View file

@ -30,6 +30,7 @@ package mage.view;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.Constants.TableState; import mage.Constants.TableState;
@ -49,6 +50,7 @@ public class TableView implements Serializable {
private String deckType; private String deckType;
private String tableName; private String tableName;
private String controllerName; private String controllerName;
private Date createTime;
private TableState tableState; private TableState tableState;
private boolean isTournament; private boolean isTournament;
private List<SeatView> seats = new ArrayList<SeatView>(); private List<SeatView> seats = new ArrayList<SeatView>();
@ -59,6 +61,7 @@ public class TableView implements Serializable {
this.gameType = table.getGameType(); this.gameType = table.getGameType();
this.tableName = table.getName(); this.tableName = table.getName();
this.controllerName = table.getControllerName(); this.controllerName = table.getControllerName();
this.createTime = table.getCreateTime();
this.deckType = table.getDeckType(); this.deckType = table.getDeckType();
this.tableState = table.getState(); this.tableState = table.getState();
this.isTournament = table.isTournament(); this.isTournament = table.isTournament();
@ -92,6 +95,10 @@ public class TableView implements Serializable {
return deckType; return deckType;
} }
public Date getCreateTime() {
return createTime;
}
public TableState getTableState() { public TableState getTableState() {
return tableState; return tableState;
} }

View file

@ -592,7 +592,9 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
@Override @Override
public Image getImage() { public Image getImage() {
if (this.hasImage)
return ImageCache.getImageOriginal(gameCard); return ImageCache.getImageOriginal(gameCard);
return null;
} }
@Override @Override

View file

@ -79,9 +79,9 @@ public class CardPluginImpl implements CardPlugin {
} }
@Override @Override
public MagePermanent getMagePermanent(PermanentView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil) { public MagePermanent getMagePermanent(PermanentView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage) {
boolean foil = canBeFoil && (new Random()).nextInt(5) == 0; boolean foil = canBeFoil && (new Random()).nextInt(5) == 0;
CardPanel cardPanel = new CardPanel(permanent, gameId, true, callback, foil); CardPanel cardPanel = new CardPanel(permanent, gameId, loadImage, callback, foil);
cardPanel.setCardBounds(0, 0, dimension.width, dimension.height); cardPanel.setCardBounds(0, 0, dimension.width, dimension.height);
boolean implemented = !permanent.getRarity().equals(mage.Constants.Rarity.NA); boolean implemented = !permanent.getRarity().equals(mage.Constants.Rarity.NA);
cardPanel.setShowCastingCost(implemented); cardPanel.setShowCastingCost(implemented);
@ -89,9 +89,9 @@ public class CardPluginImpl implements CardPlugin {
} }
@Override @Override
public MagePermanent getMageCard(CardView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil) { public MagePermanent getMageCard(CardView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage) {
boolean foil = canBeFoil && (new Random()).nextInt(5) == 0; boolean foil = canBeFoil && (new Random()).nextInt(5) == 0;
CardPanel cardPanel = new CardPanel(permanent, gameId, true, callback, foil); CardPanel cardPanel = new CardPanel(permanent, gameId, loadImage, callback, foil);
cardPanel.setCardBounds(0, 0, dimension.width, dimension.height); cardPanel.setCardBounds(0, 0, dimension.width, dimension.height);
boolean implemented = !permanent.getRarity().equals(mage.Constants.Rarity.NA); boolean implemented = !permanent.getRarity().equals(mage.Constants.Rarity.NA);
cardPanel.setShowCastingCost(implemented); cardPanel.setShowCastingCost(implemented);

View file

@ -52,11 +52,11 @@ public class RateThread extends Thread {
Card card1 = getRandomUniqueNonLandCard(null); Card card1 = getRandomUniqueNonLandCard(null);
Card card2 = getRandomUniqueNonLandCard(card1); Card card2 = getRandomUniqueNonLandCard(card1);
mageCard1 = impl.getMageCard(new CardView(card1), cardDimension, UUID.randomUUID(), new RateCallback(card1, card2, this, bigCard), false); mageCard1 = impl.getMageCard(new CardView(card1), cardDimension, UUID.randomUUID(), new RateCallback(card1, card2, this, bigCard), false, true);
mageCard1.setCardBounds(bigCardDimension.frameWidth + 80, 10, dimensions.frameWidth, dimensions.frameHeight); mageCard1.setCardBounds(bigCardDimension.frameWidth + 80, 10, dimensions.frameWidth, dimensions.frameHeight);
frame.add(mageCard1); frame.add(mageCard1);
mageCard2 = impl.getMageCard(new CardView(card2), cardDimension, UUID.randomUUID(), new RateCallback(card2, card1, this, bigCard), false); mageCard2 = impl.getMageCard(new CardView(card2), cardDimension, UUID.randomUUID(), new RateCallback(card2, card1, this, bigCard), false, true);
mageCard2.setCardBounds(bigCardDimension.frameWidth + 80 + dimensions.frameWidth + 30, 10, dimensions.frameWidth, dimensions.frameHeight); mageCard2.setCardBounds(bigCardDimension.frameWidth + 80 + dimensions.frameWidth + 30, 10, dimensions.frameWidth, dimensions.frameHeight);
frame.add(mageCard2); frame.add(mageCard2);

View file

@ -29,6 +29,7 @@
package mage.game; package mage.game;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.Constants.TableState; import mage.Constants.TableState;
@ -51,6 +52,7 @@ public class Table implements Serializable {
private String name; private String name;
private String controllerName; private String controllerName;
private String gameType; private String gameType;
private Date createTime;
private Seat[] seats; private Seat[] seats;
private int numSeats; private int numSeats;
private boolean isTournament; private boolean isTournament;
@ -80,6 +82,7 @@ public class Table implements Serializable {
this.gameType = gameType; this.gameType = gameType;
this.name = name; this.name = name;
this.controllerName = controllerName; this.controllerName = controllerName;
this.createTime = new Date();
createSeats(playerTypes); createSeats(playerTypes);
this.validator = validator; this.validator = validator;
} }
@ -129,6 +132,10 @@ public class Table implements Serializable {
return validator.getName(); return validator.getName();
} }
public Date getCreateTime() {
return createTime;
}
public boolean isTournament() { public boolean isTournament() {
return this.isTournament; return this.isTournament;
} }