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) {
|
||||
boolean isStored;
|
||||
if (view.getCatalogManager().isInfinite()) {
|
||||
Deck currentDeck = view.getHumanDeck();
|
||||
if (substituteCurrentDeck || currentDeck.isEmpty()) {
|
||||
newModel();
|
||||
}
|
||||
isStored = false;
|
||||
} else
|
||||
isStored = !this.modelPath.equals("");
|
||||
} else {
|
||||
CardPool catalogClone = new CardPool(view.getInitialCatalog());
|
||||
deck = pickFromCatalog(deck, catalogClone);
|
||||
ItemPool<PaperCard> catalogPool = view.getCatalogManager().getPool();
|
||||
catalogPool.clear();
|
||||
catalogPool.addAll(catalogClone);
|
||||
isStored = false;
|
||||
}
|
||||
|
||||
Deck currentDeck = view.getHumanDeck();
|
||||
@@ -112,9 +116,9 @@ public class DeckController<T extends DeckBase> {
|
||||
}
|
||||
}
|
||||
// Allow to specify the name of Deck in DeckImporter
|
||||
if ((deck.hasName()) && (!currentDeck.hasName()))
|
||||
view.getHumanDeck().setName(deck.getName());
|
||||
onModelChanged(false);
|
||||
if (deck.hasName())
|
||||
currentDeck.setName(deck.getName());
|
||||
this.setModel((T) currentDeck, isStored);
|
||||
}
|
||||
|
||||
private Deck pickFromCatalog(Deck deck, CardPool catalog) {
|
||||
@@ -237,7 +241,7 @@ public class DeckController<T extends DeckBase> {
|
||||
} else { //TODO: Make this smarter
|
||||
currentFolder = rootFolder;
|
||||
modelPath = "";
|
||||
setSaved(true);
|
||||
setSaved(this.model.isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user