mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
added a method to reload a proxied object from storage (call this method after the object has been changed in deck editor)
This commit is contained in:
@@ -30,8 +30,8 @@ import forge.util.storage.StorageImmediatelySerialized;
|
||||
|
||||
// Adding a generic to this class creates compile problems in ItemManager (that I can not fix)
|
||||
public class DeckProxy implements InventoryItem {
|
||||
protected final IHasName deck;
|
||||
protected final IStorage<?> storage;
|
||||
protected IHasName deck;
|
||||
protected final IStorage<? extends IHasName> storage;
|
||||
|
||||
public static final Function<DeckProxy, String> FN_GET_NAME = new Function<DeckProxy, String>() {
|
||||
@Override
|
||||
@@ -48,15 +48,15 @@ public class DeckProxy implements InventoryItem {
|
||||
private final String path;
|
||||
private final Function<IHasName, Deck> fnGetDeck;
|
||||
|
||||
public DeckProxy(Deck deck, GameType type, IStorage<?> storage) {
|
||||
public DeckProxy(Deck deck, GameType type, IStorage<? extends IHasName> storage) {
|
||||
this(deck, type, null, storage, null);
|
||||
}
|
||||
|
||||
public DeckProxy(IHasName deck, Function<IHasName, Deck> fnGetDeck, GameType type, IStorage<?> storage) {
|
||||
public DeckProxy(IHasName deck, Function<IHasName, Deck> fnGetDeck, GameType type, IStorage<? extends IHasName> storage) {
|
||||
this(deck, type, null, storage, fnGetDeck);
|
||||
}
|
||||
|
||||
private DeckProxy(IHasName deck, GameType type, String path, IStorage<?> storage, Function<IHasName, Deck> fnGetDeck) {
|
||||
private DeckProxy(IHasName deck, GameType type, String path, IStorage<? extends IHasName> storage, Function<IHasName, Deck> fnGetDeck) {
|
||||
this.deck = deck;
|
||||
this.storage = storage;
|
||||
this.path = path;
|
||||
@@ -178,6 +178,12 @@ public class DeckProxy implements InventoryItem {
|
||||
};
|
||||
}
|
||||
|
||||
public void reloadFromStorage() {
|
||||
if( null != storage )
|
||||
deck = storage.get(getName());
|
||||
invalidateCache();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void updateInStorage() {
|
||||
if ( storage instanceof StorageImmediatelySerialized<?> )
|
||||
|
||||
@@ -232,15 +232,6 @@ public class DeckController<T extends DeckBase> {
|
||||
this.setModel(newDeck);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is model in store.
|
||||
*
|
||||
* @return true, if is model in store
|
||||
*/
|
||||
public boolean isModelInStore() {
|
||||
return this.modelInStorage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh current model or create new one if none
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user