Removed intro and loaded the oceans

This commit is contained in:
Willem Cazander 2022-03-02 00:19:07 +01:00
parent f0de4f3a9b
commit 706baabfd0
10 changed files with 157 additions and 164 deletions

View file

@ -20,10 +20,6 @@ public interface BãßBȍőnCoffinOpenʸᴰ<T extends BãßBȍőnCoffinStoreKey
PUT_OBJ(key, new ArrayList<>());
}
static <T extends DefaultEnumBaseʸᴰ<?> & BãßBȍőnCoffinStoreʸᴰ<?>> void lockCoffin(T store) {
lockCoffin(store, v -> System.out.println(v));
}
static <T extends DefaultEnumBaseʸᴰ<?> & BãßBȍőnCoffinStoreʸᴰ<?>> void lockCoffin(T store, Consumer<String> logHandler) {
logHandler.accept("Lock: "+store.BãßClassNaam()+" since: "+store.BãßAuthorCopyright());
for (Object o:store.BãßInstances()) {

View file

@ -2,6 +2,7 @@ package love.distributedrebirth.numberxd.base2t.part.warp;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
import love.distributedrebirth.bassboonyd.BãßBȍőnClassInfoʸᴰ;
@ -51,11 +52,11 @@ public enum TOSWarpCore implements DefaultEnumInstanceᴶᴹˣ<TOSWarpCore,MBean
armedWarpCipherLock.setValueBoolean(false);
}
public void BãßLockWarpCipher() {
public void BãßLockWarpCipher(Consumer<String> logHandler) {
armedWarpCipherLock.setValueBoolean(true);
for (int base:Base2PartsFactory.INSTANCE.BãßBases()) {
BãßBȍőnPartʸᴰ<?>[] parts = Base2PartsFactory.INSTANCE.BãßBuildPartsByBase(base);
BãßBȍőnCoffinOpenʸᴰ.lockCoffin(parts[0]);
BãßBȍőnCoffinOpenʸᴰ.lockCoffin(parts[0], logHandler);
}
}

View file

@ -9,6 +9,7 @@ import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Properties;
import java.util.function.Consumer;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
@ -40,6 +41,7 @@ public class GDXAppTos4Activator implements BundleActivator {
private NativeFileChooser fileChooser;
private File hyperdriveHome;
private File warpshipHome;
private Properties localOverrides;
private WaterDevice warpshipDevice;
private SystemWarpTerminal systemWarpTerminal;
private List<GDXAppTos4BootListener> listeners = new ArrayList<>();
@ -110,12 +112,6 @@ public class GDXAppTos4Activator implements BundleActivator {
fireMessageEvent("ERROR: No warp-ship.xml found.");
return;
}
context.registerService(SystemWarpBase.class.getName(), new SystemWarpBaseImpl(), new Hashtable<String, String>());
context.registerService(SystemWarpBootArgs.class.getName(), new SystemWarpBootArgsImpl(), new Hashtable<String, String>());
context.registerService(SystemWarpShip.class.getName(), new SystemWarpShipImpl(), new Hashtable<String, String>());
context.registerService(SystemWarpTerminal.class.getName(), systemWarpTerminal, new Hashtable<String, String>());
try {
warpshipDevice = WaterDeviceDriver.newInstance().createReader().readFile(warpShip);
} catch (Exception e) {
@ -125,12 +121,12 @@ public class GDXAppTos4Activator implements BundleActivator {
}
fireMessageEvent("warp-engine: "+warpshipDevice.theShip().getName());
Properties overrides = new Properties();
localOverrides = new Properties();
if (useLocal) {
File localOverride = new File("local-override.xml");
if (localOverride.exists()) {
try {
overrides.loadFromXML(new FileInputStream(localOverride));
localOverrides.loadFromXML(new FileInputStream(localOverride));
} catch (Exception e) {
throw new RuntimeException(e);
}
@ -138,11 +134,18 @@ public class GDXAppTos4Activator implements BundleActivator {
} else {
fireMessageEvent("use-local: local-override.xml not found.");
}
}
SystemWarpShipImpl systemWarpShip = new SystemWarpShipImpl();
context.registerService(SystemWarpBase.class.getName(), new SystemWarpBaseImpl(), new Hashtable<String, String>());
context.registerService(SystemWarpBootArgs.class.getName(), new SystemWarpBootArgsImpl(), new Hashtable<String, String>());
context.registerService(SystemWarpShip.class.getName(), systemWarpShip, new Hashtable<String, String>());
context.registerService(SystemWarpTerminal.class.getName(), systemWarpTerminal, new Hashtable<String, String>());
int result = 0;
try {
result = resolveWaterOcean(overrides, context, warpshipDevice.theShip().getEngine());
result = systemWarpShip.loadWaterOcean(context, warpshipDevice.theShip().getEngine(), v -> fireMessageEvent(v));
} catch (Exception e) {
e.printStackTrace();
fireMessageEvent("ERROR: "+e.getMessage());
@ -155,69 +158,6 @@ public class GDXAppTos4Activator implements BundleActivator {
}
}
private int resolveWaterOcean(Properties overrides, BundleContext context, String key) throws IOException, InterruptedException, X4OConnectionException, SAXException, BundleException {
File waterHome;
String override = overrides.getProperty(key);
if (override == null) {
waterHome = new File(hyperdriveHome, key);
if (!waterHome.exists()) {
executeHyperdrive("hyperdrive", "mount", waterHome.getAbsolutePath(), key);
}
String infoResult = executeHyperdrive("hyperdrive", "info", waterHome.getAbsolutePath());
if (!infoResult.startsWith("Drive Info")) {
fireMessageEvent("ERROR: Couldn't get info on: "+waterHome);
return 1;
}
} else {
waterHome = new File(override);
}
File waterSea = new File(waterHome, Warpᵐᵉ.WARP_SEA);
if (!waterSea.exists()) {
fireMessageEvent("ERROR: No warp-sea.xml found.");
return 1;
}
WaterOcean ocean = WaterOceanDriver.newInstance().createReader().readFile(waterSea);
fireMessageEvent("water-ocean: "+key+" ("+ocean.theWater().getName()+")");
Hashtable<String, String> props = new Hashtable<String, String>();
props.put(SystemWarpSea.NAME_PROPERTY, ocean.theWater().getName());
props.put(SystemWarpSea.PROVIDER_PROPERTY, ocean.theWater().getProvider());
context.registerService(SystemWarpSea.class.getName(), new SystemWarpSeaImpl(ocean), props);
for (WaterSeaMagic magic:ocean.theWater().getSeaMagics()) {
if ("application/vnd.osgi.bundle".equals(magic.getMime())) {
String overrideBundleKey = key + "." + magic.getFile();
String overrideBundle = overrides.getProperty(overrideBundleKey);
if (overrideBundle == null) {
GDXAppTos4BootFactory.installAndStartBundles(context, "reference:file:"+waterHome.getAbsolutePath()+"/"+magic.getFile());
} else {
GDXAppTos4BootFactory.installAndStartBundles(context, "reference:file:"+overrideBundle);
}
}
}
int result = 0;
for (WaterSeaChain chain: ocean.theWater().getSeaChains()) {
result += resolveWaterOcean(overrides, context, chain.getKey());
}
return result;
}
private String executeHyperdrive(String...cmd) throws IOException, InterruptedException {
ProcessBuilder builder = new ProcessBuilder();
builder.command(cmd);
builder.directory(new File(System.getProperty("user.home")));
Process process = builder.start();
StringBuilder buf = new StringBuilder();
try(BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
String line;
while ((line = input.readLine()) != null) {
buf.append(line);
}
}
process.waitFor();
return buf.toString();
}
public class SystemWarpSeaImpl implements SystemWarpSea {
private final WaterOcean warpSea;
@ -267,6 +207,11 @@ public class GDXAppTos4Activator implements BundleActivator {
public NativeFileChooser getFileChooser() {
return fileChooser;
}
@Override
public Properties getLocalOverrides() {
return localOverrides;
}
}
public class SystemWarpShipImpl implements SystemWarpShip {
@ -275,5 +220,70 @@ public class GDXAppTos4Activator implements BundleActivator {
public WaterDevice getWarpShip() {
return warpshipDevice;
}
@Override
public int loadWaterOcean(BundleContext context, String key, Consumer<String> logger)
throws IOException, InterruptedException, X4OConnectionException, SAXException, BundleException {
File waterHome;
String override = localOverrides.getProperty(key);
if (override == null) {
waterHome = new File(hyperdriveHome, key);
if (!waterHome.exists()) {
executeHyperdrive("hyperdrive", "mount", waterHome.getAbsolutePath(), key);
}
String infoResult = executeHyperdrive("hyperdrive", "info", waterHome.getAbsolutePath());
if (!infoResult.startsWith("Drive Info")) {
logger.accept("ERROR: Couldn't get info on: "+waterHome);
return 1;
}
} else {
waterHome = new File(override);
}
File waterSea = new File(waterHome, Warpᵐᵉ.WARP_SEA);
if (!waterSea.exists()) {
logger.accept("ERROR: No warp-sea.xml found.");
return 1;
}
WaterOcean ocean = WaterOceanDriver.newInstance().createReader().readFile(waterSea);
logger.accept("water-ocean: "+key+" ("+ocean.theWater().getName()+")");
Hashtable<String, String> props = new Hashtable<String, String>();
props.put(SystemWarpSea.NAME_PROPERTY, ocean.theWater().getName());
props.put(SystemWarpSea.PROVIDER_PROPERTY, ocean.theWater().getProvider());
context.registerService(SystemWarpSea.class.getName(), new SystemWarpSeaImpl(ocean), props);
for (WaterSeaMagic magic:ocean.theWater().getSeaMagics()) {
if ("application/vnd.osgi.bundle".equals(magic.getMime())) {
String overrideBundleKey = key + "." + magic.getFile();
String overrideBundle = localOverrides.getProperty(overrideBundleKey);
if (overrideBundle == null) {
GDXAppTos4BootFactory.installAndStartBundles(context, "reference:file:"+waterHome.getAbsolutePath()+"/"+magic.getFile());
} else {
GDXAppTos4BootFactory.installAndStartBundles(context, "reference:file:"+overrideBundle);
}
}
}
int result = 0;
for (WaterSeaChain chain: ocean.theWater().getSeaChains()) {
result += loadWaterOcean(context, chain.getKey(), logger);
}
return result;
}
private String executeHyperdrive(String...cmd) throws IOException, InterruptedException {
ProcessBuilder builder = new ProcessBuilder();
builder.command(cmd);
builder.directory(new File(System.getProperty("user.home")));
Process process = builder.start();
StringBuilder buf = new StringBuilder();
try(BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
String line;
while ((line = input.readLine()) != null) {
buf.append(line);
}
}
process.waitFor();
return buf.toString();
}
}
}

View file

@ -107,6 +107,11 @@ public class GDXAppTos4BootFactory {
"love.distributedrebirth.numberxd.base2t.typexl,"+
"love.distributedrebirth.numberxd.glyph,"+
"love.distributedrebirth.numberxd.x4o,"+
"love.distributedrebirth.warpme,"+
"love.distributedrebirth.warpme.core,"+
"love.distributedrebirth.warpme.hash,"+
"love.distributedrebirth.warpme.sea,"+
"love.distributedrebirth.warpme.ship,"+
"love.distributedrebirth.unicode4d,"+
"love.distributedrebirth.unicode4d.atlas"
); // ; version=1.0.0

View file

@ -1,6 +1,7 @@
package love.distributedrebirth.gdxapp4d.tos4.service;
import java.util.List;
import java.util.Properties;
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
import net.spookygames.gdx.nativefilechooser.NativeFileChooser;
@ -15,4 +16,6 @@ public interface SystemWarpBootArgs {
int getBootWindowHeight();
NativeFileChooser getFileChooser();
Properties getLocalOverrides();
}

View file

@ -1,5 +1,13 @@
package love.distributedrebirth.gdxapp4d.tos4.service;
import java.io.IOException;
import java.util.function.Consumer;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.x4o.xml.io.X4OConnectionException;
import org.xml.sax.SAXException;
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
import love.distributedrebirth.warpme.ship.WaterDevice;
@ -7,4 +15,6 @@ import love.distributedrebirth.warpme.ship.WaterDevice;
public interface SystemWarpShip {
WaterDevice getWarpShip();
int loadWaterOcean(BundleContext context, String key, Consumer<String> logger) throws IOException, InterruptedException, X4OConnectionException, SAXException, BundleException;
}

View file

@ -90,6 +90,11 @@
love.distributedrebirth.numberxd.base2t.typexl,
love.distributedrebirth.numberxd.glyph,
love.distributedrebirth.numberxd.x4o,
love.distributedrebirth.warpme,
love.distributedrebirth.warpme.core,
love.distributedrebirth.warpme.hash,
love.distributedrebirth.warpme.sea,
love.distributedrebirth.warpme.ship,
love.distributedrebirth.unicode4d,
love.distributedrebirth.unicode4d.atlas
</Import-Package>

View file

@ -12,6 +12,7 @@ import imgui.type.ImBoolean;
import love.distributedrebirth.bassboonyd.BãßBȍőnCoffinOpenʸᴰ;
import love.distributedrebirth.bassboonyd.jmx.DefaultEnumBaseᴶᴹˣ;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpBootArgs;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpShip;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpTerminal;
import love.distributedrebirth.gdxapp4d.vrgem4.screen.ScreenCredits;
import love.distributedrebirth.gdxapp4d.vrgem4.screen.ScreenDesktop1;
@ -19,7 +20,6 @@ import love.distributedrebirth.gdxapp4d.vrgem4.screen.ScreenDesktop2;
import love.distributedrebirth.gdxapp4d.vrgem4.screen.ScreenDesktop3;
import love.distributedrebirth.gdxapp4d.vrgem4.screen.ScreenDesktop4;
import love.distributedrebirth.gdxapp4d.vrgem4.screen.ScreenHelp;
import love.distributedrebirth.gdxapp4d.vrgem4.screen.ScreenIntro;
import love.distributedrebirth.gdxapp4d.vrgem4.screen.ScreenIntroMission;
import love.distributedrebirth.numberxd.base2t.Base2PartsFactory;
import love.distributedrebirth.numberxd.base2t.Base2Terminator;
@ -27,6 +27,7 @@ import love.distributedrebirth.numberxd.base2t.part.warp.TOSWarpCore;
import love.distributedrebirth.numberxd.glyph.BaseGlyphSet;
import love.distributedrebirth.warpme.core.WaterBucket;
import love.distributedrebirth.warpme.core.WaterBucketDriver;
import love.distributedrebirth.warpme.ship.WaterShipOcean;
public class GDXAppVrGem4Activator implements BundleActivator {
@ -59,13 +60,16 @@ public class GDXAppVrGem4Activator implements BundleActivator {
bootScreen.bootLine("vrGEM4 Booting...");
// ref to init
// LOG.debug("BãßBȍőnCoffinʸᴰ init......");
for (DefaultEnumBaseᴶᴹˣ<?,?> coffin:coffinInstances()) {
BãßBȍőnCoffinOpenʸᴰ.lockCoffin(coffin);
BãßBȍőnCoffinOpenʸᴰ.lockCoffin(coffin, v -> bootScreen.bootLine(v));
}
bootScreen.bootLine("BãßBȍőnCoffinʸᴰ init done.");
bootScreen.bootLine("ImGui Setup");
try {
Thread.sleep(100);
} catch (InterruptedException ignored) {
}
ImBoolean imLoaded = new ImBoolean(false);
Gdx.app.postRunnable(new Runnable() {
@Override
@ -82,11 +86,11 @@ public class GDXAppVrGem4Activator implements BundleActivator {
}
bootScreen.bootLine("ImGui Loaded");
ServiceReference<SystemWarpBootArgs> bootArgsRef = context.getServiceReference(SystemWarpBootArgs.class);
SystemWarpBootArgs bootArgs = context.getService(bootArgsRef);
List<String> args = bootArgs.getBootArgs();
bootScreen.bootLine("warpcore: Check request");
try {
if (args.contains("warpcore-load")) {
bootScreen.bootLine("warpcore-load: requested");
@ -103,13 +107,13 @@ public class GDXAppVrGem4Activator implements BundleActivator {
}
if (!args.contains("warpcore-nolock")) {
bootScreen.bootLine("warpcore-lock: BãßLockWarpCipher");
TOSWarpCore.INSTANCE.BãßLockWarpCipher();
TOSWarpCore.INSTANCE.BãßLockWarpCipher(v -> {});
} else {
bootScreen.bootLine("warpcore-nolock: requested");
}
if (args.contains("full-screen")) {
System.out.println("full-screen: requested");
bootScreen.bootLine("full-screen: requested");
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
@ -118,33 +122,58 @@ public class GDXAppVrGem4Activator implements BundleActivator {
});
}
bootScreen.bootLine("vrGEM4: init");
GDXAppVrGem4.INSTANCE.init(args, terminal);
bootScreen.bootLine("terminal: added screens");
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
terminal.registrateScreen(new ScreenIntro());
terminal.registrateScreen(new ScreenIntroMission());
terminal.registrateScreen(new ScreenDesktop1());
terminal.registrateScreen(new ScreenDesktop2());
terminal.registrateScreen(new ScreenDesktop3());
terminal.registrateScreen(new ScreenDesktop4());
terminal.registrateScreen(new ScreenCredits());
terminal.registrateScreen(new ScreenHelp());
if (args.contains("intro-skip")) {
System.out.println("intro-skip: requested");
terminal.selectScreen(ScreenDesktop1.class);
// music.play(MusicSongType.BACKGROUND);
} else {
terminal.selectScreen(ScreenIntro.class);
}
terminal.registrateScreen(new ScreenIntroMission());
}
});
try {
Thread.sleep(100);
} catch (InterruptedException ignored) {
}
ServiceReference<SystemWarpShip> systemWarpShipRef = context.getServiceReference(SystemWarpShip.class);
SystemWarpShip systemWarpShip = context.getService(systemWarpShipRef);
int result = 0;
try {
for (WaterShipOcean ocean:systemWarpShip.getWarpShip().theShip().getShipOceans()) {
result = systemWarpShip.loadWaterOcean(context, ocean.getSea(), v -> bootScreen.bootLine(v));
}
} catch (Exception e) {
e.printStackTrace();
bootScreen.bootLine("ERROR: "+e.getMessage());
return;
}
if (result > 0) {
bootScreen.bootLine("vrGEM4: FAILURE BOOT ABORTED");
} else {
bootScreen.bootLine("vrGEM4: chains resolved.");
try {
Thread.sleep(5000);
} catch (InterruptedException ignored) {
}
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
terminal.selectScreen(ScreenDesktop1.class);
}
});
}
}
//TODO: add layer or ?? private <T extends BãßBȍőnCoffinStoreʸᴰ<?>,DefaultAuthorInfoʸᴰ> T[] storeInstances() {
@SuppressWarnings("unchecked")
private <T extends DefaultEnumBaseᴶᴹˣ<?,?>> T[] coffinInstances() {

View file

@ -35,7 +35,7 @@ public class GDXAppVrGem4BootScreen extends ScreenAdapter implements GDXAppVrGem
for (String message:messages) {
font.draw(batch, message, textX, textY-=textYStep);
}
batch.draw(backgroundImage, textY, textY, textY, textY);
batch.draw(backgroundImage, 200, textY, Gdx.graphics.getWidth() - 200, Gdx.graphics.getHeight() - textY);
}
batch.end();
}

View file

@ -1,66 +0,0 @@
package love.distributedrebirth.gdxapp4d.vrgem4.screen;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.ScreenUtils;
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
import love.distributedrebirth.gdxapp4d.tos4.GDXAppTos4;
import love.distributedrebirth.gdxapp4d.vrgem4.GDXAppVrGem4;
import love.distributedrebirth.gdxapp4d.vrgem4.music.MusicSongType;
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
public class ScreenIntro extends ScreenAdapter {
private Texture backgroundImage;
private float colorDeltaTime = 0f;
private boolean colorPositive = true;
protected SpriteBatch batch;
protected BitmapFont font;
public ScreenIntro() {
batch = new SpriteBatch();
font = new BitmapFont();
backgroundImage = new Texture(Gdx.files.internal("background/temple-os.png"));
}
@Override
public void render(float delta) {
if (colorPositive) {
colorDeltaTime += Gdx.graphics.getDeltaTime()/2;
} else {
colorDeltaTime -= Gdx.graphics.getDeltaTime()/2;
}
if (colorDeltaTime > 1f) {
colorPositive = false;
} else if (colorDeltaTime < 0f) {
colorPositive = true;
}
ScreenUtils.clear(0.333f, colorDeltaTime, colorDeltaTime, 1);
batch.begin();
batch.draw(backgroundImage, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
font.draw(batch, "Tap anywhere to begin!", Gdx.graphics.getWidth()/2 - 73, 33);
batch.end();
if (Gdx.input.isTouched() || Gdx.input.isKeyPressed(Keys.ENTER) || Gdx.input.isKeyPressed(Keys.SPACE)) {
GDXAppVrGem4.INSTANCE.terminal.selectScreen(ScreenIntroMission.class);
dispose();
}
}
@Override
public void show() {
GDXAppVrGem4.INSTANCE.music.play(MusicSongType.INTRO);
}
@Override
public void dispose() {
//batch.dispose();
font.dispose();
backgroundImage.dispose();
}
}