mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 02:08:00 +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 cacheSize = 400;
|
||||||
public static int totalDeviceRAM = 0;
|
public static int totalDeviceRAM = 0;
|
||||||
public static int androidVersion = 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) {
|
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value, boolean androidOrientation, int totalRAM, boolean isTablet, int AndroidVersion) {
|
||||||
if (GuiBase.getInterface() == null) {
|
if (GuiBase.getInterface() == null) {
|
||||||
@@ -87,9 +88,6 @@ public class Forge implements ApplicationListener {
|
|||||||
totalDeviceRAM = totalRAM;
|
totalDeviceRAM = totalRAM;
|
||||||
isTabletDevice = isTablet;
|
isTabletDevice = isTablet;
|
||||||
androidVersion = AndroidVersion;
|
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;
|
return app;
|
||||||
}
|
}
|
||||||
@@ -103,6 +101,7 @@ public class Forge implements ApplicationListener {
|
|||||||
ExceptionHandler.registerErrorHandling();
|
ExceptionHandler.registerErrorHandling();
|
||||||
|
|
||||||
GuiBase.setIsAndroid(Gdx.app.getType() == Application.ApplicationType.Android);
|
GuiBase.setIsAndroid(Gdx.app.getType() == Application.ApplicationType.Android);
|
||||||
|
|
||||||
graphics = new Graphics();
|
graphics = new Graphics();
|
||||||
splashScreen = new SplashScreen();
|
splashScreen = new SplashScreen();
|
||||||
frameRate = new FrameRate();
|
frameRate = new FrameRate();
|
||||||
@@ -132,6 +131,13 @@ public class Forge implements ApplicationListener {
|
|||||||
enableUIMask = prefs.getPrefBoolean(FPref.UI_ENABLE_BORDER_MASKING);
|
enableUIMask = prefs.getPrefBoolean(FPref.UI_ENABLE_BORDER_MASKING);
|
||||||
enablePreloadExtendedArt = prefs.getPrefBoolean(FPref.UI_ENABLE_PRELOAD_EXTENDED_ART);
|
enablePreloadExtendedArt = prefs.getPrefBoolean(FPref.UI_ENABLE_PRELOAD_EXTENDED_ART);
|
||||||
locale = prefs.getPref(FPref.UI_LANGUAGE);
|
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();
|
final Localizer localizer = Localizer.getInstance();
|
||||||
|
|
||||||
@@ -155,12 +161,12 @@ public class Forge implements ApplicationListener {
|
|||||||
|
|
||||||
//add reminder to preload
|
//add reminder to preload
|
||||||
if (enablePreloadExtendedArt) {
|
if (enablePreloadExtendedArt) {
|
||||||
if(totalDeviceRAM>0)
|
if(autoCache)
|
||||||
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblPreloadExtendedArt")+"\nDetected RAM: " +totalDeviceRAM+"MB. Cache size: "+cacheSize);
|
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblPreloadExtendedArt")+"\nDetected RAM: " +totalDeviceRAM+"MB. Cache size: "+cacheSize);
|
||||||
else
|
else
|
||||||
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblPreloadExtendedArt"));
|
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblPreloadExtendedArt"));
|
||||||
} else {
|
} else {
|
||||||
if(totalDeviceRAM>0)
|
if(autoCache)
|
||||||
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblFinishingStartup")+"\nDetected RAM: " +totalDeviceRAM+"MB. Cache size: "+cacheSize);
|
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblFinishingStartup")+"\nDetected RAM: " +totalDeviceRAM+"MB. Cache size: "+cacheSize);
|
||||||
else
|
else
|
||||||
splashScreen.getProgressBar().setDescription(localizer.getMessage("lblFinishingStartup"));
|
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);
|
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 {
|
} else {
|
||||||
if (!dp.isGeneratedDeck()){
|
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
|
//draw the deckbox
|
||||||
if (cardArt == null){
|
if (cardArt == null){
|
||||||
//draw generic box if null or still loading
|
//draw generic box if null or still loading
|
||||||
|
|||||||
@@ -274,6 +274,29 @@ public class SettingsPage extends TabPage<SettingsScreen> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
3);
|
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
|
//Graphic Options
|
||||||
lstSettings.addItem(new BooleanSetting(FPref.UI_ENABLE_ONLINE_IMAGE_FETCHER,
|
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)
|
nlEnableUnknownCards=Erlaube unbekannte Karten von unbekannten Sets. (Erfordert Neustart)
|
||||||
lblExperimentalNetworkCompatibility=Experimentelle Netzwerkkompatibilität
|
lblExperimentalNetworkCompatibility=Experimentelle Netzwerkkompatibilität
|
||||||
nlExperimentalNetworkCompatibility=Forge wechselt auf kompatiblen Netzwerk-Stream. (Im Zweifel bitte ausschalten)
|
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
|
#MatchScreen.java
|
||||||
lblPlayers=Spieler
|
lblPlayers=Spieler
|
||||||
lblLog=Bericht
|
lblLog=Bericht
|
||||||
|
|||||||
@@ -994,6 +994,8 @@ lblEnableUnknownCards=Enable Unknown Cards
|
|||||||
nlEnableUnknownCards=Enable Unknown Cards to be loaded to Unknown Set. (Requires restart)
|
nlEnableUnknownCards=Enable Unknown Cards to be loaded to Unknown Set. (Requires restart)
|
||||||
lblExperimentalNetworkCompatibility=Experimental Network Compatibility
|
lblExperimentalNetworkCompatibility=Experimental Network Compatibility
|
||||||
nlExperimentalNetworkCompatibility=Forge switches to compatible network stream. (If unsure, turn OFF this option)
|
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
|
#MatchScreen.java
|
||||||
lblPlayers=Players
|
lblPlayers=Players
|
||||||
lblLog=Log
|
lblLog=Log
|
||||||
|
|||||||
@@ -994,6 +994,8 @@ lblEnableUnknownCards=Habilitar Cartas Desconocidas
|
|||||||
nlEnableUnknownCards=Habilitar que las cartas desconocidas se carguen en el Unknown Set. (Requiere reinicio)
|
nlEnableUnknownCards=Habilitar que las cartas desconocidas se carguen en el Unknown Set. (Requiere reinicio)
|
||||||
lblExperimentalNetworkCompatibility=Compatibilidad de red experimental
|
lblExperimentalNetworkCompatibility=Compatibilidad de red experimental
|
||||||
nlExperimentalNetworkCompatibility=Forge cambia a un flujo de red compatible. (Si no estás seguro, deshabilita esta opción)
|
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
|
#MatchScreen.java
|
||||||
lblPlayers=Jugadores
|
lblPlayers=Jugadores
|
||||||
lblLog=Log
|
lblLog=Log
|
||||||
|
|||||||
@@ -994,6 +994,8 @@ lblEnableUnknownCards=Enable Unknown Cards
|
|||||||
nlEnableUnknownCards=Enable Unknown Cards to be loaded to Unknown Set. (Requires restart)
|
nlEnableUnknownCards=Enable Unknown Cards to be loaded to Unknown Set. (Requires restart)
|
||||||
lblExperimentalNetworkCompatibility=Experimental Network Compatibility
|
lblExperimentalNetworkCompatibility=Experimental Network Compatibility
|
||||||
nlExperimentalNetworkCompatibility=Forge switches to compatible network stream. (If unsure, turn OFF this option)
|
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
|
#MatchScreen.java
|
||||||
lblPlayers=Giocatori
|
lblPlayers=Giocatori
|
||||||
lblLog=Login
|
lblLog=Login
|
||||||
|
|||||||
@@ -994,6 +994,8 @@ lblEnableUnknownCards=启用未知卡牌
|
|||||||
nlEnableUnknownCards=将未知卡牌加载到未知系列中。(需要重启)
|
nlEnableUnknownCards=将未知卡牌加载到未知系列中。(需要重启)
|
||||||
lblExperimentalNetworkCompatibility=实验性网络兼容
|
lblExperimentalNetworkCompatibility=实验性网络兼容
|
||||||
nlExperimentalNetworkCompatibility=Forge将切换为兼容性的网络流。(如果不清楚,请关闭此选项)
|
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
|
#MatchScreen.java
|
||||||
lblPlayers=玩家列表
|
lblPlayers=玩家列表
|
||||||
lblLog=日志
|
lblLog=日志
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ public class ForgePreferences extends PreferencesStore<ForgePreferences.FPref> {
|
|||||||
UI_SHOW_FPS("false"),
|
UI_SHOW_FPS("false"),
|
||||||
UI_NETPLAY_COMPAT("false"),
|
UI_NETPLAY_COMPAT("false"),
|
||||||
UI_LOAD_UNKNOWN_CARDS("true"),
|
UI_LOAD_UNKNOWN_CARDS("true"),
|
||||||
|
UI_AUTO_CACHE_SIZE("false"),
|
||||||
UI_ALLOW_ORDER_GRAVEYARD_WHEN_NEEDED ("Never"),
|
UI_ALLOW_ORDER_GRAVEYARD_WHEN_NEEDED ("Never"),
|
||||||
UI_DEFAULT_FONT_SIZE("12"),
|
UI_DEFAULT_FONT_SIZE("12"),
|
||||||
UI_SELECT_FROM_CARD_DISPLAYS("true"),
|
UI_SELECT_FROM_CARD_DISPLAYS("true"),
|
||||||
|
|||||||
Reference in New Issue
Block a user