use of com.faforever.client.mod.ModVersion in project downlords-faf-client by FAForever.
the class CreateGameControllerTest method testInitModListPopulated.
@Test
public void testInitModListPopulated() {
assertThat(instance.modListView.getItems(), empty());
ModVersion modVersion1 = mock(ModVersion.class);
ModVersion modVersion2 = mock(ModVersion.class);
when(modService.getInstalledModVersions()).thenReturn(FXCollections.observableArrayList(modVersion1, modVersion2));
WaitForAsyncUtils.asyncFx(() -> instance.initialize());
WaitForAsyncUtils.waitForFxEvents();
assertThat(instance.modListView.getItems(), hasSize(2));
assertThat(instance.modListView.getItems(), contains(modVersion1, modVersion2));
}
use of com.faforever.client.mod.ModVersion 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.mod.ModVersion in project downlords-faf-client by FAForever.
the class GitFeaturedModUpdateTaskImpl method call.
@Override
protected PatchResult call() throws Exception {
logger.info("Updating game files from {}@{}", gameRepositoryUrl, ref);
updateTitle(i18n.get("updater.taskTitle"));
checkout(repositoryDirectory, gameRepositoryUrl, ref);
Path modInfoLuaFile = repositoryDirectory.resolve("mod_info.lua");
if (Files.notExists(modInfoLuaFile)) {
throw new IllegalStateException("Could not find " + modInfoLuaFile.toAbsolutePath());
}
try (InputStream inputStream = Files.newInputStream(modInfoLuaFile)) {
ModVersion modVersion = modService.extractModInfo(inputStream, repositoryDirectory);
return PatchResult.fromModInfo(modService.readModVersion(repositoryDirectory), modVersion.getMountInfos(), modVersion.getHookDirectories());
}
}
use of com.faforever.client.mod.ModVersion in project downlords-faf-client by FAForever.
the class BireusFeaturedModUpdateTask method call.
@Override
protected PatchResult call() throws Exception {
String repoDirName = featuredMod.getBireusUrl().toString().replaceAll(NON_WORD_CHARACTER_PATTERN, "");
Path repositoryPath = preferencesService.getPatchReposDirectory().resolve(repoDirName);
ResourceLocks.acquireDiskLock();
try {
BireusClient bireusClient = initBireus(repositoryPath);
if (version == null) {
bireusClient.checkoutLatestVersion();
} else {
bireusClient.checkoutVersion(String.valueOf(version));
}
} finally {
ResourceLocks.freeDiskLock();
}
Path modInfoLuaFile = repositoryPath.resolve(MOD_INFO_LUA);
// Older versions do not have a mod info file. Their init file can't be generated, so we require the mod to provide its own
if (!Files.exists(modInfoLuaFile)) {
Path initFile = repositoryPath.resolve("bin/init_" + featuredMod.getTechnicalName() + ".lua");
Assert.isTrue(Files.exists(initFile), "Neither '" + MOD_INFO_LUA + "' nor '" + initFile.getFileName() + "' could be found.");
return PatchResult.withLegacyInitFile(new ComparableVersion(checkedOutVersion), initFile);
}
try (InputStream inputStream = Files.newInputStream(modInfoLuaFile)) {
ModVersion modVersion = modService.extractModInfo(inputStream, repositoryPath);
return PatchResult.fromModInfo(modService.readModVersion(repositoryPath), modVersion.getMountInfos(), modVersion.getHookDirectories());
}
}
Aggregations