Search in sources :

Example 1 with ModVersion

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));
}
Also used : ModVersion(com.faforever.client.mod.ModVersion) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Example 2 with ModVersion

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();
}
Also used : ModVersion(com.faforever.client.mod.ModVersion) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) ReportAction(com.faforever.client.notification.ReportAction) IOException(java.io.IOException)

Example 3 with ModVersion

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());
    }
}
Also used : Path(java.nio.file.Path) ModVersion(com.faforever.client.mod.ModVersion) InputStream(java.io.InputStream)

Example 4 with ModVersion

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());
    }
}
Also used : Path(java.nio.file.Path) ModVersion(com.faforever.client.mod.ModVersion) InputStream(java.io.InputStream) ComparableVersion(org.apache.maven.artifact.versioning.ComparableVersion) BireusClient(net.brutus5000.bireus.BireusClient)

Aggregations

ModVersion (com.faforever.client.mod.ModVersion)4 InputStream (java.io.InputStream)2 Path (java.nio.file.Path)2 ImmediateNotification (com.faforever.client.notification.ImmediateNotification)1 ReportAction (com.faforever.client.notification.ReportAction)1 AbstractPlainJavaFxTest (com.faforever.client.test.AbstractPlainJavaFxTest)1 IOException (java.io.IOException)1 BireusClient (net.brutus5000.bireus.BireusClient)1 ComparableVersion (org.apache.maven.artifact.versioning.ComparableVersion)1 Test (org.junit.Test)1