Merge pull request #5636 from hitch17/deck-exporters

Refactor Sets.saveDeck into a deck exporter series of classes.
This commit is contained in:
Oleg Agafonov 2019-03-19 03:32:54 +01:00 committed by GitHub
commit 7140a41445
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 310 additions and 80 deletions

View file

@ -11,7 +11,6 @@ import javax.swing.*;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import mage.cards.Sets;
import mage.cards.decks.Deck;
import mage.client.MageFrame;
import mage.client.dialog.PreferencesDialog;
@ -19,6 +18,8 @@ import mage.client.util.gui.ColorsChooser;
import mage.client.util.gui.FastSearchUtil;
import mage.client.util.sets.ConstructedFormats;
import static mage.cards.decks.DeckFormats.DCK;
/**
*
* @author Simown
@ -328,7 +329,7 @@ public class DeckGeneratorDialog {
tmp.getParentFile().mkdirs();
tmp.createNewFile();
deck.setName(deckName);
Sets.saveDeck(tmp.getAbsolutePath(), deck.getDeckCardLists());
DCK.getExporter().writeDeck(tmp.getAbsolutePath(), deck.getDeckCardLists());
cleanUp();
return tmp.getAbsolutePath();
} catch (Exception e) {

View file

@ -1,7 +1,6 @@
package mage.client.deckeditor;
import mage.cards.Card;
import mage.cards.Sets;
import mage.cards.decks.Deck;
import mage.cards.decks.DeckCardLists;
import mage.cards.decks.DnDDeckTargetListener;
@ -35,12 +34,13 @@ import java.awt.*;
import java.awt.dnd.DropTarget;
import java.awt.event.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
import java.util.*;
import java.util.concurrent.*;
import static mage.cards.decks.DeckFormats.DCK;
/**
* @author BetaSteward_at_googlemail.com
*/
@ -965,8 +965,8 @@ public class DeckEditorPanel extends javax.swing.JPanel {
DeckCardLists cardLists = deck.getDeckCardLists();
cardLists.setCardLayout(deckArea.getCardLayout());
cardLists.setSideboardLayout(deckArea.getSideboardLayout());
Sets.saveDeck(fileName, cardLists);
} catch (FileNotFoundException ex) {
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));