diff --git a/gdxapp4d-app-calculator/src/main/java/love/distributedrebirth/gdxapp4d/app/calculator/CalculatorComponent.java b/gdxapp4d-app-calculator/src/main/java/love/distributedrebirth/gdxapp4d/app/calculator/CalculatorComponent.java new file mode 100644 index 00000000..01452293 --- /dev/null +++ b/gdxapp4d-app-calculator/src/main/java/love/distributedrebirth/gdxapp4d/app/calculator/CalculatorComponent.java @@ -0,0 +1,39 @@ +package love.distributedrebirth.gdxapp4d.app.calculator; + +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Reference; + +import love.distributedrebirth.gdxapp4d.tos4.service.SystemGdxLog; +import love.distributedrebirth.gdxapp4d.vrgem4.service.VrGem4DeskAppService; +import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppLauncher; +import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppMenuSection; + +@Component +public class CalculatorComponent { + + @Reference + private SystemGdxLog log; + + @Reference + private VrGem4DeskAppService deskAppService; + + private final DeskAppLauncher launcher; + + public CalculatorComponent() { + launcher = new DeskAppLauncher("Calculator", () -> new CalculatorDeskApp()); + } + + @Activate + void open() { + log.debug(this, SystemGdxLog.ACTIVATE); + deskAppService.installDeskApp(DeskAppMenuSection.PROGRAMMING, launcher); + } + + @Deactivate + void close() { + log.debug(this, SystemGdxLog.DEACTIVATE); + deskAppService.installDeskApp(DeskAppMenuSection.PROGRAMMING, launcher); + } +} diff --git a/gdxapp4d-app-calculator/src/main/java/love/distributedrebirth/gdxapp4d/app/calculator/CalculatorDeskApp.java b/gdxapp4d-app-calculator/src/main/java/love/distributedrebirth/gdxapp4d/app/calculator/CalculatorDeskApp.java new file mode 100644 index 00000000..eade2855 --- /dev/null +++ b/gdxapp4d-app-calculator/src/main/java/love/distributedrebirth/gdxapp4d/app/calculator/CalculatorDeskApp.java @@ -0,0 +1,119 @@ +package love.distributedrebirth.gdxapp4d.app.calculator; + +import imgui.ImGui; +import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ; +import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.AbstractDeskApp; +import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppContourSection; +import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppRenderer; + +@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天") +public class CalculatorDeskApp extends AbstractDeskApp implements DeskAppRenderer { + + private String value = ""; + private String valueArg = ""; + private Operation operation = Operation.NONE; + + public void create() { + getContours().setTitle("Calculator"); + getContours().registrateContour(DeskAppContourSection.MAIN, this); + } + + enum Operation { + NONE, + PLUS, + MINUS, + MULTIPLY + } + + @Override + public void render() { + ImGui.text("Value:"); + ImGui.sameLine(); + ImGui.text(value); + ImGui.separator(); + + if (ImGui.button("0")) { + value+="0"; + } + ImGui.sameLine(); + if (ImGui.button("1")) { + value+="1"; + } + ImGui.sameLine(); + if (ImGui.button("2")) { + value+="2"; + } + ImGui.sameLine(); + if (ImGui.button("3")) { + value+="3"; + } + ImGui.sameLine(); + if (ImGui.button("4")) { + value+="4"; + } + + + if (ImGui.button("5")) { + value+="5"; + } + ImGui.sameLine(); + if (ImGui.button("6")) { + value+="6"; + } + ImGui.sameLine(); + if (ImGui.button("7")) { + value+="7"; + } + ImGui.sameLine(); + if (ImGui.button("8")) { + value+="8"; + } + ImGui.sameLine(); + if (ImGui.button("9")) { + value+="9"; + } + + + if (ImGui.button("C")) { + value=""; + valueArg=""; + operation = Operation.NONE; + } + if (ImGui.button("+")) { + valueArg=value; + value=""; + operation = Operation.PLUS; + } + ImGui.sameLine(); + if (ImGui.button("-")) { + valueArg=value; + value=""; + operation = Operation.MINUS; + } + ImGui.sameLine(); + if (ImGui.button("*")) { + valueArg=value; + value=""; + operation = Operation.MULTIPLY; + } + if (ImGui.button("=")) { + int v1 = Integer.parseInt(valueArg); + int v2 = Integer.parseInt(value); + int result = 0; + switch (operation) { + case PLUS: + result = v1+v2; + break; + case MINUS: + result = v1-v2; + break; + case MULTIPLY: + result = v1*v2; + break; + default: + break; + } + value = ""+result; + } + } +} diff --git a/gdxapp4d-app-hewallet/src/main/java/love/distributedrebirth/gdxapp4d/app/hewallet/HeWalletComponent.java b/gdxapp4d-app-hewallet/src/main/java/love/distributedrebirth/gdxapp4d/app/hewallet/HeWalletComponent.java index aa8d1db5..5eb4b70a 100644 --- a/gdxapp4d-app-hewallet/src/main/java/love/distributedrebirth/gdxapp4d/app/hewallet/HeWalletComponent.java +++ b/gdxapp4d-app-hewallet/src/main/java/love/distributedrebirth/gdxapp4d/app/hewallet/HeWalletComponent.java @@ -19,13 +19,21 @@ public class HeWalletComponent { @Reference private VrGem4DeskAppService deskAppService; + private final DeskAppLauncher launcher; + + public HeWalletComponent() { + launcher = new DeskAppLauncher("Hebrew Wallet", () -> new HeWalletDeskApp()); + } + @Activate void open() { - log.info(this, "Activated HeWalletComponent"); - deskAppService.registrateDeskApp(DeskAppMenuSection.INTERNET, new DeskAppLauncher("Hebrew Wallet", () -> new HeWalletDeskApp())); + log.debug(this, SystemGdxLog.ACTIVATE); + deskAppService.installDeskApp(DeskAppMenuSection.INTERNET, launcher); } @Deactivate void close() { + log.debug(this, SystemGdxLog.DEACTIVATE); + deskAppService.installDeskApp(DeskAppMenuSection.INTERNET, launcher); } } diff --git a/gdxapp4d-app-tosamp/src/main/java/love/distributedrebirth/gdxapp4d/app/tosamp/TosAmpComponent.java b/gdxapp4d-app-tosamp/src/main/java/love/distributedrebirth/gdxapp4d/app/tosamp/TosAmpComponent.java index dd34b026..0dd89dde 100644 --- a/gdxapp4d-app-tosamp/src/main/java/love/distributedrebirth/gdxapp4d/app/tosamp/TosAmpComponent.java +++ b/gdxapp4d-app-tosamp/src/main/java/love/distributedrebirth/gdxapp4d/app/tosamp/TosAmpComponent.java @@ -23,13 +23,21 @@ public class TosAmpComponent { @Reference private SystemGdxBootArgs bootArgs; + private final DeskAppLauncher launcher; + + public TosAmpComponent() { + launcher = new DeskAppLauncher("TosAmp", () -> new TosAmpDeskApp(bootArgs.getFileChooser())); + } + @Activate void open() { - log.info(this, "Activated TosAmpComponent"); - deskAppService.registrateDeskApp(DeskAppMenuSection.MULTIMEDIA, new DeskAppLauncher("TosAmp", () -> new TosAmpDeskApp(bootArgs.getFileChooser()))); + log.debug(this, SystemGdxLog.ACTIVATE); + deskAppService.installDeskApp(DeskAppMenuSection.MULTIMEDIA, launcher); } @Deactivate void close() { + log.debug(this, SystemGdxLog.DEACTIVATE); + deskAppService.installDeskApp(DeskAppMenuSection.MULTIMEDIA, launcher); } } diff --git a/gdxapp4d-boot-desktop/local-override.xml b/gdxapp4d-boot-desktop/local-override.xml index 476ebf63..5d202eae 100644 --- a/gdxapp4d-boot-desktop/local-override.xml +++ b/gdxapp4d-boot-desktop/local-override.xml @@ -5,6 +5,9 @@ ../gdxapp4d-chain-sys-ocean/src/chain ../gdxapp4d-chain-dep-osgi-scr/src/chain + ../gdxapp4d-app-calculator/src/chain + ../gdxapp4d-app-calculator/target/classes + ../gdxapp4d-app-hewallet/src/chain ../gdxapp4d-app-hewallet/target/classes diff --git a/gdxapp4d-chain-sys-ocean/src/chain/warp-sea.xml b/gdxapp4d-chain-sys-ocean/src/chain/warp-sea.xml index 684cd92a..8b3699d0 100644 --- a/gdxapp4d-chain-sys-ocean/src/chain/warp-sea.xml +++ b/gdxapp4d-chain-sys-ocean/src/chain/warp-sea.xml @@ -4,6 +4,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://wrap-sea.x4o.distributedrebirth.love/xml/ns/warp-sea-root http://warp-sea.x4o.distributedrebirth.love/xml/ns/warp-sea-root-1.0.xsd"> + + diff --git a/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/service/SystemGdxLog.java b/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/service/SystemGdxLog.java index 5f48b7c3..d5aecd13 100644 --- a/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/service/SystemGdxLog.java +++ b/gdxapp4d-tos4/src/main/java/love/distributedrebirth/gdxapp4d/tos4/service/SystemGdxLog.java @@ -5,6 +5,9 @@ import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ; @BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天") public interface SystemGdxLog { + public static final String ACTIVATE = "Activate"; + public static final String DEACTIVATE = "Deactivate"; + void infoTag(String tag, String message, Object...args); void infoTag(String tag, String message, Throwable exception); diff --git a/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/GDXAppVrGem4Activator.java b/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/GDXAppVrGem4Activator.java index eb8479c0..6349f11b 100644 --- a/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/GDXAppVrGem4Activator.java +++ b/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/GDXAppVrGem4Activator.java @@ -16,6 +16,7 @@ import love.distributedrebirth.bassboonyd.BãßBȍőnCoffinOpenʸᴰ; import love.distributedrebirth.bassboonyd.jmx.DefaultEnumBaseᴶᴹˣ; import love.distributedrebirth.gdxapp4d.tos4.service.SystemGdxBootArgs; import love.distributedrebirth.gdxapp4d.tos4.service.SystemGdxFont; +import love.distributedrebirth.gdxapp4d.tos4.service.SystemGdxLog; import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpShip; import love.distributedrebirth.gdxapp4d.tos4.service.SystemGdxTerminal; import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpSea; @@ -48,12 +49,16 @@ public class GDXAppVrGem4Activator implements BundleActivator { } catch (InterruptedException ignored) { } + ServiceReference loggerRef = context.getServiceReference(SystemGdxLog.class); + SystemGdxLog logger = context.getService(loggerRef); + ServiceReference termRef = context.getServiceReference(SystemGdxTerminal.class); SystemGdxTerminal terminal = context.getService(termRef); ServiceReference gdxFontRef = context.getServiceReference(SystemGdxFont.class); SystemGdxFont gdxFont = context.getService(gdxFontRef); + logger.info(this, "Booting"); GDXAppVrGem4BootScreen bootScreen = new GDXAppVrGem4BootScreen(gdxFont.getFont()); Gdx.app.postRunnable(new Runnable() { @Override @@ -205,6 +210,7 @@ public class GDXAppVrGem4Activator implements BundleActivator { terminal.disposeScreen(bootScreen); } }); + logger.info(this, "Boot done"); } //TODO: add layer or ?? private ,DefaultAuthorInfoʸᴰ> T[] storeInstances() { diff --git a/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/VrGem4DeskAppServiceImpl.java b/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/VrGem4DeskAppServiceImpl.java index e76980f1..f39a1d64 100644 --- a/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/VrGem4DeskAppServiceImpl.java +++ b/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/VrGem4DeskAppServiceImpl.java @@ -23,7 +23,12 @@ public class VrGem4DeskAppServiceImpl implements VrGem4DeskAppService { } @Override - public void registrateDeskApp(DeskAppMenuSection section, DeskAppLauncher launcher) { + public void installDeskApp(DeskAppMenuSection section, DeskAppLauncher launcher) { getMenuSection(section).add(launcher); } + + @Override + public void removeDeskApp(DeskAppMenuSection section, DeskAppLauncher launcher) { + getMenuSection(section).remove(launcher); + } } diff --git a/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/service/VrGem4DeskAppService.java b/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/service/VrGem4DeskAppService.java index 69000247..608e4bce 100644 --- a/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/service/VrGem4DeskAppService.java +++ b/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/service/VrGem4DeskAppService.java @@ -5,5 +5,7 @@ import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppMenuSectio public interface VrGem4DeskAppService { - void registrateDeskApp(DeskAppMenuSection section, DeskAppLauncher launcher); + void installDeskApp(DeskAppMenuSection section, DeskAppLauncher launcher); + + void removeDeskApp(DeskAppMenuSection section, DeskAppLauncher launcher); } diff --git a/gdxapp4d-vrsys5/src/main/java/love/distributedrebirth/gdxapp4d/vrsys5/BasicConsoleComponent.java b/gdxapp4d-vrsys5/src/main/java/love/distributedrebirth/gdxapp4d/vrsys5/BasicConsoleComponent.java index 61bb5353..71f0bca3 100644 --- a/gdxapp4d-vrsys5/src/main/java/love/distributedrebirth/gdxapp4d/vrsys5/BasicConsoleComponent.java +++ b/gdxapp4d-vrsys5/src/main/java/love/distributedrebirth/gdxapp4d/vrsys5/BasicConsoleComponent.java @@ -19,13 +19,21 @@ public class BasicConsoleComponent { @Reference private VrGem4DeskAppService deskAppService; + private final DeskAppLauncher launcher; + + public BasicConsoleComponent() { + launcher = new DeskAppLauncher("Basic Console", () -> new BasicConsoleDeskApp()); + } + @Activate void open() { - log.info(this, "Activate BasicConsoleComponent"); - deskAppService.registrateDeskApp(DeskAppMenuSection.PROGRAMMING, new DeskAppLauncher("Basic Console", () -> new BasicConsoleDeskApp())); + log.debug(this, SystemGdxLog.ACTIVATE); + deskAppService.installDeskApp(DeskAppMenuSection.SYSTEM, launcher); } @Deactivate void close() { + log.debug(this, SystemGdxLog.DEACTIVATE); + deskAppService.installDeskApp(DeskAppMenuSection.SYSTEM, launcher); } }