diff --git a/assets/BASIC/BASIC.PNG b/assets/BASIC/BASIC.PNG new file mode 100644 index 0000000..eae011f Binary files /dev/null and b/assets/BASIC/BASIC.PNG differ diff --git a/assets/BASIC/OPEN_EGGBERT.png b/assets/BASIC/OPEN_EGGBERT.png new file mode 100644 index 0000000..e57047a Binary files /dev/null and b/assets/BASIC/OPEN_EGGBERT.png differ diff --git a/core/src/main/java/com/openeggbert/core/configuration/OpenEggbertDisplayMode.java b/core/src/main/java/com/openeggbert/core/configuration/OpenEggbertDisplayMode.java index 7b1964d..add6973 100644 --- a/core/src/main/java/com/openeggbert/core/configuration/OpenEggbertDisplayMode.java +++ b/core/src/main/java/com/openeggbert/core/configuration/OpenEggbertDisplayMode.java @@ -21,7 +21,7 @@ package com.openeggbert.core.configuration; import com.pixelgamelibrary.api.Pixel; import com.openeggbert.core.main.OpenEggbertException; -import com.pixelgamelibrary.api.DisplayMode; +import com.pixelgamelibrary.api.ViewMode; /** * @@ -34,19 +34,21 @@ public enum OpenEggbertDisplayMode { if (configDef == null) { return OpenEggbertDisplayMode.WINDOW; } - return setDisplayMode(fromConfigDef(configDef)); + final OpenEggbertDisplayMode fromConfigDef = fromConfigDef(configDef); + setDisplayMode(fromConfigDef); + return fromConfigDef; } public static OpenEggbertDisplayMode fromConfigDef(ConfigDef configDef) { return configDef.isFullscreen() ? FULLSCREEN : WINDOW; } - public static OpenEggbertDisplayMode setDisplayModeToFullscreen() { - return setDisplayMode(FULLSCREEN); + public static void setDisplayModeToFullscreen() { + setDisplayMode(FULLSCREEN); } - public static OpenEggbertDisplayMode setDisplayModeToWindow() { - return setDisplayMode(WINDOW); + public static void setDisplayModeToWindow() { + setDisplayMode(WINDOW); } public static OpenEggbertDisplayMode find(boolean fullscreen, boolean window) { @@ -63,10 +65,8 @@ public enum OpenEggbertDisplayMode { } } - public static OpenEggbertDisplayMode setDisplayMode(OpenEggbertDisplayMode displayMode) { - DisplayMode result = Pixel.graphics().setDisplayMode(displayMode == FULLSCREEN, displayMode == WINDOW); - - return result == null ? null : OpenEggbertDisplayMode.valueOf(result.name()); + public static void setDisplayMode(OpenEggbertDisplayMode displayMode) { + Pixel.graphics().getMonitor().setViewMode(displayMode == FULLSCREEN ? ViewMode.FULLSCREEN : ViewMode.WINDOW); } public OpenEggbertDisplayMode flip() { diff --git a/core/src/main/java/com/openeggbert/core/configuration/ScreenResolution.java b/core/src/main/java/com/openeggbert/core/configuration/VirtualScreenResolution.java similarity index 90% rename from core/src/main/java/com/openeggbert/core/configuration/ScreenResolution.java rename to core/src/main/java/com/openeggbert/core/configuration/VirtualScreenResolution.java index 4da1497..494ba4c 100644 --- a/core/src/main/java/com/openeggbert/core/configuration/ScreenResolution.java +++ b/core/src/main/java/com/openeggbert/core/configuration/VirtualScreenResolution.java @@ -27,7 +27,7 @@ import lombok.Getter; * * @author robertvokac */ -public enum ScreenResolution implements IsThisFeatureEnabledForStrictMode { +public enum VirtualScreenResolution implements IsThisFeatureEnabledForStrictMode { VGA(640,480,true), QUAD_VGA(1280, 960, false), CURRENT(0, 0, false); @@ -37,7 +37,7 @@ public enum ScreenResolution implements IsThisFeatureEnabledForStrictMode { private int width; @Getter private int height; - ScreenResolution(int width, int height, boolean enabledInCaseOfStrictMode) { + VirtualScreenResolution(int width, int height, boolean enabledInCaseOfStrictMode) { this.width = width; this.height = height; this.enabledInCaseOfStrictMode = enabledInCaseOfStrictMode; diff --git a/core/src/main/java/com/openeggbert/core/main/OpenEggbertGame.java b/core/src/main/java/com/openeggbert/core/main/OpenEggbertGame.java index 2b05295..d6ed7f3 100644 --- a/core/src/main/java/com/openeggbert/core/main/OpenEggbertGame.java +++ b/core/src/main/java/com/openeggbert/core/main/OpenEggbertGame.java @@ -136,6 +136,9 @@ public class OpenEggbertGame extends GameAdapter { public void loadImageTexture(com.badlogic.gdx.files.FileHandle fileHandle) { Texture texture = new Texture(fileHandle); + if(!fileHandle.exists()) { + throw new OpenEggbertException("File does not exist: " + fileHandle.path()); + } imageTextures.put(OpenEggbertUtils.getFileNameWithoutExtension(fileHandle.name().toUpperCase()), texture); } diff --git a/core/src/main/java/com/openeggbert/core/screen/AbstractBasicScreen.java b/core/src/main/java/com/openeggbert/core/screen/AbstractBasicScreen.java new file mode 100644 index 0000000..c5b5252 --- /dev/null +++ b/core/src/main/java/com/openeggbert/core/screen/AbstractBasicScreen.java @@ -0,0 +1,34 @@ +/////////////////////////////////////////////////////////////////////////////////////////////// +// 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 +// or write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +/////////////////////////////////////////////////////////////////////////////////////////////// +package com.openeggbert.core.screen; + +import com.openeggbert.core.main.OpenEggbertGame; + +/** + * + * @author robertvokac + */ +public abstract class AbstractBasicScreen extends OpenEggbertScreen { + + public AbstractBasicScreen(OpenEggbertGame openEggbertGame) { + super(openEggbertGame); + } + +} diff --git a/core/src/main/java/com/openeggbert/core/screen/DemoScreen.java b/core/src/main/java/com/openeggbert/core/screen/DemoScreen.java index 3e841e4..cbe80cb 100644 --- a/core/src/main/java/com/openeggbert/core/screen/DemoScreen.java +++ b/core/src/main/java/com/openeggbert/core/screen/DemoScreen.java @@ -38,6 +38,7 @@ public class DemoScreen extends OpenEggbertScreen { } + @Override protected final Optional getScreenType() { return Optional.of(ScreenType.DEMO); } diff --git a/core/src/main/java/com/openeggbert/core/screen/GameSpaceListScreen.java b/core/src/main/java/com/openeggbert/core/screen/GameSpaceListScreen.java index 5838766..ce2b2f2 100644 --- a/core/src/main/java/com/openeggbert/core/screen/GameSpaceListScreen.java +++ b/core/src/main/java/com/openeggbert/core/screen/GameSpaceListScreen.java @@ -27,7 +27,6 @@ import com.badlogic.gdx.Preferences; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; -import com.badlogic.gdx.utils.ScreenUtils; import com.openeggbert.core.gamespace.GameSpace; import com.openeggbert.core.main.OpenEggbertGame; import com.openeggbert.core.mod.Mod; @@ -35,6 +34,7 @@ import com.openeggbert.core.mod.ModType; import com.pixelgamelibrary.api.Pixel; import com.pixelgamelibrary.api.storage.Storage; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; @@ -44,7 +44,7 @@ import lombok.ToString; * * @author robertvokac */ -public class GameSpaceListScreen extends OpenEggbertScreen { +public class GameSpaceListScreen extends AbstractBasicScreen { private int pageNumber = 1; private final int pageSize = 5; @@ -65,7 +65,6 @@ public class GameSpaceListScreen extends OpenEggbertScreen { public GameSpaceListScreen(OpenEggbertGame openEggbertGame) { super(openEggbertGame); this.fullEmbeddedMods = openEggbertGame.getEmbeddedMods().stream().filter(m -> m.getModType() == ModType.FULL).collect(Collectors.toList()); - if (Gdx.app.getType() == Application.ApplicationType.Android) { game.setHeightInPixels(Gdx.app.getGraphics().getHeight()); @@ -79,16 +78,18 @@ public class GameSpaceListScreen extends OpenEggbertScreen { storage.createDirectory("gameSpaces"); System.out.println(storage.debug()); //storage.file("modes").child("text.txt").writeString("textabc"); - + storage.flush(); } + @Override + protected final Optional getScreenType() { + return Optional.of(ScreenType.GAME_SPACE_LIST); + } + @Override public void show() { - System.out.println("Calling : GameSpaceListScreen : show"); - try{ -throw new RuntimeException(); - } catch (Exception e) {e.printStackTrace();} + System.out.println("Calling : GameSpaceListScreen : show"); Gdx.input.setInputProcessor(new InputAdapter() { public boolean touchUp(int screenX, int screenY, int pointer, int button) { @@ -141,14 +142,14 @@ throw new RuntimeException(); System.out.println(buttons[i].toString()); } y = Gdx.graphics.getHeight() - y; - + for (int i = 0; i < 5; i++) { if (buttons[i] == null) { break; } if (x > buttons[i].x && x < (buttons[i].x + buttons[i].width) && y > buttons[i].y && y < (buttons[i].y + buttons[i].height)) { - + activateButton(i); } @@ -196,10 +197,11 @@ throw new RuntimeException(); activateButton(0); } - ScreenUtils.clear(1f, 1f, 0.6f, 0.5f); + //ScreenUtils.clear(1f, 1f, 0.6f, 0.5f); int buttonHeight = (int) (game.getHeightInPixels() * 0.1f); batch.begin(); + drawBackgroundIfAvailable(); BitmapFont font; font = game.getFont(); diff --git a/core/src/main/java/com/openeggbert/core/screen/InitScreen.java b/core/src/main/java/com/openeggbert/core/screen/InitScreen.java index e9524dd..7fa9120 100644 --- a/core/src/main/java/com/openeggbert/core/screen/InitScreen.java +++ b/core/src/main/java/com/openeggbert/core/screen/InitScreen.java @@ -132,10 +132,9 @@ public class InitScreen extends OpenEggbertScreen { if (game.getConfigDef() != null && Gdx.app.getType() == Application.ApplicationType.Desktop && !game.getConfigDef().isStrictCompatibility() && keyCode == Input.Keys.F) { OpenEggbertDisplayMode currentDisplayMode = game.getOpenEggbertDisplayMode(); OpenEggbertDisplayMode newDisplayMode = currentDisplayMode.flip(); - boolean success = OpenEggbertDisplayMode.setDisplayMode(newDisplayMode) != null; - if (success) { - game.setOpenEggbertDisplayMode(newDisplayMode); - } + OpenEggbertDisplayMode.setDisplayMode(newDisplayMode); + game.setOpenEggbertDisplayMode(newDisplayMode); + } return true; diff --git a/core/src/main/java/com/openeggbert/core/screen/OpenEggbertScreen.java b/core/src/main/java/com/openeggbert/core/screen/OpenEggbertScreen.java index 12fabcd..93d8a99 100644 --- a/core/src/main/java/com/openeggbert/core/screen/OpenEggbertScreen.java +++ b/core/src/main/java/com/openeggbert/core/screen/OpenEggbertScreen.java @@ -71,6 +71,21 @@ public abstract class OpenEggbertScreen extends ScreenAdapter { String fileName = getBackgroundFileName(); + if(getScreenType().isPresent() && getScreenType().get().isBasic()) { + if (!game.existsImageTexture("BASIC")) { + FileHandle fileHandle; + if (Gdx.app.getType() == Application.ApplicationType.Android || Gdx.app.getType() == Application.ApplicationType.WebGL) { + Gdx.app.log("screen","loading from internal"); + fileHandle = Gdx.files.internal("BASIC/BASIC.PNG"); + } else { + + Gdx.app.log("screen","loading from classpath"); + fileHandle = Gdx.files.classpath("BASIC/BASIC.PNG"); + } + game.loadImageTexture(fileHandle); + } + return; + } List possibleFileNames = OpenEggbertUtils.createPossibleFileNames(GameFileType.IMAGE8, fileName); for(String possibleFileName: possibleFileNames) { if (!game.existsImageTexture(possibleFileName)) { @@ -111,6 +126,10 @@ public abstract class OpenEggbertScreen extends ScreenAdapter { } protected void drawBackgroundIfAvailable() { + if(getScreenType().isPresent() && getScreenType().get().isBasic()) { + batch.draw(game.getImageTexture("BASIC").get(), 0, 0, 640,480); + return; + } if (getBackgroundTexture().isPresent()) { batch.draw(getBackgroundTexture().get(), 0, 0); } diff --git a/core/src/main/java/com/openeggbert/core/screen/ScreenType.java b/core/src/main/java/com/openeggbert/core/screen/ScreenType.java index bfc9ffa..15f3679 100644 --- a/core/src/main/java/com/openeggbert/core/screen/ScreenType.java +++ b/core/src/main/java/com/openeggbert/core/screen/ScreenType.java @@ -29,16 +29,19 @@ import lombok.Getter; */ public enum ScreenType { MAIN, - GAME_SPACE_LIST, - GAME_SPACE_CREATE, - GAME_SPACE_READ, - GAME_SPACE_UPDATE, - GAME_SPACE_DELETE, + GAME_SPACE_LIST("BASIC"), + GAME_SPACE_CREATE("BASIC"), + GAME_SPACE_RENAME("BASIC"), + GAME_SPACE_DELETE("BASIC"), + GAME_SPACE_RESET("BASIC"), + GAME_SPACE_EDIT("BASIC"), + GAME_SPACE_CONFIGURE("BASIC"), + GAME_SPACE_CONFIGURE_ENTRY("BASIC"), + GAME_SPACE_SELECT_MODE("BASIC"), + // MOD_LIST, - MOD_CREATE, - MOD_READ, - MOD_UPDATE, - MOD_DELETE, + MOD_VIEW, + // INIT("INIT"), GAMER("GAMER"), MAIN_HUB(""), @@ -58,5 +61,8 @@ public enum ScreenType { ScreenType(String fileName) { this.fileNameWithoutExtension = fileName; } + public boolean isBasic() { + return name().startsWith("GAME_SPACE") || name().startsWith("MOD"); + } } diff --git a/html/src/main/java/com/openeggbert/gwt/GwtLauncher.java b/html/src/main/java/com/openeggbert/gwt/GwtLauncher.java index 06d8b90..eed6776 100644 --- a/html/src/main/java/com/openeggbert/gwt/GwtLauncher.java +++ b/html/src/main/java/com/openeggbert/gwt/GwtLauncher.java @@ -3,7 +3,7 @@ package com.openeggbert.gwt; import com.badlogic.gdx.ApplicationListener; import com.badlogic.gdx.backends.gwt.GwtApplication; import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration; -import com.openeggbert.core.configuration.ScreenResolution; +import com.openeggbert.core.configuration.VirtualScreenResolution; import com.openeggbert.core.main.OpenEggbertApplication; import com.pixelgamelibrary.api.Pixel; import com.pixelgamelibrary.backend.libgdx.PixelBackendLibGDX; @@ -21,7 +21,7 @@ public class GwtLauncher extends GwtApplication { // If you want a fixed size application, comment out the above resizable section, // and uncomment below: - return new GwtApplicationConfiguration(ScreenResolution.VGA.getWidth(), ScreenResolution.VGA.getHeight()); + return new GwtApplicationConfiguration(VirtualScreenResolution.VGA.getWidth(), VirtualScreenResolution.VGA.getHeight()); } @Override diff --git a/lwjgl3/src/main/java/com/openeggbert/lwjgl3/Lwjgl3Launcher.java b/lwjgl3/src/main/java/com/openeggbert/lwjgl3/Lwjgl3Launcher.java index 9986999..cb50fe6 100644 --- a/lwjgl3/src/main/java/com/openeggbert/lwjgl3/Lwjgl3Launcher.java +++ b/lwjgl3/src/main/java/com/openeggbert/lwjgl3/Lwjgl3Launcher.java @@ -22,7 +22,7 @@ package com.openeggbert.lwjgl3; import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application; import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration; -import com.openeggbert.core.configuration.ScreenResolution; +import com.openeggbert.core.configuration.VirtualScreenResolution; import com.openeggbert.core.main.OpenEggbertApplication; import com.openeggbert.core.gamespace.GameSpace; import com.pixelgamelibrary.api.Pixel; @@ -64,7 +64,7 @@ public class Lwjgl3Launcher { //// If you remove the above line and set Vsync to false, you can get unlimited FPS, which can be //// useful for testing performance, but can also be very stressful to some hardware. //// You may also need to configure GPU drivers to fully disable Vsync; this can cause screen tearing. - configuration.setWindowedMode(ScreenResolution.VGA.getWidth(), ScreenResolution.VGA.getHeight()); + configuration.setWindowedMode(VirtualScreenResolution.VGA.getWidth(), VirtualScreenResolution.VGA.getHeight()); configuration.setWindowIcon("libgdx128.png", "libgdx64.png", "libgdx32.png", "libgdx16.png"); return configuration; }