Search in sources :

Example 1 with WindowPrefs

use of com.faforever.client.preferences.WindowPrefs in project downlords-faf-client by FAForever.

the class MainController method display.

public void display() {
    eventBus.post(UpdateApplicationBadgeEvent.ofNewValue(0));
    Stage stage = StageHolder.getStage();
    windowController.configure(stage, mainRoot, true, MINIMIZE, MAXIMIZE_RESTORE, CLOSE);
    final WindowPrefs mainWindowPrefs = preferencesService.getPreferences().getMainWindow();
    double x = mainWindowPrefs.getX();
    double y = mainWindowPrefs.getY();
    int width = mainWindowPrefs.getWidth();
    int height = mainWindowPrefs.getHeight();
    stage.setWidth(width);
    stage.setHeight(height);
    stage.show();
    noCatch(SplashScreen::hide);
    enterLoggedOutState();
    ObservableList<Screen> screensForRectangle = Screen.getScreensForRectangle(x, y, width, height);
    if (screensForRectangle.isEmpty()) {
        JavaFxUtil.centerOnScreen(stage);
    } else {
        stage.setX(x);
        stage.setY(y);
    }
    if (mainWindowPrefs.getMaximized()) {
        WindowController.maximize(stage);
    }
    registerWindowListeners();
}
Also used : WindowPrefs(com.faforever.client.preferences.WindowPrefs) Screen(javafx.stage.Screen) SplashScreen(com.install4j.api.launcher.SplashScreen) Stage(javafx.stage.Stage) SplashScreen(com.install4j.api.launcher.SplashScreen)

Example 2 with WindowPrefs

use of com.faforever.client.preferences.WindowPrefs in project downlords-faf-client by FAForever.

the class MainController method registerWindowListeners.

private void registerWindowListeners() {
    Stage stage = StageHolder.getStage();
    final WindowPrefs mainWindowPrefs = preferencesService.getPreferences().getMainWindow();
    stage.maximizedProperty().addListener((observable, oldValue, newValue) -> {
        if (!newValue) {
            stage.setWidth(mainWindowPrefs.getWidth());
            stage.setHeight(mainWindowPrefs.getHeight());
            ObservableList<Screen> screensForRectangle = Screen.getScreensForRectangle(mainWindowPrefs.getX(), mainWindowPrefs.getY(), mainWindowPrefs.getWidth(), mainWindowPrefs.getHeight());
            if (screensForRectangle.isEmpty()) {
                JavaFxUtil.centerOnScreen(stage);
            } else {
                stage.setX(mainWindowPrefs.getX());
                stage.setY(mainWindowPrefs.getY());
            }
        }
        mainWindowPrefs.setMaximized(newValue);
        preferencesService.storeInBackground();
    });
    stage.heightProperty().addListener((observable, oldValue, newValue) -> {
        if (!stage.isMaximized()) {
            mainWindowPrefs.setHeight(newValue.intValue());
            preferencesService.storeInBackground();
        }
    });
    stage.widthProperty().addListener((observable, oldValue, newValue) -> {
        if (!stage.isMaximized()) {
            mainWindowPrefs.setWidth(newValue.intValue());
            preferencesService.storeInBackground();
        }
    });
    stage.xProperty().addListener(observable -> {
        if (!stage.isMaximized()) {
            mainWindowPrefs.setX(stage.getX());
            preferencesService.storeInBackground();
        }
    });
    stage.yProperty().addListener(observable -> {
        if (!stage.isMaximized()) {
            mainWindowPrefs.setY(stage.getY());
            preferencesService.storeInBackground();
        }
    });
}
Also used : WindowPrefs(com.faforever.client.preferences.WindowPrefs) Screen(javafx.stage.Screen) SplashScreen(com.install4j.api.launcher.SplashScreen) Stage(javafx.stage.Stage)

Example 3 with WindowPrefs

use of com.faforever.client.preferences.WindowPrefs in project downlords-faf-client by FAForever.

the class MainController method restoreLastView.

private void restoreLastView() {
    final NavigationItem navigationItem;
    if (preferencesService.getPreferences().getRememberLastTab()) {
        final WindowPrefs mainWindowPrefs = preferencesService.getPreferences().getMainWindow();
        navigationItem = Optional.ofNullable(NavigationItem.fromString(mainWindowPrefs.getLastView())).orElse(NavigationItem.NEWS);
    } else {
        navigationItem = NavigationItem.NEWS;
    }
    eventBus.post(new NavigateEvent(navigationItem));
}
Also used : NavigationItem(com.faforever.client.main.event.NavigationItem) WindowPrefs(com.faforever.client.preferences.WindowPrefs) NavigateEvent(com.faforever.client.main.event.NavigateEvent)

Aggregations

WindowPrefs (com.faforever.client.preferences.WindowPrefs)3 SplashScreen (com.install4j.api.launcher.SplashScreen)2 Screen (javafx.stage.Screen)2 Stage (javafx.stage.Stage)2 NavigateEvent (com.faforever.client.main.event.NavigateEvent)1 NavigationItem (com.faforever.client.main.event.NavigationItem)1