Fixed some issues

This commit is contained in:
Robert Vokac 2024-08-06 23:11:17 +02:00
parent 8ba4bb9233
commit 75d65dbaf7
No known key found for this signature in database
GPG Key ID: C459E1E4B4A986BB
5 changed files with 23 additions and 16 deletions

View File

@ -20,7 +20,8 @@
package com.openeggbert.entity.common; package com.openeggbert.entity.common;
import com.openeggbert.utils.OpenEggbertUtils; import com.openeggbert.utils.OpenEggbertUtils;
import java.util.Properties; import java.util.HashMap;
import java.util.Map;
import lombok.ToString; import lombok.ToString;
/** /**
@ -30,7 +31,7 @@ import lombok.ToString;
@ToString @ToString
public class ConfigDef { public class ConfigDef {
private Properties properties = new Properties(); private Map<String,String> map = new HashMap<>();
public ConfigDef(String textContentofConfigDefFile) { public ConfigDef(String textContentofConfigDefFile) {
OpenEggbertUtils OpenEggbertUtils
@ -42,7 +43,7 @@ public class ConfigDef {
String[] array = line.split("="); String[] array = line.split("=");
String key = array[0]; String key = array[0];
String value = array[1]; String value = array[1];
properties.put(key, value); map.put(key, value);
}); });
} }
private static final String HASH_CHARACTER = "#"; private static final String HASH_CHARACTER = "#";
@ -59,15 +60,15 @@ public class ConfigDef {
} }
private boolean getMandatoryBooleanProperty(ConfigDefKey configDefKey) { private boolean getMandatoryBooleanProperty(ConfigDefKey configDefKey) {
String key = configDefKey.getKey(); String key = configDefKey.getKey();
if (!properties.containsKey(key)) { if (!map.containsKey(key)) {
throw new OpenEggbertException("Fatal error: CONFIG.DEF is missing key: " + key); throw new OpenEggbertException("Fatal error: CONFIG.DEF is missing key: " + key);
} }
return convertStringToBoolean(properties.getProperty(configDefKey.getKey())); return convertStringToBoolean(map.get(configDefKey.getKey()));
} }
private boolean getOptionalBooleanProperty(ConfigDefKey configDefKey, boolean defaultValue) { private boolean getOptionalBooleanProperty(ConfigDefKey configDefKey, boolean defaultValue) {
String key = configDefKey.getKey(); String key = configDefKey.getKey();
if (!properties.containsKey(key)) { if (!map.containsKey(key)) {
return defaultValue; return defaultValue;
} }
return getMandatoryBooleanProperty(configDefKey); return getMandatoryBooleanProperty(configDefKey);

View File

@ -28,9 +28,9 @@ import lombok.Getter;
* @author robertvokac * @author robertvokac
*/ */
public enum OpenEggbertScreenType { public enum OpenEggbertScreenType {
INIT("INIT.BLP"), INIT("INIT.BMP"),
GAMER("GAMER.BLP"), GAMER("GAMER.BLP"),
DEMO("DECOR016.BLP"); DEMO("DECOR016.BMP");
@Getter @Getter
private String fileName; private String fileName;
OpenEggbertScreenType(String fileName) { OpenEggbertScreenType(String fileName) {

View File

@ -21,7 +21,6 @@ package com.openeggbert.main;
import com.badlogic.gdx.Game; import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Graphics;
import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Camera; import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.GL20;

View File

@ -20,6 +20,7 @@
package com.openeggbert.screens; package com.openeggbert.screens;
import com.badlogic.gdx.Application; import com.badlogic.gdx.Application;
import static com.badlogic.gdx.Application.LOG_INFO;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.ScreenAdapter; import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.files.FileHandle;
@ -46,6 +47,7 @@ public abstract class AbstractOpenEggbertScreen extends ScreenAdapter {
} }
private final String getBackgroundFileName() { private final String getBackgroundFileName() {
//return "INIT.BLP.BMP";
return getScreenType().isPresent() ? getScreenType().get().getFileName() : ""; return getScreenType().isPresent() ? getScreenType().get().getFileName() : "";
} }
@ -64,35 +66,40 @@ public abstract class AbstractOpenEggbertScreen extends ScreenAdapter {
if (getBackgroundFileName().isEmpty()) { if (getBackgroundFileName().isEmpty()) {
return; return;
} }
String fileName = getBackgroundFileName(); String fileName = getBackgroundFileName();
if (!game.existsImageTexture(fileName)) { if (!game.existsImageTexture(fileName)) {
String nameUpperCase = game.getGameSpace().getImage08Directory() + "/" + fileName; String nameUpperCase = game.getGameSpace().getImage08Directory() + "/" + fileName;
String nameLowerCase = game.getGameSpace().getImage08Directory() + "/" + fileName.toLowerCase(); String nameLowerCase = game.getGameSpace().getImage08Directory() + "/" + fileName.toLowerCase();
System.out.println("nameUpperCase=" + nameUpperCase); Gdx.app.setLogLevel(LOG_INFO);
System.out.println("nameLowerCase=" + nameLowerCase); Gdx.app.log("screen","nameUpperCase=" + nameUpperCase);
Gdx.app.log("screen","nameLowerCase=" + nameLowerCase);
FileHandle fileHandleUpperCase = null; FileHandle fileHandleUpperCase = null;
FileHandle fileHandleLowerCase = null; FileHandle fileHandleLowerCase = null;
if (game.getGameSpace().isEmbeddedAssets()) { if (game.getGameSpace().isEmbeddedAssets()) {
if (Gdx.app.getType() == Application.ApplicationType.Android || Gdx.app.getType() == Application.ApplicationType.WebGL) { if (Gdx.app.getType() == Application.ApplicationType.Android || Gdx.app.getType() == Application.ApplicationType.WebGL) {
System.out.println("loading from internal"); Gdx.app.log("screen","loading from internal");
fileHandleUpperCase = Gdx.files.internal(nameUpperCase); fileHandleUpperCase = Gdx.files.internal(nameUpperCase);
fileHandleLowerCase = Gdx.files.internal(nameLowerCase); fileHandleLowerCase = Gdx.files.internal(nameLowerCase);
} else { } else {
System.out.println("loading from classpath"); Gdx.app.log("screen","loading from classpath");
fileHandleUpperCase = Gdx.files.classpath(nameUpperCase); fileHandleUpperCase = Gdx.files.classpath(nameUpperCase);
fileHandleLowerCase = Gdx.files.classpath(nameLowerCase); fileHandleLowerCase = Gdx.files.classpath(nameLowerCase);
} }
} else { } else {
System.out.println("loading from absolute"); Gdx.app.log("screen","loading from absolute");
fileHandleUpperCase = Gdx.files.absolute(nameUpperCase); fileHandleUpperCase = Gdx.files.absolute(nameUpperCase);
fileHandleLowerCase = Gdx.files.absolute(nameLowerCase); fileHandleLowerCase = Gdx.files.absolute(nameLowerCase);
} }
Gdx.app.log("screen", "fileHandleUpperCase.exists()=" + fileHandleUpperCase.exists());
Gdx.app.log("screen", "fileHandleLowerCase.exists()=" + fileHandleLowerCase.exists());
if (fileHandleUpperCase.exists()) { if (fileHandleUpperCase.exists()) {
game.loadImageTexture(fileHandleUpperCase); game.loadImageTexture(fileHandleUpperCase);
} else { } else {

View File

@ -13,10 +13,10 @@ public class GwtLauncher extends GwtApplication {
GwtApplicationConfiguration cfg = new GwtApplicationConfiguration(true); GwtApplicationConfiguration cfg = new GwtApplicationConfiguration(true);
cfg.padVertical = 0; cfg.padVertical = 0;
cfg.padHorizontal = 0; cfg.padHorizontal = 0;
return cfg; //return cfg;
// If you want a fixed size application, comment out the above resizable section, // If you want a fixed size application, comment out the above resizable section,
// and uncomment below: // and uncomment below:
//return new GwtApplicationConfiguration(640, 480); return new GwtApplicationConfiguration(640, 480);
} }
@Override @Override