From eec2da8f0048bb6441a9651c07b5a2e4235f6ab5 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Fri, 11 Mar 2022 00:26:48 +0800 Subject: [PATCH] [Mobile] update SplashScreen --- forge-gui-mobile/src/forge/Forge.java | 35 +++++++++++++------ .../src/forge/screens/SplashScreen.java | 14 +++----- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/forge-gui-mobile/src/forge/Forge.java b/forge-gui-mobile/src/forge/Forge.java index 98960d81a4e..1d77a76c637 100644 --- a/forge-gui-mobile/src/forge/Forge.java +++ b/forge-gui-mobile/src/forge/Forge.java @@ -54,7 +54,9 @@ import java.io.File; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Deque; +import java.util.HashMap; import java.util.List; +import java.util.Map; public class Forge implements ApplicationListener { public static final String CURRENT_VERSION = "1.6.47.001"; @@ -62,9 +64,8 @@ public class Forge implements ApplicationListener { private static ApplicationListener app = null; static Scene currentScene = null; static Array lastScene = new Array<>(); - private float animationTimeout; + private static float animationTimeout; static Batch animationBatch; - static Texture transitionTexture; static TextureRegion lastScreenTexture; private static boolean sceneWasSwapped = false; private static Clipboard clipboard; @@ -119,6 +120,7 @@ public class Forge implements ApplicationListener { private static Cursor cursor0, cursor1, cursor2, cursorA0, cursorA1, cursorA2; public static boolean forcedEnglishonCJKMissing = false; private static Localizer localizer; + static Map misc = new HashMap<>(); public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value, boolean androidOrientation, int totalRAM, boolean isTablet, int AndroidAPI, String AndroidRelease, String deviceName) { app = new Forge(); @@ -336,12 +338,23 @@ public class Forge implements ApplicationListener { e.printStackTrace(); } } - + public static Texture getTitleBG() { + if (misc.get(0) == null) { + misc.put(0, new Texture(GuiBase.isAndroid() + ? Gdx.files.internal("fallback_skin").child("title_bg_lq.png") + : Gdx.files.classpath("fallback_skin").child("title_bg_lq.png"))); + } + return misc.get(0); + } + public static Texture getTransitionBG() { + if (misc.get(1) == null) { + misc.put(1, new Texture(GuiBase.isAndroid() + ? Gdx.files.internal("fallback_skin").child("transition.png") + : Gdx.files.classpath("fallback_skin").child("transition.png"))); + } + return misc.get(1); + } protected void afterDbLoaded() { - //init here to fix crash if the assets are missing - transitionTexture = new Texture(GuiBase.isAndroid() ? Gdx.files.internal("fallback_skin").child("transition.png") : Gdx.files.classpath("fallback_skin").child("transition.png")); - - destroyThis = false; //Allow back() Gdx.input.setCatchKey(Keys.MENU, true); @@ -816,8 +829,8 @@ public class Forge implements ApplicationListener { animationBatch.setColor(1, 1, 1, 1); animationBatch.draw(lastScreenTexture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); animationBatch.setColor(1, 1, 1, 1 - (1 / transitionTime) * animationTimeout); - animationBatch.draw(transitionTexture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); - animationBatch.draw(transitionTexture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); + animationBatch.draw(getTransitionBG(), 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); + animationBatch.draw(getTransitionBG(), 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); animationBatch.end(); if (animationTimeout < 0) { currentScene.render(); @@ -836,8 +849,8 @@ public class Forge implements ApplicationListener { animationBatch.setColor(1, 1, 1, 1); animationBatch.draw(lastScreenTexture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); animationBatch.setColor(1, 1, 1, (1 / transitionTime) * (animationTimeout + transitionTime)); - animationBatch.draw(transitionTexture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); - animationBatch.draw(transitionTexture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); + animationBatch.draw(getTransitionBG(), 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); + animationBatch.draw(getTransitionBG(), 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); animationBatch.end(); return; } diff --git a/forge-gui-mobile/src/forge/screens/SplashScreen.java b/forge-gui-mobile/src/forge/screens/SplashScreen.java index 958fa78dbb1..237ea6b27c6 100644 --- a/forge-gui-mobile/src/forge/screens/SplashScreen.java +++ b/forge-gui-mobile/src/forge/screens/SplashScreen.java @@ -2,7 +2,6 @@ package forge.screens; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; -import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.utils.Align; @@ -13,7 +12,6 @@ import forge.assets.FSkin; import forge.assets.FSkinColor; import forge.assets.FSkinFont; import forge.assets.FSkinTexture; -import forge.gui.GuiBase; import forge.toolbox.FButton; import forge.toolbox.FContainer; import forge.toolbox.FEvent; @@ -96,10 +94,6 @@ public class SplashScreen extends FContainer { float DURATION = 0.8f; private float progress = 0; private boolean finished, openAdventure; - //for transition image only... - TextureRegion transition_bg = new TextureRegion(new Texture(GuiBase.isAndroid() - ? Gdx.files.internal("fallback_skin").child("title_bg_lq.png") - : Gdx.files.classpath("fallback_skin").child("title_bg_lq.png"))); public void drawBackground(Graphics g) { float percentage = progress / DURATION; @@ -114,7 +108,7 @@ public class SplashScreen extends FContainer { } else { if (animateLogo) { //bg - drawTransition(g, transition_bg, openAdventure, percentage); + drawTransition(g, openAdventure, percentage); g.setAlphaComposite(1 - percentage); g.drawImage(FSkinTexture.BG_TEXTURE, 0, 0, getWidth(), getHeight()); g.setAlphaComposite(oldAlpha); @@ -134,7 +128,7 @@ public class SplashScreen extends FContainer { g.setAlphaComposite(oldAlpha); if (hideBG) { g.setAlphaComposite(0 + percentage); - drawTransition(g, transition_bg, openAdventure, percentage); + drawTransition(g, openAdventure, percentage); g.setAlphaComposite(oldAlpha); } } @@ -175,8 +169,8 @@ public class SplashScreen extends FContainer { bgAnimation.drawBackground(g); } - void drawTransition(Graphics g, TextureRegion bg, boolean openAdventure, float percentage) { - TextureRegion tr = new TextureRegion(bg.getTexture()); + void drawTransition(Graphics g, boolean openAdventure, float percentage) { + TextureRegion tr = new TextureRegion(Forge.getTransitionBG()); if (!Forge.isLandscapeMode() && tr != null) { float ar = 1.78f; int w = (int) (tr.getRegionHeight() / ar);