mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
[Mobile] Update Splashscreen transitions
This commit is contained in:
BIN
forge-gui-android/assets/fallback_skin/title_bg_lq.png
Normal file
BIN
forge-gui-android/assets/fallback_skin/title_bg_lq.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 47 KiB |
BIN
forge-gui-android/assets/fallback_skin/transition.png
Normal file
BIN
forge-gui-android/assets/fallback_skin/transition.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
@@ -222,7 +222,6 @@ public class Forge implements ApplicationListener {
|
|||||||
/* call preloadExtendedArt here, if we put it above we will *
|
/* call preloadExtendedArt here, if we put it above we will *
|
||||||
* get error: No OpenGL context found in the current thread. */
|
* get error: No OpenGL context found in the current thread. */
|
||||||
preloadExtendedArt();
|
preloadExtendedArt();
|
||||||
preloadBoosterDrafts();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -273,17 +272,16 @@ public class Forge implements ApplicationListener {
|
|||||||
public static void openHomeDefault() {
|
public static void openHomeDefault() {
|
||||||
GuiBase.setIsAdventureMode(false);
|
GuiBase.setIsAdventureMode(false);
|
||||||
openHomeScreen(-1, null); //default for startup
|
openHomeScreen(-1, null); //default for startup
|
||||||
splashScreen = null;
|
|
||||||
isMobileAdventureMode = false;
|
isMobileAdventureMode = false;
|
||||||
if (isLandscapeMode()) { //open preferred new game screen by default if landscape mode
|
if (isLandscapeMode()) { //open preferred new game screen by default if landscape mode
|
||||||
NewGameMenu.getPreferredScreen().open();
|
NewGameMenu.getPreferredScreen().open();
|
||||||
}
|
}
|
||||||
|
stopContinuousRendering(); //save power consumption by disabling continuous rendering once assets loaded
|
||||||
}
|
}
|
||||||
public static void openAdventure() {
|
public static void openAdventure() {
|
||||||
//continuous rendering is needed for adventure mode
|
//continuous rendering is needed for adventure mode
|
||||||
startContinuousRendering();
|
startContinuousRendering();
|
||||||
GuiBase.setIsAdventureMode(true);
|
GuiBase.setIsAdventureMode(true);
|
||||||
splashScreen = null;
|
|
||||||
isMobileAdventureMode = true;
|
isMobileAdventureMode = true;
|
||||||
try {
|
try {
|
||||||
for (SceneType sceneType : SceneType.values()) {
|
for (SceneType sceneType : SceneType.values()) {
|
||||||
@@ -293,23 +291,16 @@ public class Forge implements ApplicationListener {
|
|||||||
} catch (Exception e) { e.printStackTrace(); }
|
} catch (Exception e) { e.printStackTrace(); }
|
||||||
}
|
}
|
||||||
protected void afterDbLoaded() {
|
protected void afterDbLoaded() {
|
||||||
stopContinuousRendering(); //save power consumption by disabling continuous rendering once assets loaded
|
|
||||||
//init here to fix crash if the assets are missings on android
|
//init here to fix crash if the assets are missings on android
|
||||||
transitionTexture = new Texture(Config.instance().getFile("ui/transition.png"));
|
transitionTexture = new Texture(GuiBase.isAndroid()
|
||||||
|
? Gdx.files.internal("fallback_skin").child("transition.png")
|
||||||
|
: Config.instance().getFile("ui/transition.png"));
|
||||||
|
|
||||||
FSkin.loadFull(splashScreen);
|
|
||||||
|
|
||||||
SoundSystem.instance.setBackgroundMusic(MusicPlaylist.MENUS); //start background music
|
|
||||||
destroyThis = false; //Allow back()
|
destroyThis = false; //Allow back()
|
||||||
Gdx.input.setCatchKey(Keys.MENU, true);
|
Gdx.input.setCatchKey(Keys.MENU, true);
|
||||||
|
|
||||||
afterDBloaded = true;
|
afterDBloaded = true;
|
||||||
//selection
|
|
||||||
if (isLandscapeMode() && !GuiBase.isAndroid())
|
|
||||||
splashScreen.setShowModeSelector(true);
|
|
||||||
else
|
|
||||||
openHomeDefault();
|
|
||||||
|
|
||||||
//adjust height modifier
|
//adjust height modifier
|
||||||
adjustHeightModifier(getScreenWidth(), getScreenHeight());
|
adjustHeightModifier(getScreenWidth(), getScreenHeight());
|
||||||
|
|
||||||
@@ -318,6 +309,39 @@ public class Forge implements ApplicationListener {
|
|||||||
FModel.getPreferences().setPref(FPref.UI_LANDSCAPE_MODE, isLandscapeMode());
|
FModel.getPreferences().setPref(FPref.UI_LANDSCAPE_MODE, isLandscapeMode());
|
||||||
FModel.getPreferences().save();
|
FModel.getPreferences().save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FThreads.invokeInBackgroundThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
FThreads.invokeInEdtLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
//load skin full
|
||||||
|
FSkin.loadFull(splashScreen);
|
||||||
|
FThreads.invokeInBackgroundThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
//load Drafts
|
||||||
|
preloadBoosterDrafts();
|
||||||
|
FThreads.invokeInEdtLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
//selection
|
||||||
|
if (isLandscapeMode() && !GuiBase.isAndroid())
|
||||||
|
splashScreen.setShowModeSelector(true);
|
||||||
|
else {
|
||||||
|
splashScreen.startClassic();
|
||||||
|
}
|
||||||
|
//start background music
|
||||||
|
SoundSystem.instance.setBackgroundMusic(MusicPlaylist.MENUS);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Clipboard getClipboard() {
|
public static Clipboard getClipboard() {
|
||||||
@@ -531,6 +555,10 @@ public class Forge implements ApplicationListener {
|
|||||||
public static void clearCurrentScreen() {
|
public static void clearCurrentScreen() {
|
||||||
currentScreen = null;
|
currentScreen = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void clearSplashScreen() {
|
||||||
|
splashScreen = null;
|
||||||
|
}
|
||||||
private static void setCurrentScreen(FScreen screen0) {
|
private static void setCurrentScreen(FScreen screen0) {
|
||||||
String toNewScreen = screen0 != null ? screen0.toString() : "";
|
String toNewScreen = screen0 != null ? screen0.toString() : "";
|
||||||
String previousScreen = currentScreen != null ? currentScreen.toString() : "";
|
String previousScreen = currentScreen != null ? currentScreen.toString() : "";
|
||||||
|
|||||||
@@ -753,6 +753,25 @@ public class Graphics {
|
|||||||
setAlphaComposite(oldalpha);
|
setAlphaComposite(oldalpha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void drawGrayTransitionImage(Texture image, float x, float y, float w, float h, boolean withDarkOverlay, float percentage) {
|
||||||
|
batch.end();
|
||||||
|
shaderGrayscale.bind();
|
||||||
|
shaderGrayscale.setUniformf("u_grayness", percentage);
|
||||||
|
batch.setShader(shaderGrayscale);
|
||||||
|
batch.begin();
|
||||||
|
//draw gray
|
||||||
|
batch.draw(image, x, y, w, h);
|
||||||
|
//reset
|
||||||
|
batch.end();
|
||||||
|
batch.setShader(null);
|
||||||
|
batch.begin();
|
||||||
|
if(withDarkOverlay){
|
||||||
|
float oldalpha = alphaComposite;
|
||||||
|
setAlphaComposite(0.4f);
|
||||||
|
fillRect(Color.BLACK, x, y, w, h);
|
||||||
|
setAlphaComposite(oldalpha);
|
||||||
|
}
|
||||||
|
}
|
||||||
public void drawWarpImage(Texture image, float x, float y, float w, float h, float time) {
|
public void drawWarpImage(Texture image, float x, float y, float w, float h, float time) {
|
||||||
batch.end();
|
batch.end();
|
||||||
shaderWarp.bind();
|
shaderWarp.bind();
|
||||||
|
|||||||
@@ -1,16 +1,20 @@
|
|||||||
package forge.screens;
|
package forge.screens;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
import forge.Forge;
|
import forge.Forge;
|
||||||
import forge.Graphics;
|
import forge.Graphics;
|
||||||
|
import forge.adventure.util.Config;
|
||||||
import forge.animation.ForgeAnimation;
|
import forge.animation.ForgeAnimation;
|
||||||
import forge.assets.FSkin;
|
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;
|
||||||
@@ -21,7 +25,7 @@ public class SplashScreen extends FContainer {
|
|||||||
private TextureRegion background;
|
private TextureRegion background;
|
||||||
private final FProgressBar progressBar;
|
private final FProgressBar progressBar;
|
||||||
private FSkinFont disclaimerFont;
|
private FSkinFont disclaimerFont;
|
||||||
private boolean preparedForDialogs, showModeSelector, init, animateLogo;
|
private boolean preparedForDialogs, showModeSelector, init, animateLogo, hideBG, hideBtn, startClassic;
|
||||||
private FButton btnAdventure, btnHome;
|
private FButton btnAdventure, btnHome;
|
||||||
private BGAnimation bgAnimation;
|
private BGAnimation bgAnimation;
|
||||||
|
|
||||||
@@ -38,6 +42,14 @@ public class SplashScreen extends FContainer {
|
|||||||
public void setBackground(TextureRegion background0) {
|
public void setBackground(TextureRegion background0) {
|
||||||
background = background0;
|
background = background0;
|
||||||
}
|
}
|
||||||
|
public void startClassic() {
|
||||||
|
startClassic = true;
|
||||||
|
hideBtn = true;
|
||||||
|
hideBG = true;
|
||||||
|
bgAnimation.DURATION = 1f;
|
||||||
|
bgAnimation.progress = 0;
|
||||||
|
bgAnimation.openAdventure = false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doLayout(float width, float height) {
|
protected void doLayout(float width, float height) {
|
||||||
@@ -76,35 +88,60 @@ public class SplashScreen extends FContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class BGAnimation extends ForgeAnimation {
|
private class BGAnimation extends ForgeAnimation {
|
||||||
private static final 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...
|
||||||
|
Texture transition_bg = new Texture(GuiBase.isAndroid() ? Gdx.files.internal("fallback_skin").child("title_bg_lq.png") : Config.instance().getFile("ui/title_bg.png"));
|
||||||
|
|
||||||
public void drawBackground(Graphics g) {
|
public void drawBackground(Graphics g) {
|
||||||
float percentage = progress / DURATION;
|
float percentage = progress / DURATION;
|
||||||
|
float oldAlpha = g.getfloatAlphaComposite();
|
||||||
if (percentage < 0) {
|
if (percentage < 0) {
|
||||||
percentage = 0;
|
percentage = 0;
|
||||||
} else if (percentage > 1) {
|
} else if (percentage > 1) {
|
||||||
percentage = 1;
|
percentage = 1;
|
||||||
}
|
}
|
||||||
if (animateLogo) {
|
if (startClassic) {
|
||||||
g.drawImage(FSkinTexture.BG_TEXTURE, 0, 0, getWidth(), getHeight());
|
showSplash(g, 1-percentage);
|
||||||
float xmod = Forge.getScreenHeight() > 1000 ? 1.5f : Forge.getScreenHeight() > 800 ? 1.3f : 1f;
|
} else {
|
||||||
float scale = xmod > 1f ? xmod+(percentage*0.7f) : 0.7f+(percentage*0.7f);
|
if (animateLogo) {
|
||||||
float hscale = xmod > 1f ? xmod+0.2f+(percentage*0.9f) : 0.9f+(percentage*0.9f);
|
//bg
|
||||||
float logoHeight = FSkin.hdLogo.getHeight()*scale;
|
drawTransition(g, transition_bg, openAdventure, percentage);
|
||||||
float logoWidth = FSkin.hdLogo.getWidth()*scale;
|
g.setAlphaComposite(1-percentage);
|
||||||
float logoY = getHeight()/2 - logoHeight/hscale;
|
g.drawImage(FSkinTexture.BG_TEXTURE, 0, 0, getWidth(), getHeight());
|
||||||
float logoX = getWidth()/2 - logoWidth/2;
|
g.setAlphaComposite(oldAlpha);
|
||||||
float mod = getHeight()/2 - logoHeight/2;
|
//logo
|
||||||
float oldalpha = g.getfloatAlphaComposite();
|
g.setAlphaComposite(oldAlpha-percentage);
|
||||||
g.setAlphaComposite(oldalpha-percentage);
|
float xmod = Forge.getScreenHeight() > 1000 ? 1.5f : Forge.getScreenHeight() > 800 ? 1.3f : 1f;
|
||||||
g.drawImage(FSkin.hdLogo, logoX, logoY+(mod*percentage), logoWidth, logoHeight);
|
xmod += 10 * percentage;
|
||||||
g.setAlphaComposite(oldalpha);
|
g.drawImage(FSkin.hdLogo, getWidth()/2 - (FSkin.hdLogo.getWidth()*xmod)/2, getHeight()/2 - (FSkin.hdLogo.getHeight()*xmod)/1.5f, FSkin.hdLogo.getWidth()*xmod, FSkin.hdLogo.getHeight()*xmod);
|
||||||
} else if (showModeSelector)
|
g.setAlphaComposite(oldAlpha);
|
||||||
showSelector(g);
|
} else {
|
||||||
else
|
g.setAlphaComposite(hideBG ? 1-percentage : 1);
|
||||||
showSplash(g);
|
if (showModeSelector) {
|
||||||
|
showSelector(g, hideBG ? 1 - percentage : 1);
|
||||||
|
} else {
|
||||||
|
showSplash(g, 1);
|
||||||
|
}
|
||||||
|
g.setAlphaComposite(oldAlpha);
|
||||||
|
if (hideBG) {
|
||||||
|
g.setAlphaComposite(0+percentage);
|
||||||
|
drawTransition(g, transition_bg, openAdventure, percentage);
|
||||||
|
g.setAlphaComposite(oldAlpha);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hideBtn) {
|
||||||
|
if (btnAdventure != null) {
|
||||||
|
float y = btnAdventure.getTop();
|
||||||
|
btnAdventure.setTop(y+(getHeight()/16 * percentage));
|
||||||
|
}
|
||||||
|
if (btnHome != null) {
|
||||||
|
float y = btnHome.getTop();
|
||||||
|
btnHome.setTop(y+(getHeight()/16 * percentage));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -115,11 +152,12 @@ public class SplashScreen extends FContainer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onEnd(boolean endingAll) {
|
protected void onEnd(boolean endingAll) {
|
||||||
if (animateLogo) {
|
if (animateLogo||hideBG) {
|
||||||
if (openAdventure)
|
if (openAdventure)
|
||||||
Forge.openAdventure();
|
Forge.openAdventure();
|
||||||
else
|
else
|
||||||
Forge.openHomeDefault();
|
Forge.openHomeDefault();
|
||||||
|
Forge.clearSplashScreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,8 +167,19 @@ public class SplashScreen extends FContainer {
|
|||||||
bgAnimation.start();
|
bgAnimation.start();
|
||||||
bgAnimation.drawBackground(g);
|
bgAnimation.drawBackground(g);
|
||||||
}
|
}
|
||||||
|
void drawTransition(Graphics g, Texture bg, boolean openAdventure, float percentage) {
|
||||||
private void showSelector(Graphics g) {
|
float oldAlpha = g.getfloatAlphaComposite();
|
||||||
|
g.setAlphaComposite(percentage);
|
||||||
|
if (openAdventure) {
|
||||||
|
if (bg != null) {
|
||||||
|
g.drawGrayTransitionImage(bg, 0, 0, getWidth(), getHeight(), false, percentage*1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
g.fillRect(FSkinColor.get(FSkinColor.Colors.CLR_THEME),0, 0, getWidth(), getHeight());
|
||||||
|
}
|
||||||
|
g.setAlphaComposite(oldAlpha);
|
||||||
|
}
|
||||||
|
private void showSelector(Graphics g, float alpha) {
|
||||||
g.drawImage(FSkinTexture.BG_TEXTURE, 0, 0, getWidth(), getHeight());
|
g.drawImage(FSkinTexture.BG_TEXTURE, 0, 0, getWidth(), getHeight());
|
||||||
|
|
||||||
float x, y, w, h;
|
float x, y, w, h;
|
||||||
@@ -159,16 +208,19 @@ public class SplashScreen extends FContainer {
|
|||||||
float height = 57f / 450f * h;
|
float height = 57f / 450f * h;
|
||||||
|
|
||||||
if (!init) {
|
if (!init) {
|
||||||
|
init = true;
|
||||||
btnAdventure = new FButton(Localizer.getInstance().getMessageorUseDefault("lblAdventureMode", "Adventure Mode"));
|
btnAdventure = new FButton(Localizer.getInstance().getMessageorUseDefault("lblAdventureMode", "Adventure Mode"));
|
||||||
btnHome = new FButton(Localizer.getInstance().getMessageorUseDefault("lblClassicMode", "Classic Mode"));
|
btnHome = new FButton(Localizer.getInstance().getMessageorUseDefault("lblClassicMode", "Classic Mode"));
|
||||||
btnAdventure.setCommand(new FEvent.FEventHandler() {
|
btnAdventure.setCommand(new FEvent.FEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(FEvent e) {
|
public void handleEvent(FEvent e) {
|
||||||
if (FSkin.hdLogo == null)
|
if (FSkin.hdLogo == null) {
|
||||||
Forge.openAdventure();
|
hideBG = true;
|
||||||
else {
|
hideBtn = true;
|
||||||
btnAdventure.setVisible(false);
|
bgAnimation.progress = 0;
|
||||||
btnHome.setVisible(false);
|
bgAnimation.openAdventure = true;
|
||||||
|
} else {
|
||||||
|
hideBtn = true;
|
||||||
animateLogo = true;
|
animateLogo = true;
|
||||||
bgAnimation.progress = 0;
|
bgAnimation.progress = 0;
|
||||||
bgAnimation.openAdventure = true;
|
bgAnimation.openAdventure = true;
|
||||||
@@ -178,11 +230,13 @@ public class SplashScreen extends FContainer {
|
|||||||
btnHome.setCommand(new FEvent.FEventHandler() {
|
btnHome.setCommand(new FEvent.FEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(FEvent e) {
|
public void handleEvent(FEvent e) {
|
||||||
if (FSkin.hdLogo == null)
|
if (FSkin.hdLogo == null) {
|
||||||
Forge.openHomeDefault();
|
hideBG = true;
|
||||||
else {
|
hideBtn = true;
|
||||||
btnAdventure.setVisible(false);
|
bgAnimation.progress = 0;
|
||||||
btnHome.setVisible(false);
|
bgAnimation.openAdventure = false;
|
||||||
|
} else {
|
||||||
|
hideBtn = true;
|
||||||
animateLogo = true;
|
animateLogo = true;
|
||||||
bgAnimation.progress = 0;
|
bgAnimation.progress = 0;
|
||||||
bgAnimation.openAdventure = false;
|
bgAnimation.openAdventure = false;
|
||||||
@@ -198,12 +252,16 @@ public class SplashScreen extends FContainer {
|
|||||||
add(btnHome);
|
add(btnHome);
|
||||||
btnAdventure.setBounds(btn_x, btn_y+height+padding/2, btn_w, height);
|
btnAdventure.setBounds(btn_x, btn_y+height+padding/2, btn_w, height);
|
||||||
add(btnAdventure);
|
add(btnAdventure);
|
||||||
init = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void showSplash(Graphics g) {
|
private void showSplash(Graphics g, float alpha) {
|
||||||
|
float oldAlpha = g.getfloatAlphaComposite();
|
||||||
|
g.setAlphaComposite(alpha);
|
||||||
|
drawDisclaimer(g);
|
||||||
|
g.setAlphaComposite(oldAlpha);
|
||||||
|
}
|
||||||
|
void drawDisclaimer(Graphics g) {
|
||||||
if (background == null) { return; }
|
if (background == null) { return; }
|
||||||
|
|
||||||
g.drawImage(FSkinTexture.BG_TEXTURE, 0, 0, getWidth(), getHeight());
|
g.drawImage(FSkinTexture.BG_TEXTURE, 0, 0, getWidth(), getHeight());
|
||||||
|
|
||||||
float x, y, w, h;
|
float x, y, w, h;
|
||||||
@@ -214,8 +272,7 @@ public class SplashScreen extends FContainer {
|
|||||||
w = getWidth();
|
w = getWidth();
|
||||||
h = getWidth() * backgroundRatio;
|
h = getWidth() * backgroundRatio;
|
||||||
y = (getHeight() - h) / 2;
|
y = (getHeight() - h) / 2;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
y = 0;
|
y = 0;
|
||||||
h = getHeight();
|
h = getHeight();
|
||||||
w = getHeight() / backgroundRatio;
|
w = getHeight() / backgroundRatio;
|
||||||
|
|||||||
Reference in New Issue
Block a user