mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
[Mobile] update SplashScreen
This commit is contained in:
@@ -54,7 +54,9 @@ import java.io.File;
|
|||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Deque;
|
import java.util.Deque;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class Forge implements ApplicationListener {
|
public class Forge implements ApplicationListener {
|
||||||
public static final String CURRENT_VERSION = "1.6.47.001";
|
public static final String CURRENT_VERSION = "1.6.47.001";
|
||||||
@@ -62,9 +64,8 @@ public class Forge implements ApplicationListener {
|
|||||||
private static ApplicationListener app = null;
|
private static ApplicationListener app = null;
|
||||||
static Scene currentScene = null;
|
static Scene currentScene = null;
|
||||||
static Array<Scene> lastScene = new Array<>();
|
static Array<Scene> lastScene = new Array<>();
|
||||||
private float animationTimeout;
|
private static float animationTimeout;
|
||||||
static Batch animationBatch;
|
static Batch animationBatch;
|
||||||
static Texture transitionTexture;
|
|
||||||
static TextureRegion lastScreenTexture;
|
static TextureRegion lastScreenTexture;
|
||||||
private static boolean sceneWasSwapped = false;
|
private static boolean sceneWasSwapped = false;
|
||||||
private static Clipboard clipboard;
|
private static Clipboard clipboard;
|
||||||
@@ -119,6 +120,7 @@ public class Forge implements ApplicationListener {
|
|||||||
private static Cursor cursor0, cursor1, cursor2, cursorA0, cursorA1, cursorA2;
|
private static Cursor cursor0, cursor1, cursor2, cursorA0, cursorA1, cursorA2;
|
||||||
public static boolean forcedEnglishonCJKMissing = false;
|
public static boolean forcedEnglishonCJKMissing = false;
|
||||||
private static Localizer localizer;
|
private static Localizer localizer;
|
||||||
|
static Map<Integer, Texture> 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) {
|
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();
|
app = new Forge();
|
||||||
@@ -336,12 +338,23 @@ public class Forge implements ApplicationListener {
|
|||||||
e.printStackTrace();
|
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() {
|
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()
|
destroyThis = false; //Allow back()
|
||||||
Gdx.input.setCatchKey(Keys.MENU, true);
|
Gdx.input.setCatchKey(Keys.MENU, true);
|
||||||
|
|
||||||
@@ -816,8 +829,8 @@ public class Forge implements ApplicationListener {
|
|||||||
animationBatch.setColor(1, 1, 1, 1);
|
animationBatch.setColor(1, 1, 1, 1);
|
||||||
animationBatch.draw(lastScreenTexture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
animationBatch.draw(lastScreenTexture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
animationBatch.setColor(1, 1, 1, 1 - (1 / transitionTime) * animationTimeout);
|
animationBatch.setColor(1, 1, 1, 1 - (1 / transitionTime) * animationTimeout);
|
||||||
animationBatch.draw(transitionTexture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
animationBatch.draw(getTransitionBG(), 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.end();
|
animationBatch.end();
|
||||||
if (animationTimeout < 0) {
|
if (animationTimeout < 0) {
|
||||||
currentScene.render();
|
currentScene.render();
|
||||||
@@ -836,8 +849,8 @@ public class Forge implements ApplicationListener {
|
|||||||
animationBatch.setColor(1, 1, 1, 1);
|
animationBatch.setColor(1, 1, 1, 1);
|
||||||
animationBatch.draw(lastScreenTexture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
animationBatch.draw(lastScreenTexture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
animationBatch.setColor(1, 1, 1, (1 / transitionTime) * (animationTimeout + transitionTime));
|
animationBatch.setColor(1, 1, 1, (1 / transitionTime) * (animationTimeout + transitionTime));
|
||||||
animationBatch.draw(transitionTexture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
animationBatch.draw(getTransitionBG(), 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.end();
|
animationBatch.end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package forge.screens;
|
|||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.badlogic.gdx.utils.Align;
|
import com.badlogic.gdx.utils.Align;
|
||||||
|
|
||||||
@@ -13,7 +12,6 @@ import forge.assets.FSkin;
|
|||||||
import forge.assets.FSkinColor;
|
import forge.assets.FSkinColor;
|
||||||
import forge.assets.FSkinFont;
|
import forge.assets.FSkinFont;
|
||||||
import forge.assets.FSkinTexture;
|
import forge.assets.FSkinTexture;
|
||||||
import forge.gui.GuiBase;
|
|
||||||
import forge.toolbox.FButton;
|
import forge.toolbox.FButton;
|
||||||
import forge.toolbox.FContainer;
|
import forge.toolbox.FContainer;
|
||||||
import forge.toolbox.FEvent;
|
import forge.toolbox.FEvent;
|
||||||
@@ -96,10 +94,6 @@ public class SplashScreen extends FContainer {
|
|||||||
float DURATION = 0.8f;
|
float DURATION = 0.8f;
|
||||||
private float progress = 0;
|
private float progress = 0;
|
||||||
private boolean finished, openAdventure;
|
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) {
|
public void drawBackground(Graphics g) {
|
||||||
float percentage = progress / DURATION;
|
float percentage = progress / DURATION;
|
||||||
@@ -114,7 +108,7 @@ public class SplashScreen extends FContainer {
|
|||||||
} else {
|
} else {
|
||||||
if (animateLogo) {
|
if (animateLogo) {
|
||||||
//bg
|
//bg
|
||||||
drawTransition(g, transition_bg, openAdventure, percentage);
|
drawTransition(g, openAdventure, percentage);
|
||||||
g.setAlphaComposite(1 - percentage);
|
g.setAlphaComposite(1 - percentage);
|
||||||
g.drawImage(FSkinTexture.BG_TEXTURE, 0, 0, getWidth(), getHeight());
|
g.drawImage(FSkinTexture.BG_TEXTURE, 0, 0, getWidth(), getHeight());
|
||||||
g.setAlphaComposite(oldAlpha);
|
g.setAlphaComposite(oldAlpha);
|
||||||
@@ -134,7 +128,7 @@ public class SplashScreen extends FContainer {
|
|||||||
g.setAlphaComposite(oldAlpha);
|
g.setAlphaComposite(oldAlpha);
|
||||||
if (hideBG) {
|
if (hideBG) {
|
||||||
g.setAlphaComposite(0 + percentage);
|
g.setAlphaComposite(0 + percentage);
|
||||||
drawTransition(g, transition_bg, openAdventure, percentage);
|
drawTransition(g, openAdventure, percentage);
|
||||||
g.setAlphaComposite(oldAlpha);
|
g.setAlphaComposite(oldAlpha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,8 +169,8 @@ public class SplashScreen extends FContainer {
|
|||||||
bgAnimation.drawBackground(g);
|
bgAnimation.drawBackground(g);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawTransition(Graphics g, TextureRegion bg, boolean openAdventure, float percentage) {
|
void drawTransition(Graphics g, boolean openAdventure, float percentage) {
|
||||||
TextureRegion tr = new TextureRegion(bg.getTexture());
|
TextureRegion tr = new TextureRegion(Forge.getTransitionBG());
|
||||||
if (!Forge.isLandscapeMode() && tr != null) {
|
if (!Forge.isLandscapeMode() && tr != null) {
|
||||||
float ar = 1.78f;
|
float ar = 1.78f;
|
||||||
int w = (int) (tr.getRegionHeight() / ar);
|
int w = (int) (tr.getRegionHeight() / ar);
|
||||||
|
|||||||
Reference in New Issue
Block a user