2022-02-20 19:56:37 +00:00
|
|
|
import lib.ui.Observable;
|
2021-12-20 00:55:30 +00:00
|
|
|
import lib.ui.TextElement;
|
|
|
|
import lib.ui.ReactiveUI;
|
|
|
|
import kernel.Log;
|
|
|
|
import util.Debug;
|
|
|
|
import kernel.ui.WindowManager;
|
|
|
|
import kernel.net.Net;
|
|
|
|
import kernel.KernelEvents;
|
|
|
|
|
|
|
|
using util.Extender.LambdaExtender;
|
|
|
|
|
|
|
|
class Startup {
|
|
|
|
static public function main() {
|
|
|
|
// OS.sleep(Math.random() * 3); // Native lua call to `sleep`
|
|
|
|
Net.instance.init();
|
|
|
|
WindowManager.instance.init();
|
|
|
|
|
|
|
|
Debug.printBuildInfo();
|
|
|
|
|
|
|
|
exampleUI();
|
|
|
|
|
|
|
|
Log.moveToOutput("top");
|
|
|
|
|
|
|
|
KernelEvents.instance.startEventLoop();
|
|
|
|
}
|
|
|
|
|
|
|
|
static function exampleProgramm() {
|
|
|
|
var context = WindowManager.instance.createNewContext();
|
|
|
|
|
|
|
|
context.clickSignal.on(data -> {
|
|
|
|
context.setCursorPos(data.pos.x,data.pos.y);
|
|
|
|
context.write("x");
|
|
|
|
});
|
|
|
|
|
|
|
|
context.write("Example programm");
|
|
|
|
}
|
|
|
|
|
|
|
|
static function exampleUI() {
|
|
|
|
var context = WindowManager.instance.createNewContext();
|
|
|
|
|
2022-02-20 19:56:37 +00:00
|
|
|
var text = new Observable("Hello world");
|
|
|
|
|
|
|
|
var ui = new ReactiveUI(context,[
|
|
|
|
new TextElement(text),
|
|
|
|
new TextElement(text,Green,Red),
|
2021-12-20 00:55:30 +00:00
|
|
|
]);
|
|
|
|
|
2022-02-20 19:56:37 +00:00
|
|
|
ui.render();
|
|
|
|
|
|
|
|
context.clickSignal.on(data -> {
|
|
|
|
text.set("Holla mundo");
|
|
|
|
});
|
|
|
|
|
2021-12-20 00:55:30 +00:00
|
|
|
WindowManager.instance.focusContextToOutput(context,"main");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|