diff --git a/core/src/cz/nic/tablexia/loader/TablexiaAtlasManager.java b/core/src/cz/nic/tablexia/loader/TablexiaAtlasManager.java index 8909de0e17065488538b0f38a0b1f40ec72b91c3..b03b25fbc743e36d16eeb3b3d49a204268a6c768 100644 --- a/core/src/cz/nic/tablexia/loader/TablexiaAtlasManager.java +++ b/core/src/cz/nic/tablexia/loader/TablexiaAtlasManager.java @@ -1,14 +1,23 @@ package cz.nic.tablexia.loader; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.Pixmap; +import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.NinePatch; import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.graphics.g2d.TextureRegion; +import java.util.HashMap; +import java.util.Map; + import cz.nic.tablexia.util.Log; public class TablexiaAtlasManager extends TablexiaAbstractFileManager { public static final float BLEEDING_EDGE_OFFSET = 1f; + public static final Color COLOR_OVERLAY = new Color(0, 0, 0, 0.5f); + + private Map<Color, Texture> colorMap = new HashMap<Color, Texture>();// TODO dispose with application! public TablexiaAtlasManager() { super(AssetsStorageType.EXTERNAL); @@ -18,6 +27,14 @@ public class TablexiaAtlasManager extends TablexiaAbstractFileManager { super(storageType); } + @Override + public synchronized void dispose() { + super.dispose(); + for (Texture texture : colorMap.values()) { + texture.dispose(); + } + } + public void loadAtlas(String atlasName) { loadAtlas(atlasName, true); } @@ -48,10 +65,10 @@ public class TablexiaAtlasManager extends TablexiaAbstractFileManager { float invTexHeight = 1f / region.getTexture().getHeight(); return new TextureRegion(region.getTexture(), - (x + BLEEDING_EDGE_OFFSET) * invTexWidth, - (y + BLEEDING_EDGE_OFFSET) * invTexHeight, - (x + width - BLEEDING_EDGE_OFFSET) * invTexWidth, - (y + height - BLEEDING_EDGE_OFFSET) * invTexHeight); + (x + BLEEDING_EDGE_OFFSET) * invTexWidth, + (y + BLEEDING_EDGE_OFFSET) * invTexHeight, + (x + width - BLEEDING_EDGE_OFFSET) * invTexWidth, + (y + height - BLEEDING_EDGE_OFFSET) * invTexHeight); } public NinePatch getPatchFromAtlas(String atlasName, String patchName) { @@ -69,4 +86,16 @@ public class TablexiaAtlasManager extends TablexiaAbstractFileManager { return patch; } + + public Texture getColorTexture(Color color) { + if (colorMap.get(color) == null) { + Pixmap p = new Pixmap(1, 1, Pixmap.Format.RGBA8888); + p.setColor(color); + p.drawPixel(0, 0); + Texture texture = new Texture(p); + p.dispose(); + colorMap.put(color, texture); + } + return colorMap.get(color); + } } diff --git a/core/src/cz/nic/tablexia/loader/application/ApplicationAtlasManager.java b/core/src/cz/nic/tablexia/loader/application/ApplicationAtlasManager.java index e8564ef22961cf9fbe4fa7f21c3f225b88a28482..6fb4f47ad8b5ea1b145f0e72e17be88d5c7cef61 100644 --- a/core/src/cz/nic/tablexia/loader/application/ApplicationAtlasManager.java +++ b/core/src/cz/nic/tablexia/loader/application/ApplicationAtlasManager.java @@ -1,14 +1,8 @@ package cz.nic.tablexia.loader.application; -import com.badlogic.gdx.graphics.Color; -import com.badlogic.gdx.graphics.Pixmap; -import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.NinePatch; import com.badlogic.gdx.graphics.g2d.TextureRegion; -import java.util.HashMap; -import java.util.Map; - import cz.nic.tablexia.loader.IApplicationLoader; import cz.nic.tablexia.loader.TablexiaAtlasManager; @@ -17,8 +11,6 @@ public class ApplicationAtlasManager extends TablexiaAtlasManager implements IAp private static ApplicationAtlasManager instance; - private Map<Color, Texture> colorMap = new HashMap<Color, Texture>();// TODO dispose with application! - private ApplicationAtlasManager() { } @@ -32,14 +24,9 @@ public class ApplicationAtlasManager extends TablexiaAtlasManager implements IAp @Override public synchronized void dispose() { super.dispose(); - for (Texture texture : colorMap.values()) { - texture.dispose(); - } instance = null; } - public static final Color COLOR_OVERLAY = new Color(0, 0, 0, 0.5f); - private static final String GLOBAL_PATH = "_global/"; private static final String APPLICATION_PATH = GLOBAL_PATH + "application/"; private static final String APPLICATION_ATLAS = APPLICATION_PATH + "application.atlas"; @@ -86,15 +73,4 @@ public class ApplicationAtlasManager extends TablexiaAtlasManager implements IAp return getPatchFromAtlas(APPLICATION_ATLAS, patchName); } - public Texture getColorTexture(Color color) { - if (colorMap.get(color) == null) { - Pixmap p = new Pixmap(1, 1, Pixmap.Format.RGBA8888); - p.setColor(color); - p.drawPixel(0, 0); - Texture texture = new Texture(p); - p.dispose(); - colorMap.put(color, texture); - } - return colorMap.get(color); - } } \ No newline at end of file diff --git a/core/src/cz/nic/tablexia/screen/AbstractTablexiaScreen.java b/core/src/cz/nic/tablexia/screen/AbstractTablexiaScreen.java index 17596247f9a828740b8b60bd940f497d74b96680..5dcc50d19d50566afeb3356e4f5183145c8568b5 100644 --- a/core/src/cz/nic/tablexia/screen/AbstractTablexiaScreen.java +++ b/core/src/cz/nic/tablexia/screen/AbstractTablexiaScreen.java @@ -431,29 +431,18 @@ public abstract class AbstractTablexiaScreen<T> extends ScreenAdapter { protected void screenRender(float delta) { } - ; - protected void screenLoaded() { } - ; - protected void screenVisible() { } - ; - protected void screenDisposed() { } - ; - protected void screenResized(int width, int height) { } - ; - - //////////////////////////// TABLEXIA SCREEN CALLBACKS // SFX diff --git a/core/src/cz/nic/tablexia/screen/createuser/FormScreen.java b/core/src/cz/nic/tablexia/screen/createuser/FormScreen.java index 8b4d2051ede22a93e57b33ee216c078c2ecdf2b1..5bc3b4c177a0b77ed2fa98b857c19f698e3af855 100644 --- a/core/src/cz/nic/tablexia/screen/createuser/FormScreen.java +++ b/core/src/cz/nic/tablexia/screen/createuser/FormScreen.java @@ -19,6 +19,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.Drawable; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; import cz.nic.tablexia.TablexiaSettings; +import cz.nic.tablexia.loader.TablexiaAtlasManager; import cz.nic.tablexia.loader.application.ApplicationAtlasManager; import cz.nic.tablexia.loader.application.ApplicationFontManager; import cz.nic.tablexia.model.User; @@ -265,7 +266,7 @@ public class FormScreen extends AbstractTablexiaScreen<Void> { final Group signature = new Group(); // grey translucent overlay - Image overlay = new Image(ApplicationAtlasManager.getInstance().getColorTexture(ApplicationAtlasManager.COLOR_OVERLAY)); + Image overlay = new Image(ApplicationAtlasManager.getInstance().getColorTexture(TablexiaAtlasManager.COLOR_OVERLAY)); signature.addActor(ScaleUtil.setBackgroundSize(overlay)); overlay.addListener(new InputListener() { @Override