Add mod modification.

This commit is contained in:
huanghongxun
2015-08-11 13:02:02 +08:00
parent 798d933079
commit 70f0383b1d
24 changed files with 1729 additions and 1092 deletions

2
HMCL/proguard.pro vendored
View File

@@ -57,6 +57,8 @@
-keepclassmembers class org.jackhuang.hellominecraft.launcher.utils.assets.AssetsObject { <fields>; }
-keepclassmembers class org.jackhuang.hellominecraft.launcher.utils.assets.AssetsIndex { <fields>; }
-keepclassmembers class org.jackhuang.hellominecraft.launcher.utils.ModInfo { <fields>; }
-keepclassmembers class org.jackhuang.hellominecraft.launcher.utils.installers.forge.InstallProfile { public <fields>; }
-keepclassmembers class org.jackhuang.hellominecraft.launcher.utils.installers.forge.Install { public <fields>; }

View File

@@ -22,6 +22,8 @@ import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.swing.SwingUtilities;
import org.jackhuang.hellominecraft.C;
import org.jackhuang.hellominecraft.HMCLog;
@@ -42,8 +44,6 @@ import org.jackhuang.hellominecraft.utils.Utils;
*/
public final class Launcher {
private static final Launcher instance = new Launcher();
public static void println(String s) {
System.out.println(s);
}
@@ -84,7 +84,7 @@ public final class Launcher {
println("Failed to add log file appender.");
e.printStackTrace();
}
println("Arguments: {\n" + StrUtils.parseParams(" ", args, "\n") + "\n}");
println("Main Class: " + mainClass);
println("Class Path: {\n" + StrUtils.parseParams(" ", tokenized, "\n") + "\n}");

View File

@@ -127,7 +127,8 @@ public abstract class AbstractMinecraftLoader implements IMinecraftLoader {
if (OS.os() != OS.WINDOWS)
res.add("-Duser.home=" + gameDir.getParent());
res.add("-Dhellominecraftlauncher.gamedir=" + gameDir.getAbsolutePath());
if (!v.isCanceledWrapper()) {
res.add("-cp");
res.add(StrUtils.parseParams("", Utils.getURL(), File.pathSeparator));

View File

@@ -22,6 +22,7 @@ import java.util.List;
import org.jackhuang.hellominecraft.launcher.utils.auth.UserProfileProvider;
import org.jackhuang.hellominecraft.launcher.utils.download.DownloadType;
import org.jackhuang.hellominecraft.launcher.settings.Profile;
import org.jackhuang.hellominecraft.launcher.utils.ModInfo;
import org.jackhuang.hellominecraft.launcher.version.MinecraftVersion;
/**
@@ -56,6 +57,8 @@ public abstract class IMinecraftProvider {
public abstract void open(String version, String folder);
public abstract File getAssets();
public abstract List<ModInfo> listMods();
/**
* Returns the thing like ".minecraft/resourcepacks".

View File

@@ -125,6 +125,7 @@ public final class Profile {
public Profile setGameDir(String gameDir) {
this.gameDir = gameDir;
getMinecraftProvider().refreshVersions();
Settings.save();
return this;
}
@@ -153,9 +154,8 @@ public final class Profile {
}
public int getJavaIndexInAllJavas() {
if(StrUtils.isBlank(java) && StrUtils.isNotBlank(javaDir)) {
if (StrUtils.isBlank(java) && StrUtils.isNotBlank(javaDir))
java = "Custom";
}
int idx = Settings.JAVA.indexOf(new Java(java, null));
if (idx == -1) {
java = "Default";
@@ -172,7 +172,7 @@ public final class Profile {
}
public File getFolder(String folder) {
return new File(getGameDir(), folder);
return new File(getMinecraftProvider().getRunDirectory(getSelectedMinecraftVersion().id), folder);
}
public String getName() {

View File

@@ -20,8 +20,15 @@ import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.jackhuang.hellominecraft.C;
import org.jackhuang.hellominecraft.HMCLog;
import org.jackhuang.hellominecraft.launcher.utils.assets.AssetsIndex;
import org.jackhuang.hellominecraft.launcher.utils.assets.AssetsObject;
@@ -35,6 +42,7 @@ import org.jackhuang.hellominecraft.utils.system.FileUtils;
import org.jackhuang.hellominecraft.utils.system.IOUtils;
import org.jackhuang.hellominecraft.version.MinecraftVersionRequest;
import org.jackhuang.hellominecraft.utils.NetUtils;
import org.jackhuang.hellominecraft.utils.Pair;
import org.jackhuang.hellominecraft.utils.system.OS;
/**
@@ -244,6 +252,30 @@ public final class MCUtils {
}
return null;
}
public static boolean downloadMinecraftJar(File gameDir, String id, DownloadType sourceType) {
String vurl = sourceType.getProvider().getVersionsDownloadURL() + id + "/";
File vpath = new File(gameDir, "versions/" + id);
File mvv = new File(vpath, id + ".jar"), moved = null;
if (mvv.exists()) {
moved = new File(vpath, id + "-renamed.jar");
mvv.renameTo(moved);
}
File mvt = new File(vpath, id + ".jar");
vpath.mkdirs();
if (TaskWindow.getInstance()
.addTask(new FileDownloadTask(vurl + id + ".jar", IOUtils.tryGetCanonicalFile(mvt)).setTag(id + ".jar"))
.start()) {
if (moved != null)
moved.delete();
return true;
} else {
mvt.delete();
if (moved != null)
moved.renameTo(mvt);
return false;
}
}
public static boolean downloadMinecraftVersionJson(File gameDir, String id, DownloadType sourceType) {
String vurl = sourceType.getProvider().getVersionsDownloadURL() + id + "/";

View File

@@ -0,0 +1,98 @@
/*
* Copyright 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 2 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.
*/
package org.jackhuang.hellominecraft.launcher.utils;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.jackhuang.hellominecraft.C;
import org.jackhuang.hellominecraft.HMCLog;
import org.jackhuang.hellominecraft.utils.system.FileUtils;
/**
*
* @author huangyuhui
*/
public class ModInfo implements Comparable<ModInfo> {
public File location;
public String modid, name, description, version, mcversion, url, updateUrl, credits;
public String[] authorList;
public boolean isActive() {
return !location.getName().endsWith(".disabled");
}
@Override
public int compareTo(ModInfo o) {
return getFileName().toLowerCase().compareTo(o.getFileName().toLowerCase());
}
public String getName() {
return name == null ? FileUtils.removeExtension(location.getName()) : name;
}
@Override
public boolean equals(Object obj) {
return obj != null && obj instanceof ModInfo && (((ModInfo) obj).location == location || ((ModInfo) obj).location.equals(location));
}
@Override
public int hashCode() {
return location.hashCode();
}
public String getFileName() {
String n = location.getName();
return FileUtils.removeExtension(isActive() ? n : n.substring(0, n.length() - ".disabled".length()));
}
public static boolean isFileMod(File file) {
if (file == null) return false;
String name = file.getName();
boolean disabled = name.endsWith(".disabled");
if (disabled) name = name.substring(0, name.length() - ".disabled".length());
return name.endsWith(".zip") || name.endsWith(".jar");
}
public static ModInfo readModInfo(File f) {
ModInfo i = new ModInfo();
i.location = f;
try {
ZipFile jar = new ZipFile(f);
ZipEntry entry = jar.getEntry("mcmod.info");
if (entry == null) return i;
else {
List<ModInfo> m = C.gson.fromJson(new InputStreamReader(jar.getInputStream(entry)), new TypeToken<List<ModInfo>>() {
}.getType());
if (m != null && m.size() > 0) { i = m.get(0); i.location = f; }
}
jar.close();
return i;
} catch (IOException ex) {
HMCLog.warn("File " + f + " is not a jar.", ex);
return i;
} catch (JsonSyntaxException e) {
return i;
}
}
}

View File

@@ -23,7 +23,7 @@ import org.jackhuang.hellominecraft.C;
import org.jackhuang.hellominecraft.HMCLog;
import org.jackhuang.hellominecraft.tasks.Task;
import org.jackhuang.hellominecraft.tasks.communication.PreviousResult;
import org.jackhuang.hellominecraft.tasks.communication.PreviousResultRegistrator;
import org.jackhuang.hellominecraft.tasks.communication.PreviousResultRegistrar;
import org.jackhuang.hellominecraft.launcher.settings.Profile;
import org.jackhuang.hellominecraft.utils.system.FileUtils;
import org.jackhuang.hellominecraft.launcher.version.MinecraftLibrary;
@@ -33,7 +33,7 @@ import org.jackhuang.hellominecraft.launcher.version.MinecraftVersion;
*
* @author huangyuhui
*/
public class LiteLoaderInstaller extends Task implements PreviousResultRegistrator<File> {
public class LiteLoaderInstaller extends Task implements PreviousResultRegistrar<File> {
public LiteLoaderVersionList.LiteLoaderInstallerVersion version;
public File installer;

View File

@@ -24,7 +24,7 @@ import org.jackhuang.hellominecraft.C;
import org.jackhuang.hellominecraft.launcher.settings.Profile;
import org.jackhuang.hellominecraft.tasks.Task;
import org.jackhuang.hellominecraft.tasks.communication.PreviousResult;
import org.jackhuang.hellominecraft.tasks.communication.PreviousResultRegistrator;
import org.jackhuang.hellominecraft.tasks.communication.PreviousResultRegistrar;
import org.jackhuang.hellominecraft.utils.system.FileUtils;
import org.jackhuang.hellominecraft.launcher.version.MinecraftLibrary;
import org.jackhuang.hellominecraft.launcher.version.MinecraftVersion;
@@ -33,7 +33,7 @@ import org.jackhuang.hellominecraft.launcher.version.MinecraftVersion;
*
* @author huangyuhui
*/
public class OptiFineInstaller extends Task implements PreviousResultRegistrator<File> {
public class OptiFineInstaller extends Task implements PreviousResultRegistrar<File> {
public File installer;
public Profile profile;

View File

@@ -22,8 +22,11 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.TreeMap;
import org.jackhuang.hellominecraft.C;
import org.jackhuang.hellominecraft.HMCLog;
@@ -38,9 +41,9 @@ import org.jackhuang.hellominecraft.launcher.utils.auth.UserProfileProvider;
import org.jackhuang.hellominecraft.launcher.utils.download.DownloadType;
import org.jackhuang.hellominecraft.launcher.settings.Profile;
import org.jackhuang.hellominecraft.launcher.settings.Settings;
import org.jackhuang.hellominecraft.launcher.utils.ModInfo;
import org.jackhuang.hellominecraft.utils.system.IOUtils;
import org.jackhuang.hellominecraft.utils.system.MessageBox;
import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.utils.Utils;
/**
@@ -115,13 +118,8 @@ public final class MinecraftVersionManager extends IMinecraftProvider {
jsons[0].renameTo(new File(jsons[0].getParent(), id + ".json"));
}
if (!jsonFile.exists()) {
if (StrUtils.formatVersion(id) == null) {
if (MessageBox.Show(C.i18n("launcher.versions_json_not_matched_cannot_auto_completion", id), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
FileUtils.deleteDirectoryQuietly(dir);
} else if (MessageBox.Show(C.i18n("launcher.versions_json_not_matched_needs_auto_completion", id), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
if (!refreshJson(id))
if (MessageBox.Show(C.i18n("launcher.versions_json_not_matched_cannot_auto_completion", id), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
FileUtils.deleteDirectoryQuietly(dir);
if (MessageBox.Show(C.i18n("launcher.versions_json_not_matched_cannot_auto_completion", id), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
FileUtils.deleteDirectoryQuietly(dir);
continue;
}
MinecraftVersion mcVersion;
@@ -130,7 +128,7 @@ public final class MinecraftVersionManager extends IMinecraftProvider {
if (mcVersion == null) throw new RuntimeException("Wrong json format, got null.");
} catch (IOException | RuntimeException e) {
HMCLog.warn("Found wrong format json, try to fix it.", e);
if (MessageBox.Show(C.i18n("launcher.versions_json_not_formattedn", id), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) {
if (MessageBox.Show(C.i18n("launcher.versions_json_not_formatted", id), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) {
refreshJson(id);
try {
mcVersion = gson.fromJson(FileUtils.readFileToString(jsonFile), MinecraftVersion.class);
@@ -222,6 +220,29 @@ public final class MinecraftVersionManager extends IMinecraftProvider {
}
}
@Override
public List<ModInfo> listMods() {
File modsFolder = new File(getRunDirectory(profile.getSelectedMinecraftVersion().id), "mods");
ArrayList<ModInfo> mods = new ArrayList<>();
Queue<File> queue = new LinkedList<>();
queue.add(modsFolder);
while (!queue.isEmpty()) {
File dir = queue.poll();
File[] fs = dir.listFiles();
if (fs != null)
for (File f : fs)
if (ModInfo.isFileMod(f)) {
ModInfo m = ModInfo.readModInfo(f);
if (m != null)
mods.add(m);
} else if(f.isDirectory()) {
queue.add(f);
}
}
Collections.sort(mods);
return mods;
}
@Override
public List<GameLauncher.DownloadLibraryJob> getDownloadLibraries(DownloadType downloadType) {
ArrayList<DownloadLibraryJob> downloadLibraries = new ArrayList<>();

View File

@@ -17,6 +17,14 @@
package org.jackhuang.hellominecraft.launcher.views;
import java.awt.Color;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
import java.awt.dnd.DropTargetListener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
@@ -32,6 +40,9 @@ import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.TableModelEvent;
import javax.swing.table.DefaultTableModel;
import org.jackhuang.hellominecraft.C;
import org.jackhuang.hellominecraft.HMCLog;
@@ -49,6 +60,7 @@ import org.jackhuang.hellominecraft.launcher.utils.download.DownloadType;
import org.jackhuang.hellominecraft.launcher.settings.Profile;
import org.jackhuang.hellominecraft.launcher.settings.Settings;
import org.jackhuang.hellominecraft.launcher.utils.FileNameFilter;
import org.jackhuang.hellominecraft.launcher.utils.ModInfo;
import org.jackhuang.hellominecraft.launcher.version.GameDirType;
import org.jackhuang.hellominecraft.launcher.version.MinecraftVersion;
import org.jackhuang.hellominecraft.tasks.Task;
@@ -63,6 +75,8 @@ import org.jackhuang.hellominecraft.version.MinecraftVersionRequest;
import org.jackhuang.hellominecraft.utils.system.OS;
import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.utils.SwingUtils;
import org.jackhuang.hellominecraft.utils.Utils;
import org.jackhuang.hellominecraft.utils.system.FileUtils;
import org.jackhuang.hellominecraft.utils.system.Java;
import org.jackhuang.hellominecraft.version.MinecraftRemoteVersion;
import org.jackhuang.hellominecraft.version.MinecraftRemoteVersions;
@@ -72,7 +86,7 @@ import org.jackhuang.hellominecraft.views.Selector;
*
* @author huangyuhui
*/
public class GameSettingsPanel extends javax.swing.JPanel {
public class GameSettingsPanel extends javax.swing.JPanel implements DropTargetListener {
/**
* Creates new form GameSettingsPanel
@@ -161,12 +175,80 @@ public class GameSettingsPanel extends javax.swing.JPanel {
ppmManage.add(itm);
//</editor-fold>
lstExternalMods.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
if (lstExternalMods.getColumnModel().getColumnCount() > 0) {
lstExternalMods.getColumnModel().getColumn(0).setMinWidth(17);
lstExternalMods.getColumnModel().getColumn(0).setPreferredWidth(17);
lstExternalMods.getColumnModel().getColumn(0).setMaxWidth(17);
}
lstExternalMods.getSelectionModel().addListSelectionListener(e -> {
int row = lstExternalMods.getSelectedRow();
if (mods != null && 0 <= row && row < mods.size()) {
ModInfo m = mods.get(row);
boolean hasLink = m.url != null;
String text = "<html>" + (hasLink ? "<a href=\"" + m.url + "\">" : "") + m.getName() + (hasLink ? "</a>" : "");
if (m.authorList != null && m.authorList.length > 0)
text += " by " + StrUtils.parseParams("", m.authorList, ", ");
text += "<br>" + (m.description == null ? "No mcmod.info found" : SwingUtils.getParsedJPanelText(lblModInfo, m.description));
lblModInfo.setText(text);
lblModInfo.setCursor(new java.awt.Cursor(hasLink ? java.awt.Cursor.HAND_CURSOR : java.awt.Cursor.DEFAULT_CURSOR));
}
});
((DefaultTableModel) lstExternalMods.getModel()).addTableModelListener(e -> {
if (e.getType() == TableModelEvent.UPDATE && e.getColumn() == 0) {
int row = lstExternalMods.getSelectedRow();
if (mods != null && mods.size() > row && row >= 0) {
File f = mods.get(row).location, newf;
if (f.getName().endsWith(".disabled"))
newf = new File(f.getParentFile(), f.getName().substring(0, f.getName().length() - ".disabled".length()));
else
newf = new File(f.getParentFile(), f.getName() + ".disabled");
if (f.renameTo(newf))
mods.get(row).location = newf;
}
}
});
tabVersionEdit.addChangeListener(new ChangeListener() {
boolean a = false, b = false;
@Override
public void stateChanged(ChangeEvent e) {
if (tabVersionEdit.getSelectedComponent() == pnlGameDownloads && !a) {
a = true;
refreshDownloads(Settings.getInstance().getDownloadSource());
} else if (tabVersionEdit.getSelectedComponent() == pnlAutoInstall && !b) {
b = true;
forge.refreshVersions();
}
}
});
tabInstallers.addChangeListener(new ChangeListener() {
boolean a = false, b = false, c = false;
@Override
public void stateChanged(ChangeEvent e) {
switch (tabInstallers.getSelectedIndex()) {
case 0: if (!a) forge.refreshVersions();
a = true;
break;
case 1: if (!b) optifine.refreshVersions();
b = true;
break;
case 2: if (!c) liteloader.refreshVersions();
c = true;
break;
}
}
});
for (Java j : Settings.JAVA) {
String name = j.getName();
if (name.equals("Default")) name = C.i18n("settings.default");
if (name.equals("Custom")) name = C.i18n("settings.custom");
cboJava.addItem(name);
}
dropTarget = new DropTarget(lstExternalMods, DnDConstants.ACTION_COPY_OR_MOVE, this);
}
/**
@@ -178,19 +260,6 @@ public class GameSettingsPanel extends javax.swing.JPanel {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jPanel4 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
cboProfiles = new javax.swing.JComboBox();
cboVersions = new javax.swing.JComboBox();
jLabel2 = new javax.swing.JLabel();
jPanel5 = new javax.swing.JPanel();
btnModify = new javax.swing.JButton();
btnRefreshVersions = new javax.swing.JButton();
txtMinecraftVersion = new javax.swing.JTextField();
btnNewProfile = new javax.swing.JButton();
btnRemoveProfile = new javax.swing.JButton();
btnExplore = new javax.swing.JButton();
tabVersionEdit = new javax.swing.JTabbedPane();
jPanel22 = new javax.swing.JPanel();
jLabel24 = new javax.swing.JLabel();
@@ -212,6 +281,7 @@ public class GameSettingsPanel extends javax.swing.JPanel {
cboGameDirType = new javax.swing.JComboBox();
btnChoosingJavaDir = new javax.swing.JButton();
cboJava = new javax.swing.JComboBox();
btnChoosingGameDir = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
chkDebug = new javax.swing.JCheckBox();
jLabel26 = new javax.swing.JLabel();
@@ -226,6 +296,13 @@ public class GameSettingsPanel extends javax.swing.JPanel {
txtWrapperLauncher = new javax.swing.JTextField();
jLabel31 = new javax.swing.JLabel();
txtServerIP = new javax.swing.JTextField();
jPanel6 = new javax.swing.JPanel();
jPanel7 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
lstExternalMods = new javax.swing.JTable();
btnAddMod = new javax.swing.JButton();
btnRemoveMod = new javax.swing.JButton();
lblModInfo = new javax.swing.JLabel();
pnlAutoInstall = new javax.swing.JPanel();
tabInstallers = new javax.swing.JTabbedPane();
jPanel16 = new javax.swing.JPanel();
@@ -248,152 +325,26 @@ public class GameSettingsPanel extends javax.swing.JPanel {
jScrollPane2 = new javax.swing.JScrollPane();
lstDownloads = new javax.swing.JTable();
btnRefreshGameDownloads = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jPanel4 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
cboProfiles = new javax.swing.JComboBox();
cboVersions = new javax.swing.JComboBox();
jLabel2 = new javax.swing.JLabel();
jPanel5 = new javax.swing.JPanel();
btnModify = new javax.swing.JButton();
btnRefreshVersions = new javax.swing.JButton();
txtMinecraftVersion = new javax.swing.JTextField();
btnNewProfile = new javax.swing.JButton();
btnRemoveProfile = new javax.swing.JButton();
btnExplore = new javax.swing.JButton();
btnIncludeMinecraft = new javax.swing.JButton();
setBackground(new java.awt.Color(255, 255, 255));
java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/jackhuang/hellominecraft/launcher/I18N"); // NOI18N
jLabel1.setText(bundle.getString("ui.label.profile")); // NOI18N
cboProfiles.setMinimumSize(new java.awt.Dimension(32, 23));
cboProfiles.setPreferredSize(new java.awt.Dimension(32, 23));
cboProfiles.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
cboProfilesItemStateChanged(evt);
}
});
cboVersions.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
cboVersionsItemStateChanged(evt);
}
});
jLabel2.setText(bundle.getString("ui.label.version")); // NOI18N
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cboProfiles, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jPanel4Layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cboVersions, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cboProfiles, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cboVersions, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addContainerGap(11, Short.MAX_VALUE))
);
btnModify.setText(bundle.getString("settings.manage")); // NOI18N
btnModify.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
btnModifyMouseClicked(evt);
}
});
btnRefreshVersions.setText(bundle.getString("ui.button.refresh")); // NOI18N
btnRefreshVersions.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnRefreshVersionsActionPerformed(evt);
}
});
txtMinecraftVersion.setEditable(false);
btnNewProfile.setText(bundle.getString("setupwindow.new")); // NOI18N
btnNewProfile.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNewProfileActionPerformed(evt);
}
});
btnRemoveProfile.setText(bundle.getString("ui.button.delete")); // NOI18N
btnRemoveProfile.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnRemoveProfileActionPerformed(evt);
}
});
btnExplore.setText(bundle.getString("settings.explore")); // NOI18N
btnExplore.setToolTipText("");
btnExplore.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
btnExploreMouseClicked(evt);
}
});
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGap(0, 0, 0)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(btnNewProfile, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txtMinecraftVersion))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(btnRemoveProfile, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnRefreshVersions, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(btnModify, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnExplore, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnNewProfile, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnRemoveProfile, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnExplore, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtMinecraftVersion, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnRefreshVersions, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnModify, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(0, 0, Short.MAX_VALUE))
);
tabVersionEdit.setName("tabVersionEdit"); // NOI18N
java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/jackhuang/hellominecraft/launcher/I18N"); // NOI18N
jLabel24.setText(bundle.getString("settings.game_directory")); // NOI18N
txtGameDir.addFocusListener(new java.awt.event.FocusAdapter() {
@@ -483,6 +434,13 @@ public class GameSettingsPanel extends javax.swing.JPanel {
}
});
btnChoosingGameDir.setText(bundle.getString("ui.button.explore")); // NOI18N
btnChoosingGameDir.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnChoosingGameDirActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel22Layout = new javax.swing.GroupLayout(jPanel22);
jPanel22.setLayout(jPanel22Layout);
jPanel22Layout.setHorizontalGroup(
@@ -505,7 +463,6 @@ public class GameSettingsPanel extends javax.swing.JPanel {
.addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cboGameDirType, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(cboLauncherVisibility, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txtGameDir)
.addGroup(jPanel22Layout.createSequentialGroup()
.addComponent(txtWidth, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@@ -515,16 +472,19 @@ public class GameSettingsPanel extends javax.swing.JPanel {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 320, Short.MAX_VALUE)
.addComponent(chkFullscreen))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel22Layout.createSequentialGroup()
.addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtMaxMemory)
.addGroup(jPanel22Layout.createSequentialGroup()
.addComponent(cboJava, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtJavaDir)))
.addComponent(txtMaxMemory)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btnChoosingJavaDir, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblMaxMemory, javax.swing.GroupLayout.Alignment.TRAILING))))))
.addComponent(lblMaxMemory))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel22Layout.createSequentialGroup()
.addComponent(txtGameDir)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnChoosingGameDir))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel22Layout.createSequentialGroup()
.addComponent(cboJava, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtJavaDir)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnChoosingJavaDir)))))
.addContainerGap())
);
jPanel22Layout.setVerticalGroup(
@@ -533,7 +493,8 @@ public class GameSettingsPanel extends javax.swing.JPanel {
.addContainerGap()
.addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtGameDir, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel24))
.addComponent(jLabel24)
.addComponent(btnChoosingGameDir, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtJavaDir, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
@@ -560,7 +521,7 @@ public class GameSettingsPanel extends javax.swing.JPanel {
.addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel25)
.addComponent(txtWidth, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 92, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 95, Short.MAX_VALUE)
.addComponent(btnDownloadAllAssets)
.addContainerGap())
);
@@ -684,7 +645,7 @@ public class GameSettingsPanel extends javax.swing.JPanel {
.addComponent(jLabel31)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtServerIP, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 86, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 90, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(chkDebug)
.addComponent(chkNoJVMArgs)
@@ -694,6 +655,84 @@ public class GameSettingsPanel extends javax.swing.JPanel {
tabVersionEdit.addTab(bundle.getString("advancedsettings"), jPanel2); // NOI18N
lstExternalMods.setModel(SwingUtils.makeDefaultTableModel(new String[]{"", "Mod", C.i18n("ui.label.version")}, new Class[]{Boolean.class,String.class,String.class}, new boolean[]{true,false,false}));
lstExternalMods.setColumnSelectionAllowed(true);
lstExternalMods.getTableHeader().setReorderingAllowed(false);
lstExternalMods.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
lstExternalModsKeyPressed(evt);
}
});
jScrollPane1.setViewportView(lstExternalMods);
lstExternalMods.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
btnAddMod.setText("添加");
btnAddMod.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnAddModActionPerformed(evt);
}
});
btnRemoveMod.setText("删除");
btnRemoveMod.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnRemoveModActionPerformed(evt);
}
});
lblModInfo.setText(bundle.getString("mods.default_information")); // NOI18N
lblModInfo.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
lblModInfo.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
lblModInfoMouseClicked(evt);
}
});
javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
jPanel7.setLayout(jPanel7Layout);
jPanel7Layout.setHorizontalGroup(
jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel7Layout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 606, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btnRemoveMod)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
.addComponent(btnAddMod)
.addContainerGap())))
.addGroup(jPanel7Layout.createSequentialGroup()
.addContainerGap()
.addComponent(lblModInfo)
.addContainerGap())
);
jPanel7Layout.setVerticalGroup(
jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel7Layout.createSequentialGroup()
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel7Layout.createSequentialGroup()
.addComponent(btnAddMod)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnRemoveMod)
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 279, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblModInfo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
jPanel6.setLayout(jPanel6Layout);
jPanel6Layout.setHorizontalGroup(
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
jPanel6Layout.setVerticalGroup(
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
tabVersionEdit.addTab(bundle.getString("mods"), jPanel6); // NOI18N
lstForge.setModel(SwingUtils.makeDefaultTableModel(new String[]{C.I18N.getString("install.version"), C.I18N.getString("install.mcversion")},
new Class[]{String.class, String.class}, new boolean[]{false, false}));
lstForge.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
@@ -727,7 +766,7 @@ public class GameSettingsPanel extends javax.swing.JPanel {
);
jPanel16Layout.setVerticalGroup(
jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane11, javax.swing.GroupLayout.DEFAULT_SIZE, 292, Short.MAX_VALUE)
.addComponent(jScrollPane11, javax.swing.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE)
.addGroup(jPanel16Layout.createSequentialGroup()
.addComponent(btnDownloadForge)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@@ -775,7 +814,7 @@ btnRefreshOptifine.addActionListener(new java.awt.event.ActionListener() {
.addComponent(btnDownloadOptifine)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnRefreshOptifine)
.addGap(0, 240, Short.MAX_VALUE))
.addGap(0, 244, Short.MAX_VALUE))
);
tabInstallers.addTab("OptiFine", pnlOptifine);
@@ -813,7 +852,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane12, javax.swing.GroupLayout.DEFAULT_SIZE, 292, Short.MAX_VALUE)
.addComponent(jScrollPane12, javax.swing.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(btnInstallLiteLoader)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@@ -873,11 +912,150 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
.addComponent(btnRefreshGameDownloads)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnDownload))
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 325, Short.MAX_VALUE)
);
tabVersionEdit.addTab(bundle.getString("settings.tabs.game_download"), pnlGameDownloads); // NOI18N
jLabel1.setText(bundle.getString("ui.label.profile")); // NOI18N
cboProfiles.setMinimumSize(new java.awt.Dimension(32, 23));
cboProfiles.setPreferredSize(new java.awt.Dimension(32, 23));
cboProfiles.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
cboProfilesItemStateChanged(evt);
}
});
cboVersions.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
cboVersionsItemStateChanged(evt);
}
});
jLabel2.setText(bundle.getString("ui.label.version")); // NOI18N
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cboProfiles, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jPanel4Layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cboVersions, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cboProfiles, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cboVersions, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addContainerGap(11, Short.MAX_VALUE))
);
btnModify.setText(bundle.getString("settings.manage")); // NOI18N
btnModify.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
btnModifyMouseClicked(evt);
}
});
btnRefreshVersions.setText(bundle.getString("ui.button.refresh")); // NOI18N
btnRefreshVersions.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnRefreshVersionsActionPerformed(evt);
}
});
txtMinecraftVersion.setEditable(false);
btnNewProfile.setText(bundle.getString("setupwindow.new")); // NOI18N
btnNewProfile.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNewProfileActionPerformed(evt);
}
});
btnRemoveProfile.setText(bundle.getString("ui.button.delete")); // NOI18N
btnRemoveProfile.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnRemoveProfileActionPerformed(evt);
}
});
btnExplore.setText(bundle.getString("settings.explore")); // NOI18N
btnExplore.setToolTipText("");
btnExplore.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
btnExploreMouseClicked(evt);
}
});
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGap(0, 0, 0)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(btnNewProfile, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(txtMinecraftVersion))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(btnRemoveProfile, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnRefreshVersions, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(btnModify, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnExplore, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnNewProfile, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnRemoveProfile, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnExplore, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtMinecraftVersion, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnRefreshVersions, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnModify, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(0, 0, Short.MAX_VALUE))
);
btnIncludeMinecraft.setText(bundle.getString("setupwindow.include_minecraft")); // NOI18N
btnIncludeMinecraft.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@@ -1174,6 +1352,82 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
}
}//GEN-LAST:event_cboJavaItemStateChanged
private void btnAddModActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddModActionPerformed
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
fc.setDialogTitle(C.I18N.getString("mods.choose_mod"));
fc.setMultiSelectionEnabled(true);
if (fc.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) return;
boolean flag = false;
for (File f : fc.getSelectedFiles())
if (!addMod(f)) flag |= true;
if (flag)
MessageBox.Show(C.I18N.getString("mods.failed"));
}//GEN-LAST:event_btnAddModActionPerformed
boolean addMod(File f) {
try {
if (!ModInfo.isFileMod(f) || mods == null) return false;
File newf = profile.getFolder("mods");
newf.mkdirs();
newf = new File(newf, f.getName());
FileUtils.copyFile(f, newf);
ModInfo i = ModInfo.readModInfo(f);
mods.add(i);
((DefaultTableModel) lstExternalMods.getModel()).addRow(new Object[]{i.isActive(), i.location.getName(), i.version});
return true;
} catch (IOException ex) {
HMCLog.warn("Failed to copy mod", ex);
return false;
}
}
private void btnRemoveModActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveModActionPerformed
DefaultTableModel model = (DefaultTableModel) lstExternalMods.getModel();
int[] rows = lstExternalMods.getSelectedRows();
Arrays.sort(rows);
int removed = 0;
for (int idx : rows) {
ModInfo mi = mods.get(idx - removed);
File f = mi.location;
mods.remove(idx - removed);
model.removeRow(idx - removed);
removed++;
f.delete();
}
}//GEN-LAST:event_btnRemoveModActionPerformed
private void lstExternalModsKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_lstExternalModsKeyPressed
btnRemoveModActionPerformed(null);
}//GEN-LAST:event_lstExternalModsKeyPressed
private void lblModInfoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblModInfoMouseClicked
int idx = lstExternalMods.getSelectedRow();
if (idx > 0 && idx < mods.size()) {
ModInfo m = mods.get(idx);
if (m.url != null)
Utils.openLink(m.url);
}
}//GEN-LAST:event_lblModInfoMouseClicked
private void btnChoosingGameDirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnChoosingGameDirActionPerformed
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.setDialogTitle(C.i18n("settings.choose_gamedir"));
fc.setMultiSelectionEnabled(false);
fc.showOpenDialog(this);
if (fc.getSelectedFile() == null)
return;
try {
String path = fc.getSelectedFile().getCanonicalPath();
txtGameDir.setText(path);
profile.setGameDir(path);
} catch (IOException e) {
HMCLog.warn("Failed to set game dir.", e);
MessageBox.Show(C.i18n("ui.label.failed_set") + e.getMessage());
}
}//GEN-LAST:event_btnChoosingGameDirActionPerformed
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Load">
private void loadProfiles() {
@@ -1250,6 +1504,8 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
}
isLoading = false;
if (index < cboVersions.getItemCount()) cboVersions.setSelectedIndex(index);
reloadMods();
}
void loadMinecraftVersion() {
@@ -1343,6 +1599,36 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
return minecraftVersion == null ? "" : (StrUtils.formatVersion(minecraftVersion.version) == null) ? mcVersion : minecraftVersion.version;
}
@Override
public void dragEnter(DropTargetDragEvent dtde) {
DataFlavor[] f = dtde.getCurrentDataFlavors();
if (f[0].match(DataFlavor.javaFileListFlavor))
try {
Transferable tr = dtde.getTransferable();
List<File> files = (List<File>) tr.getTransferData(DataFlavor.javaFileListFlavor);
for (File file : files)
addMod(file);
} catch (Exception ex) {
HMCLog.warn("Failed to drop file.", ex);
}
}
@Override
public void dragOver(DropTargetDragEvent dtde) {
}
@Override
public void dropActionChanged(DropTargetDragEvent dtde) {
}
@Override
public void dragExit(DropTargetEvent dte) {
}
@Override
public void drop(DropTargetDropEvent dtde) {
}
class InstallerHelper {
List<InstallerVersionList.InstallerVersion> versions;
@@ -1406,6 +1692,17 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
String mcVersion;
// </editor-fold>
// <editor-fold>
List<ModInfo> mods;
private void reloadMods() {
mods = profile.getMinecraftProvider().listMods();
SwingUtils.clearDefaultTable(lstExternalMods);
DefaultTableModel model = (DefaultTableModel) lstExternalMods.getModel();
for (ModInfo info : mods)
model.addRow(new Object[]{info.isActive(), info.getFileName(), info.version});
}
// </editor-fold>
public void versionChanged(Profile profile, String version) {
this.mcVersion = version;
@@ -1413,6 +1710,8 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
optifine.loadVersions();
liteloader.loadVersions();
reloadMods();
MinecraftVersion v = profile.getMinecraftProvider().getVersionById(version);
if (v != null)
for (IAssetsHandler ph : IAssetsHandler.getAssetsHandlers())
@@ -1433,7 +1732,11 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
// <editor-fold defaultstate="collapsed" desc="UI Definations">
JPopupMenu ppmManage, ppmExplore;
DropTarget dropTarget;
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnAddMod;
private javax.swing.JButton btnChoosingGameDir;
private javax.swing.JButton btnChoosingJavaDir;
private javax.swing.JButton btnDownload;
private javax.swing.JButton btnDownloadAllAssets;
@@ -1449,6 +1752,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
private javax.swing.JButton btnRefreshLiteLoader;
private javax.swing.JButton btnRefreshOptifine;
private javax.swing.JButton btnRefreshVersions;
private javax.swing.JButton btnRemoveMod;
private javax.swing.JButton btnRemoveProfile;
private javax.swing.JComboBox cboGameDirType;
private javax.swing.JComboBox cboJava;
@@ -1480,12 +1784,17 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5;
private javax.swing.JPanel jPanel6;
private javax.swing.JPanel jPanel7;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane11;
private javax.swing.JScrollPane jScrollPane12;
private javax.swing.JScrollPane jScrollPane13;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JLabel lblMaxMemory;
private javax.swing.JLabel lblModInfo;
private javax.swing.JTable lstDownloads;
private javax.swing.JTable lstExternalMods;
private javax.swing.JTable lstForge;
private javax.swing.JTable lstLiteLoader;
private javax.swing.JTable lstOptifine;