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();
}
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();
}
});
}
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));
}
Aggregations