update SplashScreen

- Adventure Splashscreen will be used if default startup is Adventure Mode.
This commit is contained in:
Anthony Calosa
2022-11-21 14:51:16 +08:00
parent 08b72fdc3c
commit 3db079d8e3
12 changed files with 127 additions and 55 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -37,6 +37,8 @@
<include>**/*.frag</include> <include>**/*.frag</include>
<include>**/title_bg_lq.png</include> <include>**/title_bg_lq.png</include>
<include>**/transition.png</include> <include>**/transition.png</include>
<include>**/adv_bg_texture.jpg</include>
<include>**/adv_bg_splash.png</include>
<include>**/bg_splash.png</include> <include>**/bg_splash.png</include>
<include>**/bg_texture.jpg</include> <include>**/bg_texture.jpg</include>
<include>**/font1.ttf</include> <include>**/font1.ttf</include>

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -21,6 +21,8 @@
<include>**/*.frag</include> <include>**/*.frag</include>
<include>**/title_bg_lq.png</include> <include>**/title_bg_lq.png</include>
<include>**/transition.png</include> <include>**/transition.png</include>
<include>**/adv_bg_texture.jpg</include>
<include>**/adv_bg_splash.png</include>
<include>**/bg_splash.png</include> <include>**/bg_splash.png</include>
<include>**/bg_texture.jpg</include> <include>**/bg_texture.jpg</include>
<include>**/font1.ttf</include> <include>**/font1.ttf</include>

View File

@@ -172,7 +172,7 @@ public class Forge implements ApplicationListener {
Gdx.input.setCatchKey(Keys.BACK, true); Gdx.input.setCatchKey(Keys.BACK, true);
destroyThis = true; //Prevent back() destroyThis = true; //Prevent back()
ForgePreferences prefs = new ForgePreferences(); ForgePreferences prefs = new ForgePreferences();
selector = prefs.getPref(FPref.UI_SELECTOR_MODE);
String skinName; String skinName;
if (FileUtil.doesFileExist(ForgeConstants.MAIN_PREFS_FILE)) { if (FileUtil.doesFileExist(ForgeConstants.MAIN_PREFS_FILE)) {
skinName = prefs.getPref(FPref.UI_SKIN); skinName = prefs.getPref(FPref.UI_SKIN);
@@ -187,7 +187,6 @@ public class Forge implements ApplicationListener {
altPlayerLayout = prefs.getPrefBoolean(FPref.UI_ALT_PLAYERINFOLAYOUT); altPlayerLayout = prefs.getPrefBoolean(FPref.UI_ALT_PLAYERINFOLAYOUT);
altZoneTabs = prefs.getPrefBoolean(FPref.UI_ALT_PLAYERZONETABS); altZoneTabs = prefs.getPrefBoolean(FPref.UI_ALT_PLAYERZONETABS);
animatedCardTapUntap = prefs.getPrefBoolean(FPref.UI_ANIMATED_CARD_TAPUNTAP); animatedCardTapUntap = prefs.getPrefBoolean(FPref.UI_ANIMATED_CARD_TAPUNTAP);
selector = prefs.getPref(FPref.UI_SELECTOR_MODE);
enableUIMask = prefs.getPref(FPref.UI_ENABLE_BORDER_MASKING); enableUIMask = prefs.getPref(FPref.UI_ENABLE_BORDER_MASKING);
if (prefs.getPref(FPref.UI_ENABLE_BORDER_MASKING).equals("true")) //override old settings if not updated if (prefs.getPref(FPref.UI_ENABLE_BORDER_MASKING).equals("true")) //override old settings if not updated
enableUIMask = "Full"; enableUIMask = "Full";
@@ -363,6 +362,7 @@ public class Forge implements ApplicationListener {
if (selector.equals("Adventure")) { if (selector.equals("Adventure")) {
//preload adventure resources to speedup startup if selector is adventure. Needs in edt when setting up worldstage //preload adventure resources to speedup startup if selector is adventure. Needs in edt when setting up worldstage
loadAdventureResources(false); loadAdventureResources(false);
Forge.isMobileAdventureMode = true;
} }
//selection transition //selection transition
setTransitionScreen(new TransitionScreen(() -> { setTransitionScreen(new TransitionScreen(() -> {

View File

@@ -153,6 +153,8 @@ public class FSkin {
if (splashScreen != null) { if (splashScreen != null) {
final FileHandle f = getSkinFile("bg_splash.png"); final FileHandle f = getSkinFile("bg_splash.png");
final FileHandle f2 = getSkinFile("bg_splash_hd.png"); //HD Splashscreen final FileHandle f2 = getSkinFile("bg_splash_hd.png"); //HD Splashscreen
final FileHandle f3 = getSkinFile("adv_bg_splash.png"); //Adventure splash
final FileHandle f4 = getSkinFile("adv_bg_texture.jpg"); //Adventure splash
if (!f.exists()) { if (!f.exists()) {
if (!skinName.equals("default")) { if (!skinName.equals("default")) {
@@ -168,7 +170,7 @@ public class FSkin {
Texture txSplash = new Texture(f); Texture txSplash = new Texture(f);
w = txSplash.getWidth(); w = txSplash.getWidth();
h = txSplash.getHeight(); h = txSplash.getHeight();
splashScreen.setBackground(new TextureRegion(txSplash, 0, 0, w, h - 100)); splashScreen.setSplashTexture(new TextureRegion(txSplash, 0, 0, w, h - 100));
} else { } else {
manager.load(f.path(), Texture.class); manager.load(f.path(), Texture.class);
manager.finishLoadingAsset(f.path()); manager.finishLoadingAsset(f.path());
@@ -178,13 +180,23 @@ public class FSkin {
if (f2.exists()) { if (f2.exists()) {
manager.load(f2.path(), Texture.class, Forge.getAssets().getTextureFilter()); manager.load(f2.path(), Texture.class, Forge.getAssets().getTextureFilter());
manager.finishLoadingAsset(f2.path()); manager.finishLoadingAsset(f2.path());
splashScreen.setBackground(new TextureRegion(manager.get(f2.path(), Texture.class))); splashScreen.setSplashTexture(new TextureRegion(manager.get(f2.path(), Texture.class)));
} else { } else {
splashScreen.setBackground(new TextureRegion(manager.get(f.path(), Texture.class), 0, 0, w, h - 100)); splashScreen.setSplashTexture(new TextureRegion(manager.get(f.path(), Texture.class), 0, 0, w, h - 100));
} }
} }
Pixmap pxSplash = new Pixmap(f); Pixmap pxSplash = new Pixmap(f);
//override splashscreen startup
if (Forge.selector.equals("Adventure")) {
Texture advSplash = new Texture(f3);
Texture advBG = new Texture(f4);
advBG.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat);
w = advSplash.getWidth();
h = advSplash.getHeight();
splashScreen.setSplashTexture(new TextureRegion(advSplash, 0, 0, w, h - 100));
splashScreen.setSplashBGTexture(advBG);
pxSplash = new Pixmap(f3);
}
FProgressBar.BACK_COLOR = new Color(pxSplash.getPixel(25, h - 75)); FProgressBar.BACK_COLOR = new Color(pxSplash.getPixel(25, h - 75));
FProgressBar.FORE_COLOR = new Color(pxSplash.getPixel(75, h - 75)); FProgressBar.FORE_COLOR = new Color(pxSplash.getPixel(75, h - 75));
FProgressBar.SEL_BACK_COLOR = new Color(pxSplash.getPixel(25, h - 25)); FProgressBar.SEL_BACK_COLOR = new Color(pxSplash.getPixel(25, h - 25));

View File

@@ -1,6 +1,7 @@
package forge.screens; package forge.screens;
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,29 +14,41 @@ import forge.assets.FSkinFont;
import forge.assets.FSkinTexture; import forge.assets.FSkinTexture;
import forge.toolbox.FButton; import forge.toolbox.FButton;
import forge.toolbox.FContainer; import forge.toolbox.FContainer;
import forge.toolbox.FEvent;
import forge.toolbox.FProgressBar; import forge.toolbox.FProgressBar;
public class SplashScreen extends FContainer { public class SplashScreen extends FContainer {
private TextureRegion background; private TextureRegion splashTexture;
private final FProgressBar progressBar; private Texture splashBGTexture;
private FProgressBar progressBar;
private FSkinFont disclaimerFont; private FSkinFont disclaimerFont;
private boolean preparedForDialogs, showModeSelector, init, animateLogo, hideBG, hideBtn, startClassic, clear; private boolean preparedForDialogs, showModeSelector, init, animateLogo, hideBG, hideBtn, startClassic, clear;
private FButton btnAdventure, btnHome; private FButton btnAdventure, btnHome;
private BGAnimation bgAnimation; private BGAnimation bgAnimation;
public SplashScreen() { public SplashScreen() {
progressBar = new FProgressBar(); progressBar = getProgressBar();
progressBar.setDescription("Welcome to Forge"); bgAnimation = getBgAnimation();
bgAnimation = new BGAnimation();
} }
public BGAnimation getBgAnimation() {
if (bgAnimation == null) {
bgAnimation = new BGAnimation();
}
return bgAnimation;
}
public FProgressBar getProgressBar() { public FProgressBar getProgressBar() {
if (progressBar == null) {
progressBar = new FProgressBar();
progressBar.setDescription("Welcome to Forge");
}
return progressBar; return progressBar;
} }
public void setBackground(TextureRegion background0) { public void setSplashTexture(TextureRegion textureRegion) {
background = background0; splashTexture = textureRegion;
}
public void setSplashBGTexture(Texture texture) {
splashBGTexture = texture;
} }
public void startClassic() { public void startClassic() {
@@ -93,7 +106,59 @@ 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;
private void drawAdventureBackground(Graphics g) {
float percentage = progress / DURATION;
float oldAlpha = g.getfloatAlphaComposite();
if (percentage < 0) {
percentage = 0;
} else if (percentage > 1) {
percentage = 1;
}
g.fillRect(Color.BLACK, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight());
g.setAlphaComposite(percentage);
g.drawRepeatingImage(splashBGTexture, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight());
g.setAlphaComposite(oldAlpha);
float x, y, w, h;
float backgroundRatio = (float) splashTexture.getRegionWidth() / splashTexture.getRegionHeight();
float screenRatio = getWidth() / getHeight();
if (backgroundRatio > screenRatio) {
x = 0;
w = getWidth();
h = getWidth() * backgroundRatio;
y = (getHeight() - h) / 2;
} else {
y = 0;
h = getHeight();
w = getHeight() / backgroundRatio;
x = (getWidth() - w) / 2;
}
float hmod = Forge.isLandscapeMode() ? 1f : 1.3f;
float ymod = 2.6f;
g.drawImage(splashTexture, Forge.getScreenWidth()/2 - (w*percentage*hmod)/2 , Forge.getScreenHeight()/2 - (h*percentage*hmod)/ymod, (w*percentage)*hmod, (h*percentage)*hmod);
y += h * 295f / 450f;
if (disclaimerFont == null) {
disclaimerFont = FSkinFont.get(9);
}
float disclaimerHeight = 30f / 450f * h;
if (Forge.forcedEnglishonCJKMissing && !clear) {
clear = true;
FSkinFont.preloadAll("");
disclaimerFont = FSkinFont.get(9);
}
float padding = 20f / 450f * w;
float pbHeight = 57f / 450f * h;
y += 78f / 450f * h;
float w2 = Forge.isLandscapeMode() ? Forge.getScreenWidth() / 2 : Forge.getScreenHeight() / 2;
float h2 = 57f / 450f * (w2/2);
String version = "v. " + Forge.CURRENT_VERSION;
g.drawText(version, disclaimerFont, FProgressBar.SEL_FORE_COLOR, x, getHeight() - disclaimerHeight, w, disclaimerHeight, false, Align.center, true);
progressBar.setBounds(x + padding, Forge.getScreenHeight() - h2 * 2f, w2, h2);
g.draw(progressBar);
}
public void drawBackground(Graphics g) { public void drawBackground(Graphics g) {
float percentage = progress / DURATION; float percentage = progress / DURATION;
float oldAlpha = g.getfloatAlphaComposite(); float oldAlpha = g.getfloatAlphaComposite();
@@ -165,17 +230,14 @@ public class SplashScreen extends FContainer {
@Override @Override
protected void drawBackground(Graphics g) { protected void drawBackground(Graphics g) {
bgAnimation.start(); bgAnimation.start();
bgAnimation.drawBackground(g); if (!Forge.selector.equalsIgnoreCase("Adventure"))
bgAnimation.drawBackground(g);
else
bgAnimation.drawAdventureBackground(g);
} }
void drawTransition(Graphics g, boolean openAdventure, float percentage) { void drawTransition(Graphics g, boolean openAdventure, float percentage) {
TextureRegion tr = new TextureRegion(Forge.getAssets().fallback_skins().get(0)); TextureRegion tr = new TextureRegion(Forge.getAssets().fallback_skins().get(0));
if (!Forge.isLandscapeMode() && tr != null) {
float ar = 1.78f;
int w = (int) (tr.getRegionHeight() / ar);
int x = (int) ((tr.getRegionWidth() - w) / ar);
tr.setRegion(x, 0, w, tr.getRegionHeight());
}
float oldAlpha = g.getfloatAlphaComposite(); float oldAlpha = g.getfloatAlphaComposite();
g.setAlphaComposite(percentage); g.setAlphaComposite(percentage);
if (openAdventure) { if (openAdventure) {
@@ -189,14 +251,14 @@ public class SplashScreen extends FContainer {
} }
private void showSelector(Graphics g, float alpha) { private void showSelector(Graphics g, float alpha) {
if (background == null) { if (splashTexture == null) {
return; return;
} }
g.fillRect(Color.BLACK, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight()); g.fillRect(Color.BLACK, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight());
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;
float backgroundRatio = (float) background.getRegionWidth() / background.getRegionHeight(); float backgroundRatio = (float) splashTexture.getRegionWidth() / splashTexture.getRegionHeight();
float screenRatio = getWidth() / getHeight(); float screenRatio = getWidth() / getHeight();
if (backgroundRatio > screenRatio) { if (backgroundRatio > screenRatio) {
x = 0; x = 0;
@@ -213,7 +275,7 @@ public class SplashScreen extends FContainer {
float xmod = Forge.getScreenHeight() > 1000 ? 1.5f : Forge.getScreenHeight() > 800 ? 1.3f : 1f; float xmod = Forge.getScreenHeight() > 1000 ? 1.5f : Forge.getScreenHeight() > 800 ? 1.3f : 1f;
g.drawImage(FSkin.getLogo(), getWidth() / 2 - (FSkin.getLogo().getWidth() * xmod) / 2, getHeight() / 2 - (FSkin.getLogo().getHeight() * xmod) / 1.5f, FSkin.getLogo().getWidth() * xmod, FSkin.getLogo().getHeight() * xmod); g.drawImage(FSkin.getLogo(), getWidth() / 2 - (FSkin.getLogo().getWidth() * xmod) / 2, getHeight() / 2 - (FSkin.getLogo().getHeight() * xmod) / 1.5f, FSkin.getLogo().getWidth() * xmod, FSkin.getLogo().getHeight() * xmod);
} else { } else {
g.drawImage(background, x, y, w, h); g.drawImage(splashTexture, x, y, w, h);
} }
y += h * 295f / 450f; y += h * 295f / 450f;
float padding = 20f / 450f * w; float padding = 20f / 450f * w;
@@ -223,36 +285,30 @@ public class SplashScreen extends FContainer {
init = true; init = true;
btnAdventure = new FButton(Forge.getLocalizer().getMessageorUseDefault("lblAdventureMode", "Adventure Mode")); btnAdventure = new FButton(Forge.getLocalizer().getMessageorUseDefault("lblAdventureMode", "Adventure Mode"));
btnHome = new FButton(Forge.getLocalizer().getMessageorUseDefault("lblClassicMode", "Classic Mode")); btnHome = new FButton(Forge.getLocalizer().getMessageorUseDefault("lblClassicMode", "Classic Mode"));
btnAdventure.setCommand(new FEvent.FEventHandler() { btnAdventure.setCommand(e -> {
@Override if (FSkin.getLogo() == null) {
public void handleEvent(FEvent e) { hideBG = true;
if (FSkin.getLogo() == null) { hideBtn = true;
hideBG = true; bgAnimation.progress = 0;
hideBtn = true; bgAnimation.openAdventure = true;
bgAnimation.progress = 0; } else {
bgAnimation.openAdventure = true; hideBtn = true;
} else { animateLogo = true;
hideBtn = true; bgAnimation.progress = 0;
animateLogo = true; bgAnimation.openAdventure = true;
bgAnimation.progress = 0;
bgAnimation.openAdventure = true;
}
} }
}); });
btnHome.setCommand(new FEvent.FEventHandler() { btnHome.setCommand(e -> {
@Override if (FSkin.getLogo() == null) {
public void handleEvent(FEvent e) { hideBG = true;
if (FSkin.getLogo() == null) { hideBtn = true;
hideBG = true; bgAnimation.progress = 0;
hideBtn = true; bgAnimation.openAdventure = false;
bgAnimation.progress = 0; } else {
bgAnimation.openAdventure = false; hideBtn = true;
} else { animateLogo = true;
hideBtn = true; bgAnimation.progress = 0;
animateLogo = true; bgAnimation.openAdventure = false;
bgAnimation.progress = 0;
bgAnimation.openAdventure = false;
}
} }
}); });
float btn_w = (w - 2 * padding); float btn_w = (w - 2 * padding);
@@ -276,14 +332,14 @@ public class SplashScreen extends FContainer {
} }
void drawDisclaimer(Graphics g) { void drawDisclaimer(Graphics g) {
if (background == null) { if (splashTexture == null) {
return; return;
} }
g.fillRect(Color.BLACK, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight()); g.fillRect(Color.BLACK, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight());
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;
float backgroundRatio = (float) background.getRegionWidth() / background.getRegionHeight(); float backgroundRatio = (float) splashTexture.getRegionWidth() / splashTexture.getRegionHeight();
float screenRatio = getWidth() / getHeight(); float screenRatio = getWidth() / getHeight();
if (backgroundRatio > screenRatio) { if (backgroundRatio > screenRatio) {
x = 0; x = 0;
@@ -296,7 +352,7 @@ public class SplashScreen extends FContainer {
w = getHeight() / backgroundRatio; w = getHeight() / backgroundRatio;
x = (getWidth() - w) / 2; x = (getWidth() - w) / 2;
} }
g.drawImage(background, x, y, w, h); g.drawImage(splashTexture, x, y, w, h);
y += h * 295f / 450f; y += h * 295f / 450f;
if (disclaimerFont == null) { if (disclaimerFont == null) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB