diff --git a/android/build.gradle b/android/build.gradle index d274d99..657220b 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -21,12 +21,15 @@ android { minSdkVersion 14 targetSdkVersion 29 versionCode 1 - versionName "0.0.1-beta" // Remember to update the GAME_VERSION in Constants.java too !! + versionName "0.0.1-beta" + // Remember to update the GAME_VERSION in Constants.java + // And project.setVersion in Desktop's build.gradle + // Or for Linux users, use the versionUpdate.sh script } buildTypes { release { - minifyEnabled true - shrinkResources true + minifyEnabled false // Don't set this to true because it'll result in a lot of classes missing causing Runtime crashes + shrinkResources false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } diff --git a/core/build.gradle b/core/build.gradle index ed8e6bf..ceaa27e 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -6,7 +6,6 @@ sourceCompatibility = 1.7 sourceSets.main.java.srcDirs = [ "src/" ] - eclipse.project { name = appName + "-core" } diff --git a/core/src/com/cg/zoned/Constants.java b/core/src/com/cg/zoned/Constants.java index e330fd4..2280a7a 100644 --- a/core/src/com/cg/zoned/Constants.java +++ b/core/src/com/cg/zoned/Constants.java @@ -8,6 +8,9 @@ public final class Constants { public static final String GAME_VERSION = "0.0.1-beta"; + // Remember to update the versionName in Android's build.gradle + // And project.setVersion in Desktop's build.gradle + // Or for Linux users, use the versionUpdate.sh script public static final float WORLD_SIZE = 480.0f; diff --git a/core/src/com/cg/zoned/Zoned.java b/core/src/com/cg/zoned/Zoned.java index c4c0be3..d1dd0b4 100644 --- a/core/src/com/cg/zoned/Zoned.java +++ b/core/src/com/cg/zoned/Zoned.java @@ -83,6 +83,8 @@ public void dispose() { } catch (GdxRuntimeException ignored) { // "Pixmap already disposed!" error // idk why this happens but ok ¯\_(ツ)_/¯ + } catch (NullPointerException ignored) { + // Application was closed before the skin was loaded } } } \ No newline at end of file diff --git a/desktop/build.gradle b/desktop/build.gradle index f8ec9ed..0597401 100644 --- a/desktop/build.gradle +++ b/desktop/build.gradle @@ -5,6 +5,10 @@ sourceSets.main.java.srcDirs = [ "src/" ] project.ext.mainClassName = "com.cg.zoned.desktop.DesktopLauncher" project.ext.assetsDir = new File("../android/assets") +project.setVersion("0.0.1-beta") +// Remember to update the GAME_VERSION in Constants.java +// And versionName in Android's build.gradle +// Or for Linux users, use the versionUpdate.sh script task run(dependsOn: classes, type: JavaExec) { main = project.mainClassName @@ -12,6 +16,7 @@ task run(dependsOn: classes, type: JavaExec) { standardInput = System.in workingDir = project.assetsDir ignoreExitValue = true + args project.getVersion() } task debug(dependsOn: classes, type: JavaExec) { @@ -21,6 +26,7 @@ task debug(dependsOn: classes, type: JavaExec) { workingDir = project.assetsDir ignoreExitValue = true debug = true + args project.getVersion() } task dist(type: Jar) { @@ -30,9 +36,10 @@ task dist(type: Jar) { from {configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }} from {configurations.compile.collect {zipTree(it)}} from files(project.assetsDir) - + manifest { attributes 'Main-Class': project.mainClassName + attributes 'Game-Version': project.getVersion() } } diff --git a/desktop/src/com/cg/zoned/desktop/DesktopLauncher.java b/desktop/src/com/cg/zoned/desktop/DesktopLauncher.java index b342634..313c4fa 100644 --- a/desktop/src/com/cg/zoned/desktop/DesktopLauncher.java +++ b/desktop/src/com/cg/zoned/desktop/DesktopLauncher.java @@ -3,10 +3,17 @@ import com.badlogic.gdx.Files; import com.badlogic.gdx.backends.lwjgl.LwjglApplication; import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; +import com.cg.zoned.Constants; import com.cg.zoned.Zoned; public class DesktopLauncher { - public static void main(String[] arg) { + public static void main(String[] args) { + if (args.length > 0 && !args[0].equals(Constants.GAME_VERSION)) { + // Used as a precaution + System.err.println("GAME VERSION MISMATCH (" + args[0] + " and " + Constants.GAME_VERSION + ")"); + return; + } + LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.title = "Zoned"; config.vSyncEnabled = true; diff --git a/versionUpdate.sh b/versionUpdate.sh new file mode 100755 index 0000000..1e518ef --- /dev/null +++ b/versionUpdate.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +read -p "Old version name: " oldVersionName +read -p "New version name: " newVersionName +read -p "Are you sure you wanna do this? (Y/N) " proceed + +if [ "$proceed" == "Y" ]; then + grep -l "$oldVersionName" android/build.gradle | while read filename + do + sed -i -e "s/$oldVersionName/$newVersionName/g" "$filename" + done + + grep -l "$oldVersionName" desktop/build.gradle | while read filename + do + sed -i -e "s/$oldVersionName/$newVersionName/g" "$filename" + done + + grep -l "$oldVersionName" core/src/com/cg/zoned/Constants.java | while read filename + do + sed -i -e "s/$oldVersionName/$newVersionName/g" "$filename" + done +else + echo "Alright, aborted" +fi