Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/issue-335
Browse files Browse the repository at this point in the history
  • Loading branch information
tonihele committed Feb 11, 2024
2 parents 9eacd6b + 781712b commit 618cc6e
Show file tree
Hide file tree
Showing 233 changed files with 1,260 additions and 1,865 deletions.
2 changes: 1 addition & 1 deletion .deepsource.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ name = "java"
enabled = true

[analyzers.meta]
runtime_version = "17"
runtime_version = "21"
4 changes: 2 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ name: Java CI with Gradle

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

Expand All @@ -19,8 +18,9 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
- uses: Trass3r/setup-cpp@master
- name: Build with Gradle
run: ./gradlew build
- uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ An open source remake of the Dungeon Keeper II game and engine.

Goal is to fully implement the game (version 1.7 with 3 bonus packs) as open source cross platform version, with minimal or no changes at all, using the original game assets. So it will require the original game to play / develop. Future development could have fan made graphics (to at least enable standalone version) and features.

OpenKeeper is written in Java using [JMonkeyEngine](http://jmonkeyengine.org/). Currently we are using JME 3.6 + Java 17.
OpenKeeper is written in Java using [JMonkeyEngine](http://jmonkeyengine.org/). Currently we are using JME 3.6 + Java 21.

Builds are available from the CI:

Expand Down
32 changes: 18 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ allprojects {
application {
applicationName = 'OpenKeeper'
mainClass = 'toniarts.openkeeper.Main'
applicationDefaultJvmArgs = ["-Dvisualvm.display.name=OpenKeeper -XstartOnFirstThread"]
if (System.getProperty("os.name").toLowerCase().contains("mac")) {
applicationDefaultJvmArgs = ["-Dvisualvm.display.name=OpenKeeper", "-XstartOnFirstThread"]
}
else {
applicationDefaultJvmArgs = ["-Dvisualvm.display.name=OpenKeeper"]
}
}

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
task sourcesJar(type: Jar, dependsOn: [classes, startScripts, distZip, distTar]) {
from sourceSets.main.allSource
}

Expand All @@ -39,9 +43,9 @@ artifacts {

configurations.all {
resolutionStrategy.dependencySubstitution {
substitute module('com.github.nifty-gui:nifty') with module('com.github.tonihele.nifty-gui:nifty:1.4-SNAPSHOT')
substitute module('com.github.nifty-gui:nifty-default-controls') with module('com.github.tonihele.nifty-gui:nifty-default-controls:1.4-SNAPSHOT')
substitute module('com.github.nifty-gui:nifty-style-black') with module('com.github.tonihele.nifty-gui:nifty-style-black:1.4-SNAPSHOT')
substitute module('com.github.nifty-gui:nifty') using module('com.github.tonihele.nifty-gui:nifty:1.4-SNAPSHOT')
substitute module('com.github.nifty-gui:nifty-default-controls') using module('com.github.tonihele.nifty-gui:nifty-default-controls:1.4-SNAPSHOT')
substitute module('com.github.nifty-gui:nifty-style-black') using module('com.github.tonihele.nifty-gui:nifty-style-black:1.4-SNAPSHOT')
}
}

Expand Down Expand Up @@ -75,6 +79,12 @@ sourceSets {
}
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

jar {
manifest {
attributes(
Expand Down Expand Up @@ -106,19 +116,13 @@ idea {
}
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

compileJava {
// We have annotation processors in log4j, only needed for writing plugins, disable the warnings
options.compilerArgs += ["-proc:none"]
//options.compilerArgs += ["-Xlint:deprecation"]
options.compilerArgs += ["-Xlint:deprecation"]
//options.compilerArgs += ["-Xlint:unchecked"]
}

wrapper {
gradleVersion = '7.6.2'
gradleVersion = '8.5'
}
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
org.gradle.caching = true
org.gradle.vfs.watch = true
org.gradle.parallel = true
org.gradle.warning.mode = all
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
29 changes: 17 additions & 12 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,26 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
36 changes: 18 additions & 18 deletions src/toniarts/openkeeper/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.net.URLClassLoader;
Expand All @@ -60,8 +62,6 @@
import java.util.Properties;
import java.util.Queue;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import toniarts.openkeeper.audio.plugins.MP2Loader;
Expand All @@ -88,7 +88,7 @@
*/
public class Main extends SimpleApplication {

private static final Logger LOGGER = Logger.getLogger(Main.class.getName());
private static final Logger logger = System.getLogger(Main.class.getName());

private static boolean folderOk = false;
private static boolean conversionOk = false;
Expand Down Expand Up @@ -123,7 +123,7 @@ public static void main(String[] args) throws InvocationTargetException, Interru
if (checkSetup(app)) {
app.start();
} else {
LOGGER.warning("Application setup not complete!!");
logger.log(Level.WARNING, "Application setup not complete!!");
}
}

Expand All @@ -133,7 +133,7 @@ public static void main(String[] args) throws InvocationTargetException, Interru
* @param args the arguments list
*/
private static void parseArguments(String[] args) {
params = new HashMap<>(args.length);
params = HashMap.newHashMap(args.length);

// Go through the params
int i = 0;
Expand Down Expand Up @@ -171,7 +171,7 @@ private static boolean checkSetup(final Main app) throws InterruptedException {

// First and foremost, the folder
if (!PathUtils.checkDkFolder(getDkIIFolder())) {
LOGGER.info("Dungeon Keeper II folder not found or valid! Prompting user!");
logger.log(Level.INFO, "Dungeon Keeper II folder not found or valid! Prompting user!");
saveSetup = true;

// Let the user select
Expand All @@ -190,7 +190,7 @@ protected void continueOk(String path) {

// If the folder is ok, check the conversion
if (folderOk && (AssetsConverter.isConversionNeeded(Main.getSettings()))) {
LOGGER.info("Need to convert the assets!");
logger.log(Level.INFO, "Need to convert the assets!");
saveSetup = true;

// Convert
Expand Down Expand Up @@ -225,12 +225,12 @@ private static void initSettings(Main app) {
try {
Files.createDirectories(Paths.get(USER_HOME_FOLDER));
} catch (IOException ex) {
LOGGER.log(Level.SEVERE, "Failed to create folder " + USER_HOME_FOLDER + "!", ex);
logger.log(Level.ERROR, "Failed to create folder " + USER_HOME_FOLDER + "!", ex);
}
try {
Files.createDirectories(Paths.get(SCREENSHOTS_FOLDER));
} catch (IOException ex) {
LOGGER.log(Level.SEVERE, "Failed to create folder " + SCREENSHOTS_FOLDER + "!", ex);
logger.log(Level.ERROR, "Failed to create folder " + SCREENSHOTS_FOLDER + "!", ex);
}

// Init the user settings (which in JME are app settings)
Expand Down Expand Up @@ -274,7 +274,7 @@ private static void setLookNFeel() {
}
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(DKFolderSelector.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
System.getLogger(DKFolderSelector.class.getName()).log(Level.ERROR, (String) null, ex);
}
}

Expand All @@ -295,7 +295,7 @@ public void run() {
try {
LOCK.wait();
} catch (InterruptedException e) {
LOGGER.warning("Lock interrupted!");
logger.log(Level.WARNING, "Lock interrupted!");
}
}
}
Expand Down Expand Up @@ -411,7 +411,7 @@ public void onLoad() {
// Eventually we are going to use Nifty, the XML files take some time to parse
nifty.addXml(new ByteArrayInputStream(mainMenuUiXml));
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Failed to load the game!", e);
logger.log(Level.ERROR, "Failed to load the game!", e);
app.stop();
}
}
Expand Down Expand Up @@ -510,7 +510,7 @@ public static BufferedImage[] getApplicationIcons() {
readIcon("/Icons/openkeeper16.png")
};
} catch (IOException ex) {
LOGGER.log(Level.SEVERE, "Failed to load the application icons!", ex);
logger.log(Level.ERROR, "Failed to load the application icons!", ex);
}
return null;
}
Expand Down Expand Up @@ -544,7 +544,7 @@ public void restart() {
// Continue to save the settings
Settings.getInstance().save();
} catch (IOException ex) {
LOGGER.log(Level.WARNING, "Can not save the settings!", ex);
logger.log(Level.WARNING, "Can not save the settings!", ex);
}

} catch (Exception e) {
Expand Down Expand Up @@ -587,7 +587,7 @@ public static ResourceBundle getResourceBundle(String baseName) {
ClassLoader loader = new URLClassLoader(urls);
return ResourceBundle.getBundle(baseName, Locale.getDefault(), loader);
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Failed to locate the resource bundle " + baseName + " in " + file + "!", e);
logger.log(Level.ERROR, "Failed to locate the resource bundle " + baseName + " in " + file + "!", e);
}

// Works only from the IDE
Expand Down Expand Up @@ -626,12 +626,12 @@ private void playIntro() {
try {
introSequence.add(PathUtils.getRealFileName(getDkIIFolder(), PathUtils.DKII_MOVIES_FOLDER + "BullfrogIntro.tgq"));
} catch (IOException ex) {
LOGGER.log(Level.INFO, "Could not find the Bullfrog intro!", ex);
logger.log(Level.INFO, "Could not find the Bullfrog intro!", ex);
}
try {
introSequence.add(PathUtils.getRealFileName(getDkIIFolder(), PathUtils.DKII_MOVIES_FOLDER + "INTRO.TGQ"));
} catch (IOException ex) {
LOGGER.log(Level.INFO, "Could not find the game intro!", ex);
logger.log(Level.INFO, "Could not find the game intro!", ex);
}
playMovie(introSequence);
}
Expand All @@ -655,7 +655,7 @@ protected void onPlayingEnd() {
};
stateManager.attach(movieState);
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Failed to initiate playing " + movieFile + "!", e);
logger.log(Level.WARNING, "Failed to initiate playing " + movieFile + "!", e);

// Continue with the movie list
playMovie(introSequence);
Expand Down
8 changes: 4 additions & 4 deletions src/toniarts/openkeeper/audio/plugins/MP2Loader.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import toniarts.openkeeper.audio.plugins.decoder.AudioInformation;
import toniarts.openkeeper.audio.plugins.decoder.Decoder;
import toniarts.openkeeper.audio.plugins.decoder.MediaInformation;
Expand All @@ -42,7 +42,7 @@
*/
public class MP2Loader implements AssetLoader {

private static final Logger LOGGER = Logger.getLogger(MP2Loader.class.getName());
private static final Logger logger = System.getLogger(MP2Loader.class.getName());

public static final String FILE_EXTENSION = "mp2";

Expand Down Expand Up @@ -155,7 +155,7 @@ private AudioData load(InputStream inputStream, boolean stream) throws IOExcepti
return audioData;
}
} catch (IOException | UnsupportedMediaException ex) {
LOGGER.log(Level.SEVERE, "Failed to read a frame!", ex);
logger.log(Level.ERROR, "Failed to read a frame!", ex);
throw new IOException("Failed to read a frame!");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,7 @@ public void close() {
*/
public final void embed(MediaInformation information) {
if (information != null) {
for (Map.Entry<String, Object> entry : information.entrySet()) {
put(entry.getKey(), entry.getValue());
}
this.putAll(information);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ private int getInt() {
* @param b the input array
* @return the integer value
*/
protected final static int getShortInt(byte b[]) {
protected static int getShortInt(byte b[]) {
return b[0] << 16 & 0xFF0000 | b[1] << 8 & 0xFF00 | b[2] & 0xFF;
}

Expand Down
Loading

0 comments on commit 618cc6e

Please sign in to comment.