mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +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 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) {
|
public static File getCachedCardsFile(String key) {
|
||||||
return cachedCards.get(key);
|
return cachedCards.get(key);
|
||||||
}
|
}
|
||||||
@@ -101,6 +105,9 @@ public final class ImageKeys {
|
|||||||
dir = CACHE_CARD_PICS_DIR;
|
dir = CACHE_CARD_PICS_DIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (missingCards.contains(filename))
|
||||||
|
return null;
|
||||||
|
|
||||||
File cachedFile = cachedCards.get(filename);
|
File cachedFile = cachedCards.get(filename);
|
||||||
if (cachedFile != null) {
|
if (cachedFile != null) {
|
||||||
return cachedFile;
|
return cachedFile;
|
||||||
@@ -237,6 +244,8 @@ public final class ImageKeys {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// System.out.println("File not found, no image created: " + key);
|
// System.out.println("File not found, no image created: " + key);
|
||||||
|
//add missing cards
|
||||||
|
missingCards.add(filename);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -290,6 +290,7 @@ public class GuiDesktop implements IGuiBase {
|
|||||||
@Override
|
@Override
|
||||||
public void clearImageCache() {
|
public void clearImageCache() {
|
||||||
ImageCache.clear();
|
ImageCache.clear();
|
||||||
|
ImageKeys.clearMissingCards();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ public class ImageCache {
|
|||||||
public static void clear() {
|
public static void clear() {
|
||||||
_CACHE.invalidateAll();
|
_CACHE.invalidateAll();
|
||||||
_missingIconKeys.clear();
|
_missingIconKeys.clear();
|
||||||
|
ImageKeys.clearMissingCards();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -288,6 +288,7 @@ public class GuiMobile implements IGuiBase {
|
|||||||
@Override
|
@Override
|
||||||
public void clearImageCache() {
|
public void clearImageCache() {
|
||||||
ImageCache.clear();
|
ImageCache.clear();
|
||||||
|
ImageKeys.clearMissingCards();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ public class ImageCache {
|
|||||||
|
|
||||||
public static void clear() {
|
public static void clear() {
|
||||||
missingIconKeys.clear();
|
missingIconKeys.clear();
|
||||||
|
ImageKeys.clearMissingCards();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void disposeTexture(){
|
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 IButton btnStart;
|
||||||
private UiCommand cmdClose;
|
private UiCommand cmdClose;
|
||||||
private Runnable onUpdate;
|
private Runnable onUpdate;
|
||||||
|
private boolean clearImageCache = false;
|
||||||
|
|
||||||
private final UiCommand cmdStartDownload = new UiCommand() {
|
private final UiCommand cmdStartDownload = new UiCommand() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
//invalidate image cache so newly downloaded images will be loaded
|
//invalidate image cache so newly downloaded images will be loaded
|
||||||
GuiBase.getInterface().clearImageCache();
|
if (clearImageCache)
|
||||||
|
GuiBase.getInterface().clearImageCache();
|
||||||
FThreads.invokeInBackgroundThread(GuiDownloadService.this);
|
FThreads.invokeInBackgroundThread(GuiDownloadService.this);
|
||||||
btnStart.setEnabled(false);
|
btnStart.setEnabled(false);
|
||||||
}
|
}
|
||||||
@@ -95,6 +97,7 @@ public abstract class GuiDownloadService implements Runnable {
|
|||||||
btnStart = btnStart0;
|
btnStart = btnStart0;
|
||||||
cmdClose = cmdClose0;
|
cmdClose = cmdClose0;
|
||||||
onUpdate = onUpdate0;
|
onUpdate = onUpdate0;
|
||||||
|
clearImageCache = txtAddress0.getText().contains(".jpg") || txtAddress0.getText().contains(".png");
|
||||||
|
|
||||||
String startOverrideDesc = getStartOverrideDesc();
|
String startOverrideDesc = getStartOverrideDesc();
|
||||||
if (startOverrideDesc == null) {
|
if (startOverrideDesc == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user