Search in sources :

Example 1 with JMetro

use of jfxtras.styles.jmetro8.JMetro in project osumer by mob41.

the class AppMain method initRootLayout.

/**
 * Initializes the root layout.
 */
private void initRootLayout() {
    try {
        // Load root layout from fxml file.
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(AppMain.class.getResource("/view/RootLayout.fxml"));
        rootLayout = (BorderPane) loader.load();
        controller = loader.getController();
        controller.setDaemon(d);
        controller.setConfiguration(config);
        controller.setOsums(osums);
        controller.fetchQueues();
        // rootLayout.setStyle("-fx-background-color: #111;");
        // Show the scene containing the root layout.
        Scene scene = new Scene(rootLayout);
        primaryStage.setScene(scene);
        primaryStage.show();
        String skin = config.getUiSkin();
        new JMetro(skin.equals("light") ? JMetro.Style.LIGHT : JMetro.Style.DARK).applyTheme(scene);
        scene.getStylesheets().add(getClass().getResource("/css/application.css").toExternalForm());
    } catch (IOException e) {
        e.printStackTrace();
        DumpManager.addDump(new DebugDump(null, "(Method Start)", "Initialize root layout for UI", "(Method End)", "Could not initialize root layout", false, e));
        Alert alert = new Alert(AlertType.ERROR, "Could not initialize root layout, check dumps for details:\n" + e, ButtonType.OK);
        alert.setHeaderText("osumer UI Layout Error");
        alert.showAndWait();
        DumpManager.forceMetricsReport();
        Platform.exit();
        System.exit(-1);
        return;
    }
}
Also used : Alert(javafx.scene.control.Alert) IOException(java.io.IOException) Scene(javafx.scene.Scene) JMetro(jfxtras.styles.jmetro8.JMetro) FXMLLoader(javafx.fxml.FXMLLoader) DebugDump(com.github.mob41.osumer.debug.DebugDump)

Example 2 with JMetro

use of jfxtras.styles.jmetro8.JMetro in project osumer by mob41.

the class MainController method initialize.

@Override
public void initialize(URL location, ResourceBundle resources) {
    beatmapDwnBtn.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            boolean showPreview = showPreviewCheckbox.isSelected();
            String idUrl = beatmapUrlText.getText();
            if (idUrl == null || idUrl.isEmpty()) {
                Alert alert = new Alert(AlertType.WARNING, "Please enter a valid osu! beatmap link/ID.", ButtonType.OK);
                alert.showAndWait();
                return;
            }
            addQueue(idUrl, showPreview, true);
        }
    });
    preferencesMenuItem.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            FXMLLoader loader = new FXMLLoader();
            loader.setLocation(AppMain.class.getResource("/view/PreferencesLayout.fxml"));
            BorderPane borderPane = null;
            try {
                borderPane = (BorderPane) loader.load();
            } catch (IOException e) {
                e.printStackTrace();
            }
            PreferencesController controller = loader.getController();
            controller.setD(d);
            controller.setConfig(config);
            controller.restore();
            Scene scene = new Scene(borderPane);
            String skin = config.getUiSkin();
            new JMetro(skin.equals("light") ? JMetro.Style.LIGHT : JMetro.Style.DARK).applyTheme(scene);
            Stage stage = new Stage();
            stage.setScene(scene);
            // stage.setTitle("Preferences");
            stage.initStyle(StageStyle.UTILITY);
            stage.initModality(Modality.APPLICATION_MODAL);
            stage.showAndWait();
        }
    });
    updatesMenuItem.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            checkUpdate();
            checkAnnouncements();
        }
    });
    locateConfigMenuItem.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            String configPath = Osumer.isWindows() ? System.getenv("localappdata") + "\\osumerExpress" : "";
            try {
                Desktop.getDesktop().open(new File(configPath));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    dumpsMenuItem.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            String dumpPath = Osumer.isWindows() ? System.getenv("localappdata") + "\\osumerExpress\\dumps" : "";
            File folder = new File(dumpPath);
            if (!folder.exists()) {
                Alert alert = new Alert(AlertType.ERROR, "There are no dumps currently.", ButtonType.OK);
                alert.showAndWait();
                return;
            }
            try {
                Desktop.getDesktop().open(folder);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    closeMenuItem.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            Platform.exit();
        }
    });
    exitMenuItem.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            try {
                d.shutdown();
                d = null;
            } catch (RemoteException e) {
            // e.printStackTrace();
            // Alert alert = new Alert(AlertType.ERROR, "Could not shutdown daemon. Please do this manually in task manager by terminating Java VM.", ButtonType.OK);
            // alert.showAndWait();
            }
            Platform.exit();
        }
    });
    docsMenuItem.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            try {
                Desktop.getDesktop().browse(new URI("https://github.com/mob41/osumer/wiki"));
                ;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    issueMenuItem.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            try {
                Desktop.getDesktop().browse(new URI("https://github.com/mob41/osumer/issues/new"));
                ;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    aboutMenuItem.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            Alert alert = new Alert(AlertType.NONE, "", ButtonType.OK);
            alert.setHeaderText("About");
            alert.setContentText("osumer2 (" + Osumer.getVersionString() + ")\n" + "Copyright (c) mob41. 2016-2020\n\n" + "osumer is an application that provides osu! players a\n" + "more comfortable and faster way to download beatmaps.");
            alert.showAndWait();
        }
    });
}
Also used : BorderPane(javafx.scene.layout.BorderPane) ActionEvent(javafx.event.ActionEvent) IOException(java.io.IOException) Scene(javafx.scene.Scene) FXMLLoader(javafx.fxml.FXMLLoader) URI(java.net.URI) NoBuildsForVersionException(com.github.mob41.osumer.exceptions.NoBuildsForVersionException) RemoteException(java.rmi.RemoteException) MalformedURLException(java.net.MalformedURLException) NoSuchVersionException(com.github.mob41.osumer.exceptions.NoSuchVersionException) IOException(java.io.IOException) NoSuchBuildNumberException(com.github.mob41.osumer.exceptions.NoSuchBuildNumberException) WithDumpException(com.github.mob41.osumer.debug.WithDumpException) Stage(javafx.stage.Stage) Alert(javafx.scene.control.Alert) JMetro(jfxtras.styles.jmetro8.JMetro) RemoteException(java.rmi.RemoteException) File(java.io.File)

Aggregations

IOException (java.io.IOException)2 FXMLLoader (javafx.fxml.FXMLLoader)2 Scene (javafx.scene.Scene)2 Alert (javafx.scene.control.Alert)2 JMetro (jfxtras.styles.jmetro8.JMetro)2 DebugDump (com.github.mob41.osumer.debug.DebugDump)1 WithDumpException (com.github.mob41.osumer.debug.WithDumpException)1 NoBuildsForVersionException (com.github.mob41.osumer.exceptions.NoBuildsForVersionException)1 NoSuchBuildNumberException (com.github.mob41.osumer.exceptions.NoSuchBuildNumberException)1 NoSuchVersionException (com.github.mob41.osumer.exceptions.NoSuchVersionException)1 File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 URI (java.net.URI)1 RemoteException (java.rmi.RemoteException)1 ActionEvent (javafx.event.ActionEvent)1 BorderPane (javafx.scene.layout.BorderPane)1 Stage (javafx.stage.Stage)1