Net Deck Archive Block (Desktop & Android)

This commit is contained in:
Churrufli
2021-03-11 13:06:46 +01:00
parent e36d8d8db3
commit b2634686e6
14 changed files with 1206 additions and 10 deletions

View File

@@ -48,6 +48,7 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
private NetDeckArchiveModern NetDeckArchiveModern;
private NetDeckArchiveLegacy NetDeckArchiveLegacy;
private NetDeckArchiveVintage NetDeckArchiveVintage;
private NetDeckArchiveBlock NetDeckArchiveBlock;
private boolean refreshingDeckType;
private boolean isForCommander;
@@ -303,6 +304,12 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
updateDecks(DeckProxy.getNetArchiveVintageDecks(NetDeckArchiveVintage), ItemManagerConfig.NET_DECKS);
}
private void updateNetArchiveBlockDecks() {
if (NetDeckArchiveBlock != null) {
decksComboBox.setText(NetDeckArchiveBlock.getDeckType());
}
updateDecks(DeckProxy.getNetArchiveBlockecks(NetDeckArchiveBlock), ItemManagerConfig.NET_DECKS);
}
public Deck getDeck() {
final DeckProxy proxy = lstDecks.getSelectedItem();
if (proxy == null) {
@@ -407,7 +414,8 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
NetDeckArchivePioneer = category;
refreshDecksList(ev.getDeckType(), true, ev);
}
}); }
});
}
});
return;
@@ -432,7 +440,8 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
NetDeckArchiveModern = category;
refreshDecksList(ev.getDeckType(), true, ev);
}
}); }
});
}
});
return;
@@ -457,7 +466,8 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
NetDeckArchiveLegacy = category;
refreshDecksList(ev.getDeckType(), true, ev);
}
}); }
});
}
});
return;
@@ -482,10 +492,39 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
NetDeckArchiveVintage = category;
refreshDecksList(ev.getDeckType(), true, ev);
}
}); }
});
}
});
return;
} else if (ev.getDeckType() == DeckType.NET_ARCHIVE_BLOCK_DECK&& !refreshingDeckType) {
if(lstDecks.getGameType() != GameType.Constructed)
return;
FThreads.invokeInBackgroundThread(new Runnable() { //needed for loading net decks
@Override
public void run() {
final NetDeckArchiveBlock category = NetDeckArchiveBlock.selectAndLoad(lstDecks.getGameType());
FThreads.invokeInEdtLater(new Runnable() {
@Override
public void run() {
if (category == null) {
decksComboBox.setDeckType(selectedDeckType); //restore old selection if user cancels
if (selectedDeckType == DeckType.NET_ARCHIVE_BLOCK_DECK && NetDeckArchiveBlock != null) {
decksComboBox.setText(NetDeckArchiveVintage.getDeckType());
}
return;
}
NetDeckArchiveBlock = category;
refreshDecksList(ev.getDeckType(), true, ev);
}
});
}
});
return;
} else if ((ev.getDeckType() == DeckType.NET_DECK || ev.getDeckType() == DeckType.NET_COMMANDER_DECK) && !refreshingDeckType) {
FThreads.invokeInBackgroundThread(new Runnable() { //needed for loading net decks
@Override
@@ -619,6 +658,9 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
case NET_ARCHIVE_VINTAGE_DECK:
updateNetArchiveVintageDecks();
break;
case NET_ARCHIVE_BLOCK_DECK:
updateNetArchiveBlockDecks();
break;
default:
break; //other deck types not currently supported here
}
@@ -651,6 +693,8 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
state.append(NetDeckArchiveLegacy.PREFIX).append(NetDeckArchiveLegacy.getName());
} else if (decksComboBox.getDeckType() == DeckType.NET_ARCHIVE_VINTAGE_DECK) {
state.append(NetDeckArchiveVintage.PREFIX).append(NetDeckArchiveVintage.getName());
} else if (decksComboBox.getDeckType() == DeckType.NET_ARCHIVE_BLOCK_DECK) {
state.append(NetDeckArchiveBlock.PREFIX).append(NetDeckArchiveBlock.getName());
} else if (decksComboBox.getDeckType() == null || decksComboBox.getDeckType() == DeckType.NET_DECK) {
//handle special case of net decks
if (netDeckCategory == null) { return ""; }
@@ -723,6 +767,9 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
} else if (deckType.startsWith(NetDeckArchiveVintage.PREFIX)) {
NetDeckArchiveVintage = NetDeckArchiveVintage.selectAndLoad(lstDecks.getGameType(), deckType.substring(NetDeckArchiveVintage.PREFIX.length()));
return DeckType.NET_ARCHIVE_VINTAGE_DECK;
} else if (deckType.startsWith(NetDeckArchiveBlock.PREFIX)) {
NetDeckArchiveBlock = NetDeckArchiveBlock.selectAndLoad(lstDecks.getGameType(), deckType.substring(NetDeckArchiveBlock.PREFIX.length()));
return DeckType.NET_ARCHIVE_BLOCK_DECK;
}
return DeckType.valueOf(deckType);
}