test ModpackManager

This commit is contained in:
huangyuhui
2016-01-23 16:52:40 +08:00
parent 102205de40
commit 08301bed8d
120 changed files with 8363 additions and 169 deletions

View File

@@ -27,7 +27,7 @@ import java.net.URLClassLoader;
import java.util.ArrayList;
import javax.swing.SwingUtilities;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.utils.views.LogWindow;
import org.jackhuang.hellominecraft.launcher.utils.MinecraftCrashAdvicer;

View File

@@ -32,7 +32,7 @@ import javax.net.ssl.X509TrustManager;
import javax.swing.ImageIcon;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.api.PluginManager;
import org.jackhuang.hellominecraft.launcher.core.launch.GameLauncher;
import org.jackhuang.hellominecraft.launcher.utils.CrashReporter;

View File

@@ -17,7 +17,7 @@
*/
package org.jackhuang.hellominecraft.launcher.api;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.settings.DefaultPlugin;
/**

View File

@@ -26,7 +26,7 @@ import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.utils.system.FileUtils;

View File

@@ -22,7 +22,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Map;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftAssetService;
import org.jackhuang.hellominecraft.utils.tasks.Task;
import org.jackhuang.hellominecraft.utils.system.FileUtils;

View File

@@ -24,7 +24,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftAssetService;
import org.jackhuang.hellominecraft.launcher.core.download.IDownloadProvider;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;

View File

@@ -31,7 +31,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
public class PropertyMap extends HashMap<String, Property> {

View File

@@ -29,7 +29,7 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.utils.NetUtils;
import org.jackhuang.hellominecraft.utils.StrUtils;

View File

@@ -23,9 +23,8 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.GameException;
import org.jackhuang.hellominecraft.launcher.core.launch.GameLauncher;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
import org.jackhuang.hellominecraft.launcher.core.version.IMinecraftLibrary;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
@@ -119,6 +118,19 @@ public class MinecraftDownloadService extends IMinecraftDownloadService {
}
}
@Override
public boolean downloadMinecraftJarTo(String id, File mvt) {
String vurl = service.getDownloadType().getProvider().getVersionsDownloadURL() + id + "/";
if (TaskWindow.getInstance()
.addTask(new FileDownloadTask(vurl + id + ".jar", IOUtils.tryGetCanonicalFile(mvt)).setTag(id + ".jar"))
.start())
return true;
else {
mvt.delete();
return false;
}
}
@Override
public boolean downloadMinecraftVersionJson(String id) {
String vurl = service.getDownloadType().getProvider().getVersionsDownloadURL() + id + "/";

View File

@@ -17,7 +17,6 @@
*/
package org.jackhuang.hellominecraft.launcher.core.download;
import org.jackhuang.hellominecraft.launcher.core.installers.InstallerType;
import org.jackhuang.hellominecraft.launcher.core.installers.InstallerVersionList;
/**

View File

@@ -43,7 +43,7 @@ public class PackMinecraftInstaller {
file.mkdirs();
for (String src1 : src)
Compressor.unzip(new File(src1), file);
Compressor.zip(file, dest);
Compressor.zip(file.getAbsolutePath(), dest.getAbsolutePath());
FileUtils.deleteDirectory(file);
}
}

View File

@@ -25,7 +25,7 @@ import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
import org.jackhuang.hellominecraft.launcher.core.installers.InstallerVersionList.InstallerVersion;
import org.jackhuang.hellominecraft.utils.tasks.Task;

View File

@@ -21,7 +21,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
import org.jackhuang.hellominecraft.utils.tasks.Task;
import org.jackhuang.hellominecraft.utils.tasks.communication.PreviousResult;

View File

@@ -24,7 +24,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.Launcher;
import org.jackhuang.hellominecraft.launcher.core.GameException;
import org.jackhuang.hellominecraft.launcher.core.auth.UserProfileProvider;
@@ -132,7 +132,7 @@ public abstract class AbstractMinecraftLoader implements IMinecraftLoader {
}
@Override
public List<String> makeLaunchingCommand() {
public List<String> makeLaunchingCommand() throws GameException {
HMCLog.log("*** Make shell command ***");
ArrayList<String> res = new ArrayList<>();
@@ -191,7 +191,7 @@ public abstract class AbstractMinecraftLoader implements IMinecraftLoader {
*
* @param list the command list you shoud edit.
*/
protected abstract void makeSelf(List<String> list);
protected abstract void makeSelf(List<String> list) throws GameException;
protected void appendJVMArgs(List<String> list) {
}

View File

@@ -19,7 +19,7 @@ package org.jackhuang.hellominecraft.launcher.core.launch;
import java.io.IOException;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator;
import org.jackhuang.hellominecraft.launcher.core.auth.LoginInfo;
import org.jackhuang.hellominecraft.launcher.core.download.DownloadLibraryJob;

View File

@@ -27,7 +27,7 @@ import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.util.List;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.api.PluginManager;
import org.jackhuang.hellominecraft.launcher.core.GameException;
import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator;
@@ -174,13 +174,10 @@ public class GameLauncher {
}
writer.write(StrUtils.makeCommand(str));
writer.close();
if (!isWin)
try {
Runtime.getRuntime().exec("chmod +x " + IOUtils.tryGetCanonicalFilePath(f));
} catch (IOException e) {
HMCLog.warn("Failed to give sh file permission.", e);
MessageBox.Show(C.i18n("launch.failed_sh_permission"));
}
if (!f.setExecutable(true)) {
HMCLog.warn("Failed to give launcher permission.");
MessageBox.Show(C.i18n("launch.failed_sh_permission"));
}
HMCLog.log("Command: " + StrUtils.parseParams("", str, " "));
return f;

View File

@@ -28,7 +28,7 @@ import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.jar.Pack200;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.download.DownloadLibraryJob;
import org.jackhuang.hellominecraft.utils.tasks.download.FileDownloadTask;
import org.jackhuang.hellominecraft.utils.system.IOUtils;
@@ -50,23 +50,25 @@ public class LibraryDownloadTask extends FileDownloadTask {
@Override
public void executeTask() throws Throwable {
File packFile = new File(job.path.getParentFile(), job.path.getName() + ".pack.xz");
if (job.name.contains("typesafe")) {
download(new URL(job.url + ".pack.xz"), packFile);
unpackLibrary(job.path, packFile);
packFile.delete();
} else {
if (job.name.startsWith("net.minecraftforge:forge:")) {
String[] s = job.name.split(":");
if (s.length == 3)
job.url = "http://files.minecraftforge.net/maven/net/minecraftforge/forge/" + s[2] + "/forge-" + s[2] + "-universal.jar";
}
if (job.name.startsWith("com.mumfrey:liteloader:")) {
String[] s = job.name.split(":");
if (s.length == 3 && s[2].length() > 3)
job.url = "http://dl.liteloader.com/versions/com/mumfrey/liteloader/" + s[2].substring(0, s[2].length() - 3) + "/liteloader-" + s[2] + ".jar";
}
download(new URL(job.url), job.path);
/*
* if (job.name.contains("typesafe")) {
* download(new URL(job.url + ".pack.xz"), packFile);
* unpackLibrary(job.path, packFile);
* packFile.delete();
* } else {
*/
if (job.name.startsWith("net.minecraftforge:forge:")) {
String[] s = job.name.split(":");
if (s.length == 3)
job.url = "http://files.minecraftforge.net/maven/net/minecraftforge/forge/" + s[2] + "/forge-" + s[2] + "-universal.jar";
}
if (job.name.startsWith("com.mumfrey:liteloader:")) {
String[] s = job.name.split(":");
if (s.length == 3 && s[2].length() > 3)
job.url = "http://dl.liteloader.com/versions/com/mumfrey/liteloader/" + s[2].substring(0, s[2].length() - 3) + "/liteloader-" + s[2] + ".jar";
}
download(new URL(job.url), job.path);
//}
}
void download(URL url, File filePath) throws Throwable {

View File

@@ -24,7 +24,7 @@ import java.io.IOException;
import java.util.List;
import java.util.Map;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.Main;
import org.jackhuang.hellominecraft.launcher.core.GameException;
import org.jackhuang.hellominecraft.launcher.core.auth.UserProfileProvider;
@@ -54,14 +54,17 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
}
@Override
protected void makeSelf(List<String> res) {
protected void makeSelf(List<String> res) throws GameException {
String library = options.isCanceledWrapper() ? "" : "-cp=";
for (MinecraftLibrary l : version.libraries) {
l.init();
if (l.allow() && !l.isRequiredToUnzip())
library += l.getFilePath(gameDir).getAbsolutePath() + File.pathSeparator;
}
library += IOUtils.tryGetCanonicalFilePath(version.getJar(service.baseDirectory())) + File.pathSeparator;
File f = version.getJar(service.baseDirectory());
if (!f.exists())
throw new GameException("Minecraft jar does not exists");
library += IOUtils.tryGetCanonicalFilePath(f) + File.pathSeparator;
library = library.substring(0, library.length() - File.pathSeparator.length());
if (options.isCanceledWrapper())
res.add("-cp");

View File

@@ -25,7 +25,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftModService;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
import org.jackhuang.hellominecraft.launcher.core.ModInfo;

View File

@@ -22,14 +22,20 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.FileSystemException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.GameException;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftProvider;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
import org.jackhuang.hellominecraft.utils.system.Compressor;
import org.jackhuang.hellominecraft.utils.system.FileUtils;
import org.jackhuang.hellominecraft.utils.system.ZipEngine;
import org.jackhuang.hellominecraft.utils.version.MinecraftVersionRequest;
/**
* A mod pack(*.zip) includes these things:
@@ -51,8 +57,8 @@ import org.jackhuang.hellominecraft.utils.system.FileUtils;
*/
public final class ModpackManager {
public static void install(File input, File installFolder, String id) throws IOException, FileAlreadyExistsException {
File versions = new File(installFolder, "versions");
public static void install(File input, IMinecraftService service, String id) throws IOException, FileAlreadyExistsException {
File versions = new File(service.baseDirectory(), "versions");
File oldFile = new File(versions, "minecraft"), newFile = null;
if (oldFile.exists()) {
newFile = new File(versions, "minecraft-" + System.currentTimeMillis());
@@ -64,19 +70,29 @@ public final class ModpackManager {
}
try {
AtomicBoolean b = new AtomicBoolean(false);
AtomicInteger b = new AtomicInteger(0);
HMCLog.log("Decompressing modpack");
Compressor.unzip(input, versions, t -> {
if (t.equals("minecraft/pack.json"))
b.set(true);
b.incrementAndGet();
if (t.equals("minecraft/pack.jar"))
b.incrementAndGet();
return true;
});
if (!b.get())
throw new FileNotFoundException("the mod pack is not in a correct format.");
if (b.get() < 2)
throw new FileNotFoundException("the mod pack is in an incorrect format.");
File nowFile = new File(versions, id);
oldFile.renameTo(nowFile);
new File(nowFile, "pack.json").renameTo(new File(nowFile, id + ".json"));
File json = new File(nowFile, "pack.json");
MinecraftVersion mv = C.gson.fromJson(FileUtils.readFileToString(json), MinecraftVersion.class);
if (mv.jar == null)
throw new FileSystemException("the mod pack is in an incorrect format, pack.json does not have attribute 'jar'.");
service.download().downloadMinecraftJarTo(mv.jar, new File(nowFile, id + ".jar"));
mv.jar = null;
FileUtils.writeStringToFile(json, C.gsonPrettyPrinting.toJson(mv));
json.renameTo(new File(nowFile, id + ".json"));
} finally {
FileUtils.deleteDirectoryQuietly(oldFile);
if (newFile != null)
@@ -94,31 +110,34 @@ public final class ModpackManager {
*
* @throws IOException if create tmp directory failed
*/
public static void export(File output, IMinecraftProvider provider, String version) throws IOException, GameException {
File tmp = new File(System.getProperty("java.io.tmpdir"), "hmcl-modpack");
tmp.mkdirs();
File root = new File(tmp, "minecraft");
HMCLog.log("Copying files from game directory.");
FileUtils.copyDirectory(provider.getRunDirectory(version), root);
File pack = new File(root, "pack.json");
MinecraftVersion mv = provider.getVersionById(version).resolve(provider);
public static void export(File output, IMinecraftProvider provider, String version, List<String> blacklist) throws IOException, GameException {
ArrayList<String> b = new ArrayList<>(Arrays.asList(new String[] { "usernamecache.json", "asm", "logs", "backups", "versions", "assets", "usercache.json", "libraries", "crash-reports", "launcher_profiles.json", "NVIDIA", "TCNodeTracker" }));
if (blacklist != null)
b.addAll(blacklist);
HMCLog.log("Compressing game files without some files in blacklist, including files or directories: usernamecache.json, asm, logs, backups, versions, assets, usercache.json, libraries, crash-reports, launcher_profiles.json, NVIDIA, TCNodeTracker");
ZipEngine zip = null;
try {
FileUtils.writeStringToFile(pack, C.gsonPrettyPrinting.toJson(mv));
String[] blacklist = { "usernamecache.json", "asm", "logs", "backups", "versions", "assets", "usercache.json", "libraries", "crash-reports", "launcher_profiles.json", "NVIDIA", "TCNodeTracker" };
HMCLog.log("Removing files in blacklist, including files or directories: usernamecache.json, asm, logs, backups, versions, assets, usercache.json, libraries, crash-reports, launcher_profiles.json, NVIDIA, TCNodeTracker");
for (String s : blacklist) {
File f = new File(root, s);
if (f.isFile())
f.delete();
else if (f.isDirectory())
FileUtils.deleteDirectory(f);
}
HMCLog.log("Compressing game files");
Compressor.zip(tmp, output);
zip = new ZipEngine(output);
zip.putDirectory(provider.getRunDirectory(version), (String x, Boolean y) -> {
for (String s : b)
if (y) {
if (x.startsWith(s + "/"))
return null;
} else if (x.equals(s))
return null;
return "minecraft/" + x;
});
MinecraftVersion mv = provider.getVersionById(version).resolve(provider);
mv.runDir = "version";
MinecraftVersionRequest r = MinecraftVersionRequest.minecraftVersion(provider.getMinecraftJar(version));
if (r.type != MinecraftVersionRequest.OK)
throw new FileSystemException("Cannot read vanilla version, " + MinecraftVersionRequest.getResponse(r));
mv.jar = r.version;
zip.putTextFile(C.gsonPrettyPrinting.toJson(mv), "minecraft/pack.json");
} finally {
FileUtils.deleteDirectory(tmp);
if (zip != null)
zip.closeFile();
}
}

View File

@@ -17,6 +17,7 @@
*/
package org.jackhuang.hellominecraft.launcher.core.service;
import java.io.File;
import java.util.List;
import org.jackhuang.hellominecraft.launcher.core.GameException;
import org.jackhuang.hellominecraft.launcher.core.download.DownloadLibraryJob;
@@ -38,6 +39,8 @@ public abstract class IMinecraftDownloadService extends IMinecraftBasicService {
public abstract boolean downloadMinecraftJar(String id);
public abstract boolean downloadMinecraftJarTo(String id, File f);
public abstract boolean downloadMinecraftVersionJson(String id);
/**

View File

@@ -25,7 +25,7 @@ import java.util.Collection;
import java.util.Map;
import java.util.TreeMap;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.GameException;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftProvider;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
@@ -36,6 +36,7 @@ import org.jackhuang.hellominecraft.utils.tasks.TaskWindow;
import org.jackhuang.hellominecraft.utils.tasks.download.FileDownloadTask;
import org.jackhuang.hellominecraft.utils.system.IOUtils;
import org.jackhuang.hellominecraft.utils.MessageBox;
import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.utils.functions.Consumer;
import org.jackhuang.hellominecraft.utils.views.SwingUtils;
@@ -232,7 +233,10 @@ public class MinecraftVersionManager extends IMinecraftProvider {
@Override
public File getMinecraftJar(String id) {
return versions.get(id).getJar(service.baseDirectory());
if (versions.containsKey(id))
return versions.get(id).getJar(service.baseDirectory());
else
return null;
}
@Override
@@ -242,7 +246,7 @@ public class MinecraftVersionManager extends IMinecraftProvider {
@Override
public MinecraftVersion getVersionById(String id) {
return id == null ? null : versions.get(id);
return StrUtils.isBlank(id) ? null : versions.get(id);
}
@Override

View File

@@ -20,7 +20,7 @@ package org.jackhuang.hellominecraft.launcher.settings;
import java.io.File;
import java.io.IOException;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.Main;
import org.jackhuang.hellominecraft.launcher.api.PluginManager;
import org.jackhuang.hellominecraft.launcher.core.LauncherVisibility;
@@ -115,7 +115,7 @@ public final class Profile {
public String getSelectedVersion() {
String v = selectedMinecraftVersion;
if (v == null) {
if (StrUtils.isBlank(v) || service.version().getVersionById(v) == null) {
v = service.version().getOneVersion().id;
if (v != null)
setSelectedMinecraftVersion(v);

View File

@@ -26,7 +26,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.Main;
import org.jackhuang.hellominecraft.launcher.core.download.DownloadType;
import org.jackhuang.hellominecraft.utils.CollectionUtils;

View File

@@ -24,7 +24,7 @@ import java.util.HashMap;
import java.util.HashSet;
import javax.swing.SwingUtilities;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.Main;
import org.jackhuang.hellominecraft.launcher.settings.Settings;
import org.jackhuang.hellominecraft.utils.NetUtils;

View File

@@ -35,7 +35,7 @@ import java.util.jar.JarOutputStream;
import java.util.jar.Pack200;
import java.util.zip.GZIPInputStream;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.MCUtils;
import org.jackhuang.hellominecraft.utils.tasks.Task;
import org.jackhuang.hellominecraft.utils.tasks.TaskWindow;

View File

@@ -21,7 +21,7 @@ import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.utils.tasks.TaskWindow;
import org.jackhuang.hellominecraft.utils.tasks.download.FileDownloadTask;
import org.jackhuang.hellominecraft.utils.ArrayUtils;

View File

@@ -19,7 +19,7 @@ package org.jackhuang.hellominecraft.launcher.views;
import javax.swing.table.DefaultTableModel;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.utils.MessageBox;
import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.utils.views.SwingUtils;

View File

@@ -346,7 +346,9 @@
</Component>
<Component class="javax.swing.JButton" name="btnExportModpack">
<Properties>
<Property name="text" type="java.lang.String" value="&#x5bfc;&#x51fa;&#x6574;&#x5408;&#x5305;"/>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="settings.modpack.save.task" replaceFormat="C.i18n(&quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnExportModpackActionPerformed"/>
@@ -354,7 +356,9 @@
</Component>
<Component class="javax.swing.JButton" name="btnImportModpack">
<Properties>
<Property name="text" type="java.lang.String" value="&#x5bfc;&#x5165;&#x6574;&#x5408;&#x5305;"/>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="settings.modpack.install.task" replaceFormat="C.i18n(&quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnImportModpackActionPerformed"/>

View File

@@ -32,7 +32,9 @@ import java.awt.event.ItemEvent;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
@@ -45,7 +47,7 @@ import javax.swing.event.TableModelEvent;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.DefaultTableModel;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.GameException;
import org.jackhuang.hellominecraft.launcher.core.LauncherVisibility;
import org.jackhuang.hellominecraft.launcher.settings.Profile;
@@ -56,6 +58,8 @@ import org.jackhuang.hellominecraft.launcher.core.installers.InstallerType;
import org.jackhuang.hellominecraft.launcher.core.mod.ModpackManager;
import org.jackhuang.hellominecraft.launcher.core.version.GameDirType;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
import org.jackhuang.hellominecraft.launcher.views.modpack.ModpackInitializationPanel;
import org.jackhuang.hellominecraft.launcher.views.modpack.ModpackWizard;
import org.jackhuang.hellominecraft.utils.tasks.TaskRunnable;
import org.jackhuang.hellominecraft.utils.tasks.TaskWindow;
import org.jackhuang.hellominecraft.utils.Event;
@@ -64,8 +68,10 @@ import org.jackhuang.hellominecraft.utils.MessageBox;
import org.jackhuang.hellominecraft.utils.version.MinecraftVersionRequest;
import org.jackhuang.hellominecraft.utils.system.OS;
import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.utils.system.FileUtils;
import org.jackhuang.hellominecraft.utils.views.SwingUtils;
import org.jackhuang.hellominecraft.utils.system.Java;
import org.jackhuang.hellominecraft.utils.views.wizard.api.WizardDisplayer;
import rx.Observable;
import rx.concurrency.Schedulers;
@@ -403,14 +409,14 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
}
});
btnExportModpack.setText("导出整合包");
btnExportModpack.setText(C.i18n("settings.modpack.save.task")); // NOI18N
btnExportModpack.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnExportModpackActionPerformed(evt);
}
});
btnImportModpack.setText("导入整合包");
btnImportModpack.setText(C.i18n("settings.modpack.install.task")); // NOI18N
btnImportModpack.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnImportModpackActionPerformed(evt);
@@ -914,6 +920,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
// <editor-fold defaultstate="collapsed" desc="UI Events">
private void cboProfilesItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboProfilesItemStateChanged
if (!isLoading) {
Settings.getInstance().setLast((String) cboProfiles.getSelectedItem());
if (getProfile().service().version().getVersionCount() <= 0)
versionChanged(null);
prepare(getProfile());
@@ -1139,13 +1146,14 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
fc.setDialogTitle(C.i18n("settings.modpack.choose"));
fc.setMultiSelectionEnabled(false);
fc.setFileFilter(new FileNameExtensionFilter(C.i18n("settings.modpack"), ".zip"));
fc.setFileFilter(new FileNameExtensionFilter(C.i18n("settings.modpack"), "zip"));
fc.showOpenDialog(this);
if (fc.getSelectedFile() == null)
return;
TaskWindow.getInstance().addTask(new TaskRunnable(C.i18n("settings.modpack"), () -> {
String suggestedModpackId = JOptionPane.showInputDialog("Please enter your favourite game name", FileUtils.getBaseName(fc.getSelectedFile().getName()));
TaskWindow.getInstance().addTask(new TaskRunnable(C.i18n("settings.modpack.install.task"), () -> {
try {
ModpackManager.install(fc.getSelectedFile(), getProfile().getCanonicalGameDirFile(), fc.getSelectedFile().getName());
ModpackManager.install(fc.getSelectedFile(), getProfile().service(), suggestedModpackId);
} catch (IOException ex) {
MessageBox.Show(C.i18n("settings.modpack.install_error"));
HMCLog.err("Failed to install modpack", ex);
@@ -1154,22 +1162,20 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
}//GEN-LAST:event_btnImportModpackActionPerformed
private void btnExportModpackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExportModpackActionPerformed
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
fc.setDialogTitle(C.i18n("settings.modpack.save"));
fc.setMultiSelectionEnabled(false);
fc.setFileFilter(new FileNameExtensionFilter(C.i18n("settings.modpack"), ".zip"));
fc.showSaveDialog(this);
if (fc.getSelectedFile() == null)
return;
TaskWindow.getInstance().addTask(new TaskRunnable(C.i18n("settings.modpack"), () -> {
try {
ModpackManager.export(fc.getSelectedFile(), getProfile().service().version(), getProfile().getSelectedVersion());
} catch (IOException | GameException ex) {
MessageBox.Show(C.i18n("settings.modpack.export_error"));
HMCLog.err("Failed to export modpack", ex);
}
})).start();
Map settings = (Map) WizardDisplayer.showWizard(new ModpackWizard(getProfile().service().version()).createWizard());
if (settings != null)
TaskWindow.getInstance().addTask(new TaskRunnable(C.i18n("settings.modpack.save.task"),
() -> {
try {
ModpackManager.export(new File((String) settings.get(ModpackInitializationPanel.KEY_MODPACK_LOCATION)),
getProfile().service().version(),
(String) settings.get(ModpackInitializationPanel.KEY_GAME_VERSION),
((Boolean) settings.get(ModpackInitializationPanel.KEY_SAVE) == false) ? Arrays.asList("saves") : null);
} catch (IOException | GameException ex) {
MessageBox.Show(C.i18n("settings.modpack.export_error"));
HMCLog.err("Failed to export modpack", ex);
}
})).start();
}//GEN-LAST:event_btnExportModpackActionPerformed
// </editor-fold>

View File

@@ -23,7 +23,7 @@ import javax.swing.DefaultComboBoxModel;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileNameExtensionFilter;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.settings.Settings;
import org.jackhuang.hellominecraft.launcher.core.download.DownloadType;
import org.jackhuang.hellominecraft.utils.system.IOUtils;

View File

@@ -41,7 +41,7 @@ import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.Main;
import org.jackhuang.hellominecraft.launcher.settings.Settings;
import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator;

View File

@@ -28,7 +28,7 @@ import java.util.List;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.HMCLog;
import org.jackhuang.hellominecraft.utils.logging.HMCLog;
import org.jackhuang.hellominecraft.launcher.core.launch.DefaultGameLauncher;
import org.jackhuang.hellominecraft.launcher.core.GameException;
import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator;

View File

@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="lblModpackLocation" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="175" max="32767" attributes="0"/>
<Component id="cboModpackLocation" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="txtModpackLocation" max="32767" attributes="0"/>
<Component id="cboGameVersion" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblGameVersion" min="-2" max="-2" attributes="0"/>
<Component id="chkSave" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lblModpackLocation" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cboModpackLocation" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtModpackLocation" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="29" max="-2" attributes="0"/>
<Component id="lblGameVersion" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cboGameVersion" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="chkSave" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="133" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="lblModpackLocation">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/jackhuang/hellominecraft/launcher/I18N.properties" key="settings.modpack.save" replaceFormat="C.i18n(&quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="txtModpackLocation">
<Events>
<EventHandler event="caretUpdate" listener="javax.swing.event.CaretListener" parameters="javax.swing.event.CaretEvent" handler="txtModpackLocationCaretUpdate"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="cboModpackLocation">
<Properties>
<Property name="text" type="java.lang.String" value="..."/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cboModpackLocationActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="lblGameVersion">
<Properties>
<Property name="text" type="java.lang.String" value="&#x8981;&#x5bfc;&#x51fa;&#x7684;&#x6e38;&#x620f;&#x7248;&#x672c;"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="cboGameVersion">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="0"/>
</Property>
</Properties>
<Events>
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="cboGameVersionItemStateChanged"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
<Component class="javax.swing.JCheckBox" name="chkSave">
<Properties>
<Property name="text" type="java.lang.String" value="&#x5141;&#x8bb8;&#x5bfc;&#x51fa;&#x5b58;&#x6863;"/>
</Properties>
<Events>
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="chkSaveItemStateChanged"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@@ -0,0 +1,187 @@
/*
* Hello Minecraft! Launcher.
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}.
*/
package org.jackhuang.hellominecraft.launcher.views.modpack;
import java.io.File;
import java.util.Map;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileNameExtensionFilter;
import org.jackhuang.hellominecraft.utils.C;
import org.jackhuang.hellominecraft.utils.views.wizard.spi.WizardController;
/**
*
* @author huangyuhui
*/
public class ModpackInitializationPanel extends javax.swing.JPanel {
public static final String KEY_GAME_VERSION = "gameVersion";
public static final String KEY_MODPACK_LOCATION = "modpackLocation";
public static final String KEY_SAVE = "save";
private final WizardController controller;
private final Map wizardData;
/**
* Creates new form ModpackInitializationPanel
*/
public ModpackInitializationPanel(WizardController controller, Map wizardData, String[] versions) {
initComponents();
this.controller = controller;
this.wizardData = wizardData;
wizardData.put(KEY_GAME_VERSION, versions);
wizardData.put(KEY_SAVE, false);
configureComboContents();
controller.setProblem("Not a valid file location");
controller.setForwardNavigationMode(WizardController.MODE_CAN_FINISH);
}
private void configureComboContents() {
String[] versions = (String[]) wizardData.get(KEY_GAME_VERSION);
cboGameVersion.setModel(new DefaultComboBoxModel<>(versions));
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
lblModpackLocation = new javax.swing.JLabel();
txtModpackLocation = new javax.swing.JTextField();
cboModpackLocation = new javax.swing.JButton();
lblGameVersion = new javax.swing.JLabel();
cboGameVersion = new javax.swing.JComboBox<>();
chkSave = new javax.swing.JCheckBox();
lblModpackLocation.setText(C.i18n("settings.modpack.save")); // NOI18N
txtModpackLocation.addCaretListener(new javax.swing.event.CaretListener() {
public void caretUpdate(javax.swing.event.CaretEvent evt) {
txtModpackLocationCaretUpdate(evt);
}
});
cboModpackLocation.setText("...");
cboModpackLocation.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cboModpackLocationActionPerformed(evt);
}
});
lblGameVersion.setText("要导出的游戏版本");
cboGameVersion.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
cboGameVersionItemStateChanged(evt);
}
});
chkSave.setText("允许导出存档");
chkSave.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
chkSaveItemStateChanged(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(lblModpackLocation)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 175, Short.MAX_VALUE)
.addComponent(cboModpackLocation))
.addComponent(txtModpackLocation)
.addComponent(cboGameVersion, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblGameVersion)
.addComponent(chkSave))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblModpackLocation)
.addComponent(cboModpackLocation))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtModpackLocation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(29, 29, 29)
.addComponent(lblGameVersion)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cboGameVersion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(chkSave)
.addContainerGap(133, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void cboModpackLocationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cboModpackLocationActionPerformed
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
fc.setDialogTitle(C.i18n("settings.modpack.save"));
fc.setMultiSelectionEnabled(false);
fc.setFileFilter(new FileNameExtensionFilter(C.i18n("settings.modpack") + "(*.zip)", "zip"));
fc.showSaveDialog(this);
if (fc.getSelectedFile() != null)
txtModpackLocation.setText(fc.getSelectedFile().getAbsolutePath());
}//GEN-LAST:event_cboModpackLocationActionPerformed
private void txtModpackLocationCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_txtModpackLocationCaretUpdate
wizardData.put(KEY_MODPACK_LOCATION, txtModpackLocation.getText());
if (txtModpackLocation.getText().trim().isEmpty())
controller.setProblem("Please choose a location!!!");
else
controller.setProblem(null);
}//GEN-LAST:event_txtModpackLocationCaretUpdate
private void chkSaveItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkSaveItemStateChanged
wizardData.put(KEY_SAVE, chkSave.isSelected());
}//GEN-LAST:event_chkSaveItemStateChanged
private void cboGameVersionItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboGameVersionItemStateChanged
wizardData.put(KEY_GAME_VERSION, cboGameVersion.getSelectedItem());
}//GEN-LAST:event_cboGameVersionItemStateChanged
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JComboBox<String> cboGameVersion;
private javax.swing.JButton cboModpackLocation;
private javax.swing.JCheckBox chkSave;
private javax.swing.JLabel lblGameVersion;
private javax.swing.JLabel lblModpackLocation;
private javax.swing.JTextField txtModpackLocation;
// End of variables declaration//GEN-END:variables
}

View File

@@ -0,0 +1,59 @@
/*
* Hello Minecraft! Launcher.
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}.
*/
package org.jackhuang.hellominecraft.launcher.views.modpack;
import java.util.Iterator;
import java.util.Map;
import javax.swing.JComponent;
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftProvider;
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
import org.jackhuang.hellominecraft.utils.views.wizard.spi.WizardBranchController;
import org.jackhuang.hellominecraft.utils.views.wizard.spi.WizardController;
import org.jackhuang.hellominecraft.utils.views.wizard.spi.WizardPanelProvider;
/**
*
* @author huangyuhui
*/
public class ModpackWizard extends WizardBranchController {
public ModpackWizard(IMinecraftProvider provider) {
super(new WizardPanelProvider("Modpack Wizard", new String[] { "Settings" }, new String[] { "Select location, version and allow version" }) {
@Override
protected JComponent createPanel(WizardController controller, String id, Map settings) {
switch (indexOfStep(id)) {
case 0:
String[] s = new String[provider.getVersionCount()];
Iterator<MinecraftVersion> it = provider.getVersions().iterator();
for (int i = 0; i < s.length; i++)
s[i] = it.next().id;
return new ModpackInitializationPanel(controller, settings, s);
default:
throw new IllegalArgumentException(id);
}
}
});
}
@Override
protected WizardPanelProvider getPanelProviderForStep(String step, Map settings) {
return null;
}
}