mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
-[Android] Option for Auto Cache size
This commit is contained in:
@@ -76,6 +76,7 @@ public class Forge implements ApplicationListener {
|
||||
public static int cacheSize = 400;
|
||||
public static int totalDeviceRAM = 0;
|
||||
public static int androidVersion = 0;
|
||||
public static boolean autoCache = false;
|
||||
|
||||
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value, boolean androidOrientation, int totalRAM, boolean isTablet, int AndroidVersion) {
|
||||
if (GuiBase.getInterface() == null) {
|
||||
@@ -87,9 +88,6 @@ public class Forge implements ApplicationListener {
|
||||
totalDeviceRAM = totalRAM;
|
||||
isTabletDevice = isTablet;
|
||||
androidVersion = AndroidVersion;
|
||||
//increase cacheSize for devices with RAM more than 5GB, default is 400. Some phones have more than 10GB RAM (Mi 10, OnePlus 8, S20, etc..)
|
||||
if (totalDeviceRAM>5000) //devices with more than 10GB RAM will have 1000 Cache size, 700 Cache size for morethan 5GB RAM
|
||||
cacheSize = totalDeviceRAM>10000 ? 1000: 700;
|
||||
}
|
||||
return app;
|
||||
}
|
||||
@@ -103,6 +101,7 @@ public class Forge implements ApplicationListener {
|
||||
ExceptionHandler.registerErrorHandling();
|
||||
|
||||
GuiBase.setIsAndroid(Gdx.app.getType() == Application.ApplicationType.Android);
|
||||
|
||||
graphics = new Graphics();
|
||||
splashScreen = new SplashScreen();
|
||||
frameRate = new FrameRate();
|
||||
@@ -132,6 +131,13 @@ public class Forge implements ApplicationListener {
|
||||
enableUIMask = prefs.getPrefBoolean(FPref.UI_ENABLE_BORDER_MASKING);
|
||||
enablePreloadExtendedArt = prefs.getPrefBoolean(FPref.UI_ENABLE_PRELOAD_EXTENDED_ART);
|
||||
locale = prefs.getPref(FPref.UI_LANGUAGE);
|
||||
autoCache = prefs.getPrefBoolean(FPref.UI_AUTO_CACHE_SIZE);
|
||||
|
||||
if (autoCache) {
|
||||
//increase cacheSize for devices with RAM more than 5GB, default is 400. Some phones have more than 10GB RAM (Mi 10, OnePlus 8, S20, etc..)
|
||||
if (totalDeviceRAM>5000) //devices with more than 10GB RAM will have 1000 Cache size, 700 Cache size for morethan 5GB RAM
|
||||
cacheSize = totalDeviceRAM>10000 ? 1000: 700;
|
||||
}
|
||||
|
||||
final Localizer localizer = Localizer.getInstance();
|
||||
|
||||
@@ -155,12 +161,12 @@ public class Forge implements ApplicationListener {
|
||||
|
||||
//add reminder to preload
|
||||
if (enablePreloadExtendedArt) {
|
||||
if(totalDeviceRAM>0)
|
||||
if(autoCache)
|
||||
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblPreloadExtendedArt")+"\nDetected RAM: " +totalDeviceRAM+"MB. Cache size: "+cacheSize);
|
||||
else
|
||||
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblPreloadExtendedArt"));
|
||||
} else {
|
||||
if(totalDeviceRAM>0)
|
||||
if(autoCache)
|
||||
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblFinishingStartup")+"\nDetected RAM: " +totalDeviceRAM+"MB. Cache size: "+cacheSize);
|
||||
else
|
||||
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblFinishingStartup"));
|
||||
|
||||
@@ -1023,7 +1023,9 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
g.drawText(item.getName(), GROUP_HEADER_FONT, Color.WHITE, x + PADDING, y + PADDING*2, w - 2 * PADDING, h - 2 * PADDING, true, Align.center, false);
|
||||
} else {
|
||||
if (!dp.isGeneratedDeck()){
|
||||
FImageComplex cardArt = CardRenderer.getCardArt(dp.getHighestCMCCard().getImageKey(false), false, false, false);
|
||||
//If deck has Commander, use it as cardArt reference
|
||||
String deckImageKey = dp.getDeck().getCommanders().isEmpty() ? dp.getHighestCMCCard().getImageKey(false) : dp.getDeck().getCommanders().get(0).getImageKey(false);
|
||||
FImageComplex cardArt = CardRenderer.getCardArt(deckImageKey, false, false, false);
|
||||
//draw the deckbox
|
||||
if (cardArt == null){
|
||||
//draw generic box if null or still loading
|
||||
|
||||
@@ -274,6 +274,29 @@ public class SettingsPage extends TabPage<SettingsScreen> {
|
||||
}
|
||||
},
|
||||
3);
|
||||
if (GuiBase.isAndroid()) { //this option does nothing except on Android
|
||||
lstSettings.addItem(new BooleanSetting(FPref.UI_AUTO_CACHE_SIZE,
|
||||
localizer.getMessage("lblAutoCacheSize"),
|
||||
localizer.getMessage("nlAutoCacheSize")) {
|
||||
@Override
|
||||
public void select() {
|
||||
super.select();
|
||||
FOptionPane.showConfirmDialog(
|
||||
localizer.getMessage("lblRestartForgeDescription"),
|
||||
localizer.getMessage("lblRestartForge"),
|
||||
localizer.getMessage("lblRestart"),
|
||||
localizer.getMessage("lblLater"), new Callback<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean result) {
|
||||
if (result) {
|
||||
Forge.restart(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
3);
|
||||
}
|
||||
|
||||
//Graphic Options
|
||||
lstSettings.addItem(new BooleanSetting(FPref.UI_ENABLE_ONLINE_IMAGE_FETCHER,
|
||||
|
||||
Reference in New Issue
Block a user