mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-14 09:48:02 +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,
|
||||
|
||||
@@ -994,6 +994,8 @@ lblEnableUnknownCards=Erlaube unbekannte Karten
|
||||
nlEnableUnknownCards=Erlaube unbekannte Karten von unbekannten Sets. (Erfordert Neustart)
|
||||
lblExperimentalNetworkCompatibility=Experimentelle Netzwerkkompatibilität
|
||||
nlExperimentalNetworkCompatibility=Forge wechselt auf kompatiblen Netzwerk-Stream. (Im Zweifel bitte ausschalten)
|
||||
lblAutoCacheSize=Enable Auto Cache Size
|
||||
nlAutoCacheSize=When enabled, Cache size are automatically determined on startup. (If unsure, turn OFF this option)
|
||||
#MatchScreen.java
|
||||
lblPlayers=Spieler
|
||||
lblLog=Bericht
|
||||
|
||||
@@ -994,6 +994,8 @@ lblEnableUnknownCards=Enable Unknown Cards
|
||||
nlEnableUnknownCards=Enable Unknown Cards to be loaded to Unknown Set. (Requires restart)
|
||||
lblExperimentalNetworkCompatibility=Experimental Network Compatibility
|
||||
nlExperimentalNetworkCompatibility=Forge switches to compatible network stream. (If unsure, turn OFF this option)
|
||||
lblAutoCacheSize=Enable Auto Cache Size
|
||||
nlAutoCacheSize=When enabled, Cache size are automatically determined on startup. (If unsure, turn OFF this option)
|
||||
#MatchScreen.java
|
||||
lblPlayers=Players
|
||||
lblLog=Log
|
||||
|
||||
@@ -994,6 +994,8 @@ lblEnableUnknownCards=Habilitar Cartas Desconocidas
|
||||
nlEnableUnknownCards=Habilitar que las cartas desconocidas se carguen en el Unknown Set. (Requiere reinicio)
|
||||
lblExperimentalNetworkCompatibility=Compatibilidad de red experimental
|
||||
nlExperimentalNetworkCompatibility=Forge cambia a un flujo de red compatible. (Si no estás seguro, deshabilita esta opción)
|
||||
lblAutoCacheSize=Enable Auto Cache Size
|
||||
nlAutoCacheSize=When enabled, Cache size are automatically determined on startup. (If unsure, turn OFF this option)
|
||||
#MatchScreen.java
|
||||
lblPlayers=Jugadores
|
||||
lblLog=Log
|
||||
|
||||
@@ -994,6 +994,8 @@ lblEnableUnknownCards=Enable Unknown Cards
|
||||
nlEnableUnknownCards=Enable Unknown Cards to be loaded to Unknown Set. (Requires restart)
|
||||
lblExperimentalNetworkCompatibility=Experimental Network Compatibility
|
||||
nlExperimentalNetworkCompatibility=Forge switches to compatible network stream. (If unsure, turn OFF this option)
|
||||
lblAutoCacheSize=Enable Auto Cache Size
|
||||
nlAutoCacheSize=When enabled, Cache size are automatically determined on startup. (If unsure, turn OFF this option)
|
||||
#MatchScreen.java
|
||||
lblPlayers=Giocatori
|
||||
lblLog=Login
|
||||
|
||||
@@ -994,6 +994,8 @@ lblEnableUnknownCards=启用未知卡牌
|
||||
nlEnableUnknownCards=将未知卡牌加载到未知系列中。(需要重启)
|
||||
lblExperimentalNetworkCompatibility=实验性网络兼容
|
||||
nlExperimentalNetworkCompatibility=Forge将切换为兼容性的网络流。(如果不清楚,请关闭此选项)
|
||||
lblAutoCacheSize=Enable Auto Cache Size
|
||||
nlAutoCacheSize=When enabled, Cache size are automatically determined on startup. (If unsure, turn OFF this option)
|
||||
#MatchScreen.java
|
||||
lblPlayers=玩家列表
|
||||
lblLog=日志
|
||||
|
||||
@@ -144,6 +144,7 @@ public class ForgePreferences extends PreferencesStore<ForgePreferences.FPref> {
|
||||
UI_SHOW_FPS("false"),
|
||||
UI_NETPLAY_COMPAT("false"),
|
||||
UI_LOAD_UNKNOWN_CARDS("true"),
|
||||
UI_AUTO_CACHE_SIZE("false"),
|
||||
UI_ALLOW_ORDER_GRAVEYARD_WHEN_NEEDED ("Never"),
|
||||
UI_DEFAULT_FONT_SIZE("12"),
|
||||
UI_SELECT_FROM_CARD_DISPLAYS("true"),
|
||||
|
||||
Reference in New Issue
Block a user