From 0b885bc84ab784eb1c4dfd791dc0ea41b999951e Mon Sep 17 00:00:00 2001 From: Robert Vokac Date: Fri, 20 Sep 2024 17:44:15 +0200 Subject: [PATCH] Bug 18: Refactor and separate Pixel Api and LibGDX and Open Eggbert Core --- assets/BASIC/BASIC.PNG | Bin 0 -> 7479 bytes assets/BASIC/OPEN_EGGBERT.png | Bin 0 -> 8526 bytes .../configuration/OpenEggbertDisplayMode.java | 20 +++++------ ...tion.java => VirtualScreenResolution.java} | 4 +-- .../core/main/OpenEggbertGame.java | 3 ++ .../core/screen/AbstractBasicScreen.java | 34 ++++++++++++++++++ .../openeggbert/core/screen/DemoScreen.java | 1 + .../core/screen/GameSpaceListScreen.java | 24 +++++++------ .../openeggbert/core/screen/InitScreen.java | 7 ++-- .../core/screen/OpenEggbertScreen.java | 19 ++++++++++ .../openeggbert/core/screen/ScreenType.java | 24 ++++++++----- .../java/com/openeggbert/gwt/GwtLauncher.java | 4 +-- .../openeggbert/lwjgl3/Lwjgl3Launcher.java | 4 +-- 13 files changed, 104 insertions(+), 40 deletions(-) create mode 100644 assets/BASIC/BASIC.PNG create mode 100644 assets/BASIC/OPEN_EGGBERT.png rename core/src/main/java/com/openeggbert/core/configuration/{ScreenResolution.java => VirtualScreenResolution.java} (90%) create mode 100644 core/src/main/java/com/openeggbert/core/screen/AbstractBasicScreen.java diff --git a/assets/BASIC/BASIC.PNG b/assets/BASIC/BASIC.PNG new file mode 100644 index 0000000000000000000000000000000000000000..eae011fccbbce16633bd4b75e870d1132242338a GIT binary patch literal 7479 zcmeHLdpK0x9$uIkgM7^hlOnn(_d0f+R7&L9SI8|DDY0G4wL)^KgoH+@T?*;YMJkl9 zi;<9I)AghnQhiS%AH zC_haeA*5($Yw3g#6F$n^Vave9Q+m#?2uY;{tXk!0W4G2(%X?=)aHL_t4y_0$8w-SV z_ddx%`!&;C zWqE#{8XipZ&ocEdYwaFetse7o^5?#-4KwTN+#{@(8EesVZaK{;2+ZZ%X(xHaxqjT! zfbO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|`nk^~-*%+Sv?#_W9Ch!{GA|Q32#+;9DVgnUg&EH@gZl95 z*3=m|npRhWv_ZtLY~KZ6!V}}j?KH(k^bI-Fm`e0XCy2jcrJ%~Ey@KK%!XTG#%sg{2 z{s(v^N=Y0l{B;2u+&5Hijvkf5s*UEie)savNEFYYf#OVL3Ppx|;`<+n9+8cH9JAYy z57y|Cu8aG4=M!u9`mRd`Qp6>)8;oVPMm{?xpyDY6;#TYv6iCn@da-eXtaGKY#m5i> za-KzXqyPU8#}sWJYm2Ol)If90qklqkk4 zaY`eS7LFj5_54l@b~|yHzBpEj_R~)B(QH=&=QdtFYmJU$b4eZ%XcWkoT}q}bmGiXj zTLm{Y+q&zfOqwWs6ypWOdKxe)INMHKD4o|3D`}PnTk^)|<({kG%`f1Yh=gM6ELI=R zia3)>M)YrBJ3sZjMvsK7wn>SkIC{O^(2;G1b>~TZGyy+a;&4ft-DPkOXqAY7K5m#$&p%{PR6pic4!rb9-K-7{`M)kgp$TMt_shkO_Vri+29urvjgLSDk3u@<% gi2vbV5Iqu`9L}HLn3_Lz3f+Rhnpv6_8@t8)2V>C39RL6T literal 0 HcmV?d00001 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; }