Merge remote-tracking branch 'origin/AI_ATTACK_TIMEOUT' into AI_ATTACK_TIMEOUT

This commit is contained in:
Anthony Calosa
2024-11-22 19:13:37 +08:00
2 changed files with 17 additions and 11 deletions

View File

@@ -20,9 +20,21 @@ import java.util.Optional;
public class Main { public class Main {
private static final String versionString = BuildInfo.getVersionString(); private static final String versionString = BuildInfo.getVersionString();
public static void main(String[] args) { public static void main(String[] args) {
if (!OperatingSystem.isWindows()) {
/* Prevents crash on non Windows OS before creating the LWJGL3 window.
It seems it defeats the purpose of having a splash image since
this is an indicator if the LWJGL3 has booted up succesfully. */
closeSplash();
}
new GameLauncher(versionString); new GameLauncher(versionString);
} }
public static void closeSplash() {
try {
Optional.ofNullable(SplashScreen.getSplashScreen()).ifPresent(SplashScreen::close);
} catch (Exception e) {
e.printStackTrace();
}
}
public static class DesktopAdapter implements IDeviceAdapter { public static class DesktopAdapter implements IDeviceAdapter {
private final String switchOrientationFile; private final String switchOrientationFile;
@@ -96,15 +108,7 @@ public class Main {
@Override @Override
public void closeSplashScreen() { public void closeSplashScreen() {
// FIXME: on Linux system it can't close splashscreen image or crash with SIGSEGV? How come it works on other OS? closeSplash();
if (OperatingSystem.isUnix() || OperatingSystem.isSolaris())
return;
//could throw exception..
try {
Optional.ofNullable(SplashScreen.getSplashScreen()).ifPresent(SplashScreen::close);
} catch (Exception e) {
e.printStackTrace();
}
} }
@Override @Override

View File

@@ -159,7 +159,9 @@ public class Forge implements ApplicationListener {
public void create() { public void create() {
//install our error handler //install our error handler
ExceptionHandler.registerErrorHandling(); ExceptionHandler.registerErrorHandling();
getDeviceAdapter().closeSplashScreen(); // closeSplashScreen() is called early on non-Windows OS so it will not crash, LWJGL3 bug on AWT Splash.
if (OperatingSystem.isWindows())
getDeviceAdapter().closeSplashScreen();
GuiBase.setIsAndroid(Gdx.app.getType() == Application.ApplicationType.Android); GuiBase.setIsAndroid(Gdx.app.getType() == Application.ApplicationType.Android);