forked from External/mage
check for new card images when client starts
This commit is contained in:
parent
0ce1b4b918
commit
f9cb39ea7e
6 changed files with 51 additions and 1 deletions
|
|
@ -286,6 +286,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
disableButtons();
|
||||
checkForNewImages();
|
||||
if (autoConnect())
|
||||
enableButtons();
|
||||
else {
|
||||
|
|
@ -424,6 +425,17 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
menu.show(component, 0, component.getHeight());
|
||||
}
|
||||
|
||||
private void checkForNewImages() {
|
||||
HashSet<Card> cards = new HashSet<Card>(CardsStorage.getAllCards());
|
||||
List<Card> notImplemented = CardsStorage.getNotImplementedCards();
|
||||
cards.addAll(notImplemented);
|
||||
if (Plugins.getInstance().newImage(cards)) {
|
||||
if (JOptionPane.showConfirmDialog(null, "New cards are available. Do you want to download the images?") == JOptionPane.OK_OPTION) {
|
||||
Plugins.getInstance().downloadImage(cards);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btnImagesActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
HashSet<Card> cards = new HashSet<Card>(CardsStorage.getAllCards());
|
||||
List<Card> notImplemented = CardsStorage.getNotImplementedCards();
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ public interface MagePlugins {
|
|||
boolean isCardPluginLoaded();
|
||||
boolean isCounterPluginLoaded();
|
||||
void sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> permanents);
|
||||
boolean newImage(Set<Card> allCards);
|
||||
void downloadImage(Set<Card> allCards);
|
||||
void downloadSymbols();
|
||||
int getGamesPlayed();
|
||||
|
|
|
|||
|
|
@ -110,6 +110,13 @@ public class Plugins implements MagePlugins {
|
|||
if (this.cardPlugin != null) this.cardPlugin.sortPermanents(ui, permanents, sortingOptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean newImage(Set<mage.cards.Card> allCards) {
|
||||
String useDefault = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_USE_DEFAULT, "true");
|
||||
String path = useDefault.equals("true") ? null : PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_PATH, null);
|
||||
return this.cardPlugin.newImages(allCards, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadImage(Set<mage.cards.Card> allCards) {
|
||||
String useDefault = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_USE_DEFAULT, "true");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue