Commit d8a6744a authored by Matyáš Latner's avatar Matyáš Latner

#1 Build variants for desktop app

 * build variant connected to application settings
parent 86d0a27a
......@@ -11,6 +11,6 @@ public class AndroidLauncher extends AndroidApplication {
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
initialize(new Tablexia(), config);
initialize(new Tablexia(BuildConfig.DEBUG), config);
}
}
......@@ -19,7 +19,7 @@ allprojects {
appName = 'Tablexia-libGDX'
gdxVersion = '1.5.2'
gdxUtilsVersion = '0.9.1'
mbassadorVersion = '1.2.0'
mbassadorVersion = '1.2.0'
roboVMVersion = '1.0.0-beta-01'
box2DLightsVersion = '1.3'
ashleyVersion = '1.3.1'
......@@ -42,8 +42,9 @@ project(":desktop") {
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
compile "net.engio:mbassador:$mbassadorVersion"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
compile "net.engio:mbassador:$mbassadorVersion"
compile "com.jcabi:jcabi-manifests:1.1"
}
}
......@@ -55,11 +56,11 @@ project(":android") {
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "net.engio:mbassador:$mbassadorVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "net.engio:mbassador:$mbassadorVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
......@@ -76,10 +77,10 @@ project(":ios") {
compile project(":core")
compile "org.robovm:robovm-rt:${roboVMVersion}"
compile "org.robovm:robovm-cocoatouch:${roboVMVersion}"
compile "net.engio:mbassador:$mbassadorVersion"
compile "net.engio:mbassador:$mbassadorVersion"
compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
}
}
......@@ -109,8 +110,8 @@ project(":core") {
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "net.dermetfan.libgdx-utils:libgdx-utils:$gdxUtilsVersion"
compile "net.engio:mbassador:$mbassadorVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "net.engio:mbassador:$mbassadorVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
testCompile "junit:junit:4.11"
testCompile "com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion"
......
......@@ -29,11 +29,15 @@ public class Tablexia extends TablexiaApplication {
public static final String LOADER_BACKGOURND = "application/gfx/intro/screen_loader_background.png";
private static final float MAIN_MWNU_WIDTH_RATIO = 2f/7;
private boolean loadingComplete;
public Tablexia() {
loadingComplete = false;
}
private boolean loadingComplete = false;
public Tablexia(boolean debug) {
TablexiaSettings.init(debug);
}
public Tablexia(String buildVariantKey) {
TablexiaSettings.init(buildVariantKey);
}
private void loadingComplete() {
if (!loadingComplete) {
......
......@@ -52,7 +52,7 @@ public abstract class TablexiaApplication implements ApplicationListener {
@Override
public void dispose () {
inputMultiplexer.removeProcessor(stage);
if (TablexiaSettings.isDebug()) {
if (TablexiaSettings.getInstance().isDebug()) {
debugInfo.dispose();
}
stage.dispose();
......@@ -92,7 +92,7 @@ public abstract class TablexiaApplication implements ApplicationListener {
Gdx.gl.glClearColor(BACKGROUND_COLOR.r, BACKGROUND_COLOR.g, BACKGROUND_COLOR.b, BACKGROUND_COLOR.a);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
if (TablexiaSettings.isDebug()) {
if (TablexiaSettings.getInstance().isDebug()) {
debugInfo.update();
}
float deltaTime = Gdx.graphics.getDeltaTime();
......@@ -114,7 +114,7 @@ public abstract class TablexiaApplication implements ApplicationListener {
//////////////////////////// DEBUG INFO
private void prepareDebugInfo() {
if (TablexiaSettings.isDebug()) {
if (TablexiaSettings.getInstance().isDebug()) {
debugInfo = new DebugInfo(getStage().getWidth(), getStage().getHeight());
getStage().addActor(debugInfo);
}
......
package cz.nic.tablexia;
import cz.nic.tablexia.util.Log;
public class TablexiaSettings {
public static enum BuildVariant {
RELEASE("release", false),
DEBUG("debug", true);
private final static BuildVariant FALLBACK_VARIANT = BuildVariant.DEBUG;
private final String key;
private final boolean isDebug;
private BuildVariant(String key, boolean isDebug) {
this.key = key;
this.isDebug = isDebug;
}
public boolean isDebug() {
return isDebug;
}
public static BuildVariant getBuildVariantForKey(String key) {
for(BuildVariant buildVariant: BuildVariant.values()) {
if (buildVariant.key.equals(key)) {
return buildVariant;
}
}
return FALLBACK_VARIANT;
}
}
private static final boolean DEBUG = true;
private final BuildVariant BUILD_VARIANT;
private static final boolean DEBUG_SHOW_BOUNDING_BOXES = true;
private static TablexiaSettings instance;
private TablexiaSettings(BuildVariant buildVariant) {
BUILD_VARIANT = buildVariant;
}
public static TablexiaSettings getInstance() {
if (instance == null) {
String exceptionMessage = "Tablexia setting is not initialized!";
Log.err(TablexiaSettings.class, exceptionMessage);
throw new IllegalStateException(exceptionMessage);
}
return instance;
}
public static void init(boolean debug) {
TablexiaSettings.init(debug ? TablexiaSettings.BuildVariant.DEBUG : TablexiaSettings.BuildVariant.RELEASE);
}
public static void init(String buildVariantKey) {
TablexiaSettings.init(BuildVariant.getBuildVariantForKey(buildVariantKey));
}
public static void init(BuildVariant buildVariant) {
if (instance != null) {
String exceptionMessage = "Tablexia setting already initialized!";
Log.err(TablexiaSettings.class, exceptionMessage);
throw new IllegalStateException(exceptionMessage);
}
instance = new TablexiaSettings(buildVariant);
}
public static boolean isDebug() {
return DEBUG;
public boolean isDebug() {
return BUILD_VARIANT.isDebug();
}
public static boolean isShowBoudingBoxes() {
return DEBUG && DEBUG_SHOW_BOUNDING_BOXES;
public boolean isShowBoudingBoxes() {
return isDebug() && DEBUG_SHOW_BOUNDING_BOXES;
}
......
......@@ -49,7 +49,7 @@ public class MainMenu extends Stack {
public MainMenu(float width, float height) {
setBounds(0, 0, width, height);
setDebug(TablexiaSettings.isShowBoudingBoxes());
setDebug(TablexiaSettings.getInstance().isShowBoudingBoxes());
Texture background = ApplicationTextureManager.getInstance().get(ApplicationTextureManager.MAINMENU_BACKGROUND, Texture.class);
background.setFilter(TextureFilter.Linear, TextureFilter.Linear);
......@@ -91,7 +91,7 @@ public class MainMenu extends Stack {
public void initMenuItems() {
menuTableLayout.reset();
menuTableLayout.setDebug(TablexiaSettings.isShowBoudingBoxes());
menuTableLayout.setDebug(TablexiaSettings.getInstance().isShowBoudingBoxes());
for (final MainMenuDefinition menuItem : MainMenuDefinition.values()) {
addMenuItem(menuItem);
......
......@@ -35,7 +35,7 @@ public class StatisticsScreen extends AbstractTablexiaScreen<Void> {
label.setPosition(getStage().getWidth() / 2, getStage().getHeight() / 2);
backgroundLayout.setActor(label);
backgroundLayout.setDebug(TablexiaSettings.isShowBoudingBoxes());
backgroundLayout.setDebug(TablexiaSettings.getInstance().isShowBoudingBoxes());
getStage().addActor(backgroundLayout);
}
......
......@@ -14,18 +14,38 @@ task run(dependsOn: classes, type: JavaExec) {
ignoreExitValue = true
}
task dist(type: Jar) {
task debugJar(type: Jar) {
baseName = "debug"
from files(sourceSets.main.output.classesDir)
from files(sourceSets.main.output.resourcesDir)
from {configurations.compile.collect {zipTree(it)}}
from files(project.assetsDir);
manifest {
attributes 'Main-Class': project.mainClassName
attributes 'Build-Variant': 'debug'
}
}
dist.dependsOn classes
task releaseJar(type: Jar) {
baseName = "release"
from files(sourceSets.main.output.classesDir)
from files(sourceSets.main.output.resourcesDir)
from {configurations.compile.collect {zipTree(it)}}
from files(project.assetsDir);
manifest {
attributes 'Main-Class': project.mainClassName
attributes 'Build-Variant': 'release'
}
}
artifacts {
archives releaseJar, debugJar
}
debugJar.dependsOn classes
releaseJar.dependsOn classes
eclipse {
project {
......
......@@ -2,14 +2,25 @@ package cz.nic.tablexia.desktop;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.jcabi.manifests.Manifests;
import cz.nic.tablexia.Tablexia;
public class DesktopLauncher {
public static void main (String[] arg) {
public static final String BUILD_VARIANT_MANIFEST_ATTRIBUTE = "Build-Variant";
public static void main (String[] arg) {
String buildVariant = null;
if (Manifests.exists(BUILD_VARIANT_MANIFEST_ATTRIBUTE)) {
buildVariant = Manifests.read(BUILD_VARIANT_MANIFEST_ATTRIBUTE);
}
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.resizable = false;
config.width = 1280;
config.height = 800;
new LwjglApplication(new Tablexia(), config);
new LwjglApplication(new Tablexia(buildVariant), config);
}
}
......@@ -11,7 +11,7 @@ public class IOSLauncher extends IOSApplication.Delegate {
@Override
protected IOSApplication createApplication() {
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
return new IOSApplication(new Tablexia(), config);
return new IOSApplication(new Tablexia(null), config);
}
public static void main(String[] argv) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment