From 83eec6a1aac63570221de4a349fe9935b78b88de Mon Sep 17 00:00:00 2001 From: Willem Date: Wed, 9 Mar 2022 13:42:37 +0100 Subject: [PATCH] Added failure boot line message in red. --- .../gdxapp4d/tos4/GDXAppTos4Activator.java | 52 ++++++++----------- .../gdxapp4d/tos4/GDXAppTos4BootListener.java | 2 + .../gdxapp4d/tos4/GDXAppTos4BootScreen.java | 32 ++++++++++-- .../gdxapp4d/tos4/GDXAppTos4Startup.java | 4 +- .../vrgem4/service/VrGem4LocaleService.java | 3 -- 5 files changed, 53 insertions(+), 40 deletions(-) diff --git a/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4Activator.java b/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4Activator.java index de835c26..a7222d00 100644 --- a/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4Activator.java +++ b/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4Activator.java @@ -58,7 +58,7 @@ public class GDXAppTos4Activator implements BundleActivator { private Properties localOverrides; private WaterDevice warpshipDevice; private SystemGdxTerminal systemGdxTerminal; - private List listeners = new ArrayList<>(); + private GDXAppTos4BootListener bootScreen; private static final String SYSTEM_USER_HOME = "user.home"; private static final String HYPERDRIVE_HOME = "Hyperdrive"; @@ -76,18 +76,8 @@ public class GDXAppTos4Activator implements BundleActivator { this.systemGdxTerminal = systemGdxTerminal; } - private void fireMessageEvent(String message) { - for (GDXAppTos4BootListener listener:listeners) { - listener.bootLine(message); - } - } - - public void addBootListener(GDXAppTos4BootListener listener) { - listeners.add(listener); - } - - public void removeBootListener(GDXAppTos4BootListener listener) { - listeners.remove(listener); + public void setBootListener(GDXAppTos4BootListener bootScreen) { + this.bootScreen = bootScreen; } public boolean hasStartError() { @@ -101,17 +91,17 @@ public class GDXAppTos4Activator implements BundleActivator { @Override public void start(final BundleContext context) { - fireMessageEvent("Mecca System eXtension superscript Four"); - fireMessageEvent("tos4: starting..."); - fireMessageEvent("init-cpus: "+Runtime.getRuntime().availableProcessors()); - fireMessageEvent("free-memory: 0x"+Long.toHexString(Runtime.getRuntime().freeMemory())); + bootScreen.bootLine("Mecca System eXtension superscript Four"); + bootScreen.bootLine("tos4: starting..."); + bootScreen.bootLine("init-cpus: "+Runtime.getRuntime().availableProcessors()); + bootScreen.bootLine("free-memory: 0x"+Long.toHexString(Runtime.getRuntime().freeMemory())); boolean useLocal = args.contains("use-local"); File userHome = new File(System.getProperty(SYSTEM_USER_HOME)); hyperdriveHome = new File(userHome, HYPERDRIVE_HOME); if (!hyperdriveHome.exists()) { - fireMessageEvent("ERROR: No Hyperdrive home."); + bootScreen.bootLineError("ERROR: No Hyperdrive home."); startError = true; return; } @@ -120,7 +110,7 @@ public class GDXAppTos4Activator implements BundleActivator { warpshipHome = new File("."); } if (!warpshipHome.exists()) { - fireMessageEvent("ERROR: No Warpship home."); + bootScreen.bootLineError("ERROR: No Warpship home."); startError = true; return; } @@ -128,9 +118,9 @@ public class GDXAppTos4Activator implements BundleActivator { if (useLocal) { warpShip = new File(warpshipHome, "local-ship.xml"); } - fireMessageEvent("warp-ship: "+warpShip); + bootScreen.bootLine("warp-ship: "+warpShip); if (!warpShip.exists()) { - fireMessageEvent("ERROR: No warp-ship.xml found."); + bootScreen.bootLineError("ERROR: No warp-ship.xml found."); startError = true; return; } @@ -138,11 +128,11 @@ public class GDXAppTos4Activator implements BundleActivator { warpshipDevice = WaterDeviceDriver.newInstance().createReader().readFile(warpShip); } catch (Exception e) { e.printStackTrace(); - fireMessageEvent("ERROR: "+e.getMessage()); + bootScreen.bootLineError("ERROR: "+e.getMessage()); startError = true; return; } - fireMessageEvent("warp-engine: "+warpshipDevice.theShip().getName()); + bootScreen.bootLine("warp-engine: "+warpshipDevice.theShip().getName()); localOverrides = new Properties(); if (useLocal) { @@ -153,9 +143,9 @@ public class GDXAppTos4Activator implements BundleActivator { } catch (Exception e) { throw new RuntimeException(e); } - fireMessageEvent("use-local: local-override.xml loaded."); + bootScreen.bootLine("use-local: local-override.xml loaded."); } else { - fireMessageEvent("use-local: local-override.xml not found."); + bootScreen.bootLine("use-local: local-override.xml not found."); } } @@ -175,7 +165,7 @@ public class GDXAppTos4Activator implements BundleActivator { } catch (InterruptedException ignored) { } } - fireMessageEvent("gdx-font: "+parameter.characters.length()+" glyphs loaded."); + bootScreen.bootLine("gdx-font: "+parameter.characters.length()+" glyphs loaded."); SystemWarpShipImpl systemWarpShip = new SystemWarpShipImpl(); @@ -195,25 +185,25 @@ public class GDXAppTos4Activator implements BundleActivator { List registratedSeas = new ArrayList<>(); int result = 0; try { - result = systemWarpShip.loadWaterOcean(context, registratedSeas, warpshipDevice.theShip().getEngine(), v -> fireMessageEvent(v)); + result = systemWarpShip.loadWaterOcean(context, registratedSeas, warpshipDevice.theShip().getEngine(), v -> bootScreen.bootLine(v)); } catch (Exception e) { e.printStackTrace(); - fireMessageEvent("ERROR: "+e.getMessage()); + bootScreen.bootLineError("ERROR: "+e.getMessage()); startError = true; return; } if (result > 0) { - fireMessageEvent("tos4: FAILURE BOOT ABORTED"); + bootScreen.bootLineError("tos4: FAILURE BOOT ABORTED"); startError = true; return; } - fireMessageEvent("tos4: chains resolved."); + bootScreen.bootLine("tos4: chains resolved."); try { systemWarpShip.loadBundles(context, registratedSeas); } catch (BundleException e) { e.printStackTrace(); - fireMessageEvent("ERROR: "+e.getMessage()); + bootScreen.bootLineError("ERROR: "+e.getMessage()); startError = true; return; } diff --git a/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4BootListener.java b/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4BootListener.java index 4e4312f6..753728d0 100644 --- a/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4BootListener.java +++ b/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4BootListener.java @@ -6,4 +6,6 @@ import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ; public interface GDXAppTos4BootListener { void bootLine(String message); + + void bootLineError(String message); } diff --git a/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4BootScreen.java b/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4BootScreen.java index e3568642..2be75166 100644 --- a/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4BootScreen.java +++ b/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4BootScreen.java @@ -15,14 +15,26 @@ import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ; public class GDXAppTos4BootScreen extends ScreenAdapter implements GDXAppTos4BootListener { private BitmapFont font; + private BitmapFont fontError; private SpriteBatch batch; private Texture backgroundImage; - private List messages = new ArrayList<>(); + private List messages = new ArrayList<>(); + + class BootMessage { + String bootLine; + String bootLineError; + public BootMessage(String bootLine, String bootLineError) { + this.bootLine = bootLine; + this.bootLineError = bootLineError; + } + } public GDXAppTos4BootScreen() { batch = new SpriteBatch(); backgroundImage = new Texture(Gdx.files.internal("background/msx-boot.png")); font = new BitmapFont(); + fontError = new BitmapFont(); + fontError.setColor(1f, 0f, 0f, 1f); } @Override @@ -33,8 +45,12 @@ public class GDXAppTos4BootScreen extends ScreenAdapter implements GDXAppTos4Boo batch.begin(); batch.draw(backgroundImage, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); synchronized (messages) { - for (String message:messages) { - font.draw(batch, message, textX, textY-=textYStep); + for (BootMessage message:messages) { + if (message.bootLine != null) { + font.draw(batch, message.bootLine, textX, textY-=textYStep); + } else if (message.bootLineError != null) { + fontError.draw(batch, message.bootLineError, textX, textY-=textYStep); + } } } batch.end(); @@ -45,12 +61,20 @@ public class GDXAppTos4BootScreen extends ScreenAdapter implements GDXAppTos4Boo batch.dispose(); backgroundImage.dispose(); font.dispose(); + fontError.dispose(); } @Override public void bootLine(String message) { synchronized (messages) { - messages.add(message); + messages.add(new BootMessage(message, null)); + } + } + + @Override + public void bootLineError(String message) { + synchronized (messages) { + messages.add(new BootMessage(null, message)); } } } diff --git a/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4Startup.java b/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4Startup.java index 26eaedc7..5dd7da5a 100644 --- a/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4Startup.java +++ b/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/GDXAppTos4Startup.java @@ -19,7 +19,7 @@ public class GDXAppTos4Startup { final Framework systemBundle = GDXAppTos4BootFactory.createFramework(); final GDXAppTos4BootScreen bootScreen = new GDXAppTos4BootScreen(); - systemActivator.addBootListener(bootScreen); + systemActivator.setBootListener(bootScreen); tos4.registrateScreen(bootScreen); tos4.selectScreen(GDXAppTos4BootScreen.class); @@ -33,7 +33,7 @@ public class GDXAppTos4Startup { if (!systemActivator.hasStartError()) { Gdx.app.postRunnable(() -> { LOG.debug("Release boot-screen"); - systemActivator.removeBootListener(bootScreen); + systemActivator.setBootListener(null); tos4.disposeScreen(bootScreen); }); } diff --git a/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/service/VrGem4LocaleService.java b/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/service/VrGem4LocaleService.java index 89d6149e..a1293e56 100644 --- a/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/service/VrGem4LocaleService.java +++ b/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/service/VrGem4LocaleService.java @@ -2,9 +2,6 @@ package love.distributedrebirth.gdxapp4d.vrgem4.service; import java.util.Locale; -import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppLauncher; -import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppMenuSection; - public interface VrGem4LocaleService { void setTextLocaleI18n(String isoCode);