mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Prevent marking deck as modified when changing sections
Update item manager caption when changing section Show full catalog when in sideboard section Avoid hiding title and save buttons when changing sections
This commit is contained in:
@@ -23,6 +23,7 @@ import javax.swing.SwingUtilities;
|
||||
|
||||
import forge.Command;
|
||||
import forge.deck.DeckBase;
|
||||
import forge.deck.DeckSection;
|
||||
import forge.gui.deckeditor.CDeckEditorUI;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.FScreen;
|
||||
@@ -69,6 +70,7 @@ public abstract class ACEditorBase<TItem extends InventoryItem, TModel extends D
|
||||
private final FScreen screen;
|
||||
private ItemManager<TItem> catalogManager;
|
||||
private ItemManager<TItem> deckManager;
|
||||
protected DeckSection sectionMode = DeckSection.Main;
|
||||
|
||||
// card transfer buttons
|
||||
private final FLabel btnAdd = new FLabel.Builder()
|
||||
@@ -113,6 +115,10 @@ public abstract class ACEditorBase<TItem extends InventoryItem, TModel extends D
|
||||
return this.screen;
|
||||
}
|
||||
|
||||
public DeckSection getSectionMode() {
|
||||
return this.sectionMode;
|
||||
}
|
||||
|
||||
public final void addItem(TItem item) {
|
||||
onAddItems(createPoolForItem(item, 1), false);
|
||||
}
|
||||
|
||||
@@ -32,8 +32,6 @@ import forge.deck.Deck;
|
||||
import forge.deck.DeckSection;
|
||||
import forge.gui.deckeditor.SEditorIO;
|
||||
import forge.gui.deckeditor.views.VAllDecks;
|
||||
import forge.gui.deckeditor.views.VCardCatalog;
|
||||
import forge.gui.deckeditor.views.VCurrentDeck;
|
||||
import forge.gui.deckeditor.views.VDeckgen;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.FScreen;
|
||||
@@ -65,7 +63,6 @@ public final class CEditorCommander extends ACEditorBase<PaperCard, Deck> {
|
||||
private DragCell deckGenParent = null;
|
||||
|
||||
private List<DeckSection> allSections = new ArrayList<DeckSection>();
|
||||
private DeckSection sectionMode = DeckSection.Main;
|
||||
private final ItemPoolView<PaperCard> commanderPool;
|
||||
private final ItemPoolView<PaperCard> normalPool;
|
||||
|
||||
@@ -162,6 +159,7 @@ public final class CEditorCommander extends ACEditorBase<PaperCard, Deck> {
|
||||
*/
|
||||
@Override
|
||||
public void resetTables() {
|
||||
this.sectionMode = DeckSection.Main;
|
||||
this.getCatalogManager().setPool(normalPool,false);
|
||||
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Main));
|
||||
}
|
||||
@@ -240,52 +238,29 @@ public final class CEditorCommander extends ACEditorBase<PaperCard, Deck> {
|
||||
|
||||
final List<TableColumnInfo<InventoryItem>> lstCatalogCols = SColumnUtil.getCatalogDefaultColumns();
|
||||
|
||||
String title = "";
|
||||
String tabtext = "";
|
||||
Boolean showOptions = true;
|
||||
switch(sectionMode)
|
||||
{
|
||||
switch(sectionMode) {
|
||||
case Main:
|
||||
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
||||
this.getCatalogManager().getTable().setAvailableColumns(lstCatalogCols);
|
||||
this.getCatalogManager().setPool(normalPool, false);
|
||||
this.getDeckManager().setPool(this.controller.getModel().getMain());
|
||||
showOptions = true;
|
||||
title = "Title: ";
|
||||
tabtext = "Main Deck";
|
||||
break;
|
||||
case Sideboard:
|
||||
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
||||
this.getCatalogManager().getTable().setAvailableColumns(lstCatalogCols);
|
||||
this.getCatalogManager().setPool(normalPool, false);
|
||||
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Sideboard));
|
||||
showOptions = false;
|
||||
title = "Sideboard";
|
||||
tabtext = "Card Catalog";
|
||||
break;
|
||||
case Commander:
|
||||
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
||||
this.getCatalogManager().getTable().setAvailableColumns(lstCatalogCols);
|
||||
this.getCatalogManager().setPool(commanderPool, true);
|
||||
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Commander));
|
||||
showOptions = false;
|
||||
title = "Commander";
|
||||
tabtext = "Card Catalog";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
VCardCatalog.SINGLETON_INSTANCE.getTabLabel().setText(tabtext);
|
||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnNew().setVisible(showOptions);
|
||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnOpen().setVisible(showOptions);
|
||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnSave().setVisible(showOptions);
|
||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnSaveAs().setVisible(showOptions);
|
||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnPrintProxies().setVisible(showOptions);
|
||||
VCurrentDeck.SINGLETON_INSTANCE.getTxfTitle().setVisible(showOptions);
|
||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnImport().setVisible(showOptions);
|
||||
VCurrentDeck.SINGLETON_INSTANCE.getLblTitle().setText(title);
|
||||
|
||||
this.controller.notifyModelChanged();
|
||||
this.controller.updateCaptions();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,8 +30,6 @@ import forge.card.CardRulesPredicates;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckSection;
|
||||
import forge.gui.deckeditor.SEditorIO;
|
||||
import forge.gui.deckeditor.views.VCardCatalog;
|
||||
import forge.gui.deckeditor.views.VCurrentDeck;
|
||||
import forge.gui.framework.FScreen;
|
||||
import forge.gui.toolbox.itemmanager.CardManager;
|
||||
import forge.gui.toolbox.itemmanager.SItemManagerIO;
|
||||
@@ -57,14 +55,8 @@ import forge.util.ItemPoolView;
|
||||
*/
|
||||
public final class CEditorConstructed extends ACEditorBase<PaperCard, Deck> {
|
||||
private final DeckController<Deck> controller;
|
||||
//private boolean sideboardMode = false;
|
||||
|
||||
private List<DeckSection> allSections = new ArrayList<DeckSection>();
|
||||
private DeckSection sectionMode = DeckSection.Main;
|
||||
|
||||
private final ItemPoolView<PaperCard> avatarPool;
|
||||
private final ItemPoolView<PaperCard> planePool;
|
||||
private final ItemPoolView<PaperCard> schemePool;
|
||||
private final List<DeckSection> allSections = new ArrayList<DeckSection>();
|
||||
private final ItemPoolView<PaperCard> normalPool, avatarPool, planePool, schemePool;
|
||||
|
||||
//=========== Constructor
|
||||
/**
|
||||
@@ -82,6 +74,7 @@ public final class CEditorConstructed extends ACEditorBase<PaperCard, Deck> {
|
||||
allSections.add(DeckSection.Planes);
|
||||
//allSections.add(DeckSection.Commander);
|
||||
|
||||
normalPool = ItemPool.createFrom(Singletons.getMagicDb().getCommonCards().getAllCards(), PaperCard.class);
|
||||
avatarPool = ItemPool.createFrom(Singletons.getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_VANGUARD, PaperCard.FN_GET_RULES)),PaperCard.class);
|
||||
planePool = ItemPool.createFrom(Singletons.getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_PLANE_OR_PHENOMENON, PaperCard.FN_GET_RULES)),PaperCard.class);
|
||||
schemePool = ItemPool.createFrom(Singletons.getMagicDb().getVariantCards().getAllCards(Predicates.compose(CardRulesPredicates.Presets.IS_SCHEME, PaperCard.FN_GET_RULES)),PaperCard.class);
|
||||
@@ -176,7 +169,8 @@ public final class CEditorConstructed extends ACEditorBase<PaperCard, Deck> {
|
||||
@Override
|
||||
public void resetTables() {
|
||||
// Constructed mode can use all cards, no limitations.
|
||||
this.getCatalogManager().setPool(ItemPool.createFrom(Singletons.getMagicDb().getCommonCards().getAllCards(), PaperCard.class), true);
|
||||
this.sectionMode = DeckSection.Main;
|
||||
this.getCatalogManager().setPool(normalPool, true);
|
||||
this.getDeckManager().setPool(this.controller.getModel().getMain());
|
||||
}
|
||||
|
||||
@@ -201,26 +195,18 @@ public final class CEditorConstructed extends ACEditorBase<PaperCard, Deck> {
|
||||
|
||||
final List<TableColumnInfo<InventoryItem>> lstCatalogCols = SColumnUtil.getCatalogDefaultColumns();
|
||||
|
||||
String title = "";
|
||||
String tabtext = "";
|
||||
Boolean showOptions = true;
|
||||
switch(sectionMode) {
|
||||
case Main:
|
||||
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
||||
this.getCatalogManager().getTable().setAvailableColumns(lstCatalogCols);
|
||||
this.getCatalogManager().setPool(ItemPool.createFrom(Singletons.getMagicDb().getCommonCards().getAllCards(), PaperCard.class), true);
|
||||
this.getCatalogManager().setPool(normalPool, true);
|
||||
this.getDeckManager().setPool(this.controller.getModel().getMain());
|
||||
showOptions = true;
|
||||
title = "Title: ";
|
||||
tabtext = "Main Deck";
|
||||
break;
|
||||
case Sideboard:
|
||||
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
||||
this.getCatalogManager().getTable().setAvailableColumns(lstCatalogCols);
|
||||
this.getCatalogManager().setPool(this.controller.getModel().getMain());
|
||||
this.getCatalogManager().setPool(normalPool, true);
|
||||
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Sideboard));
|
||||
showOptions = false;
|
||||
title = "Sideboard";
|
||||
tabtext = "Card Catalog";
|
||||
break;
|
||||
case Avatar:
|
||||
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
||||
@@ -232,9 +218,6 @@ public final class CEditorConstructed extends ACEditorBase<PaperCard, Deck> {
|
||||
this.getCatalogManager().getTable().setAvailableColumns(lstCatalogCols);
|
||||
this.getCatalogManager().setPool(avatarPool, true);
|
||||
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Avatar));
|
||||
showOptions = false;
|
||||
title = "Vanguard";
|
||||
tabtext = "Card Catalog";
|
||||
break;
|
||||
case Planes:
|
||||
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
||||
@@ -246,9 +229,6 @@ public final class CEditorConstructed extends ACEditorBase<PaperCard, Deck> {
|
||||
this.getCatalogManager().getTable().setAvailableColumns(lstCatalogCols);
|
||||
this.getCatalogManager().setPool(planePool,true);
|
||||
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Planes));
|
||||
showOptions = false;
|
||||
title = "Planar";
|
||||
tabtext = "Card Catalog";
|
||||
break;
|
||||
case Schemes:
|
||||
lstCatalogCols.remove(SColumnUtil.getColumn(ColumnName.CAT_QUANTITY));
|
||||
@@ -260,25 +240,12 @@ public final class CEditorConstructed extends ACEditorBase<PaperCard, Deck> {
|
||||
this.getCatalogManager().getTable().setAvailableColumns(lstCatalogCols);
|
||||
this.getCatalogManager().setPool(schemePool,true);
|
||||
this.getDeckManager().setPool(this.controller.getModel().getOrCreate(DeckSection.Schemes));
|
||||
showOptions = false;
|
||||
title = "Scheme";
|
||||
tabtext = "Card Catalog";
|
||||
break;
|
||||
case Commander:
|
||||
break; //do nothing for Commander here
|
||||
}
|
||||
|
||||
VCardCatalog.SINGLETON_INSTANCE.getTabLabel().setText(tabtext);
|
||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnNew().setVisible(showOptions);
|
||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnOpen().setVisible(showOptions);
|
||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnSave().setVisible(showOptions);
|
||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnSaveAs().setVisible(showOptions);
|
||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnPrintProxies().setVisible(showOptions);
|
||||
VCurrentDeck.SINGLETON_INSTANCE.getTxfTitle().setVisible(showOptions);
|
||||
VCurrentDeck.SINGLETON_INSTANCE.getBtnImport().setVisible(showOptions);
|
||||
VCurrentDeck.SINGLETON_INSTANCE.getLblTitle().setText(title);
|
||||
|
||||
this.controller.notifyModelChanged();
|
||||
this.controller.updateCaptions();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -33,15 +33,8 @@ import forge.util.storage.IStorage;
|
||||
*
|
||||
* @param <T> the generic type
|
||||
*/
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public class DeckController<T extends DeckBase> {
|
||||
|
||||
private T model;
|
||||
private String modelName;
|
||||
private boolean saved;
|
||||
private boolean modelInStore;
|
||||
private final IStorage<T> folder;
|
||||
@@ -60,7 +53,6 @@ public class DeckController<T extends DeckBase> {
|
||||
this.folder = folder0;
|
||||
this.view = view0;
|
||||
this.model = null;
|
||||
this.modelName = null;
|
||||
this.saved = true;
|
||||
this.modelInStore = false;
|
||||
this.newModelCreator = newModelCreator0;
|
||||
@@ -78,22 +70,13 @@ public class DeckController<T extends DeckBase> {
|
||||
/**
|
||||
* Sets the model.
|
||||
*
|
||||
* @param document the new model
|
||||
*/
|
||||
public void setModel(final T document) {
|
||||
this.setModel(document, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the model.
|
||||
*
|
||||
* @param document the document
|
||||
* @param isStored the is stored
|
||||
*/
|
||||
public void setModel(final T document, final boolean isStored) {
|
||||
this.modelInStore = isStored;
|
||||
this.model = document;
|
||||
this.modelName = document.getName();
|
||||
this.view.resetTables();
|
||||
|
||||
CStatistics.SINGLETON_INSTANCE.update();
|
||||
@@ -101,7 +84,8 @@ public class DeckController<T extends DeckBase> {
|
||||
|
||||
if (this.isModelInSyncWithFolder()) {
|
||||
_setSaved(true);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.notifyModelChanged();
|
||||
}
|
||||
}
|
||||
@@ -116,7 +100,7 @@ public class DeckController<T extends DeckBase> {
|
||||
if (modelStored == this.model) {
|
||||
return true;
|
||||
}
|
||||
if (null == modelStored) {
|
||||
if (modelStored == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -132,11 +116,6 @@ public class DeckController<T extends DeckBase> {
|
||||
return this.view;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see forge.gui.deckeditor.IDeckController#notifyModelChanged()
|
||||
*/
|
||||
/**
|
||||
* Notify model changed.
|
||||
*/
|
||||
@@ -148,12 +127,7 @@ public class DeckController<T extends DeckBase> {
|
||||
saved = val;
|
||||
updateCaptions();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see forge.gui.deckeditor.IDeckController#getSavedModelNames()
|
||||
*/
|
||||
|
||||
/**
|
||||
* Gets the saved names.
|
||||
*
|
||||
@@ -163,11 +137,6 @@ public class DeckController<T extends DeckBase> {
|
||||
return new ArrayList<String>(this.folder.getItemNames());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see forge.gui.deckeditor.IDeckController#load(java.lang.String)
|
||||
*/
|
||||
/**
|
||||
* Load.
|
||||
*
|
||||
@@ -176,38 +145,30 @@ public class DeckController<T extends DeckBase> {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void load(final String name) {
|
||||
T newModel = this.folder.get(name);
|
||||
if (null != newModel) {
|
||||
if (newModel != null) {
|
||||
this.setModel((T) newModel.copyTo(name), true);
|
||||
}
|
||||
_setSaved(true);
|
||||
else {
|
||||
_setSaved(true);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see forge.gui.deckeditor.IDeckController#save()
|
||||
*/
|
||||
/**
|
||||
* Save.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void save() {
|
||||
if (null == model) {
|
||||
if (model == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.folder.add(this.model);
|
||||
// copy to new instance which will be edited and left if unsaved
|
||||
this.setModel((T) this.model.copyTo(this.model.getName()), true);
|
||||
this.model = (T)this.model.copyTo(this.model.getName());
|
||||
this.modelInStore = true;
|
||||
_setSaved(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see forge.gui.deckeditor.IDeckController#rename(java.lang.String)
|
||||
*/
|
||||
/**
|
||||
* Save as.
|
||||
*
|
||||
@@ -215,16 +176,11 @@ public class DeckController<T extends DeckBase> {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void saveAs(final String name0) {
|
||||
this.setModel((T) this.model.copyTo(name0), false);
|
||||
this.model = (T)this.model.copyTo(name0);
|
||||
this.modelInStore = false;
|
||||
this.save();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see forge.gui.deckeditor.IDeckController#isSaved()
|
||||
*/
|
||||
|
||||
/**
|
||||
* Checks if is saved.
|
||||
*
|
||||
@@ -234,12 +190,6 @@ public class DeckController<T extends DeckBase> {
|
||||
return this.saved;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see forge.gui.deckeditor.IDeckController#delete()
|
||||
*/
|
||||
|
||||
/**
|
||||
* Delete.
|
||||
*/
|
||||
@@ -251,12 +201,6 @@ public class DeckController<T extends DeckBase> {
|
||||
this.newModel();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see forge.gui.deckeditor.IDeckController#isGoodName(java.lang.String)
|
||||
*/
|
||||
|
||||
/**
|
||||
* File exists.
|
||||
*
|
||||
@@ -267,12 +211,6 @@ public class DeckController<T extends DeckBase> {
|
||||
return this.folder.contains(deckName);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see forge.gui.deckeditor.IDeckController#importDeck(forge.deck.Deck)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Import deck.
|
||||
*
|
||||
@@ -282,12 +220,6 @@ public class DeckController<T extends DeckBase> {
|
||||
this.setModel(newDeck);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see forge.gui.deckeditor.IDeckController#isModelInStore()
|
||||
*/
|
||||
|
||||
/**
|
||||
* Checks if is model in store.
|
||||
*
|
||||
@@ -319,17 +251,20 @@ public class DeckController<T extends DeckBase> {
|
||||
}
|
||||
|
||||
public String getModelName() {
|
||||
return modelName;
|
||||
return this.model != null ? this.model.getName() : "";
|
||||
}
|
||||
|
||||
private void updateCaptions() {
|
||||
|
||||
public void updateCaptions() {
|
||||
String tabCaption = "Current Deck";
|
||||
String title = this.model.getName();
|
||||
String itemManagerCaption = title.isEmpty() ? "[Untitled]" : title;
|
||||
|
||||
if (!saved) {
|
||||
tabCaption = "*" + tabCaption;
|
||||
itemManagerCaption = "*" + itemManagerCaption;
|
||||
}
|
||||
itemManagerCaption += " - " + this.view.getSectionMode().name();
|
||||
|
||||
VCurrentDeck.SINGLETON_INSTANCE.getTabLabel().setText(tabCaption);
|
||||
VCurrentDeck.SINGLETON_INSTANCE.getTxfTitle().setText(title);
|
||||
VCurrentDeck.SINGLETON_INSTANCE.getItemManager().setCaption(itemManagerCaption);
|
||||
|
||||
Reference in New Issue
Block a user