v0.8.0: improved desktop debugRun task, version info is now dynamic
This commit is contained in:
parent
7ae14f9142
commit
b3d4515b32
|
@ -3,14 +3,18 @@ apply plugin: "java"
|
|||
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
||||
sourceCompatibility = targetCompatibility = appJavaCompatibility
|
||||
|
||||
ext.mainClass = "com.shatteredpixel.shatteredpixeldungeon.desktop.DesktopLauncher"
|
||||
sourceSets.main.resources.srcDirs = [new File(project(':core').projectDir, "/src/main/assets"),
|
||||
new File(project(':desktop').projectDir,"/src/main/assets")]
|
||||
|
||||
task runDebug(dependsOn: classes, type: JavaExec) {
|
||||
main = "com.shatteredpixel.shatteredpixeldungeon.desktop.DesktopLauncher"
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
|
||||
ignoreExitValue = true
|
||||
|
||||
main = mainClass
|
||||
systemProperty 'Specification-Name', appName
|
||||
systemProperty 'Specification-Version', appVersionName + "-INDEV"
|
||||
systemProperty 'Implementation-Version', appVersionCode
|
||||
}
|
||||
|
||||
task releaseJAR(dependsOn: classes, type: Jar) {
|
||||
|
@ -18,7 +22,7 @@ task releaseJAR(dependsOn: classes, type: Jar) {
|
|||
from { configurations.runtimeClasspath.findAll { it.name.endsWith('jar') }.collect { zipTree(it) } }
|
||||
|
||||
manifest {
|
||||
attributes 'Main-Class': "com.shatteredpixel.shatteredpixeldungeon.desktop.DesktopLauncher"
|
||||
attributes 'Main-Class': mainClass
|
||||
attributes 'Specification-Name': appName
|
||||
attributes 'Specification-Version': appVersionName
|
||||
attributes 'Implementation-Version': appVersionCode
|
||||
|
|
|
@ -35,6 +35,8 @@ import javax.swing.JOptionPane;
|
|||
public class DesktopLauncher {
|
||||
public static void main (String[] arg) {
|
||||
|
||||
final LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
|
||||
|
||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||
@Override
|
||||
public void uncaughtException(Thread thread, Throwable throwable) {
|
||||
|
@ -42,14 +44,28 @@ public class DesktopLauncher {
|
|||
PrintWriter pw = new PrintWriter(sw);
|
||||
throwable.printStackTrace(pw);
|
||||
pw.flush();
|
||||
JOptionPane.showMessageDialog(null, "Shattered Pixel Dungeon has crashed, sorry about that!\n\n" +
|
||||
JOptionPane.showMessageDialog(null, config.title + " has crashed, sorry about that!\n\n" +
|
||||
"If you could, please email this error message to me and I'll get it fixed (Evan@ShatteredPixel.com):\n\n" +
|
||||
sw.toString(), "Game Crash!", JOptionPane.ERROR_MESSAGE);
|
||||
Gdx.app.exit();
|
||||
}
|
||||
});
|
||||
|
||||
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
|
||||
config.title = DesktopLauncher.class.getPackage().getSpecificationTitle();
|
||||
if (config.title == null) {
|
||||
config.title = System.getProperty("Specification-Name");
|
||||
}
|
||||
|
||||
Game.version = DesktopLauncher.class.getPackage().getSpecificationVersion();
|
||||
if (Game.version == null) {
|
||||
Game.version = System.getProperty("Specification-Version");
|
||||
}
|
||||
|
||||
try {
|
||||
Game.versionCode = Integer.parseInt(DesktopLauncher.class.getPackage().getImplementationVersion());
|
||||
} catch (NumberFormatException e) {
|
||||
Game.versionCode = Integer.parseInt(System.getProperty("Implementation-Version"));
|
||||
}
|
||||
|
||||
config.width = 1920;
|
||||
config.height = 1080;
|
||||
|
@ -58,24 +74,6 @@ public class DesktopLauncher {
|
|||
config.foregroundFPS = 0;
|
||||
config.backgroundFPS = -1;
|
||||
|
||||
//TODO rather than hardcoding these values when running debug
|
||||
// it would be nice to be able to fetch them from gradle in some way
|
||||
config.title = DesktopLauncher.class.getPackage().getSpecificationTitle();
|
||||
if (config.title == null) {
|
||||
config.title = "ShatteredPD INDEV";
|
||||
}
|
||||
|
||||
Game.version = DesktopLauncher.class.getPackage().getSpecificationVersion();
|
||||
if (Game.version == null) {
|
||||
Game.version = "0.7.5e-INDEV";
|
||||
}
|
||||
|
||||
try {
|
||||
Game.versionCode = Integer.parseInt(DesktopLauncher.class.getPackage().getImplementationVersion());
|
||||
} catch (NumberFormatException e) {
|
||||
Game.versionCode = 382;
|
||||
}
|
||||
|
||||
new LwjglApplication(new ShatteredPixelDungeon(new DesktopPlatformSupport()), config);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user