Skip to content

Commit

Permalink
Overhaul Client State Handling (#3050)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheikah45 authored Nov 30, 2023
1 parent 7e39b73 commit 395201e
Show file tree
Hide file tree
Showing 336 changed files with 5,458 additions and 4,904 deletions.
6 changes: 6 additions & 0 deletions .idea/codeStyles/Project.xml

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

9 changes: 9 additions & 0 deletions .idea/vcs.xml

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

43 changes: 21 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ apply plugin: 'io.spring.dependency-management'
// source: https://github.com/mendhak/Gradle-Travis-Colored-Output/blob/master/ColoredOutput.gradle
tasks.withType(Test).configureEach {

String ANSI_BOLD_WHITE = "\u001B[0;1m";
String ANSI_RESET = "\u001B[0m";
String ANSI_BLACK = "\u001B[30m";
String ANSI_RED = "\u001B[31m";
String ANSI_GREEN = "\u001B[32m";
String ANSI_YELLOW = "\u001B[33m";
String ANSI_BLUE = "\u001B[34m";
String ANSI_PURPLE = "\u001B[35m";
String ANSI_CYAN = "\u001B[36m";
String ANSI_WHITE = "\u001B[37m";
String CHECK_MARK = "\u2713";
String NEUTRAL_FACE = "\u0CA0_\u0CA0";
String X_MARK = "\u274C";
String indent = '\t';
String ANSI_BOLD_WHITE = "\u001B[0;1m"
String ANSI_RESET = "\u001B[0m"
String ANSI_BLACK = "\u001B[30m"
String ANSI_RED = "\u001B[31m"
String ANSI_GREEN = "\u001B[32m"
String ANSI_YELLOW = "\u001B[33m"
String ANSI_BLUE = "\u001B[34m"
String ANSI_PURPLE = "\u001B[35m"
String ANSI_CYAN = "\u001B[36m"
String ANSI_WHITE = "\u001B[37m"
String CHECK_MARK = "\u2713"
String NEUTRAL_FACE = "\u0CA0_\u0CA0"
String X_MARK = "\u274C"
String indent = '\t'

def outputCache = new HashMap<TestDescriptor, List<String>>()

Expand Down Expand Up @@ -71,21 +71,21 @@ tasks.withType(Test).configureEach {

switch (result.resultType) {
case TestResult.ResultType.SUCCESS:
summaryStyle = ANSI_GREEN;
break;
summaryStyle = ANSI_GREEN
break
case TestResult.ResultType.FAILURE:
summaryStyle = ANSI_RED;
break;
summaryStyle = ANSI_RED
break
}

out.println("--------------------------------------------------------------------------");
out.println("--------------------------------------------------------------------------")
out.println("Results: " + summaryStyle + " ${result.resultType} " + ANSI_RESET
+ " (${result.testCount} tests, "
+ ANSI_GREEN + " ${result.successfulTestCount} passed " + ANSI_RESET
+ ", " + failStyle + " ${result.failedTestCount} failed " + ANSI_RESET
+ ", " + skipStyle + " ${result.skippedTestCount} skipped " + ANSI_RESET
+ ")");
out.println("--------------------------------------------------------------------------");
+ ")")
out.println("--------------------------------------------------------------------------")
}
}
}
Expand Down Expand Up @@ -357,7 +357,6 @@ dependencies {
testImplementation("org.testfx:testfx-junit5:4.0.17")
testImplementation("com.natpryce.hamcrest:hamcrest-reflection:0.1-2")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.testfx:openjfx-monocle:jdk-12.0.1+2")

annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
annotationProcessor("org.projectlombok:lombok")
Expand Down
1 change: 1 addition & 0 deletions src/lombok.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ lombok.accessors.chain=true
config.stopBubbling=true
lombok.anyConstructor.addConstructorProperties=true
lombok.copyableAnnotations+=org.springframework.beans.factory.annotation.Qualifier
lombok.copyableannotations+=org.springframework.context.annotation.Lazy
4 changes: 3 additions & 1 deletion src/main/java/com/faforever/client/FafClientApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.faforever.client.notification.NotificationService;
import com.faforever.client.notification.Severity;
import com.faforever.client.svg.SvgImageLoaderFactory;
import com.faforever.client.theme.ThemeService;
import com.faforever.client.theme.UiService;
import com.faforever.client.ui.StageHolder;
import com.faforever.client.ui.taskbar.WindowsTaskbarProgressUpdater;
Expand Down Expand Up @@ -62,7 +63,8 @@ public void start(Stage stage) {
try {
StageHolder.setStage(stage);
FxStage fxStage = FxStage.configure(stage)
.withSceneFactory(parent -> applicationContext.getBean(UiService.class).createScene(parent))
.withSceneFactory(
parent -> applicationContext.getBean(ThemeService.class).createScene(parent))
.apply();

fxStage.getStage().setOnCloseRequest(this::closeMainWindow);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.faforever.client.achievements;

import com.faforever.client.fx.Controller;
import com.faforever.client.fx.FxApplicationThreadExecutor;
import com.faforever.client.fx.NodeController;
import com.faforever.client.i18n.I18n;
import com.faforever.client.util.Assert;
import com.faforever.commons.api.dto.AchievementDefinition;
Expand All @@ -24,7 +24,7 @@
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
@RequiredArgsConstructor
// TODO this class should not use API objects
public class AchievementItemController implements Controller<Node> {
public class AchievementItemController extends NodeController<Node> {

private final I18n i18n;
private final AchievementService achievementService;
Expand All @@ -39,11 +39,13 @@ public class AchievementItemController implements Controller<Node> {
public ImageView imageView;
private AchievementDefinition achievementDefinition;

public void initialize() {
@Override
protected void onInitialize() {
progressBar.managedProperty().bind(progressBar.visibleProperty());
progressLabel.managedProperty().bind(progressLabel.visibleProperty());
}

@Override
public Node getRoot() {
return achievementItemRoot;
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/faforever/client/api/IceServer.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
package com.faforever.client.api;

public record IceServer(String id, String region) {
}
public record IceServer(String id, String region) {}
6 changes: 3 additions & 3 deletions src/main/java/com/faforever/client/audio/AudioService.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.faforever.client.audio;

import com.faforever.client.preferences.NotificationPrefs;
import com.faforever.client.theme.UiService;
import com.faforever.client.theme.ThemeService;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.scene.media.AudioClip;
Expand Down Expand Up @@ -30,7 +30,7 @@ public class AudioService implements InitializingBean {
private static final long MILLISECONDS_SILENT_AFTER_SOUND = 30000;

private final AudioClipPlayer audioClipPlayer;
private final UiService uiService;
private final ThemeService themeService;
private final NotificationPrefs notificationPrefs;

private final BooleanProperty playSounds = new SimpleBooleanProperty();
Expand Down Expand Up @@ -69,7 +69,7 @@ private void loadSounds() throws IOException {
}

private AudioClip loadSound(String sound) throws IOException {
return new AudioClip(uiService.getThemeFileUrl(sound).toString());
return new AudioClip(themeService.getThemeFileUrl(sound).toString());
}


Expand Down
15 changes: 4 additions & 11 deletions src/main/java/com/faforever/client/avatar/AvatarService.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package com.faforever.client.avatar;

import com.faforever.client.avatar.event.AvatarChangedEvent;
import com.faforever.client.domain.AvatarBean;
import com.faforever.client.mapstruct.AvatarMapper;
import com.faforever.client.mapstruct.CycleAvoidingMappingContext;
import com.faforever.client.player.PlayerService;
import com.faforever.client.remote.AssetService;
import com.faforever.client.remote.FafServerAccessor;
import com.google.common.eventbus.EventBus;
import javafx.scene.image.Image;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
Expand All @@ -23,11 +21,11 @@
@Lazy
@Service
@RequiredArgsConstructor
public class AvatarService implements InitializingBean {
public class AvatarService {

private final FafServerAccessor fafServerAccessor;
private final AssetService assetService;
private final EventBus eventBus;
private final PlayerService playerService;
private final AvatarMapper avatarMapper;

@Cacheable(value = AVATARS, sync = true)
Expand All @@ -45,11 +43,6 @@ public CompletableFuture<List<AvatarBean>> getAvailableAvatars() {

public void changeAvatar(AvatarBean avatar) {
fafServerAccessor.selectAvatar(avatar.getUrl());
eventBus.post(new AvatarChangedEvent(avatar));
}

@Override
public void afterPropertiesSet() throws Exception {
eventBus.register(this);
playerService.getCurrentPlayer().setAvatar(avatar);
}
}
Loading

0 comments on commit 395201e

Please sign in to comment.