mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Better control on Deck save and editor state set + FIX set deck name
the loadDeck method now has a better handling of the deck (model) status, also wrt. the state of the UI editor. If the deck is Stored, the editor will be in "modified - not saved" state.
This commit is contained in:
@@ -91,17 +91,21 @@ public class DeckController<T extends DeckBase> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadDeck(Deck deck, boolean substituteCurrentDeck) {
|
public void loadDeck(Deck deck, boolean substituteCurrentDeck) {
|
||||||
|
boolean isStored;
|
||||||
if (view.getCatalogManager().isInfinite()) {
|
if (view.getCatalogManager().isInfinite()) {
|
||||||
Deck currentDeck = view.getHumanDeck();
|
Deck currentDeck = view.getHumanDeck();
|
||||||
if (substituteCurrentDeck || currentDeck.isEmpty()) {
|
if (substituteCurrentDeck || currentDeck.isEmpty()) {
|
||||||
newModel();
|
newModel();
|
||||||
}
|
isStored = false;
|
||||||
|
} else
|
||||||
|
isStored = !this.modelPath.equals("");
|
||||||
} else {
|
} else {
|
||||||
CardPool catalogClone = new CardPool(view.getInitialCatalog());
|
CardPool catalogClone = new CardPool(view.getInitialCatalog());
|
||||||
deck = pickFromCatalog(deck, catalogClone);
|
deck = pickFromCatalog(deck, catalogClone);
|
||||||
ItemPool<PaperCard> catalogPool = view.getCatalogManager().getPool();
|
ItemPool<PaperCard> catalogPool = view.getCatalogManager().getPool();
|
||||||
catalogPool.clear();
|
catalogPool.clear();
|
||||||
catalogPool.addAll(catalogClone);
|
catalogPool.addAll(catalogClone);
|
||||||
|
isStored = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Deck currentDeck = view.getHumanDeck();
|
Deck currentDeck = view.getHumanDeck();
|
||||||
@@ -112,9 +116,9 @@ public class DeckController<T extends DeckBase> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Allow to specify the name of Deck in DeckImporter
|
// Allow to specify the name of Deck in DeckImporter
|
||||||
if ((deck.hasName()) && (!currentDeck.hasName()))
|
if (deck.hasName())
|
||||||
view.getHumanDeck().setName(deck.getName());
|
currentDeck.setName(deck.getName());
|
||||||
onModelChanged(false);
|
this.setModel((T) currentDeck, isStored);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Deck pickFromCatalog(Deck deck, CardPool catalog) {
|
private Deck pickFromCatalog(Deck deck, CardPool catalog) {
|
||||||
@@ -237,7 +241,7 @@ public class DeckController<T extends DeckBase> {
|
|||||||
} else { //TODO: Make this smarter
|
} else { //TODO: Make this smarter
|
||||||
currentFolder = rootFolder;
|
currentFolder = rootFolder;
|
||||||
modelPath = "";
|
modelPath = "";
|
||||||
setSaved(true);
|
setSaved(this.model.isEmpty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user