Support setting directory for newly created decks by adding fullPath to StorageBase

This commit is contained in:
drdev
2015-10-04 21:59:20 +00:00
parent c6d81ed4cd
commit 8c49a7d264
15 changed files with 125 additions and 107 deletions

View File

@@ -66,7 +66,7 @@ public class NetDeckCategory extends StorageBase<Deck> {
NetDeckCategory category = categories.get(name);
if (category != null && category.map.isEmpty()) {
//if name passed in, try to load decks from current cached files
File downloadDir = new File(category.getDownloadLocation());
File downloadDir = new File(category.getFullPath());
if (downloadDir.exists()) {
for (File file : downloadDir.listFiles(DeckStorage.DCK_FILE_FILTER)) {
Deck deck = DeckSerializer.fromFile(file);
@@ -86,7 +86,7 @@ public class NetDeckCategory extends StorageBase<Deck> {
WaitCallback<Boolean> callback = new WaitCallback<Boolean>() {
@Override
public void run() {
String downloadLoc = c.getDownloadLocation();
String downloadLoc = c.getFullPath();
GuiBase.getInterface().download(new GuiDownloadZipService(c.getName(), "decks", c.getUrl(), downloadLoc, downloadLoc, null) {
@Override
protected void copyInputStream(InputStream in, String outPath) throws IOException {
@@ -108,14 +108,10 @@ public class NetDeckCategory extends StorageBase<Deck> {
private final String url;
private NetDeckCategory(String name0, String url0) {
super(name0, new HashMap<String, Deck>());
super(name0, ForgeConstants.DECK_NET_DIR + name0, new HashMap<String, Deck>());
url = url0;
}
public String getDownloadLocation() {
return ForgeConstants.DECK_NET_DIR + name + "/";
}
public String getUrl() {
return url;
}

View File

@@ -24,7 +24,7 @@ import java.util.Map;
public class ConquestDeckMap extends StorageBase<Deck> {
public ConquestDeckMap(Map<String, Deck> in) {
super("Conquest decks", in);
super("Conquest decks", null, in);
}
@Override

View File

@@ -28,12 +28,11 @@ import forge.util.storage.StorageBase;
*
*/
public class QuestDeckGroupMap extends StorageBase<DeckGroup> {
/**
* Instantiates a new quest deck map.
*/
public QuestDeckGroupMap(Map<String, DeckGroup> in) {
super("Quest draft decks", in == null ? new HashMap<String, DeckGroup>() : in);
super("Quest draft decks", null, in == null ? new HashMap<String, DeckGroup>() : in);
}

View File

@@ -27,12 +27,11 @@ import java.util.Map;
*
*/
public class QuestDeckMap extends StorageBase<Deck> {
/**
* Instantiates a new quest deck map.
*/
public QuestDeckMap(Map<String, Deck> in) {
super("Quest decks", in);
super("Quest decks", null, in);
}