Added calculator and fixed install/remove log

This commit is contained in:
Willem Cazander 2022-03-07 22:22:54 +01:00
parent 1ad97608ee
commit b9f6cedace
11 changed files with 211 additions and 8 deletions

View file

@ -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);
}
}

View file

@ -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;
}
}
}

View file

@ -19,13 +19,21 @@ public class HeWalletComponent {
@Reference @Reference
private VrGem4DeskAppService deskAppService; private VrGem4DeskAppService deskAppService;
private final DeskAppLauncher launcher;
public HeWalletComponent() {
launcher = new DeskAppLauncher("Hebrew Wallet", () -> new HeWalletDeskApp());
}
@Activate @Activate
void open() { void open() {
log.info(this, "Activated HeWalletComponent"); log.debug(this, SystemGdxLog.ACTIVATE);
deskAppService.registrateDeskApp(DeskAppMenuSection.INTERNET, new DeskAppLauncher("Hebrew Wallet", () -> new HeWalletDeskApp())); deskAppService.installDeskApp(DeskAppMenuSection.INTERNET, launcher);
} }
@Deactivate @Deactivate
void close() { void close() {
log.debug(this, SystemGdxLog.DEACTIVATE);
deskAppService.installDeskApp(DeskAppMenuSection.INTERNET, launcher);
} }
} }

View file

@ -23,13 +23,21 @@ public class TosAmpComponent {
@Reference @Reference
private SystemGdxBootArgs bootArgs; private SystemGdxBootArgs bootArgs;
private final DeskAppLauncher launcher;
public TosAmpComponent() {
launcher = new DeskAppLauncher("TosAmp", () -> new TosAmpDeskApp(bootArgs.getFileChooser()));
}
@Activate @Activate
void open() { void open() {
log.info(this, "Activated TosAmpComponent"); log.debug(this, SystemGdxLog.ACTIVATE);
deskAppService.registrateDeskApp(DeskAppMenuSection.MULTIMEDIA, new DeskAppLauncher("TosAmp", () -> new TosAmpDeskApp(bootArgs.getFileChooser()))); deskAppService.installDeskApp(DeskAppMenuSection.MULTIMEDIA, launcher);
} }
@Deactivate @Deactivate
void close() { void close() {
log.debug(this, SystemGdxLog.DEACTIVATE);
deskAppService.installDeskApp(DeskAppMenuSection.MULTIMEDIA, launcher);
} }
} }

View file

@ -5,6 +5,9 @@
<entry key="f8be3b29da5b6b2cb464f781469ceede6ccfd848d158293a4cdffbc2c41a410b">../gdxapp4d-chain-sys-ocean/src/chain</entry> <entry key="f8be3b29da5b6b2cb464f781469ceede6ccfd848d158293a4cdffbc2c41a410b">../gdxapp4d-chain-sys-ocean/src/chain</entry>
<entry key="8833aa29da5b6b2cb464f781469ceede6ccfd848d158293a4cdffbc2c41b58de">../gdxapp4d-chain-dep-osgi-scr/src/chain</entry> <entry key="8833aa29da5b6b2cb464f781469ceede6ccfd848d158293a4cdffbc2c41b58de">../gdxapp4d-chain-dep-osgi-scr/src/chain</entry>
<entry key="7744aa29da5b6b2cb4b8f781469c33de688fd848d158293a4cdddbc2c41b12aa">../gdxapp4d-app-calculator/src/chain</entry>
<entry key="7744aa29da5b6b2cb4b8f781469c33de688fd848d158293a4cdddbc2c41b12aa.gdxapp4d-app-calculator.jar">../gdxapp4d-app-calculator/target/classes</entry>
<entry key="6633aa29da5b6b2cb4bef781469cffde677fd848d158293a4cdffbc2c41b89fe">../gdxapp4d-app-hewallet/src/chain</entry> <entry key="6633aa29da5b6b2cb4bef781469cffde677fd848d158293a4cdffbc2c41b89fe">../gdxapp4d-app-hewallet/src/chain</entry>
<entry key="6633aa29da5b6b2cb4bef781469cffde677fd848d158293a4cdffbc2c41b89fe.gdxapp4d-app-hewallet.jar">../gdxapp4d-app-hewallet/target/classes</entry> <entry key="6633aa29da5b6b2cb4bef781469cffde677fd848d158293a4cdffbc2c41b89fe.gdxapp4d-app-hewallet.jar">../gdxapp4d-app-hewallet/target/classes</entry>

View file

@ -4,6 +4,8 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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"> 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">
<link:sea name="System Ocean" provider="gdxapp4d.system" author="willemtsade"> <link:sea name="System Ocean" provider="gdxapp4d.system" author="willemtsade">
<!-- Link app-calculator -->
<link:chain key="7744aa29da5b6b2cb4b8f781469c33de688fd848d158293a4cdddbc2c41b12aa"/>
<!-- Link app-hewallet --> <!-- Link app-hewallet -->
<link:chain key="6633aa29da5b6b2cb4bef781469cffde677fd848d158293a4cdffbc2c41b89fe"/> <link:chain key="6633aa29da5b6b2cb4bef781469cffde677fd848d158293a4cdffbc2c41b89fe"/>
<!-- Link app-tosamp --> <!-- Link app-tosamp -->

View file

@ -5,6 +5,9 @@ import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天") @BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
public interface SystemGdxLog { 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, Object...args);
void infoTag(String tag, String message, Throwable exception); void infoTag(String tag, String message, Throwable exception);

View file

@ -16,6 +16,7 @@ import love.distributedrebirth.bassboonyd.BãßBȍőnCoffinOpenʸᴰ;
import love.distributedrebirth.bassboonyd.jmx.DefaultEnumBaseᴶᴹˣ; import love.distributedrebirth.bassboonyd.jmx.DefaultEnumBaseᴶᴹˣ;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemGdxBootArgs; import love.distributedrebirth.gdxapp4d.tos4.service.SystemGdxBootArgs;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemGdxFont; 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.SystemWarpShip;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemGdxTerminal; import love.distributedrebirth.gdxapp4d.tos4.service.SystemGdxTerminal;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpSea; import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpSea;
@ -48,12 +49,16 @@ public class GDXAppVrGem4Activator implements BundleActivator {
} catch (InterruptedException ignored) { } catch (InterruptedException ignored) {
} }
ServiceReference<SystemGdxLog> loggerRef = context.getServiceReference(SystemGdxLog.class);
SystemGdxLog logger = context.getService(loggerRef);
ServiceReference<SystemGdxTerminal> termRef = context.getServiceReference(SystemGdxTerminal.class); ServiceReference<SystemGdxTerminal> termRef = context.getServiceReference(SystemGdxTerminal.class);
SystemGdxTerminal terminal = context.getService(termRef); SystemGdxTerminal terminal = context.getService(termRef);
ServiceReference<SystemGdxFont> gdxFontRef = context.getServiceReference(SystemGdxFont.class); ServiceReference<SystemGdxFont> gdxFontRef = context.getServiceReference(SystemGdxFont.class);
SystemGdxFont gdxFont = context.getService(gdxFontRef); SystemGdxFont gdxFont = context.getService(gdxFontRef);
logger.info(this, "Booting");
GDXAppVrGem4BootScreen bootScreen = new GDXAppVrGem4BootScreen(gdxFont.getFont()); GDXAppVrGem4BootScreen bootScreen = new GDXAppVrGem4BootScreen(gdxFont.getFont());
Gdx.app.postRunnable(new Runnable() { Gdx.app.postRunnable(new Runnable() {
@Override @Override
@ -205,6 +210,7 @@ public class GDXAppVrGem4Activator implements BundleActivator {
terminal.disposeScreen(bootScreen); terminal.disposeScreen(bootScreen);
} }
}); });
logger.info(this, "Boot done");
} }
//TODO: add layer or ?? private <T extends BãßBȍőnCoffinStoreʸᴰ<?>,DefaultAuthorInfoʸᴰ> T[] storeInstances() { //TODO: add layer or ?? private <T extends BãßBȍőnCoffinStoreʸᴰ<?>,DefaultAuthorInfoʸᴰ> T[] storeInstances() {

View file

@ -23,7 +23,12 @@ public class VrGem4DeskAppServiceImpl implements VrGem4DeskAppService {
} }
@Override @Override
public void registrateDeskApp(DeskAppMenuSection section, DeskAppLauncher launcher) { public void installDeskApp(DeskAppMenuSection section, DeskAppLauncher launcher) {
getMenuSection(section).add(launcher); getMenuSection(section).add(launcher);
} }
@Override
public void removeDeskApp(DeskAppMenuSection section, DeskAppLauncher launcher) {
getMenuSection(section).remove(launcher);
}
} }

View file

@ -5,5 +5,7 @@ import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppMenuSectio
public interface VrGem4DeskAppService { public interface VrGem4DeskAppService {
void registrateDeskApp(DeskAppMenuSection section, DeskAppLauncher launcher); void installDeskApp(DeskAppMenuSection section, DeskAppLauncher launcher);
void removeDeskApp(DeskAppMenuSection section, DeskAppLauncher launcher);
} }

View file

@ -19,13 +19,21 @@ public class BasicConsoleComponent {
@Reference @Reference
private VrGem4DeskAppService deskAppService; private VrGem4DeskAppService deskAppService;
private final DeskAppLauncher launcher;
public BasicConsoleComponent() {
launcher = new DeskAppLauncher("Basic Console", () -> new BasicConsoleDeskApp());
}
@Activate @Activate
void open() { void open() {
log.info(this, "Activate BasicConsoleComponent"); log.debug(this, SystemGdxLog.ACTIVATE);
deskAppService.registrateDeskApp(DeskAppMenuSection.PROGRAMMING, new DeskAppLauncher("Basic Console", () -> new BasicConsoleDeskApp())); deskAppService.installDeskApp(DeskAppMenuSection.SYSTEM, launcher);
} }
@Deactivate @Deactivate
void close() { void close() {
log.debug(this, SystemGdxLog.DEACTIVATE);
deskAppService.installDeskApp(DeskAppMenuSection.SYSTEM, launcher);
} }
} }