Skip to content

Commit

Permalink
Native window behavior and design brush-up
Browse files Browse the repository at this point in the history
Fixes #1007
Fixes #1033
Fixes #1038
Fixes #1075
Fixes #1685
Fixes #1751
Fixes #1760
Fixes #1766
Fixes #1815
Fixes #1816
Fixes #1817
Fixes #1821
  • Loading branch information
micheljung committed Jul 10, 2020
1 parent 9cfd412 commit f5ff9bf
Show file tree
Hide file tree
Showing 141 changed files with 4,209 additions and 3,402 deletions.
4 changes: 4 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion .idea/runConfigurations/Main.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ env:
- secure: "UVIbeoJpx9n0KSWHbpdWZuR4zeZfXw3JQBq2Zb1h0/j4uREfXWiGFuNVQBPjsdtYi2+LkecjJ/MgKWo+SS0SjsvTa/ZPkOXt4408H1qYgwVnvWoeL/g1QQ6T8ADNysl/4ZtJLnSp0WXYEBkfHYZJD++vgDwkpVhnCLVzSFVAHls="

before_install:
- export JDK="openjdk11"
- export JDK="openjdk14"
#Installs the normal openjdk as this is not supported by travis itself
- chmod +x ./ci/installjdk.sh && sudo ./ci/installjdk.sh
- export JAVA_HOME="~/$JDK"
- export JAVA_TOOL_OPTIONS="-Dprism.verbose=true -Dprism.order=sw -Djava.library.path=$HOME/openjfx/javafx-sdk-11/lib"
- export JAVA_TOOL_OPTIONS="-Dprism.verbose=true -Dprism.order=sw -Djava.library.path=$HOME/openjfx/javafx-sdk-14/lib"
- export JAVA_TOOL_OPTIONS="-Dprism.verbose=true -Dprism.order=sw"
- export APP_VERSION=$([ -n "${TRAVIS_TAG}" ] && echo "${TRAVIS_TAG#*v}" || echo "${TRAVIS_BRANCH##*/}")
- export GITHUB_RELEASE_VERSION=$([ -n "${TRAVIS_TAG}" ] && echo "${TRAVIS_TAG}" || echo "${TRAVIS_BRANCH##*/}")
Expand Down Expand Up @@ -84,4 +84,4 @@ cache:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- /home/travis/build/FAForever/downlords-faf-client/build/cache/
- ~/openjdk11
- ~/openjdk14
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ apply plugin: 'propdeps'
apply plugin: 'distribution'


sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_14
targetCompatibility = JavaVersion.VERSION_14

// These are read from gradle.properties
version "${version}"
Expand Down Expand Up @@ -237,7 +237,6 @@ task sendCoverageToCodacy(type: JavaExec, dependsOn: jacocoTestReport) {
}

repositories {
mavenCentral()
jcenter()
maven { url "https://jitpack.io" }
maven { url 'https://maven.ej-technologies.com/repository' }
Expand Down Expand Up @@ -284,7 +283,8 @@ dependencies {
compile("javax.annotation:javax.annotation-api:1.3.1")
compile("com.github.ben-manes.caffeine:caffeine")
compile("org.apache.httpcomponents:httpclient")
compile("com.github.micheljung:FX-BorderlessScene:3.5.0")
compile("ch.micheljung.fxstage:fxstage:0.7.2")
compile("ch.micheljung.waitomo:jfx-waitomo-theme:0.2.0")

compile("org.openjfx:javafx-base:${javafxVersion}:${javafxPlatform}")
compile("org.openjfx:javafx-controls:${javafxVersion}:${javafxPlatform}")
Expand All @@ -300,7 +300,7 @@ dependencies {

provided("com.install4j:install4j-runtime:${install4jRuntimeVersion}")

testCompile 'junit:junit:4.11'
testCompile 'junit:junit:4.13'
testCompile("org.testfx:testfx-core:4.0.8-alpha") {
exclude module: 'guava'
}
Expand Down
2 changes: 1 addition & 1 deletion ci/installjdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ wget "$url" -P ~/bin/ || {
}
chmod +x ~/bin/install-jdk.sh
export JAVA_HOME="~/$JDK"
~/bin/install-jdk.sh --url "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7%2B10/OpenJDK11U-jdk_x64_linux_hotspot_11.0.7_10.tar.gz" --target "$JAVA_HOME" --workspace "$TRAVIS_HOME/.cache/install-jdk" --cacerts
~/bin/install-jdk.sh --url "https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14%2B36/OpenJDK14U-jdk_x64_linux_hotspot_14_36.tar.gz" --target "$JAVA_HOME" --workspace "$TRAVIS_HOME/.cache/install-jdk" --cacerts
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ javafxPlatform=unspecified
faf_ice_adapter_version=2.4.1
faf_uid_version=4.0.4
propdepsVersion=0.0.7
springBootVersion=2.1.6.RELEASE
springSecurityOauth2AutoconfigureVersion=2.1.6.RELEASE
springBootVersion=2.3.1.RELEASE
springSecurityOauth2AutoconfigureVersion=2.3.1.RELEASE
lombokVersion=1.18.12
fafCommonsVersion=0b83fa48a039cea085a7d462cc937fb5a035c186
jacksonDatatypeJsr310Version=2.9.7
qBuildersVersion=1.6
jSkillsVersion=8b333ec63d
jsonapiConverterVersion=0.9
install4jRuntimeVersion=7.0.7
jfoenixVersion=9.0.6
jfoenixVersion=9.0.10
javassist.version=3.23.1-GA
javafxVersion=11.0.2
coverallsGradlePluginVersion=2.10.1
Expand Down
19 changes: 12 additions & 7 deletions src/main/java/com/faforever/client/FafClientApplication.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.faforever.client;

import ch.micheljung.fxwindow.FxStage;
import com.faforever.client.config.ClientProperties;
import com.faforever.client.fx.JavaFxUtil;
import com.faforever.client.fx.PlatformService;
Expand All @@ -17,7 +18,6 @@
import javafx.scene.control.ButtonType;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.Banner.Mode;
import org.springframework.boot.builder.SpringApplicationBuilder;
Expand Down Expand Up @@ -100,9 +100,11 @@ public void init() {
@Override
public void start(Stage stage) {
StageHolder.setStage(stage);
stage.initStyle(StageStyle.UNDECORATED);
showMainWindow();
JavaFxUtil.fixJDK8089296();
FxStage fxStage = FxStage.configure(stage)
.withSceneFactory(parent -> applicationContext.getBean(UiService.class).createScene(parent))
.apply();

showMainWindow(fxStage);

// TODO publish event instead
if (!applicationContext.getBeansOfType(WindowsTaskbarProgressUpdater.class).isEmpty()) {
Expand All @@ -115,8 +117,11 @@ public PlatformService platformService() {
return new PlatformService(getHostServices());
}

private void showMainWindow() {
MainController controller = applicationContext.getBean(UiService.class).loadFxml("theme/main.fxml");
private void showMainWindow(FxStage fxStage) {
UiService uiService = applicationContext.getBean(UiService.class);

MainController controller = uiService.loadFxml("theme/main.fxml");
controller.setFxStage(fxStage);
controller.display();
}

Expand All @@ -127,7 +132,7 @@ public void stop() throws Exception {

Thread timeoutThread = new Thread(() -> {
try {
Thread.sleep(Duration.ofSeconds(30).toMillis());
Thread.sleep(Duration.ofSeconds(10).toMillis());
} catch (InterruptedException e) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@
import com.faforever.client.preferences.PreferencesService;
import com.faforever.client.replay.ReplayService;
import com.faforever.client.theme.UiService;
import com.faforever.client.ui.alert.Alert;
import com.faforever.client.ui.alert.animation.AlertAnimation;
import com.google.common.eventbus.EventBus;
import com.jfoenix.animation.alert.JFXAlertAnimation;
import com.jfoenix.controls.JFXAlert;
import com.jfoenix.controls.JFXButton;
import javafx.application.Platform;
import javafx.beans.binding.Bindings;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.WeakChangeListener;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.scene.control.Button;
import javafx.scene.control.ColorPicker;
import javafx.scene.control.ComboBox;
import javafx.scene.control.ContextMenu;
Expand All @@ -42,7 +42,6 @@
import javafx.scene.image.ImageView;
import javafx.scene.input.Clipboard;
import javafx.scene.input.ClipboardContent;
import javafx.stage.Stage;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -94,7 +93,7 @@ public class ChatUserContextMenuController implements Controller<ContextMenu> {
public MenuItem banItem;
public ContextMenu chatUserContextMenuRoot;
public MenuItem showUserInfo;
public JFXButton removeCustomColorButton;
public Button removeCustomColorButton;
private ChatChannelUser chatUser;
public MenuItem kickGameItem;
public MenuItem kickLobbyItem;
Expand Down Expand Up @@ -319,14 +318,14 @@ public void onInviteToGameSelected() {

public void onBan(ActionEvent actionEvent) {
actionEvent.consume();
JFXAlert<?> dialog = new JFXAlert<>((Stage) getRoot().getOwnerWindow());
Alert<?> dialog = new Alert<>(getRoot().getOwnerWindow());

BanDialogController controller = ((BanDialogController) uiService.loadFxml("theme/moderator/ban_dialog.fxml"))
.setPlayer(getPlayer())
.setCloseListener(dialog::close);

dialog.setContent(controller.getDialogLayout());
dialog.setAnimation(JFXAlertAnimation.TOP_ANIMATION);
dialog.setAnimation(AlertAnimation.TOP_ANIMATION);
dialog.show();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.faforever.client.chat;

import ch.micheljung.fxborderlessscene.borderless.BorderlessScene;
import ch.micheljung.fxwindow.FxStage;
import com.faforever.client.achievements.AchievementItemController;
import com.faforever.client.achievements.AchievementService;
import com.faforever.client.achievements.AchievementService.AchievementState;
Expand Down Expand Up @@ -31,6 +31,7 @@
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.PieChart;
Expand All @@ -47,7 +48,6 @@
import javafx.scene.layout.Region;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.stage.Window;
import javafx.util.StringConverter;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -109,7 +109,6 @@ public class UserInfoWindowController implements Controller<Node> {
public Label gamesPlayedLabel;
public Label ratingLabelGlobal;
public Label ratingLabel1v1;
public ImageView avatarImageView;
public Pane unlockedAchievementsHeader;
public Pane lockedAchievementsHeader;
public ScrollPane achievementsPane;
Expand All @@ -134,7 +133,7 @@ public class UserInfoWindowController implements Controller<Node> {
public TableColumn<NameRecord, String> nameColumn;
private Player player;
private Map<String, AchievementItemController> achievementItemById = new HashMap<>();
private Map<String, AchievementDefinition> achievementDefinitionById= new HashMap<>();
private Map<String, AchievementDefinition> achievementDefinitionById = new HashMap<>();
private Window ownerWindow;

private static boolean isUnlocked(PlayerAchievement playerAchievement) {
Expand Down Expand Up @@ -192,7 +191,6 @@ public void setPlayer(Player player) {

usernameLabel.setText(player.getUsername());
countryFlagService.loadCountryFlag(player.getCountry()).ifPresent(image -> countryImageView.setImage(image));
avatarImageView.setImage(IdenticonUtil.createIdenticon(player.getId()));
gamesPlayedLabel.setText(i18n.number(player.getNumberOfGames()));
ratingLabelGlobal.setText(i18n.number(RatingUtil.getGlobalRating(player)));
ratingLabel1v1.setText(i18n.number(RatingUtil.getLeaderboardRating(player)));
Expand Down Expand Up @@ -424,18 +422,21 @@ public void globalButtonClicked() {

public void show() {
Assert.checkNullIllegalState(ownerWindow, "ownerWindow must be set");
Stage userInfoWindow = new Stage(StageStyle.TRANSPARENT);
userInfoWindow.initModality(Modality.NONE);
userInfoWindow.initOwner(ownerWindow);

BorderlessScene scene = uiService.createScene(userInfoWindow, userInfoRoot);
userInfoWindow.setScene(scene);
userInfoWindow.show();
userInfoWindow.showingProperty().addListener((observable, oldValue, newValue) -> {
if(!newValue) {

FxStage fxStage = FxStage.create(userInfoRoot)
.initOwner(ownerWindow)
.initModality(Modality.WINDOW_MODAL)
.withSceneFactory(uiService::createScene)
.allowMinimize(false)
.apply();

Stage stage = fxStage.getStage();
stage.showingProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue) {
userInfoRoot.getChildren().clear();
}
});
stage.show();
}

public void setOwnerWindow(Window ownerWindow) {
Expand Down
50 changes: 50 additions & 0 deletions src/main/java/com/faforever/client/fx/IconCell.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.faforever.client.fx;

import com.faforever.client.theme.UiService;
import com.google.common.base.Strings;
import javafx.geometry.Pos;
import javafx.scene.control.TableCell;
import javafx.scene.layout.Region;
import lombok.RequiredArgsConstructor;

import java.util.function.Function;

public class IconCell<S, T> extends TableCell<S, T> {

private final Function<T, String> iconCssClassFunction;
private final Pos alignment;
private final String[] containerCssClasses;

public IconCell(Function<T, String> iconCssClassFunction) {
this(iconCssClassFunction, Pos.CENTER_LEFT);
}

public IconCell(Function<T, String> iconCssClassFunction, Pos alignment, String... containerCssClasses) {
this.iconCssClassFunction = iconCssClassFunction;
this.alignment = alignment;
this.containerCssClasses = containerCssClasses;
}

@Override
protected void updateItem(T item, boolean empty) {
super.updateItem(item, empty);

setText(null);
if (empty || item == null) {
setGraphic(null);
} else {
String cssClass = iconCssClassFunction.apply(item);
if (Strings.isNullOrEmpty(cssClass)) {
setGraphic(null);
return;
}

Region region = new Region();
region.getStyleClass().add(UiService.CSS_CLASS_ICON);
region.getStyleClass().add(cssClass);
setGraphic(region);
setAlignment(alignment);
getStyleClass().addAll(containerCssClasses);
}
}
}
16 changes: 0 additions & 16 deletions src/main/java/com/faforever/client/fx/JavaFxUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -391,22 +391,6 @@ public static void bindManagedToVisible(Node... nodes) {
Arrays.stream(nodes).forEach(node -> node.managedProperty().bind(node.visibleProperty()));
}


/**
* Uniconifies stages when clicking on the icon in the task bar. Source: http://stackoverflow.com/questions/26972683/javafx-minimizing-undecorated-stage
* Bug report: https://bugs.openjdk.java.net/browse/JDK-8089296
*/
public static void fixJDK8089296() {
if (!org.bridj.Platform.isWindows()) {
return;
}
Pointer lpVoid = getNativeWindow();
WinDef.HWND hwnd = new WinDef.HWND(lpVoid);
final User32 user32 = User32.INSTANCE;
int newStyle = user32.GetWindowLong(hwnd, GWL_STYLE) | 0x00020000; //WS_MINIMIZEBOX
user32.SetWindowLong(hwnd, GWL_STYLE, newStyle);
}

public static void assureRunOnMainThread(Runnable runnable) {
if (Platform.isFxApplicationThread()) {
runnable.run();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import com.faforever.client.theme.UiService;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings;
import com.jfoenix.controls.JFXButton;
import javafx.scene.control.Button;
import javafx.application.Platform;
import javafx.beans.binding.Bindings;
import javafx.collections.FXCollections;
Expand Down Expand Up @@ -104,7 +104,7 @@ public class CreateGameController implements Controller<Pane> {
public Pane mapPreviewPane;
public Label versionLabel;
public CheckBox onlyForFriendsCheckBox;
public JFXButton generateMapButton;
public Button generateMapButton;
@VisibleForTesting
FilteredList<MapBean> filteredMapBeans;
private Runnable onCloseButtonClickedListener;
Expand Down

0 comments on commit f5ff9bf

Please sign in to comment.