[Mobile] Disable loading of HD Textures for Devices with RAM < 5GB

This commit is contained in:
Anthony Calosa
2021-05-21 10:58:03 +08:00
parent 5ea5ca0ef7
commit f8a41b39ec
2 changed files with 35 additions and 10 deletions

View File

@@ -672,9 +672,12 @@ public class Graphics {
batch.draw(image, adjustX(x), adjustY(y, h), w, h);
}
public void drawImage(TextureRegion image, float x, float y, float w, float h) {
batch.draw(image, adjustX(x), adjustY(y, h), w, h);
if (image != null)
batch.draw(image, adjustX(x), adjustY(y, h), w, h);
}
public void drawImage(TextureRegion image, TextureRegion glowImageReference, float x, float y, float w, float h, Color glowColor, boolean selected) {
if (image == null || glowImageReference == null)
return;
//1st image is the image on top of the shader, 2nd image is for the outline reference for the shader glow...
// if the 1st image don't have transparency in the middle (only on the sides, top and bottom, use the 1st image as outline reference...
if (!selected) {
@@ -698,6 +701,8 @@ public class Graphics {
}
}
public void drawDeckBox(FImage cardArt, float scale, TextureRegion image, TextureRegion glowImageReference, float x, float y, float w, float h, Color glowColor, boolean selected) {
if (image == null || glowImageReference == null)
return;
float yBox = y-(h*0.25f);
if (!selected) {
cardArt.draw(this,x+((w-w*scale)/2), y+((h-h*scale)/3f), w*scale, h*scale/1.85f);
@@ -788,6 +793,8 @@ public class Graphics {
drawText(text, font, skinColor.getColor(), x, y, w, h, wrap, horzAlignment, centerVertically);
}
public void drawText(String text, FSkinFont font, Color color, float x, float y, float w, float h, boolean wrap, int horzAlignment, boolean centerVertically) {
if (text == null)
return;
if (alphaComposite < 1) {
color = FSkinColor.alphaColor(color, color.a * alphaComposite);
}

View File

@@ -15,6 +15,7 @@ import forge.Forge;
import forge.assets.FSkinImage.SourceFile;
import forge.card.CardFaceSymbols;
import forge.gui.FThreads;
import forge.gui.GuiBase;
import forge.localinstance.properties.ForgeConstants;
import forge.localinstance.properties.ForgePreferences;
import forge.localinstance.properties.ForgePreferences.FPref;
@@ -240,16 +241,24 @@ public class FSkin {
//hdbuttons
if (f11.exists()) {
Texture t = new Texture(f11, true);
t.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
textures.put(f11.path(), t);
Forge.hdbuttons = true;
if (GuiBase.isAndroid() && Forge.totalDeviceRAM <5000) {
Forge.hdbuttons = false;
} else {
Texture t = new Texture(f11, true);
t.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
textures.put(f11.path(), t);
Forge.hdbuttons = true;
}
} else { Forge.hdbuttons = false; } //how to refresh buttons when a theme don't have hd buttons?
if (f12.exists()) {
Texture t = new Texture(f12, true);
t.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
textures.put(f12.path(), t);
Forge.hdstart = true;
if (GuiBase.isAndroid() && Forge.totalDeviceRAM <5000) {
Forge.hdstart = false;
} else {
Texture t = new Texture(f12, true);
t.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
textures.put(f12.path(), t);
Forge.hdstart = true;
}
} else { Forge.hdstart = false; }
//update colors
for (final FSkinColor.Colors c : FSkinColor.Colors.values()) {
@@ -258,7 +267,16 @@ public class FSkin {
//load images
for (FSkinImage image : FSkinImage.values()) {
image.load(textures, preferredIcons);
if (GuiBase.isAndroid()) {
if (Forge.totalDeviceRAM>5000)
image.load(textures, preferredIcons);
else if (image.toString().equals("HDMULTI"))
image.load(textures, preferredIcons);
else if (!image.toString().startsWith("HD"))
image.load(textures, preferredIcons);
} else {
image.load(textures, preferredIcons);
}
}
for (FSkinTexture texture : FSkinTexture.values()) {
if (texture != FSkinTexture.BG_TEXTURE) {