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);
}
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;
}
}
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;
}
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();
}
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;
}
Aggregations