Search in sources :

Example 1 with Version

use of net.technicpack.launchercore.install.Version in project LauncherV3 by TechnicPack.

the class ModpackBanner method setModpack.

public void setModpack(ModpackModel modpack) {
    currentModpack = modpack;
    modpackName.setText(modpack.getDisplayName());
    modpackOptions.setVisible(!modpack.isLocalOnly() || modpack.getInstalledVersion() != null);
    Version packVersion = modpack.getInstalledVersion();
    if (packVersion == null) {
        updateReady.setVisible(false);
        versionText.setVisible(false);
        installedVersion.setVisible(false);
    } else {
        updateReady.setVisible(modpack.hasRecommendedUpdate());
        versionText.setVisible(true);
        installedVersion.setVisible(true);
        installedVersion.setText(packVersion.getVersion());
    }
    ImageJob<ModpackModel> job = iconRepo.startImageJob(modpack);
    job.addJobListener(this);
    BufferedImage icon = job.getImage();
    if (icon.getWidth() > 50 || icon.getHeight() > 50)
        icon = ImageUtils.scaleImage(icon, 50, 50);
    modpackIcon.setIcon(new ImageIcon(icon));
    rebuildTags(modpack);
}
Also used : Version(net.technicpack.launchercore.install.Version) ModpackModel(net.technicpack.launchercore.modpacks.ModpackModel) BufferedImage(java.awt.image.BufferedImage)

Example 2 with Version

use of net.technicpack.launchercore.install.Version in project LauncherV3 by TechnicPack.

the class ModpackModel method getInstalledVersion.

public Version getInstalledVersion() {
    Version version = null;
    File versionFile = new File(getBinDir(), "version");
    if (versionFile.exists()) {
        return Version.load(versionFile);
    } else {
        return null;
    }
}
Also used : Version(net.technicpack.launchercore.install.Version) File(java.io.File)

Example 3 with Version

use of net.technicpack.launchercore.install.Version in project LauncherV3 by TechnicPack.

the class ModpackModel method hasRecommendedUpdate.

public boolean hasRecommendedUpdate() {
    if (installedPack == null || packInfo == null)
        return false;
    Version installedVersion = getInstalledVersion();
    if (installedVersion == null)
        return false;
    String installedBuild = installedVersion.getVersion();
    List<String> allBuilds = packInfo.getBuilds();
    if (allBuilds.isEmpty())
        return false;
    if (!allBuilds.contains(installedBuild))
        return true;
    for (String build : allBuilds) {
        if (build.equalsIgnoreCase(packInfo.getRecommended())) {
            return false;
        } else if (build.equalsIgnoreCase(installedBuild)) {
            return true;
        }
    }
    return false;
}
Also used : Version(net.technicpack.launchercore.install.Version)

Example 4 with Version

use of net.technicpack.launchercore.install.Version in project LauncherV3 by TechnicPack.

the class LauncherFrame method launchModpack.

protected void launchModpack() {
    ModpackModel pack = modpackSelector.getSelectedPack();
    boolean requiresInstall = false;
    if (pack == null || (pack.getInstalledPack() == null && (pack.getPackInfo() == null || !pack.getPackInfo().isComplete())))
        return;
    if (pack.getInstalledDirectory() == null) {
        requiresInstall = true;
        pack.save();
        modpackSelector.forceRefresh();
    }
    boolean forceInstall = false;
    Version installedVersion = pack.getInstalledVersion();
    // Force a full install (check cache, redownload, unzip files) if we have no current installation of this modpack
    if (installedVersion == null) {
        forceInstall = true;
        requiresInstall = true;
    } else if (pack.getBuild() != null && !pack.isLocalOnly()) {
        // Ask the user if they want to update to the newer version if:
        // 1- the pack build is RECOMMENDED & the recommended version is diff from the installed version
        // 2- the pack build is LATEST & the latest version is diff from the installed version
        // 3- the pack build is neither LATEST or RECOMMENDED & the pack build is diff from the installed version
        boolean requestInstall = false;
        if (pack.getBuild().equalsIgnoreCase(InstalledPack.RECOMMENDED) && pack.getPackInfo().getRecommended() != null && !pack.getPackInfo().getRecommended().equalsIgnoreCase(installedVersion.getVersion()))
            requestInstall = true;
        else if (pack.getBuild().equalsIgnoreCase(InstalledPack.LATEST) && pack.getPackInfo().getLatest() != null && !pack.getPackInfo().getLatest().equalsIgnoreCase(installedVersion.getVersion()))
            requestInstall = true;
        else if (!pack.getBuild().equalsIgnoreCase(InstalledPack.RECOMMENDED) && !pack.getBuild().equalsIgnoreCase(InstalledPack.LATEST) && !pack.getBuild().equalsIgnoreCase(installedVersion.getVersion()))
            requestInstall = true;
        // If the user says yes, update, then force a full install
        if (requestInstall) {
            int result = JOptionPane.showConfirmDialog(this, resources.getString("launcher.install.query"), resources.getString("launcher.install.query.title"), JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);
            if (result == JOptionPane.YES_OPTION) {
                forceInstall = true;
            }
        }
    }
    // If we're forcing an install, then derive the installation build from the pack build
    // otherwise, just use the installed version
    String installBuild = null;
    if (forceInstall && !pack.isLocalOnly()) {
        installBuild = pack.getBuild();
        if (installBuild.equalsIgnoreCase(InstalledPack.RECOMMENDED))
            installBuild = pack.getPackInfo().getRecommended();
        else if (installBuild.equalsIgnoreCase(InstalledPack.LATEST))
            installBuild = pack.getPackInfo().getLatest();
    } else if (installedVersion != null)
        installBuild = installedVersion.getVersion();
    if (requiresInstall && installBuild != null && !installBuild.isEmpty()) {
        installer.justInstall(resources, pack, installBuild, forceInstall, this, installProgress);
    } else {
        installer.installAndRun(resources, pack, installBuild, forceInstall, this, installProgress);
    }
    installProgress.setVisible(true);
    installProgressPlaceholder.setVisible(false);
    userChanged(userModel.getCurrentUser());
    invalidate();
}
Also used : ModpackModel(net.technicpack.launchercore.modpacks.ModpackModel) Version(net.technicpack.launchercore.install.Version)

Example 5 with Version

use of net.technicpack.launchercore.install.Version in project LauncherV3 by TechnicPack.

the class ModpackModel method getBuilds.

public List<String> getBuilds() {
    if (packInfo != null && packInfo.getBuilds() != null)
        return packInfo.getBuilds();
    List<String> oneBuild = new ArrayList<String>(1);
    Version version = getInstalledVersion();
    if (version != null)
        oneBuild.add(version.getVersion());
    else
        oneBuild.add(getBuild());
    return oneBuild;
}
Also used : Version(net.technicpack.launchercore.install.Version) ArrayList(java.util.ArrayList)

Aggregations

Version (net.technicpack.launchercore.install.Version)6 File (java.io.File)2 ModpackModel (net.technicpack.launchercore.modpacks.ModpackModel)2 BufferedImage (java.awt.image.BufferedImage)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Pattern (java.util.regex.Pattern)1 CacheDeleteException (net.technicpack.launchercore.exception.CacheDeleteException)1 MD5FileVerifier (net.technicpack.launchercore.install.verifiers.MD5FileVerifier)1 ValidZipFileVerifier (net.technicpack.launchercore.install.verifiers.ValidZipFileVerifier)1 IJavaVersion (net.technicpack.launchercore.launch.java.IJavaVersion)1 MojangVersion (net.technicpack.minecraftcore.mojang.version.MojangVersion)1 Modpack (net.technicpack.rest.io.Modpack)1 PackInfo (net.technicpack.rest.io.PackInfo)1