Search in sources :

Example 1 with ProgrammingError

use of com.faforever.client.util.ProgrammingError in project downlords-faf-client by FAForever.

the class OnGameFullNotifier method onGameFull.

@Subscribe
public void onGameFull(GameFullEvent event) {
    executor.execute(() -> {
        platformService.startFlashingWindow(faWindowTitle);
        while (gameService.isGameRunning() && !platformService.isWindowFocused(faWindowTitle)) {
            noCatch(() -> sleep(500));
        }
        platformService.stopFlashingWindow(faWindowTitle);
    });
    Game currentGame = gameService.getCurrentGame();
    if (currentGame == null) {
        throw new ProgrammingError("Got a GameFull notification but player is not in a game");
    }
    if (platformService.isWindowFocused(faWindowTitle)) {
        return;
    }
    notificationService.addNotification(new TransientNotification(i18n.get("game.full"), i18n.get("game.full.action"), mapService.loadPreview(currentGame.getMapFolderName(), PreviewSize.SMALL), v -> platformService.focusWindow(faWindowTitle)));
}
Also used : TransientNotification(com.faforever.client.notification.TransientNotification) ClientProperties(com.faforever.client.config.ClientProperties) GameService(com.faforever.client.game.GameService) GameFullEvent(com.faforever.client.fa.relay.event.GameFullEvent) ProgrammingError(com.faforever.client.util.ProgrammingError) Executor(java.util.concurrent.Executor) PreviewSize(com.faforever.client.map.MapServiceImpl.PreviewSize) PlatformService(com.faforever.client.fx.PlatformService) TransientNotification(com.faforever.client.notification.TransientNotification) EventBus(com.google.common.eventbus.EventBus) Inject(javax.inject.Inject) NotificationService(com.faforever.client.notification.NotificationService) Component(org.springframework.stereotype.Component) PostConstruct(javax.annotation.PostConstruct) Thread.sleep(java.lang.Thread.sleep) Subscribe(com.google.common.eventbus.Subscribe) I18n(com.faforever.client.i18n.I18n) MapService(com.faforever.client.map.MapService) NoCatch.noCatch(com.github.nocatch.NoCatch.noCatch) Game(com.faforever.client.game.Game) Game(com.faforever.client.game.Game) ProgrammingError(com.faforever.client.util.ProgrammingError) Subscribe(com.google.common.eventbus.Subscribe)

Example 2 with ProgrammingError

use of com.faforever.client.util.ProgrammingError in project downlords-faf-client by FAForever.

the class GameUpdaterImpl method copyLegacyInitFile.

@SneakyThrows
private void copyLegacyInitFile(List<PatchResult> patchResults) {
    Path initFile = patchResults.stream().map(PatchResult::getLegacyInitFile).filter(Objects::nonNull).findFirst().orElseThrow(() -> new ProgrammingError("No legacy init file is available"));
    Files.copy(initFile, initFile.resolveSibling(ForgedAlliancePrefs.INIT_FILE_NAME), StandardCopyOption.REPLACE_EXISTING);
}
Also used : Path(java.nio.file.Path) Objects(java.util.Objects) ProgrammingError(com.faforever.client.util.ProgrammingError) SneakyThrows(lombok.SneakyThrows)

Aggregations

ProgrammingError (com.faforever.client.util.ProgrammingError)2 ClientProperties (com.faforever.client.config.ClientProperties)1 GameFullEvent (com.faforever.client.fa.relay.event.GameFullEvent)1 PlatformService (com.faforever.client.fx.PlatformService)1 Game (com.faforever.client.game.Game)1 GameService (com.faforever.client.game.GameService)1 I18n (com.faforever.client.i18n.I18n)1 MapService (com.faforever.client.map.MapService)1 PreviewSize (com.faforever.client.map.MapServiceImpl.PreviewSize)1 NotificationService (com.faforever.client.notification.NotificationService)1 TransientNotification (com.faforever.client.notification.TransientNotification)1 NoCatch.noCatch (com.github.nocatch.NoCatch.noCatch)1 EventBus (com.google.common.eventbus.EventBus)1 Subscribe (com.google.common.eventbus.Subscribe)1 Thread.sleep (java.lang.Thread.sleep)1 Path (java.nio.file.Path)1 Objects (java.util.Objects)1 Executor (java.util.concurrent.Executor)1 PostConstruct (javax.annotation.PostConstruct)1 Inject (javax.inject.Inject)1