Some changes
This commit is contained in:
parent
d66f843d31
commit
4c888e084c
1
build_html.sh
Executable file
1
build_html.sh
Executable file
@ -0,0 +1 @@
|
|||||||
|
./gradlew html:dist
|
@ -31,6 +31,7 @@ import lombok.Data;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class GameSpace {
|
public class GameSpace {
|
||||||
|
|
||||||
|
private boolean embeddedAssets;
|
||||||
private FeatureLevel featureLevel;
|
private FeatureLevel featureLevel;
|
||||||
private String dataDirectory;
|
private String dataDirectory;
|
||||||
private String image08Directory;
|
private String image08Directory;
|
||||||
@ -38,7 +39,7 @@ public class GameSpace {
|
|||||||
private String image24Directory;
|
private String image24Directory;
|
||||||
private String image24x2Directory;
|
private String image24x2Directory;
|
||||||
private String soundDirectory;
|
private String soundDirectory;
|
||||||
private String currenteDirectory;
|
private String currentDirectory;
|
||||||
|
|
||||||
public GameSpace() {
|
public GameSpace() {
|
||||||
|
|
||||||
|
@ -24,19 +24,17 @@ import com.badlogic.gdx.Gdx;
|
|||||||
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;
|
||||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||||
import com.badlogic.gdx.utils.ObjectMap;
|
import com.badlogic.gdx.utils.ObjectMap;
|
||||||
import com.badlogic.gdx.utils.viewport.FitViewport;
|
|
||||||
import com.badlogic.gdx.utils.viewport.Viewport;
|
import com.badlogic.gdx.utils.viewport.Viewport;
|
||||||
import com.openeggbert.entity.common.GameSpace;
|
import com.openeggbert.entity.common.GameSpace;
|
||||||
import com.openeggbert.mods.Mod;
|
import com.openeggbert.mods.Mod;
|
||||||
|
import com.openeggbert.mods.ModIdentification;
|
||||||
import com.openeggbert.screens.GameSpaceListScreen;
|
import com.openeggbert.screens.GameSpaceListScreen;
|
||||||
import com.openeggbert.screens.InitScreen;
|
import com.openeggbert.screens.InitScreen;
|
||||||
import com.openeggbert.utils.OpenEggbertUtils;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -117,9 +115,7 @@ public class OpenEggbertGame extends Game {
|
|||||||
Mod mod = new Mod(modXml.readString());
|
Mod mod = new Mod(modXml.readString());
|
||||||
embeddedMods.add(mod);
|
embeddedMods.add(mod);
|
||||||
System.out.println("embeddedMods.size(): " + embeddedMods.size());
|
System.out.println("embeddedMods.size(): " + embeddedMods.size());
|
||||||
for (int i = 0; i < 42; i++) {
|
// for (int i = 0; i < 42; i++) embeddedMods.add(mod);//for testing purposes
|
||||||
embeddedMods.add(mod);//for testing purposes
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -174,5 +170,8 @@ public class OpenEggbertGame extends Game {
|
|||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public Mod loadMod(ModIdentification modIdentification) {
|
||||||
|
return embeddedMods.stream().filter(m->m.getIdentification().asString().equals(modIdentification.asString())).findFirst().get();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.openeggbert.screens;
|
package com.openeggbert.screens;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Application;
|
||||||
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;
|
||||||
@ -47,10 +48,11 @@ public abstract class AbstractOpenEggbertScreen extends ScreenAdapter {
|
|||||||
private final String getBackgroundFileName() {
|
private final String getBackgroundFileName() {
|
||||||
return getScreenType().isPresent() ? getScreenType().get().getFileName() : "";
|
return getScreenType().isPresent() ? getScreenType().get().getFileName() : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Optional<OpenEggbertScreenType> getScreenType() {
|
protected Optional<OpenEggbertScreenType> getScreenType() {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Optional<Texture> getBackgroundTexture() {
|
protected Optional<Texture> getBackgroundTexture() {
|
||||||
if (getBackgroundFileName().isEmpty()) {
|
if (getBackgroundFileName().isEmpty()) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
@ -64,15 +66,43 @@ public abstract class AbstractOpenEggbertScreen extends ScreenAdapter {
|
|||||||
}
|
}
|
||||||
String fileName = getBackgroundFileName();
|
String fileName = getBackgroundFileName();
|
||||||
if (!game.existsImageTexture(fileName)) {
|
if (!game.existsImageTexture(fileName)) {
|
||||||
FileHandle fileHandleUpperCase = Gdx.files.absolute(game.getGameSpace().getImage08Directory() + "/" + fileName);
|
String nameUpperCase = game.getGameSpace().getImage08Directory() + "/" + fileName;
|
||||||
FileHandle fileHandleLowerCase = Gdx.files.absolute(game.getGameSpace().getImage08Directory() + "/" + fileName.toLowerCase());
|
String nameLowerCase = game.getGameSpace().getImage08Directory() + "/" + fileName.toLowerCase();
|
||||||
|
System.out.println("nameUpperCase=" + nameUpperCase);
|
||||||
|
System.out.println("nameLowerCase=" + nameLowerCase);
|
||||||
|
FileHandle fileHandleUpperCase = null;
|
||||||
|
FileHandle fileHandleLowerCase = null;
|
||||||
|
if (game.getGameSpace().isEmbeddedAssets()) {
|
||||||
|
|
||||||
|
if (Gdx.app.getType() == Application.ApplicationType.Android || Gdx.app.getType() == Application.ApplicationType.WebGL) {
|
||||||
|
System.out.println("loading from internal");
|
||||||
|
fileHandleUpperCase = Gdx.files.internal(nameUpperCase);
|
||||||
|
fileHandleLowerCase = Gdx.files.internal(nameLowerCase);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
System.out.println("loading from classpath");
|
||||||
|
fileHandleUpperCase = Gdx.files.classpath(nameUpperCase);
|
||||||
|
fileHandleLowerCase = Gdx.files.classpath(nameLowerCase);
|
||||||
|
System.out.println("fileHandleUpperCase.exists()=" + fileHandleUpperCase.exists());
|
||||||
|
System.out.println("fileHandleLowerCase.exists()=" + fileHandleLowerCase.exists());
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.out.println("loading from absolute");
|
||||||
|
|
||||||
|
fileHandleUpperCase = Gdx.files.absolute(nameUpperCase);
|
||||||
|
fileHandleLowerCase = Gdx.files.absolute(nameLowerCase);
|
||||||
|
}
|
||||||
|
|
||||||
if (fileHandleUpperCase.exists()) {
|
if (fileHandleUpperCase.exists()) {
|
||||||
game.loadImageTexture(fileHandleUpperCase);
|
game.loadImageTexture(fileHandleUpperCase);
|
||||||
} else {
|
} else {
|
||||||
if (!fileHandleLowerCase.exists()) {
|
if (fileHandleLowerCase.exists()) {
|
||||||
|
game.loadImageTexture(fileHandleLowerCase);
|
||||||
|
} else {
|
||||||
throw new OpenEggbertException("Could not load file: " + fileName);
|
throw new OpenEggbertException("Could not load file: " + fileName);
|
||||||
}
|
}
|
||||||
game.loadImageTexture(fileHandleLowerCase);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,10 @@ import com.badlogic.gdx.graphics.Color;
|
|||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
|
||||||
import com.badlogic.gdx.utils.ScreenUtils;
|
import com.badlogic.gdx.utils.ScreenUtils;
|
||||||
|
import com.openeggbert.entity.common.GameSpace;
|
||||||
import com.openeggbert.main.OpenEggbertGame;
|
import com.openeggbert.main.OpenEggbertGame;
|
||||||
import com.openeggbert.mods.Mod;
|
import com.openeggbert.mods.Mod;
|
||||||
import com.openeggbert.mods.ModType;
|
import com.openeggbert.mods.ModType;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@ -46,6 +46,7 @@ public class GameSpaceListScreen extends AbstractOpenEggbertScreen {
|
|||||||
private int pageNumber = 1;
|
private int pageNumber = 1;
|
||||||
private final int pageSize = 5;
|
private final int pageSize = 5;
|
||||||
private final List<Mod> fullEmbeddedMods;
|
private final List<Mod> fullEmbeddedMods;
|
||||||
|
private float timeSeconds = 0f;
|
||||||
|
|
||||||
@ToString
|
@ToString
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@ -73,6 +74,32 @@ public class GameSpaceListScreen extends AbstractOpenEggbertScreen {
|
|||||||
@Override
|
@Override
|
||||||
public void show() {
|
public void show() {
|
||||||
Gdx.input.setInputProcessor(new InputAdapter() {
|
Gdx.input.setInputProcessor(new InputAdapter() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public boolean touchUp (int screenX, int screenY, int pointer, int button) {
|
||||||
|
timeSeconds = 0f;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean touchCancelled (int screenX, int screenY, int pointer, int button) {
|
||||||
|
timeSeconds = 0f;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean touchDragged (int screenX, int screenY, int pointer) {
|
||||||
|
timeSeconds = 0f;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mouseMoved (int screenX, int screenY) {
|
||||||
|
timeSeconds = 0f;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyDown(int keyCode) {
|
public boolean keyDown(int keyCode) {
|
||||||
if (keyCode == Input.Keys.SPACE) {
|
if (keyCode == Input.Keys.SPACE) {
|
||||||
@ -87,31 +114,74 @@ public class GameSpaceListScreen extends AbstractOpenEggbertScreen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean touchDown(int x, int y, int pointer, int button) {
|
public boolean touchDown(int x, int y, int pointer, int button) {
|
||||||
|
timeSeconds = 0f;
|
||||||
Gdx.app.log("touchDown: ", "x=" + x + " " + "y=" + y);
|
Gdx.app.log("touchDown: ", "x=" + x + " " + "y=" + y);
|
||||||
if (x <= Gdx.graphics.getWidth() / 3f && y >= (Gdx.graphics.getHeight()* 0.92f) && pageNumber > 1) {
|
if (x <= Gdx.graphics.getWidth() / 3f && y >= (Gdx.graphics.getHeight() * 0.92f) && pageNumber > 1) {
|
||||||
pageNumber--;
|
pageNumber--;
|
||||||
}
|
}
|
||||||
if (x >= Gdx.graphics.getWidth() * 2f / 3f && y >= (Gdx.graphics.getHeight() * 0.92f) && (pageNumber * pageSize) < fullEmbeddedMods.size()) {
|
if (x >= Gdx.graphics.getWidth() * 2f / 3f && y >= (Gdx.graphics.getHeight() * 0.92f) && (pageNumber * pageSize) < fullEmbeddedMods.size()) {
|
||||||
pageNumber++;
|
pageNumber++;
|
||||||
}
|
}
|
||||||
// for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
// System.out.println(fourArray[i].toString());
|
if (buttons[i] == null) {
|
||||||
// }
|
continue;
|
||||||
// for (int i = 0; i < 5; i++) {
|
}
|
||||||
// if (x > fourArray[i].x && x < (fourArray[i].x + fourArray[i].width)
|
System.out.println(buttons[i].toString());
|
||||||
// && y > fourArray[4 - i].y && y < (fourArray[4 - i].y + fourArray[4 - i].height)) {
|
}
|
||||||
// System.out.println("button " + i);
|
y = Gdx.graphics.getHeight() - y;
|
||||||
// }
|
Gdx.app.log("touchDown2: ", "x=" + x + " " + "y=" + 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)) {
|
||||||
|
System.out.println("button " + i);
|
||||||
|
activateButton(i);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void activateButton(int i) {
|
||||||
|
Mod mod = fullEmbeddedMods.get(pageSize * (pageNumber - 1) + i);
|
||||||
|
GameSpace gameSpace = new GameSpace();
|
||||||
|
gameSpace.setFeatureLevel(mod.getFeatureLevel());
|
||||||
|
mod.getImportedMods().stream().map(m -> game.loadMod(m))
|
||||||
|
.filter(m -> m.getModType().name().startsWith("IMAGE"))
|
||||||
|
.forEach(m -> {
|
||||||
|
if (m.getModType() == ModType.IMAGE08) {
|
||||||
|
gameSpace.setImage08Directory("embedded_mods/" + m.getIdentification().getGroupId() + "/" + m.getIdentification().getModId());
|
||||||
|
}
|
||||||
|
if (m.getModType() == ModType.IMAGE16) {
|
||||||
|
gameSpace.setImage16Directory("embedded_mods/" + m.getIdentification().getGroupId() + "/" + m.getIdentification().getModId());
|
||||||
|
}
|
||||||
|
if (m.getModType() == ModType.IMAGE24) {
|
||||||
|
gameSpace.setImage24Directory("embedded_mods/" + m.getIdentification().getGroupId() + "/" + m.getIdentification().getModId());
|
||||||
|
}
|
||||||
|
if (m.getModType() == ModType.IMAGE24X2) {
|
||||||
|
gameSpace.setImage24x2Directory("embedded_mods/" + m.getIdentification().getGroupId() + "/" + m.getIdentification().getModId());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
gameSpace.setEmbeddedAssets(true);
|
||||||
|
game.setGameSpace(gameSpace);
|
||||||
|
game.setScreen(new InitScreen(game));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(float delta) {
|
public void render(float delta) {
|
||||||
|
|
||||||
|
timeSeconds += Gdx.graphics.getRawDeltaTime();
|
||||||
|
if (timeSeconds > 5) {
|
||||||
|
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);
|
int buttonHeight = (int) (game.getHeightInPixels() * 0.1f);
|
||||||
|
|
||||||
@ -149,7 +219,9 @@ public class GameSpaceListScreen extends AbstractOpenEggbertScreen {
|
|||||||
int q = 0;
|
int q = 0;
|
||||||
for (Rectangle r : buttons) {
|
for (Rectangle r : buttons) {
|
||||||
q++;
|
q++;
|
||||||
if(q> modsForPage.size())break;
|
if (q > modsForPage.size()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
shapeRenderer.rect(r.x, r.y, r.width, r.height);
|
shapeRenderer.rect(r.x, r.y, r.width, r.height);
|
||||||
}
|
}
|
||||||
if (pageNumber
|
if (pageNumber
|
||||||
|
@ -73,7 +73,7 @@ public class DesktopUtils {
|
|||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
GameSpace gameSpace = new GameSpace();
|
GameSpace gameSpace = new GameSpace();
|
||||||
gameSpace.setCurrenteDirectory(new File(".").getAbsolutePath());
|
gameSpace.setCurrentDirectory(new File(".").getAbsolutePath());
|
||||||
gameSpace.setFeatureLevel(featureLevel);
|
gameSpace.setFeatureLevel(featureLevel);
|
||||||
if (featureLevel == FeatureLevel.SPEEDY_BLUPI_DEMO) {
|
if (featureLevel == FeatureLevel.SPEEDY_BLUPI_DEMO) {
|
||||||
gameSpace.setDataDirectory(gameSpaceDirectory.getAbsolutePath() + "/" + "Data");
|
gameSpace.setDataDirectory(gameSpaceDirectory.getAbsolutePath() + "/" + "Data");
|
||||||
|
Reference in New Issue
Block a user