Merge branch 'deck-editor' into 'master'

Deck Editor changes

Closes #554 and #696

See merge request core-developers/forge!896
This commit is contained in:
Sol
2018-09-11 01:26:27 +00:00
25 changed files with 915 additions and 207 deletions

View File

@@ -6,11 +6,14 @@ package forge.gui.framework;
import com.google.common.collect.ObjectArrays; import com.google.common.collect.ObjectArrays;
import forge.screens.deckeditor.views.VAllDecks; import forge.screens.deckeditor.views.VAllDecks;
import forge.screens.deckeditor.views.VBrawlDecks;
import forge.screens.deckeditor.views.VCardCatalog; import forge.screens.deckeditor.views.VCardCatalog;
import forge.screens.deckeditor.views.VCommanderDecks;
import forge.screens.deckeditor.views.VCurrentDeck; import forge.screens.deckeditor.views.VCurrentDeck;
import forge.screens.deckeditor.views.VDeckgen; import forge.screens.deckeditor.views.VDeckgen;
import forge.screens.deckeditor.views.VProbabilities; import forge.screens.deckeditor.views.VProbabilities;
import forge.screens.deckeditor.views.VStatistics; import forge.screens.deckeditor.views.VStatistics;
import forge.screens.deckeditor.views.VTinyLeadersDecks;
import forge.screens.home.gauntlet.VSubmenuGauntletBuild; import forge.screens.home.gauntlet.VSubmenuGauntletBuild;
import forge.screens.home.gauntlet.VSubmenuGauntletContests; import forge.screens.home.gauntlet.VSubmenuGauntletContests;
import forge.screens.home.gauntlet.VSubmenuGauntletLoad; import forge.screens.home.gauntlet.VSubmenuGauntletLoad;
@@ -54,6 +57,9 @@ public enum EDocID {
EDITOR_CATALOG (VCardCatalog.SINGLETON_INSTANCE), EDITOR_CATALOG (VCardCatalog.SINGLETON_INSTANCE),
EDITOR_CURRENTDECK (VCurrentDeck.SINGLETON_INSTANCE), EDITOR_CURRENTDECK (VCurrentDeck.SINGLETON_INSTANCE),
EDITOR_DECKGEN (VDeckgen.SINGLETON_INSTANCE), EDITOR_DECKGEN (VDeckgen.SINGLETON_INSTANCE),
EDITOR_COMMANDER (VCommanderDecks.SINGLETON_INSTANCE),
EDITOR_BRAWL (VBrawlDecks.SINGLETON_INSTANCE),
EDITOR_TINY_LEADERS (VTinyLeadersDecks.SINGLETON_INSTANCE),
WORKSHOP_CATALOG (VWorkshopCatalog.SINGLETON_INSTANCE), WORKSHOP_CATALOG (VWorkshopCatalog.SINGLETON_INSTANCE),
WORKSHOP_CARDDESIGNER (VCardDesigner.SINGLETON_INSTANCE), WORKSHOP_CARDDESIGNER (VCardDesigner.SINGLETON_INSTANCE),

View File

@@ -28,6 +28,7 @@ import javax.xml.stream.events.XMLEvent;
import forge.FThreads; import forge.FThreads;
import forge.Singletons; import forge.Singletons;
import forge.error.BugReporter;
import forge.gui.SOverlayUtils; import forge.gui.SOverlayUtils;
import forge.properties.FileLocation; import forge.properties.FileLocation;
import forge.properties.ForgeConstants; import forge.properties.ForgeConstants;
@@ -36,6 +37,7 @@ import forge.toolbox.SaveOpenDialog;
import forge.toolbox.SaveOpenDialog.Filetypes; import forge.toolbox.SaveOpenDialog.Filetypes;
import forge.util.CollectionSuppliers; import forge.util.CollectionSuppliers;
import forge.util.ThreadUtil; import forge.util.ThreadUtil;
import forge.util.gui.SOptionPane;
import forge.util.maps.HashMapOfLists; import forge.util.maps.HashMapOfLists;
import forge.util.maps.MapOfLists; import forge.util.maps.MapOfLists;
import forge.view.FFrame; import forge.view.FFrame;
@@ -307,6 +309,8 @@ public final class SLayoutIO {
FileOutputStream fos = null; FileOutputStream fos = null;
XMLEventWriter writer = null; XMLEventWriter writer = null;
try { try {
String layoutSerial = getLayoutSerial(file.defaultLoc);
fos = new FileOutputStream(fWriteTo); fos = new FileOutputStream(fWriteTo);
writer = out.createXMLEventWriter(fos); writer = out.createXMLEventWriter(fos);
final List<DragCell> cells = FView.SINGLETON_INSTANCE.getDragCells(); final List<DragCell> cells = FView.SINGLETON_INSTANCE.getDragCells();
@@ -314,6 +318,7 @@ public final class SLayoutIO {
writer.add(EF.createStartDocument()); writer.add(EF.createStartDocument());
writer.add(NEWLINE); writer.add(NEWLINE);
writer.add(EF.createStartElement("", "", "layout")); writer.add(EF.createStartElement("", "", "layout"));
writer.add(EF.createAttribute("serial", layoutSerial));
writer.add(NEWLINE); writer.add(NEWLINE);
for (final DragCell cell : cells) { for (final DragCell cell : cells) {
@@ -356,8 +361,63 @@ public final class SLayoutIO {
} }
} }
private static String getLayoutSerial(String layoutFileName) {
final XMLInputFactory inputFactory = XMLInputFactory.newInstance();
FileInputStream fis = null;
XMLEventReader reader = null;
XMLEvent event;
StartElement element;
Iterator<?> attributes;
Attribute attribute;
try {
fis = new FileInputStream(layoutFileName);
reader = inputFactory.createXMLEventReader(fis);
while (null != reader && reader.hasNext()) {
event = reader.nextEvent();
if (event.isStartElement()) {
element = event.asStartElement();
if (element.getName().getLocalPart().equals("layout")) {
attributes = element.getAttributes();
while (attributes.hasNext()) {
attribute = (Attribute) attributes.next();
String atrName = attribute.getName().toString();
if (atrName.equals("serial")) {
return attribute.getValue();
}
}
}
}
}
} catch (final Exception e) { // I don't care what happened inside, the layout is wrong
e.printStackTrace();
}
finally {
try {
if (reader != null) {
reader.close();
}
if (fis != null) {
fis.close();
}
}
catch (Exception e) {
e.printStackTrace();
}
}
return "";
}
public static void loadLayout(final File f) { public static void loadLayout(final File f) {
final FView view = FView.SINGLETON_INSTANCE; final FView view = FView.SINGLETON_INSTANCE;
String defaultLayoutSerial = "";
String userLayoutSerial = "";
Boolean resetLayout = false;
FScreen screen = Singletons.getControl().getCurrentScreen();
FAbsolutePositioner.SINGLETON_INSTANCE.hideAll(); FAbsolutePositioner.SINGLETON_INSTANCE.hideAll();
view.getPnlInsets().removeAll(); view.getPnlInsets().removeAll();
view.getPnlInsets().setLayout(new BorderLayout()); view.getPnlInsets().setLayout(new BorderLayout());
@@ -365,7 +425,7 @@ public final class SLayoutIO {
view.getPnlInsets().setBorder(new EmptyBorder(SLayoutConstants.BORDER_T, SLayoutConstants.BORDER_T, 0, 0)); view.getPnlInsets().setBorder(new EmptyBorder(SLayoutConstants.BORDER_T, SLayoutConstants.BORDER_T, 0, 0));
view.removeAllDragCells(); view.removeAllDragCells();
FileLocation file = Singletons.getControl().getCurrentScreen().getLayoutFile(); FileLocation file = screen.getLayoutFile();
if (file != null) { if (file != null) {
// Read a model for new layout // Read a model for new layout
MapOfLists<LayoutInfo, EDocID> model = null; MapOfLists<LayoutInfo, EDocID> model = null;
@@ -379,8 +439,27 @@ public final class SLayoutIO {
else { else {
File userSetting = new File(file.userPrefLoc); File userSetting = new File(file.userPrefLoc);
if (userSetting.exists()) { if (userSetting.exists()) {
usedCustomPrefsFile = true; defaultLayoutSerial = getLayoutSerial(file.defaultLoc);
fis = new FileInputStream(userSetting); userLayoutSerial = getLayoutSerial(file.userPrefLoc);
if (defaultLayoutSerial.compareTo(userLayoutSerial) > 0) {
// prompt the user that their saved layout is older
resetLayout = SOptionPane.showConfirmDialog(
String.format("Your %s layout file is from an older template.",
screen.getTabCaption()
),
"Reset Layout?",
"Reset",
"Keep");
}
if (resetLayout) {
// delete the old layout file
screen.deleteLayoutFile();
fis = new FileInputStream(file.defaultLoc);
} else {
fis = new FileInputStream(userSetting);
usedCustomPrefsFile = true;
}
} }
else { else {
fis = new FileInputStream(file.defaultLoc); fis = new FileInputStream(file.defaultLoc);
@@ -413,13 +492,13 @@ public final class SLayoutIO {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
finally { finally {
if (fis != null) { try {
try { if (fis != null) {
fis.close(); fis.close();
} }
catch (IOException e) { }
catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
}
} }
} }

View File

@@ -12,6 +12,8 @@ import javax.swing.JTable;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionListener;
import forge.deck.Deck;
import forge.screens.deckeditor.controllers.CEditorConstructed;
import forge.screens.home.quest.DialogChooseFormats; import forge.screens.home.quest.DialogChooseFormats;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@@ -267,48 +269,69 @@ public final class DeckManager extends ItemManager<DeckProxy> implements IHasGam
}); });
} }
private void editDeck(final DeckProxy deck) { public void editDeck(final DeckProxy deck) {
if (deck == null) { return; }
ACEditorBase<? extends InventoryItem, ? extends DeckBase> editorCtrl = null; ACEditorBase<? extends InventoryItem, ? extends DeckBase> editorCtrl = null;
FScreen screen = null; FScreen screen = null;
switch (this.gameType) { switch (this.gameType) {
case Quest: case Quest:
screen = FScreen.DECK_EDITOR_QUEST; screen = FScreen.DECK_EDITOR_QUEST;
editorCtrl = new CEditorQuest(FModel.getQuest(), getCDetailPicture()); editorCtrl = new CEditorQuest(FModel.getQuest(), getCDetailPicture());
break; break;
case Constructed: case Constructed:
screen = FScreen.DECK_EDITOR_CONSTRUCTED; screen = FScreen.DECK_EDITOR_CONSTRUCTED;
DeckPreferences.setCurrentDeck(deck.toString()); DeckPreferences.setCurrentDeck((deck != null) ? deck.toString() : "");
//re-use constructed controller editorCtrl = new CEditorConstructed(getCDetailPicture(), this.gameType);
break; break;
case Sealed: case Commander:
screen = FScreen.DECK_EDITOR_SEALED; screen = FScreen.DECK_EDITOR_CONSTRUCTED; // re-use "Deck Editor", rather than creating a new top level tab
editorCtrl = new CEditorLimited(FModel.getDecks().getSealed(), screen, getCDetailPicture()); DeckPreferences.setCommanderDeck((deck != null) ? deck.toString() : "");
break; editorCtrl = new CEditorConstructed(getCDetailPicture(), this.gameType);
case Draft: break;
screen = FScreen.DECK_EDITOR_DRAFT; case Brawl:
editorCtrl = new CEditorLimited(FModel.getDecks().getDraft(), screen, getCDetailPicture()); screen = FScreen.DECK_EDITOR_CONSTRUCTED; // re-use "Deck Editor", rather than creating a new top level tab
break; DeckPreferences.setBrawlDeck((deck != null) ? deck.toString() : "");
case Winston: editorCtrl = new CEditorConstructed(getCDetailPicture(), this.gameType);
screen = FScreen.DECK_EDITOR_DRAFT; break;
editorCtrl = new CEditorLimited(FModel.getDecks().getWinston(), screen, getCDetailPicture()); case TinyLeaders:
break; screen = FScreen.DECK_EDITOR_CONSTRUCTED; // re-use "Deck Editor", rather than creating a new top level tab
DeckPreferences.setTinyLeadersDeck((deck != null) ? deck.toString() : "");
editorCtrl = new CEditorConstructed(getCDetailPicture(), this.gameType);
break;
case Sealed:
screen = FScreen.DECK_EDITOR_SEALED;
editorCtrl = new CEditorLimited(FModel.getDecks().getSealed(), screen, getCDetailPicture());
break;
case Draft:
screen = FScreen.DECK_EDITOR_DRAFT;
editorCtrl = new CEditorLimited(FModel.getDecks().getDraft(), screen, getCDetailPicture());
break;
case Winston:
screen = FScreen.DECK_EDITOR_DRAFT;
editorCtrl = new CEditorLimited(FModel.getDecks().getWinston(), screen, getCDetailPicture());
break;
default: default:
return; return;
} }
if (!Singletons.getControl().ensureScreenActive(screen)) { return; } if (!Singletons.getControl().ensureScreenActive(screen)) {
return;
}
if (editorCtrl != null) { if (editorCtrl != null) {
CDeckEditorUI.SINGLETON_INSTANCE.setEditorController(editorCtrl); CDeckEditorUI.SINGLETON_INSTANCE.setEditorController(editorCtrl);
} }
if (!SEditorIO.confirmSaveChanges(screen, true)) { return; } //ensure previous deck on screen is saved if needed if (!SEditorIO.confirmSaveChanges(screen, true)) {
return;
} //ensure previous deck on screen is saved if needed
CDeckEditorUI.SINGLETON_INSTANCE.getCurrentEditorController().getDeckController().load(deck.getPath(), deck.getName()); if (deck != null) {
CDeckEditorUI.SINGLETON_INSTANCE.getCurrentEditorController().getDeckController().load(deck.getPath(), deck.getName());
} else {
CDeckEditorUI.SINGLETON_INSTANCE.getCurrentEditorController().getDeckController().loadDeck(new Deck());
}
} }
public boolean deleteDeck(final DeckProxy deck) { public boolean deleteDeck(final DeckProxy deck) {
@@ -322,17 +345,20 @@ public final class DeckManager extends ItemManager<DeckProxy> implements IHasGam
// consider using deck proxy's method to delete deck // consider using deck proxy's method to delete deck
switch(this.gameType) { switch(this.gameType) {
case Constructed: case Brawl:
case Draft: case Commander:
case Sealed: case TinyLeaders:
deck.deleteFromStorage(); case Constructed:
break; case Draft:
case Quest: case Sealed:
deck.deleteFromStorage(); deck.deleteFromStorage();
FModel.getQuest().save(); break;
break; case Quest:
default: deck.deleteFromStorage();
throw new UnsupportedOperationException("Delete not implemented for game type = " + gameType.toString()); FModel.getQuest().save();
break;
default:
throw new UnsupportedOperationException("Delete not implemented for game type = " + gameType.toString());
} }
this.removeItem(deck, 1); this.removeItem(deck, 1);

View File

@@ -30,12 +30,7 @@ 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.JMenu; import javax.swing.*;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionListener;
import javax.swing.event.PopupMenuEvent; import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener; import javax.swing.event.PopupMenuListener;
@@ -58,6 +53,7 @@ import forge.itemmanager.views.ItemTableColumn;
import forge.itemmanager.views.ItemView; import forge.itemmanager.views.ItemView;
import forge.screens.match.controllers.CDetailPicture; import forge.screens.match.controllers.CDetailPicture;
import forge.toolbox.ContextMenuBuilder; import forge.toolbox.ContextMenuBuilder;
import forge.toolbox.FComboBox;
import forge.toolbox.FLabel; import forge.toolbox.FLabel;
import forge.toolbox.FSkin; import forge.toolbox.FSkin;
import forge.toolbox.FSkin.Colors; import forge.toolbox.FSkin.Colors;
@@ -115,13 +111,11 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel implem
.fontSize(12) .fontSize(12)
.build(); .build();
private final FLabel btnCycleSection = new FLabel.Builder() private final FLabel lblEmpty = new FLabel.Builder()
.text("Change Section") .text("")
.tooltip("Toggle between editing the deck and the sideboard/planar/scheme/vanguard parts of this deck")
.icon(FSkin.getIcon(FSkinProp.ICO_EDIT))
.iconScaleAuto(false).hoverable()
.fontSize(12) .fontSize(12)
.build(); .build();
private FComboBox cbxSection = new FComboBox();
private static final SkinIcon VIEW_OPTIONS_ICON = FSkin.getIcon(FSkinProp.ICO_SETTINGS).resize(20, 20); private static final SkinIcon VIEW_OPTIONS_ICON = FSkin.getIcon(FSkinProp.ICO_SETTINGS).resize(20, 20);
private final FLabel btnViewOptions = new FLabel.Builder() private final FLabel btnViewOptions = new FLabel.Builder()
@@ -193,8 +187,9 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel implem
this.add(this.btnFilters); this.add(this.btnFilters);
this.add(this.lblCaption); this.add(this.lblCaption);
this.add(this.lblRatio); this.add(this.lblRatio);
btnCycleSection.setVisible(false); //hide by default this.add(this.lblEmpty);
this.add(btnCycleSection); this.cbxSection.setVisible(false);
this.add(this.cbxSection);
for (final ItemView<T> view : this.views) { for (final ItemView<T> view : this.views) {
this.add(view.getButton()); this.add(view.getButton());
view.getButton().setSelected(view == this.currentView); view.getButton().setSelected(view == this.currentView);
@@ -381,30 +376,42 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel implem
helper.newLine(-3); helper.newLine(-3);
helper.fillLine(this.pnlButtons, showButtonPanel ? buttonPanelHeight : 1); //just show border if no buttons helper.fillLine(this.pnlButtons, showButtonPanel ? buttonPanelHeight : 1); //just show border if no buttons
} }
// get the width for all components
final int viewButtonWidth = FTextField.HEIGHT; final int viewButtonWidth = FTextField.HEIGHT;
helper.newLine();
helper.offset(1, 0); //align filters button with expand/collapse all button
helper.include(this.btnFilters, viewButtonWidth, FTextField.HEIGHT);
int captionWidth = this.lblCaption.getAutoSizeWidth();
int btnCycleSectionWidth = this.btnCycleSection.isVisible() ? this.btnCycleSection.getAutoSizeWidth() : 0;
final int ratioWidth = this.lblRatio.getAutoSizeWidth(); final int ratioWidth = this.lblRatio.getAutoSizeWidth();
final int viewButtonCount = this.views.size() + 1; int captionWidth = this.lblCaption.getAutoSizeWidth();
final int availableCaptionWidth = helper.getParentWidth() - viewButtonWidth * viewButtonCount - ratioWidth - btnCycleSectionWidth - 3 * helper.getX() - (viewButtonCount + 2) * helper.getGapX(); final int cbxSectionWidth = this.cbxSection.isVisible() ? this.cbxSection.getAutoSizeWidth() : 0;
final int viewButtonCount = this.views.size() + 1; // +1 is for the options button
final int widthViewButtons = viewButtonCount * viewButtonWidth + helper.getGapX() * (viewButtonCount);
// remove the space needed by all components that will be displayed
int availableCaptionWidth = helper.getParentWidth()
- viewButtonWidth // btnFilters
- cbxSectionWidth
- ratioWidth
- widthViewButtons;
if (captionWidth > availableCaptionWidth) { //truncate caption if not enough room for it if (captionWidth > availableCaptionWidth) { //truncate caption if not enough room for it
this.lblCaption.setToolTipText(this.lblCaption.getText()); this.lblCaption.setToolTipText(this.lblCaption.getText());
captionWidth = availableCaptionWidth; captionWidth = availableCaptionWidth;
} else { } else {
this.lblCaption.setToolTipText(null); this.lblCaption.setToolTipText(null);
} }
helper.newLine();
helper.offset(1, 0); //align filters button with expand/collapse all button
helper.include(this.btnFilters, viewButtonWidth, FTextField.HEIGHT);
helper.include(this.lblCaption, captionWidth, FTextField.HEIGHT); helper.include(this.lblCaption, captionWidth, FTextField.HEIGHT);
helper.fillLine(this.lblRatio, FTextField.HEIGHT, (viewButtonWidth + helper.getGapX()) * viewButtonCount - viewButtonCount + btnCycleSectionWidth + 2 * helper.getGapX() + 1); //leave room for view buttons and btnCycleSectionWidth helper.include(this.cbxSection, cbxSectionWidth, FTextField.HEIGHT);
helper.include(this.btnCycleSection, btnCycleSectionWidth, FTextField.HEIGHT);
helper.offset(helper.getGapX(), 0); helper.offset(helper.getGapX(), 0);
helper.include(this.lblRatio, ratioWidth, FTextField.HEIGHT);
helper.fillLine(this.lblEmpty, FTextField.HEIGHT, widthViewButtons);
for (final ItemView<T> view : this.views) { for (final ItemView<T> view : this.views) {
helper.include(view.getButton(), viewButtonWidth, FTextField.HEIGHT); helper.include(view.getButton(), viewButtonWidth, FTextField.HEIGHT);
helper.offset(-1, 0); helper.offset(-1, 0);
} }
helper.include(this.btnViewOptions, viewButtonWidth, FTextField.HEIGHT); helper.include(this.btnViewOptions, viewButtonWidth, FTextField.HEIGHT);
helper.newLine(-1); helper.newLine(-1);
if (this.currentView.getPnlOptions().isVisible()) { if (this.currentView.getPnlOptions().isVisible()) {
helper.fillLine(this.currentView.getPnlOptions(), FTextField.HEIGHT + 4); helper.fillLine(this.currentView.getPnlOptions(), FTextField.HEIGHT + 4);
@@ -1092,8 +1099,8 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel implem
return this.pnlButtons; return this.pnlButtons;
} }
public FLabel getBtnCycleSection() { public FComboBox getCbxSection() {
return btnCycleSection; return this.cbxSection;
} }
/** /**

View File

@@ -38,8 +38,11 @@ import forge.item.InventoryItem;
import forge.itemmanager.ItemManager; import forge.itemmanager.ItemManager;
import forge.screens.deckeditor.controllers.*; import forge.screens.deckeditor.controllers.*;
import forge.screens.deckeditor.views.VAllDecks; import forge.screens.deckeditor.views.VAllDecks;
import forge.screens.deckeditor.views.VBrawlDecks;
import forge.screens.deckeditor.views.VCardCatalog; import forge.screens.deckeditor.views.VCardCatalog;
import forge.screens.deckeditor.views.VCommanderDecks;
import forge.screens.deckeditor.views.VCurrentDeck; import forge.screens.deckeditor.views.VCurrentDeck;
import forge.screens.deckeditor.views.VTinyLeadersDecks;
import forge.screens.match.controllers.CDetailPicture; import forge.screens.match.controllers.CDetailPicture;
import forge.util.ItemPool; import forge.util.ItemPool;
@@ -59,12 +62,21 @@ public enum CDeckEditorUI implements ICDoc {
private ACEditorBase<? extends InventoryItem, ? extends DeckBase> childController; private ACEditorBase<? extends InventoryItem, ? extends DeckBase> childController;
private final CDetailPicture cDetailPicture; private final CDetailPicture cDetailPicture;
private final VAllDecks vAllDecks; private final VAllDecks vAllDecks;
private final VCommanderDecks vCommanderDecks;
private final VBrawlDecks vBrawlDecks;
private final VTinyLeadersDecks vTinyLeadersDecks;
private CDeckEditorUI() { private CDeckEditorUI() {
screenChildControllers = new HashMap<FScreen, ACEditorBase<? extends InventoryItem, ? extends DeckBase>>(); screenChildControllers = new HashMap<FScreen, ACEditorBase<? extends InventoryItem, ? extends DeckBase>>();
this.cDetailPicture = new CDetailPicture(); this.cDetailPicture = new CDetailPicture();
this.vAllDecks = VAllDecks.SINGLETON_INSTANCE; this.vAllDecks = VAllDecks.SINGLETON_INSTANCE;
this.vAllDecks.setCDetailPicture(cDetailPicture); this.vAllDecks.setCDetailPicture(cDetailPicture);
this.vCommanderDecks = VCommanderDecks.SINGLETON_INSTANCE;
this.vCommanderDecks.setCDetailPicture(cDetailPicture);
this.vBrawlDecks = VBrawlDecks.SINGLETON_INSTANCE;
this.vBrawlDecks.setCDetailPicture(cDetailPicture);
this.vTinyLeadersDecks = VTinyLeadersDecks.SINGLETON_INSTANCE;
this.vTinyLeadersDecks.setCDetailPicture(cDetailPicture);
} }
public CDetailPicture getCDetailPicture() { public CDetailPicture getCDetailPicture() {

View File

@@ -39,6 +39,7 @@ import forge.screens.deckeditor.views.VCardCatalog;
import forge.screens.deckeditor.views.VCurrentDeck; import forge.screens.deckeditor.views.VCurrentDeck;
import forge.screens.match.controllers.CDetailPicture; import forge.screens.match.controllers.CDetailPicture;
import forge.toolbox.ContextMenuBuilder; import forge.toolbox.ContextMenuBuilder;
import forge.toolbox.FComboBox;
import forge.toolbox.FLabel; import forge.toolbox.FLabel;
import forge.toolbox.FSkin; import forge.toolbox.FSkin;
import forge.util.Aggregates; import forge.util.Aggregates;
@@ -389,7 +390,7 @@ public abstract class ACEditorBase<TItem extends InventoryItem, TModel extends D
VCardCatalog.SINGLETON_INSTANCE.getTabLabel().setText("Card Catalog"); VCardCatalog.SINGLETON_INSTANCE.getTabLabel().setText("Card Catalog");
VCurrentDeck.SINGLETON_INSTANCE.getBtnPrintProxies().setVisible(true); VCurrentDeck.SINGLETON_INSTANCE.getBtnPrintProxies().setVisible(true);
getBtnCycleSection().setVisible(false); getCbxSection().setVisible(false);
VCurrentDeck.SINGLETON_INSTANCE.getTxfTitle().setVisible(true); VCurrentDeck.SINGLETON_INSTANCE.getTxfTitle().setVisible(true);
VCurrentDeck.SINGLETON_INSTANCE.getLblTitle().setText("Title:"); VCurrentDeck.SINGLETON_INSTANCE.getLblTitle().setText("Title:");
@@ -400,7 +401,7 @@ public abstract class ACEditorBase<TItem extends InventoryItem, TModel extends D
public FLabel getBtnRemove() { return btnRemove; } public FLabel getBtnRemove() { return btnRemove; }
public FLabel getBtnRemove4() { return btnRemove4; } public FLabel getBtnRemove4() { return btnRemove4; }
public FLabel getBtnAddBasicLands() { return btnAddBasicLands; } public FLabel getBtnAddBasicLands() { return btnAddBasicLands; }
public FLabel getBtnCycleSection() { return deckManager.getBtnCycleSection(); } public FComboBox getCbxSection() { return deckManager.getCbxSection(); }
public ContextMenuBuilder createContextMenuBuilder(final boolean isAddContextMenu0) { public ContextMenuBuilder createContextMenuBuilder(final boolean isAddContextMenu0) {
return new EditorContextMenuBuilder(isAddContextMenu0); return new EditorContextMenuBuilder(isAddContextMenu0);

View File

@@ -0,0 +1,46 @@
package forge.screens.deckeditor.controllers;
import forge.deck.DeckProxy;
import forge.gui.framework.ICDoc;
import forge.itemmanager.ItemManagerConfig;
import forge.screens.deckeditor.views.VBrawlDecks;
import forge.screens.deckeditor.views.VCommanderDecks;
import forge.screens.deckeditor.views.VTinyLeadersDecks;
/**
* Controls the "Commander Decks" panel in the deck editor UI.
*
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
*
*/
public enum CBrawlDecks implements ICDoc {
SINGLETON_INSTANCE;
private final VBrawlDecks view = VBrawlDecks.SINGLETON_INSTANCE;
//========== Overridden methods
@Override
public void register() {
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#initialize()
*/
@Override
public void initialize() {
refresh();
}
public void refresh() {
view.getLstDecks().setPool(DeckProxy.getAllBrawlDecks());
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#update()
*/
@Override
public void update() {
view.getLstDecks().setup(ItemManagerConfig.CONSTRUCTED_DECKS);
}
}

View File

@@ -0,0 +1,45 @@
package forge.screens.deckeditor.controllers;
import forge.deck.DeckProxy;
import forge.gui.framework.ICDoc;
import forge.itemmanager.ItemManagerConfig;
import forge.screens.deckeditor.views.VAllDecks;
import forge.screens.deckeditor.views.VCommanderDecks;
/**
* Controls the "Commander Decks" panel in the deck editor UI.
*
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
*
*/
public enum CCommanderDecks implements ICDoc {
SINGLETON_INSTANCE;
private final VCommanderDecks view = VCommanderDecks.SINGLETON_INSTANCE;
//========== Overridden methods
@Override
public void register() {
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#initialize()
*/
@Override
public void initialize() {
refresh();
}
public void refresh() {
view.getLstDecks().setPool(DeckProxy.getAllCommanderDecks());
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#update()
*/
@Override
public void update() {
view.getLstDecks().setup(ItemManagerConfig.CONSTRUCTED_DECKS);
}
}

View File

@@ -35,8 +35,11 @@ import forge.screens.deckeditor.SEditorIO;
import forge.screens.deckeditor.views.VAllDecks; import forge.screens.deckeditor.views.VAllDecks;
import forge.screens.deckeditor.views.VDeckgen; import forge.screens.deckeditor.views.VDeckgen;
import forge.screens.match.controllers.CDetailPicture; import forge.screens.match.controllers.CDetailPicture;
import forge.toolbox.FComboBox;
import forge.util.ItemPool; import forge.util.ItemPool;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
@@ -191,15 +194,20 @@ public final class CEditorCommander extends CDeckEditor<Deck> {
this.getBtnRemove4().setVisible(false); this.getBtnRemove4().setVisible(false);
this.getBtnAdd4().setVisible(false); this.getBtnAdd4().setVisible(false);
this.getBtnCycleSection().setVisible(true);
this.getBtnCycleSection().setCommand(new UiCommand() {
private static final long serialVersionUID = -9082606944024479599L;
this.getCbxSection().removeAllItems();
for (DeckSection section : allSections) {
this.getCbxSection().addItem(section);
}
this.getCbxSection().addActionListener(new ActionListener() {
@Override @Override
public void run() { public void actionPerformed(ActionEvent actionEvent) {
cycleEditorMode(); FComboBox cb = (FComboBox)actionEvent.getSource();
DeckSection ds = (DeckSection)cb.getSelectedItem();
setEditorMode(ds);
} }
}); });
this.getCbxSection().setVisible(true);
deckGenParent = removeTab(VDeckgen.SINGLETON_INSTANCE); deckGenParent = removeTab(VDeckgen.SINGLETON_INSTANCE);
allDecksParent = removeTab(VAllDecks.SINGLETON_INSTANCE); allDecksParent = removeTab(VAllDecks.SINGLETON_INSTANCE);
@@ -232,11 +240,7 @@ public final class CEditorCommander extends CDeckEditor<Deck> {
/** /**
* Switch between the main deck and the sideboard editor. * Switch between the main deck and the sideboard editor.
*/ */
public void cycleEditorMode() { public void setEditorMode(DeckSection sectionMode) {
int curindex = allSections.indexOf(sectionMode);
curindex = (curindex + 1) % allSections.size();
sectionMode = allSections.get(curindex);
switch(sectionMode) { switch(sectionMode) {
case Main: case Main:
this.getCatalogManager().setup(ItemManagerConfig.CARD_CATALOG); this.getCatalogManager().setup(ItemManagerConfig.CARD_CATALOG);
@@ -257,6 +261,7 @@ public final class CEditorCommander extends CDeckEditor<Deck> {
break; break;
} }
this.sectionMode = sectionMode;
this.controller.updateCaptions(); this.controller.updateCaptions();
} }
} }

View File

@@ -17,13 +17,16 @@
*/ */
package forge.screens.deckeditor.controllers; package forge.screens.deckeditor.controllers;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import forge.UiCommand; import forge.UiCommand;
import forge.card.CardRules;
import forge.card.CardRulesPredicates; import forge.card.CardRulesPredicates;
import forge.deck.CardPool; import forge.deck.CardPool;
import forge.deck.Deck; import forge.deck.Deck;
import forge.deck.DeckSection; import forge.deck.DeckSection;
import forge.game.GameType;
import forge.gui.framework.FScreen; import forge.gui.framework.FScreen;
import forge.item.PaperCard; import forge.item.PaperCard;
import forge.itemmanager.CardManager; import forge.itemmanager.CardManager;
@@ -33,8 +36,13 @@ import forge.properties.ForgePreferences.FPref;
import forge.screens.deckeditor.AddBasicLandsDialog; import forge.screens.deckeditor.AddBasicLandsDialog;
import forge.screens.deckeditor.SEditorIO; import forge.screens.deckeditor.SEditorIO;
import forge.screens.match.controllers.CDetailPicture; import forge.screens.match.controllers.CDetailPicture;
import forge.toolbox.FComboBox;
import forge.util.ItemPool; import forge.util.ItemPool;
import sun.font.FontConfigManager;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
@@ -50,9 +58,16 @@ import java.util.Map.Entry;
* @version $Id: CEditorConstructed.java 24868 2014-02-17 05:08:05Z drdev $ * @version $Id: CEditorConstructed.java 24868 2014-02-17 05:08:05Z drdev $
*/ */
public final class CEditorConstructed extends CDeckEditor<Deck> { public final class CEditorConstructed extends CDeckEditor<Deck> {
private final DeckController<Deck> controller; private DeckController<Deck> controller;
private final List<DeckSection> allSections = new ArrayList<DeckSection>(); private final List<DeckSection> allSections = new ArrayList<DeckSection>();
private final ItemPool<PaperCard> normalPool, avatarPool, planePool, schemePool, conspiracyPool; private ItemPool<PaperCard> normalPool, avatarPool, planePool, schemePool, conspiracyPool, commanderPool;
private final GameType gameType;
Predicate<CardRules> commanderFilter;
CardManager catalogManager;
CardManager deckManager;
//=========== Constructor //=========== Constructor
/** /**
@@ -62,23 +77,56 @@ public final class CEditorConstructed extends CDeckEditor<Deck> {
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public CEditorConstructed(final CDetailPicture cDetailPicture) { public CEditorConstructed(final CDetailPicture cDetailPicture) {
this(cDetailPicture, GameType.Constructed);
}
public CEditorConstructed(final CDetailPicture cDetailPicture, final GameType gameType) {
super(FScreen.DECK_EDITOR_CONSTRUCTED, cDetailPicture); super(FScreen.DECK_EDITOR_CONSTRUCTED, cDetailPicture);
this.gameType = gameType;
boolean wantUnique = false;
allSections.add(DeckSection.Main); allSections.add(DeckSection.Main);
allSections.add(DeckSection.Sideboard); allSections.add(DeckSection.Sideboard);
allSections.add(DeckSection.Avatar);
allSections.add(DeckSection.Schemes);
allSections.add(DeckSection.Planes);
allSections.add(DeckSection.Conspiracy);
normalPool = ItemPool.createFrom(FModel.getMagicDb().getCommonCards().getAllCards(), PaperCard.class); switch (this.gameType) {
avatarPool = ItemPool.createFrom(FModel.getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_VANGUARD, PaperCard.FN_GET_RULES)), PaperCard.class); case Constructed:
planePool = ItemPool.createFrom(FModel.getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_PLANE_OR_PHENOMENON, PaperCard.FN_GET_RULES)), PaperCard.class); allSections.add(DeckSection.Avatar);
schemePool = ItemPool.createFrom(FModel.getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_SCHEME, PaperCard.FN_GET_RULES)), PaperCard.class); allSections.add(DeckSection.Schemes);
conspiracyPool = ItemPool.createFrom(FModel.getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_CONSPIRACY, PaperCard.FN_GET_RULES)), PaperCard.class); allSections.add(DeckSection.Planes);
allSections.add(DeckSection.Conspiracy);
CardManager catalogManager = new CardManager(getCDetailPicture(), false, false); // TODO: restore the functionality of the "want uniques only" toggle normalPool = ItemPool.createFrom(FModel.getMagicDb().getCommonCards().getAllCards(), PaperCard.class);
CardManager deckManager = new CardManager(getCDetailPicture(), false, false); // IMPORTANT: must *always* show all cards in the deck, otherwise cards with different art get ignored! avatarPool = ItemPool.createFrom(FModel.getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_VANGUARD, PaperCard.FN_GET_RULES)), PaperCard.class);
planePool = ItemPool.createFrom(FModel.getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_PLANE_OR_PHENOMENON, PaperCard.FN_GET_RULES)), PaperCard.class);
schemePool = ItemPool.createFrom(FModel.getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_SCHEME, PaperCard.FN_GET_RULES)), PaperCard.class);
conspiracyPool = ItemPool.createFrom(FModel.getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_CONSPIRACY, PaperCard.FN_GET_RULES)), PaperCard.class);
break;
case Commander:
case TinyLeaders:
allSections.add(DeckSection.Commander);
commanderFilter = CardRulesPredicates.Presets.CAN_BE_COMMANDER;
commanderPool = ItemPool.createFrom(FModel.getMagicDb().getCommonCards().getAllCards(Predicates.compose(commanderFilter, PaperCard.FN_GET_RULES)), PaperCard.class);
normalPool = ItemPool.createFrom(FModel.getMagicDb().getCommonCards().getAllCards(), PaperCard.class);
wantUnique = true;
break;
case Brawl:
allSections.add(DeckSection.Commander);
commanderFilter = CardRulesPredicates.Presets.CAN_BE_BRAWL_COMMANDER;
commanderPool = ItemPool.createFrom(FModel.getMagicDb().getCommonCards().getAllCards(Predicates.and(
FModel.getFormats().get("Brawl").getFilterPrinted(), Predicates.compose(commanderFilter, PaperCard.FN_GET_RULES))), PaperCard.class);
normalPool = ItemPool.createFrom(FModel.getFormats().get("Brawl").getAllCards(), PaperCard.class);
wantUnique = true;
break;
}
catalogManager = new CardManager(getCDetailPicture(), wantUnique, false);
deckManager = new CardManager(getCDetailPicture(), wantUnique, false);
catalogManager.setCaption("Catalog"); catalogManager.setCaption("Catalog");
@@ -92,7 +140,20 @@ public final class CEditorConstructed extends CDeckEditor<Deck> {
} }
}; };
this.controller = new DeckController<Deck>(FModel.getDecks().getConstructed(), this, newCreator); switch (this.gameType) {
case Constructed:
this.controller = new DeckController<Deck>(FModel.getDecks().getConstructed(), this, newCreator);
break;
case Commander:
this.controller = new DeckController<Deck>(FModel.getDecks().getCommander(), this, newCreator);
break;
case Brawl:
this.controller = new DeckController<Deck>(FModel.getDecks().getBrawl(), this, newCreator);
break;
case TinyLeaders:
this.controller = new DeckController<Deck>(FModel.getDecks().getTinyLeaders(), this, newCreator);
break;
}
getBtnAddBasicLands().setCommand(new UiCommand() { getBtnAddBasicLands().setCommand(new UiCommand() {
@Override @Override
@@ -110,7 +171,14 @@ public final class CEditorConstructed extends CDeckEditor<Deck> {
return CardLimit.Singleton; return CardLimit.Singleton;
} }
if (FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY)) { if (FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY)) {
return CardLimit.Default; switch (this.gameType) {
case Constructed:
return CardLimit.Default;
case Commander:
case TinyLeaders:
case Brawl:
return CardLimit.Singleton;
}
} }
return CardLimit.None; //if not enforcing deck legality, don't enforce default limit return CardLimit.None; //if not enforcing deck legality, don't enforce default limit
} }
@@ -296,45 +364,70 @@ public final class CEditorConstructed extends CDeckEditor<Deck> {
/** /**
* Switch between the main deck and the sideboard editor. * Switch between the main deck and the sideboard editor.
*/ */
public void cycleEditorMode() { public void setEditorMode(DeckSection sectionMode) {
int curindex = allSections.indexOf(sectionMode); if (sectionMode == null) {
curindex = (curindex + 1) % allSections.size(); return;
sectionMode = allSections.get(curindex); }
switch(this.gameType) {
switch(sectionMode) { case Constructed:
case Main: switch(sectionMode) {
this.getCatalogManager().setup(ItemManagerConfig.CARD_CATALOG); case Main:
this.getCatalogManager().setPool(normalPool, true); this.getCatalogManager().setup(ItemManagerConfig.CARD_CATALOG);
this.getDeckManager().setPool(this.controller.getModel().getMain()); this.getCatalogManager().setPool(normalPool, true);
break; this.getDeckManager().setPool(this.controller.getModel().getMain());
case Sideboard: break;
this.getCatalogManager().setup(ItemManagerConfig.CARD_CATALOG); case Sideboard:
this.getCatalogManager().setPool(normalPool, true); this.getCatalogManager().setup(ItemManagerConfig.CARD_CATALOG);
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Sideboard)); this.getCatalogManager().setPool(normalPool, true);
break; this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Sideboard));
case Avatar: break;
this.getCatalogManager().setup(ItemManagerConfig.AVATAR_POOL); case Avatar:
this.getCatalogManager().setPool(avatarPool, true); this.getCatalogManager().setup(ItemManagerConfig.AVATAR_POOL);
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Avatar)); this.getCatalogManager().setPool(avatarPool, true);
break; this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Avatar));
case Planes: break;
this.getCatalogManager().setup(ItemManagerConfig.PLANAR_POOL); case Planes:
this.getCatalogManager().setPool(planePool,true); this.getCatalogManager().setup(ItemManagerConfig.PLANAR_POOL);
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Planes)); this.getCatalogManager().setPool(planePool, true);
break; this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Planes));
case Schemes: break;
this.getCatalogManager().setup(ItemManagerConfig.SCHEME_POOL); case Schemes:
this.getCatalogManager().setPool(schemePool,true); this.getCatalogManager().setup(ItemManagerConfig.SCHEME_POOL);
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Schemes)); this.getCatalogManager().setPool(schemePool, true);
break; this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Schemes));
case Commander: break;
break; //do nothing for Commander here case Commander:
case Conspiracy: break; //do nothing for Commander here
this.getCatalogManager().setup(ItemManagerConfig.CONSPIRACY_DECKS); case Conspiracy:
this.getCatalogManager().setPool(conspiracyPool,true); this.getCatalogManager().setup(ItemManagerConfig.CONSPIRACY_DECKS);
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Conspiracy)); this.getCatalogManager().setPool(conspiracyPool, true);
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Conspiracy));
}
case Commander:
case TinyLeaders:
case Brawl:
switch(sectionMode) {
case Main:
this.getCatalogManager().setup(ItemManagerConfig.CARD_CATALOG);
this.getCatalogManager().setPool(normalPool, true);
this.getDeckManager().setPool(this.controller.getModel().getMain());
break;
case Sideboard:
this.getCatalogManager().setup(ItemManagerConfig.CARD_CATALOG);
this.getCatalogManager().setPool(normalPool, true);
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Sideboard));
break;
case Commander:
this.getCatalogManager().setup(ItemManagerConfig.COMMANDER_POOL);
this.getCatalogManager().setPool(commanderPool, true);
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Commander));
break;
default:
break;
}
} }
this.sectionMode = sectionMode;
this.controller.updateCaptions(); this.controller.updateCaptions();
} }
@@ -360,13 +453,19 @@ public final class CEditorConstructed extends CDeckEditor<Deck> {
resetUI(); resetUI();
this.getBtnCycleSection().setVisible(true); this.getCbxSection().removeAllItems();
this.getBtnCycleSection().setCommand(new UiCommand() { for (DeckSection section : allSections) {
this.getCbxSection().addItem(section);
}
this.getCbxSection().addActionListener(new ActionListener() {
@Override @Override
public void run() { public void actionPerformed(ActionEvent actionEvent) {
cycleEditorMode(); FComboBox cb = (FComboBox)actionEvent.getSource();
DeckSection ds = (DeckSection)cb.getSelectedItem();
setEditorMode(ds);
} }
}); });
this.getCbxSection().setVisible(true);
this.controller.refreshModel(); this.controller.refreshModel();
} }

View File

@@ -272,7 +272,7 @@ public class CEditorDraftingProcess extends ACEditorBase<PaperCard, DeckGroup> {
this.getBtnRemove().setVisible(false); this.getBtnRemove().setVisible(false);
this.getBtnRemove4().setVisible(false); this.getBtnRemove4().setVisible(false);
this.getBtnCycleSection().setVisible(false); this.getCbxSection().setVisible(false);
VCurrentDeck.SINGLETON_INSTANCE.getPnlHeader().setVisible(false); VCurrentDeck.SINGLETON_INSTANCE.getPnlHeader().setVisible(false);

View File

@@ -33,14 +33,20 @@ import forge.model.FModel;
import forge.screens.deckeditor.AddBasicLandsDialog; import forge.screens.deckeditor.AddBasicLandsDialog;
import forge.screens.deckeditor.SEditorIO; import forge.screens.deckeditor.SEditorIO;
import forge.screens.deckeditor.views.VAllDecks; import forge.screens.deckeditor.views.VAllDecks;
import forge.screens.deckeditor.views.VBrawlDecks;
import forge.screens.deckeditor.views.VCommanderDecks;
import forge.screens.deckeditor.views.VCurrentDeck; import forge.screens.deckeditor.views.VCurrentDeck;
import forge.screens.deckeditor.views.VDeckgen; import forge.screens.deckeditor.views.VDeckgen;
import forge.screens.deckeditor.views.VTinyLeadersDecks;
import forge.screens.home.sanctioned.CSubmenuDraft; import forge.screens.home.sanctioned.CSubmenuDraft;
import forge.screens.home.sanctioned.CSubmenuSealed; import forge.screens.home.sanctioned.CSubmenuSealed;
import forge.screens.match.controllers.CDetailPicture; import forge.screens.match.controllers.CDetailPicture;
import forge.toolbox.FComboBox;
import forge.util.storage.IStorage; import forge.util.storage.IStorage;
import java.util.*; import java.util.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Map.Entry; import java.util.Map.Entry;
/** /**
@@ -54,7 +60,10 @@ import java.util.Map.Entry;
public final class CEditorLimited extends CDeckEditor<DeckGroup> { public final class CEditorLimited extends CDeckEditor<DeckGroup> {
private final DeckController<DeckGroup> controller; private final DeckController<DeckGroup> controller;
private DragCell allDecksParent = null; private DragCell constructedDecksParent = null;
private DragCell commanderDecksParent = null;
private DragCell brawlDecksParent = null;
private DragCell tinyLeadersDecksParent = null;
private DragCell deckGenParent = null; private DragCell deckGenParent = null;
private final List<DeckSection> allSections = new ArrayList<DeckSection>(); private final List<DeckSection> allSections = new ArrayList<DeckSection>();
@@ -98,10 +107,16 @@ public final class CEditorLimited extends CDeckEditor<DeckGroup> {
allSections.add(DeckSection.Main); allSections.add(DeckSection.Main);
allSections.add(DeckSection.Conspiracy); allSections.add(DeckSection.Conspiracy);
this.getBtnCycleSection().setCommand(new UiCommand() { this.getCbxSection().removeAllItems();
for (DeckSection section : allSections) {
this.getCbxSection().addItem(section);
}
this.getCbxSection().addActionListener(new ActionListener() {
@Override @Override
public void run() { public void actionPerformed(ActionEvent actionEvent) {
cycleEditorMode(); FComboBox cb = (FComboBox)actionEvent.getSource();
DeckSection ds = (DeckSection)cb.getSelectedItem();
setEditorMode(ds);
} }
}); });
} }
@@ -194,10 +209,7 @@ public final class CEditorLimited extends CDeckEditor<DeckGroup> {
} }
public void cycleEditorMode() { public void setEditorMode(DeckSection sectionMode) {
int curindex = (allSections.indexOf(sectionMode) + 1) % allSections.size();
sectionMode = allSections.get(curindex);
switch(sectionMode) { switch(sectionMode) {
case Conspiracy: case Conspiracy:
this.getCatalogManager().setup(ItemManagerConfig.DRAFT_CONSPIRACY); this.getCatalogManager().setup(ItemManagerConfig.DRAFT_CONSPIRACY);
@@ -211,6 +223,7 @@ public final class CEditorLimited extends CDeckEditor<DeckGroup> {
break; break;
} }
this.sectionMode = sectionMode;
this.controller.updateCaptions(); this.controller.updateCaptions();
} }
@@ -226,10 +239,13 @@ public final class CEditorLimited extends CDeckEditor<DeckGroup> {
VCurrentDeck.SINGLETON_INSTANCE.getBtnPrintProxies().setVisible(false); VCurrentDeck.SINGLETON_INSTANCE.getBtnPrintProxies().setVisible(false);
VCurrentDeck.SINGLETON_INSTANCE.getTxfTitle().setEnabled(false); VCurrentDeck.SINGLETON_INSTANCE.getTxfTitle().setEnabled(false);
this.getBtnCycleSection().setVisible(true); this.getCbxSection().setVisible(true);
deckGenParent = removeTab(VDeckgen.SINGLETON_INSTANCE); deckGenParent = removeTab(VDeckgen.SINGLETON_INSTANCE);
allDecksParent = removeTab(VAllDecks.SINGLETON_INSTANCE); constructedDecksParent = removeTab(VAllDecks.SINGLETON_INSTANCE);
commanderDecksParent = removeTab(VCommanderDecks.SINGLETON_INSTANCE);
brawlDecksParent = removeTab(VBrawlDecks.SINGLETON_INSTANCE);
tinyLeadersDecksParent = removeTab(VTinyLeadersDecks.SINGLETON_INSTANCE);
} }
/* (non-Javadoc) /* (non-Javadoc)
@@ -252,8 +268,17 @@ public final class CEditorLimited extends CDeckEditor<DeckGroup> {
if (deckGenParent != null) { if (deckGenParent != null) {
deckGenParent.addDoc(VDeckgen.SINGLETON_INSTANCE); deckGenParent.addDoc(VDeckgen.SINGLETON_INSTANCE);
} }
if (allDecksParent != null) { if (constructedDecksParent != null) {
allDecksParent.addDoc(VAllDecks.SINGLETON_INSTANCE); constructedDecksParent.addDoc(VAllDecks.SINGLETON_INSTANCE);
}
if (commanderDecksParent != null) {
commanderDecksParent.addDoc(VCommanderDecks.SINGLETON_INSTANCE);
}
if (brawlDecksParent!= null) {
brawlDecksParent.addDoc(VBrawlDecks.SINGLETON_INSTANCE);
}
if (tinyLeadersDecksParent != null) {
tinyLeadersDecksParent.addDoc(VTinyLeadersDecks.SINGLETON_INSTANCE);
} }
} }
} }

View File

@@ -42,9 +42,12 @@ import forge.screens.deckeditor.views.VCurrentDeck;
import forge.screens.deckeditor.views.VDeckgen; import forge.screens.deckeditor.views.VDeckgen;
import forge.screens.home.quest.CSubmenuQuestDecks; import forge.screens.home.quest.CSubmenuQuestDecks;
import forge.screens.match.controllers.CDetailPicture; import forge.screens.match.controllers.CDetailPicture;
import forge.toolbox.FComboBox;
import forge.util.ItemPool; import forge.util.ItemPool;
import javax.swing.*; import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -279,11 +282,7 @@ public final class CEditorQuest extends CDeckEditor<Deck> {
/** /**
* Switch between the main deck and the sideboard editor. * Switch between the main deck and the sideboard editor.
*/ */
public void cycleEditorMode() { public void setEditorMode(DeckSection sectionMode) {
int curindex = allSections.indexOf(sectionMode);
curindex = (curindex + 1) % allSections.size();
sectionMode = allSections.get(curindex);
if (sectionMode == DeckSection.Sideboard) { if (sectionMode == DeckSection.Sideboard) {
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Sideboard)); this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Sideboard));
} }
@@ -291,6 +290,7 @@ public final class CEditorQuest extends CDeckEditor<Deck> {
this.getDeckManager().setPool(this.controller.getModel().getMain()); this.getDeckManager().setPool(this.controller.getModel().getMain());
} }
this.sectionMode = sectionMode;
this.controller.updateCaptions(); this.controller.updateCaptions();
} }
@@ -316,12 +316,19 @@ public final class CEditorQuest extends CDeckEditor<Deck> {
VCurrentDeck.SINGLETON_INSTANCE.getBtnSave().setVisible(true); VCurrentDeck.SINGLETON_INSTANCE.getBtnSave().setVisible(true);
this.getBtnCycleSection().setVisible(true); this.getCbxSection().removeAllItems();
this.getBtnCycleSection().setCommand(new UiCommand() { for (DeckSection section : allSections) {
@Override public void run() { this.getCbxSection().addItem(section);
cycleEditorMode(); }
this.getCbxSection().addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
FComboBox cb = (FComboBox)actionEvent.getSource();
DeckSection ds = (DeckSection)cb.getSelectedItem();
setEditorMode(ds);
} }
}); });
this.getCbxSection().setVisible(true);
deckGenParent = removeTab(VDeckgen.SINGLETON_INSTANCE); deckGenParent = removeTab(VDeckgen.SINGLETON_INSTANCE);
allDecksParent = removeTab(VAllDecks.SINGLETON_INSTANCE); allDecksParent = removeTab(VAllDecks.SINGLETON_INSTANCE);

View File

@@ -270,7 +270,7 @@ public class CEditorQuestDraftingProcess extends ACEditorBase<PaperCard, DeckGro
getBtnRemove().setVisible(false); getBtnRemove().setVisible(false);
getBtnRemove4().setVisible(false); getBtnRemove4().setVisible(false);
getBtnCycleSection().setVisible(false); getCbxSection().setVisible(false);
VCurrentDeck.SINGLETON_INSTANCE.getPnlHeader().setVisible(false); VCurrentDeck.SINGLETON_INSTANCE.getPnlHeader().setVisible(false);

View File

@@ -0,0 +1,45 @@
package forge.screens.deckeditor.controllers;
import forge.deck.DeckProxy;
import forge.gui.framework.ICDoc;
import forge.itemmanager.ItemManagerConfig;
import forge.screens.deckeditor.views.VCommanderDecks;
import forge.screens.deckeditor.views.VTinyLeadersDecks;
/**
* Controls the "Commander Decks" panel in the deck editor UI.
*
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
*
*/
public enum CTinyLeadersDecks implements ICDoc {
SINGLETON_INSTANCE;
private final VTinyLeadersDecks view = VTinyLeadersDecks.SINGLETON_INSTANCE;
//========== Overridden methods
@Override
public void register() {
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#initialize()
*/
@Override
public void initialize() {
refresh();
}
public void refresh() {
view.getLstDecks().setPool(DeckProxy.getAllTinyLeadersDecks());
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#update()
*/
@Override
public void update() {
view.getLstDecks().setup(ItemManagerConfig.CONSTRUCTED_DECKS);
}
}

View File

@@ -88,6 +88,10 @@ public class DeckController<T extends DeckBase> {
*/ */
public void loadDeck(Deck deck) { public void loadDeck(Deck deck) {
if (deck.getName() == "") {
newModel();
}
if (!view.getCatalogManager().isInfinite()) { if (!view.getCatalogManager().isInfinite()) {
CardPool catalogClone = new CardPool(view.getInitialCatalog()); CardPool catalogClone = new CardPool(view.getInitialCatalog());
deck = pickFromCatalog(deck, catalogClone); deck = pickFromCatalog(deck, catalogClone);
@@ -406,7 +410,7 @@ public class DeckController<T extends DeckBase> {
tabCaption = "*" + tabCaption; tabCaption = "*" + tabCaption;
itemManagerCaption = "*" + itemManagerCaption; itemManagerCaption = "*" + itemManagerCaption;
} }
itemManagerCaption += " - " + view.getSectionMode().name(); itemManagerCaption += " - ";
VCurrentDeck.SINGLETON_INSTANCE.getTabLabel().setText(tabCaption); VCurrentDeck.SINGLETON_INSTANCE.getTabLabel().setText(tabCaption);
VCurrentDeck.SINGLETON_INSTANCE.getTxfTitle().setText(title); VCurrentDeck.SINGLETON_INSTANCE.getTxfTitle().setText(title);

View File

@@ -1,5 +1,6 @@
package forge.screens.deckeditor.views; package forge.screens.deckeditor.views;
import forge.deck.io.DeckPreferences;
import forge.game.GameType; import forge.game.GameType;
import forge.gui.framework.DragCell; import forge.gui.framework.DragCell;
import forge.gui.framework.DragTab; import forge.gui.framework.DragTab;
@@ -24,7 +25,7 @@ public enum VAllDecks implements IVDoc<CAllDecks> {
// Fields used with interface IVDoc // Fields used with interface IVDoc
private DragCell parentCell; private DragCell parentCell;
private final DragTab tab = new DragTab("All Decks"); private final DragTab tab = new DragTab("Constructed");
private DeckManager lstDecks; private DeckManager lstDecks;
@@ -80,6 +81,8 @@ public enum VAllDecks implements IVDoc<CAllDecks> {
JPanel parentBody = parentCell.getBody(); JPanel parentBody = parentCell.getBody();
parentBody.setLayout(new MigLayout("insets 5, gap 0, wrap, hidemode 3")); parentBody.setLayout(new MigLayout("insets 5, gap 0, wrap, hidemode 3"));
parentBody.add(new ItemManagerContainer(lstDecks), "push, grow"); parentBody.add(new ItemManagerContainer(lstDecks), "push, grow");
String preferredDeck = DeckPreferences.getCurrentDeck();
lstDecks.editDeck(lstDecks.stringToItem(preferredDeck));
} }
//========== Retrieval methods //========== Retrieval methods
@@ -90,6 +93,6 @@ public enum VAllDecks implements IVDoc<CAllDecks> {
public void setCDetailPicture(final CDetailPicture cDetailPicture) { public void setCDetailPicture(final CDetailPicture cDetailPicture) {
this.lstDecks = new DeckManager(GameType.Constructed, cDetailPicture); this.lstDecks = new DeckManager(GameType.Constructed, cDetailPicture);
this.lstDecks.setCaption("Decks"); this.lstDecks.setCaption("Constructed Decks");
} }
} }

View File

@@ -0,0 +1,98 @@
package forge.screens.deckeditor.views;
import forge.deck.io.DeckPreferences;
import forge.game.GameType;
import forge.gui.framework.DragCell;
import forge.gui.framework.DragTab;
import forge.gui.framework.EDocID;
import forge.gui.framework.IVDoc;
import forge.itemmanager.DeckManager;
import forge.itemmanager.ItemManagerContainer;
import forge.screens.deckeditor.controllers.CBrawlDecks;
import forge.screens.match.controllers.CDetailPicture;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
/**
* Assembles Swing components of all deck viewer in deck editor.
*
* <br><br><i>(V at beginning of class name denotes a view class.)</i>
*/
public enum VBrawlDecks implements IVDoc<CBrawlDecks> {
/** */
SINGLETON_INSTANCE;
// Fields used with interface IVDoc
private DragCell parentCell;
private final DragTab tab = new DragTab("Brawl");
private DeckManager lstDecks;
//========== Overridden methods
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#getDocumentID()
*/
@Override
public EDocID getDocumentID() {
return EDocID.EDITOR_BRAWL;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#getTabLabel()
*/
@Override
public DragTab getTabLabel() {
return tab;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#getLayoutControl()
*/
@Override
public CBrawlDecks getLayoutControl() {
return CBrawlDecks.SINGLETON_INSTANCE;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#setParentCell(forge.gui.framework.DragCell)
*/
@Override
public void setParentCell(DragCell cell0) {
this.parentCell = cell0;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#getParentCell()
*/
@Override
public DragCell getParentCell() {
return this.parentCell;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#populate()
*/
@Override
public void populate() {
CBrawlDecks.SINGLETON_INSTANCE.refresh(); //ensure decks refreshed in case any deleted or added since last loaded
JPanel parentBody = parentCell.getBody();
parentBody.setLayout(new MigLayout("insets 5, gap 0, wrap, hidemode 3"));
parentBody.add(new ItemManagerContainer(lstDecks), "push, grow");
String preferredDeck = DeckPreferences.getBrawlDeck();
lstDecks.editDeck(lstDecks.stringToItem(preferredDeck));
}
//========== Retrieval methods
/** @return {@link JPanel} */
public DeckManager getLstDecks() {
return lstDecks;
}
public void setCDetailPicture(final CDetailPicture cDetailPicture) {
this.lstDecks = new DeckManager(GameType.Brawl, cDetailPicture);
this.lstDecks.setCaption("Brawl Decks");
}
}

View File

@@ -0,0 +1,98 @@
package forge.screens.deckeditor.views;
import forge.deck.io.DeckPreferences;
import forge.game.GameType;
import forge.gui.framework.DragCell;
import forge.gui.framework.DragTab;
import forge.gui.framework.EDocID;
import forge.gui.framework.IVDoc;
import forge.itemmanager.DeckManager;
import forge.itemmanager.ItemManagerContainer;
import forge.screens.deckeditor.controllers.CCommanderDecks;
import forge.screens.match.controllers.CDetailPicture;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
/**
* Assembles Swing components of all deck viewer in deck editor.
*
* <br><br><i>(V at beginning of class name denotes a view class.)</i>
*/
public enum VCommanderDecks implements IVDoc<CCommanderDecks> {
/** */
SINGLETON_INSTANCE;
// Fields used with interface IVDoc
private DragCell parentCell;
private final DragTab tab = new DragTab("Commander");
private DeckManager lstDecks;
//========== Overridden methods
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#getDocumentID()
*/
@Override
public EDocID getDocumentID() {
return EDocID.EDITOR_COMMANDER;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#getTabLabel()
*/
@Override
public DragTab getTabLabel() {
return tab;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#getLayoutControl()
*/
@Override
public CCommanderDecks getLayoutControl() {
return CCommanderDecks.SINGLETON_INSTANCE;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#setParentCell(forge.gui.framework.DragCell)
*/
@Override
public void setParentCell(DragCell cell0) {
this.parentCell = cell0;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#getParentCell()
*/
@Override
public DragCell getParentCell() {
return this.parentCell;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#populate()
*/
@Override
public void populate() {
CCommanderDecks.SINGLETON_INSTANCE.refresh(); //ensure decks refreshed in case any deleted or added since last loaded
JPanel parentBody = parentCell.getBody();
parentBody.setLayout(new MigLayout("insets 5, gap 0, wrap, hidemode 3"));
parentBody.add(new ItemManagerContainer(lstDecks), "push, grow");
String preferredDeck = DeckPreferences.getCommanderDeck();
lstDecks.editDeck(lstDecks.stringToItem(preferredDeck));
}
//========== Retrieval methods
/** @return {@link JPanel} */
public DeckManager getLstDecks() {
return lstDecks;
}
public void setCDetailPicture(final CDetailPicture cDetailPicture) {
this.lstDecks = new DeckManager(GameType.Commander, cDetailPicture);
this.lstDecks.setCaption("Commander Decks");
}
}

View File

@@ -0,0 +1,98 @@
package forge.screens.deckeditor.views;
import forge.deck.io.DeckPreferences;
import forge.game.GameType;
import forge.gui.framework.DragCell;
import forge.gui.framework.DragTab;
import forge.gui.framework.EDocID;
import forge.gui.framework.IVDoc;
import forge.itemmanager.DeckManager;
import forge.itemmanager.ItemManagerContainer;
import forge.screens.deckeditor.controllers.CTinyLeadersDecks;
import forge.screens.match.controllers.CDetailPicture;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
/**
* Assembles Swing components of all deck viewer in deck editor.
*
* <br><br><i>(V at beginning of class name denotes a view class.)</i>
*/
public enum VTinyLeadersDecks implements IVDoc<CTinyLeadersDecks> {
/** */
SINGLETON_INSTANCE;
// Fields used with interface IVDoc
private DragCell parentCell;
private final DragTab tab = new DragTab("Tiny Leaders");
private DeckManager lstDecks;
//========== Overridden methods
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#getDocumentID()
*/
@Override
public EDocID getDocumentID() {
return EDocID.EDITOR_TINY_LEADERS;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#getTabLabel()
*/
@Override
public DragTab getTabLabel() {
return tab;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#getLayoutControl()
*/
@Override
public CTinyLeadersDecks getLayoutControl() {
return CTinyLeadersDecks.SINGLETON_INSTANCE;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#setParentCell(forge.gui.framework.DragCell)
*/
@Override
public void setParentCell(DragCell cell0) {
this.parentCell = cell0;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#getParentCell()
*/
@Override
public DragCell getParentCell() {
return this.parentCell;
}
/* (non-Javadoc)
* @see forge.gui.framework.IVDoc#populate()
*/
@Override
public void populate() {
CTinyLeadersDecks.SINGLETON_INSTANCE.refresh(); //ensure decks refreshed in case any deleted or added since last loaded
JPanel parentBody = parentCell.getBody();
parentBody.setLayout(new MigLayout("insets 5, gap 0, wrap, hidemode 3"));
parentBody.add(new ItemManagerContainer(lstDecks), "push, grow");
String preferredDeck = DeckPreferences.getTinyLeadersDeck();
lstDecks.editDeck(lstDecks.stringToItem(preferredDeck));
}
//========== Retrieval methods
/** @return {@link JPanel} */
public DeckManager getLstDecks() {
return lstDecks;
}
public void setCDetailPicture(final CDetailPicture cDetailPicture) {
this.lstDecks = new DeckManager(GameType.TinyLeaders, cDetailPicture);
this.lstDecks.setCaption("Tiny Leaders Decks");
}
}

View File

@@ -88,7 +88,6 @@ public class PlayerPanel extends FPanel {
private final FLabel scmLabel; private final FLabel scmLabel;
private final FLabel cmdDeckSelectorBtn = new FLabel.ButtonBuilder().text("Select a Commander deck").build(); private final FLabel cmdDeckSelectorBtn = new FLabel.ButtonBuilder().text("Select a Commander deck").build();
private final FLabel cmdDeckEditor = new FLabel.ButtonBuilder().text("Commander Deck Editor").build();
private final FLabel cmdLabel; private final FLabel cmdLabel;
private final FLabel pchDeckSelectorBtn = new FLabel.ButtonBuilder().text("Select a planar deck").build(); private final FLabel pchDeckSelectorBtn = new FLabel.ButtonBuilder().text("Select a planar deck").build();
@@ -161,9 +160,8 @@ public class PlayerPanel extends FPanel {
addHandlersDeckSelector(); addHandlersDeckSelector();
this.add(cmdLabel, variantBtnConstraints + ", cell 0 3, sx 2, ax right"); this.add(cmdLabel, variantBtnConstraints + ", cell 0 2, sx 2, ax right");
this.add(cmdDeckSelectorBtn, variantBtnConstraints + ", cell 2 3, growx, pushx"); this.add(cmdDeckSelectorBtn, variantBtnConstraints + ", cell 2 2, pushx, growx, wmax 100%-153px, h 30px, spanx 4, wrap");
this.add(cmdDeckEditor, variantBtnConstraints + ", cell 3 3, sx 3, growx, wrap");
this.add(scmLabel, variantBtnConstraints + ", cell 0 4, sx 2, ax right"); this.add(scmLabel, variantBtnConstraints + ", cell 0 4, sx 2, ax right");
this.add(scmDeckSelectorBtn, variantBtnConstraints + ", cell 2 4, growx, pushx"); this.add(scmDeckSelectorBtn, variantBtnConstraints + ", cell 2 4, growx, pushx");
@@ -348,8 +346,6 @@ public class PlayerPanel extends FPanel {
deckLabel.setVisible(isDeckBuildingAllowed); deckLabel.setVisible(isDeckBuildingAllowed);
deckBtn.setVisible(isDeckBuildingAllowed); deckBtn.setVisible(isDeckBuildingAllowed);
cmdDeckSelectorBtn.setVisible(isCommanderApplied); cmdDeckSelectorBtn.setVisible(isCommanderApplied);
cmdDeckEditor.setText(isTinyLeaders ? "TL Deck Editor" : isBrawl ? "Brawl Editor" : "Commander Deck Editor");
cmdDeckEditor.setVisible(isCommanderApplied);
cmdLabel.setVisible(isCommanderApplied); cmdLabel.setVisible(isCommanderApplied);
scmDeckSelectorBtn.setVisible(archenemyVisiblity); scmDeckSelectorBtn.setVisible(archenemyVisiblity);
@@ -516,25 +512,6 @@ public class PlayerPanel extends FPanel {
} }
}); });
cmdDeckEditor.setCommand(new UiCommand() {
@Override
public void run() {
if (lobby.hasVariant(GameType.TinyLeaders)) {
lobby.setCurrentGameMode(GameType.TinyLeaders);
Singletons.getControl().setCurrentScreen(FScreen.DECK_EDITOR_TINY_LEADERS);
CDeckEditorUI.SINGLETON_INSTANCE.setEditorController(new CEditorCommander(CDeckEditorUI.SINGLETON_INSTANCE.getCDetailPicture(), true, false));
} else if (lobby.hasVariant(GameType.Brawl)) {
lobby.setCurrentGameMode(GameType.Brawl);
Singletons.getControl().setCurrentScreen(FScreen.DECK_EDITOR_BRAWL);
CDeckEditorUI.SINGLETON_INSTANCE.setEditorController(new CEditorCommander(CDeckEditorUI.SINGLETON_INSTANCE.getCDetailPicture(), false, true));
} else {
lobby.setCurrentGameMode(GameType.Commander);
Singletons.getControl().setCurrentScreen(FScreen.DECK_EDITOR_COMMANDER);
CDeckEditorUI.SINGLETON_INSTANCE.setEditorController(new CEditorCommander(CDeckEditorUI.SINGLETON_INSTANCE.getCDetailPicture(), false, false));
}
}
});
// Planechase buttons // Planechase buttons
pchDeckSelectorBtn.setCommand(new Runnable() { pchDeckSelectorBtn.setCommand(new Runnable() {
@Override @Override

View File

@@ -96,9 +96,9 @@ public class VLobby implements ILobbyView {
private final VariantCheckBox vntArchenemy = new VariantCheckBox(GameType.Archenemy); private final VariantCheckBox vntArchenemy = new VariantCheckBox(GameType.Archenemy);
private final VariantCheckBox vntArchenemyRumble = new VariantCheckBox(GameType.ArchenemyRumble); private final VariantCheckBox vntArchenemyRumble = new VariantCheckBox(GameType.ArchenemyRumble);
private final ImmutableList<VariantCheckBox> vntBoxesLocal = private final ImmutableList<VariantCheckBox> vntBoxesLocal =
ImmutableList.of(vntVanguard, vntMomirBasic, vntMoJhoSto, vntCommander, vntTinyLeaders, vntBrawl, vntPlanechase, vntArchenemy, vntArchenemyRumble); ImmutableList.of(vntVanguard, vntMomirBasic, vntMoJhoSto, vntCommander, vntBrawl, vntTinyLeaders, vntPlanechase, vntArchenemy, vntArchenemyRumble);
private final ImmutableList<VariantCheckBox> vntBoxesNetwork = private final ImmutableList<VariantCheckBox> vntBoxesNetwork =
ImmutableList.of(vntVanguard, vntMomirBasic, vntMoJhoSto, vntCommander, vntTinyLeaders, vntBrawl /*, vntPlanechase, vntArchenemy, vntArchenemyRumble */); ImmutableList.of(vntVanguard, vntMomirBasic, vntMoJhoSto, vntCommander, vntBrawl, vntTinyLeaders /*, vntPlanechase, vntArchenemy, vntArchenemyRumble */);
// Player frame elements // Player frame elements
private final JPanel playersFrame = new JPanel(new MigLayout("insets 0, gap 0 5, wrap, hidemode 3")); private final JPanel playersFrame = new JPanel(new MigLayout("insets 0, gap 0 5, wrap, hidemode 3"));

View File

@@ -1,5 +1,5 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<layout> <layout serial="2018090601">
<cell x="0.77443" y="0.37698" w="0.22557" h="0.62302"> <cell x="0.77443" y="0.37698" w="0.22557" h="0.62302">
<doc>CARD_PICTURE</doc> <doc>CARD_PICTURE</doc>
</cell> </cell>
@@ -14,6 +14,9 @@
<cell x="0.0" y="0.0" w="0.38722" h="1.0"> <cell x="0.0" y="0.0" w="0.38722" h="1.0">
<doc>EDITOR_CATALOG</doc> <doc>EDITOR_CATALOG</doc>
<doc>EDITOR_ALLDECKS</doc> <doc>EDITOR_ALLDECKS</doc>
<doc>EDITOR_COMMANDER</doc>
<doc>EDITOR_BRAWL</doc>
<doc>EDITOR_TINY_LEADERS</doc>
<doc>EDITOR_DECKGEN</doc> <doc>EDITOR_DECKGEN</doc>
</cell> </cell>
</layout> </layout>

View File

@@ -5,6 +5,7 @@ import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.NotImplementedException;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import forge.interfaces.ICheckBox; import forge.interfaces.ICheckBox;
@@ -71,22 +72,43 @@ public class DeckImportController {
} }
final Deck result = new Deck(); final Deck result = new Deck();
boolean isMain = true; DeckSection deckSection = null;
String section = "";
for (final DeckRecognizer.Token t : tokens) { for (final DeckRecognizer.Token t : tokens) {
final DeckRecognizer.TokenType type = t.getType(); final DeckRecognizer.TokenType type = t.getType();
if ((type == DeckRecognizer.TokenType.SectionName) && t.getText().toLowerCase().contains("side")) { if (type == DeckRecognizer.TokenType.SectionName) {
isMain = false; section = t.getText().toLowerCase();
// can't use wildcards in switch/case, so if/else it is
if (section.startsWith("main")) {
deckSection = DeckSection.Main;
}
else if (section.startsWith("side")) {
deckSection = DeckSection.Sideboard;
}
else if (section.startsWith("commander")) {
deckSection = DeckSection.Commander;
}
else if (section.startsWith("avatar")) {
deckSection = DeckSection.Avatar;
}
else if (section.startsWith("planes")) {
deckSection = DeckSection.Planes;
}
else if (section.startsWith("scheme")) {
deckSection = DeckSection.Schemes;
}
else if (section.startsWith("conspiracy")) {
deckSection = DeckSection.Conspiracy;
}
else {
throw new NotImplementedException("Unexpected section: %s", t.getText());
}
} }
if (type != DeckRecognizer.TokenType.KnownCard) { if (type != DeckRecognizer.TokenType.KnownCard) {
continue; continue;
} }
final PaperCard crd = t.getCard(); final PaperCard crd = t.getCard();
if (isMain) { result.getOrCreate(deckSection).add(crd, t.getNumber());
result.getMain().add(crd, t.getNumber());
}
else {
result.getOrCreate(DeckSection.Sideboard).add(crd, t.getNumber());
}
} }
return result; return result;
} }

View File

@@ -118,6 +118,7 @@ public class DeckPreferences {
draftDeck = root.getAttribute("draftDeck"); draftDeck = root.getAttribute("draftDeck");
sealedDeck = root.getAttribute("sealedDeck"); sealedDeck = root.getAttribute("sealedDeck");
commanderDeck = root.getAttribute("commanderDeck"); commanderDeck = root.getAttribute("commanderDeck");
brawlDeck = root.getAttribute("brawlDeck");
tinyLeadersDeck = root.getAttribute("tinyLeadersDeck"); tinyLeadersDeck = root.getAttribute("tinyLeadersDeck");
planarDeck = root.getAttribute("planarDeck"); planarDeck = root.getAttribute("planarDeck");
schemeDeck = root.getAttribute("schemeDeck"); schemeDeck = root.getAttribute("schemeDeck");
@@ -148,6 +149,7 @@ public class DeckPreferences {
root.setAttribute("draftDeck", draftDeck); root.setAttribute("draftDeck", draftDeck);
root.setAttribute("sealedDeck", sealedDeck); root.setAttribute("sealedDeck", sealedDeck);
root.setAttribute("commanderDeck", commanderDeck); root.setAttribute("commanderDeck", commanderDeck);
root.setAttribute("brawlDeck", brawlDeck);
root.setAttribute("tinyLeadersDeck", tinyLeadersDeck); root.setAttribute("tinyLeadersDeck", tinyLeadersDeck);
root.setAttribute("planarDeck", planarDeck); root.setAttribute("planarDeck", planarDeck);
root.setAttribute("schemeDeck", schemeDeck); root.setAttribute("schemeDeck", schemeDeck);