Launcher/Launcher/runtime/init.js

75 lines
2.1 KiB
JavaScript
Raw Normal View History

var app, stage, scene, loginScene, menuScene;
var rootPane, loginPane, authPane, menuPane;
2018-09-17 10:07:32 +03:00
// Override application class
var LauncherApp = Java.extend(JSApplication, {
init: function() {
app = JSApplication.getInstance();
cliParams.init(app.getParameters());
settings.load();
cliParams.applySettings();
2018-09-17 10:07:32 +03:00
}, start: function(primaryStage) {
stage = primaryStage;
stage.initStyle(javafx.stage.StageStyle.TRANSPARENT);
stage.setResizable(false);
stage.setTitle(config.title);
2018-09-17 10:07:32 +03:00
// Set icons
config.icons.forEach(function(icon) {
2018-09-17 10:07:32 +03:00
var iconURL = Launcher.getResourceURL(icon).toString();
stage.getIcons().add(new javafx.scene.image.Image(iconURL));
});
// Load launcher FXML
loginPane = loadFXML("dialog/login.fxml");
menuPane = loadFXML("dialog/mainmenu.fxml");
loginScene = new javafx.scene.Scene(loginPane);
loginScene.setFill(javafx.scene.paint.Color.TRANSPARENT);
2018-09-17 10:07:32 +03:00
menuScene = new javafx.scene.Scene(menuPane);
menuScene.setFill(javafx.scene.paint.Color.TRANSPARENT);
2018-09-17 10:07:32 +03:00
setCurrentScene(loginScene);
initLauncher();
2018-09-17 10:07:32 +03:00
}, stop: function() {
settings.save();
options.save();
2018-09-17 10:07:32 +03:00
}
});
// Helper functions
function loadFXML(name) {
var loader = new javafx.fxml.FXMLLoader(Launcher.getResourceURL(name));
loader.setCharset(IOHelper.UNICODE_CHARSET);
return loader.load();
}
function setCurrentScene(scene) {
stage.setScene(scene);
rootPane = scene.getRoot();
dimPane = rootPane.lookup("#mask");
stage.sizeToScene();
stage.centerOnScreen();
stage.show();
}
2018-09-17 10:07:32 +03:00
function setRootParent(parent) {
scene.setRoot(parent);
}
// Start function - there all begins
function start(args) {
2018-09-17 10:07:32 +03:00
// Set font rendering properties
LogHelper.debug("Setting FX properties");
java.lang.System.setProperty("prism.lcdtext", "false");
2018-09-17 10:07:32 +03:00
// Start laucher JavaFX stage
LogHelper.debug("Launching JavaFX application");
javafx.application.Application.launch(LauncherApp.class, args);
}
launcher.loadScript("dialog/dialog.js");