chore: merge BaseLauncherSettings into LauncherSettings (#662)

For historic reasons, the launcher settings classes were split into an abstract class interface and (several) implementations, but we dropped most of those some time ago.

Since we now only have single implementation class there's no point in keeping the interface and implementation separate.
master
Tobias Nett 2021-09-01 18:18:25 +02:00 committed by GitHub
parent a0fed1fbae
commit 6a41541d93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 374 additions and 527 deletions

View File

@ -5,7 +5,6 @@ package org.terasology.launcher;
import org.terasology.launcher.game.GameManager;
import org.terasology.launcher.repositories.RepositoryManager;
import org.terasology.launcher.settings.BaseLauncherSettings;
import org.terasology.launcher.settings.LauncherSettings;
import java.nio.file.Path;
@ -15,7 +14,7 @@ import java.nio.file.Path;
*
* Provides information on
* - directories managed by the launcher
* - user settings in form of {@link BaseLauncherSettings}
* - user settings in form of {@link LauncherSettings}
*/
public class LauncherConfiguration {

View File

@ -1,414 +0,0 @@
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.launcher.settings;
import com.google.gson.Gson;
import com.google.gson.JsonParseException;
import javafx.beans.property.Property;
import javafx.beans.property.ReadOnlyProperty;
import javafx.beans.property.SimpleBooleanProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.event.Level;
import org.terasology.launcher.model.GameIdentifier;
import org.terasology.launcher.util.JavaHeapSize;
import org.terasology.launcher.util.Languages;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Locale;
import java.util.Optional;
import java.util.Properties;
/**
* Provides access to launcher settings.
*/
public final class BaseLauncherSettings extends LauncherSettings {
public static final String USER_JAVA_PARAMETERS_DEFAULT = "-XX:MaxGCPauseMillis=20";
public static final String USER_GAME_PARAMETERS_DEFAULT = "";
public static final String PROPERTY_LOCALE = "locale";
public static final String PROPERTY_MAX_HEAP_SIZE = "maxHeapSize";
public static final String PROPERTY_INITIAL_HEAP_SIZE = "initialHeapSize";
public static final String PROPERTY_CLOSE_LAUNCHER_AFTER_GAME_START = "closeLauncherAfterGameStart";
public static final String PROPERTY_GAME_DIRECTORY = "gameDirectory";
public static final String PROPERTY_GAME_DATA_DIRECTORY = "gameDataDirectory";
public static final String PROPERTY_SAVE_DOWNLOADED_FILES = "saveDownloadedFiles";
public static final String PROPERTY_SHOW_PRE_RELEASES = "showPreReleases";
public static final String PROPERTY_BASE_JAVA_PARAMETERS = "baseJavaParameters";
public static final String PROPERTY_USER_JAVA_PARAMETERS = "userJavaParameters";
public static final String PROPERTY_USER_GAME_PARAMETERS = "userGameParameters";
public static final String PROPERTY_LOG_LEVEL = "logLevel";
public static final String PROPERTY_DEFAULT_GAME_JOB = "defaultGameJob";
public static final String PROPERTY_LAST_PLAYED_GAME_VERSION = "lastPlayedGameVersion";
public static final String PROPERTY_LAST_INSTALLED_GAME_JOB = "lastInstalledGameJob";
public static final String PROPERTY_LAST_INSTALLED_GAME_VERSION = "lastInstalledGameVersion";
public static final JavaHeapSize MAX_HEAP_SIZE_DEFAULT = JavaHeapSize.NOT_USED;
public static final JavaHeapSize INITIAL_HEAP_SIZE_DEFAULT = JavaHeapSize.NOT_USED;
public static final boolean CLOSE_LAUNCHER_AFTER_GAME_START_DEFAULT = true;
public static final boolean SAVE_DOWNLOADED_FILES_DEFAULT = false;
public static final boolean SHOW_PRE_RELEASES_DEFAULT = false;
public static final String LAST_PLAYED_GAME_VERSION_DEFAULT = "";
public static final String LAST_INSTALLED_GAME_VERSION_DEFAULT = "";
public static final String LAUNCHER_SETTINGS_FILE_NAME = "TerasologyLauncherSettings.properties";
private static final Logger logger = LoggerFactory.getLogger(BaseLauncherSettings.class);
private static final String WARN_MSG_INVALID_VALUE = "Invalid value '{}' for the parameter '{}'!";
private static final Level LOG_LEVEL_DEFAULT = Level.INFO;
private final Properties properties;
private final Property<Boolean> showPreReleases = new SimpleBooleanProperty(SHOW_PRE_RELEASES_DEFAULT);
BaseLauncherSettings(Properties properties) {
this.properties = properties;
}
@Override
Properties getProperties() {
return properties;
}
// --------------------------------------------------------------------- //
// INIT
// --------------------------------------------------------------------- //
protected void initLocale() {
final String localeStr = properties.getProperty(PROPERTY_LOCALE);
if (localeStr != null) {
Languages.init(localeStr);
if (!Languages.getCurrentLocale().toString().equals(localeStr)) {
logger.warn(WARN_MSG_INVALID_VALUE, localeStr, PROPERTY_LOCALE);
}
}
properties.setProperty(PROPERTY_LOCALE, Languages.getCurrentLocale().toString());
}
protected void initMaxHeapSize() {
final String maxHeapSizeStr = properties.getProperty(PROPERTY_MAX_HEAP_SIZE);
JavaHeapSize maxJavaHeapSize = MAX_HEAP_SIZE_DEFAULT;
if (maxHeapSizeStr != null) {
try {
maxJavaHeapSize = JavaHeapSize.valueOf(maxHeapSizeStr);
} catch (IllegalArgumentException e) {
logger.warn(WARN_MSG_INVALID_VALUE, maxHeapSizeStr, PROPERTY_MAX_HEAP_SIZE);
}
}
properties.setProperty(PROPERTY_MAX_HEAP_SIZE, maxJavaHeapSize.name());
}
protected void initInitialHeapSize() {
final String initialHeapSizeStr = properties.getProperty(PROPERTY_INITIAL_HEAP_SIZE);
JavaHeapSize initialJavaHeapSize = INITIAL_HEAP_SIZE_DEFAULT;
if (initialHeapSizeStr != null) {
try {
initialJavaHeapSize = JavaHeapSize.valueOf(initialHeapSizeStr);
} catch (IllegalArgumentException e) {
logger.warn(WARN_MSG_INVALID_VALUE, initialHeapSizeStr, PROPERTY_INITIAL_HEAP_SIZE);
}
}
properties.setProperty(PROPERTY_INITIAL_HEAP_SIZE, initialJavaHeapSize.name());
}
protected void initBaseJavaParameters() {
}
protected void initUserJavaParameters() {
final String userJavaParsStr = properties.getProperty(PROPERTY_USER_JAVA_PARAMETERS);
if (userJavaParsStr == null || userJavaParsStr.isEmpty()) {
properties.setProperty(PROPERTY_USER_JAVA_PARAMETERS, USER_JAVA_PARAMETERS_DEFAULT);
}
}
protected void initUserGameParameters() {
final String userJavaParsStr = properties.getProperty(PROPERTY_USER_GAME_PARAMETERS);
if (userJavaParsStr == null || userJavaParsStr.isEmpty()) {
properties.setProperty(PROPERTY_USER_GAME_PARAMETERS, USER_GAME_PARAMETERS_DEFAULT);
}
}
protected void initLogLevel() {
final String logLevelStr = properties.getProperty(PROPERTY_LOG_LEVEL);
Level logLevel = LOG_LEVEL_DEFAULT;
if (logLevelStr != null) {
try {
logLevel = Level.valueOf(logLevelStr);
} catch (IllegalArgumentException e) {
logger.warn(WARN_MSG_INVALID_VALUE, logLevelStr, PROPERTY_LOG_LEVEL);
}
}
properties.setProperty(PROPERTY_LOG_LEVEL, logLevel.name());
}
protected void initCloseLauncherAfterGameStart() {
final String closeLauncherAfterGameStartStr = properties.getProperty(PROPERTY_CLOSE_LAUNCHER_AFTER_GAME_START);
boolean closeLauncherAfterGameStart = CLOSE_LAUNCHER_AFTER_GAME_START_DEFAULT;
if (closeLauncherAfterGameStartStr != null) {
closeLauncherAfterGameStart = Boolean.valueOf(closeLauncherAfterGameStartStr);
}
properties.setProperty(PROPERTY_CLOSE_LAUNCHER_AFTER_GAME_START, Boolean.toString(closeLauncherAfterGameStart));
}
protected void initSaveDownloadedFiles() {
final String saveDownloadedFilesStr = properties.getProperty(PROPERTY_SAVE_DOWNLOADED_FILES);
boolean saveDownloadedFiles = SAVE_DOWNLOADED_FILES_DEFAULT;
if (saveDownloadedFilesStr != null) {
saveDownloadedFiles = Boolean.valueOf(saveDownloadedFilesStr);
}
properties.setProperty(PROPERTY_SAVE_DOWNLOADED_FILES, Boolean.toString(saveDownloadedFiles));
}
protected void initShowPreReleases() {
final String showPreReleasesStr = properties.getProperty(PROPERTY_SHOW_PRE_RELEASES);
if (showPreReleasesStr != null) {
setShowPreReleases(Boolean.parseBoolean(showPreReleasesStr));
} else {
setShowPreReleases(SHOW_PRE_RELEASES_DEFAULT);
}
}
protected void initGameDirectory() {
final String gameDirectoryStr = properties.getProperty(PROPERTY_GAME_DIRECTORY);
Path gameDirectory = null;
if (gameDirectoryStr != null && gameDirectoryStr.trim().length() > 0) {
try {
gameDirectory = Paths.get(new URI(gameDirectoryStr));
} catch (URISyntaxException | RuntimeException e) {
logger.warn(WARN_MSG_INVALID_VALUE, gameDirectoryStr, PROPERTY_GAME_DIRECTORY);
}
}
if (gameDirectory != null) {
properties.setProperty(PROPERTY_GAME_DIRECTORY, gameDirectory.toUri().toString());
} else {
properties.setProperty(PROPERTY_GAME_DIRECTORY, "");
}
}
protected void initGameDataDirectory() {
final String gameDataDirectoryStr = properties.getProperty(PROPERTY_GAME_DATA_DIRECTORY);
Path gameDataDirectory = null;
if (gameDataDirectoryStr != null && gameDataDirectoryStr.trim().length() > 0) {
try {
gameDataDirectory = Paths.get(new URI(gameDataDirectoryStr));
} catch (URISyntaxException | RuntimeException e) {
logger.warn(WARN_MSG_INVALID_VALUE, gameDataDirectoryStr, PROPERTY_GAME_DATA_DIRECTORY);
}
}
if (gameDataDirectory != null) {
properties.setProperty(PROPERTY_GAME_DATA_DIRECTORY, gameDataDirectory.toUri().toString());
} else {
properties.setProperty(PROPERTY_GAME_DATA_DIRECTORY, "");
}
}
protected void initLastPlayedGameVersion() {
final String lastPlayedGameVersionStr = properties.getProperty(PROPERTY_LAST_PLAYED_GAME_VERSION);
if (lastPlayedGameVersionStr == null || lastPlayedGameVersionStr.isEmpty()) {
properties.setProperty(PROPERTY_LAST_PLAYED_GAME_VERSION, LAST_PLAYED_GAME_VERSION_DEFAULT);
}
}
protected void initLastInstalledGameVersion() {
final String lastInstalledGameVersionStr = properties.getProperty(PROPERTY_LAST_INSTALLED_GAME_VERSION);
if (lastInstalledGameVersionStr == null || lastInstalledGameVersionStr.isEmpty()) {
properties.setProperty(PROPERTY_LAST_INSTALLED_GAME_VERSION, LAST_INSTALLED_GAME_VERSION_DEFAULT);
}
}
// --------------------------------------------------------------------- //
// PROPERTIES
// --------------------------------------------------------------------- //
@Override
public ReadOnlyProperty<Boolean> showPreReleases() {
return showPreReleases;
}
// --------------------------------------------------------------------- //
// GETTERS
// --------------------------------------------------------------------- //
@Override
public synchronized Locale getLocale() {
return Locale.forLanguageTag(properties.getProperty(PROPERTY_LOCALE));
}
@Override
public synchronized JavaHeapSize getMaxHeapSize() {
return JavaHeapSize.valueOf(properties.getProperty(PROPERTY_MAX_HEAP_SIZE));
}
@Override
public synchronized JavaHeapSize getInitialHeapSize() {
return JavaHeapSize.valueOf(properties.getProperty(PROPERTY_INITIAL_HEAP_SIZE));
}
@Override
public synchronized String getBaseJavaParameters() {
return properties.getProperty(PROPERTY_BASE_JAVA_PARAMETERS);
}
@Override
public synchronized String getUserJavaParameters() {
return properties.getProperty(PROPERTY_USER_JAVA_PARAMETERS);
}
@Override
public synchronized String getUserGameParameters() {
return properties.getProperty(PROPERTY_USER_GAME_PARAMETERS);
}
@Override
public synchronized Level getLogLevel() {
return Level.valueOf(properties.getProperty(PROPERTY_LOG_LEVEL));
}
@Override
public synchronized Path getGameDirectory() {
final String gameDirectoryStr = properties.getProperty(PROPERTY_GAME_DIRECTORY);
if (gameDirectoryStr != null && gameDirectoryStr.trim().length() > 0) {
try {
return Paths.get(new URI(gameDirectoryStr));
} catch (URISyntaxException | RuntimeException e) {
logger.error(WARN_MSG_INVALID_VALUE, gameDirectoryStr, PROPERTY_GAME_DIRECTORY);
}
}
return null;
}
@Override
public synchronized Path getGameDataDirectory() {
final String gameDataDirectoryStr = properties.getProperty(PROPERTY_GAME_DATA_DIRECTORY);
if (gameDataDirectoryStr != null && gameDataDirectoryStr.trim().length() > 0) {
try {
return Paths.get(new URI(gameDataDirectoryStr));
} catch (URISyntaxException | RuntimeException e) {
logger.error(WARN_MSG_INVALID_VALUE, gameDataDirectoryStr, PROPERTY_GAME_DATA_DIRECTORY);
}
}
return null;
}
@Override
public synchronized boolean isCloseLauncherAfterGameStart() {
return Boolean.valueOf(properties.getProperty(PROPERTY_CLOSE_LAUNCHER_AFTER_GAME_START));
}
@Override
public synchronized boolean isKeepDownloadedFiles() {
return Boolean.valueOf(properties.getProperty(PROPERTY_SAVE_DOWNLOADED_FILES));
}
@Override
public synchronized boolean isShowPreReleases() {
return Boolean.parseBoolean(properties.getProperty(PROPERTY_SHOW_PRE_RELEASES));
}
@Override
public synchronized Optional<GameIdentifier> getLastPlayedGameVersion() {
String property = properties.getProperty(PROPERTY_LAST_PLAYED_GAME_VERSION);
if (property == null || property.isEmpty()) {
return Optional.empty();
}
GameIdentifier id;
try {
id = new Gson().fromJson(property, GameIdentifier.class);
} catch (JsonParseException e) {
logger.warn("Failed to parse a game version from \"{}\". This should automatically resolve when starting a game.", property, e);
return Optional.empty();
}
return Optional.ofNullable(id);
}
@Override
public synchronized String getLastInstalledGameJob() {
return properties.getProperty(PROPERTY_LAST_INSTALLED_GAME_JOB);
}
// --------------------------------------------------------------------- //
// SETTERS
// --------------------------------------------------------------------- //
@Override
public synchronized void setLocale(Locale locale) {
properties.setProperty(PROPERTY_LOCALE, locale.toString());
}
@Override
public synchronized void setMaxHeapSize(JavaHeapSize maxHeapSize) {
properties.setProperty(PROPERTY_MAX_HEAP_SIZE, maxHeapSize.name());
}
@Override
public synchronized void setInitialHeapSize(JavaHeapSize initialHeapSize) {
properties.setProperty(PROPERTY_INITIAL_HEAP_SIZE, initialHeapSize.name());
}
@Override
public synchronized void setUserJavaParameters(String userJavaParameters) {
properties.setProperty(PROPERTY_USER_JAVA_PARAMETERS, userJavaParameters);
}
@Override
public synchronized void setUserGameParameters(String userGameParameters) {
properties.setProperty(PROPERTY_USER_GAME_PARAMETERS, userGameParameters);
}
@Override
public synchronized void setLogLevel(Level logLevel) {
properties.setProperty(PROPERTY_LOG_LEVEL, logLevel.name());
}
@Override
public synchronized void setCloseLauncherAfterGameStart(boolean closeLauncherAfterGameStart) {
properties.setProperty(PROPERTY_CLOSE_LAUNCHER_AFTER_GAME_START, Boolean.toString(closeLauncherAfterGameStart));
}
@Override
public synchronized void setKeepDownloadedFiles(boolean keepDownloadedFiles) {
properties.setProperty(PROPERTY_SAVE_DOWNLOADED_FILES, Boolean.toString(keepDownloadedFiles));
}
@Override
public synchronized void setShowPreReleases(boolean selected) {
showPreReleases.setValue(selected);
properties.setProperty(PROPERTY_SHOW_PRE_RELEASES, Boolean.toString(selected));
}
@Override
public synchronized void setGameDirectory(Path gameDirectory) {
properties.setProperty(PROPERTY_GAME_DIRECTORY, gameDirectory.toUri().toString());
}
@Override
public synchronized void setGameDataDirectory(Path gameDataDirectory) {
properties.setProperty(PROPERTY_GAME_DATA_DIRECTORY, gameDataDirectory.toUri().toString());
}
@Override
public synchronized void setDefaultGameJob(String defaultGameJob) {
properties.setProperty(PROPERTY_DEFAULT_GAME_JOB, defaultGameJob);
}
@Override
public synchronized void setLastPlayedGameVersion(GameIdentifier lastPlayedGameVersion) {
if (lastPlayedGameVersion == null) {
properties.setProperty(PROPERTY_LAST_PLAYED_GAME_VERSION, "");
} else {
properties.setProperty(PROPERTY_LAST_PLAYED_GAME_VERSION, new Gson().toJson(lastPlayedGameVersion));
}
}
@Override
public String toString() {
return this.getClass().getName() + "[" + properties.toString() + "]";
}
}

View File

@ -4,14 +4,22 @@
package org.terasology.launcher.settings;
import com.google.common.collect.Lists;
import com.google.gson.Gson;
import com.google.gson.JsonParseException;
import javafx.beans.property.Property;
import javafx.beans.property.ReadOnlyProperty;
import javafx.beans.property.SimpleBooleanProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.event.Level;
import org.terasology.launcher.model.GameIdentifier;
import org.terasology.launcher.util.JavaHeapSize;
import org.terasology.launcher.util.Languages;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
@ -19,11 +27,61 @@ import java.util.Optional;
import java.util.Properties;
import java.util.stream.Collectors;
public abstract class LauncherSettings {
/**
* User settings for the launcher, backed by Java {@link Properties}.
*/
public class LauncherSettings {
private static final Logger logger = LoggerFactory.getLogger(LauncherSettings.class);
abstract Properties getProperties();
public static final String USER_JAVA_PARAMETERS_DEFAULT = "-XX:MaxGCPauseMillis=20";
public static final String USER_GAME_PARAMETERS_DEFAULT = "";
public static final String PROPERTY_LOCALE = "locale";
public static final String PROPERTY_MAX_HEAP_SIZE = "maxHeapSize";
public static final String PROPERTY_INITIAL_HEAP_SIZE = "initialHeapSize";
public static final String PROPERTY_CLOSE_LAUNCHER_AFTER_GAME_START = "closeLauncherAfterGameStart";
public static final String PROPERTY_GAME_DIRECTORY = "gameDirectory";
public static final String PROPERTY_GAME_DATA_DIRECTORY = "gameDataDirectory";
public static final String PROPERTY_SAVE_DOWNLOADED_FILES = "saveDownloadedFiles";
public static final String PROPERTY_SHOW_PRE_RELEASES = "showPreReleases";
public static final String PROPERTY_BASE_JAVA_PARAMETERS = "baseJavaParameters";
public static final String PROPERTY_USER_JAVA_PARAMETERS = "userJavaParameters";
public static final String PROPERTY_USER_GAME_PARAMETERS = "userGameParameters";
public static final String PROPERTY_LOG_LEVEL = "logLevel";
public static final String PROPERTY_DEFAULT_GAME_JOB = "defaultGameJob";
public static final String PROPERTY_LAST_PLAYED_GAME_VERSION = "lastPlayedGameVersion";
public static final String PROPERTY_LAST_INSTALLED_GAME_JOB = "lastInstalledGameJob";
public static final String PROPERTY_LAST_INSTALLED_GAME_VERSION = "lastInstalledGameVersion";
static final JavaHeapSize MAX_HEAP_SIZE_DEFAULT = JavaHeapSize.NOT_USED;
static final JavaHeapSize INITIAL_HEAP_SIZE_DEFAULT = JavaHeapSize.NOT_USED;
static final boolean CLOSE_LAUNCHER_AFTER_GAME_START_DEFAULT = true;
static final boolean SAVE_DOWNLOADED_FILES_DEFAULT = false;
static final boolean SHOW_PRE_RELEASES_DEFAULT = false;
static final String LAST_PLAYED_GAME_VERSION_DEFAULT = "";
static final String LAST_INSTALLED_GAME_VERSION_DEFAULT = "";
static final String LAUNCHER_SETTINGS_FILE_NAME = "TerasologyLauncherSettings.properties";
private static final String WARN_MSG_INVALID_VALUE = "Invalid value '{}' for the parameter '{}'!";
private static final Level LOG_LEVEL_DEFAULT = Level.INFO;
private final Properties properties;
private final Property<Boolean> showPreReleases = new SimpleBooleanProperty(SHOW_PRE_RELEASES_DEFAULT);
LauncherSettings(Properties properties) {
this.properties = properties;
}
Properties getProperties() {
return properties;
}
// --------------------------------------------------------------------- //
// INIT
// --------------------------------------------------------------------- //
public synchronized void init() {
logger.trace("Init launcher settings ...");
@ -44,57 +102,243 @@ public abstract class LauncherSettings {
initLastInstalledGameVersion();
}
// --------------------------------------------------------------------- //
// INIT
// --------------------------------------------------------------------- //
void initLocale() {
final String localeStr = properties.getProperty(PROPERTY_LOCALE);
if (localeStr != null) {
Languages.init(localeStr);
protected abstract void initInitialHeapSize();
if (!Languages.getCurrentLocale().toString().equals(localeStr)) {
logger.warn(WARN_MSG_INVALID_VALUE, localeStr, PROPERTY_LOCALE);
}
}
properties.setProperty(PROPERTY_LOCALE, Languages.getCurrentLocale().toString());
}
protected abstract void initCloseLauncherAfterGameStart();
void initMaxHeapSize() {
final String maxHeapSizeStr = properties.getProperty(PROPERTY_MAX_HEAP_SIZE);
JavaHeapSize maxJavaHeapSize = MAX_HEAP_SIZE_DEFAULT;
if (maxHeapSizeStr != null) {
try {
maxJavaHeapSize = JavaHeapSize.valueOf(maxHeapSizeStr);
} catch (IllegalArgumentException e) {
logger.warn(WARN_MSG_INVALID_VALUE, maxHeapSizeStr, PROPERTY_MAX_HEAP_SIZE);
}
}
properties.setProperty(PROPERTY_MAX_HEAP_SIZE, maxJavaHeapSize.name());
}
protected abstract void initSaveDownloadedFiles();
void initInitialHeapSize() {
final String initialHeapSizeStr = properties.getProperty(PROPERTY_INITIAL_HEAP_SIZE);
JavaHeapSize initialJavaHeapSize = INITIAL_HEAP_SIZE_DEFAULT;
if (initialHeapSizeStr != null) {
try {
initialJavaHeapSize = JavaHeapSize.valueOf(initialHeapSizeStr);
} catch (IllegalArgumentException e) {
logger.warn(WARN_MSG_INVALID_VALUE, initialHeapSizeStr, PROPERTY_INITIAL_HEAP_SIZE);
}
}
properties.setProperty(PROPERTY_INITIAL_HEAP_SIZE, initialJavaHeapSize.name());
}
protected abstract void initShowPreReleases();
void initBaseJavaParameters() {
}
protected abstract void initGameDirectory();
void initUserJavaParameters() {
final String userJavaParsStr = properties.getProperty(PROPERTY_USER_JAVA_PARAMETERS);
if (userJavaParsStr == null || userJavaParsStr.isEmpty()) {
properties.setProperty(PROPERTY_USER_JAVA_PARAMETERS, USER_JAVA_PARAMETERS_DEFAULT);
}
}
protected abstract void initGameDataDirectory();
void initUserGameParameters() {
final String userJavaParsStr = properties.getProperty(PROPERTY_USER_GAME_PARAMETERS);
if (userJavaParsStr == null || userJavaParsStr.isEmpty()) {
properties.setProperty(PROPERTY_USER_GAME_PARAMETERS, USER_GAME_PARAMETERS_DEFAULT);
}
}
protected abstract void initBaseJavaParameters();
void initLogLevel() {
final String logLevelStr = properties.getProperty(PROPERTY_LOG_LEVEL);
Level logLevel = LOG_LEVEL_DEFAULT;
if (logLevelStr != null) {
try {
logLevel = Level.valueOf(logLevelStr);
} catch (IllegalArgumentException e) {
logger.warn(WARN_MSG_INVALID_VALUE, logLevelStr, PROPERTY_LOG_LEVEL);
}
}
properties.setProperty(PROPERTY_LOG_LEVEL, logLevel.name());
}
protected abstract void initUserJavaParameters();
void initCloseLauncherAfterGameStart() {
final String closeLauncherAfterGameStartStr = properties.getProperty(PROPERTY_CLOSE_LAUNCHER_AFTER_GAME_START);
boolean closeLauncherAfterGameStart = CLOSE_LAUNCHER_AFTER_GAME_START_DEFAULT;
if (closeLauncherAfterGameStartStr != null) {
closeLauncherAfterGameStart = Boolean.valueOf(closeLauncherAfterGameStartStr);
}
properties.setProperty(PROPERTY_CLOSE_LAUNCHER_AFTER_GAME_START, Boolean.toString(closeLauncherAfterGameStart));
}
protected abstract void initUserGameParameters();
void initSaveDownloadedFiles() {
final String saveDownloadedFilesStr = properties.getProperty(PROPERTY_SAVE_DOWNLOADED_FILES);
boolean saveDownloadedFiles = SAVE_DOWNLOADED_FILES_DEFAULT;
if (saveDownloadedFilesStr != null) {
saveDownloadedFiles = Boolean.valueOf(saveDownloadedFilesStr);
}
properties.setProperty(PROPERTY_SAVE_DOWNLOADED_FILES, Boolean.toString(saveDownloadedFiles));
}
protected abstract void initLogLevel();
void initShowPreReleases() {
final String showPreReleasesStr = properties.getProperty(PROPERTY_SHOW_PRE_RELEASES);
if (showPreReleasesStr != null) {
setShowPreReleases(Boolean.parseBoolean(showPreReleasesStr));
} else {
setShowPreReleases(SHOW_PRE_RELEASES_DEFAULT);
}
}
protected abstract void initMaxHeapSize();
void initGameDirectory() {
final String gameDirectoryStr = properties.getProperty(PROPERTY_GAME_DIRECTORY);
Path gameDirectory = null;
if (gameDirectoryStr != null && gameDirectoryStr.trim().length() > 0) {
try {
gameDirectory = Paths.get(new URI(gameDirectoryStr));
} catch (URISyntaxException | RuntimeException e) {
logger.warn(WARN_MSG_INVALID_VALUE, gameDirectoryStr, PROPERTY_GAME_DIRECTORY);
}
}
if (gameDirectory != null) {
properties.setProperty(PROPERTY_GAME_DIRECTORY, gameDirectory.toUri().toString());
} else {
properties.setProperty(PROPERTY_GAME_DIRECTORY, "");
}
}
protected abstract void initLocale();
void initGameDataDirectory() {
final String gameDataDirectoryStr = properties.getProperty(PROPERTY_GAME_DATA_DIRECTORY);
Path gameDataDirectory = null;
if (gameDataDirectoryStr != null && gameDataDirectoryStr.trim().length() > 0) {
try {
gameDataDirectory = Paths.get(new URI(gameDataDirectoryStr));
} catch (URISyntaxException | RuntimeException e) {
logger.warn(WARN_MSG_INVALID_VALUE, gameDataDirectoryStr, PROPERTY_GAME_DATA_DIRECTORY);
}
}
if (gameDataDirectory != null) {
properties.setProperty(PROPERTY_GAME_DATA_DIRECTORY, gameDataDirectory.toUri().toString());
} else {
properties.setProperty(PROPERTY_GAME_DATA_DIRECTORY, "");
}
}
protected abstract void initLastPlayedGameVersion();
void initLastPlayedGameVersion() {
final String lastPlayedGameVersionStr = properties.getProperty(PROPERTY_LAST_PLAYED_GAME_VERSION);
if (lastPlayedGameVersionStr == null || lastPlayedGameVersionStr.isEmpty()) {
properties.setProperty(PROPERTY_LAST_PLAYED_GAME_VERSION, LAST_PLAYED_GAME_VERSION_DEFAULT);
}
}
protected abstract void initLastInstalledGameVersion();
void initLastInstalledGameVersion() {
final String lastInstalledGameVersionStr = properties.getProperty(PROPERTY_LAST_INSTALLED_GAME_VERSION);
if (lastInstalledGameVersionStr == null || lastInstalledGameVersionStr.isEmpty()) {
properties.setProperty(PROPERTY_LAST_INSTALLED_GAME_VERSION, LAST_INSTALLED_GAME_VERSION_DEFAULT);
}
}
// --------------------------------------------------------------------- //
// PROPERTIES
// --------------------------------------------------------------------- //
public abstract ReadOnlyProperty<Boolean> showPreReleases();
public ReadOnlyProperty<Boolean> showPreReleases() {
return showPreReleases;
}
// --------------------------------------------------------------------- //
// GETTERS
// --------------------------------------------------------------------- //
public abstract Locale getLocale();
public synchronized Locale getLocale() {
return Locale.forLanguageTag(properties.getProperty(PROPERTY_LOCALE));
}
public abstract JavaHeapSize getMaxHeapSize();
public synchronized JavaHeapSize getMaxHeapSize() {
return JavaHeapSize.valueOf(properties.getProperty(PROPERTY_MAX_HEAP_SIZE));
}
public abstract JavaHeapSize getInitialHeapSize();
public synchronized JavaHeapSize getInitialHeapSize() {
return JavaHeapSize.valueOf(properties.getProperty(PROPERTY_INITIAL_HEAP_SIZE));
}
public abstract String getUserJavaParameters();
public synchronized String getBaseJavaParameters() {
return properties.getProperty(PROPERTY_BASE_JAVA_PARAMETERS);
}
public abstract String getBaseJavaParameters();
public synchronized String getUserJavaParameters() {
return properties.getProperty(PROPERTY_USER_JAVA_PARAMETERS);
}
public synchronized String getUserGameParameters() {
return properties.getProperty(PROPERTY_USER_GAME_PARAMETERS);
}
public synchronized Level getLogLevel() {
return Level.valueOf(properties.getProperty(PROPERTY_LOG_LEVEL));
}
public synchronized Path getGameDirectory() {
final String gameDirectoryStr = properties.getProperty(PROPERTY_GAME_DIRECTORY);
if (gameDirectoryStr != null && gameDirectoryStr.trim().length() > 0) {
try {
return Paths.get(new URI(gameDirectoryStr));
} catch (URISyntaxException | RuntimeException e) {
logger.error(WARN_MSG_INVALID_VALUE, gameDirectoryStr, PROPERTY_GAME_DIRECTORY);
}
}
return null;
}
public synchronized Path getGameDataDirectory() {
final String gameDataDirectoryStr = properties.getProperty(PROPERTY_GAME_DATA_DIRECTORY);
if (gameDataDirectoryStr != null && gameDataDirectoryStr.trim().length() > 0) {
try {
return Paths.get(new URI(gameDataDirectoryStr));
} catch (URISyntaxException | RuntimeException e) {
logger.error(WARN_MSG_INVALID_VALUE, gameDataDirectoryStr, PROPERTY_GAME_DATA_DIRECTORY);
}
}
return null;
}
public synchronized boolean isCloseLauncherAfterGameStart() {
return Boolean.valueOf(properties.getProperty(PROPERTY_CLOSE_LAUNCHER_AFTER_GAME_START));
}
public synchronized boolean isKeepDownloadedFiles() {
return Boolean.valueOf(properties.getProperty(PROPERTY_SAVE_DOWNLOADED_FILES));
}
public synchronized boolean isShowPreReleases() {
return Boolean.parseBoolean(properties.getProperty(PROPERTY_SHOW_PRE_RELEASES));
}
public synchronized Optional<GameIdentifier> getLastPlayedGameVersion() {
String property = properties.getProperty(PROPERTY_LAST_PLAYED_GAME_VERSION);
if (property == null || property.isEmpty()) {
return Optional.empty();
}
GameIdentifier id;
try {
id = new Gson().fromJson(property, GameIdentifier.class);
} catch (JsonParseException e) {
logger.warn("Failed to parse a game version from \"{}\". This should automatically resolve when starting a game.", property, e);
return Optional.empty();
}
return Optional.ofNullable(id);
}
public synchronized String getLastInstalledGameJob() {
return properties.getProperty(PROPERTY_LAST_INSTALLED_GAME_JOB);
}
public synchronized List<String> getJavaParameterList() {
List<String> javaParameters = Lists.newArrayList();
@ -111,57 +355,76 @@ public abstract class LauncherSettings {
return javaParameters;
}
public abstract String getUserGameParameters();
public synchronized List<String> getUserGameParameterList() {
return Arrays.stream(getUserGameParameters().split("\\s+"))
.filter(s -> !s.isEmpty())
.collect(Collectors.toUnmodifiableList());
}
public abstract Level getLogLevel();
public abstract Path getGameDirectory();
public abstract Path getGameDataDirectory();
public abstract boolean isCloseLauncherAfterGameStart();
public abstract boolean isKeepDownloadedFiles();
public abstract boolean isShowPreReleases();
public abstract Optional<GameIdentifier> getLastPlayedGameVersion();
public abstract String getLastInstalledGameJob();
// --------------------------------------------------------------------- //
// SETTERS
// --------------------------------------------------------------------- //
public abstract void setLocale(Locale locale);
public synchronized void setLocale(Locale locale) {
properties.setProperty(PROPERTY_LOCALE, locale.toString());
}
public abstract void setMaxHeapSize(JavaHeapSize maxHeapSize);
public synchronized void setMaxHeapSize(JavaHeapSize maxHeapSize) {
properties.setProperty(PROPERTY_MAX_HEAP_SIZE, maxHeapSize.name());
}
public abstract void setInitialHeapSize(JavaHeapSize initialHeapSize);
public synchronized void setInitialHeapSize(JavaHeapSize initialHeapSize) {
properties.setProperty(PROPERTY_INITIAL_HEAP_SIZE, initialHeapSize.name());
}
public abstract void setUserJavaParameters(String userJavaParameters);
public synchronized void setUserJavaParameters(String userJavaParameters) {
properties.setProperty(PROPERTY_USER_JAVA_PARAMETERS, userJavaParameters);
}
public abstract void setUserGameParameters(String userGameParameters);
public synchronized void setUserGameParameters(String userGameParameters) {
properties.setProperty(PROPERTY_USER_GAME_PARAMETERS, userGameParameters);
}
public abstract void setLogLevel(Level logLevel);
public synchronized void setLogLevel(Level logLevel) {
properties.setProperty(PROPERTY_LOG_LEVEL, logLevel.name());
}
public abstract void setCloseLauncherAfterGameStart(boolean closeLauncherAfterGameStart);
public synchronized void setCloseLauncherAfterGameStart(boolean closeLauncherAfterGameStart) {
properties.setProperty(PROPERTY_CLOSE_LAUNCHER_AFTER_GAME_START, Boolean.toString(closeLauncherAfterGameStart));
}
public abstract void setKeepDownloadedFiles(boolean keepDownloadedFiles);
public synchronized void setKeepDownloadedFiles(boolean keepDownloadedFiles) {
properties.setProperty(PROPERTY_SAVE_DOWNLOADED_FILES, Boolean.toString(keepDownloadedFiles));
}
public abstract void setShowPreReleases(boolean selected);
public synchronized void setShowPreReleases(boolean selected) {
showPreReleases.setValue(selected);
properties.setProperty(PROPERTY_SHOW_PRE_RELEASES, Boolean.toString(selected));
}
public abstract void setGameDirectory(Path gameDirectory);
public synchronized void setGameDirectory(Path gameDirectory) {
properties.setProperty(PROPERTY_GAME_DIRECTORY, gameDirectory.toUri().toString());
}
public abstract void setGameDataDirectory(Path gameDataDirectory);
public synchronized void setGameDataDirectory(Path gameDataDirectory) {
properties.setProperty(PROPERTY_GAME_DATA_DIRECTORY, gameDataDirectory.toUri().toString());
}
public abstract void setDefaultGameJob(String lastPlayedGameJob);
public synchronized void setDefaultGameJob(String defaultGameJob) {
properties.setProperty(PROPERTY_DEFAULT_GAME_JOB, defaultGameJob);
}
public abstract void setLastPlayedGameVersion(GameIdentifier lastPlayedGameVersion);
public synchronized void setLastPlayedGameVersion(GameIdentifier lastPlayedGameVersion) {
if (lastPlayedGameVersion == null) {
properties.setProperty(PROPERTY_LAST_PLAYED_GAME_VERSION, "");
} else {
properties.setProperty(PROPERTY_LAST_PLAYED_GAME_VERSION, new Gson().toJson(lastPlayedGameVersion));
}
}
@Override
public String toString() {
return this.getClass().getName() + "[" + properties.toString() + "]";
}
}

View File

@ -33,7 +33,7 @@ public final class Settings {
try (InputStream inputStream = Files.newInputStream(path)) {
Properties properties = new Properties();
properties.load(inputStream);
return new BaseLauncherSettings(properties);
return new LauncherSettings(properties);
} catch (IOException e) {
logger.error("Error while loading launcher settings from file.", e);
}
@ -52,6 +52,6 @@ public final class Settings {
}
public static LauncherSettings getDefault() {
return new BaseLauncherSettings(new Properties());
return new LauncherSettings(new Properties());
};
}

View File

@ -18,7 +18,6 @@ import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.event.Level;
import org.terasology.launcher.settings.BaseLauncherSettings;
import org.terasology.launcher.settings.LauncherSettings;
import org.terasology.launcher.settings.Settings;
import org.terasology.launcher.util.BundleUtils;
@ -137,13 +136,13 @@ public class SettingsController {
//save userParameters (java & game), if textfield is empty then set to defaults
if (userJavaParametersField.getText().isEmpty()) {
launcherSettings.setUserJavaParameters(BaseLauncherSettings.USER_JAVA_PARAMETERS_DEFAULT);
launcherSettings.setUserJavaParameters(LauncherSettings.USER_JAVA_PARAMETERS_DEFAULT);
} else {
logger.debug("User defined Java parameters: {}", userJavaParametersField.getText());
launcherSettings.setUserJavaParameters(userJavaParametersField.getText());
}
if (userGameParametersField.getText().isEmpty()) {
launcherSettings.setUserGameParameters(BaseLauncherSettings.USER_GAME_PARAMETERS_DEFAULT);
launcherSettings.setUserGameParameters(LauncherSettings.USER_GAME_PARAMETERS_DEFAULT);
} else {
logger.debug("User defined game parameters: {}", userGameParametersField.getText());
launcherSettings.setUserGameParameters(userGameParametersField.getText());
@ -332,11 +331,11 @@ public class SettingsController {
private void initUserParameterFields() {
//if the VM parameters are left default do not display, the prompt message will show
if (!launcherSettings.getUserJavaParameters().equals(BaseLauncherSettings.USER_JAVA_PARAMETERS_DEFAULT)) {
if (!launcherSettings.getUserJavaParameters().equals(LauncherSettings.USER_JAVA_PARAMETERS_DEFAULT)) {
userJavaParametersField.setText(launcherSettings.getUserJavaParameters());
}
//if the Game parameters are left default do not display, the prompt message will show
if (!launcherSettings.getUserGameParameters().equals(BaseLauncherSettings.USER_GAME_PARAMETERS_DEFAULT)) {
if (!launcherSettings.getUserGameParameters().equals(LauncherSettings.USER_GAME_PARAMETERS_DEFAULT)) {
userGameParametersField.setText(launcherSettings.getUserGameParameters());
}
}

View File

@ -22,16 +22,16 @@ import java.util.Properties;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.terasology.launcher.settings.BaseLauncherSettings.PROPERTY_CLOSE_LAUNCHER_AFTER_GAME_START;
import static org.terasology.launcher.settings.BaseLauncherSettings.PROPERTY_GAME_DATA_DIRECTORY;
import static org.terasology.launcher.settings.BaseLauncherSettings.PROPERTY_GAME_DIRECTORY;
import static org.terasology.launcher.settings.BaseLauncherSettings.PROPERTY_INITIAL_HEAP_SIZE;
import static org.terasology.launcher.settings.BaseLauncherSettings.PROPERTY_LOCALE;
import static org.terasology.launcher.settings.BaseLauncherSettings.PROPERTY_LOG_LEVEL;
import static org.terasology.launcher.settings.BaseLauncherSettings.PROPERTY_MAX_HEAP_SIZE;
import static org.terasology.launcher.settings.BaseLauncherSettings.PROPERTY_SAVE_DOWNLOADED_FILES;
import static org.terasology.launcher.settings.BaseLauncherSettings.PROPERTY_USER_GAME_PARAMETERS;
import static org.terasology.launcher.settings.BaseLauncherSettings.PROPERTY_USER_JAVA_PARAMETERS;
import static org.terasology.launcher.settings.LauncherSettings.PROPERTY_CLOSE_LAUNCHER_AFTER_GAME_START;
import static org.terasology.launcher.settings.LauncherSettings.PROPERTY_GAME_DATA_DIRECTORY;
import static org.terasology.launcher.settings.LauncherSettings.PROPERTY_GAME_DIRECTORY;
import static org.terasology.launcher.settings.LauncherSettings.PROPERTY_INITIAL_HEAP_SIZE;
import static org.terasology.launcher.settings.LauncherSettings.PROPERTY_LOCALE;
import static org.terasology.launcher.settings.LauncherSettings.PROPERTY_LOG_LEVEL;
import static org.terasology.launcher.settings.LauncherSettings.PROPERTY_MAX_HEAP_SIZE;
import static org.terasology.launcher.settings.LauncherSettings.PROPERTY_SAVE_DOWNLOADED_FILES;
import static org.terasology.launcher.settings.LauncherSettings.PROPERTY_USER_GAME_PARAMETERS;
import static org.terasology.launcher.settings.LauncherSettings.PROPERTY_USER_JAVA_PARAMETERS;
class TestLauncherSettings {
@TempDir
@ -41,7 +41,7 @@ class TestLauncherSettings {
@TempDir
Path gameDataDirectory;
private LauncherSettings baseLauncherSettings;
private LauncherSettings launcherSettings;
private Path testPropertiesFile;
private String locale;
@ -54,23 +54,23 @@ class TestLauncherSettings {
private String logLevel;
private void assertPropertiesEqual() throws Exception {
assertEquals(baseLauncherSettings.getLocale(), Locale.forLanguageTag(locale));
assertEquals(baseLauncherSettings.getMaxHeapSize(), JavaHeapSize.valueOf(maxHeapSize));
assertEquals(baseLauncherSettings.getInitialHeapSize(), JavaHeapSize.valueOf(initialHeapSize));
assertEquals(baseLauncherSettings.isCloseLauncherAfterGameStart(), Boolean.valueOf(closeLauncherAfterGameStart));
assertEquals(baseLauncherSettings.getGameDirectory(), gameDirectory);
assertEquals(baseLauncherSettings.getGameDataDirectory(), gameDataDirectory);
assertEquals(baseLauncherSettings.isKeepDownloadedFiles(), Boolean.valueOf(saveDownloadedFiles));
assertEquals(baseLauncherSettings.getUserJavaParameters(), userJavaParameters);
assertEquals(baseLauncherSettings.getUserGameParameters(), userGameParameters);
assertEquals(baseLauncherSettings.getLogLevel(), Level.valueOf(logLevel));
assertEquals(launcherSettings.getLocale(), Locale.forLanguageTag(locale));
assertEquals(launcherSettings.getMaxHeapSize(), JavaHeapSize.valueOf(maxHeapSize));
assertEquals(launcherSettings.getInitialHeapSize(), JavaHeapSize.valueOf(initialHeapSize));
assertEquals(launcherSettings.isCloseLauncherAfterGameStart(), Boolean.valueOf(closeLauncherAfterGameStart));
assertEquals(launcherSettings.getGameDirectory(), gameDirectory);
assertEquals(launcherSettings.getGameDataDirectory(), gameDataDirectory);
assertEquals(launcherSettings.isKeepDownloadedFiles(), Boolean.valueOf(saveDownloadedFiles));
assertEquals(launcherSettings.getUserJavaParameters(), userJavaParameters);
assertEquals(launcherSettings.getUserGameParameters(), userGameParameters);
assertEquals(launcherSettings.getLogLevel(), Level.valueOf(logLevel));
}
@BeforeEach
void setup() {
testPropertiesFile = tempDirectory.resolve(BaseLauncherSettings.LAUNCHER_SETTINGS_FILE_NAME);
testPropertiesFile = tempDirectory.resolve(LauncherSettings.LAUNCHER_SETTINGS_FILE_NAME);
baseLauncherSettings = Settings.getDefault();
launcherSettings = Settings.getDefault();
}
@Test
@ -103,8 +103,8 @@ class TestLauncherSettings {
testProperties.store(output, null);
}
baseLauncherSettings = Settings.load(testPropertiesFile);
baseLauncherSettings.init();
launcherSettings = Settings.load(testPropertiesFile);
launcherSettings.init();
assertPropertiesEqual();
}
@ -112,19 +112,19 @@ class TestLauncherSettings {
void testInitDefault() throws Exception {
//null properties file
baseLauncherSettings = Settings.getDefault();
baseLauncherSettings.init();
launcherSettings = Settings.getDefault();
launcherSettings.init();
assertEquals(baseLauncherSettings.getLocale(), Languages.DEFAULT_LOCALE);
assertEquals(baseLauncherSettings.getMaxHeapSize(), BaseLauncherSettings.MAX_HEAP_SIZE_DEFAULT);
assertEquals(baseLauncherSettings.getInitialHeapSize(), BaseLauncherSettings.INITIAL_HEAP_SIZE_DEFAULT);
assertEquals(baseLauncherSettings.isCloseLauncherAfterGameStart(), BaseLauncherSettings.CLOSE_LAUNCHER_AFTER_GAME_START_DEFAULT);
assertNull(baseLauncherSettings.getGameDirectory());
assertNull(baseLauncherSettings.getGameDataDirectory());
assertEquals(baseLauncherSettings.isKeepDownloadedFiles(), Boolean.valueOf(saveDownloadedFiles));
assertEquals(baseLauncherSettings.getUserJavaParameters(), BaseLauncherSettings.USER_JAVA_PARAMETERS_DEFAULT);
assertEquals(baseLauncherSettings.getUserGameParameters(), BaseLauncherSettings.USER_GAME_PARAMETERS_DEFAULT);
assertEquals(baseLauncherSettings.getLogLevel(), Level.INFO);
assertEquals(launcherSettings.getLocale(), Languages.DEFAULT_LOCALE);
assertEquals(launcherSettings.getMaxHeapSize(), LauncherSettings.MAX_HEAP_SIZE_DEFAULT);
assertEquals(launcherSettings.getInitialHeapSize(), LauncherSettings.INITIAL_HEAP_SIZE_DEFAULT);
assertEquals(launcherSettings.isCloseLauncherAfterGameStart(), LauncherSettings.CLOSE_LAUNCHER_AFTER_GAME_START_DEFAULT);
assertNull(launcherSettings.getGameDirectory());
assertNull(launcherSettings.getGameDataDirectory());
assertEquals(launcherSettings.isKeepDownloadedFiles(), Boolean.valueOf(saveDownloadedFiles));
assertEquals(launcherSettings.getUserJavaParameters(), LauncherSettings.USER_JAVA_PARAMETERS_DEFAULT);
assertEquals(launcherSettings.getUserGameParameters(), LauncherSettings.USER_GAME_PARAMETERS_DEFAULT);
assertEquals(launcherSettings.getLogLevel(), Level.INFO);
}
@Test
@ -140,16 +140,16 @@ class TestLauncherSettings {
logLevel = "INFO";
//set using setters
baseLauncherSettings.setLocale(Locale.forLanguageTag(locale));
baseLauncherSettings.setMaxHeapSize(JavaHeapSize.valueOf(maxHeapSize));
baseLauncherSettings.setInitialHeapSize(JavaHeapSize.valueOf(initialHeapSize));
baseLauncherSettings.setCloseLauncherAfterGameStart(Boolean.parseBoolean(closeLauncherAfterGameStart));
baseLauncherSettings.setGameDirectory(gameDirectory);
baseLauncherSettings.setGameDataDirectory(gameDataDirectory);
baseLauncherSettings.setKeepDownloadedFiles(Boolean.parseBoolean(saveDownloadedFiles));
baseLauncherSettings.setUserJavaParameters(userJavaParameters);
baseLauncherSettings.setUserGameParameters(userGameParameters);
baseLauncherSettings.setLogLevel(Level.valueOf(logLevel));
launcherSettings.setLocale(Locale.forLanguageTag(locale));
launcherSettings.setMaxHeapSize(JavaHeapSize.valueOf(maxHeapSize));
launcherSettings.setInitialHeapSize(JavaHeapSize.valueOf(initialHeapSize));
launcherSettings.setCloseLauncherAfterGameStart(Boolean.parseBoolean(closeLauncherAfterGameStart));
launcherSettings.setGameDirectory(gameDirectory);
launcherSettings.setGameDataDirectory(gameDataDirectory);
launcherSettings.setKeepDownloadedFiles(Boolean.parseBoolean(saveDownloadedFiles));
launcherSettings.setUserJavaParameters(userJavaParameters);
launcherSettings.setUserGameParameters(userGameParameters);
launcherSettings.setLogLevel(Level.valueOf(logLevel));
assertPropertiesEqual();
}
@ -161,7 +161,7 @@ class TestLauncherSettings {
// Second object so as not to rely on instance identity.
GameIdentifier expectedId = new GameIdentifier(displayVersion, Build.NIGHTLY, Profile.OMEGA);
baseLauncherSettings.setLastPlayedGameVersion(id);
assertEquals(Optional.of(expectedId), baseLauncherSettings.getLastPlayedGameVersion());
launcherSettings.setLastPlayedGameVersion(id);
assertEquals(Optional.of(expectedId), launcherSettings.getLastPlayedGameVersion());
}
}