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
|
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;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;3;1;3;;0;28;3;;ok;3
|
||||||
blupi000.blp;Yellow_Eggbert_Born;4;1;4;;0;28;0;;ok;4
|
blupi000.blp;Yellow_Eggbert_Born;4;1;4;;0;28;0;;ok;4
|
||||||
|
|
@ -102,11 +102,11 @@ public enum FileNameCaseType {
|
|||||||
&& thereIsNoUppercaseCharacterExcludingTheFirstCharacter) {
|
&& thereIsNoUppercaseCharacterExcludingTheFirstCharacter) {
|
||||||
return CAPITALIZATION;
|
return CAPITALIZATION;
|
||||||
} else {
|
} 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());
|
new FileNameCaseTypeStringComparator());
|
||||||
}
|
}
|
||||||
|
|
||||||
static class FileNameCaseTypeStringComparator implements Comparator<String> {
|
private static class FileNameCaseTypeStringComparator implements Comparator<String> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(String o1, String o2) {
|
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
|
* @author robertvokac
|
||||||
*/
|
*/
|
||||||
public enum ImageFormat {
|
public enum ImageFormat implements StrictMode{
|
||||||
BMP("blp", "bmp"),
|
BLP("blp", true),
|
||||||
PNG("png"),
|
BMP("bmp", false),
|
||||||
JPEG("jpeg")
|
PNG("png", false),
|
||||||
|
JPEG("jpeg", false)
|
||||||
;
|
;
|
||||||
@Getter
|
@Getter
|
||||||
private String[] fileExtensions;
|
private String fileExtension;
|
||||||
|
@Getter
|
||||||
|
private boolean enabledInCaseOfStrictMode;
|
||||||
|
|
||||||
ImageFormat(String... fileExtensionsIn) {
|
ImageFormat(String fileExtensionIn, boolean enabledInCaseOfStrictMode) {
|
||||||
this.fileExtensions = fileExtensionsIn;
|
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;
|
package com.openeggbert.compatibility;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author robertvokac
|
* @author robertvokac
|
||||||
*/
|
*/
|
||||||
public enum ImageResolution {
|
public enum ImageResolution implements StrictMode{
|
||||||
NORMAL, DOUBLE;
|
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
|
* @author robertvokac
|
||||||
*/
|
*/
|
||||||
public enum MusicFormat {
|
public enum MusicFormat implements StrictMode {
|
||||||
MIDI("blp", "mid"),
|
BLP("blp", true),
|
||||||
WAV("wav"),
|
MIDI("mid", false),
|
||||||
MP3("mp3"),
|
WAV("wav", false),
|
||||||
OGG("ogg"),
|
MP3("mp3", false),
|
||||||
|
OGG("ogg", false),
|
||||||
;
|
;
|
||||||
@Getter
|
@Getter
|
||||||
private String[] fileExtensions;
|
private String fileExtension;
|
||||||
MusicFormat(String... fileExtensionsIn) {
|
|
||||||
this.fileExtensions = fileExtensionsIn;
|
@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
|
* @author robertvokac
|
||||||
*/
|
*/
|
||||||
public enum FeatureLevel {
|
public enum Release {
|
||||||
SPEEDY_BLUPI_DEMO(ReleaseType.BLUPI, ReleaseVersion.DEMO, Publisher.EPSITEC_SA),
|
SPEEDY_BLUPI_DEMO(ReleaseType.BLUPI, ReleaseVersion.DEMO, Publisher.EPSITEC_SA),
|
||||||
SPEEDY_BLUPI_I(ReleaseType.BLUPI, ReleaseVersion.ONE, Publisher.EPSITEC_SA),
|
SPEEDY_BLUPI_I(ReleaseType.BLUPI, ReleaseVersion.ONE, Publisher.EPSITEC_SA),
|
||||||
SPEEDY_BLUPI_II(ReleaseType.BLUPI, ReleaseVersion.TWO, Publisher.EPSITEC_SA),
|
SPEEDY_BLUPI_II(ReleaseType.BLUPI, ReleaseVersion.TWO, Publisher.EPSITEC_SA),
|
||||||
@ -40,9 +40,21 @@ public enum FeatureLevel {
|
|||||||
@Getter
|
@Getter
|
||||||
private final ReleaseVersion releaseVersion;
|
private final ReleaseVersion releaseVersion;
|
||||||
|
|
||||||
private FeatureLevel(ReleaseType releaseType, ReleaseVersion releaseVersion, Publisher publisher) {
|
private Release(ReleaseType releaseType, ReleaseVersion releaseVersion, Publisher publisher) {
|
||||||
this.releaseType = releaseType;
|
this.releaseType = releaseType;
|
||||||
this.releaseVersion = releaseVersion;
|
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
|
* @author robertvokac
|
||||||
*/
|
*/
|
||||||
public enum SoundFormat {
|
public enum SoundFormat implements StrictMode {
|
||||||
WAV("blp", "wav"),
|
BLP("blp", true),
|
||||||
MP3("mp3"),
|
WAV("wav", false),
|
||||||
OGG("ogg")
|
MP3("mp3", false),
|
||||||
|
OGG("ogg", false),
|
||||||
;
|
;
|
||||||
@Getter
|
@Getter
|
||||||
private String[] fileExtensions;
|
private String fileExtension;
|
||||||
SoundFormat(String... fileExtensionsIn) {
|
SoundFormat(String fileExtensionIn, boolean enabledInCaseOfStrictMode) {
|
||||||
this.fileExtensions = fileExtensionsIn;
|
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
|
* @author robertvokac
|
||||||
*/
|
*/
|
||||||
public enum ResolutionMode {
|
public interface StrictMode {
|
||||||
RESOLUTION_640_480,
|
boolean isEnabledInCaseOfStrictMode();
|
||||||
RESOLUTION_1280_960,
|
|
||||||
RESOLUTION_SCALED,
|
|
||||||
RESOLUTION_CURRENT;
|
|
||||||
}
|
}
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
package com.openeggbert.entity.common;
|
package com.openeggbert.entity.common;
|
||||||
|
|
||||||
import com.openeggbert.compatibility.FeatureLevel;
|
import com.openeggbert.compatibility.Release;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,16 +31,16 @@ import lombok.Getter;
|
|||||||
public enum Cheat {
|
public enum Cheat {
|
||||||
|
|
||||||
MEGABLUPI(Utils.ALL_FEATURE_LEVELS);
|
MEGABLUPI(Utils.ALL_FEATURE_LEVELS);
|
||||||
//todo//todo
|
//todo//todo//todo//todo
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final FeatureLevel[] compatibilityModes;
|
private final Release[] compatibilityModes;
|
||||||
@Getter
|
@Getter
|
||||||
private String note;
|
private String note;
|
||||||
Cheat (FeatureLevel[] compatibilityModes) {
|
Cheat (Release[] compatibilityModes) {
|
||||||
this(compatibilityModes, "");
|
this(compatibilityModes, "");
|
||||||
}
|
}
|
||||||
Cheat (FeatureLevel[] compatibilityModes, String note) {
|
Cheat (Release[] compatibilityModes, String note) {
|
||||||
this.compatibilityModes = compatibilityModes;
|
this.compatibilityModes = compatibilityModes;
|
||||||
this.note = note;
|
this.note = note;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.openeggbert.entity.common;
|
package com.openeggbert.entity.common;
|
||||||
|
|
||||||
import com.openeggbert.compatibility.FeatureLevel;
|
import com.openeggbert.compatibility.Release;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -31,17 +31,17 @@ import lombok.Getter;
|
|||||||
* @author robertvokac
|
* @author robertvokac
|
||||||
*/
|
*/
|
||||||
public enum ConfigDefKey {
|
public enum ConfigDefKey {
|
||||||
FULLSCREEN("FullScreen", new FeatureLevel[]{FeatureLevel.SPEEDY_BLUPI_DEMO}),
|
FULLSCREEN("FullScreen", new Release[]{Release.SPEEDY_BLUPI_DEMO}),
|
||||||
STRICT_COMPATIBILITY("StrictCompatibility", new FeatureLevel[]{FeatureLevel.OPEN_EGGBERT_3});
|
STRICT_COMPATIBILITY("StrictCompatibility", new Release[]{Release.OPEN_EGGBERT_3});
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private String key;
|
private String key;
|
||||||
@Getter
|
@Getter
|
||||||
private final List<FeatureLevel> featureLevels;
|
private final List<Release> featureLevels;
|
||||||
ConfigDefKey(String keyIn, FeatureLevel[] featureLevelsIn) {
|
ConfigDefKey(String keyIn, Release[] featureLevelsIn) {
|
||||||
this.key = keyIn;
|
this.key = keyIn;
|
||||||
List<FeatureLevel> list = Arrays.asList(featureLevelsIn);
|
List<Release> list = Arrays.asList(featureLevelsIn);
|
||||||
Stream<FeatureLevel> stream = list.stream();
|
Stream<Release> stream = list.stream();
|
||||||
this.featureLevels = stream.collect(Collectors.toList());
|
this.featureLevels = stream.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.openeggbert.entity.common;
|
package com.openeggbert.entity.common;
|
||||||
|
|
||||||
import com.openeggbert.compatibility.FeatureLevel;
|
import com.openeggbert.compatibility.Release;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ import lombok.Data;
|
|||||||
public class GameSpace {
|
public class GameSpace {
|
||||||
|
|
||||||
private boolean embeddedAssets;
|
private boolean embeddedAssets;
|
||||||
private FeatureLevel featureLevel;
|
private Release featureLevel;
|
||||||
private String dataDirectory;
|
private String dataDirectory;
|
||||||
private String image08Directory;
|
private String image08Directory;
|
||||||
private String image16Directory;
|
private String image16Directory;
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
package com.openeggbert.entity.common;
|
package com.openeggbert.entity.common;
|
||||||
|
|
||||||
import com.openeggbert.compatibility.FeatureLevel;
|
import com.openeggbert.compatibility.Release;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,7 +41,7 @@ public enum MusicType {
|
|||||||
MUSIC10(9);
|
MUSIC10(9);
|
||||||
@Getter
|
@Getter
|
||||||
private int number;
|
private int number;
|
||||||
MusicType(int numberIn, FeatureLevel... featureLevels) {
|
MusicType(int numberIn, Release... featureLevels) {
|
||||||
this.number = numberIn;
|
this.number = numberIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
package com.openeggbert.entity.common;
|
package com.openeggbert.entity.common;
|
||||||
|
|
||||||
import com.openeggbert.compatibility.FeatureLevel;
|
import com.openeggbert.compatibility.Release;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,7 +108,7 @@ public enum SoundType {
|
|||||||
;
|
;
|
||||||
@Getter
|
@Getter
|
||||||
private int number;
|
private int number;
|
||||||
SoundType(int numberIn, FeatureLevel... featureLevels) {
|
SoundType(int numberIn, Release... featureLevels) {
|
||||||
this.number = numberIn;
|
this.number = numberIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
package com.openeggbert.entity.common;
|
package com.openeggbert.entity.common;
|
||||||
|
|
||||||
import com.openeggbert.compatibility.FeatureLevel;
|
import com.openeggbert.compatibility.Release;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -31,5 +31,5 @@ public class Utils {
|
|||||||
private Utils() {
|
private Utils() {
|
||||||
//Instantiate not needed.
|
//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;
|
||||||
import com.badlogic.gdx.utils.XmlReader.Element;
|
import com.badlogic.gdx.utils.XmlReader.Element;
|
||||||
import com.openeggbert.compatibility.FeatureLevel;
|
import com.openeggbert.compatibility.Release;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -45,7 +45,7 @@ public class Mod {
|
|||||||
root.get("version"));
|
root.get("version"));
|
||||||
modPackaging = ModPackaging.valueOf(root.get("packaging"));
|
modPackaging = ModPackaging.valueOf(root.get("packaging"));
|
||||||
modType = ModType.valueOf(root.get("type"));
|
modType = ModType.valueOf(root.get("type"));
|
||||||
featureLevel = FeatureLevel.valueOf(root.get("featureLevel"));
|
featureLevel = Release.valueOf(root.get("featureLevel"));
|
||||||
name = root.get("name");
|
name = root.get("name");
|
||||||
description = root.get("description");
|
description = root.get("description");
|
||||||
Element imports = root.getChildByName("imports");
|
Element imports = root.getChildByName("imports");
|
||||||
@ -76,7 +76,7 @@ public class Mod {
|
|||||||
private ModIdentification identification;
|
private ModIdentification identification;
|
||||||
private ModPackaging modPackaging;
|
private ModPackaging modPackaging;
|
||||||
private ModType modType;
|
private ModType modType;
|
||||||
private FeatureLevel featureLevel;
|
private Release featureLevel;
|
||||||
private String name;
|
private String name;
|
||||||
private String description;
|
private String description;
|
||||||
private List<ModIdentification> importedMods = new ArrayList<>();
|
private List<ModIdentification> importedMods = new ArrayList<>();
|
||||||
|
@ -55,7 +55,7 @@ public class OpenEggbertUtils {
|
|||||||
String fileNameWithoutExtension = getFileNameWithoutExtension(fileName);
|
String fileNameWithoutExtension = getFileNameWithoutExtension(fileName);
|
||||||
|
|
||||||
for (ImageFormat imageFormat : ImageFormat.values()) {
|
for (ImageFormat imageFormat : ImageFormat.values()) {
|
||||||
fillListWithPossibleFileNamesForGivenFileExtension(imageFormat.getFileExtensions(), fileNameWithoutExtension, list);
|
fillListWithPossibleFileNamesForGivenFileExtension(imageFormat.getFileExtension(), fileNameWithoutExtension, list);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ public class OpenEggbertUtils {
|
|||||||
String fileNameWithoutExtension = getFileNameWithoutExtension(fileName);
|
String fileNameWithoutExtension = getFileNameWithoutExtension(fileName);
|
||||||
|
|
||||||
for (MusicFormat musicFormat : MusicFormat.values()) {
|
for (MusicFormat musicFormat : MusicFormat.values()) {
|
||||||
fillListWithPossibleFileNamesForGivenFileExtension(musicFormat.getFileExtensions(), fileNameWithoutExtension, list);
|
fillListWithPossibleFileNamesForGivenFileExtension(musicFormat.getFileExtension(), fileNameWithoutExtension, list);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ public class OpenEggbertUtils {
|
|||||||
String fileNameWithoutExtension = getFileNameWithoutExtension(fileName);
|
String fileNameWithoutExtension = getFileNameWithoutExtension(fileName);
|
||||||
|
|
||||||
for (SoundFormat soundFormat : SoundFormat.values()) {
|
for (SoundFormat soundFormat : SoundFormat.values()) {
|
||||||
fillListWithPossibleFileNamesForGivenFileExtension(soundFormat.getFileExtensions(), fileNameWithoutExtension, list);
|
fillListWithPossibleFileNamesForGivenFileExtension(soundFormat.getFileExtension(), fileNameWithoutExtension, list);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@ -90,13 +90,13 @@ public class OpenEggbertUtils {
|
|||||||
throw new OpenEggbertException("Unsupported GameFileType: " + gameFileType);
|
throw new OpenEggbertException("Unsupported GameFileType: " + gameFileType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void fillListWithPossibleFileNamesForGivenFileExtension(String[] fileExtensions, String fileNameWithoutExtension, List<String> list) {
|
private static void fillListWithPossibleFileNamesForGivenFileExtension(String fileExtension, String fileNameWithoutExtension, List<String> list) {
|
||||||
for (String fileExtension : fileExtensions) {
|
|
||||||
String fileNameWithExtension = fileNameWithoutExtension + "." + fileExtension;
|
String fileNameWithExtension = fileNameWithoutExtension + "." + fileExtension;
|
||||||
for (FileNameCaseType fileNameCaseType : FileNameCaseType.values()) {
|
for (FileNameCaseType fileNameCaseType : FileNameCaseType.values()) {
|
||||||
list.add(FileNameCaseType.convertToString(fileNameWithExtension, fileNameCaseType));
|
list.add(FileNameCaseType.convertToString(fileNameWithExtension, fileNameCaseType));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private static final String IMAGE = "IMAGE";
|
private static final String IMAGE = "IMAGE";
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.openeggbert.lwjgl3;
|
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.GameSpace;
|
||||||
import com.openeggbert.entity.common.OpenEggbertException;
|
import com.openeggbert.entity.common.OpenEggbertException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -37,8 +37,8 @@ public class DesktopUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Optional<GameSpace> tryToLoadGameSpace() {
|
public static Optional<GameSpace> tryToLoadGameSpace() {
|
||||||
String gameSpaceDirectoryFromEnvironmentVariable = System.getenv().getOrDefault("GAME_SPACE_DIRECTORY", "");
|
String gameSpaceDirectoryFromEnvironmentVariable = System.getenv().getOrDefault(GAME_SPACE_DIRECTORY, "");
|
||||||
String gameSpaceDirectoryFromSystemProperty = System.getProperty("GAME_SPACE_DIRECTORY", "");
|
String gameSpaceDirectoryFromSystemProperty = System.getProperty(GAME_SPACE_DIRECTORY, "");
|
||||||
|
|
||||||
if (!gameSpaceDirectoryFromEnvironmentVariable.isBlank()) {
|
if (!gameSpaceDirectoryFromEnvironmentVariable.isBlank()) {
|
||||||
return tryToLoadGameSpaceFromEnvironmentVariable(gameSpaceDirectoryFromEnvironmentVariable);
|
return tryToLoadGameSpaceFromEnvironmentVariable(gameSpaceDirectoryFromEnvironmentVariable);
|
||||||
@ -49,6 +49,7 @@ public class DesktopUtils {
|
|||||||
Optional<GameSpace> gameOptional = tryToLoadGameSpaceFromCurrentDirectory();
|
Optional<GameSpace> gameOptional = tryToLoadGameSpaceFromCurrentDirectory();
|
||||||
return gameOptional;
|
return gameOptional;
|
||||||
}
|
}
|
||||||
|
private static final String GAME_SPACE_DIRECTORY = "GAME_SPACE_DIRECTORY";
|
||||||
|
|
||||||
private static Optional<GameSpace> tryToLoadGameSpaceFromEnvironmentVariable(String gameSpaceDirectoryFromEnvironmentVariable) {
|
private static Optional<GameSpace> tryToLoadGameSpaceFromEnvironmentVariable(String gameSpaceDirectoryFromEnvironmentVariable) {
|
||||||
|
|
||||||
@ -63,7 +64,7 @@ public class DesktopUtils {
|
|||||||
if (!gameSpaceDirectory.exists()) {
|
if (!gameSpaceDirectory.exists()) {
|
||||||
throw new OpenEggbertException("Directory does not exist: " + gameSpaceDirectory.getAbsolutePath());
|
throw new OpenEggbertException("Directory does not exist: " + gameSpaceDirectory.getAbsolutePath());
|
||||||
}
|
}
|
||||||
FeatureLevel featureLevel = null;
|
Release featureLevel = null;
|
||||||
try {
|
try {
|
||||||
featureLevel = findFeatureLevelFromDirectory(gameSpaceDirectory);
|
featureLevel = findFeatureLevelFromDirectory(gameSpaceDirectory);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -75,7 +76,7 @@ public class DesktopUtils {
|
|||||||
GameSpace gameSpace = new GameSpace();
|
GameSpace gameSpace = new GameSpace();
|
||||||
gameSpace.setCurrentDirectory(new File(".").getAbsolutePath());
|
gameSpace.setCurrentDirectory(new File(".").getAbsolutePath());
|
||||||
gameSpace.setFeatureLevel(featureLevel);
|
gameSpace.setFeatureLevel(featureLevel);
|
||||||
if (featureLevel == FeatureLevel.SPEEDY_BLUPI_DEMO) {
|
if (featureLevel == Release.SPEEDY_BLUPI_DEMO) {
|
||||||
gameSpace.setDataDirectory(gameSpaceDirectory.getAbsolutePath() + "/" + "Data");
|
gameSpace.setDataDirectory(gameSpaceDirectory.getAbsolutePath() + "/" + "Data");
|
||||||
gameSpace.setImage08Directory(gameSpaceDirectory.getAbsolutePath() + "/" + "Image");
|
gameSpace.setImage08Directory(gameSpaceDirectory.getAbsolutePath() + "/" + "Image");
|
||||||
gameSpace.setSoundDirectory(gameSpaceDirectory.getAbsolutePath() + "/" + "Sound");
|
gameSpace.setSoundDirectory(gameSpaceDirectory.getAbsolutePath() + "/" + "Sound");
|
||||||
@ -93,19 +94,19 @@ public class DesktopUtils {
|
|||||||
gameSpace.setImage08Directory(image08Directory.getAbsolutePath());
|
gameSpace.setImage08Directory(image08Directory.getAbsolutePath());
|
||||||
gameSpace.setSoundDirectory(soundDirectory.getAbsolutePath());
|
gameSpace.setSoundDirectory(soundDirectory.getAbsolutePath());
|
||||||
|
|
||||||
if (featureLevel != FeatureLevel.SPEEDY_EGGBERT_DEMO) {
|
if (featureLevel != Release.SPEEDY_EGGBERT_DEMO) {
|
||||||
gameSpace.setImage16Directory(image16Directory.getAbsolutePath());
|
gameSpace.setImage16Directory(image16Directory.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (featureLevel != FeatureLevel.OPEN_EGGBERT_3) {
|
if (featureLevel != Release.OPEN_EGGBERT_3) {
|
||||||
throwExceptionIfDirectoryDoesNotExist(image08Directory);
|
throwExceptionIfDirectoryDoesNotExist(image08Directory);
|
||||||
if (featureLevel != FeatureLevel.SPEEDY_EGGBERT_DEMO) {
|
if (featureLevel != Release.SPEEDY_EGGBERT_DEMO) {
|
||||||
throwExceptionIfDirectoryDoesNotExist(image16Directory);
|
throwExceptionIfDirectoryDoesNotExist(image16Directory);
|
||||||
}
|
}
|
||||||
throwExceptionIfDirectoryDoesNotExist(soundDirectory);
|
throwExceptionIfDirectoryDoesNotExist(soundDirectory);
|
||||||
return Optional.of(gameSpace);
|
return Optional.of(gameSpace);
|
||||||
}
|
}
|
||||||
if (featureLevel == FeatureLevel.OPEN_EGGBERT_3) {
|
if (featureLevel == Release.OPEN_EGGBERT_3) {
|
||||||
|
|
||||||
if (!image08Directory.exists()) {
|
if (!image08Directory.exists()) {
|
||||||
image08Directory = null;
|
image08Directory = null;
|
||||||
@ -135,7 +136,7 @@ public class DesktopUtils {
|
|||||||
|
|
||||||
private static Optional<GameSpace> tryToLoadGameSpaceFromCurrentDirectory() {
|
private static Optional<GameSpace> tryToLoadGameSpaceFromCurrentDirectory() {
|
||||||
try {
|
try {
|
||||||
return tryToLoadGameSpaceFromDirectory(new File(DesktopUtils.getPathToDirectoryWhereJarIsRunning()));
|
return tryToLoadGameSpaceFromDirectory(new File(DesktopUtils.getPathOfDirectoryWhereJarIsRunning()));
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println(e.getMessage());
|
System.err.println(e.getMessage());
|
||||||
@ -154,14 +155,14 @@ public class DesktopUtils {
|
|||||||
throwExceptionIfDirectoryDoesNotExist(new File(directoryString));
|
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 image24Directory = new File(dir, "IMAGE24");
|
||||||
final File image24x2Directory = new File(dir, "IMAGE24x2");
|
final File image24x2Directory = new File(dir, "IMAGE24X2");
|
||||||
if (image24Directory.exists() && image24x2Directory.exists()) {
|
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()) {
|
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()) {
|
if (!new File(dir, "DATA").exists()) {
|
||||||
throw new OpenEggbertException("Directory does not exist: " + new File(dir, "DATA").getAbsolutePath());
|
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()) {
|
if (new File(image08Directory, "INSERT.BLP").exists()) {
|
||||||
//blupi
|
//blupi
|
||||||
if (new File(image08Directory, "DECOR024.BLP").exists()) {
|
if (new File(image08Directory, "DECOR024.BLP").exists()) {
|
||||||
return FeatureLevel.SPEEDY_BLUPI_II;
|
return Release.SPEEDY_BLUPI_II;
|
||||||
} else {
|
} else {
|
||||||
return FeatureLevel.SPEEDY_BLUPI_I;
|
return Release.SPEEDY_BLUPI_I;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//eggbert
|
//eggbert
|
||||||
final File image16Directory = new File(dir, "IMAGE16");
|
final File image16Directory = new File(dir, "IMAGE16");
|
||||||
if (!image16Directory.exists()) {
|
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()) {
|
if (new File(image08Directory, "DECOR024.BLP").exists() || new File(image08Directory, "decor024.blp").exists()) {
|
||||||
return FeatureLevel.SPEEDY_EGGBERT_2;
|
return Release.SPEEDY_EGGBERT_2;
|
||||||
} else {
|
} else {
|
||||||
return FeatureLevel.SPEEDY_EGGBERT_1;
|
return Release.SPEEDY_EGGBERT_1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new OpenEggbertException("Directory is not compatible with any supported version: " + dir.getAbsolutePath());
|
throw new OpenEggbertException("Directory is not compatible with any supported version: " + dir.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getPathToDirectoryWhereJarIsRunning() {
|
public static String getPathOfDirectoryWhereJarIsRunning() {
|
||||||
try {
|
try {
|
||||||
return new File(DesktopUtils.class.getProtectionDomain().getCodeSource().getLocation()
|
return new File(DesktopUtils.class.getProtectionDomain().getCodeSource().getLocation()
|
||||||
.toURI()).getParentFile().getAbsolutePath();
|
.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");
|
//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();
|
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);
|
final OpenEggbertGame openEggbertGame = gameSpace.isPresent() ? new OpenEggbertGame(gameSpace.get(), currentDirectory) : new OpenEggbertGame(currentDirectory);
|
||||||
return new Lwjgl3Application(openEggbertGame, getDefaultConfiguration());
|
return new Lwjgl3Application(openEggbertGame, getDefaultConfiguration());
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user