mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +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)
|
// Adding a generic to this class creates compile problems in ItemManager (that I can not fix)
|
||||||
public class DeckProxy implements InventoryItem {
|
public class DeckProxy implements InventoryItem {
|
||||||
protected final IHasName deck;
|
protected IHasName deck;
|
||||||
protected final IStorage<?> storage;
|
protected final IStorage<? extends IHasName> storage;
|
||||||
|
|
||||||
public static final Function<DeckProxy, String> FN_GET_NAME = new Function<DeckProxy, String>() {
|
public static final Function<DeckProxy, String> FN_GET_NAME = new Function<DeckProxy, String>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -48,15 +48,15 @@ public class DeckProxy implements InventoryItem {
|
|||||||
private final String path;
|
private final String path;
|
||||||
private final Function<IHasName, Deck> fnGetDeck;
|
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);
|
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);
|
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.deck = deck;
|
||||||
this.storage = storage;
|
this.storage = storage;
|
||||||
this.path = path;
|
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")
|
@SuppressWarnings("unchecked")
|
||||||
public void updateInStorage() {
|
public void updateInStorage() {
|
||||||
if ( storage instanceof StorageImmediatelySerialized<?> )
|
if ( storage instanceof StorageImmediatelySerialized<?> )
|
||||||
|
|||||||
@@ -232,15 +232,6 @@ public class DeckController<T extends DeckBase> {
|
|||||||
this.setModel(newDeck);
|
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
|
* Refresh current model or create new one if none
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user