mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Fixed broken Deck Editor form -- now it's possible to load and edit by NetBeans
This commit is contained in:
parent
f74e4118e0
commit
b848bbfb65
2 changed files with 395 additions and 355 deletions
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||||
<AuxValues>
|
<AuxValues>
|
||||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
<DimensionLayout dim="1">
|
<DimensionLayout dim="1">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
|
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
|
||||||
<Component id="jSplitPane1" alignment="1" pref="615" max="32767" attributes="0"/>
|
<Component id="jSplitPane1" alignment="1" pref="612" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
<Component class="mage.client.deckeditor.DeckArea" name="deckArea">
|
<Component class="mage.client.deckeditor.DeckArea" name="deckArea">
|
||||||
<Constraints>
|
<Constraints>
|
||||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
|
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
|
||||||
<JSplitPaneConstraints position="right"/>
|
<JSplitPaneConstraints position="bottom"/>
|
||||||
</Constraint>
|
</Constraint>
|
||||||
</Constraints>
|
</Constraints>
|
||||||
</Component>
|
</Component>
|
||||||
|
@ -60,13 +60,13 @@
|
||||||
<Layout>
|
<Layout>
|
||||||
<DimensionLayout dim="0">
|
<DimensionLayout dim="0">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
|
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
|
||||||
<Component id="lblDeckName" min="-2" max="-2" attributes="0"/>
|
<Component id="lblDeckName" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="txtDeckName" pref="189" max="32767" attributes="0"/>
|
<Component id="txtDeckName" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
<Component id="bigCard" alignment="0" min="-2" max="-2" attributes="0"/>
|
<Component id="bigCard" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
@ -116,7 +116,7 @@
|
||||||
<Component id="btnAddLand" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="btnAddLand" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
<Component id="btnSubmit" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="btnSubmit" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
<EmptySpace pref="159" max="32767" attributes="0"/>
|
<EmptySpace max="32767" attributes="0"/>
|
||||||
<Component id="bigCard" min="-2" max="-2" attributes="0"/>
|
<Component id="bigCard" min="-2" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
|
@ -136,9 +136,6 @@
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JLabel" name="lblDeckName">
|
<Component class="javax.swing.JLabel" name="lblDeckName">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
|
|
||||||
<ComponentRef name="txtDeckName"/>
|
|
||||||
</Property>
|
|
||||||
<Property name="text" type="java.lang.String" value="Deck Name:"/>
|
<Property name="text" type="java.lang.String" value="Deck Name:"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
|
@ -220,8 +217,17 @@
|
||||||
</Events>
|
</Events>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="org.mage.plugins.card.info.CardInfoPaneImpl" name="cardInfoPane">
|
<Component class="org.mage.plugins.card.info.CardInfoPaneImpl" name="cardInfoPane">
|
||||||
|
<AuxValues>
|
||||||
|
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="Plugins.instance.getCardInfoPane()"/>
|
||||||
|
<AuxValue name="JavaCodeGenerator_CreateCodePost" type="java.lang.String" value="if (cardInfoPane != null && System.getProperty("testCardInfo") != null) {
 cardInfoPane.setPreferredSize(new Dimension(170, 150));
 cardInfoPane.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(200, 0, 0)));
 isShowCardInfo = true;
 } else {
 cardInfoPane = new JLabel();
 cardInfoPane.setVisible(false);
 }"/>
|
||||||
|
<AuxValue name="JavaCodeGenerator_DeclarationPost" type="java.lang.String" value="*/"/>
|
||||||
|
<AuxValue name="JavaCodeGenerator_DeclarationPre" type="java.lang.String" value="private JComponent cardInfoPane;
/*"/>
|
||||||
|
</AuxValues>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JTextField" name="txtTimeRemaining">
|
<Component class="javax.swing.JTextField" name="txtTimeRemaining">
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="txtTimeRemainingActionPerformed"/>
|
||||||
|
</Events>
|
||||||
</Component>
|
</Component>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Container>
|
</Container>
|
||||||
|
|
|
@ -60,11 +60,9 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
private int timeToSubmit = -1;
|
private int timeToSubmit = -1;
|
||||||
private final String LAST_DECK_FOLDER = "lastDeckFolder";
|
private final String LAST_DECK_FOLDER = "lastDeckFolder";
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates new form DeckEditorPanel
|
|
||||||
*/
|
|
||||||
public DeckEditorPanel() {
|
public DeckEditorPanel() {
|
||||||
initComponents();
|
initComponents();
|
||||||
|
|
||||||
fcSelectDeck = new JFileChooser();
|
fcSelectDeck = new JFileChooser();
|
||||||
fcSelectDeck.setAcceptAllFileFilterUsed(false);
|
fcSelectDeck.setAcceptAllFileFilterUsed(false);
|
||||||
fcSelectDeck.addChoosableFileFilter(new DeckFilter());
|
fcSelectDeck.addChoosableFileFilter(new DeckFilter());
|
||||||
|
@ -248,8 +246,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
this.jPanel1.setVisible(true);
|
this.jPanel1.setVisible(true);
|
||||||
for (ICardGrid component : this.cardSelector.getCardGridComponents()) {
|
for (ICardGrid component : this.cardSelector.getCardGridComponents()) {
|
||||||
component.clearCardEventListeners();
|
component.clearCardEventListeners();
|
||||||
component.addCardEventListener(
|
component.addCardEventListener((Listener<Event>) event -> {
|
||||||
(Listener<Event>) event -> {
|
|
||||||
switch (event.getEventType()) {
|
switch (event.getEventType()) {
|
||||||
case DOUBLE_CLICK:
|
case DOUBLE_CLICK:
|
||||||
moveSelectorCardToDeck(event);
|
moveSelectorCardToDeck(event);
|
||||||
|
@ -609,61 +606,8 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initComponents() {
|
private void importChoose(java.awt.event.ActionEvent evt) {
|
||||||
|
|
||||||
jSplitPane1 = new javax.swing.JSplitPane();
|
|
||||||
cardSelector = new mage.client.deckeditor.CardSelector();
|
|
||||||
deckArea = new mage.client.deckeditor.DeckArea();
|
|
||||||
jPanel1 = new javax.swing.JPanel();
|
|
||||||
bigCard = new mage.client.cards.BigCard();
|
|
||||||
txtDeckName = new javax.swing.JTextField();
|
|
||||||
lblDeckName = new javax.swing.JLabel();
|
|
||||||
btnSave = new javax.swing.JButton();
|
|
||||||
btnLoad = new javax.swing.JButton();
|
|
||||||
btnNew = new javax.swing.JButton();
|
|
||||||
btnExit = new javax.swing.JButton();
|
|
||||||
btnImport = new javax.swing.JButton();
|
|
||||||
btnSubmit = new javax.swing.JButton();
|
|
||||||
btnSubmitTimer = new javax.swing.JButton();
|
|
||||||
btnAddLand = new javax.swing.JButton();
|
|
||||||
btnGenDeck = new javax.swing.JButton();
|
|
||||||
txtTimeRemaining = new javax.swing.JTextField();
|
|
||||||
|
|
||||||
jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
|
|
||||||
jSplitPane1.setResizeWeight(0.5);
|
|
||||||
jSplitPane1.setTopComponent(cardSelector);
|
|
||||||
jSplitPane1.setBottomComponent(deckArea);
|
|
||||||
|
|
||||||
bigCard.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
|
|
||||||
|
|
||||||
cardInfoPane = Plugins.instance.getCardInfoPane();
|
|
||||||
if (cardInfoPane != null && System.getProperty("testCardInfo") != null) {
|
|
||||||
cardInfoPane.setPreferredSize(new Dimension(170, 150));
|
|
||||||
cardInfoPane.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(200, 0, 0)));
|
|
||||||
isShowCardInfo = true;
|
|
||||||
} else {
|
|
||||||
cardInfoPane = new JLabel();
|
|
||||||
cardInfoPane.setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
lblDeckName.setLabelFor(txtDeckName);
|
|
||||||
lblDeckName.setText("Deck Name:");
|
|
||||||
|
|
||||||
btnSave.setText("Save");
|
|
||||||
btnSave.addActionListener(evt -> btnSaveActionPerformed(evt));
|
|
||||||
|
|
||||||
btnLoad.setText("Load");
|
|
||||||
btnLoad.addActionListener(evt -> btnLoadActionPerformed(evt));
|
|
||||||
|
|
||||||
btnNew.setText("New");
|
|
||||||
btnNew.addActionListener(evt -> btnNewActionPerformed(evt));
|
|
||||||
|
|
||||||
btnExit.setText("Exit");
|
|
||||||
btnExit.addActionListener(evt -> btnExitActionPerformed(evt));
|
|
||||||
|
|
||||||
btnImport.setText("Import");
|
|
||||||
btnImport.setName("btnImport"); // NOI18N
|
|
||||||
btnImport.addActionListener(evt -> {
|
|
||||||
Object[] options = {"File", "Clipboard", "Append from Clipboard"};
|
Object[] options = {"File", "Clipboard", "Append from Clipboard"};
|
||||||
|
|
||||||
int n = JOptionPane.showOptionDialog(MageFrame.getDesktop(),
|
int n = JOptionPane.showOptionDialog(MageFrame.getDesktop(),
|
||||||
|
@ -680,123 +624,102 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
switch (n) {
|
switch (n) {
|
||||||
case 0:
|
case 0:
|
||||||
btnImportActionPerformed(evt);
|
importFromFile(evt);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
btnImportFromClipboardActionPerformed(evt);
|
importFromClipboard(evt);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
btnImportFromClipboardActionWAppendPerformed(evt);
|
importFromClipboardWithAppend(evt);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void importFromFile(java.awt.event.ActionEvent evt) {
|
||||||
|
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();
|
||||||
|
MageFrame.getDesktop().setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||||
|
try {
|
||||||
|
DeckImporter importer = DeckImporter.getDeckImporter(file.getPath());
|
||||||
|
|
||||||
|
if (importer != null) {
|
||||||
|
StringBuilder errorMessages = new StringBuilder();
|
||||||
|
Deck newDeck = null;
|
||||||
|
|
||||||
|
newDeck = Deck.load(importer.importDeck(file.getPath(), errorMessages));
|
||||||
|
processAndShowImportErrors(errorMessages);
|
||||||
|
|
||||||
|
if (newDeck != null) {
|
||||||
|
deck = newDeck;
|
||||||
|
refreshDeck();
|
||||||
|
}
|
||||||
|
|
||||||
|
// save last deck import folder
|
||||||
|
try {
|
||||||
|
MageFrame.getPreferences().put("lastImportFolder", file.getCanonicalPath());
|
||||||
|
} catch (IOException ex) {
|
||||||
|
logger.error("Error on save last used import folder: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Unknown deck format", "Error importing deck", JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.fatal(ex);
|
||||||
|
} finally {
|
||||||
|
MageFrame.getDesktop().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fcImportDeck.setSelectedFile(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void importFromClipboard(ActionEvent evt) {
|
||||||
|
final DeckImportFromClipboardDialog dialog = new DeckImportFromClipboardDialog();
|
||||||
|
dialog.pack();
|
||||||
|
dialog.setVisible(true);
|
||||||
|
|
||||||
|
dialog.addWindowListener(new WindowAdapter() {
|
||||||
|
@Override
|
||||||
|
public void windowClosed(WindowEvent e) {
|
||||||
|
loadDeck(dialog.getTmpPath());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
btnSubmit.setText("Submit");
|
private void importFromClipboardWithAppend(ActionEvent evt) {
|
||||||
btnSubmitTimer.setToolTipText("Submit your deck now!");
|
final DeckImportFromClipboardDialog dialog = new DeckImportFromClipboardDialog();
|
||||||
btnSubmit.setName("btnSubmit"); // NOI18N
|
dialog.pack();
|
||||||
btnSubmit.addActionListener(evt -> btnSubmitActionPerformed(evt));
|
dialog.setVisible(true);
|
||||||
|
|
||||||
btnSubmitTimer.setText("Submit (60s)");
|
dialog.addWindowListener(new WindowAdapter() {
|
||||||
btnSubmitTimer.setToolTipText("Submit your deck in one minute!");
|
@Override
|
||||||
btnSubmitTimer.setName("btnSubmitTimer");
|
public void windowClosed(WindowEvent e) {
|
||||||
btnSubmitTimer.addActionListener(evt -> btnSubmitTimerActionPerformed(evt));
|
Deck deckToAppend = null;
|
||||||
|
StringBuilder errorMessages = new StringBuilder();
|
||||||
|
|
||||||
btnAddLand.setText("Add Land");
|
MageFrame.getDesktop().setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||||
btnAddLand.setName("btnAddLand"); // NOI18N
|
try {
|
||||||
btnAddLand.addActionListener(evt -> btnAddLandActionPerformed(evt));
|
deckToAppend = Deck.load(DeckImporter.importDeckFromFile(dialog.getTmpPath(), errorMessages), true, true);
|
||||||
|
processAndShowImportErrors(errorMessages);
|
||||||
|
|
||||||
btnGenDeck.setText("Generate");
|
if (deckToAppend != null) {
|
||||||
btnGenDeck.setName("btnGenDeck");
|
deck = Deck.append(deckToAppend, deck);
|
||||||
btnGenDeck.addActionListener(evt -> btnGenDeckActionPerformed(evt));
|
refreshDeck();
|
||||||
txtTimeRemaining.setEditable(false);
|
}
|
||||||
txtTimeRemaining.setForeground(java.awt.Color.red);
|
} catch (GameException e1) {
|
||||||
txtTimeRemaining.setHorizontalAlignment(javax.swing.JTextField.CENTER);
|
JOptionPane.showMessageDialog(MageFrame.getDesktop(), e1.getMessage(), "Error loading deck", JOptionPane.ERROR_MESSAGE);
|
||||||
txtTimeRemaining.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
|
} finally {
|
||||||
|
MageFrame.getDesktop().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||||
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(btnGenDeck)
|
|
||||||
.addContainerGap()
|
|
||||||
.addComponent(btnAddLand)
|
|
||||||
.addContainerGap()
|
|
||||||
.addComponent(btnSubmit)
|
|
||||||
.addContainerGap()
|
|
||||||
.addComponent(btnSubmitTimer))
|
|
||||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
||||||
.addContainerGap()
|
|
||||||
.addComponent(txtTimeRemaining))
|
|
||||||
)
|
|
||||||
.addContainerGap()));
|
|
||||||
jPanel1Layout.setVerticalGroup(
|
|
||||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
||||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
||||||
.addContainerGap()
|
|
||||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
||||||
.addComponent(txtDeckName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
||||||
.addComponent(lblDeckName))
|
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
||||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
||||||
.addComponent(btnSave)
|
|
||||||
.addComponent(btnLoad)
|
|
||||||
.addComponent(btnNew)
|
|
||||||
.addComponent(btnExit))
|
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
||||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
||||||
.addComponent(btnImport)
|
|
||||||
.addComponent(btnGenDeck)
|
|
||||||
.addComponent(btnAddLand)
|
|
||||||
.addComponent(btnSubmit)
|
|
||||||
.addComponent(btnSubmitTimer))
|
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
||||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
||||||
.addComponent(txtTimeRemaining))
|
|
||||||
//.addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, isShowCardInfo ? 30 : 159, Short.MAX_VALUE)
|
|
||||||
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 104, Short.MAX_VALUE)
|
|
||||||
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)));
|
|
||||||
|
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
|
||||||
this.setLayout(layout);
|
|
||||||
layout.setHorizontalGroup(
|
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
||||||
.addGroup(layout.createSequentialGroup()
|
|
||||||
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
||||||
.addGap(0, 0, 0)
|
|
||||||
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 604, Short.MAX_VALUE)));
|
|
||||||
layout.setVerticalGroup(
|
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
||||||
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
||||||
.addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 615, Short.MAX_VALUE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processAndShowImportErrors(StringBuilder errorMessages) {
|
private void processAndShowImportErrors(StringBuilder errorMessages) {
|
||||||
|
@ -829,52 +752,242 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param evt ActionEvent
|
* 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.
|
||||||
*/
|
*/
|
||||||
private void btnImportFromClipboardActionPerformed(ActionEvent evt) {
|
@SuppressWarnings("unchecked")
|
||||||
final DeckImportFromClipboardDialog dialog = new DeckImportFromClipboardDialog();
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
dialog.pack();
|
private void initComponents() {
|
||||||
dialog.setVisible(true);
|
|
||||||
|
|
||||||
dialog.addWindowListener(new WindowAdapter() {
|
jSplitPane1 = new javax.swing.JSplitPane();
|
||||||
@Override
|
cardSelector = new mage.client.deckeditor.CardSelector();
|
||||||
public void windowClosed(WindowEvent e) {
|
deckArea = new mage.client.deckeditor.DeckArea();
|
||||||
loadDeck(dialog.getTmpPath());
|
jPanel1 = new javax.swing.JPanel();
|
||||||
|
bigCard = new mage.client.cards.BigCard();
|
||||||
|
txtDeckName = new javax.swing.JTextField();
|
||||||
|
lblDeckName = new javax.swing.JLabel();
|
||||||
|
btnSave = new javax.swing.JButton();
|
||||||
|
btnLoad = new javax.swing.JButton();
|
||||||
|
btnNew = new javax.swing.JButton();
|
||||||
|
btnExit = new javax.swing.JButton();
|
||||||
|
btnImport = new javax.swing.JButton();
|
||||||
|
btnAddLand = new javax.swing.JButton();
|
||||||
|
btnGenDeck = new javax.swing.JButton();
|
||||||
|
btnSubmit = new javax.swing.JButton();
|
||||||
|
btnSubmitTimer = new javax.swing.JButton();
|
||||||
|
cardInfoPane = Plugins.instance.getCardInfoPane();
|
||||||
|
if (cardInfoPane != null && System.getProperty("testCardInfo") != null) {
|
||||||
|
cardInfoPane.setPreferredSize(new Dimension(170, 150));
|
||||||
|
cardInfoPane.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(200, 0, 0)));
|
||||||
|
isShowCardInfo = true;
|
||||||
|
} else {
|
||||||
|
cardInfoPane = new JLabel();
|
||||||
|
cardInfoPane.setVisible(false);
|
||||||
|
}
|
||||||
|
txtTimeRemaining = new javax.swing.JTextField();
|
||||||
|
|
||||||
|
jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
|
||||||
|
jSplitPane1.setResizeWeight(0.5);
|
||||||
|
jSplitPane1.setTopComponent(cardSelector);
|
||||||
|
jSplitPane1.setBottomComponent(deckArea);
|
||||||
|
|
||||||
|
bigCard.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
|
||||||
|
|
||||||
|
lblDeckName.setText("Deck Name:");
|
||||||
|
|
||||||
|
btnSave.setText("Save");
|
||||||
|
btnSave.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
btnSaveActionPerformed(evt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
|
btnLoad.setText("Load");
|
||||||
|
btnLoad.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
btnLoadActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
btnNew.setText("New");
|
||||||
|
btnNew.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
btnNewActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
btnExit.setText("Exit");
|
||||||
|
btnExit.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
btnExitActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
btnImport.setText("Import");
|
||||||
|
btnImport.setName("btnImport"); // NOI18N
|
||||||
|
btnImport.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
btnImportActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
btnAddLand.setText("Add Land");
|
||||||
|
btnAddLand.setName("btnAddLand"); // NOI18N
|
||||||
|
btnAddLand.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
btnAddLandActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
btnGenDeck.setText("Generate");
|
||||||
|
btnGenDeck.setName("btnGenDeck"); // NOI18N
|
||||||
|
btnGenDeck.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
btnGenDeckActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
btnSubmit.setText("Submit");
|
||||||
|
btnSubmit.setName("btnSubmit"); // NOI18N
|
||||||
|
btnSubmit.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
btnSubmitActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
btnSubmitTimer.setText("Submit in 1 minute");
|
||||||
|
btnSubmitTimer.setName("btnSubmitTimer"); // NOI18N
|
||||||
|
btnSubmitTimer.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
btnSubmitTimerActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
txtTimeRemaining.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
txtTimeRemainingActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
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(jPanel1Layout.createSequentialGroup()
|
||||||
|
.addGap(6, 6, 6)
|
||||||
|
.addComponent(lblDeckName)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(txtDeckName))
|
||||||
|
.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)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(btnGenDeck)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(btnAddLand)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addComponent(btnSubmit)))
|
||||||
|
.addContainerGap())
|
||||||
|
);
|
||||||
|
jPanel1Layout.setVerticalGroup(
|
||||||
|
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(txtDeckName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(lblDeckName))
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(btnSave)
|
||||||
|
.addComponent(btnLoad)
|
||||||
|
.addComponent(btnNew)
|
||||||
|
.addComponent(btnExit))
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(btnImport)
|
||||||
|
.addComponent(btnGenDeck)
|
||||||
|
.addComponent(btnAddLand)
|
||||||
|
.addComponent(btnSubmit))
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
|
);
|
||||||
|
|
||||||
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||||
|
this.setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addGap(0, 0, 0)
|
||||||
|
.addComponent(jSplitPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 604, Short.MAX_VALUE))
|
||||||
|
);
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
|
.addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 612, Short.MAX_VALUE)
|
||||||
|
);
|
||||||
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
|
||||||
|
String lastFolder = MageFrame.getPreferences().get(LAST_DECK_FOLDER, "");
|
||||||
|
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();
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* @param evt ActionEvent
|
* Work around a JFileChooser bug on Windows 7-10 with JRT 7+ In
|
||||||
|
* the case where the user selects the exact same file as was
|
||||||
|
* previously selected without touching anything else in the
|
||||||
|
* dialog, getSelectedFile() will erroneously return null due to
|
||||||
|
* some combination of our settings.
|
||||||
|
*
|
||||||
|
* We manually sub in the last selected file in this case.
|
||||||
*/
|
*/
|
||||||
private void btnImportFromClipboardActionWAppendPerformed(ActionEvent evt) {
|
if (file == null) {
|
||||||
final DeckImportFromClipboardDialog dialog = new DeckImportFromClipboardDialog();
|
if (!lastFolder.isEmpty()) {
|
||||||
dialog.pack();
|
file = new File(lastFolder);
|
||||||
dialog.setVisible(true);
|
|
||||||
|
|
||||||
dialog.addWindowListener(new WindowAdapter() {
|
|
||||||
@Override
|
|
||||||
public void windowClosed(WindowEvent e) {
|
|
||||||
Deck deckToAppend = null;
|
|
||||||
StringBuilder errorMessages = new StringBuilder();
|
|
||||||
|
|
||||||
MageFrame.getDesktop().setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
|
||||||
try {
|
|
||||||
deckToAppend = Deck.load(DeckImporter.importDeckFromFile(dialog.getTmpPath(), errorMessages), true, true);
|
|
||||||
processAndShowImportErrors(errorMessages);
|
|
||||||
|
|
||||||
if (deckToAppend != null) {
|
|
||||||
deck = Deck.append(deckToAppend, deck);
|
|
||||||
refreshDeck();
|
|
||||||
}
|
}
|
||||||
} catch (GameException e1) {
|
}
|
||||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), e1.getMessage(), "Error loading deck", JOptionPane.ERROR_MESSAGE);
|
}
|
||||||
|
try {
|
||||||
|
String fileName = file.getPath();
|
||||||
|
if (!fileName.endsWith(".dck")) {
|
||||||
|
fileName += ".dck";
|
||||||
|
}
|
||||||
|
MageFrame.getDesktop().setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||||
|
DeckCardLists cardLists = deck.getDeckCardLists();
|
||||||
|
cardLists.setCardLayout(deckArea.getCardLayout());
|
||||||
|
cardLists.setSideboardLayout(deckArea.getSideboardLayout());
|
||||||
|
DCK.getExporter().writeDeck(fileName, cardLists);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage() + "\nTry ensuring that the selected directory is writable.", "Error saving deck", JOptionPane.ERROR_MESSAGE);
|
||||||
} finally {
|
} finally {
|
||||||
MageFrame.getDesktop().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
MageFrame.getDesktop().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
MageFrame.getPreferences().put(LAST_DECK_FOLDER, file.getCanonicalPath());
|
||||||
|
} catch (IOException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
}//GEN-LAST:event_btnSaveActionPerformed
|
||||||
|
|
||||||
private void btnLoadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoadActionPerformed
|
private void btnLoadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoadActionPerformed
|
||||||
//fcSelectDeck.setCurrentDirectory(new File());
|
//fcSelectDeck.setCurrentDirectory(new File());
|
||||||
|
@ -931,54 +1044,6 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
fcSelectDeck.setSelectedFile(null);
|
fcSelectDeck.setSelectedFile(null);
|
||||||
}//GEN-LAST:event_btnLoadActionPerformed
|
}//GEN-LAST:event_btnLoadActionPerformed
|
||||||
|
|
||||||
private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
|
|
||||||
String lastFolder = MageFrame.getPreferences().get(LAST_DECK_FOLDER, "");
|
|
||||||
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();
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Work around a JFileChooser bug on Windows 7-10 with JRT 7+ In
|
|
||||||
* the case where the user selects the exact same file as was
|
|
||||||
* previously selected without touching anything else in the
|
|
||||||
* dialog, getSelectedFile() will erroneously return null due to
|
|
||||||
* some combination of our settings.
|
|
||||||
*
|
|
||||||
* We manually sub in the last selected file in this case.
|
|
||||||
*/
|
|
||||||
if (file == null) {
|
|
||||||
if (!lastFolder.isEmpty()) {
|
|
||||||
file = new File(lastFolder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
String fileName = file.getPath();
|
|
||||||
if (!fileName.endsWith(".dck")) {
|
|
||||||
fileName += ".dck";
|
|
||||||
}
|
|
||||||
MageFrame.getDesktop().setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
|
||||||
DeckCardLists cardLists = deck.getDeckCardLists();
|
|
||||||
cardLists.setCardLayout(deckArea.getCardLayout());
|
|
||||||
cardLists.setSideboardLayout(deckArea.getSideboardLayout());
|
|
||||||
DCK.getExporter().writeDeck(fileName, cardLists);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage() + "\nTry ensuring that the selected directory is writable.", "Error saving deck", JOptionPane.ERROR_MESSAGE);
|
|
||||||
} finally {
|
|
||||||
MageFrame.getDesktop().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
MageFrame.getPreferences().put(LAST_DECK_FOLDER, file.getCanonicalPath());
|
|
||||||
} catch (IOException ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}//GEN-LAST:event_btnSaveActionPerformed
|
|
||||||
|
|
||||||
private void btnNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewActionPerformed
|
private void btnNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewActionPerformed
|
||||||
if (mode == DeckEditorMode.SIDEBOARDING || mode == DeckEditorMode.LIMITED_BUILDING) {
|
if (mode == DeckEditorMode.SIDEBOARDING || mode == DeckEditorMode.LIMITED_BUILDING) {
|
||||||
for (Card card : deck.getCards()) {
|
for (Card card : deck.getCards()) {
|
||||||
|
@ -996,48 +1061,26 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
removeDeckEditor();
|
removeDeckEditor();
|
||||||
}//GEN-LAST:event_btnExitActionPerformed
|
}//GEN-LAST:event_btnExitActionPerformed
|
||||||
|
|
||||||
private void btnImportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImportActionPerformed
|
private void btnAddLandActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddLandActionPerformed
|
||||||
String lastFolder = MageFrame.getPreferences().get("lastImportFolder", "");
|
AddLandDialog addLand = new AddLandDialog();
|
||||||
if (!lastFolder.isEmpty()) {
|
addLand.showDialog(deck, mode);
|
||||||
fcImportDeck.setCurrentDirectory(new File(lastFolder));
|
|
||||||
}
|
|
||||||
int ret = fcImportDeck.showOpenDialog(this);
|
|
||||||
if (ret == JFileChooser.APPROVE_OPTION) {
|
|
||||||
File file = fcImportDeck.getSelectedFile();
|
|
||||||
MageFrame.getDesktop().setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
|
||||||
try {
|
|
||||||
DeckImporter importer = DeckImporter.getDeckImporter(file.getPath());
|
|
||||||
|
|
||||||
if (importer != null) {
|
|
||||||
StringBuilder errorMessages = new StringBuilder();
|
|
||||||
Deck newDeck = null;
|
|
||||||
|
|
||||||
newDeck = Deck.load(importer.importDeck(file.getPath(), errorMessages));
|
|
||||||
processAndShowImportErrors(errorMessages);
|
|
||||||
|
|
||||||
if (newDeck != null) {
|
|
||||||
deck = newDeck;
|
|
||||||
refreshDeck();
|
refreshDeck();
|
||||||
}
|
}//GEN-LAST:event_btnAddLandActionPerformed
|
||||||
|
|
||||||
// save last deck import folder
|
private void btnGenDeckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGenDeckActionPerformed
|
||||||
try {
|
try {
|
||||||
MageFrame.getPreferences().put("lastImportFolder", file.getCanonicalPath());
|
MageFrame.getDesktop().setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||||
} catch (IOException ex) {
|
String path = DeckGenerator.generateDeck();
|
||||||
logger.error("Error on save last used import folder: " + ex.getMessage());
|
deck = Deck.load(DeckImporter.importDeckFromFile(path), true, true);
|
||||||
}
|
} catch (GameException ex) {
|
||||||
|
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Error loading generated deck", JOptionPane.ERROR_MESSAGE);
|
||||||
} else {
|
} catch (DeckGeneratorException ex) {
|
||||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Unknown deck format", "Error importing deck", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Generator error", JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
logger.fatal(ex);
|
|
||||||
} finally {
|
} finally {
|
||||||
MageFrame.getDesktop().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
MageFrame.getDesktop().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||||
}
|
}
|
||||||
}
|
refreshDeck();
|
||||||
fcImportDeck.setSelectedFile(null);
|
}//GEN-LAST:event_btnGenDeckActionPerformed
|
||||||
}//GEN-LAST:event_btnImportActionPerformed
|
|
||||||
|
|
||||||
private void btnSubmitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSubmitActionPerformed
|
private void btnSubmitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSubmitActionPerformed
|
||||||
if (updateDeckTask != null) {
|
if (updateDeckTask != null) {
|
||||||
|
@ -1067,45 +1110,36 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
}, 60, TimeUnit.SECONDS);
|
}, 60, TimeUnit.SECONDS);
|
||||||
}//GEN-LAST:event_btnSubmitTimerActionPerformed
|
}//GEN-LAST:event_btnSubmitTimerActionPerformed
|
||||||
|
|
||||||
private void btnAddLandActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddLandActionPerformed
|
private void txtTimeRemainingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtTimeRemainingActionPerformed
|
||||||
AddLandDialog addLand = new AddLandDialog();
|
// TODO add your handling code here:
|
||||||
addLand.showDialog(deck, mode);
|
}//GEN-LAST:event_txtTimeRemainingActionPerformed
|
||||||
refreshDeck();
|
|
||||||
}//GEN-LAST:event_btnAddLandActionPerformed
|
private void btnImportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImportActionPerformed
|
||||||
|
importChoose(evt);
|
||||||
|
}//GEN-LAST:event_btnImportActionPerformed
|
||||||
|
|
||||||
private void btnGenDeckActionPerformed(ActionEvent evt) {
|
|
||||||
try {
|
|
||||||
MageFrame.getDesktop().setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
|
||||||
String path = DeckGenerator.generateDeck();
|
|
||||||
deck = Deck.load(DeckImporter.importDeckFromFile(path), true, true);
|
|
||||||
} catch (GameException ex) {
|
|
||||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Error loading generated deck", JOptionPane.ERROR_MESSAGE);
|
|
||||||
} catch (DeckGeneratorException ex) {
|
|
||||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Generator error", JOptionPane.ERROR_MESSAGE);
|
|
||||||
} finally {
|
|
||||||
MageFrame.getDesktop().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
|
||||||
}
|
|
||||||
refreshDeck();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private mage.client.cards.BigCard bigCard;
|
private mage.client.cards.BigCard bigCard;
|
||||||
|
private javax.swing.JButton btnAddLand;
|
||||||
private javax.swing.JButton btnExit;
|
private javax.swing.JButton btnExit;
|
||||||
|
private javax.swing.JButton btnGenDeck;
|
||||||
private javax.swing.JButton btnImport;
|
private javax.swing.JButton btnImport;
|
||||||
private javax.swing.JButton btnLoad;
|
private javax.swing.JButton btnLoad;
|
||||||
private javax.swing.JButton btnNew;
|
private javax.swing.JButton btnNew;
|
||||||
private javax.swing.JButton btnSave;
|
private javax.swing.JButton btnSave;
|
||||||
|
private javax.swing.JButton btnSubmit;
|
||||||
|
private javax.swing.JButton btnSubmitTimer;
|
||||||
|
private JComponent cardInfoPane;
|
||||||
|
/*
|
||||||
|
private org.mage.plugins.card.info.CardInfoPaneImpl cardInfoPane;
|
||||||
|
*/
|
||||||
private mage.client.deckeditor.CardSelector cardSelector;
|
private mage.client.deckeditor.CardSelector cardSelector;
|
||||||
private mage.client.deckeditor.DeckArea deckArea;
|
private mage.client.deckeditor.DeckArea deckArea;
|
||||||
private javax.swing.JPanel jPanel1;
|
private javax.swing.JPanel jPanel1;
|
||||||
private javax.swing.JSplitPane jSplitPane1;
|
private javax.swing.JSplitPane jSplitPane1;
|
||||||
private javax.swing.JLabel lblDeckName;
|
private javax.swing.JLabel lblDeckName;
|
||||||
private javax.swing.JTextField txtDeckName;
|
private javax.swing.JTextField txtDeckName;
|
||||||
private javax.swing.JButton btnSubmit;
|
|
||||||
private javax.swing.JButton btnSubmitTimer;
|
|
||||||
private javax.swing.JButton btnAddLand;
|
|
||||||
private javax.swing.JButton btnGenDeck;
|
|
||||||
private JComponent cardInfoPane;
|
|
||||||
private javax.swing.JTextField txtTimeRemaining;
|
private javax.swing.JTextField txtTimeRemaining;
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration//GEN-END:variables
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue