Skip to content

Commit

Permalink
Merge PR #381 by @BenjaminAmos - code in modules!
Browse files Browse the repository at this point in the history
  • Loading branch information
Cervator committed Dec 24, 2018
2 parents c9843b9 + 90a13f4 commit 219739a
Show file tree
Hide file tree
Showing 51 changed files with 1,524 additions and 325 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ android
gwt
modules/*
!modules/core
!modules/subprojects.gradle

## GWT
war/
Expand Down
40 changes: 40 additions & 0 deletions engine/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@ apply from: '../config/gradle/common.gradle'

[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

import org.reflections.Reflections;
import org.reflections.scanners.SubTypesScanner;
import org.reflections.scanners.TypeAnnotationsScanner;
import org.reflections.util.ConfigurationBuilder;

// Dependencies needed for what our Gradle scripts themselves use. It cannot be included via an external Gradle file :-(
buildscript {
repositories {
// External libs - jcenter is Bintray and is supposed to be a superset of Maven Central, but do both just in case
jcenter()
mavenCentral()
}

dependencies {
// Needed for caching reflected data during builds
classpath 'org.reflections:reflections:0.9.10'
classpath 'dom4j:dom4j:1.6.1'
}
}

dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
Expand Down Expand Up @@ -38,7 +58,27 @@ sourceSets {
}
}

task cacheReflections {
description = 'Caches reflection output to make regular startup faster. May go stale and need cleanup at times.'
// TODO: The extra "org" qualifier excludes test classes otherwise sucked up in Jenkins, causing issues. Redo later
File dirToReflect = new File(sourceSets.main.output.classesDir, "org")
inputs.files dirToReflect
outputs.file file(sourceSets.main.output.classesDir.toString() + "/reflections.cache")
dependsOn classes
doFirst {
// Without the .mkdirs() we might hit a scenario where the classes dir doesn't exist yet
dirToReflect.mkdirs()
Reflections reflections = new Reflections(new ConfigurationBuilder()
.addUrls(dirToReflect.toURI().toURL())
.setScanners(new TypeAnnotationsScanner(), new SubTypesScanner()))
reflections.save(sourceSets.main.output.classesDir.toString() + "/reflections.cache")
}
}

jar {
// This prevents the assets from being scanned as code files
dependsOn cacheReflections

archiveName = "sol.jar"

doFirst {
Expand Down
177 changes: 0 additions & 177 deletions engine/src/main/java/org/destinationsol/ModuleManager.java

This file was deleted.

18 changes: 17 additions & 1 deletion engine/src/main/java/org/destinationsol/SolApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.destinationsol.game.context.Context;
import org.destinationsol.game.context.internal.ContextImpl;
import org.destinationsol.menu.MenuScreens;
import org.destinationsol.modules.ModuleManager;
import org.destinationsol.ui.DebugCollector;
import org.destinationsol.ui.DisplayDimensions;
import org.destinationsol.ui.FontSize;
Expand All @@ -41,12 +42,14 @@
import org.destinationsol.ui.UiDrawer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.terasology.module.sandbox.API;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashSet;
import java.util.Set;

@API
public class SolApplication implements ApplicationListener {
private static final Logger logger = LoggerFactory.getLogger(SolApplication.class);

Expand Down Expand Up @@ -133,7 +136,20 @@ public void render() {
timeAccumulator -= Const.REAL_TIME_STEP;
}

draw();
try {
draw();
} catch (Throwable t) {
logger.error("Fatal Error:", t);
fatalErrorMsg = "A fatal error occurred:\n" + t.getMessage();
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
t.printStackTrace(pw);
fatalErrorTrace = sw.toString();

if (!isMobile) {
throw t;
}
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,7 @@ public void registerModuleMusic(String moduleName, final GameOptions options) {

if (Assets.getAssetHelper().list(Json.class, moduleName + ":musicConfig").isEmpty()) {
return;
}
else
{
} else {
logger.info("Music Config found for module " + moduleName);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright 2018 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@API package org.destinationsol.assets.audio;

import org.terasology.module.sandbox.API;
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright 2018 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@API package org.destinationsol.assets.json;

import org.terasology.module.sandbox.API;
18 changes: 18 additions & 0 deletions engine/src/main/java/org/destinationsol/assets/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright 2018 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@API package org.destinationsol.assets;

import org.terasology.module.sandbox.API;
18 changes: 18 additions & 0 deletions engine/src/main/java/org/destinationsol/common/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright 2018 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@API package org.destinationsol.common;

import org.terasology.module.sandbox.API;
Loading

0 comments on commit 219739a

Please sign in to comment.