mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 10:18:01 +00:00
#CloseScreen
This commit is contained in:
@@ -4,6 +4,8 @@ import com.badlogic.gdx.ApplicationListener;
|
|||||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
|
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
|
||||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
|
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
|
||||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Clipboard;
|
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Clipboard;
|
||||||
|
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window;
|
||||||
|
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3WindowListener;
|
||||||
import com.badlogic.gdx.graphics.glutils.HdpiMode;
|
import com.badlogic.gdx.graphics.glutils.HdpiMode;
|
||||||
import forge.Forge;
|
import forge.Forge;
|
||||||
import forge.adventure.util.Config;
|
import forge.adventure.util.Config;
|
||||||
@@ -47,6 +49,50 @@ public class Main {
|
|||||||
}
|
}
|
||||||
config.setTitle("Forge Adventure Mobile");
|
config.setTitle("Forge Adventure Mobile");
|
||||||
config.setWindowIcon(Config.instance().getFilePath("forge-adventure.png"));
|
config.setWindowIcon(Config.instance().getFilePath("forge-adventure.png"));
|
||||||
|
config.setWindowListener(new Lwjgl3WindowListener() {
|
||||||
|
@Override
|
||||||
|
public void created(Lwjgl3Window lwjgl3Window) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void iconified(boolean b) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void maximized(boolean b) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void focusLost() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void focusGained() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean closeRequested() {
|
||||||
|
//use the device adpater to exit properly
|
||||||
|
if (Forge.safeToClose)
|
||||||
|
Forge.exit(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void filesDropped(String[] strings) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refreshRequested() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
new Lwjgl3Application(start, config);
|
new Lwjgl3Application(start, config);
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import java.io.OutputStream;
|
|||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window;
|
||||||
|
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3WindowListener;
|
||||||
import com.badlogic.gdx.graphics.glutils.HdpiMode;
|
import com.badlogic.gdx.graphics.glutils.HdpiMode;
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.commons.cli.CommandLineParser;
|
import org.apache.commons.cli.CommandLineParser;
|
||||||
@@ -106,6 +108,50 @@ public class Main {
|
|||||||
config.setAutoIconify(true); //fix alt-tab when running fullscreen
|
config.setAutoIconify(true); //fix alt-tab when running fullscreen
|
||||||
}
|
}
|
||||||
config.setTitle("Forge");
|
config.setTitle("Forge");
|
||||||
|
config.setWindowListener(new Lwjgl3WindowListener() {
|
||||||
|
@Override
|
||||||
|
public void created(Lwjgl3Window lwjgl3Window) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void iconified(boolean b) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void maximized(boolean b) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void focusLost() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void focusGained() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean closeRequested() {
|
||||||
|
//use the device adpater to exit properly
|
||||||
|
if (Forge.safeToClose)
|
||||||
|
Forge.exit(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void filesDropped(String[] strings) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refreshRequested() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
if (desktopMode)
|
if (desktopMode)
|
||||||
config.setHdpiMode(HdpiMode.Logical);
|
config.setHdpiMode(HdpiMode.Logical);
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import forge.localinstance.properties.ForgeConstants;
|
|||||||
import forge.localinstance.properties.ForgePreferences;
|
import forge.localinstance.properties.ForgePreferences;
|
||||||
import forge.localinstance.properties.ForgePreferences.FPref;
|
import forge.localinstance.properties.ForgePreferences.FPref;
|
||||||
import forge.model.FModel;
|
import forge.model.FModel;
|
||||||
|
import forge.screens.ClosingScreen;
|
||||||
import forge.screens.FScreen;
|
import forge.screens.FScreen;
|
||||||
import forge.screens.SplashScreen;
|
import forge.screens.SplashScreen;
|
||||||
import forge.screens.home.HomeScreen;
|
import forge.screens.home.HomeScreen;
|
||||||
@@ -66,8 +67,10 @@ public class Forge implements ApplicationListener {
|
|||||||
private static FrameRate frameRate;
|
private static FrameRate frameRate;
|
||||||
private static FScreen currentScreen;
|
private static FScreen currentScreen;
|
||||||
protected static SplashScreen splashScreen;
|
protected static SplashScreen splashScreen;
|
||||||
|
protected static ClosingScreen closingScreen;
|
||||||
public static KeyInputAdapter keyInputAdapter;
|
public static KeyInputAdapter keyInputAdapter;
|
||||||
private static boolean exited;
|
private static boolean exited;
|
||||||
|
public static boolean safeToClose = false;
|
||||||
private static int continuousRenderingCount = 1; //initialize to 1 since continuous rendering is the default
|
private static int continuousRenderingCount = 1; //initialize to 1 since continuous rendering is the default
|
||||||
private static final Deque<FScreen> Dscreens = new ArrayDeque<>();
|
private static final Deque<FScreen> Dscreens = new ArrayDeque<>();
|
||||||
private static boolean textureFiltering = false;
|
private static boolean textureFiltering = false;
|
||||||
@@ -334,6 +337,7 @@ public class Forge implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
//start background music
|
//start background music
|
||||||
SoundSystem.instance.setBackgroundMusic(MusicPlaylist.MENUS);
|
SoundSystem.instance.setBackgroundMusic(MusicPlaylist.MENUS);
|
||||||
|
Forge.safeToClose = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -452,7 +456,7 @@ public class Forge implements ApplicationListener {
|
|||||||
public void run(Boolean result) {
|
public void run(Boolean result) {
|
||||||
if (result) {
|
if (result) {
|
||||||
exited = true;
|
exited = true;
|
||||||
deviceAdapter.restart();
|
exitAnimation(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -477,7 +481,7 @@ public class Forge implements ApplicationListener {
|
|||||||
public void run(Boolean result) {
|
public void run(Boolean result) {
|
||||||
if (result) {
|
if (result) {
|
||||||
exited = true;
|
exited = true;
|
||||||
deviceAdapter.exit();
|
exitAnimation(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -595,7 +599,9 @@ public class Forge implements ApplicationListener {
|
|||||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // Clear the screen.
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // Clear the screen.
|
||||||
|
|
||||||
FContainer screen = currentScreen;
|
FContainer screen = currentScreen;
|
||||||
if (screen == null) {
|
if (closingScreen != null) {
|
||||||
|
screen = closingScreen;
|
||||||
|
} else if (screen == null) {
|
||||||
screen = splashScreen;
|
screen = splashScreen;
|
||||||
if (screen == null) {
|
if (screen == null) {
|
||||||
if (isMobileAdventureMode) {
|
if (isMobileAdventureMode) {
|
||||||
@@ -801,6 +807,12 @@ public class Forge implements ApplicationListener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void exitAnimation(boolean restart) {
|
||||||
|
if (closingScreen == null) {
|
||||||
|
closingScreen = new ClosingScreen(restart);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static abstract class KeyInputAdapter {
|
public static abstract class KeyInputAdapter {
|
||||||
public abstract FDisplayObject getOwner();
|
public abstract FDisplayObject getOwner();
|
||||||
public abstract boolean allowTouchInput();
|
public abstract boolean allowTouchInput();
|
||||||
@@ -869,7 +881,7 @@ public class Forge implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
if(keyCode == Keys.BACK){
|
if(keyCode == Keys.BACK){
|
||||||
if (destroyThis)
|
if (destroyThis)
|
||||||
deviceAdapter.exit();
|
exitAnimation(false);
|
||||||
else if(onHomeScreen() && isLandscapeMode())
|
else if(onHomeScreen() && isLandscapeMode())
|
||||||
back();
|
back();
|
||||||
}
|
}
|
||||||
|
|||||||
112
forge-gui-mobile/src/forge/screens/ClosingScreen.java
Normal file
112
forge-gui-mobile/src/forge/screens/ClosingScreen.java
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
package forge.screens;
|
||||||
|
|
||||||
|
import forge.Forge;
|
||||||
|
import forge.Graphics;
|
||||||
|
import forge.animation.ForgeAnimation;
|
||||||
|
import forge.assets.FSkin;
|
||||||
|
import forge.assets.FSkinImage;
|
||||||
|
import forge.assets.FSkinTexture;
|
||||||
|
import forge.toolbox.FContainer;
|
||||||
|
|
||||||
|
public class ClosingScreen extends FContainer {
|
||||||
|
private BGAnimation bgAnimation;
|
||||||
|
private StaticAnimation staticAnimation;
|
||||||
|
private boolean restart = false;
|
||||||
|
private boolean drawStatic = false;
|
||||||
|
|
||||||
|
public ClosingScreen(boolean restart0) {
|
||||||
|
bgAnimation = new BGAnimation();
|
||||||
|
staticAnimation = new StaticAnimation();
|
||||||
|
restart = restart0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doLayout(float width, float height) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class StaticAnimation extends ForgeAnimation {
|
||||||
|
float DURATION = 0.8f;
|
||||||
|
private float progress = 0;
|
||||||
|
|
||||||
|
public void drawBackgroud(Graphics g) {
|
||||||
|
float percentage = progress / DURATION;
|
||||||
|
float oldAlpha = g.getfloatAlphaComposite();
|
||||||
|
if (percentage < 0) {
|
||||||
|
percentage = 0;
|
||||||
|
} else if (percentage > 1) {
|
||||||
|
percentage = 1;
|
||||||
|
}
|
||||||
|
g.setAlphaComposite(1-percentage);
|
||||||
|
g.drawImage(FSkinTexture.BG_TEXTURE, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight());
|
||||||
|
g.setAlphaComposite(oldAlpha);
|
||||||
|
float xmod = Forge.getScreenHeight() > 1000 ? 1.5f : Forge.getScreenHeight() > 800 ? 1.3f : 1f;
|
||||||
|
if (FSkin.hdLogo != null) {
|
||||||
|
g.drawImage(FSkin.hdLogo, Forge.getScreenWidth()/2 - (FSkin.hdLogo.getWidth()*xmod)/2, Forge.getScreenHeight()/2 - (FSkin.hdLogo.getHeight()*xmod)/1.5f, FSkin.hdLogo.getWidth()*xmod, FSkin.hdLogo.getHeight()*xmod);
|
||||||
|
} else {
|
||||||
|
g.drawImage(FSkinImage.LOGO,Forge.getScreenWidth()/2 - (FSkinImage.LOGO.getWidth()*xmod)/2, Forge.getScreenHeight()/2 - (FSkinImage.LOGO.getHeight()*xmod)/1.5f, FSkinImage.LOGO.getWidth()*xmod, FSkinImage.LOGO.getHeight()*xmod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean advance(float dt) {
|
||||||
|
progress += dt;
|
||||||
|
return progress < DURATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onEnd(boolean endingAll) {
|
||||||
|
if (restart)
|
||||||
|
Forge.getDeviceAdapter().restart();
|
||||||
|
else
|
||||||
|
Forge.getDeviceAdapter().exit();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private class BGAnimation extends ForgeAnimation {
|
||||||
|
float DURATION = 0.6f;
|
||||||
|
private float progress = 0;
|
||||||
|
|
||||||
|
public void drawBackground(Graphics g) {
|
||||||
|
float percentage = progress / DURATION;
|
||||||
|
float oldAlpha = g.getfloatAlphaComposite();
|
||||||
|
if (percentage < 0) {
|
||||||
|
percentage = 0;
|
||||||
|
} else if (percentage > 1) {
|
||||||
|
percentage = 1;
|
||||||
|
}
|
||||||
|
g.setAlphaComposite(percentage);
|
||||||
|
g.drawImage(FSkinTexture.BG_TEXTURE, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight());
|
||||||
|
g.setAlphaComposite(oldAlpha);
|
||||||
|
float xmod = Forge.getScreenHeight() > 1000 ? 1.5f : Forge.getScreenHeight() > 800 ? 1.3f : 1f;
|
||||||
|
xmod *= 21-(20*percentage);
|
||||||
|
if (FSkin.hdLogo != null) {
|
||||||
|
g.drawImage(FSkin.hdLogo, Forge.getScreenWidth()/2 - (FSkin.hdLogo.getWidth()*xmod)/2, Forge.getScreenHeight()/2 - (FSkin.hdLogo.getHeight()*xmod)/1.5f, FSkin.hdLogo.getWidth()*xmod, FSkin.hdLogo.getHeight()*xmod);
|
||||||
|
} else {
|
||||||
|
g.drawImage(FSkinImage.LOGO,Forge.getScreenWidth()/2 - (FSkinImage.LOGO.getWidth()*xmod)/2, Forge.getScreenHeight()/2 - (FSkinImage.LOGO.getHeight()*xmod)/1.5f, FSkinImage.LOGO.getWidth()*xmod, FSkinImage.LOGO.getHeight()*xmod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean advance(float dt) {
|
||||||
|
progress += dt;
|
||||||
|
return progress < DURATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onEnd(boolean endingAll) {
|
||||||
|
drawStatic = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void drawBackground(Graphics g) {
|
||||||
|
if (drawStatic) {
|
||||||
|
staticAnimation.start();
|
||||||
|
staticAnimation.drawBackgroud(g);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bgAnimation.start();
|
||||||
|
bgAnimation.drawBackground(g);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user