Search in sources :

Example 1 with MissingGamePathEvent

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

the class MissingGamePathNotifierTest method testPersistentNotificationOnDefaultEvent.

@Test
public void testPersistentNotificationOnDefaultEvent() {
    eventBus.post(new MissingGamePathEvent());
    verify(notificationService).addNotification(any(PersistentNotification.class));
}
Also used : MissingGamePathEvent(com.faforever.client.preferences.event.MissingGamePathEvent) PersistentNotification(com.faforever.client.notification.PersistentNotification) Test(org.junit.Test)

Example 2 with MissingGamePathEvent

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

the class MissingGamePathNotifier method onMissingGamePathEvent.

@Subscribe
public void onMissingGamePathEvent(MissingGamePathEvent event) {
    List<Action> actions = Collections.singletonList(new Action(i18n.get("missingGamePath.locate"), chooseEvent -> eventBus.post(new GameDirectoryChooseEvent())));
    String notificationText = i18n.get("missingGamePath.notification");
    if (event.isImmediateUserActionRequired()) {
        notificationService.addNotification(new ImmediateNotification(notificationText, notificationText, Severity.WARN, actions));
    } else {
        notificationService.addNotification(new PersistentNotification(notificationText, Severity.WARN, actions));
    }
}
Also used : Action(com.faforever.client.notification.Action) PersistentNotification(com.faforever.client.notification.PersistentNotification) MissingGamePathEvent(com.faforever.client.preferences.event.MissingGamePathEvent) EventBus(com.google.common.eventbus.EventBus) Inject(javax.inject.Inject) NotificationService(com.faforever.client.notification.NotificationService) Component(org.springframework.stereotype.Component) List(java.util.List) Severity(com.faforever.client.notification.Severity) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) PostConstruct(javax.annotation.PostConstruct) GameDirectoryChooseEvent(com.faforever.client.ui.preferences.event.GameDirectoryChooseEvent) Subscribe(com.google.common.eventbus.Subscribe) I18n(com.faforever.client.i18n.I18n) Collections(java.util.Collections) Action(com.faforever.client.notification.Action) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) GameDirectoryChooseEvent(com.faforever.client.ui.preferences.event.GameDirectoryChooseEvent) PersistentNotification(com.faforever.client.notification.PersistentNotification) Subscribe(com.google.common.eventbus.Subscribe)

Example 3 with MissingGamePathEvent

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

the class Ladder1v1Controller method onPlayButtonClicked.

public void onPlayButtonClicked() {
    if (preferencesService.getPreferences().getForgedAlliance().getPath() == null) {
        eventBus.post(new MissingGamePathEvent(true));
        return;
    }
    setFactionButtonsDisabled(true);
    ObservableList<Faction> factions = preferencesService.getPreferences().getLadder1v1Prefs().getFactions();
    Faction randomFaction = factions.get(random.nextInt(factions.size()));
    gameService.startSearchLadder1v1(randomFaction);
}
Also used : MissingGamePathEvent(com.faforever.client.preferences.event.MissingGamePathEvent) Faction(com.faforever.client.game.Faction)

Example 4 with MissingGamePathEvent

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

the class MissingGamePathNotifierTest method testImmediateNotificationOnUrgentEvent.

@Test
public void testImmediateNotificationOnUrgentEvent() {
    eventBus.post(new MissingGamePathEvent(true));
    verify(notificationService).addNotification(any(ImmediateNotification.class));
}
Also used : ImmediateNotification(com.faforever.client.notification.ImmediateNotification) MissingGamePathEvent(com.faforever.client.preferences.event.MissingGamePathEvent) Test(org.junit.Test)

Example 5 with MissingGamePathEvent

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

the class GamePathHandler method detectGamePath.

private void detectGamePath() {
    for (Path path : USUAL_GAME_PATHS) {
        if (preferencesService.isGamePathValid(path.resolve("bin"))) {
            onGameDirectoryChosenEvent(new GameDirectoryChosenEvent(path));
            return;
        }
    }
    logger.info("Game path could not be detected");
    eventBus.post(new MissingGamePathEvent());
}
Also used : Path(java.nio.file.Path) GameDirectoryChosenEvent(com.faforever.client.ui.preferences.event.GameDirectoryChosenEvent) MissingGamePathEvent(com.faforever.client.preferences.event.MissingGamePathEvent)

Aggregations

MissingGamePathEvent (com.faforever.client.preferences.event.MissingGamePathEvent)6 Test (org.junit.Test)3 ImmediateNotification (com.faforever.client.notification.ImmediateNotification)2 PersistentNotification (com.faforever.client.notification.PersistentNotification)2 Faction (com.faforever.client.game.Faction)1 I18n (com.faforever.client.i18n.I18n)1 Action (com.faforever.client.notification.Action)1 NotificationService (com.faforever.client.notification.NotificationService)1 Severity (com.faforever.client.notification.Severity)1 AbstractPlainJavaFxTest (com.faforever.client.test.AbstractPlainJavaFxTest)1 GameDirectoryChooseEvent (com.faforever.client.ui.preferences.event.GameDirectoryChooseEvent)1 GameDirectoryChosenEvent (com.faforever.client.ui.preferences.event.GameDirectoryChosenEvent)1 EventBus (com.google.common.eventbus.EventBus)1 Subscribe (com.google.common.eventbus.Subscribe)1 Path (java.nio.file.Path)1 Collections (java.util.Collections)1 List (java.util.List)1 PostConstruct (javax.annotation.PostConstruct)1 Inject (javax.inject.Inject)1 Component (org.springframework.stereotype.Component)1