[Mobile] dispose texture as an option

This commit is contained in:
Anthony Calosa
2021-02-23 06:48:18 +08:00
parent 6af9f1831e
commit 9da70cf5dd
9 changed files with 29 additions and 3 deletions

View File

@@ -73,6 +73,7 @@ public class Forge implements ApplicationListener {
public static boolean hdstart = false;
public static boolean isPortraitMode = false;
public static boolean gameInProgress = false;
public static boolean disposeTextures = false;
public static int cacheSize = 400;
public static int totalDeviceRAM = 0;
public static int androidVersion = 0;
@@ -138,6 +139,7 @@ public class Forge implements ApplicationListener {
enablePreloadExtendedArt = prefs.getPrefBoolean(FPref.UI_ENABLE_PRELOAD_EXTENDED_ART);
locale = prefs.getPref(FPref.UI_LANGUAGE);
autoCache = prefs.getPrefBoolean(FPref.UI_AUTO_CACHE_SIZE);
disposeTextures = prefs.getPrefBoolean(FPref.UI_ENABLE_DISPOSE_TEXTURES);
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..)
@@ -437,7 +439,7 @@ public class Forge implements ApplicationListener {
String previousScreen = currentScreen != null ? currentScreen.toString() : "";
gameInProgress = toNewScreen.toLowerCase().contains("match") || previousScreen.toLowerCase().contains("match");
boolean dispose = toNewScreen.toLowerCase().contains("homescreen");
boolean dispose = toNewScreen.toLowerCase().contains("homescreen") && disposeTextures;
try {
endKeyInput(); //end key input before switching screens
ForgeAnimation.endAll(); //end all active animations before switching screens
@@ -464,9 +466,10 @@ public class Forge implements ApplicationListener {
catch (Exception ex) {
graphics.end();
BugReporter.reportException(ex);
} finally {
if(dispose)
ImageCache.disposeTexture();
}
if(dispose)
ImageCache.disposeTexture();
}
@Override

View File

@@ -274,6 +274,16 @@ public class SettingsPage extends TabPage<SettingsScreen> {
}
},
3);
lstSettings.addItem(new BooleanSetting(FPref.UI_ENABLE_DISPOSE_TEXTURES,
localizer.getMessage("lblDisposeTextures"),
localizer.getMessage("nlDisposeTextures")) {
@Override
public void select() {
super.select();
Forge.disposeTextures = FModel.getPreferences().getPrefBoolean(FPref.UI_ENABLE_DISPOSE_TEXTURES);
}
},
3);
if (GuiBase.isAndroid()) { //this option does nothing except on Android
lstSettings.addItem(new BooleanSetting(FPref.UI_AUTO_CACHE_SIZE,
localizer.getMessage("lblAutoCacheSize"),

View File

@@ -1006,6 +1006,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)
lblDisposeTextures=Dispose Textures
nlDisposeTextures=When enabled, disposes the card art caches. (If unsure, turn OFF this option)
lblAutoCacheSize=Aktiviere automatische Cache-Größe
nlAutoCacheSize=Wenn aktiviert, wird die Cache-Größe beim Start automatisch ermittelt und eingestellt. (Im Zweifel bitte ausschalten)
#MatchScreen.java

View File

@@ -1006,6 +1006,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)
lblDisposeTextures=Dispose Textures
nlDisposeTextures=When enabled, disposes the card art caches. (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

View File

@@ -1006,6 +1006,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)
lblDisposeTextures=Dispose Textures
nlDisposeTextures=When enabled, disposes the card art caches. (If unsure, turn OFF this option)
lblAutoCacheSize=Activar tamaño de caché automático
nlAutoCacheSize=Cuando se activa, el tamaño de la caché se determina automáticamente al inicio. (Si no estás seguro, desactiva esta opción)
#MatchScreen.java

View File

@@ -1006,6 +1006,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)
lblDisposeTextures=Dispose Textures
nlDisposeTextures=When enabled, disposes the card art caches. (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

View File

@@ -1006,6 +1006,8 @@ lblEnableUnknownCards=未知のカードを有効にする
nlEnableUnknownCards=未知のカードを未知のセットにまとめます。(再起動必須)
lblExperimentalNetworkCompatibility=実験的なネットワークコンパチビリティ
nlExperimentalNetworkCompatibility=Forge がコンパチブルネットワークストリーミに切り替えます。 (分からない場合はオフにしてください)
lblDisposeTextures=Dispose Textures
nlDisposeTextures=When enabled, disposes the card art caches. (If unsure, turn OFF this option)
lblAutoCacheSize=キャッシュサイズ自動計算
nlAutoCacheSize=有効にすると、キャッシュサイズは起動時に自動計算されます。 (分からない場合はオフにしてください)
#MatchScreen.java

View File

@@ -1005,6 +1005,8 @@ lblEnableUnknownCards=启用未知卡牌
nlEnableUnknownCards=将未知卡牌加载到未知系列中。(需要重启)
lblExperimentalNetworkCompatibility=实验性网络兼容
nlExperimentalNetworkCompatibility=Forge将切换为兼容性的网络流。如果不清楚此选项的作用请关闭此选项
lblDisposeTextures=Dispose Textures
nlDisposeTextures=When enabled, disposes the card art caches. (If unsure, turn OFF this option)
lblAutoCacheSize=启用自动缓存大小
nlAutoCacheSize=启用后Forge将于启动时自动确定缓存大小。如果不清楚此选项的作用请关闭此选项
#MatchScreen.java

View File

@@ -145,6 +145,7 @@ public class ForgePreferences extends PreferencesStore<ForgePreferences.FPref> {
UI_ENABLE_BORDER_MASKING("Crop"),
UI_SHOW_FPS("false"),
UI_NETPLAY_COMPAT("false"),
UI_ENABLE_DISPOSE_TEXTURES("false"),
UI_LOAD_UNKNOWN_CARDS("true"),
UI_AUTO_CACHE_SIZE("false"),
UI_ALLOW_ORDER_GRAVEYARD_WHEN_NEEDED ("Never"),