mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
[card.plugin] Added card info panel. At the moment can be seen only in deck editor with -DtestCardInfo VM parameter.
This commit is contained in:
parent
53a26bb3b5
commit
49e44b92b1
12 changed files with 289 additions and 37 deletions
|
|
@ -137,7 +137,7 @@ public class MageFrame extends javax.swing.JFrame {
|
|||
|
||||
initComponents();
|
||||
setSize(1024,768);
|
||||
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||
//this.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||
|
||||
session = new Session(this);
|
||||
connectDialog = new ConnectDialog();
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ import java.util.UUID;
|
|||
import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.StyledDocument;
|
||||
|
||||
import mage.client.components.CardInfoPane;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
|
||||
import org.jdesktop.swingx.JXPanel;
|
||||
|
|
@ -66,6 +67,8 @@ public class BigCard extends javax.swing.JPanel {
|
|||
protected JXPanel panel;
|
||||
protected boolean initState;
|
||||
|
||||
protected CardInfoPane cardInfoPane;
|
||||
|
||||
public BigCard() {
|
||||
initComponents();
|
||||
if (!Plugins.getInstance().isCardPluginLoaded()) {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,20 @@
|
|||
|
||||
package mage.client.deckeditor;
|
||||
|
||||
import java.awt.Cursor;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.Event;
|
||||
import mage.client.util.Listener;
|
||||
import mage.components.CardInfoPane;
|
||||
import mage.game.GameException;
|
||||
import mage.view.CardsView;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
|
@ -42,19 +55,6 @@ import java.util.UUID;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
|
||||
import mage.cards.Card;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.util.Event;
|
||||
import mage.client.util.Listener;
|
||||
import mage.game.GameException;
|
||||
import mage.view.CardsView;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -64,6 +64,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
private JFileChooser fcSelectDeck;
|
||||
private JFileChooser fcImportDeck;
|
||||
private Deck deck = new Deck();
|
||||
private boolean isShowCardInfo = false;
|
||||
|
||||
/** Creates new form DeckEditorPanel */
|
||||
public DeckEditorPanel() {
|
||||
|
|
@ -96,6 +97,9 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
if (System.getProperty("draft") != null) {
|
||||
cardSelector.getCardsList().removeCard(card.getId());
|
||||
}
|
||||
if (cardInfoPane instanceof CardInfoPane) {
|
||||
((CardInfoPane)cardInfoPane).setCard(card);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -150,13 +154,6 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
jSplitPane1 = new javax.swing.JSplitPane();
|
||||
|
|
@ -179,6 +176,16 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
|
||||
bigCard.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
|
||||
|
||||
cardInfoPane = Plugins.getInstance().getCardInfoPane();
|
||||
if (cardInfoPane != null && System.getProperty("testCardInfo") != null) {
|
||||
cardInfoPane.setPreferredSize(new Dimension(170,230));
|
||||
cardInfoPane.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
|
||||
isShowCardInfo = true;
|
||||
} else {
|
||||
cardInfoPane = new JLabel();
|
||||
cardInfoPane.setVisible(false);
|
||||
}
|
||||
|
||||
lblDeckName.setLabelFor(txtDeckName);
|
||||
lblDeckName.setText("Deck Name:");
|
||||
|
||||
|
|
@ -225,10 +232,11 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.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))
|
||||
.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()
|
||||
|
|
@ -249,17 +257,18 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
.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)
|
||||
.addComponent(btnImport)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 159, Short.MAX_VALUE)
|
||||
.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)
|
||||
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
);
|
||||
|
||||
|
|
@ -277,7 +286,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 615, Short.MAX_VALUE)
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
}
|
||||
|
||||
private void btnLoadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoadActionPerformed
|
||||
String lastFolder = MageFrame.getPreferences().get("lastDeckFolder", "");
|
||||
|
|
@ -396,6 +405,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
private javax.swing.JTextField txtDeckName;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
private JComponent cardInfoPane;
|
||||
}
|
||||
|
||||
class DeckFilter extends FileFilter {
|
||||
|
|
|
|||
|
|
@ -34,4 +34,5 @@ public interface MagePlugins {
|
|||
Image getManaSymbolImage(String symbol);
|
||||
void onAddCard(MagePermanent card);
|
||||
void onRemoveCard(MagePermanent card);
|
||||
JComponent getCardInfoPane();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -181,4 +181,14 @@ public class Plugins implements MagePlugins {
|
|||
this.cardPlugin.onRemoveCard(card);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getCardInfoPane() {
|
||||
if (this.cardPlugin != null) {
|
||||
return this.cardPlugin.getCardInfoPane();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue