Refactoring
This commit is contained in:
parent
e2d7733db2
commit
a55c088487
@ -1,5 +1,5 @@
|
||||
File;Group;Number in Group;Row;Column;X;Y;Width;Height;Notes;Tags;Number per file
|
||||
blupi000.blp;Yellow_Eggbert_Born;1;1;1;;0;28;20;;ok;1
|
||||
blupi000.blp;YELLOW_EGGBERT_BORN;1;1;1;;0;28;20;;ok;1
|
||||
blupi000.blp;Yellow_Eggbert_Born;2;1;2;;0;28;0;;ok;2
|
||||
blupi000.blp;Yellow_Eggbert_Born;3;1;3;;0;28;3;;ok;3
|
||||
blupi000.blp;Yellow_Eggbert_Born;4;1;4;;0;28;0;;ok;4
|
||||
|
|
@ -102,11 +102,11 @@ public enum FileNameCaseType {
|
||||
&& thereIsNoUppercaseCharacterExcludingTheFirstCharacter) {
|
||||
return CAPITALIZATION;
|
||||
} else {
|
||||
throw new OpenEggbertException("1Could not find FileNameCaseType from String: " + string);
|
||||
throw new OpenEggbertException("Could not find FileNameCaseType from String: " + string);
|
||||
}
|
||||
|
||||
}
|
||||
throw new OpenEggbertException("2Could not find FileNameCaseType from String: " + string);
|
||||
throw new OpenEggbertException("Could not find FileNameCaseType from String: " + string);
|
||||
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ public enum FileNameCaseType {
|
||||
new FileNameCaseTypeStringComparator());
|
||||
}
|
||||
|
||||
static class FileNameCaseTypeStringComparator implements Comparator<String> {
|
||||
private static class FileNameCaseTypeStringComparator implements Comparator<String> {
|
||||
|
||||
@Override
|
||||
public int compare(String o1, String o2) {
|
||||
|
@ -0,0 +1,50 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Open Eggbert: Free recreation of the computer game Speedy Eggbert.
|
||||
// Copyright (C) 2024 the original author or authors.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation, either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.openeggbert.compatibility;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public enum GameDirectoryType implements StrictMode{
|
||||
DATA(true),
|
||||
IMAGE(true),
|
||||
IMAGE08(true),
|
||||
IMAGE16(true),
|
||||
IMAGE24(false),
|
||||
IMAGE24X2(false),
|
||||
SOUND(true),
|
||||
TEXT(false),
|
||||
MOD(false),
|
||||
;
|
||||
@Getter
|
||||
private boolean enabledInCaseOfStrictMode;
|
||||
|
||||
GameDirectoryType(boolean enabledInCaseOfStrictMode) {
|
||||
this.enabledInCaseOfStrictMode = enabledInCaseOfStrictMode;
|
||||
}
|
||||
@Override
|
||||
public boolean isEnabledInCaseOfStrictMode() {
|
||||
return enabledInCaseOfStrictMode;
|
||||
}
|
||||
|
||||
}
|
@ -25,16 +25,28 @@ import lombok.Getter;
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public enum ImageFormat {
|
||||
BMP("blp", "bmp"),
|
||||
PNG("png"),
|
||||
JPEG("jpeg")
|
||||
public enum ImageFormat implements StrictMode{
|
||||
BLP("blp", true),
|
||||
BMP("bmp", false),
|
||||
PNG("png", false),
|
||||
JPEG("jpeg", false)
|
||||
;
|
||||
@Getter
|
||||
private String[] fileExtensions;
|
||||
private String fileExtension;
|
||||
@Getter
|
||||
private boolean enabledInCaseOfStrictMode;
|
||||
|
||||
ImageFormat(String... fileExtensionsIn) {
|
||||
this.fileExtensions = fileExtensionsIn;
|
||||
ImageFormat(String fileExtensionIn, boolean enabledInCaseOfStrictMode) {
|
||||
this.fileExtension = fileExtensionIn;
|
||||
this.enabledInCaseOfStrictMode = enabledInCaseOfStrictMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabledInCaseOfStrictMode() {
|
||||
return enabledInCaseOfStrictMode;
|
||||
}
|
||||
public ImageFormat getTargetFormat() {
|
||||
return this == BLP ? BMP : this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,11 +19,23 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.openeggbert.compatibility;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public enum ImageResolution {
|
||||
NORMAL, DOUBLE;
|
||||
public enum ImageResolution implements StrictMode{
|
||||
NORMAL(true), DOUBLE(false);
|
||||
@Getter
|
||||
private boolean enabledInCaseOfStrictMode;
|
||||
ImageResolution(boolean enabledInCaseOfStrictMode) {
|
||||
this.enabledInCaseOfStrictMode = enabledInCaseOfStrictMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabledInCaseOfStrictMode() {
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,16 +25,29 @@ import lombok.Getter;
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public enum MusicFormat {
|
||||
MIDI("blp", "mid"),
|
||||
WAV("wav"),
|
||||
MP3("mp3"),
|
||||
OGG("ogg"),
|
||||
public enum MusicFormat implements StrictMode {
|
||||
BLP("blp", true),
|
||||
MIDI("mid", false),
|
||||
WAV("wav", false),
|
||||
MP3("mp3", false),
|
||||
OGG("ogg", false),
|
||||
;
|
||||
@Getter
|
||||
private String[] fileExtensions;
|
||||
MusicFormat(String... fileExtensionsIn) {
|
||||
this.fileExtensions = fileExtensionsIn;
|
||||
private String fileExtension;
|
||||
|
||||
@Getter
|
||||
private boolean enabledInCaseOfStrictMode;
|
||||
MusicFormat(String fileExtension, boolean enabledInCaseOfStrictMode) {
|
||||
this.fileExtension = fileExtension;
|
||||
this.enabledInCaseOfStrictMode = enabledInCaseOfStrictMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabledInCaseOfStrictMode() {
|
||||
return enabledInCaseOfStrictMode;
|
||||
}
|
||||
|
||||
public MusicFormat getTargetFormat() {
|
||||
return this == BLP ? MIDI : this;
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import lombok.Getter;
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public enum FeatureLevel {
|
||||
public enum Release {
|
||||
SPEEDY_BLUPI_DEMO(ReleaseType.BLUPI, ReleaseVersion.DEMO, Publisher.EPSITEC_SA),
|
||||
SPEEDY_BLUPI_I(ReleaseType.BLUPI, ReleaseVersion.ONE, Publisher.EPSITEC_SA),
|
||||
SPEEDY_BLUPI_II(ReleaseType.BLUPI, ReleaseVersion.TWO, Publisher.EPSITEC_SA),
|
||||
@ -40,9 +40,21 @@ public enum FeatureLevel {
|
||||
@Getter
|
||||
private final ReleaseVersion releaseVersion;
|
||||
|
||||
private FeatureLevel(ReleaseType releaseType, ReleaseVersion releaseVersion, Publisher publisher) {
|
||||
private Release(ReleaseType releaseType, ReleaseVersion releaseVersion, Publisher publisher) {
|
||||
this.releaseType = releaseType;
|
||||
this.releaseVersion = releaseVersion;
|
||||
}
|
||||
|
||||
public String createLabel() {
|
||||
String[] array = this.name().split("_");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int i = 0;i < array.length; i++) {
|
||||
sb.append(FileNameCaseType.convertToString(array[i], FileNameCaseType.CAPITALIZATION));
|
||||
if(i < (array.length - 1)) {
|
||||
sb.append(" ");
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Open Eggbert: Free recreation of the computer game Speedy Eggbert.
|
||||
// Copyright (C) 2024 the original author or authors.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation, either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
package com.openeggbert.compatibility;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public enum ScreenResolution implements StrictMode {
|
||||
VGA(640,480,true),
|
||||
QUAD_VGA(1280, 960, false),
|
||||
CURRENT(0, 0, false);
|
||||
@Getter
|
||||
private boolean enabledInCaseOfStrictMode;
|
||||
@Getter
|
||||
private int width;
|
||||
@Getter
|
||||
private int height;
|
||||
ScreenResolution(int width, int height, boolean enabledInCaseOfStrictMode) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.enabledInCaseOfStrictMode = enabledInCaseOfStrictMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabledInCaseOfStrictMode() {
|
||||
return enabledInCaseOfStrictMode;
|
||||
}
|
||||
}
|
@ -25,15 +25,27 @@ import lombok.Getter;
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public enum SoundFormat {
|
||||
WAV("blp", "wav"),
|
||||
MP3("mp3"),
|
||||
OGG("ogg")
|
||||
public enum SoundFormat implements StrictMode {
|
||||
BLP("blp", true),
|
||||
WAV("wav", false),
|
||||
MP3("mp3", false),
|
||||
OGG("ogg", false),
|
||||
;
|
||||
@Getter
|
||||
private String[] fileExtensions;
|
||||
SoundFormat(String... fileExtensionsIn) {
|
||||
this.fileExtensions = fileExtensionsIn;
|
||||
private String fileExtension;
|
||||
SoundFormat(String fileExtensionIn, boolean enabledInCaseOfStrictMode) {
|
||||
this.fileExtension = fileExtensionIn;
|
||||
this.enabledInCaseOfStrictMode = enabledInCaseOfStrictMode;
|
||||
}
|
||||
|
||||
@Getter
|
||||
private boolean enabledInCaseOfStrictMode;
|
||||
|
||||
@Override
|
||||
public boolean isEnabledInCaseOfStrictMode() {
|
||||
return enabledInCaseOfStrictMode;
|
||||
}
|
||||
public SoundFormat getTargetFormat() {
|
||||
return this == BLP ? WAV : this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,9 +25,7 @@ package com.openeggbert.compatibility;
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public enum ResolutionMode {
|
||||
RESOLUTION_640_480,
|
||||
RESOLUTION_1280_960,
|
||||
RESOLUTION_SCALED,
|
||||
RESOLUTION_CURRENT;
|
||||
public interface StrictMode {
|
||||
boolean isEnabledInCaseOfStrictMode();
|
||||
|
||||
}
|
@ -21,7 +21,7 @@
|
||||
|
||||
package com.openeggbert.entity.common;
|
||||
|
||||
import com.openeggbert.compatibility.FeatureLevel;
|
||||
import com.openeggbert.compatibility.Release;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
@ -31,16 +31,16 @@ import lombok.Getter;
|
||||
public enum Cheat {
|
||||
|
||||
MEGABLUPI(Utils.ALL_FEATURE_LEVELS);
|
||||
//todo//todo
|
||||
//todo//todo//todo//todo
|
||||
|
||||
@Getter
|
||||
private final FeatureLevel[] compatibilityModes;
|
||||
private final Release[] compatibilityModes;
|
||||
@Getter
|
||||
private String note;
|
||||
Cheat (FeatureLevel[] compatibilityModes) {
|
||||
Cheat (Release[] compatibilityModes) {
|
||||
this(compatibilityModes, "");
|
||||
}
|
||||
Cheat (FeatureLevel[] compatibilityModes, String note) {
|
||||
Cheat (Release[] compatibilityModes, String note) {
|
||||
this.compatibilityModes = compatibilityModes;
|
||||
this.note = note;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.openeggbert.entity.common;
|
||||
|
||||
import com.openeggbert.compatibility.FeatureLevel;
|
||||
import com.openeggbert.compatibility.Release;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@ -31,17 +31,17 @@ import lombok.Getter;
|
||||
* @author robertvokac
|
||||
*/
|
||||
public enum ConfigDefKey {
|
||||
FULLSCREEN("FullScreen", new FeatureLevel[]{FeatureLevel.SPEEDY_BLUPI_DEMO}),
|
||||
STRICT_COMPATIBILITY("StrictCompatibility", new FeatureLevel[]{FeatureLevel.OPEN_EGGBERT_3});
|
||||
FULLSCREEN("FullScreen", new Release[]{Release.SPEEDY_BLUPI_DEMO}),
|
||||
STRICT_COMPATIBILITY("StrictCompatibility", new Release[]{Release.OPEN_EGGBERT_3});
|
||||
|
||||
@Getter
|
||||
private String key;
|
||||
@Getter
|
||||
private final List<FeatureLevel> featureLevels;
|
||||
ConfigDefKey(String keyIn, FeatureLevel[] featureLevelsIn) {
|
||||
private final List<Release> featureLevels;
|
||||
ConfigDefKey(String keyIn, Release[] featureLevelsIn) {
|
||||
this.key = keyIn;
|
||||
List<FeatureLevel> list = Arrays.asList(featureLevelsIn);
|
||||
Stream<FeatureLevel> stream = list.stream();
|
||||
List<Release> list = Arrays.asList(featureLevelsIn);
|
||||
Stream<Release> stream = list.stream();
|
||||
this.featureLevels = stream.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.openeggbert.entity.common;
|
||||
|
||||
import com.openeggbert.compatibility.FeatureLevel;
|
||||
import com.openeggbert.compatibility.Release;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@ -32,7 +32,7 @@ import lombok.Data;
|
||||
public class GameSpace {
|
||||
|
||||
private boolean embeddedAssets;
|
||||
private FeatureLevel featureLevel;
|
||||
private Release featureLevel;
|
||||
private String dataDirectory;
|
||||
private String image08Directory;
|
||||
private String image16Directory;
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
package com.openeggbert.entity.common;
|
||||
|
||||
import com.openeggbert.compatibility.FeatureLevel;
|
||||
import com.openeggbert.compatibility.Release;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
@ -41,7 +41,7 @@ public enum MusicType {
|
||||
MUSIC10(9);
|
||||
@Getter
|
||||
private int number;
|
||||
MusicType(int numberIn, FeatureLevel... featureLevels) {
|
||||
MusicType(int numberIn, Release... featureLevels) {
|
||||
this.number = numberIn;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
package com.openeggbert.entity.common;
|
||||
|
||||
import com.openeggbert.compatibility.FeatureLevel;
|
||||
import com.openeggbert.compatibility.Release;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
@ -108,7 +108,7 @@ public enum SoundType {
|
||||
;
|
||||
@Getter
|
||||
private int number;
|
||||
SoundType(int numberIn, FeatureLevel... featureLevels) {
|
||||
SoundType(int numberIn, Release... featureLevels) {
|
||||
this.number = numberIn;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
package com.openeggbert.entity.common;
|
||||
|
||||
import com.openeggbert.compatibility.FeatureLevel;
|
||||
import com.openeggbert.compatibility.Release;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -31,5 +31,5 @@ public class Utils {
|
||||
private Utils() {
|
||||
//Instantiate not needed.
|
||||
}
|
||||
public static final FeatureLevel[] ALL_FEATURE_LEVELS = FeatureLevel.values();
|
||||
public static final Release[] ALL_FEATURE_LEVELS = Release.values();
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ package com.openeggbert.mods;
|
||||
|
||||
import com.badlogic.gdx.utils.XmlReader;
|
||||
import com.badlogic.gdx.utils.XmlReader.Element;
|
||||
import com.openeggbert.compatibility.FeatureLevel;
|
||||
import com.openeggbert.compatibility.Release;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
@ -45,7 +45,7 @@ public class Mod {
|
||||
root.get("version"));
|
||||
modPackaging = ModPackaging.valueOf(root.get("packaging"));
|
||||
modType = ModType.valueOf(root.get("type"));
|
||||
featureLevel = FeatureLevel.valueOf(root.get("featureLevel"));
|
||||
featureLevel = Release.valueOf(root.get("featureLevel"));
|
||||
name = root.get("name");
|
||||
description = root.get("description");
|
||||
Element imports = root.getChildByName("imports");
|
||||
@ -76,7 +76,7 @@ public class Mod {
|
||||
private ModIdentification identification;
|
||||
private ModPackaging modPackaging;
|
||||
private ModType modType;
|
||||
private FeatureLevel featureLevel;
|
||||
private Release featureLevel;
|
||||
private String name;
|
||||
private String description;
|
||||
private List<ModIdentification> importedMods = new ArrayList<>();
|
||||
|
@ -55,7 +55,7 @@ public class OpenEggbertUtils {
|
||||
String fileNameWithoutExtension = getFileNameWithoutExtension(fileName);
|
||||
|
||||
for (ImageFormat imageFormat : ImageFormat.values()) {
|
||||
fillListWithPossibleFileNamesForGivenFileExtension(imageFormat.getFileExtensions(), fileNameWithoutExtension, list);
|
||||
fillListWithPossibleFileNamesForGivenFileExtension(imageFormat.getFileExtension(), fileNameWithoutExtension, list);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@ -64,7 +64,7 @@ public class OpenEggbertUtils {
|
||||
String fileNameWithoutExtension = getFileNameWithoutExtension(fileName);
|
||||
|
||||
for (MusicFormat musicFormat : MusicFormat.values()) {
|
||||
fillListWithPossibleFileNamesForGivenFileExtension(musicFormat.getFileExtensions(), fileNameWithoutExtension, list);
|
||||
fillListWithPossibleFileNamesForGivenFileExtension(musicFormat.getFileExtension(), fileNameWithoutExtension, list);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@ -73,7 +73,7 @@ public class OpenEggbertUtils {
|
||||
String fileNameWithoutExtension = getFileNameWithoutExtension(fileName);
|
||||
|
||||
for (SoundFormat soundFormat : SoundFormat.values()) {
|
||||
fillListWithPossibleFileNamesForGivenFileExtension(soundFormat.getFileExtensions(), fileNameWithoutExtension, list);
|
||||
fillListWithPossibleFileNamesForGivenFileExtension(soundFormat.getFileExtension(), fileNameWithoutExtension, list);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@ -90,13 +90,13 @@ public class OpenEggbertUtils {
|
||||
throw new OpenEggbertException("Unsupported GameFileType: " + gameFileType);
|
||||
}
|
||||
|
||||
private static void fillListWithPossibleFileNamesForGivenFileExtension(String[] fileExtensions, String fileNameWithoutExtension, List<String> list) {
|
||||
for (String fileExtension : fileExtensions) {
|
||||
String fileNameWithExtension = fileNameWithoutExtension + "." + fileExtension;
|
||||
for (FileNameCaseType fileNameCaseType : FileNameCaseType.values()) {
|
||||
list.add(FileNameCaseType.convertToString(fileNameWithExtension, fileNameCaseType));
|
||||
}
|
||||
private static void fillListWithPossibleFileNamesForGivenFileExtension(String fileExtension, String fileNameWithoutExtension, List<String> list) {
|
||||
|
||||
String fileNameWithExtension = fileNameWithoutExtension + "." + fileExtension;
|
||||
for (FileNameCaseType fileNameCaseType : FileNameCaseType.values()) {
|
||||
list.add(FileNameCaseType.convertToString(fileNameWithExtension, fileNameCaseType));
|
||||
}
|
||||
|
||||
}
|
||||
private static final String IMAGE = "IMAGE";
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.openeggbert.lwjgl3;
|
||||
|
||||
import com.openeggbert.compatibility.FeatureLevel;
|
||||
import com.openeggbert.compatibility.Release;
|
||||
import com.openeggbert.entity.common.GameSpace;
|
||||
import com.openeggbert.entity.common.OpenEggbertException;
|
||||
import java.io.File;
|
||||
@ -37,8 +37,8 @@ public class DesktopUtils {
|
||||
}
|
||||
|
||||
public static Optional<GameSpace> tryToLoadGameSpace() {
|
||||
String gameSpaceDirectoryFromEnvironmentVariable = System.getenv().getOrDefault("GAME_SPACE_DIRECTORY", "");
|
||||
String gameSpaceDirectoryFromSystemProperty = System.getProperty("GAME_SPACE_DIRECTORY", "");
|
||||
String gameSpaceDirectoryFromEnvironmentVariable = System.getenv().getOrDefault(GAME_SPACE_DIRECTORY, "");
|
||||
String gameSpaceDirectoryFromSystemProperty = System.getProperty(GAME_SPACE_DIRECTORY, "");
|
||||
|
||||
if (!gameSpaceDirectoryFromEnvironmentVariable.isBlank()) {
|
||||
return tryToLoadGameSpaceFromEnvironmentVariable(gameSpaceDirectoryFromEnvironmentVariable);
|
||||
@ -49,6 +49,7 @@ public class DesktopUtils {
|
||||
Optional<GameSpace> gameOptional = tryToLoadGameSpaceFromCurrentDirectory();
|
||||
return gameOptional;
|
||||
}
|
||||
private static final String GAME_SPACE_DIRECTORY = "GAME_SPACE_DIRECTORY";
|
||||
|
||||
private static Optional<GameSpace> tryToLoadGameSpaceFromEnvironmentVariable(String gameSpaceDirectoryFromEnvironmentVariable) {
|
||||
|
||||
@ -63,7 +64,7 @@ public class DesktopUtils {
|
||||
if (!gameSpaceDirectory.exists()) {
|
||||
throw new OpenEggbertException("Directory does not exist: " + gameSpaceDirectory.getAbsolutePath());
|
||||
}
|
||||
FeatureLevel featureLevel = null;
|
||||
Release featureLevel = null;
|
||||
try {
|
||||
featureLevel = findFeatureLevelFromDirectory(gameSpaceDirectory);
|
||||
} catch (Exception e) {
|
||||
@ -75,7 +76,7 @@ public class DesktopUtils {
|
||||
GameSpace gameSpace = new GameSpace();
|
||||
gameSpace.setCurrentDirectory(new File(".").getAbsolutePath());
|
||||
gameSpace.setFeatureLevel(featureLevel);
|
||||
if (featureLevel == FeatureLevel.SPEEDY_BLUPI_DEMO) {
|
||||
if (featureLevel == Release.SPEEDY_BLUPI_DEMO) {
|
||||
gameSpace.setDataDirectory(gameSpaceDirectory.getAbsolutePath() + "/" + "Data");
|
||||
gameSpace.setImage08Directory(gameSpaceDirectory.getAbsolutePath() + "/" + "Image");
|
||||
gameSpace.setSoundDirectory(gameSpaceDirectory.getAbsolutePath() + "/" + "Sound");
|
||||
@ -93,19 +94,19 @@ public class DesktopUtils {
|
||||
gameSpace.setImage08Directory(image08Directory.getAbsolutePath());
|
||||
gameSpace.setSoundDirectory(soundDirectory.getAbsolutePath());
|
||||
|
||||
if (featureLevel != FeatureLevel.SPEEDY_EGGBERT_DEMO) {
|
||||
if (featureLevel != Release.SPEEDY_EGGBERT_DEMO) {
|
||||
gameSpace.setImage16Directory(image16Directory.getAbsolutePath());
|
||||
}
|
||||
|
||||
if (featureLevel != FeatureLevel.OPEN_EGGBERT_3) {
|
||||
if (featureLevel != Release.OPEN_EGGBERT_3) {
|
||||
throwExceptionIfDirectoryDoesNotExist(image08Directory);
|
||||
if (featureLevel != FeatureLevel.SPEEDY_EGGBERT_DEMO) {
|
||||
if (featureLevel != Release.SPEEDY_EGGBERT_DEMO) {
|
||||
throwExceptionIfDirectoryDoesNotExist(image16Directory);
|
||||
}
|
||||
throwExceptionIfDirectoryDoesNotExist(soundDirectory);
|
||||
return Optional.of(gameSpace);
|
||||
}
|
||||
if (featureLevel == FeatureLevel.OPEN_EGGBERT_3) {
|
||||
if (featureLevel == Release.OPEN_EGGBERT_3) {
|
||||
|
||||
if (!image08Directory.exists()) {
|
||||
image08Directory = null;
|
||||
@ -135,7 +136,7 @@ public class DesktopUtils {
|
||||
|
||||
private static Optional<GameSpace> tryToLoadGameSpaceFromCurrentDirectory() {
|
||||
try {
|
||||
return tryToLoadGameSpaceFromDirectory(new File(DesktopUtils.getPathToDirectoryWhereJarIsRunning()));
|
||||
return tryToLoadGameSpaceFromDirectory(new File(DesktopUtils.getPathOfDirectoryWhereJarIsRunning()));
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
@ -154,14 +155,14 @@ public class DesktopUtils {
|
||||
throwExceptionIfDirectoryDoesNotExist(new File(directoryString));
|
||||
}
|
||||
|
||||
public static FeatureLevel findFeatureLevelFromDirectory(File dir) {
|
||||
public static Release findFeatureLevelFromDirectory(File dir) {
|
||||
final File image24Directory = new File(dir, "IMAGE24");
|
||||
final File image24x2Directory = new File(dir, "IMAGE24x2");
|
||||
final File image24x2Directory = new File(dir, "IMAGE24X2");
|
||||
if (image24Directory.exists() && image24x2Directory.exists()) {
|
||||
return FeatureLevel.OPEN_EGGBERT_3;
|
||||
return Release.OPEN_EGGBERT_3;
|
||||
}
|
||||
if (new File(dir, "Data").exists() && new File(dir, "Image").exists() && new File(dir, "Sound").exists()) {
|
||||
return FeatureLevel.SPEEDY_BLUPI_DEMO;
|
||||
return Release.SPEEDY_BLUPI_DEMO;
|
||||
}
|
||||
if (!new File(dir, "DATA").exists()) {
|
||||
throw new OpenEggbertException("Directory does not exist: " + new File(dir, "DATA").getAbsolutePath());
|
||||
@ -171,27 +172,27 @@ public class DesktopUtils {
|
||||
if (new File(image08Directory, "INSERT.BLP").exists()) {
|
||||
//blupi
|
||||
if (new File(image08Directory, "DECOR024.BLP").exists()) {
|
||||
return FeatureLevel.SPEEDY_BLUPI_II;
|
||||
return Release.SPEEDY_BLUPI_II;
|
||||
} else {
|
||||
return FeatureLevel.SPEEDY_BLUPI_I;
|
||||
return Release.SPEEDY_BLUPI_I;
|
||||
}
|
||||
} else {
|
||||
//eggbert
|
||||
final File image16Directory = new File(dir, "IMAGE16");
|
||||
if (!image16Directory.exists()) {
|
||||
return FeatureLevel.SPEEDY_EGGBERT_DEMO;
|
||||
return Release.SPEEDY_EGGBERT_DEMO;
|
||||
}
|
||||
if (new File(image08Directory, "DECOR024.BLP").exists() || new File(image08Directory, "decor024.blp").exists()) {
|
||||
return FeatureLevel.SPEEDY_EGGBERT_2;
|
||||
return Release.SPEEDY_EGGBERT_2;
|
||||
} else {
|
||||
return FeatureLevel.SPEEDY_EGGBERT_1;
|
||||
return Release.SPEEDY_EGGBERT_1;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new OpenEggbertException("Directory is not compatible with any supported version: " + dir.getAbsolutePath());
|
||||
}
|
||||
|
||||
public static String getPathToDirectoryWhereJarIsRunning() {
|
||||
public static String getPathOfDirectoryWhereJarIsRunning() {
|
||||
try {
|
||||
return new File(DesktopUtils.class.getProtectionDomain().getCodeSource().getLocation()
|
||||
.toURI()).getParentFile().getAbsolutePath();
|
||||
|
@ -37,7 +37,7 @@ public class Lwjgl3Launcher {
|
||||
//System.getProperties().put("GAME_SPACE_DIRECTORY", "/rv/data/desktop/code/code.nanoboot.org/nanoboot/open-eggbert/assets/open-eggbert-legacy-assets/speedy_blupi_I");
|
||||
|
||||
Optional<GameSpace> gameSpace = DesktopUtils.tryToLoadGameSpace();
|
||||
String currentDirectory = DesktopUtils.getPathToDirectoryWhereJarIsRunning();
|
||||
String currentDirectory = DesktopUtils.getPathOfDirectoryWhereJarIsRunning();
|
||||
final OpenEggbertGame openEggbertGame = gameSpace.isPresent() ? new OpenEggbertGame(gameSpace.get(), currentDirectory) : new OpenEggbertGame(currentDirectory);
|
||||
return new Lwjgl3Application(openEggbertGame, getDefaultConfiguration());
|
||||
}
|
||||
|
Reference in New Issue
Block a user