mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28: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 *
|
||||
* get error: No OpenGL context found in the current thread. */
|
||||
preloadExtendedArt();
|
||||
preloadBoosterDrafts();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -273,17 +272,16 @@ public class Forge implements ApplicationListener {
|
||||
public static void openHomeDefault() {
|
||||
GuiBase.setIsAdventureMode(false);
|
||||
openHomeScreen(-1, null); //default for startup
|
||||
splashScreen = null;
|
||||
isMobileAdventureMode = false;
|
||||
if (isLandscapeMode()) { //open preferred new game screen by default if landscape mode
|
||||
NewGameMenu.getPreferredScreen().open();
|
||||
}
|
||||
stopContinuousRendering(); //save power consumption by disabling continuous rendering once assets loaded
|
||||
}
|
||||
public static void openAdventure() {
|
||||
//continuous rendering is needed for adventure mode
|
||||
startContinuousRendering();
|
||||
GuiBase.setIsAdventureMode(true);
|
||||
splashScreen = null;
|
||||
isMobileAdventureMode = true;
|
||||
try {
|
||||
for (SceneType sceneType : SceneType.values()) {
|
||||
@@ -293,23 +291,16 @@ public class Forge implements ApplicationListener {
|
||||
} catch (Exception e) { e.printStackTrace(); }
|
||||
}
|
||||
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
|
||||
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()
|
||||
Gdx.input.setCatchKey(Keys.MENU, true);
|
||||
|
||||
afterDBloaded = true;
|
||||
//selection
|
||||
if (isLandscapeMode() && !GuiBase.isAndroid())
|
||||
splashScreen.setShowModeSelector(true);
|
||||
else
|
||||
openHomeDefault();
|
||||
|
||||
//adjust height modifier
|
||||
adjustHeightModifier(getScreenWidth(), getScreenHeight());
|
||||
|
||||
@@ -318,6 +309,39 @@ public class Forge implements ApplicationListener {
|
||||
FModel.getPreferences().setPref(FPref.UI_LANDSCAPE_MODE, isLandscapeMode());
|
||||
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() {
|
||||
@@ -531,6 +555,10 @@ public class Forge implements ApplicationListener {
|
||||
public static void clearCurrentScreen() {
|
||||
currentScreen = null;
|
||||
}
|
||||
|
||||
public static void clearSplashScreen() {
|
||||
splashScreen = null;
|
||||
}
|
||||
private static void setCurrentScreen(FScreen screen0) {
|
||||
String toNewScreen = screen0 != null ? screen0.toString() : "";
|
||||
String previousScreen = currentScreen != null ? currentScreen.toString() : "";
|
||||
|
||||
@@ -753,6 +753,25 @@ public class Graphics {
|
||||
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) {
|
||||
batch.end();
|
||||
shaderWarp.bind();
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
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;
|
||||
|
||||
import forge.Forge;
|
||||
import forge.Graphics;
|
||||
import forge.adventure.util.Config;
|
||||
import forge.animation.ForgeAnimation;
|
||||
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;
|
||||
@@ -21,7 +25,7 @@ public class SplashScreen extends FContainer {
|
||||
private TextureRegion background;
|
||||
private final FProgressBar progressBar;
|
||||
private FSkinFont disclaimerFont;
|
||||
private boolean preparedForDialogs, showModeSelector, init, animateLogo;
|
||||
private boolean preparedForDialogs, showModeSelector, init, animateLogo, hideBG, hideBtn, startClassic;
|
||||
private FButton btnAdventure, btnHome;
|
||||
private BGAnimation bgAnimation;
|
||||
|
||||
@@ -38,6 +42,14 @@ public class SplashScreen extends FContainer {
|
||||
public void setBackground(TextureRegion background0) {
|
||||
background = background0;
|
||||
}
|
||||
public void startClassic() {
|
||||
startClassic = true;
|
||||
hideBtn = true;
|
||||
hideBG = true;
|
||||
bgAnimation.DURATION = 1f;
|
||||
bgAnimation.progress = 0;
|
||||
bgAnimation.openAdventure = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doLayout(float width, float height) {
|
||||
@@ -76,35 +88,60 @@ public class SplashScreen extends FContainer {
|
||||
}
|
||||
|
||||
private class BGAnimation extends ForgeAnimation {
|
||||
private static final float DURATION = 0.8f;
|
||||
float DURATION = 0.8f;
|
||||
private float progress = 0;
|
||||
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) {
|
||||
float percentage = progress / DURATION;
|
||||
float oldAlpha = g.getfloatAlphaComposite();
|
||||
if (percentage < 0) {
|
||||
percentage = 0;
|
||||
} else if (percentage > 1) {
|
||||
percentage = 1;
|
||||
}
|
||||
if (startClassic) {
|
||||
showSplash(g, 1-percentage);
|
||||
} else {
|
||||
if (animateLogo) {
|
||||
//bg
|
||||
drawTransition(g, transition_bg, openAdventure, percentage);
|
||||
g.setAlphaComposite(1-percentage);
|
||||
g.drawImage(FSkinTexture.BG_TEXTURE, 0, 0, getWidth(), getHeight());
|
||||
g.setAlphaComposite(oldAlpha);
|
||||
//logo
|
||||
g.setAlphaComposite(oldAlpha-percentage);
|
||||
float xmod = Forge.getScreenHeight() > 1000 ? 1.5f : Forge.getScreenHeight() > 800 ? 1.3f : 1f;
|
||||
float scale = xmod > 1f ? xmod+(percentage*0.7f) : 0.7f+(percentage*0.7f);
|
||||
float hscale = xmod > 1f ? xmod+0.2f+(percentage*0.9f) : 0.9f+(percentage*0.9f);
|
||||
float logoHeight = FSkin.hdLogo.getHeight()*scale;
|
||||
float logoWidth = FSkin.hdLogo.getWidth()*scale;
|
||||
float logoY = getHeight()/2 - logoHeight/hscale;
|
||||
float logoX = getWidth()/2 - logoWidth/2;
|
||||
float mod = getHeight()/2 - logoHeight/2;
|
||||
float oldalpha = g.getfloatAlphaComposite();
|
||||
g.setAlphaComposite(oldalpha-percentage);
|
||||
g.drawImage(FSkin.hdLogo, logoX, logoY+(mod*percentage), logoWidth, logoHeight);
|
||||
g.setAlphaComposite(oldalpha);
|
||||
} else if (showModeSelector)
|
||||
showSelector(g);
|
||||
else
|
||||
showSplash(g);
|
||||
xmod += 10 * percentage;
|
||||
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);
|
||||
g.setAlphaComposite(oldAlpha);
|
||||
} else {
|
||||
g.setAlphaComposite(hideBG ? 1-percentage : 1);
|
||||
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
|
||||
@@ -115,11 +152,12 @@ public class SplashScreen extends FContainer {
|
||||
|
||||
@Override
|
||||
protected void onEnd(boolean endingAll) {
|
||||
if (animateLogo) {
|
||||
if (animateLogo||hideBG) {
|
||||
if (openAdventure)
|
||||
Forge.openAdventure();
|
||||
else
|
||||
Forge.openHomeDefault();
|
||||
Forge.clearSplashScreen();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,8 +167,19 @@ public class SplashScreen extends FContainer {
|
||||
bgAnimation.start();
|
||||
bgAnimation.drawBackground(g);
|
||||
}
|
||||
|
||||
private void showSelector(Graphics g) {
|
||||
void drawTransition(Graphics g, Texture bg, boolean openAdventure, float percentage) {
|
||||
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());
|
||||
|
||||
float x, y, w, h;
|
||||
@@ -159,16 +208,19 @@ public class SplashScreen extends FContainer {
|
||||
float height = 57f / 450f * h;
|
||||
|
||||
if (!init) {
|
||||
init = true;
|
||||
btnAdventure = new FButton(Localizer.getInstance().getMessageorUseDefault("lblAdventureMode", "Adventure Mode"));
|
||||
btnHome = new FButton(Localizer.getInstance().getMessageorUseDefault("lblClassicMode", "Classic Mode"));
|
||||
btnAdventure.setCommand(new FEvent.FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
if (FSkin.hdLogo == null)
|
||||
Forge.openAdventure();
|
||||
else {
|
||||
btnAdventure.setVisible(false);
|
||||
btnHome.setVisible(false);
|
||||
if (FSkin.hdLogo == null) {
|
||||
hideBG = true;
|
||||
hideBtn = true;
|
||||
bgAnimation.progress = 0;
|
||||
bgAnimation.openAdventure = true;
|
||||
} else {
|
||||
hideBtn = true;
|
||||
animateLogo = true;
|
||||
bgAnimation.progress = 0;
|
||||
bgAnimation.openAdventure = true;
|
||||
@@ -178,11 +230,13 @@ public class SplashScreen extends FContainer {
|
||||
btnHome.setCommand(new FEvent.FEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(FEvent e) {
|
||||
if (FSkin.hdLogo == null)
|
||||
Forge.openHomeDefault();
|
||||
else {
|
||||
btnAdventure.setVisible(false);
|
||||
btnHome.setVisible(false);
|
||||
if (FSkin.hdLogo == null) {
|
||||
hideBG = true;
|
||||
hideBtn = true;
|
||||
bgAnimation.progress = 0;
|
||||
bgAnimation.openAdventure = false;
|
||||
} else {
|
||||
hideBtn = true;
|
||||
animateLogo = true;
|
||||
bgAnimation.progress = 0;
|
||||
bgAnimation.openAdventure = false;
|
||||
@@ -198,12 +252,16 @@ public class SplashScreen extends FContainer {
|
||||
add(btnHome);
|
||||
btnAdventure.setBounds(btn_x, btn_y+height+padding/2, btn_w, height);
|
||||
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; }
|
||||
|
||||
g.drawImage(FSkinTexture.BG_TEXTURE, 0, 0, getWidth(), getHeight());
|
||||
|
||||
float x, y, w, h;
|
||||
@@ -214,8 +272,7 @@ public class SplashScreen extends FContainer {
|
||||
w = getWidth();
|
||||
h = getWidth() * backgroundRatio;
|
||||
y = (getHeight() - h) / 2;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
y = 0;
|
||||
h = getHeight();
|
||||
w = getHeight() / backgroundRatio;
|
||||
|
||||
Reference in New Issue
Block a user