Coverted deck editors and cardshop to JDialog.

This allows them to be modal and gets rid of the setAlwaysOnTop() call. (Which causes all manner of headaches on Linux)
This commit is contained in:
Fnoed
2012-03-18 21:06:29 +00:00
parent eb6274de8c
commit ef4fe171bb
13 changed files with 1848 additions and 1846 deletions

View File

@@ -1,351 +1,354 @@
/* /*
* Forge: Play Magic: the Gathering. * Forge: Play Magic: the Gathering.
* Copyright (C) 2011 Forge Team * Copyright (C) 2011 Forge Team
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package forge.gui.deckeditor; package forge.gui.deckeditor;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import javax.swing.JDialog;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import forge.Command;
import forge.Command; import forge.deck.DeckBase;
import forge.deck.DeckBase; import forge.gui.deckeditor.elements.CardPanelBase;
import forge.gui.deckeditor.elements.CardPanelBase; import forge.gui.deckeditor.elements.DeckAnalysis;
import forge.gui.deckeditor.elements.DeckAnalysis; import forge.gui.deckeditor.elements.FilterCheckBoxes;
import forge.gui.deckeditor.elements.FilterCheckBoxes; import forge.gui.deckeditor.elements.TableView;
import forge.gui.deckeditor.elements.TableView; import forge.item.CardPrinted;
import forge.item.CardPrinted; import forge.item.InventoryItem;
import forge.item.InventoryItem; import forge.item.ItemPool;
import forge.item.ItemPool; import forge.item.ItemPoolView;
import forge.item.ItemPoolView; import forge.util.Predicate;
import forge.util.Predicate;
/**
/** * The Class DeckEditorBase.
* The Class DeckEditorBase. *
* * @param <T> the generic type
* @param <T> the generic type * @param <TModel> the generic type
* @param <TModel> the generic type */
*/ public abstract class DeckEditorBase<T extends InventoryItem, TModel extends DeckBase> extends JDialog {
public abstract class DeckEditorBase<T extends InventoryItem, TModel extends DeckBase> extends JFrame { private static final long serialVersionUID = -401223933343539977L;
private static final long serialVersionUID = -401223933343539977L;
/** The filter boxes. */
/** The filter boxes. */ private FilterCheckBoxes filterBoxes;
private FilterCheckBoxes filterBoxes; // set this to false when resetting filter from code (like
// set this to false when resetting filter from code (like // "clearFiltersPressed"), reset when done.
// "clearFiltersPressed"), reset when done. /** The is filters change firing update. */
/** The is filters change firing update. */ private boolean isFiltersChangeFiringUpdate = true;
private boolean isFiltersChangeFiringUpdate = true;
/** The card view. */
/** The card view. */ private CardPanelBase cardView;
private CardPanelBase cardView;
// CardPools and Table data for top and bottom lists
// CardPools and Table data for top and bottom lists /** The top. */
/** The top. */ private TableView<T> topTableWithCards;
private TableView<T> topTableWithCards;
/** The bottom. */
/** The bottom. */ private TableView<T> bottomTableWithCards;
private TableView<T> bottomTableWithCards;
public DeckEditorBase(JFrame parent) {
// top shows available card pool super(parent, ModalityType.APPLICATION_MODAL);
// if constructed, top shows all cards }
// if sealed, top shows N booster packs
// if draft, top shows cards that were chosen // top shows available card pool
/** // if constructed, top shows all cards
* Gets the top table model. // if sealed, top shows N booster packs
* // if draft, top shows cards that were chosen
* @return the top table model /**
*/ * Gets the top table model.
public final TableView<T> getTopTableModel() { *
return this.getTopTableWithCards(); * @return the top table model
} */
public final TableView<T> getTopTableModel() {
/* return this.getTopTableWithCards();
* (non-Javadoc) }
*
* @see forge.gui.deckeditor.DeckDisplay#getTop() /*
*/ * (non-Javadoc)
/** *
* Gets the top. * @see forge.gui.deckeditor.DeckDisplay#getTop()
* */
* @return the top /**
*/ * Gets the top.
public final ItemPoolView<T> getTop() { *
return this.getTopTableWithCards().getCards(); * @return the top
} */
public final ItemPoolView<T> getTop() {
// bottom shows player's choice - be it deck or draft return this.getTopTableWithCards().getCards();
/* }
* (non-Javadoc)
* // bottom shows player's choice - be it deck or draft
* @see forge.gui.deckeditor.DeckDisplay#getBottom() /*
*/ * (non-Javadoc)
/** *
* Gets the bottom. * @see forge.gui.deckeditor.DeckDisplay#getBottom()
* */
* @return the bottom /**
*/ * Gets the bottom.
public final ItemPoolView<T> getBottom() { *
return this.getBottomTableWithCards().getCards(); * @return the bottom
} */
public final ItemPoolView<T> getBottom() {
/** return this.getBottomTableWithCards().getCards();
* Gets the controller. }
*
* @return the controller /**
*/ * Gets the controller.
public abstract DeckController<TModel> getController(); *
* @return the controller
// THIS IS HERE FOR OVERLOADING!!!1 */
// or may be return abstract getFilter from derived class + this filter ... public abstract DeckController<TModel> getController();
// virtual protected member, but later
/** // THIS IS HERE FOR OVERLOADING!!!1
* Builds the filter. // or may be return abstract getFilter from derived class + this filter ...
* // virtual protected member, but later
* @return the predicate /**
*/ * Builds the filter.
protected abstract Predicate<T> buildFilter(); *
* @return the predicate
/** */
* Show. protected abstract Predicate<T> buildFilter();
*
* @param exitCommand the exit command /**
*/ * Show.
public abstract void show(final Command exitCommand); *
* @param exitCommand the exit command
/** */
* Analysis button_action performed. public abstract void show(final Command exitCommand);
*
* @param e /**
* the e * Analysis button_action performed.
*/ *
final void analysisButtonActionPerformed(final ActionEvent e) { * @param e
final ItemPoolView<CardPrinted> deck = ItemPool.createFrom(this.getBottomTableWithCards().getCards(), * the e
CardPrinted.class); */
if (deck.isEmpty()) { final void analysisButtonActionPerformed(final ActionEvent e) {
JOptionPane.showMessageDialog(null, "Cards in deck not found.", "Analysis Deck", final ItemPoolView<CardPrinted> deck = ItemPool.createFrom(this.getBottomTableWithCards().getCards(),
JOptionPane.INFORMATION_MESSAGE); CardPrinted.class);
} else { if (deck.isEmpty()) {
final DeckEditorBase<T, TModel> g = DeckEditorBase.this; JOptionPane.showMessageDialog(null, "Cards in deck not found.", "Analysis Deck",
final DeckAnalysis dAnalysis = new DeckAnalysis(g, deck); JOptionPane.INFORMATION_MESSAGE);
dAnalysis.setVisible(true); } else {
g.setEnabled(false); final DeckEditorBase<T, TModel> g = DeckEditorBase.this;
} final DeckAnalysis dAnalysis = new DeckAnalysis(g, deck);
} dAnalysis.setVisible(true);
g.setEnabled(false);
/* }
* (non-Javadoc) }
*
* @see forge.gui.deckeditor.DeckDisplay#setItems(forge.item.ItemPoolView, /*
* forge.item.ItemPoolView, forge.game.GameType) * (non-Javadoc)
*/ *
/** * @see forge.gui.deckeditor.DeckDisplay#setItems(forge.item.ItemPoolView,
* Update view. * forge.item.ItemPoolView, forge.game.GameType)
*/ */
public abstract void updateView(); /**
* Update view.
/** */
* Update display. public abstract void updateView();
*/
public final void updateDisplay() { /**
this.getTopTableWithCards().setFilter(this.buildFilter()); * Update display.
} */
public final void updateDisplay() {
/** The item listener updates display. */ this.getTopTableWithCards().setFilter(this.buildFilter());
private ItemListener itemListenerUpdatesDisplay = new ItemListener() { }
@Override
public void itemStateChanged(final ItemEvent e) { /** The item listener updates display. */
if (DeckEditorBase.this.isFiltersChangeFiringUpdate()) { private ItemListener itemListenerUpdatesDisplay = new ItemListener() {
DeckEditorBase.this.updateDisplay(); @Override
} public void itemStateChanged(final ItemEvent e) {
} if (DeckEditorBase.this.isFiltersChangeFiringUpdate()) {
}; DeckEditorBase.this.updateDisplay();
}
/** }
* This class is used for a feature: when you start typing card name, the };
* list gets auto-filtered.
*/ /**
protected class OnChangeTextUpdateDisplay implements DocumentListener { * This class is used for a feature: when you start typing card name, the
private void onChange() { * list gets auto-filtered.
if (DeckEditorBase.this.isFiltersChangeFiringUpdate()) { */
DeckEditorBase.this.updateDisplay(); protected class OnChangeTextUpdateDisplay implements DocumentListener {
} private void onChange() {
} if (DeckEditorBase.this.isFiltersChangeFiringUpdate()) {
DeckEditorBase.this.updateDisplay();
/* }
* (non-Javadoc) }
*
* @see /*
* javax.swing.event.DocumentListener#insertUpdate(javax.swing.event * (non-Javadoc)
* .DocumentEvent) *
*/ * @see
@Override * javax.swing.event.DocumentListener#insertUpdate(javax.swing.event
public final void insertUpdate(final DocumentEvent e) { * .DocumentEvent)
this.onChange(); */
} @Override
public final void insertUpdate(final DocumentEvent e) {
/* this.onChange();
* (non-Javadoc) }
*
* @see /*
* javax.swing.event.DocumentListener#removeUpdate(javax.swing.event * (non-Javadoc)
* .DocumentEvent) *
*/ * @see
@Override * javax.swing.event.DocumentListener#removeUpdate(javax.swing.event
public final void removeUpdate(final DocumentEvent e) { * .DocumentEvent)
this.onChange(); */
} @Override
public final void removeUpdate(final DocumentEvent e) {
/* this.onChange();
* (non-Javadoc) }
*
* @see /*
* javax.swing.event.DocumentListener#changedUpdate(javax.swing.event * (non-Javadoc)
* .DocumentEvent) *
*/ * @see
@Override * javax.swing.event.DocumentListener#changedUpdate(javax.swing.event
public void changedUpdate(final DocumentEvent e) { * .DocumentEvent)
} // Happend only on ENTER pressed */
} @Override
public void changedUpdate(final DocumentEvent e) {
/** } // Happend only on ENTER pressed
* Gets the item listener updates display. }
*
* @return the itemListenerUpdatesDisplay /**
*/ * Gets the item listener updates display.
public ItemListener getItemListenerUpdatesDisplay() { *
return this.itemListenerUpdatesDisplay; * @return the itemListenerUpdatesDisplay
} */
public ItemListener getItemListenerUpdatesDisplay() {
/** return this.itemListenerUpdatesDisplay;
* Sets the item listener updates display. }
*
* @param itemListenerUpdatesDisplay /**
* the itemListenerUpdatesDisplay to set * Sets the item listener updates display.
*/ *
public void setItemListenerUpdatesDisplay(final ItemListener itemListenerUpdatesDisplay) { * @param itemListenerUpdatesDisplay
this.itemListenerUpdatesDisplay = itemListenerUpdatesDisplay; // TODO: * the itemListenerUpdatesDisplay to set
// Add 0 */
// to public void setItemListenerUpdatesDisplay(final ItemListener itemListenerUpdatesDisplay) {
// parameter's this.itemListenerUpdatesDisplay = itemListenerUpdatesDisplay; // TODO:
// name. // Add 0
} // to
// parameter's
/** // name.
* Checks if is filters change firing update. }
*
* @return the isFiltersChangeFiringUpdate /**
*/ * Checks if is filters change firing update.
public boolean isFiltersChangeFiringUpdate() { *
return this.isFiltersChangeFiringUpdate; * @return the isFiltersChangeFiringUpdate
} */
public boolean isFiltersChangeFiringUpdate() {
/** return this.isFiltersChangeFiringUpdate;
* Sets the filters change firing update. }
*
* @param isFiltersChangeFiringUpdate /**
* the isFiltersChangeFiringUpdate to set * Sets the filters change firing update.
*/ *
public void setFiltersChangeFiringUpdate(final boolean isFiltersChangeFiringUpdate) { * @param isFiltersChangeFiringUpdate
this.isFiltersChangeFiringUpdate = isFiltersChangeFiringUpdate; // TODO: * the isFiltersChangeFiringUpdate to set
// Add 0 */
// to public void setFiltersChangeFiringUpdate(final boolean isFiltersChangeFiringUpdate) {
// parameter's this.isFiltersChangeFiringUpdate = isFiltersChangeFiringUpdate; // TODO:
// name. // Add 0
} // to
// parameter's
/** // name.
* Gets the card view. }
*
* @return the cardView /**
*/ * Gets the card view.
public CardPanelBase getCardView() { *
return this.cardView; * @return the cardView
} */
public CardPanelBase getCardView() {
/** return this.cardView;
* Sets the card view. }
*
* @param cardView0 /**
* the cardView to set * Sets the card view.
*/ *
protected void setCardView(final CardPanelBase cardView0) { * @param cardView0
this.cardView = cardView0; * the cardView to set
} */
protected void setCardView(final CardPanelBase cardView0) {
/** this.cardView = cardView0;
* Gets the filter boxes. }
*
* @return the filterBoxes /**
*/ * Gets the filter boxes.
public FilterCheckBoxes getFilterBoxes() { *
return this.filterBoxes; * @return the filterBoxes
} */
public FilterCheckBoxes getFilterBoxes() {
/** return this.filterBoxes;
* Sets the filter boxes. }
*
* @param filterBoxes0 /**
* the filterBoxes to set * Sets the filter boxes.
*/ *
public void setFilterBoxes(final FilterCheckBoxes filterBoxes0) { * @param filterBoxes0
this.filterBoxes = filterBoxes0; * the filterBoxes to set
} */
public void setFilterBoxes(final FilterCheckBoxes filterBoxes0) {
/** this.filterBoxes = filterBoxes0;
* Gets the bottom table with cards. }
*
* @return the bottomTableWithCards /**
*/ * Gets the bottom table with cards.
public TableView<T> getBottomTableWithCards() { *
return this.bottomTableWithCards; * @return the bottomTableWithCards
} */
public TableView<T> getBottomTableWithCards() {
/** return this.bottomTableWithCards;
* Sets the bottom table with cards. }
*
* @param bottomTableWithCards0 /**
* the bottomTableWithCards to set * Sets the bottom table with cards.
*/ *
public void setBottomTableWithCards(final TableView<T> bottomTableWithCards0) { * @param bottomTableWithCards0
this.bottomTableWithCards = bottomTableWithCards0; * the bottomTableWithCards to set
} */
public void setBottomTableWithCards(final TableView<T> bottomTableWithCards0) {
/** this.bottomTableWithCards = bottomTableWithCards0;
* Gets the top table with cards. }
*
* @return the topTableWithCards /**
*/ * Gets the top table with cards.
public TableView<T> getTopTableWithCards() { *
return this.topTableWithCards; * @return the topTableWithCards
} */
public TableView<T> getTopTableWithCards() {
/** return this.topTableWithCards;
* Sets the top table with cards. }
*
* @param topTableWithCards0 /**
* the topTableWithCards to set * Sets the top table with cards.
*/ *
public void setTopTableWithCards(final TableView<T> topTableWithCards0) { * @param topTableWithCards0
this.topTableWithCards = topTableWithCards0; * the topTableWithCards to set
} */
public void setTopTableWithCards(final TableView<T> topTableWithCards0) {
} this.topTableWithCards = topTableWithCards0;
}
}

View File

@@ -18,9 +18,7 @@
package forge.gui.deckeditor; package forge.gui.deckeditor;
import java.awt.Container; import java.awt.Container;
import java.awt.Dialog.ModalityType;
import java.awt.Font; import java.awt.Font;
import java.awt.Frame;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.KeyAdapter; import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
@@ -30,12 +28,11 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel; import javax.swing.JLabel;
import net.miginfocom.swing.MigLayout;
import forge.Command; import forge.Command;
import forge.Singletons; import forge.Singletons;
import forge.deck.Deck; import forge.deck.Deck;
@@ -52,6 +49,7 @@ import forge.item.InventoryItem;
import forge.item.ItemPool; import forge.item.ItemPool;
import forge.util.Lambda0; import forge.util.Lambda0;
import forge.util.Predicate; import forge.util.Predicate;
import net.miginfocom.swing.MigLayout;
/** /**
* <p> * <p>
@@ -145,7 +143,6 @@ public final class DeckEditorConstructed extends DeckEditorBase<CardPrinted, Dec
this.filterNameTypeSet.setListeners(new OnChangeTextUpdateDisplay(), this.getItemListenerUpdatesDisplay()); this.filterNameTypeSet.setListeners(new OnChangeTextUpdateDisplay(), this.getItemListenerUpdatesDisplay());
this.setSize(1024, 740); this.setSize(1024, 740);
this.setExtendedState(Frame.MAXIMIZED_BOTH);
} }
@@ -153,7 +150,8 @@ public final class DeckEditorConstructed extends DeckEditorBase<CardPrinted, Dec
* Instantiates a new deck editor common. * Instantiates a new deck editor common.
* *
*/ */
public DeckEditorConstructed() { public DeckEditorConstructed(JFrame parent) {
super(parent);
try { try {
this.setFilterBoxes(new FilterCheckBoxes(true)); this.setFilterBoxes(new FilterCheckBoxes(true));
this.setTopTableWithCards(new TableView<CardPrinted>("Avaliable Cards", true, true, CardPrinted.class)); this.setTopTableWithCards(new TableView<CardPrinted>("Avaliable Cards", true, true, CardPrinted.class));

View File

@@ -1,419 +1,419 @@
/* /*
* Forge: Play Magic: the Gathering. * Forge: Play Magic: the Gathering.
* Copyright (C) 2011 Forge Team * Copyright (C) 2011 Forge Team
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package forge.gui.deckeditor; package forge.gui.deckeditor;
import java.awt.Container; import java.awt.Container;
import java.awt.Font; import java.awt.Font;
import java.awt.Frame; import java.awt.event.ActionEvent;
import java.awt.event.ActionEvent; import java.awt.event.KeyAdapter;
import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent;
import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter;
import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent;
import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter;
import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent;
import java.awt.event.WindowEvent; import java.util.ArrayList;
import java.util.ArrayList; import java.util.List;
import java.util.List; import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JButton; import javax.swing.JFrame;
import javax.swing.JCheckBox; import javax.swing.JLabel;
import javax.swing.JLabel;
import forge.Command;
import net.miginfocom.swing.MigLayout; import forge.deck.Deck;
import forge.Command; import forge.deck.DeckGroup;
import forge.deck.Deck; import forge.error.ErrorViewer;
import forge.deck.DeckGroup; import forge.gui.deckeditor.elements.CardPanelHeavy;
import forge.error.ErrorViewer; import forge.gui.deckeditor.elements.FilterCheckBoxes;
import forge.gui.deckeditor.elements.CardPanelHeavy; import forge.gui.deckeditor.elements.FilterNameTypeSetPanel;
import forge.gui.deckeditor.elements.FilterCheckBoxes; import forge.gui.deckeditor.elements.ManaCostRenderer;
import forge.gui.deckeditor.elements.FilterNameTypeSetPanel; import forge.gui.deckeditor.elements.TableColumnInfo;
import forge.gui.deckeditor.elements.ManaCostRenderer; import forge.gui.deckeditor.elements.TableView;
import forge.gui.deckeditor.elements.TableColumnInfo; import forge.item.CardPrinted;
import forge.gui.deckeditor.elements.TableView; import forge.item.InventoryItem;
import forge.item.CardPrinted; import forge.util.IStorage;
import forge.item.InventoryItem; import forge.util.Lambda0;
import forge.util.IStorage; import forge.util.Predicate;
import forge.util.Lambda0; import net.miginfocom.swing.MigLayout;
import forge.util.Predicate;
/**
/** * <p>
* <p> * Gui_DeckEditor class.
* Gui_DeckEditor class. * </p>
* </p> *
* * @author Forge
* @author Forge * @version $Id: DeckEditorCommon.java 12850 2011-12-26 14:55:09Z slapshot5 $
* @version $Id: DeckEditorCommon.java 12850 2011-12-26 14:55:09Z slapshot5 $ */
*/ public final class DeckEditorLimited extends DeckEditorBase<CardPrinted, DeckGroup> {
public final class DeckEditorLimited extends DeckEditorBase<CardPrinted, DeckGroup> { /** Constant <code>serialVersionUID=130339644136746796L</code>. */
/** Constant <code>serialVersionUID=130339644136746796L</code>. */ private static final long serialVersionUID = 130339644136746796L;
private static final long serialVersionUID = 130339644136746796L;
private final JButton removeButton = new JButton();
private final JButton removeButton = new JButton(); private final JButton addButton = new JButton();
private final JButton addButton = new JButton();
private final JButton analysisButton = new JButton();
private final JButton analysisButton = new JButton(); private final JButton clearFilterButton = new JButton();
private final JButton clearFilterButton = new JButton();
private final JLabel jLabelAnalysisGap = new JLabel("");
private final JLabel jLabelAnalysisGap = new JLabel(""); private FilterNameTypeSetPanel filterNameTypeSet;
private FilterNameTypeSetPanel filterNameTypeSet;
private final DeckController<DeckGroup> controller;
private final DeckController<DeckGroup> controller;
/**
/** * Show.
* Show. *
* * @param exitCommand
* @param exitCommand * the exit command
* the exit command */
*/ @Override
@Override public void show(final Command exitCommand) {
public void show(final Command exitCommand) { final Command exit = new Command() {
final Command exit = new Command() { private static final long serialVersionUID = 5210924838133689758L;
private static final long serialVersionUID = 5210924838133689758L;
@Override
@Override public void execute() {
public void execute() { DeckEditorLimited.this.dispose();
DeckEditorLimited.this.dispose(); if (exitCommand != null) {
if (exitCommand != null) { exitCommand.execute();
exitCommand.execute(); }
} }
} };
};
final MenuLimited menu = new MenuLimited(this.getController(), exit);
final MenuLimited menu = new MenuLimited(this.getController(), exit);
this.setJMenuBar(menu);
this.setJMenuBar(menu);
// do not change this!!!!
// do not change this!!!! this.addWindowListener(new WindowAdapter() {
this.addWindowListener(new WindowAdapter() { @Override
@Override public void windowClosing(final WindowEvent ev) {
public void windowClosing(final WindowEvent ev) { menu.close();
menu.close(); }
} });
});
this.setup();
this.setup();
this.getTopTableWithCards().sort(1, true);
this.getTopTableWithCards().sort(1, true); this.getBottomTableWithCards().sort(1, true);
this.getBottomTableWithCards().sort(1, true);
} // show(Command)
} // show(Command)
private void setup() {
private void setup() { final List<TableColumnInfo<InventoryItem>> columns = new ArrayList<TableColumnInfo<InventoryItem>>();
final List<TableColumnInfo<InventoryItem>> columns = new ArrayList<TableColumnInfo<InventoryItem>>(); columns.add(new TableColumnInfo<InventoryItem>("Qty", 30, PresetColumns.FN_QTY_COMPARE,
columns.add(new TableColumnInfo<InventoryItem>("Qty", 30, PresetColumns.FN_QTY_COMPARE, PresetColumns.FN_QTY_GET));
PresetColumns.FN_QTY_GET)); columns.add(new TableColumnInfo<InventoryItem>("Name", 175, PresetColumns.FN_NAME_COMPARE,
columns.add(new TableColumnInfo<InventoryItem>("Name", 175, PresetColumns.FN_NAME_COMPARE, PresetColumns.FN_NAME_GET));
PresetColumns.FN_NAME_GET)); columns.add(new TableColumnInfo<InventoryItem>("Cost", 75, PresetColumns.FN_COST_COMPARE,
columns.add(new TableColumnInfo<InventoryItem>("Cost", 75, PresetColumns.FN_COST_COMPARE, PresetColumns.FN_COST_GET));
PresetColumns.FN_COST_GET)); columns.add(new TableColumnInfo<InventoryItem>("Color", 60, PresetColumns.FN_COLOR_COMPARE,
columns.add(new TableColumnInfo<InventoryItem>("Color", 60, PresetColumns.FN_COLOR_COMPARE, PresetColumns.FN_COLOR_GET));
PresetColumns.FN_COLOR_GET)); columns.add(new TableColumnInfo<InventoryItem>("Type", 100, PresetColumns.FN_TYPE_COMPARE,
columns.add(new TableColumnInfo<InventoryItem>("Type", 100, PresetColumns.FN_TYPE_COMPARE, PresetColumns.FN_TYPE_GET));
PresetColumns.FN_TYPE_GET)); columns.add(new TableColumnInfo<InventoryItem>("Stats", 60, PresetColumns.FN_STATS_COMPARE,
columns.add(new TableColumnInfo<InventoryItem>("Stats", 60, PresetColumns.FN_STATS_COMPARE, PresetColumns.FN_STATS_GET));
PresetColumns.FN_STATS_GET)); columns.add(new TableColumnInfo<InventoryItem>("R", 25, PresetColumns.FN_RARITY_COMPARE,
columns.add(new TableColumnInfo<InventoryItem>("R", 25, PresetColumns.FN_RARITY_COMPARE, PresetColumns.FN_RARITY_GET));
PresetColumns.FN_RARITY_GET)); columns.add(new TableColumnInfo<InventoryItem>("Set", 40, PresetColumns.FN_SET_COMPARE,
columns.add(new TableColumnInfo<InventoryItem>("Set", 40, PresetColumns.FN_SET_COMPARE, PresetColumns.FN_SET_GET));
PresetColumns.FN_SET_GET)); columns.add(new TableColumnInfo<InventoryItem>("AI", 30, PresetColumns.FN_AI_STATUS_COMPARE,
columns.add(new TableColumnInfo<InventoryItem>("AI", 30, PresetColumns.FN_AI_STATUS_COMPARE, PresetColumns.FN_AI_STATUS_GET));
PresetColumns.FN_AI_STATUS_GET)); columns.get(2).setCellRenderer(new ManaCostRenderer());
columns.get(2).setCellRenderer(new ManaCostRenderer());
this.getTopTableWithCards().setup(columns, this.getCardView());
this.getTopTableWithCards().setup(columns, this.getCardView()); this.getBottomTableWithCards().setup(columns, this.getCardView());
this.getBottomTableWithCards().setup(columns, this.getCardView());
this.filterNameTypeSet.setListeners(new OnChangeTextUpdateDisplay(), this.getItemListenerUpdatesDisplay());
this.filterNameTypeSet.setListeners(new OnChangeTextUpdateDisplay(), this.getItemListenerUpdatesDisplay());
this.setSize(1024, 740);
this.setSize(1024, 740);
this.setExtendedState(Frame.MAXIMIZED_BOTH); }
} /**
* Instantiates a new deck editor common.
/** *
* Instantiates a new deck editor common. * @param mainFrame
* * @param deckMap the deck map
* @param deckMap the deck map */
*/ public DeckEditorLimited(JFrame mainFrame, final IStorage<DeckGroup> deckMap) {
public DeckEditorLimited(final IStorage<DeckGroup> deckMap) { super(mainFrame);
try { try {
this.setFilterBoxes(new FilterCheckBoxes(true)); this.setFilterBoxes(new FilterCheckBoxes(true));
this.setTopTableWithCards(new TableView<CardPrinted>("Avaliable Cards", true, true, CardPrinted.class)); this.setTopTableWithCards(new TableView<CardPrinted>("Avaliable Cards", true, true, CardPrinted.class));
this.setBottomTableWithCards(new TableView<CardPrinted>("Deck", true, CardPrinted.class)); this.setBottomTableWithCards(new TableView<CardPrinted>("Deck", true, CardPrinted.class));
this.setCardView(new CardPanelHeavy()); this.setCardView(new CardPanelHeavy());
this.filterNameTypeSet = new FilterNameTypeSetPanel(); this.filterNameTypeSet = new FilterNameTypeSetPanel();
this.jbInit(); this.jbInit();
} catch (final Exception ex) { } catch (final Exception ex) {
ErrorViewer.showError(ex); ErrorViewer.showError(ex);
} }
final Lambda0<DeckGroup> newCreator = new Lambda0<DeckGroup>() { final Lambda0<DeckGroup> newCreator = new Lambda0<DeckGroup>() {
@Override @Override
public DeckGroup apply() { public DeckGroup apply() {
return new DeckGroup(""); return new DeckGroup("");
} }
}; };
this.controller = new DeckController<DeckGroup>(deckMap, this, newCreator); this.controller = new DeckController<DeckGroup>(deckMap, this, newCreator);
} }
private void jbInit() { private void jbInit() {
final Font fButtons = new java.awt.Font("Dialog", 0, 13); final Font fButtons = new java.awt.Font("Dialog", 0, 13);
this.removeButton.setFont(fButtons); this.removeButton.setFont(fButtons);
this.addButton.setFont(fButtons); this.addButton.setFont(fButtons);
this.clearFilterButton.setFont(fButtons); this.clearFilterButton.setFont(fButtons);
this.analysisButton.setFont(fButtons); this.analysisButton.setFont(fButtons);
this.addButton.setText("Add to Deck"); this.addButton.setText("Add to Deck");
this.removeButton.setText("Remove from Deck"); this.removeButton.setText("Remove from Deck");
this.clearFilterButton.setText("Clear Filter"); this.clearFilterButton.setText("Clear Filter");
this.analysisButton.setText("Deck Analysis"); this.analysisButton.setText("Deck Analysis");
this.removeButton.addActionListener(new java.awt.event.ActionListener() { this.removeButton.addActionListener(new java.awt.event.ActionListener() {
@Override @Override
public void actionPerformed(final ActionEvent e) { public void actionPerformed(final ActionEvent e) {
DeckEditorLimited.this.removeButtonClicked(e); DeckEditorLimited.this.removeButtonClicked(e);
} }
}); });
this.addButton.addActionListener(new java.awt.event.ActionListener() { this.addButton.addActionListener(new java.awt.event.ActionListener() {
@Override @Override
public void actionPerformed(final ActionEvent e) { public void actionPerformed(final ActionEvent e) {
DeckEditorLimited.this.addButtonActionPerformed(e); DeckEditorLimited.this.addButtonActionPerformed(e);
} }
}); });
this.clearFilterButton.addActionListener(new java.awt.event.ActionListener() { this.clearFilterButton.addActionListener(new java.awt.event.ActionListener() {
@Override @Override
public void actionPerformed(final ActionEvent e) { public void actionPerformed(final ActionEvent e) {
DeckEditorLimited.this.clearFilterButtonActionPerformed(e); DeckEditorLimited.this.clearFilterButtonActionPerformed(e);
} }
}); });
this.analysisButton.addActionListener(new java.awt.event.ActionListener() { this.analysisButton.addActionListener(new java.awt.event.ActionListener() {
@Override @Override
public void actionPerformed(final ActionEvent e) { public void actionPerformed(final ActionEvent e) {
DeckEditorLimited.this.analysisButtonActionPerformed(e); DeckEditorLimited.this.analysisButtonActionPerformed(e);
} }
}); });
// Type filtering // Type filtering
final Font f = new Font("Tahoma", Font.PLAIN, 10); final Font f = new Font("Tahoma", Font.PLAIN, 10);
for (final JCheckBox box : this.getFilterBoxes().getAllTypes()) { for (final JCheckBox box : this.getFilterBoxes().getAllTypes()) {
box.setFont(f); box.setFont(f);
box.setOpaque(false); box.setOpaque(false);
} }
// Color filtering // Color filtering
for (final JCheckBox box : this.getFilterBoxes().getAllColors()) { for (final JCheckBox box : this.getFilterBoxes().getAllColors()) {
box.setOpaque(false); box.setOpaque(false);
} }
// Do not lower statsLabel any lower, we want this to be visible at 1024 // Do not lower statsLabel any lower, we want this to be visible at 1024
// x 768 screen size // x 768 screen size
this.setTitle("Deck Editor"); this.setTitle("Deck Editor");
final Container content = this.getContentPane(); final Container content = this.getContentPane();
final MigLayout layout = new MigLayout("fill"); final MigLayout layout = new MigLayout("fill");
content.setLayout(layout); content.setLayout(layout);
boolean isFirst = true; boolean isFirst = true;
for (final JCheckBox box : this.getFilterBoxes().getAllTypes()) { for (final JCheckBox box : this.getFilterBoxes().getAllTypes()) {
String growParameter = "grow"; String growParameter = "grow";
if (isFirst) { if (isFirst) {
growParameter = "cell 0 0, egx checkbox, grow, split 14"; growParameter = "cell 0 0, egx checkbox, grow, split 14";
isFirst = false; isFirst = false;
} }
content.add(box, growParameter); content.add(box, growParameter);
box.addItemListener(this.getItemListenerUpdatesDisplay()); box.addItemListener(this.getItemListenerUpdatesDisplay());
} }
for (final JCheckBox box : this.getFilterBoxes().getAllColors()) { for (final JCheckBox box : this.getFilterBoxes().getAllColors()) {
content.add(box, "grow"); content.add(box, "grow");
box.addItemListener(this.getItemListenerUpdatesDisplay()); box.addItemListener(this.getItemListenerUpdatesDisplay());
} }
content.add(this.clearFilterButton, "wmin 100, hmin 25, wmax 140, hmax 25, grow"); content.add(this.clearFilterButton, "wmin 100, hmin 25, wmax 140, hmax 25, grow");
content.add(this.filterNameTypeSet, "cell 0 1, grow"); content.add(this.filterNameTypeSet, "cell 0 1, grow");
content.add(this.getTopTableWithCards().getTableDecorated(), "cell 0 2 1 2, pushy, grow"); content.add(this.getTopTableWithCards().getTableDecorated(), "cell 0 2 1 2, pushy, grow");
content.add(this.getTopTableWithCards().getLabel(), "cell 0 4"); content.add(this.getTopTableWithCards().getLabel(), "cell 0 4");
content.add(this.addButton, "w 100, h 49, sg button, cell 0 5, split 5"); content.add(this.addButton, "w 100, h 49, sg button, cell 0 5, split 5");
content.add(this.removeButton, "w 100, h 49, sg button"); content.add(this.removeButton, "w 100, h 49, sg button");
// Label is used to push the analysis button to the right to separate // Label is used to push the analysis button to the right to separate
// analysis button from add/remove card ones // analysis button from add/remove card ones
content.add(this.jLabelAnalysisGap, "wmin 75, growx"); content.add(this.jLabelAnalysisGap, "wmin 75, growx");
content.add(this.analysisButton, "w 100, h 49, wrap"); content.add(this.analysisButton, "w 100, h 49, wrap");
content.add(this.getBottomTableWithCards().getTableDecorated(), "cell 0 6, grow"); content.add(this.getBottomTableWithCards().getTableDecorated(), "cell 0 6, grow");
content.add(this.getBottomTableWithCards().getLabel(), "cell 0 7"); content.add(this.getBottomTableWithCards().getLabel(), "cell 0 7");
content.add(this.getCardView(), "cell 1 0 1 8, flowy, grow"); content.add(this.getCardView(), "cell 1 0 1 8, flowy, grow");
this.getTopTableWithCards().getTable().addMouseListener(new MouseAdapter() { this.getTopTableWithCards().getTable().addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(final MouseEvent e) { public void mouseClicked(final MouseEvent e) {
if (e.getClickCount() == 2) { if (e.getClickCount() == 2) {
DeckEditorLimited.this.addCardToDeck(); DeckEditorLimited.this.addCardToDeck();
} }
} }
}); });
this.getTopTableWithCards().getTable().addKeyListener(new KeyAdapter() { this.getTopTableWithCards().getTable().addKeyListener(new KeyAdapter() {
@Override @Override
public void keyPressed(final KeyEvent e) { public void keyPressed(final KeyEvent e) {
if (e.getKeyChar() == ' ') { if (e.getKeyChar() == ' ') {
DeckEditorLimited.this.addCardToDeck(); DeckEditorLimited.this.addCardToDeck();
} }
} }
}); });
// javax.swing.JRootPane rootPane = this.getRootPane(); // javax.swing.JRootPane rootPane = this.getRootPane();
// rootPane.setDefaultButton(filterButton); // rootPane.setDefaultButton(filterButton);
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see forge.gui.deckeditor.DeckEditorBase#buildFilter() * @see forge.gui.deckeditor.DeckEditorBase#buildFilter()
*/ */
@Override @Override
protected Predicate<CardPrinted> buildFilter() { protected Predicate<CardPrinted> buildFilter() {
final Predicate<CardPrinted> cardFilter = Predicate.and(this.getFilterBoxes().buildFilter(), final Predicate<CardPrinted> cardFilter = Predicate.and(this.getFilterBoxes().buildFilter(),
this.filterNameTypeSet.buildFilter()); this.filterNameTypeSet.buildFilter());
return Predicate.instanceOf(cardFilter, CardPrinted.class); return Predicate.instanceOf(cardFilter, CardPrinted.class);
} }
/** /**
* Clear filter button_action performed. * Clear filter button_action performed.
* *
* @param e * @param e
* the e * the e
*/ */
void clearFilterButtonActionPerformed(final ActionEvent e) { void clearFilterButtonActionPerformed(final ActionEvent e) {
// disable automatic update triggered by listeners // disable automatic update triggered by listeners
this.setFiltersChangeFiringUpdate(false); this.setFiltersChangeFiringUpdate(false);
for (final JCheckBox box : this.getFilterBoxes().getAllTypes()) { for (final JCheckBox box : this.getFilterBoxes().getAllTypes()) {
if (!box.isSelected()) { if (!box.isSelected()) {
box.doClick(); box.doClick();
} }
} }
for (final JCheckBox box : this.getFilterBoxes().getAllColors()) { for (final JCheckBox box : this.getFilterBoxes().getAllColors()) {
if (!box.isSelected()) { if (!box.isSelected()) {
box.doClick(); box.doClick();
} }
} }
this.filterNameTypeSet.clearFilters(); this.filterNameTypeSet.clearFilters();
this.setFiltersChangeFiringUpdate(true); this.setFiltersChangeFiringUpdate(true);
this.getTopTableWithCards().setFilter(null); this.getTopTableWithCards().setFilter(null);
} }
/** /**
* Adds the button_action performed. * Adds the button_action performed.
* *
* @param e * @param e
* the e * the e
*/ */
void addButtonActionPerformed(final ActionEvent e) { void addButtonActionPerformed(final ActionEvent e) {
this.addCardToDeck(); this.addCardToDeck();
} }
/** /**
* Adds the card to deck. * Adds the card to deck.
*/ */
void addCardToDeck() { void addCardToDeck() {
final InventoryItem item = this.getTopTableWithCards().getSelectedCard(); final InventoryItem item = this.getTopTableWithCards().getSelectedCard();
if ((item == null) || !(item instanceof CardPrinted)) { if ((item == null) || !(item instanceof CardPrinted)) {
return; return;
} }
// update view // update view
final CardPrinted card = (CardPrinted) item; final CardPrinted card = (CardPrinted) item;
this.getBottomTableWithCards().addCard(card); this.getBottomTableWithCards().addCard(card);
this.getTopTableWithCards().removeCard(card); this.getTopTableWithCards().removeCard(card);
/* /*
* update model Deck model = * update model Deck model =
* getSelectedDeck(getController().getModel()); * getSelectedDeck(getController().getModel());
* model.getMain().add(card); model.getSideboard().remove(card); * model.getMain().add(card); model.getSideboard().remove(card);
*/ */
this.getController().notifyModelChanged(); this.getController().notifyModelChanged();
} }
/** /**
* TODO: Write javadoc for this method. * TODO: Write javadoc for this method.
* *
* @param model * @param model
* @return * @return
*/ */
private Deck getSelectedDeck(final DeckGroup model) { private Deck getSelectedDeck(final DeckGroup model) {
return model.getHumanDeck(); return model.getHumanDeck();
} }
/** /**
* Removes the button clicked. * Removes the button clicked.
* *
* @param e * @param e
* the e * the e
*/ */
void removeButtonClicked(final ActionEvent e) { void removeButtonClicked(final ActionEvent e) {
final InventoryItem item = this.getBottomTableWithCards().getSelectedCard(); final InventoryItem item = this.getBottomTableWithCards().getSelectedCard();
if ((item == null) || !(item instanceof CardPrinted)) { if ((item == null) || !(item instanceof CardPrinted)) {
return; return;
} }
// update view // update view
final CardPrinted card = (CardPrinted) item; final CardPrinted card = (CardPrinted) item;
this.getBottomTableWithCards().removeCard(card); this.getBottomTableWithCards().removeCard(card);
this.getTopTableWithCards().addCard(card); this.getTopTableWithCards().addCard(card);
/* /*
* update model Deck model = * update model Deck model =
* getSelectedDeck(getController().getModel()); * getSelectedDeck(getController().getModel());
* model.getMain().remove(card); model.getSideboard().add(card); * model.getMain().remove(card); model.getSideboard().add(card);
*/ */
this.getController().notifyModelChanged(); this.getController().notifyModelChanged();
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see forge.gui.deckeditor.DeckEditorBase#getController() * @see forge.gui.deckeditor.DeckEditorBase#getController()
*/ */
@Override @Override
public DeckController<DeckGroup> getController() { public DeckController<DeckGroup> getController() {
return this.controller; return this.controller;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see forge.gui.deckeditor.DeckEditorBase#updateView() * @see forge.gui.deckeditor.DeckEditorBase#updateView()
*/ */
@Override @Override
public void updateView() { public void updateView() {
Deck toEdit = this.getSelectedDeck(this.controller.getModel()); Deck toEdit = this.getSelectedDeck(this.controller.getModel());
this.getTopTableWithCards().setDeck(toEdit.getSideboard()); this.getTopTableWithCards().setDeck(toEdit.getSideboard());
this.getBottomTableWithCards().setDeck(toEdit.getMain()); this.getBottomTableWithCards().setDeck(toEdit.getMain());
} }
} }

View File

@@ -18,6 +18,7 @@
package forge.gui.deckeditor; package forge.gui.deckeditor;
// import java.awt.Font; // import java.awt.Font;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@@ -27,9 +28,9 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
import javax.swing.JFrame;
import forge.Command; import forge.Command;
import forge.Constant; import forge.Constant;
@@ -176,11 +177,12 @@ public final class DeckEditorQuest extends DeckEditorBase<CardPrinted, Deck> {
/** /**
* Instantiates a new deck editor quest. * Instantiates a new deck editor quest.
* *
* @param parent
* @param questData2 * @param questData2
* the quest data2 * the quest data2
*/ */
public DeckEditorQuest(final QuestController questData2) { public DeckEditorQuest(JFrame parent, final QuestController questData2) {
super(parent);
this.questData = questData2; this.questData = questData2;
try { try {
this.setFilterBoxes(new FilterCheckBoxes(false)); this.setFilterBoxes(new FilterCheckBoxes(false));

View File

@@ -30,8 +30,8 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JTable; import javax.swing.JTable;
import javax.swing.WindowConstants; import javax.swing.WindowConstants;
@@ -187,8 +187,8 @@ public class DraftingProcess extends DeckEditorBase<CardPrinted, DeckGroup> {
/** /**
* Instantiates a new deck editor draft. * Instantiates a new deck editor draft.
*/ */
public DraftingProcess() { public DraftingProcess(JFrame parent) {
super(parent);
try { try {
this.setTopTableWithCards(new TableView<CardPrinted>("Choose one card", false, CardPrinted.class)); this.setTopTableWithCards(new TableView<CardPrinted>("Choose one card", false, CardPrinted.class));
this.setBottomTableWithCards(new TableView<CardPrinted>("Previously picked cards", true, CardPrinted.class)); this.setBottomTableWithCards(new TableView<CardPrinted>("Previously picked cards", true, CardPrinted.class));

View File

@@ -28,8 +28,8 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
@@ -211,7 +211,8 @@ public final class QuestCardShop extends DeckEditorBase<InventoryItem, DeckBase>
* @param qd * @param qd
* a {@link forge.quest.data.QuestData} object. * a {@link forge.quest.data.QuestData} object.
*/ */
public QuestCardShop(final QuestController qd) { public QuestCardShop(JFrame parent, final QuestController qd) {
super(parent);
this.questData = qd; this.questData = qd;
try { try {
this.setFilterBoxes(null); this.setFilterBoxes(null);

View File

@@ -28,11 +28,10 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.DefaultComboBoxModel; import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JFrame; import javax.swing.JDialog;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JPanel; import javax.swing.JPanel;
@@ -45,12 +44,12 @@ import javax.swing.border.BevelBorder;
import javax.swing.event.MouseInputAdapter; import javax.swing.event.MouseInputAdapter;
import javax.swing.table.DefaultTableModel; import javax.swing.table.DefaultTableModel;
import net.miginfocom.swing.MigLayout;
import forge.card.CardRules; import forge.card.CardRules;
import forge.card.CardType; import forge.card.CardType;
import forge.item.CardPrinted; import forge.item.CardPrinted;
import forge.item.ItemPoolView; import forge.item.ItemPoolView;
import forge.util.MyRandom; import forge.util.MyRandom;
import net.miginfocom.swing.MigLayout;
/** /**
* This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
@@ -111,7 +110,7 @@ public class DeckAnalysis extends javax.swing.JDialog {
private JSeparator jSeparator1; private JSeparator jSeparator1;
private JLabel jLabel2; private JLabel jLabel2;
private JButton jButtonOk; private JButton jButtonOk;
private final JFrame jF; private final JDialog parentDialog;
/** The deck. */ /** The deck. */
private final ItemPoolView<CardPrinted> deck; private final ItemPoolView<CardPrinted> deck;
@@ -126,11 +125,11 @@ public class DeckAnalysis extends javax.swing.JDialog {
* @param deckView * @param deckView
* the deck view * the deck view
*/ */
public DeckAnalysis(final JFrame g, final ItemPoolView<CardPrinted> deckView) { public DeckAnalysis(final JDialog g, final ItemPoolView<CardPrinted> deckView) {
super(g); super(g);
this.deck = deckView; this.deck = deckView;
this.jF = g; this.parentDialog = g;
this.initGUI(); this.initGUI();
} }
@@ -160,7 +159,7 @@ public class DeckAnalysis extends javax.swing.JDialog {
this.addWindowListener(new WindowAdapter() { this.addWindowListener(new WindowAdapter() {
@Override @Override
public void windowClosing(final WindowEvent arg0) { public void windowClosing(final WindowEvent arg0) {
DeckAnalysis.this.jF.setEnabled(true); DeckAnalysis.this.parentDialog.setEnabled(true);
} }
@Override @Override
@@ -475,7 +474,7 @@ public class DeckAnalysis extends javax.swing.JDialog {
this.jButtonOk.addMouseListener(new MouseInputAdapter() { this.jButtonOk.addMouseListener(new MouseInputAdapter() {
@Override @Override
public void mouseClicked(final MouseEvent e) { public void mouseClicked(final MouseEvent e) {
DeckAnalysis.this.jF.setEnabled(true); DeckAnalysis.this.parentDialog.setEnabled(true);
DeckAnalysis.this.dispose(); DeckAnalysis.this.dispose();
} }
}); });

View File

@@ -74,7 +74,8 @@ public enum CSubmenuQuestDecks implements ICSubmenu {
VSubmenuQuestDecks.SINGLETON_INSTANCE.getBtnNewDeck().setCommand(new Command() { VSubmenuQuestDecks.SINGLETON_INSTANCE.getBtnNewDeck().setCommand(new Command() {
@Override @Override
public void execute() { public void execute() {
final DeckEditorQuest editor = new DeckEditorQuest(AllZone.getQuest()); final DeckEditorQuest editor =
new DeckEditorQuest(Singletons.getView().getFrame(), AllZone.getQuest());
editor.show(cmdDeckExit); editor.show(cmdDeckExit);
OverlayUtils.showOverlay(); OverlayUtils.showOverlay();
editor.setVisible(true); editor.setVisible(true);

View File

@@ -1,5 +1,11 @@
package forge.gui.home.quest; package forge.gui.home.quest;
import java.io.File;
import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import forge.AllZone; import forge.AllZone;
import forge.Command; import forge.Command;
import forge.Constant; import forge.Constant;
@@ -16,9 +22,9 @@ import forge.gui.toolbox.FSkin;
import forge.gui.toolbox.FTextArea; import forge.gui.toolbox.FTextArea;
import forge.properties.ForgeProps; import forge.properties.ForgeProps;
import forge.properties.NewConstants; import forge.properties.NewConstants;
import forge.quest.QuestEventChallenge;
import forge.quest.QuestController; import forge.quest.QuestController;
import forge.quest.QuestEvent; import forge.quest.QuestEvent;
import forge.quest.QuestEventChallenge;
import forge.quest.QuestMode; import forge.quest.QuestMode;
import forge.quest.QuestUtil; import forge.quest.QuestUtil;
import forge.quest.bazaar.QuestItemType; import forge.quest.bazaar.QuestItemType;
@@ -29,13 +35,6 @@ import forge.quest.data.QuestPreferences.QPref;
import net.miginfocom.swing.MigLayout; import net.miginfocom.swing.MigLayout;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
/** /**
* Utilities for the quest submenu, all over the MVC spectrum. * Utilities for the quest submenu, all over the MVC spectrum.
* If a piece of code can be reused, it's dumped here. * If a piece of code can be reused, it's dumped here.
@@ -186,7 +185,7 @@ public class SubmenuQuestUtil {
} }
}; };
final QuestCardShop g = new QuestCardShop(AllZone.getQuest()); final QuestCardShop g = new QuestCardShop(Singletons.getView().getFrame(), AllZone.getQuest());
g.show(exit); g.show(exit);
g.setVisible(true); g.setVisible(true);
} }

View File

@@ -1,263 +1,262 @@
package forge.gui.home.sanctioned; package forge.gui.home.sanctioned;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import javax.swing.JOptionPane;
import javax.swing.JOptionPane; import javax.swing.SwingUtilities;
import javax.swing.SwingUtilities; import javax.swing.SwingWorker;
import javax.swing.SwingWorker;
import forge.Command;
import forge.Command; import forge.Constant;
import forge.Constant; import forge.Singletons;
import forge.Singletons; import forge.deck.Deck;
import forge.deck.Deck; import forge.deck.DeckGroup;
import forge.deck.DeckGroup; import forge.game.GameNew;
import forge.game.GameNew; import forge.game.GameType;
import forge.game.GameType; import forge.game.limited.BoosterDraft;
import forge.game.limited.BoosterDraft; import forge.game.limited.CardPoolLimitation;
import forge.game.limited.CardPoolLimitation; import forge.gui.GuiUtils;
import forge.gui.GuiUtils; import forge.gui.OverlayUtils;
import forge.gui.OverlayUtils; import forge.gui.deckeditor.DraftingProcess;
import forge.gui.deckeditor.DraftingProcess; import forge.gui.home.ICSubmenu;
import forge.gui.home.ICSubmenu; import forge.gui.toolbox.FSkin;
import forge.gui.toolbox.FSkin;
/**
/** * TODO: Write javadoc for this type.
* TODO: Write javadoc for this type. *
* */
*/ @SuppressWarnings("serial")
@SuppressWarnings("serial") public enum CSubmenuDraft implements ICSubmenu {
public enum CSubmenuDraft implements ICSubmenu { /** */
/** */ SINGLETON_INSTANCE;
SINGLETON_INSTANCE;
private final String[] opponentNames = new String[] {
private final String[] opponentNames = new String[] { "Abigail", "Ada", "Adeline", "Adriana", "Agatha", "Agnes", "Aileen", "Alba", "Alcyon",
"Abigail", "Ada", "Adeline", "Adriana", "Agatha", "Agnes", "Aileen", "Alba", "Alcyon", "Alethea", "Alice", "Alicia", "Alison", "Amanda", "Amelia", "Amy", "Andrea", "Angelina",
"Alethea", "Alice", "Alicia", "Alison", "Amanda", "Amelia", "Amy", "Andrea", "Angelina", "Anita", "Ann", "Annabel", "Anne", "Audrey", "Barbara", "Belinda", "Bernice", "Bertha",
"Anita", "Ann", "Annabel", "Anne", "Audrey", "Barbara", "Belinda", "Bernice", "Bertha", "Bonnie", "Brenda", "Bridget", "Bunny", "Carmen", "Carol", "Catherine", "Cheryl",
"Bonnie", "Brenda", "Bridget", "Bunny", "Carmen", "Carol", "Catherine", "Cheryl", "Christine", "Cinderalla", "Claire", "Clarice", "Claudia", "Constance", "Cora",
"Christine", "Cinderalla", "Claire", "Clarice", "Claudia", "Constance", "Cora", "Corinne", "Cnythia", "Daisy", "Daphne", "Dawn", "Deborah", "Diana", "Dolly", "Dora",
"Corinne", "Cnythia", "Daisy", "Daphne", "Dawn", "Deborah", "Diana", "Dolly", "Dora", "Doreen", "Doris", "Dorothy", "Eileen", "Elaine", "Elizabeth", "Emily", "Emma", "Ethel",
"Doreen", "Doris", "Dorothy", "Eileen", "Elaine", "Elizabeth", "Emily", "Emma", "Ethel", "Evelyn", "Fiona", "Florence", "Frances", "Geraldine", "Gertrude", "Gladys", "Gloria",
"Evelyn", "Fiona", "Florence", "Frances", "Geraldine", "Gertrude", "Gladys", "Gloria", "Grace", "Greta", "Harriet", "Hazel", "Helen", "Hilda", "Ida", "Ingrid", "Irene",
"Grace", "Greta", "Harriet", "Hazel", "Helen", "Hilda", "Ida", "Ingrid", "Irene", "Isabel", "Jacinta", "Jackie", "Jane", "Janet", "Janice", "Jennifer", "Jessie", "Joan",
"Isabel", "Jacinta", "Jackie", "Jane", "Janet", "Janice", "Jennifer", "Jessie", "Joan", "Jocelyn", "Josephine", "Joyce", "Judith", "Julia", "Juliana", "Karina", "Kathleen",
"Jocelyn", "Josephine", "Joyce", "Judith", "Julia", "Juliana", "Karina", "Kathleen", "Laura", "Lilian", "Lily", "Linda", "Lisa", "Lilita", "Lora", "Lorna", "Lucy", "Lydia",
"Laura", "Lilian", "Lily", "Linda", "Lisa", "Lilita", "Lora", "Lorna", "Lucy", "Lydia", "Mabel", "Madeline", "Maggie", "Maria", "Mariam", "Marilyn", "Mary", "Matilda", "Mavis",
"Mabel", "Madeline", "Maggie", "Maria", "Mariam", "Marilyn", "Mary", "Matilda", "Mavis", "Melanie", "Melinda", "Melody", "Michelle", "Mildred", "Molly", "Mona", "Monica",
"Melanie", "Melinda", "Melody", "Michelle", "Mildred", "Molly", "Mona", "Monica", "Nancy", "Nora", "Norma", "Olga", "Pamela", "Patricia", "Paula", "Pauline", "Pearl",
"Nancy", "Nora", "Norma", "Olga", "Pamela", "Patricia", "Paula", "Pauline", "Pearl", "Peggy", "Penny", "Phoebe", "Phyllis", "Polly", "Priscilla", "Rachel", "Rebecca",
"Peggy", "Penny", "Phoebe", "Phyllis", "Polly", "Priscilla", "Rachel", "Rebecca", "Rita", "Rosa", "Rosalind", "Rose", "Rosemary", "Rowena", "Ruby", "Sally", "Samantha",
"Rita", "Rosa", "Rosalind", "Rose", "Rosemary", "Rowena", "Ruby", "Sally", "Samantha", "Sarah", "Selina", "Sharon", "Sheila", "Shirley", "Sonya", "Stella", "Sue", "Susan",
"Sarah", "Selina", "Sharon", "Sheila", "Shirley", "Sonya", "Stella", "Sue", "Susan", "Sylvia", "Tina", "Tracy", "Ursula", "Valentine", "Valerie", "Vanessa", "Veronica",
"Sylvia", "Tina", "Tracy", "Ursula", "Valentine", "Valerie", "Vanessa", "Veronica", "Victoria", "Violet", "Vivian", "Wendy", "Winnie", "Yvonne", "Aaron", "Abraham", "Adam",
"Victoria", "Violet", "Vivian", "Wendy", "Winnie", "Yvonne", "Aaron", "Abraham", "Adam", "Adrain", "Alain", "Alan", "Alban", "Albert", "Alec", "Alexander", "Alfonso", "Alfred",
"Adrain", "Alain", "Alan", "Alban", "Albert", "Alec", "Alexander", "Alfonso", "Alfred", "Allan", "Allen", "Alonso", "Aloysius", "Alphonso", "Alvin", "Andrew", "Andy", "Amadeus",
"Allan", "Allen", "Alonso", "Aloysius", "Alphonso", "Alvin", "Andrew", "Andy", "Amadeus", "Amselm", "Anthony", "Arnold", "Augusta", "Austin", "Barnaby", "Benedict", "Benjamin",
"Amselm", "Anthony", "Arnold", "Augusta", "Austin", "Barnaby", "Benedict", "Benjamin", "Bertie", "Bertram", "Bill", "Bob", "Boris", "Brady", "Brian", "Bruce", "Burt", "Byron",
"Bertie", "Bertram", "Bill", "Bob", "Boris", "Brady", "Brian", "Bruce", "Burt", "Byron", "Calvin", "Carl", "Carter", "Casey", "Cecil", "Charles", "Christian", "Christopher",
"Calvin", "Carl", "Carter", "Casey", "Cecil", "Charles", "Christian", "Christopher", "Clarence", "Clement", "Colin", "Conan", "Dalton", "Damian", "Daniel", "David", "Denis",
"Clarence", "Clement", "Colin", "Conan", "Dalton", "Damian", "Daniel", "David", "Denis", "Derek", "Desmond", "Dick", "Dominic", "Donald", "Douglas", "Duncan", "Edmund",
"Derek", "Desmond", "Dick", "Dominic", "Donald", "Douglas", "Duncan", "Edmund", "Edward", "Ellen", "Elton", "Elvis", "Eric", "Eugene", "Felix", "Francis", "Frank",
"Edward", "Ellen", "Elton", "Elvis", "Eric", "Eugene", "Felix", "Francis", "Frank", "Frederick", "Gary", "Geoffrey", "George", "Gerald", "Gerry", "Gordon", "Hamish",
"Frederick", "Gary", "Geoffrey", "George", "Gerald", "Gerry", "Gordon", "Hamish", "Hardy", "Harold", "Harry", "Henry", "Herbert", "Ignatius", "Jack", "James", "Jeffrey",
"Hardy", "Harold", "Harry", "Henry", "Herbert", "Ignatius", "Jack", "James", "Jeffrey", "Jim", "Joe", "John", "Joseph", "Karl", "Keith", "Kenneth", "Kevin", "Larry", "Lawrence",
"Jim", "Joe", "John", "Joseph", "Karl", "Keith", "Kenneth", "Kevin", "Larry", "Lawrence", "Leonard", "Lionel", "Louis", "Lucas", "Malcolm", "Mark", "Martin", "Mathew", "Maurice",
"Leonard", "Lionel", "Louis", "Lucas", "Malcolm", "Mark", "Martin", "Mathew", "Maurice", "Max", "Melvin", "Michael", "Milton", "Morgan", "Morris", "Murphy", "Neville",
"Max", "Melvin", "Michael", "Milton", "Morgan", "Morris", "Murphy", "Neville", "Nicholas", "Noel", "Norman", "Oliver", "Oscar", "Patrick", "Paul", "Perkin", "Peter",
"Nicholas", "Noel", "Norman", "Oliver", "Oscar", "Patrick", "Paul", "Perkin", "Peter", "Philip", "Ralph", "Randy", "Raymond", "Richard", "Ricky", "Robert", "Robin", "Rodney",
"Philip", "Ralph", "Randy", "Raymond", "Richard", "Ricky", "Robert", "Robin", "Rodney", "Roger", "Roland", "Ronald", "Roy", "Sam", "Sebastian", "Simon", "Stanley", "Stephen",
"Roger", "Roland", "Ronald", "Roy", "Sam", "Sebastian", "Simon", "Stanley", "Stephen", "Stuart", "Terence", "Thomas", "Tim", "Tom", "Tony", "Victor", "Vincent", "Wallace",
"Stuart", "Terence", "Thomas", "Tim", "Tom", "Tony", "Victor", "Vincent", "Wallace", "Walter", "Wilfred", "William", "Winston"
"Walter", "Wilfred", "William", "Winston" };
};
private final Command cmdDeckExit = new Command() {
private final Command cmdDeckExit = new Command() { @Override
@Override public void execute() {
public void execute() { update();
update(); OverlayUtils.hideOverlay();
OverlayUtils.hideOverlay(); }
} };
};
private final Command cmdDeckSelect = new Command() {
private final Command cmdDeckSelect = new Command() { @Override
@Override public void execute() {
public void execute() { VSubmenuDraft.SINGLETON_INSTANCE.getBtnStart().setEnabled(true);
VSubmenuDraft.SINGLETON_INSTANCE.getBtnStart().setEnabled(true); }
} };
};
/* (non-Javadoc)
/* (non-Javadoc) * @see forge.control.home.IControlSubmenu#update()
* @see forge.control.home.IControlSubmenu#update() */
*/ @Override
@Override public void initialize() {
public void initialize() { final VSubmenuDraft view = VSubmenuDraft.SINGLETON_INSTANCE;
final VSubmenuDraft view = VSubmenuDraft.SINGLETON_INSTANCE;
view.populate();
view.populate(); CSubmenuDraft.SINGLETON_INSTANCE.update();
CSubmenuDraft.SINGLETON_INSTANCE.update();
view.getLstHumanDecks().setExitCommand(cmdDeckExit);
view.getLstHumanDecks().setExitCommand(cmdDeckExit); view.getLstHumanDecks().setSelectCommand(cmdDeckSelect);
view.getLstHumanDecks().setSelectCommand(cmdDeckSelect);
view.getBtnBuildDeck().addMouseListener(
view.getBtnBuildDeck().addMouseListener( new MouseAdapter() { @Override
new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { setupDraft(); } });
public void mousePressed(MouseEvent e) { setupDraft(); } });
view.getBtnStart().addMouseListener(
view.getBtnStart().addMouseListener( new MouseAdapter() {
new MouseAdapter() { @Override
@Override public void mouseReleased(final MouseEvent e) {
public void mouseReleased(final MouseEvent e) { SwingUtilities.invokeLater(new Runnable() {
SwingUtilities.invokeLater(new Runnable() { @Override
@Override public void run() {
public void run() { startGame();
startGame(); }
} });
}); }
} });
});
view.getBtnDirections().addMouseListener(new MouseAdapter() {
view.getBtnDirections().addMouseListener(new MouseAdapter() { @Override
@Override public void mouseClicked(MouseEvent e) {
public void mouseClicked(MouseEvent e) { view.showDirections();
view.showDirections(); }
} @Override
@Override public void mouseEntered(MouseEvent e) {
public void mouseEntered(MouseEvent e) { view.getBtnDirections().setForeground(FSkin.getColor(FSkin.Colors.CLR_HOVER));
view.getBtnDirections().setForeground(FSkin.getColor(FSkin.Colors.CLR_HOVER)); }
} @Override
@Override public void mouseExited(MouseEvent e) {
public void mouseExited(MouseEvent e) { view.getBtnDirections().setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
view.getBtnDirections().setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT)); }
} });
}); }
}
/* (non-Javadoc)
/* (non-Javadoc) * @see forge.control.home.IControlSubmenu#getCommand()
* @see forge.control.home.IControlSubmenu#getCommand() */
*/ @Override
@Override public Command getMenuCommand() {
public Command getMenuCommand() { return null;
return null; }
}
/* (non-Javadoc)
/* (non-Javadoc) * @see forge.control.home.IControlSubmenu#update()
* @see forge.control.home.IControlSubmenu#update() */
*/ @Override
@Override public void update() {
public void update() { VSubmenuDraft.SINGLETON_INSTANCE.getLstAIDecks().setListData(generateNames());
VSubmenuDraft.SINGLETON_INSTANCE.getLstAIDecks().setListData(generateNames()); VSubmenuDraft.SINGLETON_INSTANCE.getLstAIDecks().setSelectedIndex(
VSubmenuDraft.SINGLETON_INSTANCE.getLstAIDecks().setSelectedIndex( (int) Math.floor(Math.random() * VSubmenuDraft.SINGLETON_INSTANCE.getLstAIDecks().getModel().getSize()));
(int) Math.floor(Math.random() * VSubmenuDraft.SINGLETON_INSTANCE.getLstAIDecks().getModel().getSize()));
List<Deck> human = new ArrayList<Deck>();
List<Deck> human = new ArrayList<Deck>(); for (DeckGroup d : Singletons.getModel().getDecks().getDraft()) {
for (DeckGroup d : Singletons.getModel().getDecks().getDraft()) { human.add(d.getHumanDeck());
human.add(d.getHumanDeck()); }
}
VSubmenuDraft.SINGLETON_INSTANCE.getLstHumanDecks().setDecks(human);
VSubmenuDraft.SINGLETON_INSTANCE.getLstHumanDecks().setDecks(human);
if (human.size() > 1) {
if (human.size() > 1) { VSubmenuDraft.SINGLETON_INSTANCE.getBtnStart().setEnabled(true);
VSubmenuDraft.SINGLETON_INSTANCE.getBtnStart().setEnabled(true); }
} }
}
private void startGame() {
private void startGame() { final Deck human = VSubmenuDraft.SINGLETON_INSTANCE.getLstHumanDecks().getSelectedDeck();
final Deck human = VSubmenuDraft.SINGLETON_INSTANCE.getLstHumanDecks().getSelectedDeck(); final int aiIndex = VSubmenuDraft.SINGLETON_INSTANCE.getLstAIDecks().getSelectedIndex();
final int aiIndex = VSubmenuDraft.SINGLETON_INSTANCE.getLstAIDecks().getSelectedIndex();
if (human == null) {
if (human == null) { JOptionPane.showMessageDialog(null,
JOptionPane.showMessageDialog(null, "No deck selected for human!\r\n(You may need to build a new deck.)",
"No deck selected for human!\r\n(You may need to build a new deck.)", "No deck", JOptionPane.ERROR_MESSAGE);
"No deck", JOptionPane.ERROR_MESSAGE); return;
return; }
} else if (human.getMain().countAll() < 40) {
else if (human.getMain().countAll() < 40) { JOptionPane.showMessageDialog(null,
JOptionPane.showMessageDialog(null, "The selected deck doesn't have enough cards to play (minimum 40)."
"The selected deck doesn't have enough cards to play (minimum 40)." + "\r\nUse the deck editor to choose the cards you want before starting.",
+ "\r\nUse the deck editor to choose the cards you want before starting.", "No deck", JOptionPane.ERROR_MESSAGE);
"No deck", JOptionPane.ERROR_MESSAGE); return;
return; }
}
SwingUtilities.invokeLater(new Runnable() {
SwingUtilities.invokeLater(new Runnable() { @Override
@Override public void run() {
public void run() { OverlayUtils.startGameOverlay();
OverlayUtils.startGameOverlay(); OverlayUtils.showOverlay();
OverlayUtils.showOverlay(); }
} });
});
final SwingWorker<Object, Void> worker = new SwingWorker<Object, Void>() {
final SwingWorker<Object, Void> worker = new SwingWorker<Object, Void>() { @Override
@Override public Object doInBackground() {
public Object doInBackground() { DeckGroup opponentDecks = Singletons.getModel().getDecks().getDraft().get(human.getName());
DeckGroup opponentDecks = Singletons.getModel().getDecks().getDraft().get(human.getName());
Constant.Runtime.HUMAN_DECK[0] = human;
Constant.Runtime.HUMAN_DECK[0] = human; Constant.Runtime.COMPUTER_DECK[0] = opponentDecks.getAiDecks().get(aiIndex); //zero is human deck, so it must be +1
Constant.Runtime.COMPUTER_DECK[0] = opponentDecks.getAiDecks().get(aiIndex); //zero is human deck, so it must be +1
if (Constant.Runtime.COMPUTER_DECK[0] == null) {
if (Constant.Runtime.COMPUTER_DECK[0] == null) { throw new IllegalStateException("Draft: Computer deck is null!");
throw new IllegalStateException("Draft: Computer deck is null!"); }
}
Constant.Runtime.setGameType(GameType.Draft);
Constant.Runtime.setGameType(GameType.Draft); GameNew.newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0]);
GameNew.newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0]); return null;
return null; }
}
@Override
@Override public void done() {
public void done() { OverlayUtils.hideOverlay();
OverlayUtils.hideOverlay(); }
} };
}; worker.execute();
worker.execute(); }
}
/** */
/** */ private void setupDraft() {
private void setupDraft() { OverlayUtils.showOverlay();
OverlayUtils.showOverlay();
final DraftingProcess draft = new DraftingProcess(Singletons.getView().getFrame());
final DraftingProcess draft = new DraftingProcess();
// Determine what kind of booster draft to run
// Determine what kind of booster draft to run final ArrayList<String> draftTypes = new ArrayList<String>();
final ArrayList<String> draftTypes = new ArrayList<String>(); draftTypes.add("Full Cardpool");
draftTypes.add("Full Cardpool"); draftTypes.add("Block / Set");
draftTypes.add("Block / Set"); draftTypes.add("Custom");
draftTypes.add("Custom");
final String prompt = "Choose Draft Format:";
final String prompt = "Choose Draft Format:"; final Object o = GuiUtils.chooseOne(prompt, draftTypes.toArray());
final Object o = GuiUtils.chooseOne(prompt, draftTypes.toArray());
if (o.toString().equals(draftTypes.get(0))) {
if (o.toString().equals(draftTypes.get(0))) { draft.showGui(new BoosterDraft(CardPoolLimitation.Full));
draft.showGui(new BoosterDraft(CardPoolLimitation.Full)); }
}
else if (o.toString().equals(draftTypes.get(1))) {
else if (o.toString().equals(draftTypes.get(1))) { draft.showGui(new BoosterDraft(CardPoolLimitation.Block));
draft.showGui(new BoosterDraft(CardPoolLimitation.Block)); }
}
else if (o.toString().equals(draftTypes.get(2))) {
else if (o.toString().equals(draftTypes.get(2))) { draft.showGui(new BoosterDraft(CardPoolLimitation.Custom));
draft.showGui(new BoosterDraft(CardPoolLimitation.Custom)); }
} }
}
private String[] generateNames() {
private String[] generateNames() { // Generate random selection of names for display
// Generate random selection of names for display Random generator = new Random();
Random generator = new Random(); int i = opponentNames.length;
int i = opponentNames.length; String[] ai = {
String[] ai = { opponentNames[generator.nextInt(i)],
opponentNames[generator.nextInt(i)], opponentNames[generator.nextInt(i)],
opponentNames[generator.nextInt(i)], opponentNames[generator.nextInt(i)],
opponentNames[generator.nextInt(i)], opponentNames[generator.nextInt(i)],
opponentNames[generator.nextInt(i)], opponentNames[generator.nextInt(i)],
opponentNames[generator.nextInt(i)], opponentNames[generator.nextInt(i)],
opponentNames[generator.nextInt(i)], opponentNames[generator.nextInt(i)]
opponentNames[generator.nextInt(i)] };
};
return ai;
return ai; }
} }
}

View File

@@ -1,237 +1,235 @@
package forge.gui.home.sanctioned; package forge.gui.home.sanctioned;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.swing.JOptionPane;
import javax.swing.JOptionPane; import javax.swing.SwingUtilities;
import javax.swing.SwingUtilities; import javax.swing.SwingWorker;
import javax.swing.SwingWorker;
import forge.Command;
import net.slightlymagic.braids.util.UtilFunctions; import forge.Constant;
import forge.Singletons;
import org.apache.commons.lang3.StringUtils; import forge.deck.Deck;
import forge.deck.DeckBase;
import forge.Command; import forge.deck.DeckGroup;
import forge.Constant; import forge.game.GameNew;
import forge.Singletons; import forge.game.limited.SealedDeck;
import forge.deck.Deck; import forge.gui.GuiUtils;
import forge.deck.DeckBase; import forge.gui.OverlayUtils;
import forge.deck.DeckGroup; import forge.gui.deckeditor.DeckEditorBase;
import forge.game.GameNew; import forge.gui.deckeditor.DeckEditorLimited;
import forge.game.limited.SealedDeck; import forge.gui.home.ICSubmenu;
import forge.gui.GuiUtils; import forge.gui.toolbox.FSkin;
import forge.gui.OverlayUtils; import forge.item.CardPrinted;
import forge.gui.deckeditor.DeckEditorBase; import forge.item.ItemPool;
import forge.gui.deckeditor.DeckEditorLimited; import forge.properties.ForgeProps;
import forge.gui.home.ICSubmenu; import forge.properties.NewConstants;
import forge.gui.toolbox.FSkin; import net.slightlymagic.braids.util.UtilFunctions;
import forge.item.CardPrinted; import org.apache.commons.lang3.StringUtils;
import forge.item.ItemPool;
import forge.properties.ForgeProps; /**
import forge.properties.NewConstants; * TODO: Write javadoc for this type.
*
/** */
* TODO: Write javadoc for this type. @SuppressWarnings("serial")
* public enum CSubmenuSealed implements ICSubmenu {
*/ /** */
@SuppressWarnings("serial") SINGLETON_INSTANCE;
public enum CSubmenuSealed implements ICSubmenu {
/** */ private Map<String, Deck> aiDecks;
SINGLETON_INSTANCE;
private final Command cmdExit = new Command() {
private Map<String, Deck> aiDecks; @Override
public void execute() {
private final Command cmdExit = new Command() { update();
@Override OverlayUtils.hideOverlay();
public void execute() { }
update(); };
OverlayUtils.hideOverlay();
} private final Command cmdDeckSelect = new Command() {
}; @Override
public void execute() {
private final Command cmdDeckSelect = new Command() { VSubmenuSealed.SINGLETON_INSTANCE.getBtnStart().setEnabled(true);
@Override }
public void execute() { };
VSubmenuSealed.SINGLETON_INSTANCE.getBtnStart().setEnabled(true);
} /* (non-Javadoc)
}; * @see forge.control.home.IControlSubmenu#update()
*/
/* (non-Javadoc) @Override
* @see forge.control.home.IControlSubmenu#update() public void initialize() {
*/ final VSubmenuSealed view = VSubmenuSealed.SINGLETON_INSTANCE;
@Override
public void initialize() { view.populate();
final VSubmenuSealed view = VSubmenuSealed.SINGLETON_INSTANCE; CSubmenuSealed.SINGLETON_INSTANCE.update();
view.populate(); VSubmenuSealed.SINGLETON_INSTANCE.getLstDecks().setExitCommand(cmdExit);
CSubmenuSealed.SINGLETON_INSTANCE.update(); VSubmenuSealed.SINGLETON_INSTANCE.getLstDecks().setSelectCommand(cmdDeckSelect);
VSubmenuSealed.SINGLETON_INSTANCE.getLstDecks().setExitCommand(cmdExit); VSubmenuSealed.SINGLETON_INSTANCE.getBtnBuildDeck().addMouseListener(
VSubmenuSealed.SINGLETON_INSTANCE.getLstDecks().setSelectCommand(cmdDeckSelect); new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) { setupSealed(); } });
VSubmenuSealed.SINGLETON_INSTANCE.getBtnBuildDeck().addMouseListener(
new MouseAdapter() { @Override VSubmenuSealed.SINGLETON_INSTANCE.getBtnStart().addMouseListener(
public void mousePressed(final MouseEvent e) { setupSealed(); } }); new MouseAdapter() {
@Override
VSubmenuSealed.SINGLETON_INSTANCE.getBtnStart().addMouseListener( public void mouseReleased(final MouseEvent e) {
new MouseAdapter() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
public void mouseReleased(final MouseEvent e) { public void run() {
SwingUtilities.invokeLater(new Runnable() { startGame();
@Override }
public void run() { });
startGame(); }
} });
});
} VSubmenuSealed.SINGLETON_INSTANCE.getBtnDirections().addMouseListener(new MouseAdapter() {
}); @Override
public void mouseClicked(final MouseEvent e) {
VSubmenuSealed.SINGLETON_INSTANCE.getBtnDirections().addMouseListener(new MouseAdapter() { VSubmenuSealed.SINGLETON_INSTANCE.showDirections();
@Override }
public void mouseClicked(final MouseEvent e) { @Override
VSubmenuSealed.SINGLETON_INSTANCE.showDirections(); public void mouseEntered(final MouseEvent e) {
} VSubmenuSealed.SINGLETON_INSTANCE.getBtnDirections().setForeground(FSkin.getColor(FSkin.Colors.CLR_HOVER));
@Override }
public void mouseEntered(final MouseEvent e) { @Override
VSubmenuSealed.SINGLETON_INSTANCE.getBtnDirections().setForeground(FSkin.getColor(FSkin.Colors.CLR_HOVER)); public void mouseExited(final MouseEvent e) {
} VSubmenuSealed.SINGLETON_INSTANCE.getBtnDirections().setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
@Override }
public void mouseExited(final MouseEvent e) { });
VSubmenuSealed.SINGLETON_INSTANCE.getBtnDirections().setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT)); }
}
}); /* (non-Javadoc)
} * @see forge.control.home.IControlSubmenu#getCommand()
*/
/* (non-Javadoc) @Override
* @see forge.control.home.IControlSubmenu#getCommand() public Command getMenuCommand() {
*/ return null;
@Override }
public Command getMenuCommand() {
return null; /* (non-Javadoc)
} * @see forge.control.home.IControlSubmenu#update()
*/
/* (non-Javadoc) @Override
* @see forge.control.home.IControlSubmenu#update() public void update() {
*/ final List<Deck> humanDecks = new ArrayList<Deck>();
@Override aiDecks = new HashMap<String, Deck>();
public void update() {
final List<Deck> humanDecks = new ArrayList<Deck>(); // Since AI decks are tied directly to the human choice,
aiDecks = new HashMap<String, Deck>(); // they're just mapped in a parallel map and grabbed when the game starts.
for (final DeckGroup d : Singletons.getModel().getDecks().getSealed()) {
// Since AI decks are tied directly to the human choice, aiDecks.put(d.getName(), d.getAiDecks().get(0));
// they're just mapped in a parallel map and grabbed when the game starts. humanDecks.add(d.getHumanDeck());
for (final DeckGroup d : Singletons.getModel().getDecks().getSealed()) { }
aiDecks.put(d.getName(), d.getAiDecks().get(0));
humanDecks.add(d.getHumanDeck()); VSubmenuSealed.SINGLETON_INSTANCE.getLstDecks().setDecks(humanDecks);
} }
VSubmenuSealed.SINGLETON_INSTANCE.getLstDecks().setDecks(humanDecks); private void startGame() {
} final Deck human = VSubmenuSealed.SINGLETON_INSTANCE.getLstDecks().getSelectedDeck();
private void startGame() { if (human == null) {
final Deck human = VSubmenuSealed.SINGLETON_INSTANCE.getLstDecks().getSelectedDeck(); JOptionPane.showMessageDialog(null,
"Please build and/or select a deck for yourself.",
if (human == null) { "No deck", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(null, return;
"Please build and/or select a deck for yourself.", }
"No deck", JOptionPane.ERROR_MESSAGE);
return; SwingUtilities.invokeLater(new Runnable() {
} @Override
public void run() {
SwingUtilities.invokeLater(new Runnable() { OverlayUtils.startGameOverlay();
@Override OverlayUtils.showOverlay();
public void run() { }
OverlayUtils.startGameOverlay(); });
OverlayUtils.showOverlay();
} final SwingWorker<Object, Void> worker = new SwingWorker<Object, Void>() {
}); @Override
public Object doInBackground() {
final SwingWorker<Object, Void> worker = new SwingWorker<Object, Void>() { Constant.Runtime.HUMAN_DECK[0] = human;
@Override Constant.Runtime.COMPUTER_DECK[0] = Singletons.getModel().getDecks().getSealed().get(human.getName()).getAiDecks().get(0);
public Object doInBackground() {
Constant.Runtime.HUMAN_DECK[0] = human; GameNew.newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0]);
Constant.Runtime.COMPUTER_DECK[0] = Singletons.getModel().getDecks().getSealed().get(human.getName()).getAiDecks().get(0); return null;
}
GameNew.newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0]);
return null; @Override
} public void done() {
OverlayUtils.hideOverlay();
@Override }
public void done() { };
OverlayUtils.hideOverlay(); worker.execute();
} }
};
worker.execute(); /** */
} @SuppressWarnings("unchecked")
private <T extends DeckBase> void setupSealed() {
/** */ final ArrayList<String> sealedTypes = new ArrayList<String>();
@SuppressWarnings("unchecked") sealedTypes.add("Full Cardpool");
private <T extends DeckBase> void setupSealed() { sealedTypes.add("Block / Set");
final ArrayList<String> sealedTypes = new ArrayList<String>(); sealedTypes.add("Custom");
sealedTypes.add("Full Cardpool");
sealedTypes.add("Block / Set"); final String prompt = "Choose Sealed Deck Format:";
sealedTypes.add("Custom"); final Object o = GuiUtils.chooseOne(prompt, sealedTypes.toArray());
final String prompt = "Choose Sealed Deck Format:"; SealedDeck sd = null;
final Object o = GuiUtils.chooseOne(prompt, sealedTypes.toArray());
if (o.toString().equals(sealedTypes.get(0))) {
SealedDeck sd = null; sd = new SealedDeck("Full");
}
if (o.toString().equals(sealedTypes.get(0))) {
sd = new SealedDeck("Full"); else if (o.toString().equals(sealedTypes.get(1))) {
} sd = new SealedDeck("Block");
}
else if (o.toString().equals(sealedTypes.get(1))) {
sd = new SealedDeck("Block"); else if (o.toString().equals(sealedTypes.get(2))) {
} sd = new SealedDeck("Custom");
}
else if (o.toString().equals(sealedTypes.get(2))) { else {
sd = new SealedDeck("Custom"); throw new IllegalStateException("choice <<" + UtilFunctions.safeToString(o)
} + ">> does not equal any of the sealedTypes.");
else { }
throw new IllegalStateException("choice <<" + UtilFunctions.safeToString(o)
+ ">> does not equal any of the sealedTypes."); if (sd.getCardpool().isEmpty()) {
} return;
}
if (sd.getCardpool().isEmpty()) {
return; final String sDeckName = JOptionPane.showInputDialog(null,
} ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.SAVE_SEALED_MSG),
ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.SAVE_SEALED_TTL),
final String sDeckName = JOptionPane.showInputDialog(null, JOptionPane.QUESTION_MESSAGE);
ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.SAVE_SEALED_MSG),
ForgeProps.getLocalized(NewConstants.Lang.OldGuiNewGame.NewGameText.SAVE_SEALED_TTL), if (StringUtils.isBlank(sDeckName)) {
JOptionPane.QUESTION_MESSAGE); return;
}
if (StringUtils.isBlank(sDeckName)) {
return; // May check for name uniqueness here
}
final ItemPool<CardPrinted> sDeck = sd.getCardpool();
// May check for name uniqueness here
final Deck deck = new Deck(sDeckName);
final ItemPool<CardPrinted> sDeck = sd.getCardpool(); deck.getSideboard().addAll(sDeck);
final Deck deck = new Deck(sDeckName); for (final String element : Constant.Color.BASIC_LANDS) {
deck.getSideboard().addAll(sDeck); deck.getSideboard().add(element, sd.getLandSetCode()[0], 18);
}
for (final String element : Constant.Color.BASIC_LANDS) {
deck.getSideboard().add(element, sd.getLandSetCode()[0], 18); final DeckGroup sealed = new DeckGroup(sDeckName);
} sealed.setHumanDeck(deck);
sealed.addAiDeck(sd.buildAIDeck(sDeck.toForgeCardList()));
final DeckGroup sealed = new DeckGroup(sDeckName); Singletons.getModel().getDecks().getSealed().add(sealed);
sealed.setHumanDeck(deck);
sealed.addAiDeck(sd.buildAIDeck(sDeck.toForgeCardList())); final DeckEditorBase<?, T> editor = (DeckEditorBase<?, T>) new DeckEditorLimited(
Singletons.getModel().getDecks().getSealed().add(sealed); Singletons.getView().getFrame(),
Singletons.getModel().getDecks().getSealed());
final DeckEditorBase<?, T> editor = (DeckEditorBase<?, T>)
new DeckEditorLimited(Singletons.getModel().getDecks().getSealed()); editor.show(cmdExit);
editor.getController().setModel((T) sealed);
editor.show(cmdExit); editor.setAlwaysOnTop(true);
editor.getController().setModel((T) sealed); editor.setVisible(true);
editor.setAlwaysOnTop(true); }
editor.setVisible(true); }
}
}

View File

@@ -1,52 +1,54 @@
package forge.gui.home.utilities; package forge.gui.home.utilities;
import forge.Command; import forge.Command;
import forge.deck.DeckBase; import forge.Singletons;
import forge.gui.deckeditor.DeckEditorBase; import forge.deck.DeckBase;
import forge.gui.deckeditor.DeckEditorConstructed; import forge.gui.deckeditor.DeckEditorBase;
import forge.gui.home.ICSubmenu; import forge.gui.deckeditor.DeckEditorConstructed;
import forge.gui.home.ICSubmenu;
/**
* TODO: Write javadoc for this type. /**
* * TODO: Write javadoc for this type.
*/ *
public enum CSubmenuDeckEditor implements ICSubmenu { */
/** */ public enum CSubmenuDeckEditor implements ICSubmenu {
SINGLETON_INSTANCE; /** */
SINGLETON_INSTANCE;
/* (non-Javadoc)
* @see forge.control.home.IControlSubmenu#update() /* (non-Javadoc)
*/ * @see forge.control.home.IControlSubmenu#update()
@Override */
public void initialize() { @Override
VSubmenuDeckEditor.SINGLETON_INSTANCE.populate(); public void initialize() {
VSubmenuDeckEditor.SINGLETON_INSTANCE.populate();
}
}
/* (non-Javadoc)
* @see forge.control.home.IControlSubmenu#getCommand() /* (non-Javadoc)
*/ * @see forge.control.home.IControlSubmenu#getCommand()
@SuppressWarnings("serial") */
@Override @SuppressWarnings("serial")
public Command getMenuCommand() { @Override
return new Command() { @Override public Command getMenuCommand() {
public void execute() { showDeckEditor(); } }; return new Command() { @Override
} public void execute() { showDeckEditor(); } };
}
/* (non-Javadoc)
* @see forge.control.home.IControlSubmenu#update() /* (non-Javadoc)
*/ * @see forge.control.home.IControlSubmenu#update()
@Override */
public void update() { } @Override
public void update() { }
/**
* Shows constructed mode editor. /**
* @param <T> extends DeckBase * Shows constructed mode editor.
*/ * @param <T> extends DeckBase
@SuppressWarnings("unchecked") */
private <T extends DeckBase> void showDeckEditor() { @SuppressWarnings("unchecked")
DeckEditorBase<?, T> editor = (DeckEditorBase<?, T>) new DeckEditorConstructed(); private <T extends DeckBase> void showDeckEditor() {
editor.show(null); DeckEditorBase<?, T> editor =
editor.setVisible(true); (DeckEditorBase<?, T>) new DeckEditorConstructed(Singletons.getView().getFrame());
} editor.show(null);
} editor.setVisible(true);
}
}

View File

@@ -1,492 +1,492 @@
/* /*
* Forge: Play Magic: the Gathering. * Forge: Play Magic: the Gathering.
* Copyright (C) 2011 Nate * Copyright (C) 2011 Nate
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package forge.gui.toolbox; package forge.gui.toolbox;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.ImageIcon; import javax.swing.JButton;
import javax.swing.JButton; import javax.swing.JFrame;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import javax.swing.border.MatteBorder; import javax.swing.border.MatteBorder;
import net.miginfocom.swing.MigLayout; import forge.AllZone;
import forge.AllZone; import forge.Command;
import forge.Command; import forge.Constant;
import forge.Constant; import forge.Singletons;
import forge.Singletons; import forge.deck.CardCollections;
import forge.deck.CardCollections; import forge.deck.Deck;
import forge.deck.Deck; import forge.game.GameType;
import forge.game.GameType; import forge.gui.OverlayUtils;
import forge.gui.OverlayUtils; import forge.gui.deckeditor.DeckEditorConstructed;
import forge.gui.deckeditor.DeckEditorConstructed; import forge.gui.deckeditor.DeckEditorLimited;
import forge.gui.deckeditor.DeckEditorLimited; import forge.gui.deckeditor.DeckEditorQuest;
import forge.gui.deckeditor.DeckEditorQuest; import net.miginfocom.swing.MigLayout;
/** /**
* Creates deck list for selected decks for quick deleting, editing, and basic * Creates deck list for selected decks for quick deleting, editing, and basic
* info. * info.
* *
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class DeckLister extends JPanel { public class DeckLister extends JPanel {
private final ImageIcon icoDelete; private final ImageIcon icoDelete;
private final ImageIcon icoDeleteOver; private final ImageIcon icoDeleteOver;
private final ImageIcon icoEdit; private final ImageIcon icoEdit;
private final ImageIcon icoEditOver; private final ImageIcon icoEditOver;
private RowPanel previousSelect; private RowPanel previousSelect;
private RowPanel[] rows; private RowPanel[] rows;
private final GameType gametype; private final GameType gametype;
private Command cmdEditorExit, cmdDelete, cmdRowSelect; private Command cmdEditorExit, cmdDelete, cmdRowSelect;
private final Color clrDefault, clrHover, clrActive, clrBorders; private final Color clrDefault, clrHover, clrActive, clrBorders;
/** /**
* Creates deck list for selected decks for quick deleting, editing, and * Creates deck list for selected decks for quick deleting, editing, and
* basic info. "selectable" and "editable" assumed true. * basic info. "selectable" and "editable" assumed true.
* *
* @param gt0 the gt0 * @param gt0 the gt0
* {@link forge.game.GameType} * {@link forge.game.GameType}
*/ */
public DeckLister(final GameType gt0) { public DeckLister(final GameType gt0) {
this(gt0, null); this(gt0, null);
} }
/** /**
* Creates deck list for selected decks for quick deleting, editing, and * Creates deck list for selected decks for quick deleting, editing, and
* basic info. Set "selectable" and "editable" to show those buttons, or * basic info. Set "selectable" and "editable" to show those buttons, or
* not. * not.
* *
* @param gt0 the gt0 * @param gt0 the gt0
* @param cmd0 the cmd0 * @param cmd0 the cmd0
* {@link forge.game.GameType} * {@link forge.game.GameType}
* {@link forge.Command}, when exiting deck editor * {@link forge.Command}, when exiting deck editor
*/ */
public DeckLister(final GameType gt0, final Command cmd0) { public DeckLister(final GameType gt0, final Command cmd0) {
super(); super();
this.gametype = gt0; this.gametype = gt0;
this.cmdEditorExit = cmd0; this.cmdEditorExit = cmd0;
this.clrDefault = new Color(0, 0, 0, 0); this.clrDefault = new Color(0, 0, 0, 0);
this.clrHover = FSkin.getColor(FSkin.Colors.CLR_HOVER); this.clrHover = FSkin.getColor(FSkin.Colors.CLR_HOVER);
this.clrActive = FSkin.getColor(FSkin.Colors.CLR_ACTIVE); this.clrActive = FSkin.getColor(FSkin.Colors.CLR_ACTIVE);
this.clrBorders = FSkin.getColor(FSkin.Colors.CLR_BORDERS); this.clrBorders = FSkin.getColor(FSkin.Colors.CLR_BORDERS);
this.setOpaque(false); this.setOpaque(false);
this.setLayout(new MigLayout("insets 0, gap 0, wrap")); this.setLayout(new MigLayout("insets 0, gap 0, wrap"));
this.icoDelete = FSkin.getIcon(FSkin.ForgeIcons.ICO_DELETE); this.icoDelete = FSkin.getIcon(FSkin.ForgeIcons.ICO_DELETE);
this.icoDeleteOver = FSkin.getIcon(FSkin.ForgeIcons.ICO_DELETE_OVER); this.icoDeleteOver = FSkin.getIcon(FSkin.ForgeIcons.ICO_DELETE_OVER);
this.icoEdit = FSkin.getIcon(FSkin.ForgeIcons.ICO_EDIT); this.icoEdit = FSkin.getIcon(FSkin.ForgeIcons.ICO_EDIT);
this.icoEditOver = FSkin.getIcon(FSkin.ForgeIcons.ICO_EDIT_OVER); this.icoEditOver = FSkin.getIcon(FSkin.ForgeIcons.ICO_EDIT_OVER);
} }
/** /**
* Sets the decks. * Sets the decks.
* *
* @param decks0 the new decks * @param decks0 the new decks
* {@link forge.deck.Deck}[] * {@link forge.deck.Deck}[]
*/ */
public void setDecks(final Iterable<Deck> decks0) { public void setDecks(final Iterable<Deck> decks0) {
this.removeAll(); this.removeAll();
final List<RowPanel> tempRows = new ArrayList<RowPanel>(); final List<RowPanel> tempRows = new ArrayList<RowPanel>();
// Title row // Title row
// Note: careful with the widths of the rows here; // Note: careful with the widths of the rows here;
// scroll panes will have difficulty dynamically resizing if 100% width // scroll panes will have difficulty dynamically resizing if 100% width
// is set. // is set.
final JPanel rowTitle = new TitlePanel(); final JPanel rowTitle = new TitlePanel();
rowTitle.setBackground(FSkin.getColor(FSkin.Colors.CLR_ZEBRA)); rowTitle.setBackground(FSkin.getColor(FSkin.Colors.CLR_ZEBRA));
rowTitle.setLayout(new MigLayout("insets 0, gap 0")); rowTitle.setLayout(new MigLayout("insets 0, gap 0"));
rowTitle.add(new FLabel.Builder().text("Delete").fontAlign(SwingConstants.CENTER).build(), rowTitle.add(new FLabel.Builder().text("Delete").fontAlign(SwingConstants.CENTER).build(),
"w 10%!, h 20px!, gaptop 5px"); "w 10%!, h 20px!, gaptop 5px");
rowTitle.add(new FLabel.Builder().text("Edit").fontAlign(SwingConstants.CENTER).build(), rowTitle.add(new FLabel.Builder().text("Edit").fontAlign(SwingConstants.CENTER).build(),
"w 10%!, h 20px!, gaptop 5px"); "w 10%!, h 20px!, gaptop 5px");
rowTitle.add(new FLabel.Builder().text("Deck Name").fontAlign(SwingConstants.CENTER).build(), rowTitle.add(new FLabel.Builder().text("Deck Name").fontAlign(SwingConstants.CENTER).build(),
"w 60%!, h 20px!, gaptop 5px"); "w 60%!, h 20px!, gaptop 5px");
rowTitle.add(new FLabel.Builder().text("Main").fontAlign(SwingConstants.CENTER).build(), rowTitle.add(new FLabel.Builder().text("Main").fontAlign(SwingConstants.CENTER).build(),
"w 10%!, h 20px!, gaptop 5px"); "w 10%!, h 20px!, gaptop 5px");
rowTitle.add(new FLabel.Builder().text("Side").fontAlign(SwingConstants.CENTER).build(), rowTitle.add(new FLabel.Builder().text("Side").fontAlign(SwingConstants.CENTER).build(),
"w 10%!, h 20px!, gaptop 5px"); "w 10%!, h 20px!, gaptop 5px");
this.add(rowTitle, "w 98%!, h 30px!, gapleft 1%"); this.add(rowTitle, "w 98%!, h 30px!, gapleft 1%");
RowPanel row; RowPanel row;
for (final Deck d : decks0) { for (final Deck d : decks0) {
if (d.getName() == null) { if (d.getName() == null) {
continue; continue;
} }
row = new RowPanel(d); row = new RowPanel(d);
row.add(new DeleteButton(row), "w 10%!, h 20px!, gaptop 5px"); row.add(new DeleteButton(row), "w 10%!, h 20px!, gaptop 5px");
row.add(new EditButton(row), "w 10%!, h 20px!, gaptop 5px"); row.add(new EditButton(row), "w 10%!, h 20px!, gaptop 5px");
row.add(new GenericLabel(d.getName()), "w 60%!, h 20px!, gaptop 5px"); row.add(new GenericLabel(d.getName()), "w 60%!, h 20px!, gaptop 5px");
row.add(new MainLabel(String.valueOf(d.getMain().countAll())), "w 10%, h 20px!, gaptop 5px"); row.add(new MainLabel(String.valueOf(d.getMain().countAll())), "w 10%, h 20px!, gaptop 5px");
row.add(new GenericLabel(String.valueOf(d.getSideboard().countAll())), "w 10%!, h 20px!, gaptop 5px"); row.add(new GenericLabel(String.valueOf(d.getSideboard().countAll())), "w 10%!, h 20px!, gaptop 5px");
this.add(row, "w 98%!, h 30px!, gapleft 1%"); this.add(row, "w 98%!, h 30px!, gapleft 1%");
tempRows.add(row); tempRows.add(row);
} }
this.rows = tempRows.toArray(new RowPanel[0]); this.rows = tempRows.toArray(new RowPanel[0]);
this.revalidate(); this.revalidate();
} }
/** /**
* Gets the selected deck. * Gets the selected deck.
* *
* @return {@link forge.deck.Deck} * @return {@link forge.deck.Deck}
*/ */
public Deck getSelectedDeck() { public Deck getSelectedDeck() {
Deck selectedDeck = null; Deck selectedDeck = null;
for (final RowPanel r : this.rows) { for (final RowPanel r : this.rows) {
if (r.isSelected()) { if (r.isSelected()) {
selectedDeck = r.getDeck(); selectedDeck = r.getDeck();
} }
} }
return selectedDeck; return selectedDeck;
} }
/** Prevent panel from repainting the whole screen. */ /** Prevent panel from repainting the whole screen. */
public void repaintOnlyThisPanel() { public void repaintOnlyThisPanel() {
final Dimension d = DeckLister.this.getSize(); final Dimension d = DeckLister.this.getSize();
this.repaint(0, 0, d.width, d.height); this.repaint(0, 0, d.width, d.height);
} }
private class DeleteButton extends JButton { private class DeleteButton extends JButton {
public DeleteButton(final RowPanel r0) { public DeleteButton(final RowPanel r0) {
super(); super();
this.setRolloverEnabled(true); this.setRolloverEnabled(true);
this.setPressedIcon(DeckLister.this.icoDeleteOver); this.setPressedIcon(DeckLister.this.icoDeleteOver);
this.setRolloverIcon(DeckLister.this.icoDeleteOver); this.setRolloverIcon(DeckLister.this.icoDeleteOver);
this.setIcon(DeckLister.this.icoDelete); this.setIcon(DeckLister.this.icoDelete);
this.setOpaque(false); this.setOpaque(false);
this.setContentAreaFilled(false); this.setContentAreaFilled(false);
this.setBorder(null); this.setBorder(null);
this.setBorderPainted(false); this.setBorderPainted(false);
this.setToolTipText("Delete this deck"); this.setToolTipText("Delete this deck");
this.addMouseListener(new MouseAdapter() { this.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseEntered(final MouseEvent e) { public void mouseEntered(final MouseEvent e) {
if (!r0.selected) { if (!r0.selected) {
r0.setBackground(DeckLister.this.clrHover); r0.setBackground(DeckLister.this.clrHover);
r0.setOpaque(true); r0.setOpaque(true);
} }
} }
@Override @Override
public void mouseExited(final MouseEvent e) { public void mouseExited(final MouseEvent e) {
if (!r0.selected) { if (!r0.selected) {
r0.setBackground(DeckLister.this.clrDefault); r0.setBackground(DeckLister.this.clrDefault);
r0.setOpaque(false); r0.setOpaque(false);
} }
} }
@Override @Override
public void mouseClicked(final MouseEvent e) { public void mouseClicked(final MouseEvent e) {
DeckLister.this.deleteDeck(r0); DeckLister.this.deleteDeck(r0);
} }
}); });
} }
} }
private class EditButton extends JButton { private class EditButton extends JButton {
public EditButton(final RowPanel r0) { public EditButton(final RowPanel r0) {
super(); super();
this.setRolloverEnabled(true); this.setRolloverEnabled(true);
this.setPressedIcon(DeckLister.this.icoEditOver); this.setPressedIcon(DeckLister.this.icoEditOver);
this.setRolloverIcon(DeckLister.this.icoEditOver); this.setRolloverIcon(DeckLister.this.icoEditOver);
this.setIcon(DeckLister.this.icoEdit); this.setIcon(DeckLister.this.icoEdit);
this.setOpaque(false); this.setOpaque(false);
this.setContentAreaFilled(false); this.setContentAreaFilled(false);
this.setBorder(null); this.setBorder(null);
this.setBorderPainted(false); this.setBorderPainted(false);
this.setToolTipText("Edit this deck"); this.setToolTipText("Edit this deck");
this.addMouseListener(new MouseAdapter() { this.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseEntered(final MouseEvent e) { public void mouseEntered(final MouseEvent e) {
if (!r0.selected) { if (!r0.selected) {
r0.setBackground(DeckLister.this.clrHover); r0.setBackground(DeckLister.this.clrHover);
r0.setOpaque(true); r0.setOpaque(true);
} }
} }
@Override @Override
public void mouseExited(final MouseEvent e) { public void mouseExited(final MouseEvent e) {
if (!r0.selected) { if (!r0.selected) {
r0.setBackground(DeckLister.this.clrDefault); r0.setBackground(DeckLister.this.clrDefault);
r0.setOpaque(false); r0.setOpaque(false);
} }
} }
@Override @Override
public void mouseClicked(final MouseEvent e) { public void mouseClicked(final MouseEvent e) {
DeckLister.this.editDeck(r0.getDeck()); DeckLister.this.editDeck(r0.getDeck());
} }
}); });
} }
} }
// Here only to prevent visual artifact problems from translucent skin // Here only to prevent visual artifact problems from translucent skin
// colors. // colors.
private class TitlePanel extends JPanel { private class TitlePanel extends JPanel {
@Override @Override
public void paintComponent(final Graphics g) { public void paintComponent(final Graphics g) {
g.setColor(this.getBackground()); g.setColor(this.getBackground());
g.clearRect(0, 0, this.getWidth(), this.getHeight()); g.clearRect(0, 0, this.getWidth(), this.getHeight());
g.fillRect(0, 0, this.getWidth(), this.getHeight()); g.fillRect(0, 0, this.getWidth(), this.getHeight());
super.paintComponent(g); super.paintComponent(g);
} }
} }
private class RowPanel extends JPanel { private class RowPanel extends JPanel {
private boolean selected = false; private boolean selected = false;
private final Deck deck; private final Deck deck;
public RowPanel(final Deck d0) { public RowPanel(final Deck d0) {
super(); super();
this.setOpaque(false); this.setOpaque(false);
this.setBackground(new Color(0, 0, 0, 0)); this.setBackground(new Color(0, 0, 0, 0));
this.setLayout(new MigLayout("insets 0, gap 0")); this.setLayout(new MigLayout("insets 0, gap 0"));
this.setBorder(new MatteBorder(0, 0, 1, 0, DeckLister.this.clrBorders)); this.setBorder(new MatteBorder(0, 0, 1, 0, DeckLister.this.clrBorders));
this.deck = d0; this.deck = d0;
this.addMouseListener(new MouseAdapter() { this.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseEntered(final MouseEvent e) { public void mouseEntered(final MouseEvent e) {
if (!RowPanel.this.selected) { if (!RowPanel.this.selected) {
((RowPanel) e.getSource()).setBackground(DeckLister.this.clrHover); ((RowPanel) e.getSource()).setBackground(DeckLister.this.clrHover);
((RowPanel) e.getSource()).setOpaque(true); ((RowPanel) e.getSource()).setOpaque(true);
} }
} }
@Override @Override
public void mouseExited(final MouseEvent e) { public void mouseExited(final MouseEvent e) {
if (!RowPanel.this.selected) { if (!RowPanel.this.selected) {
((RowPanel) e.getSource()).setBackground(DeckLister.this.clrDefault); ((RowPanel) e.getSource()).setBackground(DeckLister.this.clrDefault);
((RowPanel) e.getSource()).setOpaque(false); ((RowPanel) e.getSource()).setOpaque(false);
} }
} }
@Override @Override
public void mousePressed(final MouseEvent e) { public void mousePressed(final MouseEvent e) {
DeckLister.this.selectHandler((RowPanel) e.getSource()); DeckLister.this.selectHandler((RowPanel) e.getSource());
} }
}); });
} }
public void setSelected(final boolean b0) { public void setSelected(final boolean b0) {
this.selected = b0; this.selected = b0;
this.setOpaque(b0); this.setOpaque(b0);
this.setBackground(b0 ? DeckLister.this.clrActive : DeckLister.this.clrHover); this.setBackground(b0 ? DeckLister.this.clrActive : DeckLister.this.clrHover);
} }
public boolean isSelected() { public boolean isSelected() {
return this.selected; return this.selected;
} }
public Deck getDeck() { public Deck getDeck() {
return this.deck; return this.deck;
} }
} }
private class MainLabel extends JLabel { private class MainLabel extends JLabel {
public MainLabel(final String txt0) { public MainLabel(final String txt0) {
super(txt0); super(txt0);
this.setOpaque(true); this.setOpaque(true);
if (Integer.parseInt(txt0) < 40) { if (Integer.parseInt(txt0) < 40) {
this.setBackground(Color.RED.brighter()); this.setBackground(Color.RED.brighter());
} else { } else {
this.setBackground(Color.GREEN); this.setBackground(Color.GREEN);
} }
this.setHorizontalAlignment(SwingConstants.CENTER); this.setHorizontalAlignment(SwingConstants.CENTER);
this.setFont(FSkin.getBoldFont(12)); this.setFont(FSkin.getBoldFont(12));
this.setHorizontalAlignment(SwingConstants.CENTER); this.setHorizontalAlignment(SwingConstants.CENTER);
} }
} }
private class GenericLabel extends JLabel { private class GenericLabel extends JLabel {
public GenericLabel(final String txt0) { public GenericLabel(final String txt0) {
super(txt0); super(txt0);
this.setHorizontalAlignment(SwingConstants.CENTER); this.setHorizontalAlignment(SwingConstants.CENTER);
this.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT)); this.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT));
this.setFont(FSkin.getBoldFont(12)); this.setFont(FSkin.getBoldFont(12));
} }
} }
/** /**
* Gets the selected index. * Gets the selected index.
* *
* @return {@link java.lang.Integer} * @return {@link java.lang.Integer}
*/ */
public int getSelectedIndex() { public int getSelectedIndex() {
for (int i = 0; i < this.rows.length; i++) { for (int i = 0; i < this.rows.length; i++) {
if (this.rows[i].isSelected()) { if (this.rows[i].isSelected()) {
return i; return i;
} }
} }
return -1; return -1;
} }
/** /**
* Selects a row programatically. * Selects a row programatically.
* *
* @param i0 * @param i0
* &emsp; int * &emsp; int
* @return boolean Was able to select, or not. * @return boolean Was able to select, or not.
*/ */
public boolean setSelectedIndex(final int i0) { public boolean setSelectedIndex(final int i0) {
if (i0 >= this.rows.length) { if (i0 >= this.rows.length) {
return false; return false;
} }
this.selectHandler(this.rows[i0]); this.selectHandler(this.rows[i0]);
return true; return true;
} }
/** /**
* Sets the selected deck. * Sets the selected deck.
* *
* @param d0 &emsp; Deck object to select (if exists in list) * @param d0 &emsp; Deck object to select (if exists in list)
* @return boolean Found deck, or didn't. * @return boolean Found deck, or didn't.
*/ */
public boolean setSelectedDeck(final Deck d0) { public boolean setSelectedDeck(final Deck d0) {
for (final RowPanel r : this.rows) { for (final RowPanel r : this.rows) {
if (r.getDeck() == d0) { if (r.getDeck() == d0) {
this.selectHandler(r); this.selectHandler(r);
return true; return true;
} }
} }
return false; return false;
} }
/** /**
* Sets the delete command. * Sets the delete command.
* *
* @param c0 &emsp; {@link forge.Command} command executed on delete. * @param c0 &emsp; {@link forge.Command} command executed on delete.
*/ */
public void setDeleteCommand(final Command c0) { public void setDeleteCommand(final Command c0) {
this.cmdDelete = c0; this.cmdDelete = c0;
} }
/** /**
* Sets the select command. * Sets the select command.
* *
* @param c0 &emsp; {@link forge.Command} command executed on row select. * @param c0 &emsp; {@link forge.Command} command executed on row select.
*/ */
public void setSelectCommand(final Command c0) { public void setSelectCommand(final Command c0) {
this.cmdRowSelect = c0; this.cmdRowSelect = c0;
} }
/** /**
* Sets the exit command. * Sets the exit command.
* *
* @param c0 &emsp; {@link forge.Command} command executed on editor exit. * @param c0 &emsp; {@link forge.Command} command executed on editor exit.
*/ */
public void setExitCommand(final Command c0) { public void setExitCommand(final Command c0) {
this.cmdEditorExit = c0; this.cmdEditorExit = c0;
} }
private void selectHandler(final RowPanel r0) { private void selectHandler(final RowPanel r0) {
if (this.previousSelect != null) { if (this.previousSelect != null) {
this.previousSelect.setSelected(false); this.previousSelect.setSelected(false);
} }
r0.setSelected(true); r0.setSelected(true);
this.previousSelect = r0; this.previousSelect = r0;
if (this.cmdRowSelect != null) { if (this.cmdRowSelect != null) {
this.cmdRowSelect.execute(); this.cmdRowSelect.execute();
} }
} }
private void editDeck(final Deck d0) { private void editDeck(final Deck d0) {
OverlayUtils.showOverlay(); OverlayUtils.showOverlay();
switch (this.gametype) { JFrame mainFrame = Singletons.getView().getFrame();
case Quest: switch (this.gametype) {
Constant.Runtime.HUMAN_DECK[0] = d0; case Quest:
final DeckEditorQuest editor = new DeckEditorQuest(AllZone.getQuest()); Constant.Runtime.HUMAN_DECK[0] = d0;
editor.show(this.cmdEditorExit); final DeckEditorQuest editor = new DeckEditorQuest(mainFrame, AllZone.getQuest());
editor.setVisible(true); editor.show(this.cmdEditorExit);
editor.setAlwaysOnTop(true); editor.setVisible(true);
break; break;
case Constructed: case Constructed:
final DeckEditorConstructed cEditor = new DeckEditorConstructed(); final DeckEditorConstructed cEditor =
cEditor.show(this.cmdEditorExit); new DeckEditorConstructed(mainFrame);
cEditor.getController().load(d0.getName()); cEditor.show(this.cmdEditorExit);
cEditor.setVisible(true); cEditor.getController().load(d0.getName());
cEditor.setAlwaysOnTop(true); cEditor.setVisible(true);
break; break;
case Sealed: case Sealed:
final DeckEditorLimited sEditor = new DeckEditorLimited(Singletons.getModel().getDecks().getSealed()); final DeckEditorLimited sEditor =
sEditor.show(this.cmdEditorExit); new DeckEditorLimited(mainFrame, Singletons.getModel().getDecks().getSealed());
sEditor.getController().load(d0.getName()); sEditor.show(this.cmdEditorExit);
sEditor.setVisible(true); sEditor.getController().load(d0.getName());
sEditor.setAlwaysOnTop(true); sEditor.setVisible(true);
break; break;
case Draft: case Draft:
final DeckEditorLimited dEditor = new DeckEditorLimited(Singletons.getModel().getDecks().getDraft()); final DeckEditorLimited dEditor =
dEditor.show(this.cmdEditorExit); new DeckEditorLimited(mainFrame, Singletons.getModel().getDecks().getDraft());
dEditor.getController().load(d0.getName()); dEditor.show(this.cmdEditorExit);
dEditor.setVisible(true); dEditor.getController().load(d0.getName());
dEditor.setAlwaysOnTop(true); dEditor.setVisible(true);
break; break;
default: default:
break; break;
} }
} }
private void deleteDeck(final RowPanel r0) { private void deleteDeck(final RowPanel r0) {
final Deck d0 = r0.getDeck(); final Deck d0 = r0.getDeck();
final int n = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete \"" + d0.getName() + "\" ?", final int n = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete \"" + d0.getName() + "\" ?",
"Delete Deck", JOptionPane.YES_NO_OPTION); "Delete Deck", JOptionPane.YES_NO_OPTION);
if (n == JOptionPane.NO_OPTION) { if (n == JOptionPane.NO_OPTION) {
return; return;
} }
final CardCollections deckManager = Singletons.getModel().getDecks(); final CardCollections deckManager = Singletons.getModel().getDecks();
if (this.gametype.equals(GameType.Draft)) { if (this.gametype.equals(GameType.Draft)) {
deckManager.getDraft().delete(d0.getName()); deckManager.getDraft().delete(d0.getName());
} else if (this.gametype.equals(GameType.Sealed)) { } else if (this.gametype.equals(GameType.Sealed)) {
deckManager.getSealed().delete(d0.getName()); deckManager.getSealed().delete(d0.getName());
} else if (this.gametype.equals(GameType.Quest)) { } else if (this.gametype.equals(GameType.Quest)) {
AllZone.getQuest().getMyDecks().delete(d0.getName()); AllZone.getQuest().getMyDecks().delete(d0.getName());
AllZone.getQuest().save(); AllZone.getQuest().save();
} else { } else {
deckManager.getConstructed().delete(d0.getName()); deckManager.getConstructed().delete(d0.getName());
} }
this.remove(r0); this.remove(r0);
this.repaintOnlyThisPanel(); this.repaintOnlyThisPanel();
this.revalidate(); this.revalidate();
if (this.cmdDelete != null) { if (this.cmdDelete != null) {
this.cmdDelete.execute(); this.cmdDelete.execute();
} }
} }
} }