mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Minor Performance
- Clear image cache if necessary (prevent clearing if the downloaded data is not image) - Cache missing cards (prevent finding missing cards unless the user has fetched/downloads an image) - Clear preselected options for New Gauntlet Match (easier to filter decks for Gauntlet)
This commit is contained in:
@@ -66,6 +66,10 @@ public final class ImageKeys {
|
||||
}
|
||||
|
||||
private static final Map<String, File> cachedCards = new HashMap<>(50000);
|
||||
private static HashSet<String> missingCards = new HashSet<>();
|
||||
public static void clearMissingCards() {
|
||||
missingCards.clear();
|
||||
}
|
||||
public static File getCachedCardsFile(String key) {
|
||||
return cachedCards.get(key);
|
||||
}
|
||||
@@ -101,6 +105,9 @@ public final class ImageKeys {
|
||||
dir = CACHE_CARD_PICS_DIR;
|
||||
}
|
||||
|
||||
if (missingCards.contains(filename))
|
||||
return null;
|
||||
|
||||
File cachedFile = cachedCards.get(filename);
|
||||
if (cachedFile != null) {
|
||||
return cachedFile;
|
||||
@@ -237,6 +244,8 @@ public final class ImageKeys {
|
||||
}
|
||||
|
||||
// System.out.println("File not found, no image created: " + key);
|
||||
//add missing cards
|
||||
missingCards.add(filename);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -290,6 +290,7 @@ public class GuiDesktop implements IGuiBase {
|
||||
@Override
|
||||
public void clearImageCache() {
|
||||
ImageCache.clear();
|
||||
ImageKeys.clearMissingCards();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -96,6 +96,7 @@ public class ImageCache {
|
||||
public static void clear() {
|
||||
_CACHE.invalidateAll();
|
||||
_missingIconKeys.clear();
|
||||
ImageKeys.clearMissingCards();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -288,6 +288,7 @@ public class GuiMobile implements IGuiBase {
|
||||
@Override
|
||||
public void clearImageCache() {
|
||||
ImageCache.clear();
|
||||
ImageKeys.clearMissingCards();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -113,6 +113,7 @@ public class ImageCache {
|
||||
|
||||
public static void clear() {
|
||||
missingIconKeys.clear();
|
||||
ImageKeys.clearMissingCards();
|
||||
}
|
||||
|
||||
public static void disposeTexture(){
|
||||
|
||||
@@ -113,7 +113,7 @@ public class NewGauntletScreen extends LaunchScreen {
|
||||
});
|
||||
}
|
||||
});
|
||||
chooser.show(null, true);
|
||||
chooser.show(null, false); /*setting selectMax to true will select all available option*/
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -63,12 +63,14 @@ public abstract class GuiDownloadService implements Runnable {
|
||||
private IButton btnStart;
|
||||
private UiCommand cmdClose;
|
||||
private Runnable onUpdate;
|
||||
private boolean clearImageCache = false;
|
||||
|
||||
private final UiCommand cmdStartDownload = new UiCommand() {
|
||||
@Override
|
||||
public void run() {
|
||||
//invalidate image cache so newly downloaded images will be loaded
|
||||
GuiBase.getInterface().clearImageCache();
|
||||
if (clearImageCache)
|
||||
GuiBase.getInterface().clearImageCache();
|
||||
FThreads.invokeInBackgroundThread(GuiDownloadService.this);
|
||||
btnStart.setEnabled(false);
|
||||
}
|
||||
@@ -95,6 +97,7 @@ public abstract class GuiDownloadService implements Runnable {
|
||||
btnStart = btnStart0;
|
||||
cmdClose = cmdClose0;
|
||||
onUpdate = onUpdate0;
|
||||
clearImageCache = txtAddress0.getText().contains(".jpg") || txtAddress0.getText().contains(".png");
|
||||
|
||||
String startOverrideDesc = getStartOverrideDesc();
|
||||
if (startOverrideDesc == null) {
|
||||
|
||||
Reference in New Issue
Block a user