Skip to content

Commit

Permalink
Merge branch 'develop' into feature/implement-skinnedMesh-1
Browse files Browse the repository at this point in the history
  • Loading branch information
pollend authored May 11, 2022
2 parents 103a873 + 685a895 commit 8d818c2
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 60 deletions.
9 changes: 7 additions & 2 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/dictionaries/kevint.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2022 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0

package org.terasology.gradology

import org.gradle.api.internal.file.copy.CopySpecInternal
import org.gradle.api.tasks.Copy


/**
* Copy, but never overwrite any existing file.
*
* Preserves existing files regardless of how up-to-date they are.
*
* Useful for providing boilerplate or defaults.
*/
abstract class CopyButNeverOverwrite : Copy() {

override fun createRootSpec(): CopySpecInternal {
val copySpec = super.createRootSpec()
copySpec.eachFile {
if (this.relativePath.getFile(destinationDir).exists()) {
this.exclude()
}
}
return copySpec;
}
}
22 changes: 7 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ plugins {

import org.gradle.internal.logging.text.StyledTextOutputFactory
import org.jetbrains.gradle.ext.ActionDelegationConfig
import org.terasology.gradology.CopyButNeverOverwrite

import static org.gradle.internal.logging.text.StyledTextOutput.Style

Expand All @@ -80,7 +81,7 @@ located at ${System.getProperty("java.home")}
ext {
dirNatives = 'natives'
dirConfigMetrics = 'config/metrics'
templatesDir = 'templates'
templatesDir = file('templates')

// Lib dir for use in manifest entries etc (like in :engine). A separate "libsDir" exists, auto-created by Gradle
subDirLibs = 'libs'
Expand Down Expand Up @@ -230,19 +231,14 @@ tasks.named('wrapper') {
// General IDE customization //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

task copyInMissingTemplates {
tasks.register("copyInMissingTemplates", CopyButNeverOverwrite) {
description = "Copies in placeholders from the /templates dir to project root if not present yet"
File gradlePropsFile = new File(rootDir, 'gradle.properties')
File OverrideCfgFile = new File(rootDir, 'override.cfg')
if (!gradlePropsFile.exists()) {
new File(rootDir, 'gradle.properties') << new File(templatesDir, 'gradle.properties').text
}
if (!OverrideCfgFile.exists()) {
new File(rootDir, 'override.cfg') << new File(templatesDir, 'override.cfg').text
}
from(templatesDir)
into(rootDir)
include('gradle.properties', 'override.cfg')
}

tasks.register("jmxPassword", Copy) {
tasks.register("jmxPassword", CopyButNeverOverwrite) {
description = "Create config/jmxremote.password from a template."

setFileMode(0600) // passwords must be accessible only by owner
Expand All @@ -253,10 +249,6 @@ tasks.register("jmxPassword", Copy) {
rename("(.*).template", '$1')
into("config")

onlyIf {
// Do not overwrite an existing password file.
!it.destinationDir.toPath().resolve("jmxremote.password").toFile().exists()
}
doLast {
logger.warn("${it.outputs.files.singleFile}/jmxremote.password:100: Edit this to set your password.")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 The Terasology Foundation
// Copyright 2022 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0

package org.terasology.engine.core.modes.loadProcesses;
Expand Down Expand Up @@ -58,6 +58,7 @@
import java.nio.file.Path;

import static com.google.common.base.Verify.verify;
import static com.google.common.base.Verify.verifyNotNull;

public class InitialiseWorld extends SingleStepLoadProcess {

Expand All @@ -84,7 +85,8 @@ public boolean step() {
ModuleEnvironment environment = context.get(ModuleManager.class).getEnvironment();
context.put(WorldGeneratorPluginLibrary.class, new DefaultWorldGeneratorPluginLibrary(environment, context));

WorldInfo worldInfo = gameManifest.getWorldInfo(TerasologyConstants.MAIN_WORLD);
WorldInfo worldInfo = verifyNotNull(gameManifest.getWorldInfo(TerasologyConstants.MAIN_WORLD),
"Game manifest does not contain a MAIN_WORLD");
verify(worldInfo.getWorldGenerator().isValid(), "Game manifest did not specify world type.");
if (worldInfo.getSeed() == null || worldInfo.getSeed().isEmpty()) {
FastRandom random = new FastRandom();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
// Copyright 2021 The Terasology Foundation
// Copyright 2022 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.engine.game;

import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.terasology.engine.core.SimpleUri;
import org.terasology.engine.core.TerasologyConstants;
import org.terasology.engine.utilities.gson.CaseInsensitiveEnumTypeAdapterFactory;
import org.terasology.engine.utilities.gson.UriTypeAdapterFactory;
import org.terasology.engine.world.generator.internal.WorldGeneratorManager;
import org.terasology.engine.world.internal.WorldInfo;
import org.terasology.gestalt.entitysystem.component.Component;
import org.terasology.gestalt.naming.Name;
Expand All @@ -31,6 +35,8 @@
public class GameManifest {
public static final String DEFAULT_FILE_NAME = "manifest.json";

private static final Logger logger = LoggerFactory.getLogger(GameManifest.class);

private String title = "";
private String seed = "";
private long time;
Expand Down Expand Up @@ -174,4 +180,30 @@ public void addModule(Name id, Version version) {
modules.add(new NameVersion(id, version));
}

/**
* The name of the generator used for the main world.
* <p>
* Always returns a String, but may be an "ERROR:" string.
*/
public String mainWorldDisplayName(WorldGeneratorManager manager) {
var world = getWorldInfo(TerasologyConstants.MAIN_WORLD);
if (world == null) {
logger.warn("{} has no MAIN_WORLD", this);
return "ERROR: No main world";
}
SimpleUri generatorUri = world.getWorldGenerator();
var generator = manager.getWorldGeneratorInfo(generatorUri);
if (generator == null) {
logger.warn("{}: {} has no generator for {}", this, manager, generatorUri);
return "ERROR: No generator found for " + generatorUri;
}
return generator.getDisplayName();
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("title", title)
.toString();
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// Copyright 2021 The Terasology Foundation
// Copyright 2022 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.engine.rendering.nui.layers.mainMenu;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.terasology.gestalt.assets.ResourceUrn;
import org.terasology.engine.config.Config;
import org.terasology.engine.config.PlayerConfig;
import org.terasology.engine.core.TerasologyConstants;
import org.terasology.engine.game.GameManifest;
import org.terasology.engine.i18n.TranslationSystem;
import org.terasology.engine.persistence.internal.GamePreviewImageProvider;
import org.terasology.engine.registry.In;
Expand All @@ -18,8 +17,8 @@
import org.terasology.engine.rendering.nui.layers.mainMenu.savedGames.GameInfo;
import org.terasology.engine.utilities.Assets;
import org.terasology.engine.utilities.FilesUtil;
import org.terasology.engine.world.generator.internal.WorldGeneratorInfo;
import org.terasology.engine.world.generator.internal.WorldGeneratorManager;
import org.terasology.gestalt.assets.ResourceUrn;
import org.terasology.gestalt.naming.Name;
import org.terasology.gestalt.naming.NameVersion;
import org.terasology.nui.widgets.UIImage;
Expand Down Expand Up @@ -78,22 +77,10 @@ void updateDescription(final GameInfo gameInfo) {
return;
}

final WorldGeneratorInfo wgi = worldGeneratorManager.getWorldGeneratorInfo(
gameInfo.getManifest()
.getWorldInfo(TerasologyConstants.MAIN_WORLD)
.getWorldGenerator());

String mainWorldGenerator = "ERROR: world generator ";
if (wgi != null) {
mainWorldGenerator = wgi.getDisplayName();
} else {
mainWorldGenerator = mainWorldGenerator + gameInfo.getManifest()
.getWorldInfo(TerasologyConstants.MAIN_WORLD)
.getWorldGenerator()
.toString() + " not found";
}
GameManifest manifest = gameInfo.getManifest();
String mainWorldGenerator = manifest.mainWorldDisplayName(worldGeneratorManager);

final String commaSeparatedModules = gameInfo.getManifest()
final String commaSeparatedModules = manifest
.getModules()
.stream()
.map(NameVersion::getName)
Expand All @@ -120,7 +107,7 @@ private void loadPreviewImages(final GameInfo gameInfo) {
try {
textureData = AWTTextureFormat.convertToTextureData(buffImage, Texture.FilterMode.LINEAR);
} catch (IOException e) {
logger.error("Converting preview image to texture data {} failed", e);
logger.error("Converting preview image to texture data failed", e);
return null;
}
return Assets.generateAsset(new ResourceUrn(PREVIEW_IMAGE_URI_PATTERN + bufferedImages.indexOf(buffImage)),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 The Terasology Foundation
// Copyright 2022 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.engine.rendering.nui.layers.mainMenu.gameDetailsScreen;

Expand All @@ -9,9 +9,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.terasology.engine.context.Context;
import org.terasology.engine.core.SimpleUri;
import org.terasology.engine.core.TerasologyConstants;
import org.terasology.engine.core.module.ModuleManager;
import org.terasology.engine.game.GameManifest;
import org.terasology.engine.i18n.TranslationSystem;
import org.terasology.engine.registry.In;
import org.terasology.engine.rendering.nui.CoreScreenLayer;
Expand All @@ -21,7 +20,6 @@
import org.terasology.engine.rendering.nui.layers.mainMenu.moduleDetailsScreen.ModuleDetailsScreen;
import org.terasology.engine.rendering.nui.layers.mainMenu.savedGames.GameInfo;
import org.terasology.engine.utilities.time.DateTimeHelper;
import org.terasology.engine.world.generator.internal.WorldGeneratorInfo;
import org.terasology.engine.world.generator.internal.WorldGeneratorManager;
import org.terasology.engine.world.internal.WorldInfo;
import org.terasology.gestalt.assets.ResourceUrn;
Expand Down Expand Up @@ -392,22 +390,18 @@ private void loadGeneralInfo() {
}

private String getGeneralInfo(final GameInfo theGameInfo) {
SimpleUri name = theGameInfo.getManifest().getWorldInfo(TerasologyConstants.MAIN_WORLD).getWorldGenerator();
WorldGeneratorInfo wgi = worldGeneratorManager.getWorldGeneratorInfo(name);
String display = "ERROR: generator " + name + " not found.";
if (wgi != null) {
display = wgi.getDisplayName();
}
GameManifest manifest = theGameInfo.getManifest();

return translationSystem.translate("${engine:menu#game-details-game-title} ")
+ theGameInfo.getManifest().getTitle() + '\n' + '\n' +
+ manifest.getTitle() + '\n' + '\n' +
translationSystem.translate("${engine:menu#game-details-last-play}: ")
+ DATE_FORMAT.format(theGameInfo.getTimestamp()) + '\n' + '\n' +
translationSystem.translate("${engine:menu#game-details-game-duration} ")
+ DateTimeHelper.getDeltaBetweenTimestamps(new Date(0).getTime(), theGameInfo.getManifest().getTime()) + '\n' + '\n' +
+ DateTimeHelper.getDeltaBetweenTimestamps(new Date(0).getTime(), manifest.getTime()) + '\n' + '\n' +
translationSystem.translate("${engine:menu#game-details-game-seed} ")
+ theGameInfo.getManifest().getSeed() + '\n' + '\n' +
+ manifest.getSeed() + '\n' + '\n' +
translationSystem.translate("${engine:menu#game-details-world-generator}: ") + '\t'
+ display;
+ manifest.mainWorldDisplayName(worldGeneratorManager);
}

private void loadGameWorlds() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 The Terasology Foundation
// Copyright 2022 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.engine.rendering.nui.layers.mainMenu.savedGames;

Expand All @@ -9,6 +9,8 @@
import java.text.SimpleDateFormat;
import java.util.Date;

import static com.google.common.base.Preconditions.checkNotNull;

/**
* Contains information about saved game.
*/
Expand All @@ -17,11 +19,11 @@ public class GameInfo {
private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";

private Date timestamp;
private GameManifest manifest;
private final GameManifest manifest;
private Path savePath;

public GameInfo(GameManifest manifest, Date timestamp, Path savePath) {
this.manifest = manifest;
this.manifest = checkNotNull(manifest, "manifest");
this.timestamp = timestamp;
this.savePath = savePath;
}
Expand Down

0 comments on commit 8d818c2

Please sign in to comment.