diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/DownloadServiceInfo.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/DownloadServiceInfo.java index 719d7d21e8..0e5152b315 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/DownloadServiceInfo.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/DownloadServiceInfo.java @@ -16,6 +16,8 @@ public interface DownloadServiceInfo { void updateGlobalMessage(String text); void updateProgressMessage(String text); + + void updateProgressMessage(String text, int progressCurrent, int progressNeed); void showDownloadControls(boolean needToShow); diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallImageSource.java index 388b449ecc..6d5d3c13c8 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallImageSource.java @@ -250,7 +250,11 @@ public enum ScryfallImageSource implements CardImageSource { private void updatePrepareStats(DownloadServiceInfo service, int need, int current) { synchronized (service.getSync()) { - service.updateProgressMessage(String.format("Preparing download list... %d of %d", current, need)); + service.updateProgressMessage( + String.format("Preparing download list... %d of %d", current, need), + current, + need + ); } } diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPicturesService.java b/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPicturesService.java index d47ec13041..47107f7e3d 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPicturesService.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/images/DownloadPicturesService.java @@ -260,7 +260,16 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements @Override public void updateProgressMessage(String text) { + updateProgressMessage(text, 0, 0); + } + + @Override + public void updateProgressMessage(String text, int progressCurrent, int progressNeed) { this.uiDialog.getProgressBar().setString(text); + + // set values to 0 to disable progress bar + this.uiDialog.getProgressBar().setMaximum(progressNeed); + this.uiDialog.getProgressBar().setValue(progressCurrent); } @Override @@ -409,7 +418,7 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements ? "%d of %d (%d cards/%d tokens) image downloads finished! Please close!" : "%d of %d (%d cards/%d tokens) image downloads finished! Please wait! [%.1f Mb]", 0, imageSum, cardCount, tokenCount, mb - )); + ), 0, imageSum); } private static String createDownloadName(CardInfo card) { @@ -989,7 +998,7 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements // downloading float mb = ((needDownloadCount - lastCardIndex) * selectedSource.getAverageSize()) / 1024; updateProgressMessage(String.format("%d of %d image downloads finished! Please wait! [%.1f Mb]", - lastCardIndex, needDownloadCount, mb)); + lastCardIndex, needDownloadCount, mb), lastCardIndex, needDownloadCount); } else { // finished List downloadedCards = Collections.synchronizedList(new ArrayList<>()); diff --git a/Mage.Tests/src/test/java/org/mage/test/sets/BoosterGenerationTest.java b/Mage.Tests/src/test/java/org/mage/test/sets/BoosterGenerationTest.java index 8a84b215ed..db71ade65d 100644 --- a/Mage.Tests/src/test/java/org/mage/test/sets/BoosterGenerationTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/sets/BoosterGenerationTest.java @@ -254,7 +254,7 @@ public class BoosterGenerationTest extends MageTestBase { public void testFallenEmpires_BoosterMustUseVariousArtsButUnique() { // Related issue: https://github.com/magefree/mage/issues/7333 // Actual for default boosters without collation - Set cardNumberPosfixes = new HashSet<>(); + Set cardNumberPostfixes = new HashSet<>(); for (int i = 0; i < 10; i++) { List booster = FallenEmpires.getInstance().createBooster(); @@ -274,15 +274,15 @@ public class BoosterGenerationTest extends MageTestBase { // 123c -> c String postfix = card.getCardNumber().replace(String.valueOf(CardUtil.parseCardNumberAsInt(card.getCardNumber())), ""); if (!postfix.isEmpty()) { - cardNumberPosfixes.add(postfix); + cardNumberPostfixes.add(postfix); } }); } assertTrue("booster must use cards with various arts", - cardNumberPosfixes.contains("a") - && cardNumberPosfixes.contains("b") - && cardNumberPosfixes.contains("c") - && cardNumberPosfixes.contains("d") + cardNumberPostfixes.contains("a") + && cardNumberPostfixes.contains("b") + && cardNumberPostfixes.contains("c") + && cardNumberPostfixes.contains("d") ); }