use of com.faforever.client.notification.ImmediateNotification in project downlords-faf-client by FAForever.
the class ServerAccessorImplTest method testOnNotice.
@Test
public void testOnNotice() throws Exception {
connectAndLogIn();
NoticeMessage noticeMessage = new NoticeMessage();
noticeMessage.setText("foo bar");
noticeMessage.setStyle("warning");
when(i18n.get("messageFromServer")).thenReturn("Message from Server");
sendFromServer(noticeMessage);
ArgumentCaptor<ImmediateNotification> captor = ArgumentCaptor.forClass(ImmediateNotification.class);
verify(notificationService, timeout(1000)).addNotification(captor.capture());
ImmediateNotification notification = captor.getValue();
assertThat(notification.getSeverity(), is(Severity.WARN));
assertThat(notification.getText(), is("foo bar"));
assertThat(notification.getTitle(), is("Message from Server"));
verify(i18n).get("messageFromServer");
}
use of com.faforever.client.notification.ImmediateNotification in project downlords-faf-client by FAForever.
the class GameServiceImpl method startGame.
/**
* Actually starts the game, including relay and replay server. Call this method when everything else is prepared
* (mod/map download, connectivity check etc.)
*/
private void startGame(GameLaunchMessage gameLaunchMessage, Faction faction, RatingMode ratingMode) {
if (isRunning()) {
logger.warn("Forged Alliance is already running, not starting game");
return;
}
stopSearchLadder1v1();
replayService.startReplayServer(gameLaunchMessage.getUid()).thenCompose(aVoid -> iceAdapter.start()).thenAccept(adapterPort -> {
List<String> args = fixMalformedArgs(gameLaunchMessage.getArgs());
process = noCatch(() -> forgedAllianceService.startGame(gameLaunchMessage.getUid(), faction, args, ratingMode, adapterPort, clientProperties.getReplay().getLocalServerPort(), rehostRequested, getCurrentPlayer()));
setGameRunning(true);
this.ratingMode = ratingMode;
spawnTerminationListener(process);
}).exceptionally(throwable -> {
logger.warn("Game could not be started", throwable);
notificationService.addNotification(new ImmediateNotification(i18n.get("errorTitle"), i18n.get("game.start.couldNotStart"), ERROR, throwable, Arrays.asList(new ReportAction(i18n, reportingService, throwable), new DismissAction(i18n))));
setGameRunning(false);
return null;
});
}
use of com.faforever.client.notification.ImmediateNotification in project downlords-faf-client by FAForever.
the class CreateGameController method onCreateButtonClicked.
public void onCreateButtonClicked() {
ObservableList<ModVersion> selectedModVersions = modListView.getSelectionModel().getSelectedItems();
try {
modService.overrideActivatedMods(modListView.getSelectionModel().getSelectedItems());
} catch (IOException e) {
logger.warn("Activated mods could not be updated", e);
}
Set<String> simMods = selectedModVersions.stream().map(ModVersion::getUid).collect(Collectors.toSet());
NewGameInfo newGameInfo = new NewGameInfo(titleTextField.getText(), Strings.emptyToNull(passwordTextField.getText()), featuredModListView.getSelectionModel().getSelectedItem(), mapListView.getSelectionModel().getSelectedItem().getFolderName(), simMods);
gameService.hostGame(newGameInfo).exceptionally(throwable -> {
logger.warn("Game could not be hosted", throwable);
notificationService.addNotification(new ImmediateNotification(i18n.get("errorTitle"), i18n.get("game.create.failed"), Severity.WARN, throwable, Collections.singletonList(new ReportAction(i18n, reportingService, throwable))));
return null;
});
onCloseButtonClicked();
}
use of com.faforever.client.notification.ImmediateNotification 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));
}
}
use of com.faforever.client.notification.ImmediateNotification in project downlords-faf-client by FAForever.
the class GamePathHandler method onGameDirectoryChosenEvent.
/**
* Checks whether the chosen game path contains a ForgedAlliance.exe (either directly if the user selected the "bin"
* directory, or in the "bin" sub folder). If the path is valid, it is stored in the preferences.
*/
@Subscribe
public void onGameDirectoryChosenEvent(GameDirectoryChosenEvent event) {
Path path = event.getPath();
if (path == null || !Files.isDirectory(path)) {
notificationService.addNotification(new ImmediateNotification(i18n.get("gameChosen.invalidPath"), i18n.get("gameChosen.couldNotLocatedGame"), Severity.WARN));
return;
}
if (!Files.isRegularFile(path.resolve(PreferencesService.FORGED_ALLIANCE_EXE)) && !Files.isRegularFile(path.resolve(PreferencesService.SUPREME_COMMANDER_EXE))) {
onGameDirectoryChosenEvent(new GameDirectoryChosenEvent(path.resolve("bin")));
return;
}
// At this point, path points to the "bin" directory
Path gamePath = path.getParent();
logger.info("Found game path at {}", gamePath);
preferencesService.getPreferences().getForgedAlliance().setPath(gamePath);
preferencesService.storeInBackground();
}
Aggregations