Search in sources :

Example 1 with SimpleGuiDemo

use of com.xenoage.zong.demos.simplegui.SimpleGuiDemo in project Zong by Xenoage.

the class Demos method start.

@Override
public void start(Stage primaryStage) throws Exception {
    // demo given by parameter?
    Demo demo = null;
    if (getParameters().getUnnamed().size() > 0) {
        demo = EnumUtils.getEnumValue(getParameters().getUnnamed().get(0), Demo.values());
    } else {
        // show available demos in terminal
        System.out.println("Available demos, for direct launching:");
        for (Demo d : Demo.values()) System.out.println(" - task 'run" + d.name() + "': " + d.description);
    }
    // select demo in GUI
    if (demo == null) {
        List<String> choices = new ArrayList<>();
        for (Demo d : Demo.values()) choices.add(d.description);
        ChoiceDialog<String> dialog = new ChoiceDialog<>(choices.get(Demo.defaultDemo), choices);
        dialog.setTitle(Zong.INSTANCE.getProjectFamilyName() + " Demos");
        dialog.setHeaderText("Please select a demo to run.");
        dialog.setContentText("Demo:");
        Optional<String> result = dialog.showAndWait();
        if (result.isPresent()) {
            int demoIndex = choices.indexOf(result.get());
            if (demoIndex > -1)
                demo = Demo.values()[demoIndex];
        }
    }
    if (demo == Demo.MinimalDemo) {
        MinimalDemo.main();
        Platform.exit();
    } else if (demo == Demo.SimpleGUIDemo) {
        SimpleGuiDemo.initZong();
        new SimpleGuiDemo().start(primaryStage);
    }
}
Also used : ChoiceDialog(javafx.scene.control.ChoiceDialog) MinimalDemo(com.xenoage.zong.demos.minimal.MinimalDemo) SimpleGuiDemo(com.xenoage.zong.demos.simplegui.SimpleGuiDemo) SimpleGuiDemo(com.xenoage.zong.demos.simplegui.SimpleGuiDemo) ArrayList(java.util.ArrayList)

Aggregations

MinimalDemo (com.xenoage.zong.demos.minimal.MinimalDemo)1 SimpleGuiDemo (com.xenoage.zong.demos.simplegui.SimpleGuiDemo)1 ArrayList (java.util.ArrayList)1 ChoiceDialog (javafx.scene.control.ChoiceDialog)1